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

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

Issue 1028333002: Chromium -> Mojo roll. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 5 years, 9 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
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 22f826f1c2acaece6cb92892491fbabda49a710e..caf30af3e99d8abad139ab462f2c966df9442ef4 100644
--- a/gpu/command_buffer/common/gles2_cmd_utils.cc
+++ b/gpu/command_buffer/common/gles2_cmd_utils.cc
@@ -404,13 +404,14 @@ int ElementsPerGroup(int format, int type) {
// Return the number of bytes per element, based on the element type.
int BytesPerElement(int type) {
switch (type) {
+ case GL_FLOAT_32_UNSIGNED_INT_24_8_REV:
+ return 8;
case GL_FLOAT:
case GL_UNSIGNED_INT_24_8_OES:
case GL_UNSIGNED_INT:
case GL_UNSIGNED_INT_2_10_10_10_REV:
case GL_UNSIGNED_INT_10F_11F_11F_REV:
case GL_UNSIGNED_INT_5_9_9_9_REV:
- case GL_FLOAT_32_UNSIGNED_INT_24_8_REV:
return 4;
case GL_HALF_FLOAT_OES:
case GL_UNSIGNED_SHORT:
@@ -430,12 +431,18 @@ int BytesPerElement(int type) {
} // anonymous namespace
uint32 GLES2Util::ComputeImageGroupSize(int format, int type) {
- return BytesPerElement(type) * ElementsPerGroup(format, type);
+ int bytes_per_element = BytesPerElement(type);
+ DCHECK_GE(8, bytes_per_element);
+ int elements_per_group = ElementsPerGroup(format, type);
+ DCHECK_GE(4, elements_per_group);
+ return bytes_per_element * elements_per_group;
}
bool GLES2Util::ComputeImagePaddedRowSize(
int width, int format, int type, int unpack_alignment,
uint32* padded_row_size) {
+ DCHECK(unpack_alignment == 1 || unpack_alignment == 2 ||
+ unpack_alignment == 4 || unpack_alignment == 8);
uint32 bytes_per_group = ComputeImageGroupSize(format, type);
uint32 unpadded_row_size;
if (!SafeMultiplyUint32(width, bytes_per_group, &unpadded_row_size)) {
@@ -454,6 +461,8 @@ bool GLES2Util::ComputeImageDataSizes(
int width, int height, int depth, int format, int type,
int unpack_alignment, uint32* size, uint32* ret_unpadded_row_size,
uint32* ret_padded_row_size) {
+ DCHECK(unpack_alignment == 1 || unpack_alignment == 2 ||
+ unpack_alignment == 4 || unpack_alignment == 8);
uint32 bytes_per_group = ComputeImageGroupSize(format, type);
uint32 row_size;
if (!SafeMultiplyUint32(width, bytes_per_group, &row_size)) {
« no previous file with comments | « gpu/command_buffer/common/gles2_cmd_utils.h ('k') | gpu/command_buffer/common/gles2_cmd_utils_implementation_autogen.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698