Commit 7678ba8a authored by henrika's avatar henrika Committed by Commit Bot

Adds support of new mailbox type in SkiaOutputDeviceGL::GetGLImageForMailbox

SkiaOutputDeviceGL can sometimes look in the wrong place for a texture.
It is using a deprecated system (MailboxManager) to find a texture based
on a mailbox (which is just an opaque id), because existing Windows
video overlay code still used the old GL texture system so the mapping
is stored there.

This CL adds code to look in the new shared images system to lookup a
texture from a mailbox and it will be required when upcoming changes in
"Zero-Copy Camera Capture Optimizations on Windows" [1] lands to ensure
that Skia rendering also works with these new changes. The upcoming code
uses the new system, so the mapping is stored there.

Note that, the changes in this CL will not have any effect until the
work in [1] lands in Chrome.

[1] https://bugs.chromium.org/p/chromium/issues/detail?id=1120900

Bug: 1120900
Change-Id: I09b5f0b06ff7539a9448a5b28bbfef89b3666331
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2391236Reviewed-by: default avatarkylechar <kylechar@chromium.org>
Commit-Queue: Henrik Andreasson <henrika@chromium.org>
Cr-Commit-Position: refs/heads/master@{#804386}
parent e1961736
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
#include "gpu/command_buffer/service/gl_utils.h" #include "gpu/command_buffer/service/gl_utils.h"
#include "gpu/command_buffer/service/mailbox_manager.h" #include "gpu/command_buffer/service/mailbox_manager.h"
#include "gpu/command_buffer/service/shared_context_state.h" #include "gpu/command_buffer/service/shared_context_state.h"
#include "gpu/command_buffer/service/shared_image_factory.h"
#include "gpu/command_buffer/service/texture_base.h" #include "gpu/command_buffer/service/texture_base.h"
#include "gpu/command_buffer/service/texture_manager.h" #include "gpu/command_buffer/service/texture_manager.h"
#include "third_party/skia/include/core/SkSurface.h" #include "third_party/skia/include/core/SkSurface.h"
...@@ -34,6 +35,7 @@ namespace viz { ...@@ -34,6 +35,7 @@ namespace viz {
SkiaOutputDeviceGL::SkiaOutputDeviceGL( SkiaOutputDeviceGL::SkiaOutputDeviceGL(
gpu::MailboxManager* mailbox_manager, gpu::MailboxManager* mailbox_manager,
gpu::SharedImageRepresentationFactory* shared_image_representation_factory,
gpu::SharedContextState* context_state, gpu::SharedContextState* context_state,
scoped_refptr<gl::GLSurface> gl_surface, scoped_refptr<gl::GLSurface> gl_surface,
scoped_refptr<gpu::gles2::FeatureInfo> feature_info, scoped_refptr<gpu::gles2::FeatureInfo> feature_info,
...@@ -43,6 +45,7 @@ SkiaOutputDeviceGL::SkiaOutputDeviceGL( ...@@ -43,6 +45,7 @@ SkiaOutputDeviceGL::SkiaOutputDeviceGL(
memory_tracker, memory_tracker,
std::move(did_swap_buffer_complete_callback)), std::move(did_swap_buffer_complete_callback)),
mailbox_manager_(mailbox_manager), mailbox_manager_(mailbox_manager),
shared_image_representation_factory_(shared_image_representation_factory),
context_state_(context_state), context_state_(context_state),
gl_surface_(std::move(gl_surface)), gl_surface_(std::move(gl_surface)),
supports_async_swap_(gl_surface_->SupportsAsyncSwap()) { supports_async_swap_(gl_surface_->SupportsAsyncSwap()) {
...@@ -344,11 +347,23 @@ void SkiaOutputDeviceGL::EndPaint() {} ...@@ -344,11 +347,23 @@ void SkiaOutputDeviceGL::EndPaint() {}
scoped_refptr<gl::GLImage> SkiaOutputDeviceGL::GetGLImageForMailbox( scoped_refptr<gl::GLImage> SkiaOutputDeviceGL::GetGLImageForMailbox(
const gpu::Mailbox& mailbox) { const gpu::Mailbox& mailbox) {
// TODO(crbug.com/1005306): Use SharedImageManager to get textures here once // TODO(crbug.com/1005306): Stop using MailboxManager for lookup once all
// all clients are using SharedImageInterface to create textures. // clients are using SharedImageInterface to create textures.
auto* texture_base = mailbox_manager_->ConsumeTexture(mailbox); auto* texture_base = mailbox_manager_->ConsumeTexture(mailbox);
if (!texture_base) if (!texture_base) {
// Newer video paths use shared images to store textures.
std::unique_ptr<gpu::SharedImageRepresentationGLTexturePassthrough>
shared_image =
shared_image_representation_factory_->ProduceGLTexturePassthrough(
mailbox);
if (shared_image) {
gpu::gles2::TexturePassthrough* texture =
shared_image->GetTexturePassthrough().get();
return texture->GetLevelImage(texture->target(), 0);
}
return nullptr; return nullptr;
}
if (texture_base->GetType() == gpu::TextureBase::Type::kPassthrough) { if (texture_base->GetType() == gpu::TextureBase::Type::kPassthrough) {
gpu::gles2::TexturePassthrough* texture = gpu::gles2::TexturePassthrough* texture =
......
...@@ -12,7 +12,6 @@ ...@@ -12,7 +12,6 @@
#include "base/memory/ref_counted.h" #include "base/memory/ref_counted.h"
#include "base/memory/weak_ptr.h" #include "base/memory/weak_ptr.h"
#include "components/viz/service/display_embedder/skia_output_device.h" #include "components/viz/service/display_embedder/skia_output_device.h"
#include "gpu/command_buffer/common/mailbox.h"
namespace gl { namespace gl {
class GLImage; class GLImage;
...@@ -22,6 +21,7 @@ class GLSurface; ...@@ -22,6 +21,7 @@ class GLSurface;
namespace gpu { namespace gpu {
class MailboxManager; class MailboxManager;
class SharedContextState; class SharedContextState;
class SharedImageRepresentationFactory;
namespace gles2 { namespace gles2 {
class FeatureInfo; class FeatureInfo;
...@@ -34,6 +34,8 @@ class SkiaOutputDeviceGL final : public SkiaOutputDevice { ...@@ -34,6 +34,8 @@ class SkiaOutputDeviceGL final : public SkiaOutputDevice {
public: public:
SkiaOutputDeviceGL( SkiaOutputDeviceGL(
gpu::MailboxManager* mailbox_manager, gpu::MailboxManager* mailbox_manager,
gpu::SharedImageRepresentationFactory*
shared_image_representation_factory,
gpu::SharedContextState* context_state, gpu::SharedContextState* context_state,
scoped_refptr<gl::GLSurface> gl_surface, scoped_refptr<gl::GLSurface> gl_surface,
scoped_refptr<gpu::gles2::FeatureInfo> feature_info, scoped_refptr<gpu::gles2::FeatureInfo> feature_info,
...@@ -75,6 +77,9 @@ class SkiaOutputDeviceGL final : public SkiaOutputDevice { ...@@ -75,6 +77,9 @@ class SkiaOutputDeviceGL final : public SkiaOutputDevice {
gpu::MailboxManager* const mailbox_manager_; gpu::MailboxManager* const mailbox_manager_;
gpu::SharedImageRepresentationFactory* const
shared_image_representation_factory_;
gpu::SharedContextState* const context_state_; gpu::SharedContextState* const context_state_;
scoped_refptr<gl::GLSurface> gl_surface_; scoped_refptr<gl::GLSurface> gl_surface_;
const bool supports_async_swap_; const bool supports_async_swap_;
......
...@@ -1078,7 +1078,8 @@ bool SkiaOutputSurfaceImplOnGpu::InitializeForGL() { ...@@ -1078,7 +1078,8 @@ bool SkiaOutputSurfaceImplOnGpu::InitializeForGL() {
GetDidSwapBuffersCompleteCallback()); GetDidSwapBuffersCompleteCallback());
} else { } else {
output_device_ = std::make_unique<SkiaOutputDeviceGL>( output_device_ = std::make_unique<SkiaOutputDeviceGL>(
dependency_->GetMailboxManager(), context_state_.get(), dependency_->GetMailboxManager(),
shared_image_representation_factory_.get(), context_state_.get(),
gl_surface_, feature_info_, memory_tracker_, gl_surface_, feature_info_, memory_tracker_,
GetDidSwapBuffersCompleteCallback()); GetDidSwapBuffersCompleteCallback());
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment