Chromium Code Reviews| 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 f6a75dd40e91325cd5bc88ee00c8f5b83fb822d3..bba568f5dd6cb3a922cb4f456b5682d550aa88d9 100644 |
| --- a/gpu/command_buffer/service/texture_manager.cc |
| +++ b/gpu/command_buffer/service/texture_manager.cc |
| @@ -803,6 +803,52 @@ void Texture::SetLevelCleared(GLenum target, GLint level, bool cleared) { |
| UpdateCleared(); |
| } |
| +void Texture::SetLevelCleared(GLenum target, |
| + GLint level, |
| + GLenum attachment, |
| + bool cleared) { |
| + DCHECK_GE(level, 0); |
| + // Only take effect when the format is DEPTH_STENCIL |
| + size_t face_index = GLES2Util::GLTargetToFaceIndex(target); |
| + DCHECK_LT(static_cast<size_t>(face_index), face_infos_.size()); |
| + DCHECK_LT(static_cast<size_t>(level), |
| + face_infos_[face_index].level_infos.size()); |
| + Texture::LevelInfo& info = face_infos_[face_index].level_infos[level]; |
| + if (info.format != GL_DEPTH_STENCIL) |
|
qiankun
2016/07/14 06:48:21
Will this be true in any conditions? I think only
|
| + return; |
| + // cleared_ is true only when both depth and stencil part are cleared. |
| + if (attachment == GL_DEPTH_ATTACHMENT) { |
| + if (cleared == stencil_cleared_) { |
| + // SetLevelCleared(target, level, cleared); |
|
qiankun
2016/07/14 06:48:22
remove unused code.
|
| + UpdateMipCleared(&info, info.width, info.height, |
| + cleared ? gfx::Rect(info.width, info.height) : |
| + gfx::Rect()); |
| + UpdateCleared(); |
| + } else { |
| + // SetLevelCleared(target, level, false); |
| + UpdateMipCleared(&info, info.width, info.height, gfx::Rect()); |
| + UpdateCleared(); |
| + depth_cleared_ = cleared; |
| + stencil_cleared_ = !cleared; |
|
qiankun
2016/07/14 06:48:21
Should depth_cleared_ be updated in if branch?
ste
|
| + } |
| + } |
| + else if (attachment == GL_STENCIL_ATTACHMENT) { |
| + if (cleared == depth_cleared_) { |
| + // SetLevelCleared(target, level, cleared); |
| + UpdateMipCleared(&info, info.width, info.height, |
| + cleared ? gfx::Rect(info.width, info.height) : |
| + gfx::Rect()); |
| + UpdateCleared(); |
| + } else { |
| + // SetLevelCleared(target, level, false); |
| + UpdateMipCleared(&info, info.width, info.height, gfx::Rect()); |
| + UpdateCleared(); |
| + stencil_cleared_ = cleared; |
| + depth_cleared_ = !cleared; |
|
qiankun
2016/07/14 06:48:22
Same here.
|
| + } |
| + } |
| +} |
| + |
| void Texture::UpdateCleared() { |
| if (face_infos_.empty()) { |
| return; |
| @@ -826,6 +872,9 @@ void Texture::UpdateSafeToRenderFrom(bool cleared) { |
| int delta = cleared ? -1 : +1; |
| for (RefSet::iterator it = refs_.begin(); it != refs_.end(); ++it) |
| (*it)->manager()->UpdateSafeToRenderFrom(delta); |
| + |
| + depth_cleared_ = cleared; |
| + stencil_cleared_ = cleared; |
| } |
| void Texture::UpdateMipCleared(LevelInfo* info, |
| @@ -1403,6 +1452,26 @@ bool Texture::IsLevelCleared(GLenum target, GLint level) const { |
| return info.cleared_rect == gfx::Rect(info.width, info.height); |
| } |
| +bool Texture::IsLevelCleared(GLenum target, |
| + GLint level, |
| + GLenum attachment) const { |
|
qiankun
2016/07/14 06:48:21
ASSERT(attachment == GL_DEPTH_ATTACHMENT || attach
|
| + size_t face_index = GLES2Util::GLTargetToFaceIndex(target); |
| + if (face_index >= face_infos_.size() || |
| + level < 0 || |
| + level >= static_cast<GLint>(face_infos_[face_index].level_infos.size())) { |
| + return true; |
| + } |
| + const Texture::LevelInfo& info = face_infos_[face_index].level_infos[level]; |
| + if (info.format != GL_DEPTH_STENCIL) |
| + return info.cleared_rect == gfx::Rect(info.width, info.height); |
| + if (attachment == GL_DEPTH_ATTACHMENT) |
| + return depth_cleared_; |
| + else if (attachment == GL_STENCIL_ATTACHMENT) |
| + return stencil_cleared_; |
| + // Should not be reached |
| + return info.cleared_rect == gfx::Rect(info.width, info.height); |
|
qiankun
2016/07/14 06:48:21
change to return attachment == GL_DEPTH_ATTACHMEN
|
| +} |
| + |
| bool Texture::IsLevelPartiallyCleared(GLenum target, GLint level) const { |
| size_t face_index = GLES2Util::GLTargetToFaceIndex(target); |
| if (face_index >= face_infos_.size() || |
| @@ -1907,6 +1976,15 @@ void TextureManager::SetLevelCleared(TextureRef* ref, |
| ref->texture()->SetLevelCleared(target, level, cleared); |
| } |
| +void TextureManager::SetLevelCleared(TextureRef* ref, |
| + GLenum target, |
| + GLint level, |
| + GLenum attachment, |
| + bool cleared) { |
| + DCHECK(ref); |
| + ref->texture()->SetLevelCleared(target, level, attachment, cleared); |
| +} |
| + |
| bool TextureManager::ClearRenderableLevels( |
| GLES2Decoder* decoder, TextureRef* ref) { |
| DCHECK(ref); |