Fix StreamTexture size
crrev.com/c/1629792 relies on the LevelInfo being properly set even for
GL_TEXTURE_EXTERNAL_OES. This wasn't true for StreamTexture, as while
it sets up the LevelInfo, it does it before it knows the size, and we
end up with a zero-sized level which we consider as unrenderable.
This CL updates the LevelInfo as soon as we know the size.
(cherry picked from commit 2a27c84086b0e81685427feb13f3b466fef0136f)
Bug: 972805
Change-Id: Ie29a05f603f14c3ebd618a864c376533a07e457f
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1652574
Commit-Queue: Antoine Labour <piman@chromium.org>
Reviewed-by: Eric Karl <ericrk@chromium.org>
Cr-Original-Commit-Position: refs/heads/master@{#667889}
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1658957
Reviewed-by: Antoine Labour <piman@chromium.org>
Cr-Commit-Position: refs/branch-heads/3809@{#306}
Cr-Branched-From: d82dec1a818f378c464ba307ddd9c92133eac355-refs/heads/master@{#665002}
diff --git a/gpu/command_buffer/service/texture_manager.h b/gpu/command_buffer/service/texture_manager.h
index 27df199..d149cf5 100644
--- a/gpu/command_buffer/service/texture_manager.h
+++ b/gpu/command_buffer/service/texture_manager.h
@@ -51,6 +51,7 @@
class SharedImageRepresentationGLTextureIOSurface;
class SharedImageRepresentationSkiaIOSurface;
class SharedImageBackingDXGISwapChain;
+class StreamTexture;
class SwapChainFactoryDXGI;
namespace gles2 {
@@ -417,6 +418,7 @@
friend class gpu::SwapChainFactoryDXGI;
friend class gpu::SharedImageRepresentationGLTextureIOSurface;
friend class gpu::SharedImageRepresentationSkiaIOSurface;
+ friend class gpu::StreamTexture;
friend class AbstractTextureImplOnSharedContext;
friend class TextureDefinition;
friend class TextureManager;
diff --git a/gpu/ipc/service/stream_texture_android.cc b/gpu/ipc/service/stream_texture_android.cc
index 1b66ba80..8d6d9f6 100644
--- a/gpu/ipc/service/stream_texture_android.cc
+++ b/gpu/ipc/service/stream_texture_android.cc
@@ -223,6 +223,30 @@
surface_owner_.get());
}
+void StreamTexture::OnSetSize(const gfx::Size& size) {
+ size_ = size;
+ if (!owner_stub_ || !surface_owner_.get())
+ return;
+
+ gles2::ContextGroup* context_group =
+ owner_stub_->decoder_context()->GetContextGroup();
+ DCHECK(context_group);
+ TextureManager* texture_manager = context_group->texture_manager();
+ gles2::Texture* texture =
+ texture_manager->GetTextureForServiceId(texture_id_);
+ if (texture) {
+ // SetLevelInfo will reset the image / stream texture image, which may be
+ // the last reference to |this|, so keep a reference around, and make sure
+ // to reset the stream texture image.
+ scoped_refptr<StreamTexture> self(this);
+ texture->SetLevelInfo(GL_TEXTURE_EXTERNAL_OES, 0, GL_RGBA, size.width(),
+ size.height(), 1, 0, GL_RGBA, GL_UNSIGNED_BYTE,
+ gfx::Rect(size));
+ texture->SetLevelStreamTextureImage(GL_TEXTURE_EXTERNAL_OES, 0, this,
+ gles2::Texture::UNBOUND, 0);
+ }
+}
+
StreamTexture::BindOrCopy StreamTexture::ShouldBindOrCopy() {
return COPY;
}
diff --git a/gpu/ipc/service/stream_texture_android.h b/gpu/ipc/service/stream_texture_android.h
index 0fbac37..aabd38f9 100644
--- a/gpu/ipc/service/stream_texture_android.h
+++ b/gpu/ipc/service/stream_texture_android.h
@@ -90,7 +90,7 @@
// IPC message handlers:
void OnStartListening();
void OnForwardForSurfaceRequest(const base::UnguessableToken& request_token);
- void OnSetSize(const gfx::Size& size) { size_ = size; }
+ void OnSetSize(const gfx::Size& size);
std::unique_ptr<SurfaceOwner> surface_owner_;