blob: e88c05dcac031a0fb7bdca574d90b36028ea55f8 [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]635353c2013-03-06 09:11:208#include "base/time.h"
[email protected]6e84de22013-03-18 06:54:279#include "cc/debug/rendering_stats.h"
[email protected]556fd292013-03-18 08:03:0410#include "cc/trees/layer_tree_host_client.h"
11#include "cc/trees/layer_tree_settings.h"
[email protected]635353c2013-03-06 09:11:2012#include "skia/ext/refptr.h"
[email protected]ba91a792013-02-06 09:48:2813#include "third_party/WebKit/Source/Platform/chromium/public/WebLayerTreeView.h"
[email protected]0bc1f572013-04-17 01:46:3114#include "ui/gfx/rect.h"
[email protected]ba91a792013-02-06 09:48:2815
[email protected]635353c2013-03-06 09:11:2016class SkPicture;
17
[email protected]ba91a792013-02-06 09:48:2818namespace cc {
19class LayerTreeHost;
20}
21
22namespace content {
23class RenderWidget;
24
25class 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]e195e582013-03-08 01:32:5930 static scoped_ptr<RenderWidgetCompositor> Create(RenderWidget* widget);
[email protected]ba91a792013-02-06 09:48:2831
32 virtual ~RenderWidgetCompositor();
33
[email protected]9ed83fe2013-02-27 01:52:2834 void SetSuppressScheduleComposite(bool suppress);
[email protected]635353c2013-03-06 09:11:2035 void Animate(base::TimeTicks time);
[email protected]f0c2a242013-03-15 19:34:5236 void Composite(base::TimeTicks frame_begin_time);
[email protected]24ed0432013-04-24 07:50:3137 void SetNeedsDisplayOnAllLayers();
[email protected]635353c2013-03-06 09:11:2038 void GetRenderingStats(cc::RenderingStats* stats);
39 skia::RefPtr<SkPicture> CapturePicture();
[email protected]452b4a92013-03-28 21:24:3840 void UpdateTopControlsState(bool enable_hiding,
41 bool enable_showing,
42 bool animate);
[email protected]d9083762013-03-24 01:36:4043 void SetOverdrawBottomHeight(float overdraw_bottom_height);
[email protected]0bc1f572013-04-17 01:46:3144 void SetNeedsRedrawRect(gfx::Rect damage_rect);
[email protected]9ed83fe2013-02-27 01:52:2845
[email protected]ba91a792013-02-06 09:48:2846 // WebLayerTreeView implementation.
47 virtual void setSurfaceReady();
48 virtual void setRootLayer(const WebKit::WebLayer& layer);
49 virtual void clearRootLayer();
50 virtual void setViewportSize(
[email protected]18ce59702013-04-09 04:58:4051 const WebKit::WebSize& unused_deprecated,
[email protected]ba91a792013-02-06 09:48:2852 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]ba91a792013-02-06 09:48:2872 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]cef1b392013-03-07 20:24:5876 virtual void registerForAnimations(WebKit::WebLayer* layer);
[email protected]ba91a792013-02-06 09:48:2877 virtual void renderingStats(WebKit::WebRenderingStats& stats) const {}
78 virtual void setShowFPSCounter(bool show);
79 virtual void setShowPaintRects(bool show);
[email protected]d3be0282013-02-07 19:00:2380 virtual void setShowDebugBorders(bool show);
[email protected]ba91a792013-02-06 09:48:2881 virtual void setContinuousPaintingEnabled(bool enabled);
82
83 // cc::LayerTreeHostClient implementation.
[email protected]408b5e22013-03-19 09:48:0984 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]ba91a792013-02-06 09:48:2889 float page_scale) OVERRIDE;
[email protected]408b5e22013-03-19 09:48:0990 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]0a451722013-02-22 20:32:0598 virtual scoped_refptr<cc::ContextProvider>
99 OffscreenContextProviderForMainThread() OVERRIDE;
100 virtual scoped_refptr<cc::ContextProvider>
101 OffscreenContextProviderForCompositorThread() OVERRIDE;
[email protected]ba91a792013-02-06 09:48:28102
103private:
[email protected]635353c2013-03-06 09:11:20104 explicit RenderWidgetCompositor(RenderWidget* widget);
[email protected]ba91a792013-02-06 09:48:28105
106 bool initialize(cc::LayerTreeSettings settings);
107
108 bool threaded_;
[email protected]9ed83fe2013-02-27 01:52:28109 bool suppress_schedule_composite_;
[email protected]ba91a792013-02-06 09:48:28110 RenderWidget* widget_;
[email protected]ba91a792013-02-06 09:48:28111 scoped_ptr<cc::LayerTreeHost> layer_tree_host_;
[email protected]ba91a792013-02-06 09:48:28112};
113
114} // namespace content
115
116#endif // CONTENT_RENDERER_GPU_RENDER_WIDGET_COMPOSITOR_H_