Index: gpu/command_buffer/service/texture_manager.cc |
diff --git a/gpu/command_buffer/service/texture_manager.cc b/gpu/command_buffer/service/texture_manager.cc |
index 7c378d405ee0b4473d91b8beb3bc49eb8a7eaf9c..45c84914a3325ef0377cc02917c1bfe6dc1881ef 100644 |
--- a/gpu/command_buffer/service/texture_manager.cc |
+++ b/gpu/command_buffer/service/texture_manager.cc |
@@ -150,9 +150,13 @@ TextureManager::TextureInfo::LevelInfo::LevelInfo(const LevelInfo& rhs) |
border(rhs.border), |
format(rhs.format), |
type(rhs.type), |
+ image(rhs.image), |
estimated_size(rhs.estimated_size) { |
} |
+TextureManager::TextureInfo::LevelInfo::~LevelInfo() { |
+} |
+ |
bool TextureManager::TextureInfo::CanRender( |
const FeatureInfo* feature_info) const { |
if (target_ == 0) { |
@@ -252,7 +256,8 @@ bool TextureManager::TextureInfo::CanGenerateMipmaps( |
(info.internal_format != first.internal_format) || |
(info.type != first.type) || |
feature_info->validators()->compressed_texture_format.IsValid( |
- info.internal_format)) { |
+ info.internal_format) || |
+ info.image) { |
return false; |
} |
} |
@@ -327,6 +332,7 @@ void TextureManager::TextureInfo::SetLevelInfo( |
info.border = border; |
info.format = format; |
info.type = type; |
+ info.image = 0; |
estimated_size_ -= info.estimated_size; |
GLES2Util::ComputeImageDataSizes( |
@@ -616,6 +622,36 @@ bool TextureManager::TextureInfo::ClearLevel( |
return info.cleared; |
} |
+void TextureManager::TextureInfo::SetLevelImage( |
+ const FeatureInfo* feature_info, |
+ GLenum target, |
+ GLint level, |
+ scoped_refptr<gfx::GLImage> image) { |
+ DCHECK_GE(level, 0); |
+ DCHECK_LT(static_cast<size_t>(GLTargetToFaceIndex(target)), |
+ level_infos_.size()); |
+ DCHECK_LT(static_cast<size_t>(level), |
+ level_infos_[GLTargetToFaceIndex(target)].size()); |
+ TextureInfo::LevelInfo& info = |
+ level_infos_[GLTargetToFaceIndex(target)][level]; |
+ DCHECK_EQ(info.target, target); |
+ DCHECK_EQ(info.level, level); |
+ info.image = image; |
+} |
+ |
+scoped_refptr<gfx::GLImage> TextureManager::TextureInfo::GetLevelImage( |
+ GLint face, GLint level) const { |
+ size_t face_index = GLTargetToFaceIndex(face); |
+ if (level >= 0 && face_index < level_infos_.size() && |
+ static_cast<size_t>(level) < level_infos_[face_index].size()) { |
+ const LevelInfo& info = level_infos_[GLTargetToFaceIndex(face)][level]; |
+ if (info.target != 0) { |
+ return info.image; |
+ } |
+ } |
+ return 0; |
+} |
+ |
TextureManager::TextureManager( |
MemoryTracker* memory_tracker, |
FeatureInfo* feature_info, |
@@ -1070,5 +1106,28 @@ GLsizei TextureManager::ComputeMipMapCount( |
return 1 + base::bits::Log2Floor(std::max(std::max(width, height), depth)); |
} |
+void TextureManager::SetLevelImage( |
+ TextureManager::TextureInfo* info, |
+ GLenum target, |
+ GLint level, |
+ scoped_refptr<gfx::GLImage> image) { |
+ DCHECK(info); |
+ if (!info->CanRender(feature_info_)) { |
+ DCHECK_NE(0, num_unrenderable_textures_); |
+ --num_unrenderable_textures_; |
+ } |
+ if (!info->SafeToRenderFrom()) { |
+ DCHECK_NE(0, num_unsafe_textures_); |
+ --num_unsafe_textures_; |
+ } |
+ info->SetLevelImage(feature_info_, target, level, image); |
+ if (!info->CanRender(feature_info_)) { |
+ ++num_unrenderable_textures_; |
+ } |
+ if (!info->SafeToRenderFrom()) { |
+ ++num_unsafe_textures_; |
+ } |
+} |
+ |
} // namespace gles2 |
} // namespace gpu |