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

Unified Diff: content/browser/compositor/gpu_browser_compositor_output_surface.cc

Issue 1123763003: Draw the offscreen texture to reflector's surface without extra copy (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 7 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: content/browser/compositor/gpu_browser_compositor_output_surface.cc
diff --git a/content/browser/compositor/gpu_browser_compositor_output_surface.cc b/content/browser/compositor/gpu_browser_compositor_output_surface.cc
index 114a84f33b4195425bff6edfa041af21c5e07876..ee666790bfb5f4e76bbf87f3781940e5f00b2f53 100644
--- a/content/browser/compositor/gpu_browser_compositor_output_surface.cc
+++ b/content/browser/compositor/gpu_browser_compositor_output_surface.cc
@@ -7,9 +7,11 @@
#include "cc/output/compositor_frame.h"
#include "cc/output/output_surface_client.h"
#include "content/browser/compositor/browser_compositor_overlay_candidate_validator.h"
+#include "content/browser/compositor/owned_mailbox.h"
#include "content/browser/compositor/reflector_impl.h"
#include "content/browser/renderer_host/render_widget_host_impl.h"
#include "content/common/gpu/client/context_provider_command_buffer.h"
+#include "content/common/gpu/client/gl_helper.h"
#include "content/public/browser/browser_thread.h"
#include "gpu/command_buffer/client/context_support.h"
#include "gpu/command_buffer/client/gles2_interface.h"
@@ -32,10 +34,14 @@ GpuBrowserCompositorOutputSurface::GpuBrowserCompositorOutputSurface(
base::Unretained(this))),
update_vsync_parameters_callback_(base::Bind(
&BrowserCompositorOutputSurface::OnUpdateVSyncParametersFromGpu,
- base::Unretained(this))) {
+ base::Unretained(this))),
+ mirrored_compositor_gl_helper_texture_id_(0) {
}
-GpuBrowserCompositorOutputSurface::~GpuBrowserCompositorOutputSurface() {}
+GpuBrowserCompositorOutputSurface::~GpuBrowserCompositorOutputSurface() {
+ DCHECK(!reflector_);
+ DeleteTexture();
+}
CommandBufferProxyImpl*
GpuBrowserCompositorOutputSurface::GetCommandBufferProxy() {
@@ -60,6 +66,37 @@ bool GpuBrowserCompositorOutputSurface::BindToClient(
return true;
}
+void GpuBrowserCompositorOutputSurface::DeleteTexture() {
+ if (mirrored_compositor_gl_helper_.get()) {
+ mirrored_compositor_gl_helper_->DeleteTexture(
+ mirrored_compositor_gl_helper_texture_id_);
+ mailbox_ = nullptr;
+ mirrored_compositor_gl_helper_texture_id_ = 0;
+ mirrored_compositor_gl_helper_ = nullptr;
+ }
+}
+
+void GpuBrowserCompositorOutputSurface::OnReflectorChanged() {
+ if (!reflector_) {
+ DeleteTexture();
+ } else {
+ GLHelper* shared_helper =
+ ImageTransportFactory::GetInstance()->GetGLHelper();
+ mailbox_ = new OwnedMailbox(shared_helper);
+
+ // Create a GLHelper attached to the mirrored compositor's output
+ // surface for copying the output of the mirrored compositor.
+ mirrored_compositor_gl_helper_.reset(new GLHelper(
+ context_provider()->ContextGL(), context_provider()->ContextSupport()));
+ // Create a texture id in the name space of the new GLHelper to update the
+ // mailbox being held by the |mirroring_layer_|.
piman 2015/05/13 19:46:23 can you add a DCHECK(!mirrored_compositor_gl_helpe
oshima 2015/05/14 14:44:58 Done.
+ mirrored_compositor_gl_helper_texture_id_ =
+ mirrored_compositor_gl_helper_->ConsumeMailboxToTexture(
+ mailbox_->mailbox(), mailbox_->sync_point());
+ reflector_->OnSourceTextureMailboxUpdated(mailbox_);
+ }
+}
+
void GpuBrowserCompositorOutputSurface::SwapBuffers(
cc::CompositorFrame* frame) {
DCHECK(frame->gl_frame_data);
@@ -68,10 +105,28 @@ void GpuBrowserCompositorOutputSurface::SwapBuffers(
if (reflector_) {
if (frame->gl_frame_data->sub_buffer_rect ==
- gfx::Rect(frame->gl_frame_data->size))
+ gfx::Rect(frame->gl_frame_data->size)) {
+ gfx::Size size = SurfaceSize();
+ mirrored_compositor_gl_helper_->CopyTextureFullImage(
+ mirrored_compositor_gl_helper_texture_id_, size);
+ // Insert a barrier to make the copy show up in the mirroring compositor's
+ // mailbox. Since the the compositor contexts and the
+ // ImageTransportFactory's
+ // GLHelper are all on the same GPU channel, this is sufficient instead of
+ // plumbing through a sync point.
+ mirrored_compositor_gl_helper_->InsertOrderingBarrier();
+
reflector_->OnSourceSwapBuffers();
- else
- reflector_->OnSourcePostSubBuffer(frame->gl_frame_data->sub_buffer_rect);
+ } else {
+ const gfx::Rect& rect = frame->gl_frame_data->sub_buffer_rect;
+
+ mirrored_compositor_gl_helper_->CopyTextureSubImage(
+ mirrored_compositor_gl_helper_texture_id_, rect);
+ // Insert a barrier for the same reason above.
+ mirrored_compositor_gl_helper_->InsertOrderingBarrier();
+
+ reflector_->OnSourcePostSubBuffer(rect);
+ }
}
if (frame->gl_frame_data->sub_buffer_rect ==

Powered by Google App Engine
This is Rietveld 408576698