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

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

Issue 1508953002: Implement helper functionalities for computing image size with ES3 settings. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years 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
diff --git a/gpu/command_buffer/common/gles2_cmd_utils.cc b/gpu/command_buffer/common/gles2_cmd_utils.cc
index 8b547fa2455f68e447ec69ab26fec23e01dd7f16..1e8a49be5f02310220de4935c8dcd97daabd13f0 100644
--- a/gpu/command_buffer/common/gles2_cmd_utils.cc
+++ b/gpu/command_buffer/common/gles2_cmd_utils.cc
@@ -543,28 +543,21 @@ bool GLES2Util::ComputeImageDataSizes(
if (!SafeMultiplyUint32(height, depth, &num_of_rows)) {
return false;
}
- if (num_of_rows > 1) {
- uint32 temp;
- if (!SafeAddUint32(row_size, unpack_alignment - 1, &temp)) {
- return false;
- }
- uint32 padded_row_size = (temp / unpack_alignment) * unpack_alignment;
- uint32 size_of_all_but_last_row;
- if (!SafeMultiplyUint32((num_of_rows - 1), padded_row_size,
- &size_of_all_but_last_row)) {
- return false;
- }
- 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 {
- *size = row_size;
- if (ret_padded_row_size) {
- *ret_padded_row_size = row_size;
- }
+ uint32 temp;
+ if (!SafeAddUint32(row_size, unpack_alignment - 1, &temp)) {
+ return false;
+ }
+ uint32 padded_row_size = (temp / unpack_alignment) * unpack_alignment;
+ uint32 size_of_all_but_last_row;
+ if (!SafeMultiplyUint32((num_of_rows - 1), padded_row_size,
+ &size_of_all_but_last_row)) {
+ return false;
+ }
+ 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;
}
if (ret_unpadded_row_size) {
*ret_unpadded_row_size = row_size;
@@ -573,6 +566,49 @@ bool GLES2Util::ComputeImageDataSizes(
return true;
}
+bool GLES2Util::ComputeImageDataSizes(
+ int width, int height, int depth, int format, int type,
+ const PixelStoreParams& params,
+ uint32_t* size, uint32_t* unpadded_row_size,
+ uint32_t* padded_row_size, uint32_t* skip_size) {
+ int actual_width = params.row_length > 0 ? params.row_length : width;
piman 2015/12/08 00:06:10 So, technically, the code (whether client-side, or
Zhenyao Mo 2015/12/08 23:39:17 Done. However, I think we still need the ContextS
+ int actual_height = params.image_height > 0 ? params.image_height : height;
+ if (!ComputeImageDataSizes(actual_width, actual_height, depth, format, type,
+ params.alignment,
+ size, unpadded_row_size, padded_row_size)) {
+ return false;
+ }
+
+ uint32 total_skip_size = 0;
+ if (params.skip_images > 0) {
+ uint32 image_size;
+ if (!SafeMultiplyUint32(actual_height, *padded_row_size, &image_size))
+ return false;
+ if (!SafeMultiplyUint32(image_size, params.skip_images, &total_skip_size))
+ return false;
+ }
+ if (params.skip_rows > 0) {
+ uint32 temp;
+ if (!SafeMultiplyUint32(*padded_row_size, params.skip_rows, &temp))
+ return false;
+ if (!SafeAddUint32(total_skip_size, temp, &total_skip_size))
+ return false;
+ }
+ if (params.skip_pixels > 0) {
+ uint32 bytes_per_group = ComputeImageGroupSize(format, type);
+ uint32 temp;
+ if (!SafeMultiplyUint32(bytes_per_group, params.skip_pixels, &temp))
+ return false;
+ if (!SafeAddUint32(total_skip_size, temp, &total_skip_size))
+ return false;
+ }
+ if (!SafeAddUint32(*size, total_skip_size, size))
piman 2015/12/08 00:06:10 I think this is more confusing than useful. Only |
Zhenyao Mo 2015/12/08 23:39:17 OK, I won't write into size, but we still wanna ch
+ return false;
+ if (skip_size)
+ *skip_size = total_skip_size;
+ return true;
+}
+
size_t GLES2Util::RenderbufferBytesPerPixel(int format) {
switch (format) {
case GL_STENCIL_INDEX8:
« 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