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

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

Issue 1542513002: Switch to standard integer types in gpu/. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix 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 c0a5cd5ec714ce808cf9e5682a055775d5f7eb79..0d07f4e0c359d9a8fbd359879f16e9d7bf67d9e7 100644
--- a/gpu/command_buffer/common/gles2_cmd_utils.cc
+++ b/gpu/command_buffer/common/gles2_cmd_utils.cc
@@ -501,7 +501,7 @@ int BytesPerElement(int type) {
} // anonymous namespace
-uint32 GLES2Util::ComputeImageGroupSize(int format, int type) {
+uint32_t GLES2Util::ComputeImageGroupSize(int format, int type) {
int bytes_per_element = BytesPerElement(type);
DCHECK_GE(8, bytes_per_element);
int elements_per_group = ElementsPerGroup(format, type);
@@ -509,20 +509,22 @@ uint32 GLES2Util::ComputeImageGroupSize(int format, int type) {
return bytes_per_element * elements_per_group;
}
-bool GLES2Util::ComputeImageRowSizeHelper(
- int width, uint32 bytes_per_group, int alignment,
- uint32* rt_unpadded_row_size, uint32* rt_padded_row_size) {
+bool GLES2Util::ComputeImageRowSizeHelper(int width,
+ uint32_t bytes_per_group,
+ int alignment,
+ uint32_t* rt_unpadded_row_size,
+ uint32_t* rt_padded_row_size) {
DCHECK(alignment == 1 || alignment == 2 ||
alignment == 4 || alignment == 8);
- uint32 unpadded_row_size;
+ uint32_t unpadded_row_size;
if (!SafeMultiplyUint32(width, bytes_per_group, &unpadded_row_size)) {
return false;
}
- uint32 temp;
+ uint32_t temp;
if (!SafeAddUint32(unpadded_row_size, alignment - 1, &temp)) {
return false;
}
- uint32 padded_row_size = (temp / alignment) * alignment;
+ uint32_t padded_row_size = (temp / alignment) * alignment;
if (rt_unpadded_row_size)
*rt_unpadded_row_size = unpadded_row_size;
if (rt_padded_row_size)
@@ -530,18 +532,26 @@ bool GLES2Util::ComputeImageRowSizeHelper(
return true;
}
-bool GLES2Util::ComputeImagePaddedRowSize(
- int width, int format, int type, int alignment, uint32* padded_row_size) {
- uint32 bytes_per_group = ComputeImageGroupSize(format, type);
+bool GLES2Util::ComputeImagePaddedRowSize(int width,
+ int format,
+ int type,
+ int alignment,
+ uint32_t* padded_row_size) {
+ uint32_t bytes_per_group = ComputeImageGroupSize(format, type);
return ComputeImageRowSizeHelper(
width, bytes_per_group, alignment, nullptr, padded_row_size);
}
// Returns the amount of data glTexImage*D or glTexSubImage*D will access.
-bool GLES2Util::ComputeImageDataSizes(
- int width, int height, int depth, int format, int type,
- int alignment, uint32* size, uint32* opt_unpadded_row_size,
- uint32* opt_padded_row_size) {
+bool GLES2Util::ComputeImageDataSizes(int width,
+ int height,
+ int depth,
+ int format,
+ int type,
+ int alignment,
+ uint32_t* size,
+ uint32_t* opt_unpadded_row_size,
+ uint32_t* opt_padded_row_size) {
PixelStoreParams params;
params.alignment = alignment;
return ComputeImageDataSizesES3(
@@ -556,10 +566,10 @@ bool GLES2Util::ComputeImageDataSizesES3(
uint32_t* opt_padded_row_size, uint32_t* opt_skip_size) {
DCHECK(width >= 0 && height >= 0 && depth >= 0);
- uint32 bytes_per_group = ComputeImageGroupSize(format, type);
+ uint32_t bytes_per_group = ComputeImageGroupSize(format, type);
- uint32 unpadded_row_size;
- uint32 padded_row_size;
+ uint32_t unpadded_row_size;
+ uint32_t padded_row_size;
if (!ComputeImageRowSizeHelper(width, bytes_per_group, params.alignment,
&unpadded_row_size, &padded_row_size)) {
return false;
@@ -573,7 +583,7 @@ bool GLES2Util::ComputeImageDataSizesES3(
}
int image_height = params.image_height > 0 ? params.image_height : height;
- uint32 num_of_rows;
+ uint32_t num_of_rows;
if (depth > 0) {
if (!SafeMultiplyUint32(image_height, depth - 1, &num_of_rows) ||
!SafeAddUint32(num_of_rows, height, &num_of_rows)) {
@@ -584,7 +594,7 @@ bool GLES2Util::ComputeImageDataSizesES3(
}
if (num_of_rows > 0) {
- uint32 size_of_all_but_last_row;
+ uint32_t size_of_all_but_last_row;
if (!SafeMultiplyUint32((num_of_rows - 1), padded_row_size,
&size_of_all_but_last_row)) {
return false;
@@ -596,29 +606,29 @@ bool GLES2Util::ComputeImageDataSizesES3(
*size = 0;
}
- uint32 skip_size = 0;
+ uint32_t skip_size = 0;
if (params.skip_images > 0) {
- uint32 image_size;
+ uint32_t image_size;
if (!SafeMultiplyUint32(image_height, padded_row_size, &image_size))
return false;
if (!SafeMultiplyUint32(image_size, params.skip_images, &skip_size))
return false;
}
if (params.skip_rows > 0) {
- uint32 temp;
+ uint32_t temp;
if (!SafeMultiplyUint32(padded_row_size, params.skip_rows, &temp))
return false;
if (!SafeAddUint32(skip_size, temp, &skip_size))
return false;
}
if (params.skip_pixels > 0) {
- uint32 temp;
+ uint32_t temp;
if (!SafeMultiplyUint32(bytes_per_group, params.skip_pixels, &temp))
return false;
if (!SafeAddUint32(skip_size, temp, &skip_size))
return false;
}
- uint32 total_size;
+ uint32_t total_size;
if (!SafeAddUint32(*size, skip_size, &total_size))
return false;
@@ -654,7 +664,7 @@ size_t GLES2Util::RenderbufferBytesPerPixel(int format) {
}
}
-uint32 GLES2Util::GetElementSizeForUniformType(int type) {
+uint32_t GLES2Util::GetElementSizeForUniformType(int type) {
switch (type) {
case GL_FLOAT:
case GL_FLOAT_VEC2:
@@ -711,7 +721,7 @@ uint32 GLES2Util::GetElementSizeForUniformType(int type) {
}
}
-uint32 GLES2Util::GetElementCountForUniformType(int type) {
+uint32_t GLES2Util::GetElementCountForUniformType(int type) {
switch (type) {
case GL_FLOAT:
case GL_INT:
@@ -776,7 +786,7 @@ uint32 GLES2Util::GetElementCountForUniformType(int type) {
}
}
-size_t GLES2Util::GetGLTypeSizeForTexturesAndBuffers(uint32 type) {
+size_t GLES2Util::GetGLTypeSizeForTexturesAndBuffers(uint32_t type) {
switch (type) {
case GL_BYTE:
return sizeof(GLbyte); // NOLINT
@@ -799,7 +809,7 @@ size_t GLES2Util::GetGLTypeSizeForTexturesAndBuffers(uint32 type) {
}
}
-size_t GLES2Util::GetComponentCountForGLTransformType(uint32 type) {
+size_t GLES2Util::GetComponentCountForGLTransformType(uint32_t type) {
switch (type) {
case GL_TRANSLATE_X_CHROMIUM:
case GL_TRANSLATE_Y_CHROMIUM:
@@ -833,7 +843,7 @@ size_t GLES2Util::GetCoefficientCountForGLPathFragmentInputGenMode(
}
}
-size_t GLES2Util::GetGLTypeSizeForPathCoordType(uint32 type) {
+size_t GLES2Util::GetGLTypeSizeForPathCoordType(uint32_t type) {
switch (type) {
case GL_BYTE:
return sizeof(GLbyte); // NOLINT
@@ -850,7 +860,7 @@ size_t GLES2Util::GetGLTypeSizeForPathCoordType(uint32 type) {
}
}
-size_t GLES2Util::GetGLTypeSizeForGLPathNameType(uint32 type) {
+size_t GLES2Util::GetGLTypeSizeForGLPathNameType(uint32_t type) {
switch (type) {
case GL_BYTE:
return sizeof(GLbyte); // NOLINT
@@ -869,7 +879,7 @@ size_t GLES2Util::GetGLTypeSizeForGLPathNameType(uint32 type) {
}
}
-uint32 GLES2Util::GLErrorToErrorBit(uint32 error) {
+uint32_t GLES2Util::GLErrorToErrorBit(uint32_t error) {
switch (error) {
case GL_INVALID_ENUM:
return gl_error_bit::kInvalidEnum;
@@ -889,7 +899,7 @@ uint32 GLES2Util::GLErrorToErrorBit(uint32 error) {
}
}
-uint32 GLES2Util::GLErrorBitToGLError(uint32 error_bit) {
+uint32_t GLES2Util::GLErrorBitToGLError(uint32_t error_bit) {
switch (error_bit) {
case gl_error_bit::kInvalidEnum:
return GL_INVALID_ENUM;
@@ -909,19 +919,16 @@ uint32 GLES2Util::GLErrorBitToGLError(uint32 error_bit) {
}
}
-uint32 GLES2Util::IndexToGLFaceTarget(int index) {
- static uint32 faces[] = {
- GL_TEXTURE_CUBE_MAP_POSITIVE_X,
- GL_TEXTURE_CUBE_MAP_NEGATIVE_X,
- GL_TEXTURE_CUBE_MAP_POSITIVE_Y,
- GL_TEXTURE_CUBE_MAP_NEGATIVE_Y,
- GL_TEXTURE_CUBE_MAP_POSITIVE_Z,
- GL_TEXTURE_CUBE_MAP_NEGATIVE_Z,
+uint32_t GLES2Util::IndexToGLFaceTarget(int index) {
+ static uint32_t faces[] = {
+ GL_TEXTURE_CUBE_MAP_POSITIVE_X, GL_TEXTURE_CUBE_MAP_NEGATIVE_X,
+ GL_TEXTURE_CUBE_MAP_POSITIVE_Y, GL_TEXTURE_CUBE_MAP_NEGATIVE_Y,
+ GL_TEXTURE_CUBE_MAP_POSITIVE_Z, GL_TEXTURE_CUBE_MAP_NEGATIVE_Z,
};
return faces[index];
}
-size_t GLES2Util::GLTargetToFaceIndex(uint32 target) {
+size_t GLES2Util::GLTargetToFaceIndex(uint32_t target) {
switch (target) {
case GL_TEXTURE_2D:
case GL_TEXTURE_EXTERNAL_OES:
@@ -947,8 +954,8 @@ size_t GLES2Util::GLTargetToFaceIndex(uint32 target) {
}
}
-uint32 GLES2Util::GetGLReadPixelsImplementationFormat(
- uint32 internal_format) {
+uint32_t GLES2Util::GetGLReadPixelsImplementationFormat(
+ uint32_t internal_format) {
switch (internal_format) {
case GL_R8:
case GL_R16F:
@@ -992,8 +999,8 @@ uint32 GLES2Util::GetGLReadPixelsImplementationFormat(
}
}
-uint32 GLES2Util::GetGLReadPixelsImplementationType(
- uint32 internal_format, uint32 texture_type) {
+uint32_t GLES2Util::GetGLReadPixelsImplementationType(uint32_t internal_format,
+ uint32_t texture_type) {
switch (internal_format) {
case GL_R16UI:
case GL_RG16UI:
@@ -1048,7 +1055,7 @@ uint32 GLES2Util::GetGLReadPixelsImplementationType(
}
}
-uint32 GLES2Util::GetChannelsForFormat(int format) {
+uint32_t GLES2Util::GetChannelsForFormat(int format) {
switch (format) {
case GL_ALPHA:
case GL_ALPHA16F_EXT:
@@ -1136,8 +1143,9 @@ uint32 GLES2Util::GetChannelsForFormat(int format) {
}
}
-uint32 GLES2Util::GetChannelsNeededForAttachmentType(
- int type, uint32 max_color_attachments) {
+uint32_t GLES2Util::GetChannelsNeededForAttachmentType(
+ int type,
+ uint32_t max_color_attachments) {
switch (type) {
case GL_DEPTH_ATTACHMENT:
return kDepth;
@@ -1153,7 +1161,7 @@ uint32 GLES2Util::GetChannelsNeededForAttachmentType(
}
}
-std::string GLES2Util::GetStringEnum(uint32 value) {
+std::string GLES2Util::GetStringEnum(uint32_t value) {
const EnumToString* entry = enum_to_string_table_;
const EnumToString* end = entry + enum_to_string_table_len_;
for (;entry < end; ++entry) {
@@ -1168,7 +1176,7 @@ std::string GLES2Util::GetStringEnum(uint32 value) {
return "0x" + ss.str();
}
-std::string GLES2Util::GetStringError(uint32 value) {
+std::string GLES2Util::GetStringError(uint32_t value) {
static EnumToString string_table[] = {
{ GL_NONE, "GL_NONE" },
};
@@ -1176,12 +1184,13 @@ std::string GLES2Util::GetStringError(uint32 value) {
string_table, arraysize(string_table), value);
}
-std::string GLES2Util::GetStringBool(uint32 value) {
+std::string GLES2Util::GetStringBool(uint32_t value) {
return value ? "GL_TRUE" : "GL_FALSE";
}
-std::string GLES2Util::GetQualifiedEnumString(
- const EnumToString* table, size_t count, uint32 value) {
+std::string GLES2Util::GetQualifiedEnumString(const EnumToString* table,
+ size_t count,
+ uint32_t value) {
for (const EnumToString* end = table + count; table < end; ++table) {
if (table->value == value) {
return table->name;
@@ -1203,7 +1212,7 @@ GLSLArrayName::GLSLArrayName(const std::string& name) : element_index_(-1) {
base::CheckedNumeric<int> index = 0;
size_t last = name.size() - 1;
for (size_t pos = open_pos + 1; pos < last; ++pos) {
- int8 digit = name[pos] - '0';
+ int8_t digit = name[pos] - '0';
if (digit < 0 || digit > 9)
return;
index = index * 10 + digit;
@@ -1342,24 +1351,26 @@ namespace {
// are unique to Chromium. Attributes are matched using a closest fit algorithm.
// From <EGL/egl.h>.
-const int32 kAlphaSize = 0x3021; // EGL_ALPHA_SIZE
-const int32 kBlueSize = 0x3022; // EGL_BLUE_SIZE
-const int32 kGreenSize = 0x3023; // EGL_GREEN_SIZE
-const int32 kRedSize = 0x3024; // EGL_RED_SIZE
-const int32 kDepthSize = 0x3025; // EGL_DEPTH_SIZE
-const int32 kStencilSize = 0x3026; // EGL_STENCIL_SIZE
-const int32 kSamples = 0x3031; // EGL_SAMPLES
-const int32 kSampleBuffers = 0x3032; // EGL_SAMPLE_BUFFERS
-const int32 kNone = 0x3038; // EGL_NONE
-const int32 kSwapBehavior = 0x3093; // EGL_SWAP_BEHAVIOR
-const int32 kBufferPreserved = 0x3094; // EGL_BUFFER_PRESERVED
-const int32 kBufferDestroyed = 0x3095; // EGL_BUFFER_DESTROYED
+#include <stddef.h>
+#include <stdint.h>
+const int32_t kAlphaSize = 0x3021; // EGL_ALPHA_SIZE
+const int32_t kBlueSize = 0x3022; // EGL_BLUE_SIZE
+const int32_t kGreenSize = 0x3023; // EGL_GREEN_SIZE
+const int32_t kRedSize = 0x3024; // EGL_RED_SIZE
+const int32_t kDepthSize = 0x3025; // EGL_DEPTH_SIZE
+const int32_t kStencilSize = 0x3026; // EGL_STENCIL_SIZE
+const int32_t kSamples = 0x3031; // EGL_SAMPLES
+const int32_t kSampleBuffers = 0x3032; // EGL_SAMPLE_BUFFERS
+const int32_t kNone = 0x3038; // EGL_NONE
+const int32_t kSwapBehavior = 0x3093; // EGL_SWAP_BEHAVIOR
+const int32_t kBufferPreserved = 0x3094; // EGL_BUFFER_PRESERVED
+const int32_t kBufferDestroyed = 0x3095; // EGL_BUFFER_DESTROYED
// Chromium only.
-const int32 kBindGeneratesResource = 0x10000;
-const int32 kFailIfMajorPerfCaveat = 0x10001;
-const int32 kLoseContextWhenOutOfMemory = 0x10002;
-const int32 kContextType = 0x10003;
+const int32_t kBindGeneratesResource = 0x10000;
+const int32_t kFailIfMajorPerfCaveat = 0x10001;
+const int32_t kLoseContextWhenOutOfMemory = 0x10002;
+const int32_t kContextType = 0x10003;
} // namespace
@@ -1378,7 +1389,8 @@ ContextCreationAttribHelper::ContextCreationAttribHelper()
lose_context_when_out_of_memory(false),
context_type(CONTEXT_TYPE_OPENGLES2) {}
-void ContextCreationAttribHelper::Serialize(std::vector<int32>* attribs) const {
+void ContextCreationAttribHelper::Serialize(
+ std::vector<int32_t>* attribs) const {
if (alpha_size != -1) {
attribs->push_back(kAlphaSize);
attribs->push_back(alpha_size);
@@ -1424,9 +1436,9 @@ void ContextCreationAttribHelper::Serialize(std::vector<int32>* attribs) const {
attribs->push_back(kNone);
}
-bool ContextCreationAttribHelper::Parse(const std::vector<int32>& attribs) {
+bool ContextCreationAttribHelper::Parse(const std::vector<int32_t>& attribs) {
for (size_t i = 0; i < attribs.size(); i += 2) {
- const int32 attrib = attribs[i];
+ const int32_t attrib = attribs[i];
if (i + 1 >= attribs.size()) {
if (attrib == kNone) {
return true;
@@ -1437,7 +1449,7 @@ bool ContextCreationAttribHelper::Parse(const std::vector<int32>& attribs) {
return false;
}
- const int32 value = attribs[i+1];
+ const int32_t value = attribs[i + 1];
switch (attrib) {
case kAlphaSize:
alpha_size = value;
« 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