Apply _RELATIVE relocations ahead of others.
[chromium-blink-merge.git] / content / browser / compositor / gpu_surfaceless_browser_compositor_output_surface.cc
blobc3d9cbbc056402726864d3c4918da6545fabfc80
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 : GpuBrowserCompositorOutputSurface(context,
28 surface_id,
29 output_surface_map,
30 vsync_manager,
31 overlay_candidate_validator.Pass()),
32 internalformat_(internalformat),
33 use_own_gl_helper_(use_own_gl_helper) {
34 capabilities_.uses_default_gl_framebuffer = false;
35 capabilities_.flipped_output_surface = true;
38 GpuSurfacelessBrowserCompositorOutputSurface::
39 ~GpuSurfacelessBrowserCompositorOutputSurface() {
42 void GpuSurfacelessBrowserCompositorOutputSurface::SwapBuffers(
43 cc::CompositorFrame* frame) {
44 DCHECK(output_surface_);
46 GLuint texture = output_surface_->current_texture_id();
47 output_surface_->SwapBuffers(frame->gl_frame_data->sub_buffer_rect);
48 const gfx::Size& size = frame->gl_frame_data->size;
49 context_provider_->ContextGL()->ScheduleOverlayPlaneCHROMIUM(
51 GL_OVERLAY_TRANSFORM_NONE_CHROMIUM,
52 texture,
55 size.width(),
56 size.height(),
59 1.0f,
60 1.0f);
61 GpuBrowserCompositorOutputSurface::SwapBuffers(frame);
64 void GpuSurfacelessBrowserCompositorOutputSurface::OnSwapBuffersComplete() {
65 DCHECK(output_surface_);
66 output_surface_->PageFlipComplete();
67 GpuBrowserCompositorOutputSurface::OnSwapBuffersComplete();
70 void GpuSurfacelessBrowserCompositorOutputSurface::BindFramebuffer() {
71 DCHECK(output_surface_);
72 output_surface_->BindFramebuffer();
75 void GpuSurfacelessBrowserCompositorOutputSurface::Reshape(
76 const gfx::Size& size,
77 float scale_factor) {
78 GpuBrowserCompositorOutputSurface::Reshape(size, scale_factor);
79 DCHECK(output_surface_);
80 output_surface_->Reshape(SurfaceSize(), scale_factor);
83 bool GpuSurfacelessBrowserCompositorOutputSurface::BindToClient(
84 cc::OutputSurfaceClient* client) {
85 if (!GpuBrowserCompositorOutputSurface::BindToClient(client))
86 return false;
87 GLHelper* helper;
88 if (use_own_gl_helper_) {
89 gl_helper_.reset(new GLHelper(context_provider_->ContextGL(),
90 context_provider_->ContextSupport()));
91 helper = gl_helper_.get();
92 } else {
93 helper = ImageTransportFactory::GetInstance()->GetGLHelper();
95 output_surface_.reset(
96 new BufferQueue(context_provider_, internalformat_, helper));
97 return output_surface_->Initialize();
100 } // namespace content