[email protected] | ba91a79 | 2013-02-06 09:48:28 | [diff] [blame] | 1 | // Copyright (c) 2013 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 CONTENT_RENDERER_GPU_RENDER_WIDGET_COMPOSITOR_H_ |
| 6 | #define CONTENT_RENDERER_GPU_RENDER_WIDGET_COMPOSITOR_H_ |
| 7 | |
| 8 | #include "cc/layer_tree_host_client.h" |
| 9 | #include "cc/layer_tree_settings.h" |
| 10 | #include "third_party/WebKit/Source/Platform/chromium/public/WebLayerTreeView.h" |
| 11 | |
| 12 | namespace cc { |
| 13 | class LayerTreeHost; |
| 14 | } |
| 15 | |
| 16 | namespace content { |
| 17 | class RenderWidget; |
| 18 | |
| 19 | class RenderWidgetCompositor : public WebKit::WebLayerTreeView, |
| 20 | public cc::LayerTreeHostClient { |
| 21 | public: |
| 22 | // Attempt to construct and initialize a compositor instance for the widget |
| 23 | // with the given settings. Returns NULL if initialization fails. |
| 24 | static scoped_ptr<RenderWidgetCompositor> Create( |
| 25 | RenderWidget* widget, |
| 26 | WebKit::WebLayerTreeViewClient* client, |
| 27 | WebKit::WebLayerTreeView::Settings settings); |
| 28 | |
| 29 | virtual ~RenderWidgetCompositor(); |
| 30 | |
| 31 | cc::LayerTreeHost* layer_tree_host() const { return layer_tree_host_.get(); } |
| 32 | |
[email protected] | 9ed83fe | 2013-02-27 01:52:28 | [diff] [blame^] | 33 | void SetSuppressScheduleComposite(bool suppress); |
| 34 | |
[email protected] | ba91a79 | 2013-02-06 09:48:28 | [diff] [blame] | 35 | // WebLayerTreeView implementation. |
| 36 | virtual void setSurfaceReady(); |
| 37 | virtual void setRootLayer(const WebKit::WebLayer& layer); |
| 38 | virtual void clearRootLayer(); |
| 39 | virtual void setViewportSize( |
| 40 | const WebKit::WebSize& layout_viewport_size, |
| 41 | const WebKit::WebSize& device_viewport_size); |
| 42 | virtual WebKit::WebSize layoutViewportSize() const; |
| 43 | virtual WebKit::WebSize deviceViewportSize() const; |
| 44 | virtual WebKit::WebFloatPoint adjustEventPointForPinchZoom( |
| 45 | const WebKit::WebFloatPoint& point) const; |
| 46 | virtual void setDeviceScaleFactor(float device_scale); |
| 47 | virtual float deviceScaleFactor() const; |
| 48 | virtual void setBackgroundColor(WebKit::WebColor color); |
| 49 | virtual void setHasTransparentBackground(bool transparent); |
| 50 | virtual void setVisible(bool visible); |
| 51 | virtual void setPageScaleFactorAndLimits(float page_scale_factor, |
| 52 | float minimum, |
| 53 | float maximum); |
| 54 | virtual void startPageScaleAnimation(const WebKit::WebPoint& destination, |
| 55 | bool use_anchor, |
| 56 | float new_page_scale, |
| 57 | double duration_sec); |
| 58 | virtual void setNeedsAnimate(); |
| 59 | virtual void setNeedsRedraw(); |
| 60 | virtual bool commitRequested() const; |
| 61 | virtual void composite(); |
| 62 | virtual void updateAnimations(double frame_begin_time); |
| 63 | virtual void didStopFlinging(); |
| 64 | virtual bool compositeAndReadback(void *pixels, const WebKit::WebRect& rect); |
| 65 | virtual void finishAllRendering(); |
| 66 | virtual void setDeferCommits(bool defer_commits); |
| 67 | virtual void renderingStats(WebKit::WebRenderingStats& stats) const {} |
| 68 | virtual void setShowFPSCounter(bool show); |
| 69 | virtual void setShowPaintRects(bool show); |
[email protected] | d3be028 | 2013-02-07 19:00:23 | [diff] [blame] | 70 | virtual void setShowDebugBorders(bool show); |
[email protected] | ba91a79 | 2013-02-06 09:48:28 | [diff] [blame] | 71 | virtual void setContinuousPaintingEnabled(bool enabled); |
| 72 | |
| 73 | // cc::LayerTreeHostClient implementation. |
| 74 | virtual void willBeginFrame() OVERRIDE; |
| 75 | virtual void didBeginFrame() OVERRIDE; |
| 76 | virtual void animate(double monotonic_frame_begin_time) OVERRIDE; |
| 77 | virtual void layout() OVERRIDE; |
| 78 | virtual void applyScrollAndScale(gfx::Vector2d scroll_delta, |
| 79 | float page_scale) OVERRIDE; |
| 80 | virtual scoped_ptr<cc::OutputSurface> createOutputSurface() OVERRIDE; |
| 81 | virtual void didRecreateOutputSurface(bool success) OVERRIDE; |
| 82 | virtual scoped_ptr<cc::InputHandler> createInputHandler() OVERRIDE; |
| 83 | virtual void willCommit() OVERRIDE; |
| 84 | virtual void didCommit() OVERRIDE; |
| 85 | virtual void didCommitAndDrawFrame() OVERRIDE; |
| 86 | virtual void didCompleteSwapBuffers() OVERRIDE; |
| 87 | virtual void scheduleComposite() OVERRIDE; |
[email protected] | 0a45172 | 2013-02-22 20:32:05 | [diff] [blame] | 88 | virtual scoped_refptr<cc::ContextProvider> |
| 89 | OffscreenContextProviderForMainThread() OVERRIDE; |
| 90 | virtual scoped_refptr<cc::ContextProvider> |
| 91 | OffscreenContextProviderForCompositorThread() OVERRIDE; |
[email protected] | ba91a79 | 2013-02-06 09:48:28 | [diff] [blame] | 92 | |
| 93 | private: |
| 94 | RenderWidgetCompositor(RenderWidget* widget, |
| 95 | WebKit::WebLayerTreeViewClient* client); |
| 96 | |
| 97 | bool initialize(cc::LayerTreeSettings settings); |
| 98 | |
| 99 | bool threaded_; |
[email protected] | 9ed83fe | 2013-02-27 01:52:28 | [diff] [blame^] | 100 | bool suppress_schedule_composite_; |
[email protected] | ba91a79 | 2013-02-06 09:48:28 | [diff] [blame] | 101 | RenderWidget* widget_; |
| 102 | WebKit::WebLayerTreeViewClient* client_; |
| 103 | scoped_ptr<cc::LayerTreeHost> layer_tree_host_; |
[email protected] | 0a45172 | 2013-02-22 20:32:05 | [diff] [blame] | 104 | |
| 105 | class MainThreadContextProvider; |
| 106 | scoped_refptr<MainThreadContextProvider> contexts_main_thread_; |
| 107 | class CompositorThreadContextProvider; |
| 108 | scoped_refptr<CompositorThreadContextProvider> contexts_compositor_thread_; |
[email protected] | ba91a79 | 2013-02-06 09:48:28 | [diff] [blame] | 109 | }; |
| 110 | |
| 111 | } // namespace content |
| 112 | |
| 113 | #endif // CONTENT_RENDERER_GPU_RENDER_WIDGET_COMPOSITOR_H_ |
| 114 | |