Supervised user whitelists: Cleanup
[chromium-blink-merge.git] / content / browser / compositor / gpu_surfaceless_browser_compositor_output_surface.cc
blobff77fa946649f4a9ae8da3bd4e73055d31c7c31c
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "content/browser/compositor/gpu_surfaceless_browser_compositor_output_surface.h"
7 #include "cc/output/compositor_frame.h"
8 #include "content/browser/compositor/browser_compositor_overlay_candidate_validator.h"
9 #include "content/browser/compositor/buffer_queue.h"
10 #include "content/browser/compositor/reflector_impl.h"
11 #include "content/browser/gpu/gpu_surface_tracker.h"
12 #include "content/common/gpu/client/context_provider_command_buffer.h"
13 #include "content/common/gpu/client/gl_helper.h"
14 #include "gpu/GLES2/gl2extchromium.h"
15 #include "gpu/command_buffer/client/gles2_interface.h"
17 namespace content {
19 GpuSurfacelessBrowserCompositorOutputSurface::
20 GpuSurfacelessBrowserCompositorOutputSurface(
21 const scoped_refptr<ContextProviderCommandBuffer>& context,
22 int surface_id,
23 const scoped_refptr<ui::CompositorVSyncManager>& vsync_manager,
24 scoped_ptr<BrowserCompositorOverlayCandidateValidator>
25 overlay_candidate_validator,
26 unsigned internalformat,
27 BrowserGpuMemoryBufferManager* gpu_memory_buffer_manager)
28 : GpuBrowserCompositorOutputSurface(context,
29 vsync_manager,
30 overlay_candidate_validator.Pass()),
31 internalformat_(internalformat),
32 gpu_memory_buffer_manager_(gpu_memory_buffer_manager) {
33 capabilities_.uses_default_gl_framebuffer = false;
34 capabilities_.flipped_output_surface = true;
35 // Set |max_frames_pending| to 2 for surfaceless, which aligns scheduling
36 // more closely with the previous surfaced behavior.
37 // With a surface, swap buffer ack used to return early, before actually
38 // presenting the back buffer, enabling the browser compositor to run ahead.
39 // Surfaceless implementation acks at the time of actual buffer swap, which
40 // shifts the start of the new frame forward relative to the old
41 // implementation.
42 capabilities_.max_frames_pending = 2;
44 gl_helper_.reset(new GLHelper(context_provider_->ContextGL(),
45 context_provider_->ContextSupport()));
46 output_surface_.reset(
47 new BufferQueue(context_provider_, internalformat_, gl_helper_.get(),
48 gpu_memory_buffer_manager_, surface_id));
49 output_surface_->Initialize();
52 GpuSurfacelessBrowserCompositorOutputSurface::
53 ~GpuSurfacelessBrowserCompositorOutputSurface() {
56 void GpuSurfacelessBrowserCompositorOutputSurface::SwapBuffers(
57 cc::CompositorFrame* frame) {
58 DCHECK(output_surface_);
60 GLuint texture = output_surface_->current_texture_id();
61 output_surface_->SwapBuffers(frame->gl_frame_data->sub_buffer_rect);
62 const gfx::Size& size = frame->gl_frame_data->size;
63 context_provider_->ContextGL()->ScheduleOverlayPlaneCHROMIUM(
65 GL_OVERLAY_TRANSFORM_NONE_CHROMIUM,
66 texture,
69 size.width(),
70 size.height(),
73 1.0f,
74 1.0f);
75 GpuBrowserCompositorOutputSurface::SwapBuffers(frame);
78 void GpuSurfacelessBrowserCompositorOutputSurface::OnSwapBuffersComplete() {
79 DCHECK(output_surface_);
80 output_surface_->PageFlipComplete();
81 GpuBrowserCompositorOutputSurface::OnSwapBuffersComplete();
84 void GpuSurfacelessBrowserCompositorOutputSurface::BindFramebuffer() {
85 DCHECK(output_surface_);
86 output_surface_->BindFramebuffer();
89 void GpuSurfacelessBrowserCompositorOutputSurface::Reshape(
90 const gfx::Size& size,
91 float scale_factor) {
92 GpuBrowserCompositorOutputSurface::Reshape(size, scale_factor);
93 DCHECK(output_surface_);
94 output_surface_->Reshape(SurfaceSize(), scale_factor);
97 } // namespace content