Pin Chrome's shortcut to the Win10 Start menu on install and OS upgrade.
[chromium-blink-merge.git] / content / browser / compositor / gpu_browser_compositor_output_surface.h
blob3bc2a3a9c829ed77040a7de3a2d1e5a00317e120
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;
42 bool SurfaceIsSuspendForRecycle() const override;
44 #if defined(OS_MACOSX)
45 void OnSurfaceDisplayed() override;
46 void SetSurfaceSuspendedForRecycle(bool suspended) override;
47 bool SurfaceShouldNotShowFramesAfterSuspendForRecycle() const override;
48 enum ShouldShowFramesState {
49 // Frames that come from the GPU process should appear on-screen.
50 SHOULD_SHOW_FRAMES,
51 // The compositor has been suspended. Any frames that come from the GPU
52 // process are for the pre-suspend content and should not be displayed.
53 SHOULD_NOT_SHOW_FRAMES_SUSPENDED,
54 // The compositor has been un-suspended, but has not yet issued a swap
55 // since being un-suspended, so any frames that come from the GPU process
56 // are for pre-suspend content and should not be displayed.
57 SHOULD_NOT_SHOW_FRAMES_NO_SWAP_AFTER_SUSPENDED,
59 ShouldShowFramesState should_show_frames_state_;
60 #endif
62 CommandBufferProxyImpl* GetCommandBufferProxy();
63 virtual void OnSwapBuffersCompleted(
64 const std::vector<ui::LatencyInfo>& latency_info,
65 gfx::SwapResult result);
67 base::CancelableCallback<void(const std::vector<ui::LatencyInfo>&,
68 gfx::SwapResult)>
69 swap_buffers_completion_callback_;
70 base::CancelableCallback<void(base::TimeTicks timebase,
71 base::TimeDelta interval)>
72 update_vsync_parameters_callback_;
74 scoped_ptr<ReflectorTexture> reflector_texture_;
76 DISALLOW_COPY_AND_ASSIGN(GpuBrowserCompositorOutputSurface);
79 } // namespace content
81 #endif // CONTENT_BROWSER_COMPOSITOR_GPU_BROWSER_COMPOSITOR_OUTPUT_SURFACE_H_