Don't peek messages in the MessagePumpForUI class when we receive our kMsgHaveWork...
[chromium-blink-merge.git] / components / html_viewer / web_layer_tree_view_impl.h
blobd9cef8cf1e0e806aa7712ec05a05bff2816e9761
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 COMPONENTS_HTML_VIEWER_WEB_LAYER_TREE_VIEW_IMPL_H_
6 #define COMPONENTS_HTML_VIEWER_WEB_LAYER_TREE_VIEW_IMPL_H_
8 #include "base/macros.h"
9 #include "base/memory/ref_counted.h"
10 #include "base/memory/scoped_ptr.h"
11 #include "base/memory/weak_ptr.h"
12 #include "base/single_thread_task_runner.h"
13 #include "cc/trees/layer_tree_host_client.h"
14 #include "components/view_manager/public/interfaces/gpu.mojom.h"
15 #include "components/view_manager/public/interfaces/surfaces.mojom.h"
16 #include "mojo/cc/output_surface_mojo.h"
17 #include "third_party/WebKit/public/platform/WebLayerTreeView.h"
19 namespace base {
20 class SingleThreadTaskRunner;
23 namespace blink {
24 class WebWidget;
27 namespace cc {
28 class LayerTreeHost;
31 namespace mojo {
32 class View;
35 namespace html_viewer {
37 class WebLayerTreeViewImpl : public blink::WebLayerTreeView,
38 public cc::LayerTreeHostClient,
39 public mojo::OutputSurfaceMojoClient {
40 public:
41 WebLayerTreeViewImpl(
42 scoped_refptr<base::SingleThreadTaskRunner> compositor_task_runner,
43 mojo::SurfacePtr surface,
44 mojo::GpuPtr gpu_service);
45 ~WebLayerTreeViewImpl() override;
47 void set_widget(blink::WebWidget* widget) { widget_ = widget; }
48 void set_view(mojo::View* view) { view_ = view; }
50 // cc::LayerTreeHostClient implementation.
51 void WillBeginMainFrame() override;
52 void DidBeginMainFrame() override;
53 void BeginMainFrame(const cc::BeginFrameArgs& args) override;
54 void BeginMainFrameNotExpectedSoon() override;
55 void Layout() override;
56 void ApplyViewportDeltas(const gfx::Vector2dF& inner_delta,
57 const gfx::Vector2dF& outer_delta,
58 const gfx::Vector2dF& elastic_overscroll_delta,
59 float page_scale,
60 float top_controls_delta) override;
61 void RequestNewOutputSurface() override;
62 void DidFailToInitializeOutputSurface() override;
63 void DidInitializeOutputSurface() override;
64 void WillCommit() override;
65 void DidCommit() override;
66 void DidCommitAndDrawFrame() override;
67 void DidCompleteSwapBuffers() override;
68 void DidCompletePageScaleAnimation() override {}
69 void RateLimitSharedMainThreadContext() override {}
70 void RecordFrameTimingEvents(
71 scoped_ptr<cc::FrameTimingTracker::CompositeTimingSet> composite_events,
72 scoped_ptr<cc::FrameTimingTracker::MainFrameTimingSet> main_frame_events)
73 override {}
75 // blink::WebLayerTreeView implementation.
76 virtual void setRootLayer(const blink::WebLayer& layer);
77 virtual void clearRootLayer();
78 virtual void setViewportSize(const blink::WebSize& device_viewport_size);
79 virtual blink::WebSize deviceViewportSize() const;
80 virtual void setDeviceScaleFactor(float);
81 virtual float deviceScaleFactor() const;
82 virtual void setBackgroundColor(blink::WebColor color);
83 virtual void setHasTransparentBackground(bool has_transparent_background);
84 virtual void setVisible(bool visible);
85 virtual void setPageScaleFactorAndLimits(float page_scale_factor,
86 float minimum,
87 float maximum);
88 virtual void startPageScaleAnimation(const blink::WebPoint& destination,
89 bool use_anchor,
90 float new_page_scale,
91 double duration_sec);
92 virtual void heuristicsForGpuRasterizationUpdated(bool matches_heuristic) {}
93 virtual void setNeedsAnimate();
94 virtual bool commitRequested() const;
95 virtual void didStopFlinging() {}
96 virtual void compositeAndReadbackAsync(
97 blink::WebCompositeAndReadbackAsyncCallback* callback) {}
98 virtual void finishAllRendering();
99 virtual void setDeferCommits(bool defer_commits) {}
100 virtual void registerForAnimations(blink::WebLayer* layer);
101 virtual void registerViewportLayers(
102 const blink::WebLayer* overscrollElasticityLayer,
103 const blink::WebLayer* pageScaleLayerLayer,
104 const blink::WebLayer* innerViewportScrollLayer,
105 const blink::WebLayer* outerViewportScrollLayer);
106 virtual void clearViewportLayers();
107 virtual void registerSelection(const blink::WebSelection& selection) {}
108 virtual void clearSelection() {}
109 virtual void setShowFPSCounter(bool) {}
110 virtual void setShowPaintRects(bool) {}
111 virtual void setShowDebugBorders(bool) {}
112 virtual void setContinuousPaintingEnabled(bool) {}
113 virtual void setShowScrollBottleneckRects(bool) {}
115 // OutputSurfaceMojoClient implementation.
116 void DidCreateSurface(cc::SurfaceId id) override;
118 private:
119 void DidCreateSurfaceOnMainThread(cc::SurfaceId id);
121 // widget_ and view_ will outlive us.
122 blink::WebWidget* widget_;
123 mojo::View* view_;
124 scoped_ptr<cc::LayerTreeHost> layer_tree_host_;
125 scoped_ptr<cc::OutputSurface> output_surface_;
126 scoped_refptr<base::SingleThreadTaskRunner>
127 main_thread_compositor_task_runner_;
128 base::WeakPtr<WebLayerTreeViewImpl> main_thread_bound_weak_ptr_;
130 base::WeakPtrFactory<WebLayerTreeViewImpl> weak_factory_;
131 DISALLOW_COPY_AND_ASSIGN(WebLayerTreeViewImpl);
134 } // namespace html_viewer
136 #endif // COMPONENTS_HTML_VIEWER_WEB_LAYER_TREE_VIEW_IMPL_H_