Commit 1958f5d0 authored by Fritz Koenig's avatar Fritz Koenig Committed by Commit Bot

blink: Use OpenGL to flip WebGL buffer

GL_FRAMEBUFFER_FLIP_Y_MESA will tell OpenGL
to render the image upside down.  Passing
the buffer along like this will allow
ChromeOS to scan out directly from the buffer.

BUG=680851

Change-Id: I142cec041358af17652f7314ac89e82678b78d3b
Reviewed-on: https://chromium-review.googlesource.com/1117365Reviewed-by: default avatarDaniel Cheng <dcheng@chromium.org>
Reviewed-by: default avatarKenneth Russell <kbr@chromium.org>
Commit-Queue: Fritz Koenig <frkoenig@chromium.org>
Cr-Commit-Position: refs/heads/master@{#577396}
parent a2d2076e
...@@ -149,6 +149,7 @@ IPC_STRUCT_TRAITS_BEGIN(gpu::Capabilities) ...@@ -149,6 +149,7 @@ IPC_STRUCT_TRAITS_BEGIN(gpu::Capabilities)
IPC_STRUCT_TRAITS_MEMBER(context_supports_distance_field_text) IPC_STRUCT_TRAITS_MEMBER(context_supports_distance_field_text)
IPC_STRUCT_TRAITS_MEMBER(glyph_cache_max_texture_bytes) IPC_STRUCT_TRAITS_MEMBER(glyph_cache_max_texture_bytes)
IPC_STRUCT_TRAITS_MEMBER(chromium_nonblocking_readback) IPC_STRUCT_TRAITS_MEMBER(chromium_nonblocking_readback)
IPC_STRUCT_TRAITS_MEMBER(mesa_framebuffer_flip_y)
IPC_STRUCT_TRAITS_MEMBER(major_version) IPC_STRUCT_TRAITS_MEMBER(major_version)
IPC_STRUCT_TRAITS_MEMBER(minor_version) IPC_STRUCT_TRAITS_MEMBER(minor_version)
......
...@@ -180,7 +180,9 @@ DrawingBuffer::DrawingBuffer( ...@@ -180,7 +180,9 @@ DrawingBuffer::DrawingBuffer(
sampler_color_space_(color_params.GetSamplerGfxColorSpace()), sampler_color_space_(color_params.GetSamplerGfxColorSpace()),
use_half_float_storage_(color_params.PixelFormat() == use_half_float_storage_(color_params.PixelFormat() ==
kF16CanvasPixelFormat), kF16CanvasPixelFormat),
chromium_image_usage_(chromium_image_usage) { chromium_image_usage_(chromium_image_usage),
opengl_flip_y_extension_(
ContextProvider()->GetCapabilities().mesa_framebuffer_flip_y) {
// Used by browser tests to detect the use of a DrawingBuffer. // Used by browser tests to detect the use of a DrawingBuffer.
TRACE_EVENT_INSTANT0("test_gpu", "DrawingBufferCreation", TRACE_EVENT_INSTANT0("test_gpu", "DrawingBufferCreation",
TRACE_EVENT_SCOPE_GLOBAL); TRACE_EVENT_SCOPE_GLOBAL);
...@@ -804,10 +806,15 @@ bool DrawingBuffer::Initialize(const IntSize& size, bool use_multisampling) { ...@@ -804,10 +806,15 @@ bool DrawingBuffer::Initialize(const IntSize& size, bool use_multisampling) {
state_restorer_->SetFramebufferBindingDirty(); state_restorer_->SetFramebufferBindingDirty();
gl_->GenFramebuffers(1, &fbo_); gl_->GenFramebuffers(1, &fbo_);
gl_->BindFramebuffer(GL_FRAMEBUFFER, fbo_); gl_->BindFramebuffer(GL_FRAMEBUFFER, fbo_);
if (opengl_flip_y_extension_)
gl_->FramebufferParameteri(GL_FRAMEBUFFER, GL_FRAMEBUFFER_FLIP_Y_MESA, 1);
if (WantExplicitResolve()) { if (WantExplicitResolve()) {
gl_->GenFramebuffers(1, &multisample_fbo_); gl_->GenFramebuffers(1, &multisample_fbo_);
gl_->BindFramebuffer(GL_FRAMEBUFFER, multisample_fbo_); gl_->BindFramebuffer(GL_FRAMEBUFFER, multisample_fbo_);
gl_->GenRenderbuffers(1, &multisample_renderbuffer_); gl_->GenRenderbuffers(1, &multisample_renderbuffer_);
if (opengl_flip_y_extension_)
gl_->FramebufferParameteri(GL_FRAMEBUFFER, GL_FRAMEBUFFER_FLIP_Y_MESA, 1);
} }
if (!ResizeFramebufferInternal(size)) { if (!ResizeFramebufferInternal(size)) {
DLOG(ERROR) << "Initialization failed to allocate backbuffer."; DLOG(ERROR) << "Initialization failed to allocate backbuffer.";
...@@ -926,6 +933,9 @@ cc::Layer* DrawingBuffer::CcLayer() { ...@@ -926,6 +933,9 @@ cc::Layer* DrawingBuffer::CcLayer() {
premultiplied_alpha_false_texture_); premultiplied_alpha_false_texture_);
layer_->SetNearestNeighbor(filter_quality_ == kNone_SkFilterQuality); layer_->SetNearestNeighbor(filter_quality_ == kNone_SkFilterQuality);
if (opengl_flip_y_extension_)
layer_->SetFlipped(false);
GraphicsLayer::RegisterContentsLayer(layer_.get()); GraphicsLayer::RegisterContentsLayer(layer_.get());
} }
......
...@@ -591,6 +591,8 @@ class PLATFORM_EXPORT DrawingBuffer : public cc::TextureLayerClient, ...@@ -591,6 +591,8 @@ class PLATFORM_EXPORT DrawingBuffer : public cc::TextureLayerClient,
ChromiumImageUsage chromium_image_usage_; ChromiumImageUsage chromium_image_usage_;
bool ShouldUseChromiumImage(); bool ShouldUseChromiumImage();
bool opengl_flip_y_extension_;
// A release callback that is run when the previouis image passed to // A release callback that is run when the previouis image passed to
// OffscreenCanvas::Commit() is no longer needed. // OffscreenCanvas::Commit() is no longer needed.
std::unique_ptr<viz::SingleReleaseCallback> previous_image_release_callback_; std::unique_ptr<viz::SingleReleaseCallback> previous_image_release_callback_;
......
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