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

Side by Side Diff: gpu/command_buffer/service/texture_manager.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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "gpu/command_buffer/service/texture_manager.h" 5 #include "gpu/command_buffer/service/texture_manager.h"
6 6
7 #include <stddef.h>
8 #include <stdint.h>
9
7 #include <algorithm> 10 #include <algorithm>
8 #include <set> 11 #include <set>
9 #include <utility> 12 #include <utility>
10 13
11 #include "base/bits.h" 14 #include "base/bits.h"
12 #include "base/lazy_instance.h" 15 #include "base/lazy_instance.h"
13 #include "base/strings/stringprintf.h" 16 #include "base/strings/stringprintf.h"
14 #include "base/thread_task_runner_handle.h" 17 #include "base/thread_task_runner_handle.h"
15 #include "base/trace_event/memory_dump_manager.h" 18 #include "base/trace_event/memory_dump_manager.h"
16 #include "gpu/command_buffer/common/gles2_cmd_utils.h" 19 #include "gpu/command_buffer/common/gles2_cmd_utils.h"
(...skipping 567 matching lines...) Expand 10 before | Expand all | Expand 10 after
584 target_ == GL_TEXTURE_RECTANGLE_ARB) { 587 target_ == GL_TEXTURE_RECTANGLE_ARB) {
585 return false; 588 return false;
586 } 589 }
587 590
588 if (static_cast<size_t>(base_level_) >= face_infos_[0].level_infos.size()) { 591 if (static_cast<size_t>(base_level_) >= face_infos_[0].level_infos.size()) {
589 return false; 592 return false;
590 } 593 }
591 594
592 // Can't generate mips for depth or stencil textures. 595 // Can't generate mips for depth or stencil textures.
593 const Texture::LevelInfo& base = face_infos_[0].level_infos[base_level_]; 596 const Texture::LevelInfo& base = face_infos_[0].level_infos[base_level_];
594 uint32 channels = GLES2Util::GetChannelsForFormat(base.format); 597 uint32_t channels = GLES2Util::GetChannelsForFormat(base.format);
595 if (channels & (GLES2Util::kDepth | GLES2Util::kStencil)) { 598 if (channels & (GLES2Util::kDepth | GLES2Util::kStencil)) {
596 return false; 599 return false;
597 } 600 }
598 601
599 // TODO(gman): Check internal_format, format and type. 602 // TODO(gman): Check internal_format, format and type.
600 for (size_t ii = 0; ii < face_infos_.size(); ++ii) { 603 for (size_t ii = 0; ii < face_infos_.size(); ++ii) {
601 const LevelInfo& info = face_infos_[ii].level_infos[base_level_]; 604 const LevelInfo& info = face_infos_[ii].level_infos[base_level_];
602 if ((info.target == 0) || (info.width != base.width) || 605 if ((info.target == 0) || (info.width != base.width) ||
603 (info.height != base.height) || (info.depth != base.depth) || 606 (info.height != base.height) || (info.depth != base.depth) ||
604 (info.format != base.format) || 607 (info.format != base.format) ||
(...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after
897 GLint xoffset, 900 GLint xoffset,
898 GLint yoffset, 901 GLint yoffset,
899 GLint zoffset, 902 GLint zoffset,
900 GLsizei width, 903 GLsizei width,
901 GLsizei height, 904 GLsizei height,
902 GLsizei depth) const { 905 GLsizei depth) const {
903 size_t face_index = GLES2Util::GLTargetToFaceIndex(target); 906 size_t face_index = GLES2Util::GLTargetToFaceIndex(target);
904 if (level >= 0 && face_index < face_infos_.size() && 907 if (level >= 0 && face_index < face_infos_.size() &&
905 static_cast<size_t>(level) < face_infos_[face_index].level_infos.size()) { 908 static_cast<size_t>(level) < face_infos_[face_index].level_infos.size()) {
906 const LevelInfo& info = face_infos_[face_index].level_infos[level]; 909 const LevelInfo& info = face_infos_[face_index].level_infos[level];
907 int32 max_x; 910 int32_t max_x;
908 int32 max_y; 911 int32_t max_y;
909 int32 max_z; 912 int32_t max_z;
910 return SafeAddInt32(xoffset, width, &max_x) && 913 return SafeAddInt32(xoffset, width, &max_x) &&
911 SafeAddInt32(yoffset, height, &max_y) && 914 SafeAddInt32(yoffset, height, &max_y) &&
912 SafeAddInt32(zoffset, depth, &max_z) && 915 SafeAddInt32(zoffset, depth, &max_z) &&
913 xoffset >= 0 && 916 xoffset >= 0 &&
914 yoffset >= 0 && 917 yoffset >= 0 &&
915 zoffset >= 0 && 918 zoffset >= 0 &&
916 max_x <= info.width && 919 max_x <= info.width &&
917 max_y <= info.height && 920 max_y <= info.height &&
918 max_z <= info.depth; 921 max_z <= info.depth;
919 } 922 }
(...skipping 542 matching lines...) Expand 10 before | Expand all | Expand 10 after
1462 this, "gpu::TextureManager", base::ThreadTaskRunnerHandle::Get()); 1465 this, "gpu::TextureManager", base::ThreadTaskRunnerHandle::Get());
1463 } 1466 }
1464 1467
1465 return true; 1468 return true;
1466 } 1469 }
1467 1470
1468 scoped_refptr<TextureRef> 1471 scoped_refptr<TextureRef>
1469 TextureManager::CreateDefaultAndBlackTextures( 1472 TextureManager::CreateDefaultAndBlackTextures(
1470 GLenum target, 1473 GLenum target,
1471 GLuint* black_texture) { 1474 GLuint* black_texture) {
1472 static uint8 black[] = {0, 0, 0, 255}; 1475 static uint8_t black[] = {0, 0, 0, 255};
1473 1476
1474 // Sampling a texture not associated with any EGLImage sibling will return 1477 // Sampling a texture not associated with any EGLImage sibling will return
1475 // black values according to the spec. 1478 // black values according to the spec.
1476 bool needs_initialization = (target != GL_TEXTURE_EXTERNAL_OES); 1479 bool needs_initialization = (target != GL_TEXTURE_EXTERNAL_OES);
1477 bool needs_faces = (target == GL_TEXTURE_CUBE_MAP); 1480 bool needs_faces = (target == GL_TEXTURE_CUBE_MAP);
1478 bool is_3d_or_2d_array_target = (target == GL_TEXTURE_3D || 1481 bool is_3d_or_2d_array_target = (target == GL_TEXTURE_3D ||
1479 target == GL_TEXTURE_2D_ARRAY); 1482 target == GL_TEXTURE_2D_ARRAY);
1480 1483
1481 // Make default textures and texture for replacing non-renderable textures. 1484 // Make default textures and texture for replacing non-renderable textures.
1482 GLuint ids[2]; 1485 GLuint ids[2];
(...skipping 362 matching lines...) Expand 10 before | Expand all | Expand 10 after
1845 // For TexSubImage calls, internal_format isn't part of the parameters, 1848 // For TexSubImage calls, internal_format isn't part of the parameters,
1846 // so its validation needs to be after the internal_format/format/type 1849 // so its validation needs to be after the internal_format/format/type
1847 // combination validation. Otherwise, an unexpected INVALID_ENUM could be 1850 // combination validation. Otherwise, an unexpected INVALID_ENUM could be
1848 // generated instead of INVALID_OPERATION. 1851 // generated instead of INVALID_OPERATION.
1849 if (!validators->texture_internal_format.IsValid(internal_format)) { 1852 if (!validators->texture_internal_format.IsValid(internal_format)) {
1850 ERRORSTATE_SET_GL_ERROR_INVALID_ENUM( 1853 ERRORSTATE_SET_GL_ERROR_INVALID_ENUM(
1851 error_state, function_name, internal_format, "internal_format"); 1854 error_state, function_name, internal_format, "internal_format");
1852 return false; 1855 return false;
1853 } 1856 }
1854 if (!feature_info_->IsES3Enabled()) { 1857 if (!feature_info_->IsES3Enabled()) {
1855 uint32 channels = GLES2Util::GetChannelsForFormat(format); 1858 uint32_t channels = GLES2Util::GetChannelsForFormat(format);
1856 if ((channels & (GLES2Util::kDepth | GLES2Util::kStencil)) != 0 && level) { 1859 if ((channels & (GLES2Util::kDepth | GLES2Util::kStencil)) != 0 && level) {
1857 ERRORSTATE_SET_GL_ERROR( 1860 ERRORSTATE_SET_GL_ERROR(
1858 error_state, GL_INVALID_OPERATION, function_name, 1861 error_state, GL_INVALID_OPERATION, function_name,
1859 (std::string("invalid format ") + GLES2Util::GetStringEnum(format) + 1862 (std::string("invalid format ") + GLES2Util::GetStringEnum(format) +
1860 " for level != 0").c_str()); 1863 " for level != 0").c_str());
1861 return false; 1864 return false;
1862 } 1865 }
1863 } 1866 }
1864 return true; 1867 return true;
1865 } 1868 }
(...skipping 745 matching lines...) Expand 10 before | Expand all | Expand 10 after
2611 return GL_HALF_FLOAT_OES; 2614 return GL_HALF_FLOAT_OES;
2612 case GL_BGRA8_EXT: 2615 case GL_BGRA8_EXT:
2613 return GL_UNSIGNED_BYTE; 2616 return GL_UNSIGNED_BYTE;
2614 default: 2617 default:
2615 return GL_NONE; 2618 return GL_NONE;
2616 } 2619 }
2617 } 2620 }
2618 2621
2619 } // namespace gles2 2622 } // namespace gles2
2620 } // namespace gpu 2623 } // namespace gpu
OLDNEW
« no previous file with comments | « gpu/command_buffer/service/texture_manager.h ('k') | gpu/command_buffer/service/texture_manager_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698