[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 | |
[email protected] | 200a9c06 | 2013-05-20 04:34:37 | [diff] [blame] | 8 | #include "base/memory/weak_ptr.h" |
[email protected] | abb52216 | 2013-06-28 01:54:16 | [diff] [blame^] | 9 | #include "base/time/time.h" |
[email protected] | 6e84de2 | 2013-03-18 06:54:27 | [diff] [blame] | 10 | #include "cc/debug/rendering_stats.h" |
[email protected] | 9b00348 | 2013-05-21 14:00:17 | [diff] [blame] | 11 | #include "cc/input/top_controls_state.h" |
[email protected] | 556fd29 | 2013-03-18 08:03:04 | [diff] [blame] | 12 | #include "cc/trees/layer_tree_host_client.h" |
| 13 | #include "cc/trees/layer_tree_settings.h" |
[email protected] | 635353c | 2013-03-06 09:11:20 | [diff] [blame] | 14 | #include "skia/ext/refptr.h" |
[email protected] | 5c30b5e0 | 2013-05-30 03:46:08 | [diff] [blame] | 15 | #include "third_party/WebKit/public/platform/WebLayerTreeView.h" |
[email protected] | 0bc1f57 | 2013-04-17 01:46:31 | [diff] [blame] | 16 | #include "ui/gfx/rect.h" |
[email protected] | ba91a79 | 2013-02-06 09:48:28 | [diff] [blame] | 17 | |
[email protected] | 635353c | 2013-03-06 09:11:20 | [diff] [blame] | 18 | class SkPicture; |
| 19 | |
[email protected] | 4b15766 | 2013-05-29 04:05:05 | [diff] [blame] | 20 | namespace ui { |
| 21 | struct LatencyInfo; |
| 22 | } |
| 23 | |
[email protected] | ba91a79 | 2013-02-06 09:48:28 | [diff] [blame] | 24 | namespace cc { |
[email protected] | 200a9c06 | 2013-05-20 04:34:37 | [diff] [blame] | 25 | class InputHandler; |
[email protected] | ba91a79 | 2013-02-06 09:48:28 | [diff] [blame] | 26 | class LayerTreeHost; |
| 27 | } |
| 28 | |
| 29 | namespace content { |
| 30 | class RenderWidget; |
| 31 | |
| 32 | class RenderWidgetCompositor : public WebKit::WebLayerTreeView, |
| 33 | public cc::LayerTreeHostClient { |
| 34 | public: |
| 35 | // Attempt to construct and initialize a compositor instance for the widget |
| 36 | // with the given settings. Returns NULL if initialization fails. |
[email protected] | e195e58 | 2013-03-08 01:32:59 | [diff] [blame] | 37 | static scoped_ptr<RenderWidgetCompositor> Create(RenderWidget* widget); |
[email protected] | ba91a79 | 2013-02-06 09:48:28 | [diff] [blame] | 38 | |
| 39 | virtual ~RenderWidgetCompositor(); |
| 40 | |
[email protected] | 200a9c06 | 2013-05-20 04:34:37 | [diff] [blame] | 41 | const base::WeakPtr<cc::InputHandler>& GetInputHandler(); |
[email protected] | 9ed83fe | 2013-02-27 01:52:28 | [diff] [blame] | 42 | void SetSuppressScheduleComposite(bool suppress); |
[email protected] | 635353c | 2013-03-06 09:11:20 | [diff] [blame] | 43 | void Animate(base::TimeTicks time); |
[email protected] | f0c2a24 | 2013-03-15 19:34:52 | [diff] [blame] | 44 | void Composite(base::TimeTicks frame_begin_time); |
[email protected] | 24ed043 | 2013-04-24 07:50:31 | [diff] [blame] | 45 | void SetNeedsDisplayOnAllLayers(); |
[email protected] | 206a392 | 2013-05-17 06:34:12 | [diff] [blame] | 46 | void SetRasterizeOnlyVisibleContent(); |
[email protected] | 635353c | 2013-03-06 09:11:20 | [diff] [blame] | 47 | void GetRenderingStats(cc::RenderingStats* stats); |
| 48 | skia::RefPtr<SkPicture> CapturePicture(); |
[email protected] | 9b00348 | 2013-05-21 14:00:17 | [diff] [blame] | 49 | void UpdateTopControlsState(cc::TopControlsState constraints, |
| 50 | cc::TopControlsState current, |
[email protected] | 452b4a9 | 2013-03-28 21:24:38 | [diff] [blame] | 51 | bool animate); |
[email protected] | d908376 | 2013-03-24 01:36:40 | [diff] [blame] | 52 | void SetOverdrawBottomHeight(float overdraw_bottom_height); |
[email protected] | 0bc1f57 | 2013-04-17 01:46:31 | [diff] [blame] | 53 | void SetNeedsRedrawRect(gfx::Rect damage_rect); |
[email protected] | 4b15766 | 2013-05-29 04:05:05 | [diff] [blame] | 54 | void SetLatencyInfo(const ui::LatencyInfo& latency_info); |
[email protected] | 9ed83fe | 2013-02-27 01:52:28 | [diff] [blame] | 55 | |
[email protected] | ba91a79 | 2013-02-06 09:48:28 | [diff] [blame] | 56 | // WebLayerTreeView implementation. |
| 57 | virtual void setSurfaceReady(); |
| 58 | virtual void setRootLayer(const WebKit::WebLayer& layer); |
| 59 | virtual void clearRootLayer(); |
| 60 | virtual void setViewportSize( |
[email protected] | 18ce5970 | 2013-04-09 04:58:40 | [diff] [blame] | 61 | const WebKit::WebSize& unused_deprecated, |
[email protected] | ba91a79 | 2013-02-06 09:48:28 | [diff] [blame] | 62 | const WebKit::WebSize& device_viewport_size); |
| 63 | virtual WebKit::WebSize layoutViewportSize() const; |
| 64 | virtual WebKit::WebSize deviceViewportSize() const; |
| 65 | virtual WebKit::WebFloatPoint adjustEventPointForPinchZoom( |
| 66 | const WebKit::WebFloatPoint& point) const; |
| 67 | virtual void setDeviceScaleFactor(float device_scale); |
| 68 | virtual float deviceScaleFactor() const; |
| 69 | virtual void setBackgroundColor(WebKit::WebColor color); |
| 70 | virtual void setHasTransparentBackground(bool transparent); |
| 71 | virtual void setVisible(bool visible); |
| 72 | virtual void setPageScaleFactorAndLimits(float page_scale_factor, |
| 73 | float minimum, |
| 74 | float maximum); |
| 75 | virtual void startPageScaleAnimation(const WebKit::WebPoint& destination, |
| 76 | bool use_anchor, |
| 77 | float new_page_scale, |
| 78 | double duration_sec); |
| 79 | virtual void setNeedsAnimate(); |
| 80 | virtual void setNeedsRedraw(); |
| 81 | virtual bool commitRequested() const; |
[email protected] | ba91a79 | 2013-02-06 09:48:28 | [diff] [blame] | 82 | virtual void didStopFlinging(); |
| 83 | virtual bool compositeAndReadback(void *pixels, const WebKit::WebRect& rect); |
| 84 | virtual void finishAllRendering(); |
| 85 | virtual void setDeferCommits(bool defer_commits); |
[email protected] | cef1b39 | 2013-03-07 20:24:58 | [diff] [blame] | 86 | virtual void registerForAnimations(WebKit::WebLayer* layer); |
[email protected] | ba91a79 | 2013-02-06 09:48:28 | [diff] [blame] | 87 | virtual void renderingStats(WebKit::WebRenderingStats& stats) const {} |
| 88 | virtual void setShowFPSCounter(bool show); |
| 89 | virtual void setShowPaintRects(bool show); |
[email protected] | d3be028 | 2013-02-07 19:00:23 | [diff] [blame] | 90 | virtual void setShowDebugBorders(bool show); |
[email protected] | ba91a79 | 2013-02-06 09:48:28 | [diff] [blame] | 91 | virtual void setContinuousPaintingEnabled(bool enabled); |
| 92 | |
| 93 | // cc::LayerTreeHostClient implementation. |
[email protected] | 408b5e2 | 2013-03-19 09:48:09 | [diff] [blame] | 94 | virtual void WillBeginFrame() OVERRIDE; |
| 95 | virtual void DidBeginFrame() OVERRIDE; |
| 96 | virtual void Animate(double frame_begin_time) OVERRIDE; |
| 97 | virtual void Layout() OVERRIDE; |
| 98 | virtual void ApplyScrollAndScale(gfx::Vector2d scroll_delta, |
[email protected] | ba91a79 | 2013-02-06 09:48:28 | [diff] [blame] | 99 | float page_scale) OVERRIDE; |
[email protected] | 408b5e2 | 2013-03-19 09:48:09 | [diff] [blame] | 100 | virtual scoped_ptr<cc::OutputSurface> CreateOutputSurface() OVERRIDE; |
[email protected] | 14bd554 | 2013-05-08 21:51:30 | [diff] [blame] | 101 | virtual void DidInitializeOutputSurface(bool success) OVERRIDE; |
[email protected] | 408b5e2 | 2013-03-19 09:48:09 | [diff] [blame] | 102 | virtual void WillCommit() OVERRIDE; |
| 103 | virtual void DidCommit() OVERRIDE; |
| 104 | virtual void DidCommitAndDrawFrame() OVERRIDE; |
| 105 | virtual void DidCompleteSwapBuffers() OVERRIDE; |
| 106 | virtual void ScheduleComposite() OVERRIDE; |
[email protected] | 0a45172 | 2013-02-22 20:32:05 | [diff] [blame] | 107 | virtual scoped_refptr<cc::ContextProvider> |
| 108 | OffscreenContextProviderForMainThread() OVERRIDE; |
| 109 | virtual scoped_refptr<cc::ContextProvider> |
| 110 | OffscreenContextProviderForCompositorThread() OVERRIDE; |
[email protected] | ba91a79 | 2013-02-06 09:48:28 | [diff] [blame] | 111 | |
[email protected] | 200a9c06 | 2013-05-20 04:34:37 | [diff] [blame] | 112 | private: |
[email protected] | 635353c | 2013-03-06 09:11:20 | [diff] [blame] | 113 | explicit RenderWidgetCompositor(RenderWidget* widget); |
[email protected] | ba91a79 | 2013-02-06 09:48:28 | [diff] [blame] | 114 | |
| 115 | bool initialize(cc::LayerTreeSettings settings); |
| 116 | |
| 117 | bool threaded_; |
[email protected] | 9ed83fe | 2013-02-27 01:52:28 | [diff] [blame] | 118 | bool suppress_schedule_composite_; |
[email protected] | ba91a79 | 2013-02-06 09:48:28 | [diff] [blame] | 119 | RenderWidget* widget_; |
[email protected] | ba91a79 | 2013-02-06 09:48:28 | [diff] [blame] | 120 | scoped_ptr<cc::LayerTreeHost> layer_tree_host_; |
[email protected] | ba91a79 | 2013-02-06 09:48:28 | [diff] [blame] | 121 | }; |
| 122 | |
| 123 | } // namespace content |
| 124 | |
| 125 | #endif // CONTENT_RENDERER_GPU_RENDER_WIDGET_COMPOSITOR_H_ |