| OLD | NEW |
| (Empty) |
| 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. | |
| 4 | |
| 5 #ifndef MOJO_SERVICES_HTML_VIEWER_WEB_LAYER_TREE_VIEW_IMPL_H_ | |
| 6 #define MOJO_SERVICES_HTML_VIEWER_WEB_LAYER_TREE_VIEW_IMPL_H_ | |
| 7 | |
| 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 "mojo/cc/output_surface_mojo.h" | |
| 15 #include "third_party/WebKit/public/platform/WebLayerTreeView.h" | |
| 16 #include "third_party/mojo_services/src/gpu/public/interfaces/gpu.mojom.h" | |
| 17 #include "third_party/mojo_services/src/surfaces/public/interfaces/surfaces.mojo
m.h" | |
| 18 | |
| 19 namespace base { | |
| 20 class MessageLoopProxy; | |
| 21 } | |
| 22 | |
| 23 namespace blink { | |
| 24 class WebWidget; | |
| 25 } | |
| 26 | |
| 27 namespace cc { | |
| 28 class LayerTreeHost; | |
| 29 } | |
| 30 | |
| 31 namespace mojo { | |
| 32 class View; | |
| 33 } | |
| 34 | |
| 35 namespace html_viewer { | |
| 36 | |
| 37 class WebLayerTreeViewImpl : public blink::WebLayerTreeView, | |
| 38 public cc::LayerTreeHostClient, | |
| 39 public mojo::OutputSurfaceMojoClient { | |
| 40 public: | |
| 41 WebLayerTreeViewImpl( | |
| 42 scoped_refptr<base::MessageLoopProxy> compositor_message_loop_proxy, | |
| 43 mojo::SurfacePtr surface, | |
| 44 mojo::GpuPtr gpu_service); | |
| 45 ~WebLayerTreeViewImpl() override; | |
| 46 | |
| 47 void set_widget(blink::WebWidget* widget) { widget_ = widget; } | |
| 48 void set_view(mojo::View* view) { view_ = view; } | |
| 49 | |
| 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 ApplyViewportDeltas(const gfx::Vector2d& scroll_delta, | |
| 62 float page_scale, | |
| 63 float top_controls_delta) override; | |
| 64 void RequestNewOutputSurface() override; | |
| 65 void DidFailToInitializeOutputSurface() override; | |
| 66 void DidInitializeOutputSurface() override; | |
| 67 void WillCommit() override; | |
| 68 void DidCommit() override; | |
| 69 void DidCommitAndDrawFrame() override; | |
| 70 void DidCompleteSwapBuffers() override; | |
| 71 void DidCompletePageScaleAnimation() override {} | |
| 72 void RateLimitSharedMainThreadContext() override {} | |
| 73 | |
| 74 // blink::WebLayerTreeView implementation. | |
| 75 virtual void setRootLayer(const blink::WebLayer& layer); | |
| 76 virtual void clearRootLayer(); | |
| 77 virtual void setViewportSize(const blink::WebSize& device_viewport_size); | |
| 78 virtual blink::WebSize deviceViewportSize() const; | |
| 79 virtual void setDeviceScaleFactor(float); | |
| 80 virtual float deviceScaleFactor() const; | |
| 81 virtual void setBackgroundColor(blink::WebColor color); | |
| 82 virtual void setHasTransparentBackground(bool has_transparent_background); | |
| 83 virtual void setVisible(bool visible); | |
| 84 virtual void setPageScaleFactorAndLimits(float page_scale_factor, | |
| 85 float minimum, | |
| 86 float maximum); | |
| 87 virtual void startPageScaleAnimation(const blink::WebPoint& destination, | |
| 88 bool use_anchor, | |
| 89 float new_page_scale, | |
| 90 double duration_sec); | |
| 91 virtual void heuristicsForGpuRasterizationUpdated(bool matches_heuristic) {} | |
| 92 virtual void setNeedsAnimate(); | |
| 93 virtual bool commitRequested() const; | |
| 94 virtual void didStopFlinging() {} | |
| 95 virtual void compositeAndReadbackAsync( | |
| 96 blink::WebCompositeAndReadbackAsyncCallback* callback) {} | |
| 97 virtual void finishAllRendering(); | |
| 98 virtual void setDeferCommits(bool defer_commits) {} | |
| 99 virtual void registerForAnimations(blink::WebLayer* layer); | |
| 100 virtual void registerViewportLayers( | |
| 101 const blink::WebLayer* overscrollElasticityLayer, | |
| 102 const blink::WebLayer* pageScaleLayerLayer, | |
| 103 const blink::WebLayer* innerViewportScrollLayer, | |
| 104 const blink::WebLayer* outerViewportScrollLayer); | |
| 105 virtual void clearViewportLayers(); | |
| 106 virtual void registerSelection(const blink::WebSelectionBound& start, | |
| 107 const blink::WebSelectionBound& end) {} | |
| 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) {} | |
| 114 | |
| 115 // OutputSurfaceMojoClient implementation. | |
| 116 void DidCreateSurface(cc::SurfaceId id) override; | |
| 117 | |
| 118 private: | |
| 119 void DidCreateSurfaceOnMainThread(cc::SurfaceId id); | |
| 120 | |
| 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_; | |
| 129 | |
| 130 base::WeakPtrFactory<WebLayerTreeViewImpl> weak_factory_; | |
| 131 DISALLOW_COPY_AND_ASSIGN(WebLayerTreeViewImpl); | |
| 132 }; | |
| 133 | |
| 134 } // namespace html_viewer | |
| 135 | |
| 136 #endif // MOJO_SERVICES_HTML_VIEWER_WEB_LAYER_TREE_VIEW_IMPL_H_ | |
| OLD | NEW |