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 #ifndef CONTENT_BROWSER_COMPOSITOR_GPU_BROWSER_COMPOSITOR_OUTPUT_SURFACE_H_
6 #define CONTENT_BROWSER_COMPOSITOR_GPU_BROWSER_COMPOSITOR_OUTPUT_SURFACE_H_
8 #include "base/cancelable_callback.h"
9 #include "content/browser/compositor/browser_compositor_output_surface.h"
12 class CompositorVSyncManager
;
16 class CommandBufferProxyImpl
;
17 class BrowserCompositorOverlayCandidateValidator
;
19 // Adapts a WebGraphicsContext3DCommandBufferImpl into a
20 // cc::OutputSurface that also handles vsync parameter updates
21 // arriving from the GPU process.
22 class GpuBrowserCompositorOutputSurface
23 : public BrowserCompositorOutputSurface
{
25 GpuBrowserCompositorOutputSurface(
26 const scoped_refptr
<ContextProviderCommandBuffer
>& context
,
27 const scoped_refptr
<ui::CompositorVSyncManager
>& vsync_manager
,
28 scoped_ptr
<BrowserCompositorOverlayCandidateValidator
>
29 overlay_candidate_validator
);
31 ~GpuBrowserCompositorOutputSurface() override
;
34 // cc::OutputSurface implementation.
35 void SwapBuffers(cc::CompositorFrame
* frame
) override
;
36 bool BindToClient(cc::OutputSurfaceClient
* client
) override
;
38 #if defined(OS_MACOSX)
39 void OnSurfaceDisplayed() override
;
40 void SetSurfaceSuspendedForRecycle(bool suspended
) override
;
41 bool SurfaceShouldNotShowFramesAfterSuspendForRecycle() const override
;
42 enum ShouldShowFramesState
{
43 // Frames that come from the GPU process should appear on-screen.
45 // The compositor has been suspended. Any frames that come from the GPU
46 // process are for the pre-suspend content and should not be displayed.
47 SHOULD_NOT_SHOW_FRAMES_SUSPENDED
,
48 // The compositor has been un-suspended, but has not yet issued a swap
49 // since being un-suspended, so any frames that come from the GPU process
50 // are for pre-suspend content and should not be displayed.
51 SHOULD_NOT_SHOW_FRAMES_NO_SWAP_AFTER_SUSPENDED
,
53 ShouldShowFramesState should_show_frames_state_
;
56 CommandBufferProxyImpl
* GetCommandBufferProxy();
57 void OnSwapBuffersCompleted(const std::vector
<ui::LatencyInfo
>& latency_info
);
59 base::CancelableCallback
<void(const std::vector
<ui::LatencyInfo
>&)>
60 swap_buffers_completion_callback_
;
61 base::CancelableCallback
<void(base::TimeTicks timebase
,
62 base::TimeDelta interval
)>
63 update_vsync_parameters_callback_
;
65 DISALLOW_COPY_AND_ASSIGN(GpuBrowserCompositorOutputSurface
);
68 } // namespace content
70 #endif // CONTENT_BROWSER_COMPOSITOR_GPU_BROWSER_COMPOSITOR_OUTPUT_SURFACE_H_