Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(522)

Unified Diff: gpu/command_buffer/service/stream_texture_manager_in_process_android.cc

Issue 1401423003: Re-land: ui: Move GLImage::BindTexImage fallback from GLImage implementations to GLES2CmdDecoder. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix stream texture issue Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..40908a8cccc07f2aa427dc37175e15c91e48471d 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,9 @@ namespace {
// Simply wraps a SurfaceTexture reference as a GLImage.
class GLImageImpl : public gfx::GLImage {
public:
- GLImageImpl(const scoped_refptr<gfx::SurfaceTexture>& surface_texture,
+ GLImageImpl(uint32 texture_id,
+ gles2::TextureManager* texture_manager,
+ const scoped_refptr<gfx::SurfaceTexture>& surface_texture,
const base::Closure& release_callback);
// implement gfx::GLImage
@@ -28,13 +30,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 +46,8 @@ class GLImageImpl : public gfx::GLImage {
private:
~GLImageImpl() override;
+ uint32 texture_id_;
+ gles2::TextureManager* texture_manager_;
scoped_refptr<gfx::SurfaceTexture> surface_texture_;
base::Closure release_callback_;
@@ -54,9 +55,14 @@ class GLImageImpl : public gfx::GLImage {
};
GLImageImpl::GLImageImpl(
+ uint32 texture_id,
+ gles2::TextureManager* texture_manager,
const scoped_refptr<gfx::SurfaceTexture>& surface_texture,
const base::Closure& release_callback)
- : surface_texture_(surface_texture), release_callback_(release_callback) {}
+ : texture_id_(texture_id),
+ texture_manager_(texture_manager),
+ surface_texture_(surface_texture),
+ release_callback_(release_callback) {}
GLImageImpl::~GLImageImpl() {
release_callback_.Run();
@@ -83,16 +89,39 @@ void GLImageImpl::ReleaseTexImage(unsigned target) {
NOTREACHED();
}
+bool GLImageImpl::CopyTexImage(unsigned target) {
+ if (target != GL_TEXTURE_EXTERNAL_OES)
+ return false;
+
+ GLint texture_id;
+ glGetIntegerv(GL_TEXTURE_BINDING_EXTERNAL_OES, &texture_id);
+ DCHECK(texture_id);
+
+ // The following code only works if we're being asked to copy into
+ // |texture_id_|. Copying into a different texture is not supported.
+ if (static_cast<unsigned>(texture_id) != texture_id_)
+ return false;
+
+ surface_texture_->UpdateTexImage();
+
+ gles2::Texture* texture =
+ texture_manager_->GetTextureForServiceId(texture_id_);
+ if (texture) {
+ // 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->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 +168,17 @@ 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->service_id(), texture_manager, 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_);
« no previous file with comments | « gpu/command_buffer/service/mailbox_manager_sync.cc ('k') | gpu/command_buffer/service/texture_definition.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698