| OLD | NEW |
| 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 <algorithm> | 7 #include <algorithm> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/bits.h" | 10 #include "base/bits.h" |
| 11 #include "base/strings/stringprintf.h" | 11 #include "base/strings/stringprintf.h" |
| 12 #include "gpu/command_buffer/common/gles2_cmd_utils.h" | 12 #include "gpu/command_buffer/common/gles2_cmd_utils.h" |
| 13 #include "gpu/command_buffer/service/context_state.h" | 13 #include "gpu/command_buffer/service/context_state.h" |
| 14 #include "gpu/command_buffer/service/error_state.h" | 14 #include "gpu/command_buffer/service/error_state.h" |
| 15 #include "gpu/command_buffer/service/feature_info.h" | 15 #include "gpu/command_buffer/service/feature_info.h" |
| 16 #include "gpu/command_buffer/service/framebuffer_manager.h" | 16 #include "gpu/command_buffer/service/framebuffer_manager.h" |
| 17 #include "gpu/command_buffer/service/gles2_cmd_decoder.h" | 17 #include "gpu/command_buffer/service/gles2_cmd_decoder.h" |
| 18 #include "gpu/command_buffer/service/mailbox_manager.h" | 18 #include "gpu/command_buffer/service/mailbox_manager.h" |
| 19 #include "gpu/command_buffer/service/memory_tracking.h" | 19 #include "gpu/command_buffer/service/memory_tracking.h" |
| 20 | 20 |
| 21 namespace gpu { | 21 namespace gpu { |
| 22 namespace gles2 { | 22 namespace gles2 { |
| 23 | 23 |
| 24 static size_t GLTargetToFaceIndex(GLenum target) { | |
| 25 switch (target) { | |
| 26 case GL_TEXTURE_2D: | |
| 27 case GL_TEXTURE_EXTERNAL_OES: | |
| 28 case GL_TEXTURE_RECTANGLE_ARB: | |
| 29 return 0; | |
| 30 case GL_TEXTURE_CUBE_MAP_POSITIVE_X: | |
| 31 return 0; | |
| 32 case GL_TEXTURE_CUBE_MAP_NEGATIVE_X: | |
| 33 return 1; | |
| 34 case GL_TEXTURE_CUBE_MAP_POSITIVE_Y: | |
| 35 return 2; | |
| 36 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y: | |
| 37 return 3; | |
| 38 case GL_TEXTURE_CUBE_MAP_POSITIVE_Z: | |
| 39 return 4; | |
| 40 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z: | |
| 41 return 5; | |
| 42 default: | |
| 43 NOTREACHED(); | |
| 44 return 0; | |
| 45 } | |
| 46 } | |
| 47 | |
| 48 static size_t FaceIndexToGLTarget(size_t index) { | |
| 49 switch (index) { | |
| 50 case 0: | |
| 51 return GL_TEXTURE_CUBE_MAP_POSITIVE_X; | |
| 52 case 1: | |
| 53 return GL_TEXTURE_CUBE_MAP_NEGATIVE_X; | |
| 54 case 2: | |
| 55 return GL_TEXTURE_CUBE_MAP_POSITIVE_Y; | |
| 56 case 3: | |
| 57 return GL_TEXTURE_CUBE_MAP_NEGATIVE_Y; | |
| 58 case 4: | |
| 59 return GL_TEXTURE_CUBE_MAP_POSITIVE_Z; | |
| 60 case 5: | |
| 61 return GL_TEXTURE_CUBE_MAP_NEGATIVE_Z; | |
| 62 default: | |
| 63 NOTREACHED(); | |
| 64 return 0; | |
| 65 } | |
| 66 } | |
| 67 | |
| 68 TextureManager::DestructionObserver::DestructionObserver() {} | 24 TextureManager::DestructionObserver::DestructionObserver() {} |
| 69 | 25 |
| 70 TextureManager::DestructionObserver::~DestructionObserver() {} | 26 TextureManager::DestructionObserver::~DestructionObserver() {} |
| 71 | 27 |
| 72 TextureManager::~TextureManager() { | 28 TextureManager::~TextureManager() { |
| 73 for (unsigned int i = 0; i < destruction_observers_.size(); i++) | 29 for (unsigned int i = 0; i < destruction_observers_.size(); i++) |
| 74 destruction_observers_[i]->OnTextureManagerDestroying(this); | 30 destruction_observers_[i]->OnTextureManagerDestroying(this); |
| 75 | 31 |
| 76 DCHECK(textures_.empty()); | 32 DCHECK(textures_.empty()); |
| 77 | 33 |
| (...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 250 } | 206 } |
| 251 | 207 |
| 252 void Texture::AddToSignature( | 208 void Texture::AddToSignature( |
| 253 const FeatureInfo* feature_info, | 209 const FeatureInfo* feature_info, |
| 254 GLenum target, | 210 GLenum target, |
| 255 GLint level, | 211 GLint level, |
| 256 std::string* signature) const { | 212 std::string* signature) const { |
| 257 DCHECK(feature_info); | 213 DCHECK(feature_info); |
| 258 DCHECK(signature); | 214 DCHECK(signature); |
| 259 DCHECK_GE(level, 0); | 215 DCHECK_GE(level, 0); |
| 260 DCHECK_LT(static_cast<size_t>(GLTargetToFaceIndex(target)), | 216 size_t face_index = GLES2Util::GLTargetToFaceIndex(target); |
| 217 DCHECK_LT(static_cast<size_t>(face_index), |
| 261 level_infos_.size()); | 218 level_infos_.size()); |
| 262 DCHECK_LT(static_cast<size_t>(level), | 219 DCHECK_LT(static_cast<size_t>(level), |
| 263 level_infos_[GLTargetToFaceIndex(target)].size()); | 220 level_infos_[face_index].size()); |
| 264 const Texture::LevelInfo& info = | 221 const Texture::LevelInfo& info = |
| 265 level_infos_[GLTargetToFaceIndex(target)][level]; | 222 level_infos_[face_index][level]; |
| 266 *signature += base::StringPrintf( | 223 *signature += base::StringPrintf( |
| 267 "|Texture|target=%04x|level=%d|internal_format=%04x" | 224 "|Texture|target=%04x|level=%d|internal_format=%04x" |
| 268 "|width=%d|height=%d|depth=%d|border=%d|format=%04x|type=%04x" | 225 "|width=%d|height=%d|depth=%d|border=%d|format=%04x|type=%04x" |
| 269 "|image=%d|canrender=%d|canrenderto=%d|npot_=%d" | 226 "|image=%d|canrender=%d|canrenderto=%d|npot_=%d" |
| 270 "|min_filter=%04x|mag_filter=%04x|wrap_s=%04x|wrap_t=%04x" | 227 "|min_filter=%04x|mag_filter=%04x|wrap_s=%04x|wrap_t=%04x" |
| 271 "|usage=%04x", | 228 "|usage=%04x", |
| 272 target, level, info.internal_format, | 229 target, level, info.internal_format, |
| 273 info.width, info.height, info.depth, info.border, | 230 info.width, info.height, info.depth, info.border, |
| 274 info.format, info.type, info.image.get() != NULL, | 231 info.format, info.type, info.image.get() != NULL, |
| 275 CanRender(feature_info), CanRenderTo(), npot_, | 232 CanRender(feature_info), CanRenderTo(), npot_, |
| (...skipping 10 matching lines...) Expand all Loading... |
| 286 const FeatureInfo* feature_info) { | 243 const FeatureInfo* feature_info) { |
| 287 if (!CanGenerateMipmaps(feature_info)) { | 244 if (!CanGenerateMipmaps(feature_info)) { |
| 288 return false; | 245 return false; |
| 289 } | 246 } |
| 290 for (size_t ii = 0; ii < level_infos_.size(); ++ii) { | 247 for (size_t ii = 0; ii < level_infos_.size(); ++ii) { |
| 291 const Texture::LevelInfo& info1 = level_infos_[ii][0]; | 248 const Texture::LevelInfo& info1 = level_infos_[ii][0]; |
| 292 GLsizei width = info1.width; | 249 GLsizei width = info1.width; |
| 293 GLsizei height = info1.height; | 250 GLsizei height = info1.height; |
| 294 GLsizei depth = info1.depth; | 251 GLsizei depth = info1.depth; |
| 295 GLenum target = target_ == GL_TEXTURE_2D ? GL_TEXTURE_2D : | 252 GLenum target = target_ == GL_TEXTURE_2D ? GL_TEXTURE_2D : |
| 296 FaceIndexToGLTarget(ii); | 253 GLES2Util::IndexToGLFaceTarget(ii); |
| 297 int num_mips = | 254 int num_mips = |
| 298 TextureManager::ComputeMipMapCount(target_, width, height, depth); | 255 TextureManager::ComputeMipMapCount(target_, width, height, depth); |
| 299 for (int level = 1; level < num_mips; ++level) { | 256 for (int level = 1; level < num_mips; ++level) { |
| 300 width = std::max(1, width >> 1); | 257 width = std::max(1, width >> 1); |
| 301 height = std::max(1, height >> 1); | 258 height = std::max(1, height >> 1); |
| 302 depth = std::max(1, depth >> 1); | 259 depth = std::max(1, depth >> 1); |
| 303 SetLevelInfo(feature_info, | 260 SetLevelInfo(feature_info, |
| 304 target, | 261 target, |
| 305 level, | 262 level, |
| 306 info1.internal_format, | 263 info1.internal_format, |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 367 info.internal_format) || | 324 info.internal_format) || |
| 368 info.image.get()) { | 325 info.image.get()) { |
| 369 return false; | 326 return false; |
| 370 } | 327 } |
| 371 } | 328 } |
| 372 return true; | 329 return true; |
| 373 } | 330 } |
| 374 | 331 |
| 375 void Texture::SetLevelCleared(GLenum target, GLint level, bool cleared) { | 332 void Texture::SetLevelCleared(GLenum target, GLint level, bool cleared) { |
| 376 DCHECK_GE(level, 0); | 333 DCHECK_GE(level, 0); |
| 377 DCHECK_LT(static_cast<size_t>(GLTargetToFaceIndex(target)), | 334 size_t face_index = GLES2Util::GLTargetToFaceIndex(target); |
| 335 DCHECK_LT(static_cast<size_t>(face_index), |
| 378 level_infos_.size()); | 336 level_infos_.size()); |
| 379 DCHECK_LT(static_cast<size_t>(level), | 337 DCHECK_LT(static_cast<size_t>(level), |
| 380 level_infos_[GLTargetToFaceIndex(target)].size()); | 338 level_infos_[face_index].size()); |
| 381 Texture::LevelInfo& info = | 339 Texture::LevelInfo& info = |
| 382 level_infos_[GLTargetToFaceIndex(target)][level]; | 340 level_infos_[face_index][level]; |
| 383 UpdateMipCleared(&info, cleared); | 341 UpdateMipCleared(&info, cleared); |
| 384 UpdateCleared(); | 342 UpdateCleared(); |
| 385 } | 343 } |
| 386 | 344 |
| 387 void Texture::UpdateCleared() { | 345 void Texture::UpdateCleared() { |
| 388 if (level_infos_.empty()) { | 346 if (level_infos_.empty()) { |
| 389 return; | 347 return; |
| 390 } | 348 } |
| 391 | 349 |
| 392 const Texture::LevelInfo& first_face = level_infos_[0][0]; | 350 const Texture::LevelInfo& first_face = level_infos_[0][0]; |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 476 GLint level, | 434 GLint level, |
| 477 GLenum internal_format, | 435 GLenum internal_format, |
| 478 GLsizei width, | 436 GLsizei width, |
| 479 GLsizei height, | 437 GLsizei height, |
| 480 GLsizei depth, | 438 GLsizei depth, |
| 481 GLint border, | 439 GLint border, |
| 482 GLenum format, | 440 GLenum format, |
| 483 GLenum type, | 441 GLenum type, |
| 484 bool cleared) { | 442 bool cleared) { |
| 485 DCHECK_GE(level, 0); | 443 DCHECK_GE(level, 0); |
| 486 DCHECK_LT(static_cast<size_t>(GLTargetToFaceIndex(target)), | 444 size_t face_index = GLES2Util::GLTargetToFaceIndex(target); |
| 445 DCHECK_LT(static_cast<size_t>(face_index), |
| 487 level_infos_.size()); | 446 level_infos_.size()); |
| 488 DCHECK_LT(static_cast<size_t>(level), | 447 DCHECK_LT(static_cast<size_t>(level), |
| 489 level_infos_[GLTargetToFaceIndex(target)].size()); | 448 level_infos_[face_index].size()); |
| 490 DCHECK_GE(width, 0); | 449 DCHECK_GE(width, 0); |
| 491 DCHECK_GE(height, 0); | 450 DCHECK_GE(height, 0); |
| 492 DCHECK_GE(depth, 0); | 451 DCHECK_GE(depth, 0); |
| 493 Texture::LevelInfo& info = | 452 Texture::LevelInfo& info = |
| 494 level_infos_[GLTargetToFaceIndex(target)][level]; | 453 level_infos_[face_index][level]; |
| 495 info.target = target; | 454 info.target = target; |
| 496 info.level = level; | 455 info.level = level; |
| 497 info.internal_format = internal_format; | 456 info.internal_format = internal_format; |
| 498 info.width = width; | 457 info.width = width; |
| 499 info.height = height; | 458 info.height = height; |
| 500 info.depth = depth; | 459 info.depth = depth; |
| 501 info.border = border; | 460 info.border = border; |
| 502 info.format = format; | 461 info.format = format; |
| 503 info.type = type; | 462 info.type = type; |
| 504 info.image = 0; | 463 info.image = 0; |
| (...skipping 17 matching lines...) Expand all Loading... |
| 522 } | 481 } |
| 523 | 482 |
| 524 bool Texture::ValidForTexture( | 483 bool Texture::ValidForTexture( |
| 525 GLint target, | 484 GLint target, |
| 526 GLint level, | 485 GLint level, |
| 527 GLint xoffset, | 486 GLint xoffset, |
| 528 GLint yoffset, | 487 GLint yoffset, |
| 529 GLsizei width, | 488 GLsizei width, |
| 530 GLsizei height, | 489 GLsizei height, |
| 531 GLenum type) const { | 490 GLenum type) const { |
| 532 size_t face_index = GLTargetToFaceIndex(target); | 491 size_t face_index = GLES2Util::GLTargetToFaceIndex(target); |
| 533 if (level >= 0 && face_index < level_infos_.size() && | 492 if (level >= 0 && face_index < level_infos_.size() && |
| 534 static_cast<size_t>(level) < level_infos_[face_index].size()) { | 493 static_cast<size_t>(level) < level_infos_[face_index].size()) { |
| 535 const LevelInfo& info = level_infos_[GLTargetToFaceIndex(target)][level]; | 494 const LevelInfo& info = level_infos_[face_index][level]; |
| 536 int32 right; | 495 int32 right; |
| 537 int32 top; | 496 int32 top; |
| 538 return SafeAddInt32(xoffset, width, &right) && | 497 return SafeAddInt32(xoffset, width, &right) && |
| 539 SafeAddInt32(yoffset, height, &top) && | 498 SafeAddInt32(yoffset, height, &top) && |
| 540 xoffset >= 0 && | 499 xoffset >= 0 && |
| 541 yoffset >= 0 && | 500 yoffset >= 0 && |
| 542 right <= info.width && | 501 right <= info.width && |
| 543 top <= info.height && | 502 top <= info.height && |
| 544 type == info.type; | 503 type == info.type; |
| 545 } | 504 } |
| 546 return false; | 505 return false; |
| 547 } | 506 } |
| 548 | 507 |
| 549 bool Texture::GetLevelSize( | 508 bool Texture::GetLevelSize( |
| 550 GLint target, GLint level, GLsizei* width, GLsizei* height) const { | 509 GLint target, GLint level, GLsizei* width, GLsizei* height) const { |
| 551 DCHECK(width); | 510 DCHECK(width); |
| 552 DCHECK(height); | 511 DCHECK(height); |
| 553 size_t face_index = GLTargetToFaceIndex(target); | 512 size_t face_index = GLES2Util::GLTargetToFaceIndex(target); |
| 554 if (level >= 0 && face_index < level_infos_.size() && | 513 if (level >= 0 && face_index < level_infos_.size() && |
| 555 static_cast<size_t>(level) < level_infos_[face_index].size()) { | 514 static_cast<size_t>(level) < level_infos_[face_index].size()) { |
| 556 const LevelInfo& info = level_infos_[GLTargetToFaceIndex(target)][level]; | 515 const LevelInfo& info = level_infos_[face_index][level]; |
| 557 if (info.target != 0) { | 516 if (info.target != 0) { |
| 558 *width = info.width; | 517 *width = info.width; |
| 559 *height = info.height; | 518 *height = info.height; |
| 560 return true; | 519 return true; |
| 561 } | 520 } |
| 562 } | 521 } |
| 563 return false; | 522 return false; |
| 564 } | 523 } |
| 565 | 524 |
| 566 bool Texture::GetLevelType( | 525 bool Texture::GetLevelType( |
| 567 GLint target, GLint level, GLenum* type, GLenum* internal_format) const { | 526 GLint target, GLint level, GLenum* type, GLenum* internal_format) const { |
| 568 DCHECK(type); | 527 DCHECK(type); |
| 569 DCHECK(internal_format); | 528 DCHECK(internal_format); |
| 570 size_t face_index = GLTargetToFaceIndex(target); | 529 size_t face_index = GLES2Util::GLTargetToFaceIndex(target); |
| 571 if (level >= 0 && face_index < level_infos_.size() && | 530 if (level >= 0 && face_index < level_infos_.size() && |
| 572 static_cast<size_t>(level) < level_infos_[face_index].size()) { | 531 static_cast<size_t>(level) < level_infos_[face_index].size()) { |
| 573 const LevelInfo& info = level_infos_[GLTargetToFaceIndex(target)][level]; | 532 const LevelInfo& info = level_infos_[face_index][level]; |
| 574 if (info.target != 0) { | 533 if (info.target != 0) { |
| 575 *type = info.type; | 534 *type = info.type; |
| 576 *internal_format = info.internal_format; | 535 *internal_format = info.internal_format; |
| 577 return true; | 536 return true; |
| 578 } | 537 } |
| 579 } | 538 } |
| 580 return false; | 539 return false; |
| 581 } | 540 } |
| 582 | 541 |
| 583 GLenum Texture::SetParameteri( | 542 GLenum Texture::SetParameteri( |
| (...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 773 return false; | 732 return false; |
| 774 } | 733 } |
| 775 } | 734 } |
| 776 } | 735 } |
| 777 } | 736 } |
| 778 UpdateSafeToRenderFrom(true); | 737 UpdateSafeToRenderFrom(true); |
| 779 return true; | 738 return true; |
| 780 } | 739 } |
| 781 | 740 |
| 782 bool Texture::IsLevelCleared(GLenum target, GLint level) const { | 741 bool Texture::IsLevelCleared(GLenum target, GLint level) const { |
| 783 size_t face_index = GLTargetToFaceIndex(target); | 742 size_t face_index = GLES2Util::GLTargetToFaceIndex(target); |
| 784 if (face_index >= level_infos_.size() || | 743 if (face_index >= level_infos_.size() || |
| 785 level >= static_cast<GLint>(level_infos_[face_index].size())) { | 744 level >= static_cast<GLint>(level_infos_[face_index].size())) { |
| 786 return true; | 745 return true; |
| 787 } | 746 } |
| 788 | 747 |
| 789 const Texture::LevelInfo& info = level_infos_[face_index][level]; | 748 const Texture::LevelInfo& info = level_infos_[face_index][level]; |
| 790 | 749 |
| 791 return info.cleared; | 750 return info.cleared; |
| 792 } | 751 } |
| 793 | 752 |
| 794 void Texture::InitTextureMaxAnisotropyIfNeeded(GLenum target) { | 753 void Texture::InitTextureMaxAnisotropyIfNeeded(GLenum target) { |
| 795 if (texture_max_anisotropy_initialized_) | 754 if (texture_max_anisotropy_initialized_) |
| 796 return; | 755 return; |
| 797 texture_max_anisotropy_initialized_ = true; | 756 texture_max_anisotropy_initialized_ = true; |
| 798 GLfloat params[] = { 1.0f }; | 757 GLfloat params[] = { 1.0f }; |
| 799 glTexParameterfv(target, GL_TEXTURE_MAX_ANISOTROPY_EXT, params); | 758 glTexParameterfv(target, GL_TEXTURE_MAX_ANISOTROPY_EXT, params); |
| 800 } | 759 } |
| 801 | 760 |
| 802 bool Texture::ClearLevel( | 761 bool Texture::ClearLevel( |
| 803 GLES2Decoder* decoder, GLenum target, GLint level) { | 762 GLES2Decoder* decoder, GLenum target, GLint level) { |
| 804 DCHECK(decoder); | 763 DCHECK(decoder); |
| 805 size_t face_index = GLTargetToFaceIndex(target); | 764 size_t face_index = GLES2Util::GLTargetToFaceIndex(target); |
| 806 if (face_index >= level_infos_.size() || | 765 if (face_index >= level_infos_.size() || |
| 807 level >= static_cast<GLint>(level_infos_[face_index].size())) { | 766 level >= static_cast<GLint>(level_infos_[face_index].size())) { |
| 808 return true; | 767 return true; |
| 809 } | 768 } |
| 810 | 769 |
| 811 Texture::LevelInfo& info = level_infos_[face_index][level]; | 770 Texture::LevelInfo& info = level_infos_[face_index][level]; |
| 812 | 771 |
| 813 DCHECK(target == info.target); | 772 DCHECK(target == info.target); |
| 814 | 773 |
| 815 if (info.target == 0 || | 774 if (info.target == 0 || |
| (...skipping 13 matching lines...) Expand all Loading... |
| 829 UpdateMipCleared(&info, cleared); | 788 UpdateMipCleared(&info, cleared); |
| 830 return info.cleared; | 789 return info.cleared; |
| 831 } | 790 } |
| 832 | 791 |
| 833 void Texture::SetLevelImage( | 792 void Texture::SetLevelImage( |
| 834 const FeatureInfo* feature_info, | 793 const FeatureInfo* feature_info, |
| 835 GLenum target, | 794 GLenum target, |
| 836 GLint level, | 795 GLint level, |
| 837 gfx::GLImage* image) { | 796 gfx::GLImage* image) { |
| 838 DCHECK_GE(level, 0); | 797 DCHECK_GE(level, 0); |
| 839 DCHECK_LT(static_cast<size_t>(GLTargetToFaceIndex(target)), | 798 size_t face_index = GLES2Util::GLTargetToFaceIndex(target); |
| 799 DCHECK_LT(static_cast<size_t>(face_index), |
| 840 level_infos_.size()); | 800 level_infos_.size()); |
| 841 DCHECK_LT(static_cast<size_t>(level), | 801 DCHECK_LT(static_cast<size_t>(level), |
| 842 level_infos_[GLTargetToFaceIndex(target)].size()); | 802 level_infos_[face_index].size()); |
| 843 Texture::LevelInfo& info = | 803 Texture::LevelInfo& info = |
| 844 level_infos_[GLTargetToFaceIndex(target)][level]; | 804 level_infos_[face_index][level]; |
| 845 DCHECK_EQ(info.target, target); | 805 DCHECK_EQ(info.target, target); |
| 846 DCHECK_EQ(info.level, level); | 806 DCHECK_EQ(info.level, level); |
| 847 info.image = image; | 807 info.image = image; |
| 848 UpdateCanRenderCondition(); | 808 UpdateCanRenderCondition(); |
| 849 UpdateHasImages(); | 809 UpdateHasImages(); |
| 850 } | 810 } |
| 851 | 811 |
| 852 gfx::GLImage* Texture::GetLevelImage(GLint target, GLint level) const { | 812 gfx::GLImage* Texture::GetLevelImage(GLint target, GLint level) const { |
| 853 if (target != GL_TEXTURE_2D && target != GL_TEXTURE_EXTERNAL_OES && | 813 if (target != GL_TEXTURE_2D && target != GL_TEXTURE_EXTERNAL_OES && |
| 854 target != GL_TEXTURE_RECTANGLE_ARB) { | 814 target != GL_TEXTURE_RECTANGLE_ARB) { |
| 855 return NULL; | 815 return NULL; |
| 856 } | 816 } |
| 857 | 817 |
| 858 size_t face_index = GLTargetToFaceIndex(target); | 818 size_t face_index = GLES2Util::GLTargetToFaceIndex(target); |
| 859 if (level >= 0 && face_index < level_infos_.size() && | 819 if (level >= 0 && face_index < level_infos_.size() && |
| 860 static_cast<size_t>(level) < level_infos_[face_index].size()) { | 820 static_cast<size_t>(level) < level_infos_[face_index].size()) { |
| 861 const LevelInfo& info = level_infos_[GLTargetToFaceIndex(target)][level]; | 821 const LevelInfo& info = level_infos_[face_index][level]; |
| 862 if (info.target != 0) { | 822 if (info.target != 0) { |
| 863 return info.image.get(); | 823 return info.image.get(); |
| 864 } | 824 } |
| 865 } | 825 } |
| 866 return 0; | 826 return NULL; |
| 867 } | 827 } |
| 868 | 828 |
| 869 void Texture::OnWillModifyPixels() { | 829 void Texture::OnWillModifyPixels() { |
| 870 gfx::GLImage* image = GetLevelImage(target(), 0); | 830 gfx::GLImage* image = GetLevelImage(target(), 0); |
| 871 if (image) | 831 if (image) |
| 872 image->WillModifyTexImage(); | 832 image->WillModifyTexImage(); |
| 873 } | 833 } |
| 874 | 834 |
| 875 void Texture::OnDidModifyPixels() { | 835 void Texture::OnDidModifyPixels() { |
| 876 gfx::GLImage* image = GetLevelImage(target(), 0); | 836 gfx::GLImage* image = GetLevelImage(target(), 0); |
| (...skipping 706 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1583 } | 1543 } |
| 1584 | 1544 |
| 1585 ScopedTextureUploadTimer::~ScopedTextureUploadTimer() { | 1545 ScopedTextureUploadTimer::~ScopedTextureUploadTimer() { |
| 1586 texture_state_->texture_upload_count++; | 1546 texture_state_->texture_upload_count++; |
| 1587 texture_state_->total_texture_upload_time += | 1547 texture_state_->total_texture_upload_time += |
| 1588 base::TimeTicks::HighResNow() - begin_time_; | 1548 base::TimeTicks::HighResNow() - begin_time_; |
| 1589 } | 1549 } |
| 1590 | 1550 |
| 1591 } // namespace gles2 | 1551 } // namespace gles2 |
| 1592 } // namespace gpu | 1552 } // namespace gpu |
| OLD | NEW |