Change next_proto member type.
[chromium-blink-merge.git] / content / browser / compositor / gpu_surfaceless_browser_compositor_output_surface.cc
blob2852ba7c7b08c8f986f2287ce4fcb68f1fc4cd64
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/buffer_queue.h"
9 #include "content/browser/compositor/reflector_impl.h"
10 #include "content/browser/gpu/gpu_surface_tracker.h"
11 #include "content/common/gpu/client/context_provider_command_buffer.h"
12 #include "content/common/gpu/client/gl_helper.h"
13 #include "gpu/GLES2/gl2extchromium.h"
14 #include "gpu/command_buffer/client/gles2_interface.h"
16 namespace content {
18 GpuSurfacelessBrowserCompositorOutputSurface::
19 GpuSurfacelessBrowserCompositorOutputSurface(
20 const scoped_refptr<ContextProviderCommandBuffer>& context,
21 int surface_id,
22 IDMap<BrowserCompositorOutputSurface>* output_surface_map,
23 const scoped_refptr<ui::CompositorVSyncManager>& vsync_manager,
24 scoped_ptr<cc::OverlayCandidateValidator> overlay_candidate_validator,
25 unsigned internalformat,
26 bool use_own_gl_helper,
27 BrowserGpuMemoryBufferManager* gpu_memory_buffer_manager)
28 : GpuBrowserCompositorOutputSurface(context,
29 surface_id,
30 output_surface_map,
31 vsync_manager,
32 overlay_candidate_validator.Pass()),
33 internalformat_(internalformat),
34 use_own_gl_helper_(use_own_gl_helper),
35 gpu_memory_buffer_manager_(gpu_memory_buffer_manager) {
36 capabilities_.uses_default_gl_framebuffer = false;
37 capabilities_.flipped_output_surface = true;
40 GpuSurfacelessBrowserCompositorOutputSurface::
41 ~GpuSurfacelessBrowserCompositorOutputSurface() {
44 void GpuSurfacelessBrowserCompositorOutputSurface::SwapBuffers(
45 cc::CompositorFrame* frame) {
46 DCHECK(output_surface_);
48 GLuint texture = output_surface_->current_texture_id();
49 output_surface_->SwapBuffers(frame->gl_frame_data->sub_buffer_rect);
50 const gfx::Size& size = frame->gl_frame_data->size;
51 context_provider_->ContextGL()->ScheduleOverlayPlaneCHROMIUM(
53 GL_OVERLAY_TRANSFORM_NONE_CHROMIUM,
54 texture,
57 size.width(),
58 size.height(),
61 1.0f,
62 1.0f);
63 GpuBrowserCompositorOutputSurface::SwapBuffers(frame);
66 void GpuSurfacelessBrowserCompositorOutputSurface::OnSwapBuffersComplete() {
67 DCHECK(output_surface_);
68 output_surface_->PageFlipComplete();
69 GpuBrowserCompositorOutputSurface::OnSwapBuffersComplete();
72 void GpuSurfacelessBrowserCompositorOutputSurface::BindFramebuffer() {
73 DCHECK(output_surface_);
74 output_surface_->BindFramebuffer();
77 void GpuSurfacelessBrowserCompositorOutputSurface::Reshape(
78 const gfx::Size& size,
79 float scale_factor) {
80 GpuBrowserCompositorOutputSurface::Reshape(size, scale_factor);
81 DCHECK(output_surface_);
82 output_surface_->Reshape(SurfaceSize(), scale_factor);
85 bool GpuSurfacelessBrowserCompositorOutputSurface::BindToClient(
86 cc::OutputSurfaceClient* client) {
87 if (!GpuBrowserCompositorOutputSurface::BindToClient(client))
88 return false;
89 GLHelper* helper;
90 if (use_own_gl_helper_) {
91 gl_helper_.reset(new GLHelper(context_provider_->ContextGL(),
92 context_provider_->ContextSupport()));
93 helper = gl_helper_.get();
94 } else {
95 helper = ImageTransportFactory::GetInstance()->GetGLHelper();
97 if (!helper)
98 return false;
100 output_surface_.reset(new BufferQueue(context_provider_, internalformat_,
101 helper, gpu_memory_buffer_manager_,
102 surface_id_));
103 return output_surface_->Initialize();
106 } // namespace content