Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(257)

Unified Diff: gpu/command_buffer/common/gles2_cmd_utils.cc

Issue 10012057: Add GL_EXT_unpack_subimage support to command buffer client code. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « gpu/command_buffer/common/gles2_cmd_utils.h ('k') | gpu/command_buffer/common/gles2_cmd_utils_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: gpu/command_buffer/common/gles2_cmd_utils.cc
===================================================================
--- gpu/command_buffer/common/gles2_cmd_utils.cc (revision 131422)
+++ gpu/command_buffer/common/gles2_cmd_utils.cc (working copy)
@@ -373,12 +373,31 @@
} // anonymous namespace
+uint32 GLES2Util::ComputeImageGroupSize(int format, int type) {
+ return BytesPerElement(type) * ElementsPerGroup(format, type);
+}
+
+bool GLES2Util::ComputeImagePaddedRowSize(
+ int width, int format, int type, int unpack_alignment,
+ uint32* padded_row_size) {
+ uint32 bytes_per_group = ComputeImageGroupSize(format, type);
+ uint32 unpadded_row_size;
+ if (!SafeMultiplyUint32(width, bytes_per_group, &unpadded_row_size)) {
+ return false;
+ }
+ uint32 temp;
+ if (!SafeAddUint32(unpadded_row_size, unpack_alignment - 1, &temp)) {
+ return false;
+ }
+ *padded_row_size = (temp / unpack_alignment) * unpack_alignment;
+ return true;
+}
+
// Returns the amount of data glTexImage2D or glTexSubImage2D will access.
-bool GLES2Util::ComputeImageDataSize(
+bool GLES2Util::ComputeImageDataSizes(
int width, int height, int format, int type, int unpack_alignment,
- uint32* size) {
- uint32 bytes_per_group =
- BytesPerElement(type) * ElementsPerGroup(format, type);
+ uint32* size, uint32* ret_unpadded_row_size, uint32* ret_padded_row_size) {
+ uint32 bytes_per_group = ComputeImageGroupSize(format, type);
uint32 row_size;
if (!SafeMultiplyUint32(width, bytes_per_group, &row_size)) {
return false;
@@ -397,11 +416,21 @@
if (!SafeAddUint32(size_of_all_but_last_row, row_size, size)) {
return false;
}
+ if (ret_padded_row_size) {
+ *ret_padded_row_size = padded_row_size;
+ }
} else {
if (!SafeMultiplyUint32(height, row_size, size)) {
return false;
}
+ if (ret_padded_row_size) {
+ *ret_padded_row_size = row_size;
+ }
}
+ if (ret_unpadded_row_size) {
+ *ret_unpadded_row_size = row_size;
+ }
+
return true;
}
« no previous file with comments | « gpu/command_buffer/common/gles2_cmd_utils.h ('k') | gpu/command_buffer/common/gles2_cmd_utils_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698