Roll ANGLE e754fb8..6ffeb74
[chromium-blink-merge.git] / content / browser / compositor / gpu_browser_compositor_output_surface.h
blobe1d1a497e066f4bcb6ffad8f7f17432767d11aad
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"
10 #include "ui/gfx/swap_result.h"
12 namespace ui {
13 class CompositorVSyncManager;
16 namespace content {
17 class CommandBufferProxyImpl;
18 class BrowserCompositorOverlayCandidateValidator;
19 class ReflectorTexture;
21 // Adapts a WebGraphicsContext3DCommandBufferImpl into a
22 // cc::OutputSurface that also handles vsync parameter updates
23 // arriving from the GPU process.
24 class GpuBrowserCompositorOutputSurface
25 : public BrowserCompositorOutputSurface {
26 public:
27 GpuBrowserCompositorOutputSurface(
28 const scoped_refptr<ContextProviderCommandBuffer>& context,
29 const scoped_refptr<ui::CompositorVSyncManager>& vsync_manager,
30 scoped_ptr<BrowserCompositorOverlayCandidateValidator>
31 overlay_candidate_validator);
33 ~GpuBrowserCompositorOutputSurface() override;
35 protected:
36 // BrowserCompositorOutputSurface:
37 void OnReflectorChanged() override;
39 // cc::OutputSurface implementation.
40 void SwapBuffers(cc::CompositorFrame* frame) override;
41 bool BindToClient(cc::OutputSurfaceClient* client) override;
43 #if defined(OS_MACOSX)
44 void OnSurfaceDisplayed() override;
45 void SetSurfaceSuspendedForRecycle(bool suspended) override;
46 bool SurfaceShouldNotShowFramesAfterSuspendForRecycle() const override;
47 enum ShouldShowFramesState {
48 // Frames that come from the GPU process should appear on-screen.
49 SHOULD_SHOW_FRAMES,
50 // The compositor has been suspended. Any frames that come from the GPU
51 // process are for the pre-suspend content and should not be displayed.
52 SHOULD_NOT_SHOW_FRAMES_SUSPENDED,
53 // The compositor has been un-suspended, but has not yet issued a swap
54 // since being un-suspended, so any frames that come from the GPU process
55 // are for pre-suspend content and should not be displayed.
56 SHOULD_NOT_SHOW_FRAMES_NO_SWAP_AFTER_SUSPENDED,
58 ShouldShowFramesState should_show_frames_state_;
59 #endif
61 CommandBufferProxyImpl* GetCommandBufferProxy();
62 void OnSwapBuffersCompleted(const std::vector<ui::LatencyInfo>& latency_info,
63 gfx::SwapResult result);
65 base::CancelableCallback<void(const std::vector<ui::LatencyInfo>&,
66 gfx::SwapResult)>
67 swap_buffers_completion_callback_;
68 base::CancelableCallback<void(base::TimeTicks timebase,
69 base::TimeDelta interval)>
70 update_vsync_parameters_callback_;
72 scoped_ptr<ReflectorTexture> reflector_texture_;
74 DISALLOW_COPY_AND_ASSIGN(GpuBrowserCompositorOutputSurface);
77 } // namespace content
79 #endif // CONTENT_BROWSER_COMPOSITOR_GPU_BROWSER_COMPOSITOR_OUTPUT_SURFACE_H_