Index: content/browser/compositor/gpu_surfaceless_browser_compositor_output_surface.cc |
diff --git a/content/browser/compositor/gpu_surfaceless_browser_compositor_output_surface.cc b/content/browser/compositor/gpu_surfaceless_browser_compositor_output_surface.cc |
new file mode 100644 |
index 0000000000000000000000000000000000000000..8f12cab3063a7c24d9545b83937ea1e6bd8c1b54 |
--- /dev/null |
+++ b/content/browser/compositor/gpu_surfaceless_browser_compositor_output_surface.cc |
@@ -0,0 +1,97 @@ |
+// Copyright 2014 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#include "content/browser/compositor/gpu_surfaceless_browser_compositor_output_surface.h" |
+ |
+#include "cc/output/compositor_frame.h" |
+#include "content/browser/compositor/buffered_output_surface.h" |
+#include "content/browser/compositor/reflector_impl.h" |
+#include "content/browser/gpu/gpu_surface_tracker.h" |
+#include "content/common/gpu/client/context_provider_command_buffer.h" |
+#include "gpu/GLES2/gl2extchromium.h" |
+#include "gpu/command_buffer/client/gles2_interface.h" |
+ |
+namespace content { |
+ |
+GpuSurfacelessBrowserCompositorOutputSurface:: |
+ GpuSurfacelessBrowserCompositorOutputSurface( |
+ const scoped_refptr<ContextProviderCommandBuffer>& context, |
+ int surface_id, |
+ IDMap<BrowserCompositorOutputSurface>* output_surface_map, |
+ const scoped_refptr<ui::CompositorVSyncManager>& vsync_manager, |
+ scoped_ptr<cc::OverlayCandidateValidator> overlay_candidate_validator, |
+ unsigned internalformat, |
+ int z_order) |
+ : GpuBrowserCompositorOutputSurface(context, |
+ surface_id, |
+ output_surface_map, |
+ vsync_manager, |
+ overlay_candidate_validator.Pass()), |
+ z_order_(z_order), |
+ expects_pageflip_messages_(false), |
+ internalformat_(internalformat) { |
+} |
+ |
+GpuSurfacelessBrowserCompositorOutputSurface:: |
+ ~GpuSurfacelessBrowserCompositorOutputSurface() { |
+} |
+ |
+void GpuSurfacelessBrowserCompositorOutputSurface::SwapBuffers( |
+ cc::CompositorFrame* frame) { |
+ DCHECK(output_surface_); |
+ output_surface_->SwapBuffers(); |
+ |
+ const gfx::Size& size = frame->gl_frame_data->size; |
+ gpu::gles2::GLES2Interface* gl = context_provider_->ContextGL(); |
+ gl->Finish(); |
alexst (slow to review)
2014/09/10 15:39:07
Put a comment here to indicate this glFinish is te
|
+ gl->ScheduleOverlayPlaneCHROMIUM(z_order_, |
+ GL_OVERLAY_TRANSFORM_NONE_CHROMIUM, |
+ output_surface_->tex_id(), |
alexst (slow to review)
2014/09/10 15:39:07
Let's rename this to something more descriptive, m
achaulk
2014/09/10 16:47:55
Well the texture never changes, we just rebind new
|
+ 0, |
+ 0, |
+ size.width(), |
+ size.height(), |
+ 0, |
+ 0, |
+ 1.0f, |
+ 1.0f); |
+ GpuBrowserCompositorOutputSurface::SwapBuffers(frame); |
+} |
+ |
+void GpuSurfacelessBrowserCompositorOutputSurface::OnSwapBuffersComplete() { |
+ DCHECK(output_surface_); |
+ // PageFlipComplete must be called to properly drive the buffering. If we |
+ // don't expect to receive these calls from IPCs, we should call it here. |
+ if (!expects_pageflip_messages_) |
+ output_surface_->PageFlipComplete(); |
+ GpuBrowserCompositorOutputSurface::OnSwapBuffersComplete(); |
+} |
+ |
+void GpuSurfacelessBrowserCompositorOutputSurface::BindFramebuffer() { |
+ DCHECK(output_surface_); |
+ output_surface_->BindFramebuffer(); |
+} |
+ |
+void GpuSurfacelessBrowserCompositorOutputSurface::Reshape( |
+ const gfx::Size& size, |
+ float scale_factor) { |
+ gfx::Size current = SurfaceSize(); |
+ GpuBrowserCompositorOutputSurface::Reshape(size, scale_factor); |
+ DCHECK(output_surface_); |
+ output_surface_->Reshape(SurfaceSize(), scale_factor); |
+} |
+ |
+bool GpuSurfacelessBrowserCompositorOutputSurface::BindToClient( |
+ cc::OutputSurfaceClient* client) { |
+ DCHECK(output_surface_); |
+ if (!GpuBrowserCompositorOutputSurface::BindToClient(client)) |
+ return false; |
+ if (!output_surface_) { |
+ output_surface_.reset( |
+ new BufferedOutputSurface(context_provider_, internalformat_)); |
+ } |
+ return true; |
+} |
+ |
+} // namespace content |