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 <set> | 8 #include <set> |
9 #include <utility> | 9 #include <utility> |
10 | 10 |
(...skipping 413 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
424 | 424 |
425 Texture::CanRenderCondition Texture::GetCanRenderCondition() const { | 425 Texture::CanRenderCondition Texture::GetCanRenderCondition() const { |
426 if (target_ == 0) | 426 if (target_ == 0) |
427 return CAN_RENDER_ALWAYS; | 427 return CAN_RENDER_ALWAYS; |
428 | 428 |
429 if (target_ != GL_TEXTURE_EXTERNAL_OES) { | 429 if (target_ != GL_TEXTURE_EXTERNAL_OES) { |
430 if (face_infos_.empty()) { | 430 if (face_infos_.empty()) { |
431 return CAN_RENDER_NEVER; | 431 return CAN_RENDER_NEVER; |
432 } | 432 } |
433 | 433 |
434 const Texture::LevelInfo& first_face = face_infos_[0].level_infos[0]; | 434 const Texture::LevelInfo& first_face = |
| 435 face_infos_[0].level_infos[base_level_]; |
435 if (first_face.width == 0 || | 436 if (first_face.width == 0 || |
436 first_face.height == 0 || | 437 first_face.height == 0 || |
437 first_face.depth == 0) { | 438 first_face.depth == 0) { |
438 return CAN_RENDER_NEVER; | 439 return CAN_RENDER_NEVER; |
439 } | 440 } |
440 } | 441 } |
441 | 442 |
442 bool needs_mips = NeedsMips(); | 443 bool needs_mips = NeedsMips(); |
443 if (needs_mips) { | 444 if (needs_mips) { |
444 if (!texture_complete()) | 445 if (!texture_complete()) |
(...skipping 29 matching lines...) Expand all Loading... |
474 return feature_info->feature_flags().npot_ok; | 475 return feature_info->feature_flags().npot_ok; |
475 } | 476 } |
476 | 477 |
477 void Texture::AddToSignature( | 478 void Texture::AddToSignature( |
478 const FeatureInfo* feature_info, | 479 const FeatureInfo* feature_info, |
479 GLenum target, | 480 GLenum target, |
480 GLint level, | 481 GLint level, |
481 std::string* signature) const { | 482 std::string* signature) const { |
482 DCHECK(feature_info); | 483 DCHECK(feature_info); |
483 DCHECK(signature); | 484 DCHECK(signature); |
484 DCHECK_GE(level, 0); | 485 DCHECK_GE(level, base_level_); |
485 size_t face_index = GLES2Util::GLTargetToFaceIndex(target); | 486 size_t face_index = GLES2Util::GLTargetToFaceIndex(target); |
486 DCHECK_LT(static_cast<size_t>(face_index), | 487 DCHECK_LT(static_cast<size_t>(face_index), |
487 face_infos_.size()); | 488 face_infos_.size()); |
488 DCHECK_LT(static_cast<size_t>(level), | 489 DCHECK_LT(static_cast<size_t>(level), |
489 face_infos_[face_index].level_infos.size()); | 490 face_infos_[face_index].level_infos.size()); |
490 | 491 |
491 const Texture::LevelInfo& info = | 492 const Texture::LevelInfo& info = |
492 face_infos_[face_index].level_infos[level]; | 493 face_infos_[face_index].level_infos[level]; |
493 | 494 |
494 TextureSignature signature_data(target, | 495 TextureSignature signature_data(target, |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
527 mailbox_manager_ = mailbox_manager; | 528 mailbox_manager_ = mailbox_manager; |
528 } | 529 } |
529 | 530 |
530 bool Texture::MarkMipmapsGenerated( | 531 bool Texture::MarkMipmapsGenerated( |
531 const FeatureInfo* feature_info) { | 532 const FeatureInfo* feature_info) { |
532 if (!CanGenerateMipmaps(feature_info)) { | 533 if (!CanGenerateMipmaps(feature_info)) { |
533 return false; | 534 return false; |
534 } | 535 } |
535 for (size_t ii = 0; ii < face_infos_.size(); ++ii) { | 536 for (size_t ii = 0; ii < face_infos_.size(); ++ii) { |
536 const Texture::FaceInfo& face_info = face_infos_[ii]; | 537 const Texture::FaceInfo& face_info = face_infos_[ii]; |
537 const Texture::LevelInfo& level0_info = face_info.level_infos[0]; | 538 const Texture::LevelInfo& level0_info = face_info.level_infos[base_level_]; |
538 GLsizei width = level0_info.width; | 539 GLsizei width = level0_info.width; |
539 GLsizei height = level0_info.height; | 540 GLsizei height = level0_info.height; |
540 GLsizei depth = level0_info.depth; | 541 GLsizei depth = level0_info.depth; |
541 GLenum target = target_ == GL_TEXTURE_2D ? GL_TEXTURE_2D : | 542 GLenum target = target_ == GL_TEXTURE_2D ? GL_TEXTURE_2D : |
542 GLES2Util::IndexToGLFaceTarget(ii); | 543 GLES2Util::IndexToGLFaceTarget(ii); |
543 | 544 |
544 const GLsizei num_mips = face_info.num_mip_levels; | 545 for (GLsizei level = base_level_ + 1; |
545 for (GLsizei level = 1; level < num_mips; ++level) { | 546 level < base_level_ + face_info.num_mip_levels; |
| 547 ++level) { |
546 width = std::max(1, width >> 1); | 548 width = std::max(1, width >> 1); |
547 height = std::max(1, height >> 1); | 549 height = std::max(1, height >> 1); |
548 depth = std::max(1, depth >> 1); | 550 depth = std::max(1, depth >> 1); |
549 SetLevelInfo(feature_info, target, level, level0_info.internal_format, | 551 SetLevelInfo(feature_info, target, level, level0_info.internal_format, |
550 width, height, depth, level0_info.border, level0_info.format, | 552 width, height, depth, level0_info.border, level0_info.format, |
551 level0_info.type, gfx::Rect(width, height)); | 553 level0_info.type, gfx::Rect(width, height)); |
552 } | 554 } |
553 } | 555 } |
554 | 556 |
555 return true; | 557 return true; |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
663 internal_format == level0_face.internal_format && | 665 internal_format == level0_face.internal_format && |
664 format == level0_face.format && | 666 format == level0_face.format && |
665 type == level0_face.type); | 667 type == level0_face.type); |
666 } | 668 } |
667 return complete; | 669 return complete; |
668 } | 670 } |
669 | 671 |
670 void Texture::SetLevelClearedRect(GLenum target, | 672 void Texture::SetLevelClearedRect(GLenum target, |
671 GLint level, | 673 GLint level, |
672 const gfx::Rect& cleared_rect) { | 674 const gfx::Rect& cleared_rect) { |
673 DCHECK_GE(level, 0); | 675 DCHECK_GE(level, base_level_); |
674 size_t face_index = GLES2Util::GLTargetToFaceIndex(target); | 676 size_t face_index = GLES2Util::GLTargetToFaceIndex(target); |
675 DCHECK_LT(static_cast<size_t>(face_index), | 677 DCHECK_LT(static_cast<size_t>(face_index), |
676 face_infos_.size()); | 678 face_infos_.size()); |
677 DCHECK_LT(static_cast<size_t>(level), | 679 DCHECK_LT(static_cast<size_t>(level), |
678 face_infos_[face_index].level_infos.size()); | 680 face_infos_[face_index].level_infos.size()); |
679 Texture::LevelInfo& info = | 681 Texture::LevelInfo& info = |
680 face_infos_[face_index].level_infos[level]; | 682 face_infos_[face_index].level_infos[level]; |
681 UpdateMipCleared(&info, info.width, info.height, cleared_rect); | 683 UpdateMipCleared(&info, info.width, info.height, cleared_rect); |
682 UpdateCleared(); | 684 UpdateCleared(); |
683 } | 685 } |
684 | 686 |
685 void Texture::SetLevelCleared(GLenum target, GLint level, bool cleared) { | 687 void Texture::SetLevelCleared(GLenum target, GLint level, bool cleared) { |
686 DCHECK_GE(level, 0); | 688 DCHECK_GE(level, base_level_); |
687 size_t face_index = GLES2Util::GLTargetToFaceIndex(target); | 689 size_t face_index = GLES2Util::GLTargetToFaceIndex(target); |
688 DCHECK_LT(static_cast<size_t>(face_index), face_infos_.size()); | 690 DCHECK_LT(static_cast<size_t>(face_index), face_infos_.size()); |
689 DCHECK_LT(static_cast<size_t>(level), | 691 DCHECK_LT(static_cast<size_t>(level), |
690 face_infos_[face_index].level_infos.size()); | 692 face_infos_[face_index].level_infos.size()); |
691 Texture::LevelInfo& info = face_infos_[face_index].level_infos[level]; | 693 Texture::LevelInfo& info = face_infos_[face_index].level_infos[level]; |
692 UpdateMipCleared(&info, info.width, info.height, | 694 UpdateMipCleared(&info, info.width, info.height, |
693 cleared ? gfx::Rect(info.width, info.height) : gfx::Rect()); | 695 cleared ? gfx::Rect(info.width, info.height) : gfx::Rect()); |
694 UpdateCleared(); | 696 UpdateCleared(); |
695 } | 697 } |
696 | 698 |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
778 GLenum target, | 780 GLenum target, |
779 GLint level, | 781 GLint level, |
780 GLenum internal_format, | 782 GLenum internal_format, |
781 GLsizei width, | 783 GLsizei width, |
782 GLsizei height, | 784 GLsizei height, |
783 GLsizei depth, | 785 GLsizei depth, |
784 GLint border, | 786 GLint border, |
785 GLenum format, | 787 GLenum format, |
786 GLenum type, | 788 GLenum type, |
787 const gfx::Rect& cleared_rect) { | 789 const gfx::Rect& cleared_rect) { |
788 DCHECK_GE(level, 0); | 790 DCHECK_GE(level, base_level_); |
789 size_t face_index = GLES2Util::GLTargetToFaceIndex(target); | 791 size_t face_index = GLES2Util::GLTargetToFaceIndex(target); |
790 DCHECK_LT(static_cast<size_t>(face_index), | 792 DCHECK_LT(static_cast<size_t>(face_index), |
791 face_infos_.size()); | 793 face_infos_.size()); |
792 DCHECK_LT(static_cast<size_t>(level), | 794 DCHECK_LT(static_cast<size_t>(level), |
793 face_infos_[face_index].level_infos.size()); | 795 face_infos_[face_index].level_infos.size()); |
794 DCHECK_GE(width, 0); | 796 DCHECK_GE(width, 0); |
795 DCHECK_GE(height, 0); | 797 DCHECK_GE(height, 0); |
796 DCHECK_GE(depth, 0); | 798 DCHECK_GE(depth, 0); |
797 Texture::LevelInfo& info = | 799 Texture::LevelInfo& info = |
798 face_infos_[face_index].level_infos[level]; | 800 face_infos_[face_index].level_infos[level]; |
799 | 801 |
800 // Update counters only if any attributes have changed. Counters are | 802 // Update counters only if any attributes have changed. Counters are |
801 // comparisons between the old and new values so it must be done before any | 803 // comparisons between the old and new values so it must be done before any |
802 // assignment has been done to the LevelInfo. | 804 // assignment has been done to the LevelInfo. |
803 if (info.target != target || | 805 if (info.target != target || |
804 info.internal_format != internal_format || | 806 info.internal_format != internal_format || |
805 info.width != width || | 807 info.width != width || |
806 info.height != height || | 808 info.height != height || |
807 info.depth != depth || | 809 info.depth != depth || |
808 info.format != format || | 810 info.format != format || |
809 info.type != type) { | 811 info.type != type) { |
810 if (level == 0) { | 812 if (level == base_level_) { |
811 // Calculate the mip level count. | 813 // Calculate the mip level count. |
812 face_infos_[face_index].num_mip_levels = | 814 face_infos_[face_index].num_mip_levels = |
813 TextureManager::ComputeMipMapCount(target_, width, height, depth); | 815 TextureManager::ComputeMipMapCount(target_, width, height, depth); |
814 | 816 |
815 // Update NPOT face count for the first level. | 817 // Update NPOT face count for the first level. |
816 bool prev_npot = TextureIsNPOT(info.width, info.height, info.depth); | 818 bool prev_npot = TextureIsNPOT(info.width, info.height, info.depth); |
817 bool now_npot = TextureIsNPOT(width, height, depth); | 819 bool now_npot = TextureIsNPOT(width, height, depth); |
818 if (prev_npot != now_npot) | 820 if (prev_npot != now_npot) |
819 num_npot_faces_ += now_npot ? 1 : -1; | 821 num_npot_faces_ += now_npot ? 1 : -1; |
820 | 822 |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
857 bool Texture::ValidForTexture( | 859 bool Texture::ValidForTexture( |
858 GLint target, | 860 GLint target, |
859 GLint level, | 861 GLint level, |
860 GLint xoffset, | 862 GLint xoffset, |
861 GLint yoffset, | 863 GLint yoffset, |
862 GLint zoffset, | 864 GLint zoffset, |
863 GLsizei width, | 865 GLsizei width, |
864 GLsizei height, | 866 GLsizei height, |
865 GLsizei depth) const { | 867 GLsizei depth) const { |
866 size_t face_index = GLES2Util::GLTargetToFaceIndex(target); | 868 size_t face_index = GLES2Util::GLTargetToFaceIndex(target); |
867 if (level >= 0 && face_index < face_infos_.size() && | 869 if (level >= base_level_ && face_index < face_infos_.size() && |
868 static_cast<size_t>(level) < face_infos_[face_index].level_infos.size()) { | 870 static_cast<size_t>(level) < face_infos_[face_index].level_infos.size()) { |
869 const LevelInfo& info = face_infos_[face_index].level_infos[level]; | 871 const LevelInfo& info = face_infos_[face_index].level_infos[level]; |
870 int32 max_x; | 872 int32 max_x; |
871 int32 max_y; | 873 int32 max_y; |
872 int32 max_z; | 874 int32 max_z; |
873 return SafeAddInt32(xoffset, width, &max_x) && | 875 return SafeAddInt32(xoffset, width, &max_x) && |
874 SafeAddInt32(yoffset, height, &max_y) && | 876 SafeAddInt32(yoffset, height, &max_y) && |
875 SafeAddInt32(zoffset, depth, &max_z) && | 877 SafeAddInt32(zoffset, depth, &max_z) && |
876 xoffset >= 0 && | 878 xoffset >= 0 && |
877 yoffset >= 0 && | 879 yoffset >= 0 && |
878 zoffset >= 0 && | 880 zoffset >= 0 && |
879 max_x <= info.width && | 881 max_x <= info.width && |
880 max_y <= info.height && | 882 max_y <= info.height && |
881 max_z <= info.depth; | 883 max_z <= info.depth; |
882 } | 884 } |
883 return false; | 885 return false; |
884 } | 886 } |
885 | 887 |
886 bool Texture::GetLevelSize( | 888 bool Texture::GetLevelSize( |
887 GLint target, GLint level, | 889 GLint target, GLint level, |
888 GLsizei* width, GLsizei* height, GLsizei* depth) const { | 890 GLsizei* width, GLsizei* height, GLsizei* depth) const { |
889 DCHECK(width); | 891 DCHECK(width); |
890 DCHECK(height); | 892 DCHECK(height); |
891 size_t face_index = GLES2Util::GLTargetToFaceIndex(target); | 893 size_t face_index = GLES2Util::GLTargetToFaceIndex(target); |
892 if (level >= 0 && face_index < face_infos_.size() && | 894 if (level >= base_level_ && face_index < face_infos_.size() && |
893 static_cast<size_t>(level) < face_infos_[face_index].level_infos.size()) { | 895 static_cast<size_t>(level) < face_infos_[face_index].level_infos.size()) { |
894 const LevelInfo& info = face_infos_[face_index].level_infos[level]; | 896 const LevelInfo& info = face_infos_[face_index].level_infos[level]; |
895 if (info.target != 0) { | 897 if (info.target != 0) { |
896 *width = info.width; | 898 *width = info.width; |
897 *height = info.height; | 899 *height = info.height; |
898 if (depth) | 900 if (depth) |
899 *depth = info.depth; | 901 *depth = info.depth; |
900 return true; | 902 return true; |
901 } | 903 } |
902 } | 904 } |
903 return false; | 905 return false; |
904 } | 906 } |
905 | 907 |
906 bool Texture::GetLevelType( | 908 bool Texture::GetLevelType( |
907 GLint target, GLint level, GLenum* type, GLenum* internal_format) const { | 909 GLint target, GLint level, GLenum* type, GLenum* internal_format) const { |
908 DCHECK(type); | 910 DCHECK(type); |
909 DCHECK(internal_format); | 911 DCHECK(internal_format); |
910 size_t face_index = GLES2Util::GLTargetToFaceIndex(target); | 912 size_t face_index = GLES2Util::GLTargetToFaceIndex(target); |
911 if (level >= 0 && face_index < face_infos_.size() && | 913 if (level >= base_level_ && face_index < face_infos_.size() && |
912 static_cast<size_t>(level) < face_infos_[face_index].level_infos.size()) { | 914 static_cast<size_t>(level) < face_infos_[face_index].level_infos.size()) { |
913 const LevelInfo& info = face_infos_[face_index].level_infos[level]; | 915 const LevelInfo& info = face_infos_[face_index].level_infos[level]; |
914 if (info.target != 0) { | 916 if (info.target != 0) { |
915 *type = info.type; | 917 *type = info.type; |
916 *internal_format = info.internal_format; | 918 *internal_format = info.internal_format; |
917 return true; | 919 return true; |
918 } | 920 } |
919 } | 921 } |
920 return false; | 922 return false; |
921 } | 923 } |
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1066 npot_ = (target_ == GL_TEXTURE_EXTERNAL_OES) || (num_npot_faces_ > 0); | 1068 npot_ = (target_ == GL_TEXTURE_EXTERNAL_OES) || (num_npot_faces_ > 0); |
1067 | 1069 |
1068 if (face_infos_.empty()) { | 1070 if (face_infos_.empty()) { |
1069 texture_complete_ = false; | 1071 texture_complete_ = false; |
1070 cube_complete_ = false; | 1072 cube_complete_ = false; |
1071 return; | 1073 return; |
1072 } | 1074 } |
1073 | 1075 |
1074 // Update texture_complete and cube_complete status. | 1076 // Update texture_complete and cube_complete status. |
1075 const Texture::FaceInfo& first_face = face_infos_[0]; | 1077 const Texture::FaceInfo& first_face = face_infos_[0]; |
1076 const Texture::LevelInfo& first_level = first_face.level_infos[0]; | 1078 const Texture::LevelInfo& first_level = first_face.level_infos[base_level_]; |
1077 const GLsizei levels_needed = first_face.num_mip_levels; | 1079 const GLsizei levels_needed = first_face.num_mip_levels; |
1078 | 1080 |
1079 texture_complete_ = | 1081 texture_complete_ = |
1080 max_level_set_ >= (levels_needed - 1) && max_level_set_ >= 0; | 1082 max_level_set_ >= (levels_needed - 1) && max_level_set_ >= 0; |
1081 cube_complete_ = (face_infos_.size() == 6) && | 1083 cube_complete_ = (face_infos_.size() == 6) && |
1082 (first_level.width == first_level.height); | 1084 (first_level.width == first_level.height); |
1083 | 1085 |
1084 if (first_level.width == 0 || first_level.height == 0) { | 1086 if (first_level.width == 0 || first_level.height == 0) { |
1085 texture_complete_ = false; | 1087 texture_complete_ = false; |
1086 } else if (first_level.type == GL_FLOAT && | 1088 } else if (first_level.type == GL_FLOAT && |
1087 !feature_info->feature_flags().enable_texture_float_linear && | 1089 !feature_info->feature_flags().enable_texture_float_linear && |
1088 (min_filter_ != GL_NEAREST_MIPMAP_NEAREST || | 1090 (min_filter_ != GL_NEAREST_MIPMAP_NEAREST || |
1089 mag_filter_ != GL_NEAREST)) { | 1091 mag_filter_ != GL_NEAREST)) { |
1090 texture_complete_ = false; | 1092 texture_complete_ = false; |
1091 } else if (first_level.type == GL_HALF_FLOAT_OES && | 1093 } else if (first_level.type == GL_HALF_FLOAT_OES && |
1092 !feature_info->feature_flags().enable_texture_half_float_linear && | 1094 !feature_info->feature_flags().enable_texture_half_float_linear && |
1093 (min_filter_ != GL_NEAREST_MIPMAP_NEAREST || | 1095 (min_filter_ != GL_NEAREST_MIPMAP_NEAREST || |
1094 mag_filter_ != GL_NEAREST)) { | 1096 mag_filter_ != GL_NEAREST)) { |
1095 texture_complete_ = false; | 1097 texture_complete_ = false; |
1096 } | 1098 } |
1097 | 1099 |
1098 if (cube_complete_ && texture_level0_dirty_) { | 1100 if (cube_complete_ && texture_level0_dirty_) { |
1099 texture_level0_complete_ = true; | 1101 texture_level0_complete_ = true; |
1100 for (size_t ii = 0; ii < face_infos_.size(); ++ii) { | 1102 for (size_t ii = 0; ii < face_infos_.size(); ++ii) { |
1101 const Texture::LevelInfo& level0 = face_infos_[ii].level_infos[0]; | 1103 const Texture::LevelInfo& level0 = |
| 1104 face_infos_[ii].level_infos[base_level_]; |
1102 if (!TextureFaceComplete(first_level, | 1105 if (!TextureFaceComplete(first_level, |
1103 ii, | 1106 ii, |
1104 level0.target, | 1107 level0.target, |
1105 level0.internal_format, | 1108 level0.internal_format, |
1106 level0.width, | 1109 level0.width, |
1107 level0.height, | 1110 level0.height, |
1108 level0.depth, | 1111 level0.depth, |
1109 level0.format, | 1112 level0.format, |
1110 level0.type)) { | 1113 level0.type)) { |
1111 texture_level0_complete_ = false; | 1114 texture_level0_complete_ = false; |
1112 break; | 1115 break; |
1113 } | 1116 } |
1114 } | 1117 } |
1115 texture_level0_dirty_ = false; | 1118 texture_level0_dirty_ = false; |
1116 } | 1119 } |
1117 cube_complete_ &= texture_level0_complete_; | 1120 cube_complete_ &= texture_level0_complete_; |
1118 | 1121 |
1119 if (texture_complete_ && texture_mips_dirty_) { | 1122 if (texture_complete_ && texture_mips_dirty_) { |
1120 texture_mips_complete_ = true; | 1123 texture_mips_complete_ = true; |
1121 for (size_t ii = 0; | 1124 for (size_t ii = 0; |
1122 ii < face_infos_.size() && texture_mips_complete_; | 1125 ii < face_infos_.size() && texture_mips_complete_; |
1123 ++ii) { | 1126 ++ii) { |
1124 const Texture::FaceInfo& face_info = face_infos_[ii]; | 1127 const Texture::FaceInfo& face_info = face_infos_[ii]; |
1125 const Texture::LevelInfo& level0 = face_info.level_infos[0]; | 1128 const Texture::LevelInfo& level0 = face_info.level_infos[base_level_]; |
1126 for (GLsizei jj = 1; jj < levels_needed; ++jj) { | 1129 for (GLsizei jj = base_level_ + 1; |
| 1130 jj < base_level_ + levels_needed; |
| 1131 ++jj) { |
1127 const Texture::LevelInfo& level_info = face_infos_[ii].level_infos[jj]; | 1132 const Texture::LevelInfo& level_info = face_infos_[ii].level_infos[jj]; |
1128 if (!TextureMipComplete(level0, | 1133 if (!TextureMipComplete(level0, |
1129 level_info.target, | 1134 level_info.target, |
1130 jj, | 1135 jj - base_level_, |
1131 level_info.internal_format, | 1136 level_info.internal_format, |
1132 level_info.width, | 1137 level_info.width, |
1133 level_info.height, | 1138 level_info.height, |
1134 level_info.depth, | 1139 level_info.depth, |
1135 level_info.format, | 1140 level_info.format, |
1136 level_info.type)) { | 1141 level_info.type)) { |
1137 texture_mips_complete_ = false; | 1142 texture_mips_complete_ = false; |
1138 break; | 1143 break; |
1139 } | 1144 } |
1140 } | 1145 } |
1141 } | 1146 } |
1142 texture_mips_dirty_ = false; | 1147 texture_mips_dirty_ = false; |
1143 } | 1148 } |
1144 texture_complete_ &= texture_mips_complete_; | 1149 texture_complete_ &= texture_mips_complete_; |
1145 } | 1150 } |
1146 | 1151 |
1147 bool Texture::ClearRenderableLevels(GLES2Decoder* decoder) { | 1152 bool Texture::ClearRenderableLevels(GLES2Decoder* decoder) { |
1148 DCHECK(decoder); | 1153 DCHECK(decoder); |
1149 if (cleared_) { | 1154 if (cleared_) { |
1150 return true; | 1155 return true; |
1151 } | 1156 } |
1152 | 1157 |
1153 for (size_t ii = 0; ii < face_infos_.size(); ++ii) { | 1158 for (size_t ii = 0; ii < face_infos_.size(); ++ii) { |
1154 const Texture::FaceInfo& face_info = face_infos_[ii]; | 1159 const Texture::FaceInfo& face_info = face_infos_[ii]; |
1155 for (GLint jj = 0; jj < face_info.num_mip_levels; ++jj) { | 1160 for (GLint jj = base_level_; |
| 1161 jj < base_level_ + face_info.num_mip_levels; |
| 1162 ++jj) { |
1156 const Texture::LevelInfo& info = face_info.level_infos[jj]; | 1163 const Texture::LevelInfo& info = face_info.level_infos[jj]; |
1157 if (info.target != 0) { | 1164 if (info.target != 0) { |
1158 if (!ClearLevel(decoder, info.target, jj)) { | 1165 if (!ClearLevel(decoder, info.target, jj)) { |
1159 return false; | 1166 return false; |
1160 } | 1167 } |
1161 } | 1168 } |
1162 } | 1169 } |
1163 } | 1170 } |
1164 UpdateSafeToRenderFrom(true); | 1171 UpdateSafeToRenderFrom(true); |
1165 return true; | 1172 return true; |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1246 UpdateMipCleared(&info, info.width, info.height, | 1253 UpdateMipCleared(&info, info.width, info.height, |
1247 gfx::Rect(info.width, info.height)); | 1254 gfx::Rect(info.width, info.height)); |
1248 return true; | 1255 return true; |
1249 } | 1256 } |
1250 | 1257 |
1251 void Texture::SetLevelImage( | 1258 void Texture::SetLevelImage( |
1252 const FeatureInfo* feature_info, | 1259 const FeatureInfo* feature_info, |
1253 GLenum target, | 1260 GLenum target, |
1254 GLint level, | 1261 GLint level, |
1255 gfx::GLImage* image) { | 1262 gfx::GLImage* image) { |
1256 DCHECK_GE(level, 0); | 1263 DCHECK_GE(level, base_level_); |
1257 size_t face_index = GLES2Util::GLTargetToFaceIndex(target); | 1264 size_t face_index = GLES2Util::GLTargetToFaceIndex(target); |
1258 DCHECK_LT(static_cast<size_t>(face_index), | 1265 DCHECK_LT(static_cast<size_t>(face_index), |
1259 face_infos_.size()); | 1266 face_infos_.size()); |
1260 DCHECK_LT(static_cast<size_t>(level), | 1267 DCHECK_LT(static_cast<size_t>(level), |
1261 face_infos_[face_index].level_infos.size()); | 1268 face_infos_[face_index].level_infos.size()); |
1262 Texture::LevelInfo& info = | 1269 Texture::LevelInfo& info = |
1263 face_infos_[face_index].level_infos[level]; | 1270 face_infos_[face_index].level_infos[level]; |
1264 DCHECK_EQ(info.target, target); | 1271 DCHECK_EQ(info.target, target); |
1265 DCHECK_EQ(info.level, level); | 1272 DCHECK_EQ(info.level, level); |
1266 info.image = image; | 1273 info.image = image; |
1267 UpdateCanRenderCondition(); | 1274 UpdateCanRenderCondition(); |
1268 UpdateHasImages(); | 1275 UpdateHasImages(); |
1269 | 1276 |
1270 // TODO(ericrk): Images may have complex sizing not accounted for by | 1277 // TODO(ericrk): Images may have complex sizing not accounted for by |
1271 // |estimated_size_|, we should add logic here to update |estimated_size_| | 1278 // |estimated_size_|, we should add logic here to update |estimated_size_| |
1272 // based on the new GLImage. crbug.com/526298 | 1279 // based on the new GLImage. crbug.com/526298 |
1273 } | 1280 } |
1274 | 1281 |
1275 gfx::GLImage* Texture::GetLevelImage(GLint target, GLint level) const { | 1282 gfx::GLImage* Texture::GetLevelImage(GLint target, GLint level) const { |
1276 if (target != GL_TEXTURE_2D && target != GL_TEXTURE_EXTERNAL_OES && | 1283 if (target != GL_TEXTURE_2D && target != GL_TEXTURE_EXTERNAL_OES && |
1277 target != GL_TEXTURE_RECTANGLE_ARB) { | 1284 target != GL_TEXTURE_RECTANGLE_ARB) { |
1278 return NULL; | 1285 return NULL; |
1279 } | 1286 } |
1280 | 1287 |
1281 size_t face_index = GLES2Util::GLTargetToFaceIndex(target); | 1288 size_t face_index = GLES2Util::GLTargetToFaceIndex(target); |
1282 if (level >= 0 && face_index < face_infos_.size() && | 1289 if (level >= base_level_ && face_index < face_infos_.size() && |
1283 static_cast<size_t>(level) < face_infos_[face_index].level_infos.size()) { | 1290 static_cast<size_t>(level) < face_infos_[face_index].level_infos.size()) { |
1284 const LevelInfo& info = face_infos_[face_index].level_infos[level]; | 1291 const LevelInfo& info = face_infos_[face_index].level_infos[level]; |
1285 if (info.target != 0) { | 1292 if (info.target != 0) { |
1286 return info.image.get(); | 1293 return info.image.get(); |
1287 } | 1294 } |
1288 } | 1295 } |
1289 return NULL; | 1296 return NULL; |
1290 } | 1297 } |
1291 | 1298 |
1292 void Texture::OnWillModifyPixels() { | 1299 void Texture::OnWillModifyPixels() { |
(...skipping 906 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2199 pmd->AddOwnershipEdge(client_guid, service_guid, importance); | 2206 pmd->AddOwnershipEdge(client_guid, service_guid, importance); |
2200 | 2207 |
2201 // Dump all sub-levels held by the texture. They will appear below the main | 2208 // Dump all sub-levels held by the texture. They will appear below the main |
2202 // gl/textures/client_X/texture_Y dump. | 2209 // gl/textures/client_X/texture_Y dump. |
2203 ref->texture()->DumpLevelMemory(pmd, memory_tracker_->ClientTracingId(), | 2210 ref->texture()->DumpLevelMemory(pmd, memory_tracker_->ClientTracingId(), |
2204 dump_name); | 2211 dump_name); |
2205 } | 2212 } |
2206 | 2213 |
2207 } // namespace gles2 | 2214 } // namespace gles2 |
2208 } // namespace gpu | 2215 } // namespace gpu |
OLD | NEW |