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 #include "base/bits.h" | 6 #include "base/bits.h" |
7 #include "base/strings/stringprintf.h" | 7 #include "base/strings/stringprintf.h" |
8 #include "gpu/command_buffer/common/gles2_cmd_utils.h" | 8 #include "gpu/command_buffer/common/gles2_cmd_utils.h" |
9 #include "gpu/command_buffer/service/context_state.h" | 9 #include "gpu/command_buffer/service/context_state.h" |
10 #include "gpu/command_buffer/service/error_state.h" | 10 #include "gpu/command_buffer/service/error_state.h" |
(...skipping 788 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
799 Texture::LevelInfo& info = | 799 Texture::LevelInfo& info = |
800 level_infos_[GLTargetToFaceIndex(target)][level]; | 800 level_infos_[GLTargetToFaceIndex(target)][level]; |
801 DCHECK_EQ(info.target, target); | 801 DCHECK_EQ(info.target, target); |
802 DCHECK_EQ(info.level, level); | 802 DCHECK_EQ(info.level, level); |
803 info.image = image; | 803 info.image = image; |
804 UpdateCanRenderCondition(); | 804 UpdateCanRenderCondition(); |
805 UpdateHasImages(); | 805 UpdateHasImages(); |
806 } | 806 } |
807 | 807 |
808 gfx::GLImage* Texture::GetLevelImage(GLint target, GLint level) const { | 808 gfx::GLImage* Texture::GetLevelImage(GLint target, GLint level) const { |
| 809 if (target != GL_TEXTURE_2D && target != GL_TEXTURE_EXTERNAL_OES && |
| 810 target != GL_TEXTURE_RECTANGLE_ARB) { |
| 811 return NULL; |
| 812 } |
| 813 |
809 size_t face_index = GLTargetToFaceIndex(target); | 814 size_t face_index = GLTargetToFaceIndex(target); |
810 if (level >= 0 && face_index < level_infos_.size() && | 815 if (level >= 0 && face_index < level_infos_.size() && |
811 static_cast<size_t>(level) < level_infos_[face_index].size()) { | 816 static_cast<size_t>(level) < level_infos_[face_index].size()) { |
812 const LevelInfo& info = level_infos_[GLTargetToFaceIndex(target)][level]; | 817 const LevelInfo& info = level_infos_[GLTargetToFaceIndex(target)][level]; |
813 if (info.target != 0) { | 818 if (info.target != 0) { |
814 return info.image.get(); | 819 return info.image.get(); |
815 } | 820 } |
816 } | 821 } |
817 return 0; | 822 return 0; |
818 } | 823 } |
819 | 824 |
| 825 void Texture::OnWillModifyPixels() { |
| 826 gfx::GLImage* image = GetLevelImage(target(), 0); |
| 827 if (image) |
| 828 image->WillModifyTexImage(); |
| 829 } |
| 830 |
| 831 void Texture::OnDidModifyPixels() { |
| 832 gfx::GLImage* image = GetLevelImage(target(), 0); |
| 833 if (image) |
| 834 image->DidModifyTexImage(); |
| 835 } |
820 | 836 |
821 TextureRef::TextureRef(TextureManager* manager, | 837 TextureRef::TextureRef(TextureManager* manager, |
822 GLuint client_id, | 838 GLuint client_id, |
823 Texture* texture) | 839 Texture* texture) |
824 : manager_(manager), | 840 : manager_(manager), |
825 texture_(texture), | 841 texture_(texture), |
826 client_id_(client_id) { | 842 client_id_(client_id) { |
827 DCHECK(manager_); | 843 DCHECK(manager_); |
828 DCHECK(texture_); | 844 DCHECK(texture_); |
829 texture_->AddTextureRef(this); | 845 texture_->AddTextureRef(this); |
(...skipping 663 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1493 } | 1509 } |
1494 | 1510 |
1495 ScopedTextureUploadTimer::~ScopedTextureUploadTimer() { | 1511 ScopedTextureUploadTimer::~ScopedTextureUploadTimer() { |
1496 texture_state_->texture_upload_count++; | 1512 texture_state_->texture_upload_count++; |
1497 texture_state_->total_texture_upload_time += | 1513 texture_state_->total_texture_upload_time += |
1498 base::TimeTicks::HighResNow() - begin_time_; | 1514 base::TimeTicks::HighResNow() - begin_time_; |
1499 } | 1515 } |
1500 | 1516 |
1501 } // namespace gles2 | 1517 } // namespace gles2 |
1502 } // namespace gpu | 1518 } // namespace gpu |
OLD | NEW |