Index: gpu/command_buffer/service/stream_texture_manager_in_process_android.cc |
diff --git a/gpu/command_buffer/service/stream_texture_manager_in_process_android.cc b/gpu/command_buffer/service/stream_texture_manager_in_process_android.cc |
index e7e3a1f55a5ceaa00d71782631dc2104dfeb1510..61bdf051d58f912da7b915dc88509b10b4f2aa88 100644 |
--- a/gpu/command_buffer/service/stream_texture_manager_in_process_android.cc |
+++ b/gpu/command_buffer/service/stream_texture_manager_in_process_android.cc |
@@ -19,7 +19,8 @@ namespace { |
// Simply wraps a SurfaceTexture reference as a GLImage. |
class GLImageImpl : public gfx::GLImage { |
public: |
- GLImageImpl(const scoped_refptr<gfx::SurfaceTexture>& surface_texture, |
+ GLImageImpl(gles2::TextureRef* texture_ref, |
+ const scoped_refptr<gfx::SurfaceTexture>& surface_texture, |
const base::Closure& release_callback); |
// implement gfx::GLImage |
@@ -28,13 +29,10 @@ class GLImageImpl : public gfx::GLImage { |
unsigned GetInternalFormat() override; |
bool BindTexImage(unsigned target) override; |
void ReleaseTexImage(unsigned target) override; |
+ bool CopyTexImage(unsigned target) override; |
bool CopyTexSubImage(unsigned target, |
const gfx::Point& offset, |
const gfx::Rect& rect) override; |
- void WillUseTexImage() override; |
- void DidUseTexImage() override {} |
- void WillModifyTexImage() override {} |
- void DidModifyTexImage() override {} |
bool ScheduleOverlayPlane(gfx::AcceleratedWidget widget, |
int z_order, |
gfx::OverlayTransform transform, |
@@ -47,6 +45,7 @@ class GLImageImpl : public gfx::GLImage { |
private: |
~GLImageImpl() override; |
+ gles2::TextureRef* texture_ref_; |
scoped_refptr<gfx::SurfaceTexture> surface_texture_; |
base::Closure release_callback_; |
@@ -54,9 +53,12 @@ class GLImageImpl : public gfx::GLImage { |
}; |
GLImageImpl::GLImageImpl( |
+ gles2::TextureRef* texture_ref, |
const scoped_refptr<gfx::SurfaceTexture>& surface_texture, |
const base::Closure& release_callback) |
- : surface_texture_(surface_texture), release_callback_(release_callback) {} |
+ : texture_ref_(texture_ref), |
+ surface_texture_(surface_texture), |
+ release_callback_(release_callback) {} |
GLImageImpl::~GLImageImpl() { |
release_callback_.Run(); |
@@ -83,16 +85,23 @@ void GLImageImpl::ReleaseTexImage(unsigned target) { |
NOTREACHED(); |
} |
+bool GLImageImpl::CopyTexImage(unsigned target) { |
+ surface_texture_->UpdateTexImage(); |
+ |
+ // By setting image state to UNBOUND instead of COPIED we ensure that |
+ // CopyTexImage() is called each time the surface texture is used for |
+ // drawing. |
+ texture_ref_->texture()->SetLevelImage(GL_TEXTURE_EXTERNAL_OES, 0, this, |
+ gles2::Texture::UNBOUND); |
+ return true; |
+} |
+ |
bool GLImageImpl::CopyTexSubImage(unsigned target, |
const gfx::Point& offset, |
const gfx::Rect& rect) { |
return false; |
} |
-void GLImageImpl::WillUseTexImage() { |
- surface_texture_->UpdateTexImage(); |
-} |
- |
bool GLImageImpl::ScheduleOverlayPlane(gfx::AcceleratedWidget widget, |
int z_order, |
gfx::OverlayTransform transform, |
@@ -139,16 +148,16 @@ GLuint StreamTextureManagerInProcess::CreateStreamTexture( |
base::Closure release_callback = |
base::Bind(&StreamTextureManagerInProcess::OnReleaseStreamTexture, |
weak_factory_.GetWeakPtr(), stream_id); |
- scoped_refptr<gfx::GLImage> gl_image(new GLImageImpl(surface_texture, |
- release_callback)); |
+ scoped_refptr<gfx::GLImage> gl_image( |
+ new GLImageImpl(texture, surface_texture, release_callback)); |
gfx::Size size = gl_image->GetSize(); |
texture_manager->SetTarget(texture, GL_TEXTURE_EXTERNAL_OES); |
texture_manager->SetLevelInfo(texture, GL_TEXTURE_EXTERNAL_OES, 0, GL_RGBA, |
size.width(), size.height(), 1, 0, GL_RGBA, |
GL_UNSIGNED_BYTE, gfx::Rect(size)); |
- texture_manager->SetLevelImage( |
- texture, GL_TEXTURE_EXTERNAL_OES, 0, gl_image.get()); |
+ texture_manager->SetLevelImage(texture, GL_TEXTURE_EXTERNAL_OES, 0, |
+ gl_image.get(), gles2::Texture::UNBOUND); |
{ |
base::AutoLock lock(map_lock_); |