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