blob: ba46f10838a8755dcfe85b248b52e7a344c2b881 [file] [log] [blame]
[email protected]ba91a792013-02-06 09:48:281// 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]200a9c062013-05-20 04:34:378#include "base/memory/weak_ptr.h"
[email protected]abb522162013-06-28 01:54:169#include "base/time/time.h"
[email protected]6e84de22013-03-18 06:54:2710#include "cc/debug/rendering_stats.h"
[email protected]9b003482013-05-21 14:00:1711#include "cc/input/top_controls_state.h"
[email protected]556fd292013-03-18 08:03:0412#include "cc/trees/layer_tree_host_client.h"
13#include "cc/trees/layer_tree_settings.h"
[email protected]635353c2013-03-06 09:11:2014#include "skia/ext/refptr.h"
[email protected]5c30b5e02013-05-30 03:46:0815#include "third_party/WebKit/public/platform/WebLayerTreeView.h"
[email protected]0bc1f572013-04-17 01:46:3116#include "ui/gfx/rect.h"
[email protected]ba91a792013-02-06 09:48:2817
[email protected]635353c2013-03-06 09:11:2018class SkPicture;
19
[email protected]4b157662013-05-29 04:05:0520namespace ui {
21struct LatencyInfo;
22}
23
[email protected]ba91a792013-02-06 09:48:2824namespace cc {
[email protected]200a9c062013-05-20 04:34:3725class InputHandler;
[email protected]ba91a792013-02-06 09:48:2826class LayerTreeHost;
27}
28
29namespace content {
30class RenderWidget;
31
32class 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]e195e582013-03-08 01:32:5937 static scoped_ptr<RenderWidgetCompositor> Create(RenderWidget* widget);
[email protected]ba91a792013-02-06 09:48:2838
39 virtual ~RenderWidgetCompositor();
40
[email protected]200a9c062013-05-20 04:34:3741 const base::WeakPtr<cc::InputHandler>& GetInputHandler();
[email protected]9ed83fe2013-02-27 01:52:2842 void SetSuppressScheduleComposite(bool suppress);
[email protected]635353c2013-03-06 09:11:2043 void Animate(base::TimeTicks time);
[email protected]f0c2a242013-03-15 19:34:5244 void Composite(base::TimeTicks frame_begin_time);
[email protected]24ed0432013-04-24 07:50:3145 void SetNeedsDisplayOnAllLayers();
[email protected]206a3922013-05-17 06:34:1246 void SetRasterizeOnlyVisibleContent();
[email protected]635353c2013-03-06 09:11:2047 void GetRenderingStats(cc::RenderingStats* stats);
48 skia::RefPtr<SkPicture> CapturePicture();
[email protected]9b003482013-05-21 14:00:1749 void UpdateTopControlsState(cc::TopControlsState constraints,
50 cc::TopControlsState current,
[email protected]452b4a92013-03-28 21:24:3851 bool animate);
[email protected]d9083762013-03-24 01:36:4052 void SetOverdrawBottomHeight(float overdraw_bottom_height);
[email protected]0bc1f572013-04-17 01:46:3153 void SetNeedsRedrawRect(gfx::Rect damage_rect);
[email protected]4b157662013-05-29 04:05:0554 void SetLatencyInfo(const ui::LatencyInfo& latency_info);
[email protected]9ed83fe2013-02-27 01:52:2855
[email protected]ba91a792013-02-06 09:48:2856 // WebLayerTreeView implementation.
57 virtual void setSurfaceReady();
58 virtual void setRootLayer(const WebKit::WebLayer& layer);
59 virtual void clearRootLayer();
60 virtual void setViewportSize(
[email protected]18ce59702013-04-09 04:58:4061 const WebKit::WebSize& unused_deprecated,
[email protected]ba91a792013-02-06 09:48:2862 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]ba91a792013-02-06 09:48:2882 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]cef1b392013-03-07 20:24:5886 virtual void registerForAnimations(WebKit::WebLayer* layer);
[email protected]ba91a792013-02-06 09:48:2887 virtual void renderingStats(WebKit::WebRenderingStats& stats) const {}
88 virtual void setShowFPSCounter(bool show);
89 virtual void setShowPaintRects(bool show);
[email protected]d3be0282013-02-07 19:00:2390 virtual void setShowDebugBorders(bool show);
[email protected]ba91a792013-02-06 09:48:2891 virtual void setContinuousPaintingEnabled(bool enabled);
92
93 // cc::LayerTreeHostClient implementation.
[email protected]408b5e22013-03-19 09:48:0994 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]ba91a792013-02-06 09:48:2899 float page_scale) OVERRIDE;
[email protected]408b5e22013-03-19 09:48:09100 virtual scoped_ptr<cc::OutputSurface> CreateOutputSurface() OVERRIDE;
[email protected]14bd5542013-05-08 21:51:30101 virtual void DidInitializeOutputSurface(bool success) OVERRIDE;
[email protected]408b5e22013-03-19 09:48:09102 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]0a451722013-02-22 20:32:05107 virtual scoped_refptr<cc::ContextProvider>
108 OffscreenContextProviderForMainThread() OVERRIDE;
109 virtual scoped_refptr<cc::ContextProvider>
110 OffscreenContextProviderForCompositorThread() OVERRIDE;
[email protected]ba91a792013-02-06 09:48:28111
[email protected]200a9c062013-05-20 04:34:37112 private:
[email protected]635353c2013-03-06 09:11:20113 explicit RenderWidgetCompositor(RenderWidget* widget);
[email protected]ba91a792013-02-06 09:48:28114
115 bool initialize(cc::LayerTreeSettings settings);
116
117 bool threaded_;
[email protected]9ed83fe2013-02-27 01:52:28118 bool suppress_schedule_composite_;
[email protected]ba91a792013-02-06 09:48:28119 RenderWidget* widget_;
[email protected]ba91a792013-02-06 09:48:28120 scoped_ptr<cc::LayerTreeHost> layer_tree_host_;
[email protected]ba91a792013-02-06 09:48:28121};
122
123} // namespace content
124
125#endif // CONTENT_RENDERER_GPU_RENDER_WIDGET_COMPOSITOR_H_