blob: b6fa9af3b149ce9282b48af336c373745fcaff1e [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]5c30b5e02013-05-30 03:46:0814#include "third_party/WebKit/public/platform/WebLayerTreeView.h"
[email protected]0bc1f572013-04-17 01:46:3115#include "ui/gfx/rect.h"
[email protected]ba91a792013-02-06 09:48:2816
[email protected]4b157662013-05-29 04:05:0517namespace ui {
18struct LatencyInfo;
19}
20
[email protected]ba91a792013-02-06 09:48:2821namespace cc {
[email protected]200a9c062013-05-20 04:34:3722class InputHandler;
[email protected]ba91a792013-02-06 09:48:2823class LayerTreeHost;
24}
25
26namespace content {
27class RenderWidget;
28
29class RenderWidgetCompositor : public WebKit::WebLayerTreeView,
30 public cc::LayerTreeHostClient {
31 public:
32 // Attempt to construct and initialize a compositor instance for the widget
33 // with the given settings. Returns NULL if initialization fails.
[email protected]c5fa4c42013-07-20 05:47:3734 static scoped_ptr<RenderWidgetCompositor> Create(RenderWidget* widget,
35 bool threaded);
[email protected]ba91a792013-02-06 09:48:2836
37 virtual ~RenderWidgetCompositor();
38
[email protected]200a9c062013-05-20 04:34:3739 const base::WeakPtr<cc::InputHandler>& GetInputHandler();
[email protected]9ed83fe2013-02-27 01:52:2840 void SetSuppressScheduleComposite(bool suppress);
[email protected]635353c2013-03-06 09:11:2041 void Animate(base::TimeTicks time);
[email protected]f0c2a242013-03-15 19:34:5242 void Composite(base::TimeTicks frame_begin_time);
[email protected]24ed0432013-04-24 07:50:3143 void SetNeedsDisplayOnAllLayers();
[email protected]206a3922013-05-17 06:34:1244 void SetRasterizeOnlyVisibleContent();
[email protected]635353c2013-03-06 09:11:2045 void GetRenderingStats(cc::RenderingStats* stats);
[email protected]9b003482013-05-21 14:00:1746 void UpdateTopControlsState(cc::TopControlsState constraints,
47 cc::TopControlsState current,
[email protected]452b4a92013-03-28 21:24:3848 bool animate);
[email protected]d9083762013-03-24 01:36:4049 void SetOverdrawBottomHeight(float overdraw_bottom_height);
[email protected]0bc1f572013-04-17 01:46:3150 void SetNeedsRedrawRect(gfx::Rect damage_rect);
[email protected]4b157662013-05-29 04:05:0551 void SetLatencyInfo(const ui::LatencyInfo& latency_info);
[email protected]6e89eb72013-07-23 13:28:2252 int GetLayerTreeId() const;
[email protected]9ed83fe2013-02-27 01:52:2853
[email protected]ba91a792013-02-06 09:48:2854 // WebLayerTreeView implementation.
55 virtual void setSurfaceReady();
56 virtual void setRootLayer(const WebKit::WebLayer& layer);
57 virtual void clearRootLayer();
58 virtual void setViewportSize(
[email protected]18ce59702013-04-09 04:58:4059 const WebKit::WebSize& unused_deprecated,
[email protected]ba91a792013-02-06 09:48:2860 const WebKit::WebSize& device_viewport_size);
61 virtual WebKit::WebSize layoutViewportSize() const;
62 virtual WebKit::WebSize deviceViewportSize() const;
63 virtual WebKit::WebFloatPoint adjustEventPointForPinchZoom(
64 const WebKit::WebFloatPoint& point) const;
65 virtual void setDeviceScaleFactor(float device_scale);
66 virtual float deviceScaleFactor() const;
67 virtual void setBackgroundColor(WebKit::WebColor color);
68 virtual void setHasTransparentBackground(bool transparent);
69 virtual void setVisible(bool visible);
70 virtual void setPageScaleFactorAndLimits(float page_scale_factor,
71 float minimum,
72 float maximum);
73 virtual void startPageScaleAnimation(const WebKit::WebPoint& destination,
74 bool use_anchor,
75 float new_page_scale,
76 double duration_sec);
77 virtual void setNeedsAnimate();
78 virtual void setNeedsRedraw();
79 virtual bool commitRequested() const;
[email protected]ba91a792013-02-06 09:48:2880 virtual void didStopFlinging();
81 virtual bool compositeAndReadback(void *pixels, const WebKit::WebRect& rect);
82 virtual void finishAllRendering();
83 virtual void setDeferCommits(bool defer_commits);
[email protected]cef1b392013-03-07 20:24:5884 virtual void registerForAnimations(WebKit::WebLayer* layer);
[email protected]ba91a792013-02-06 09:48:2885 virtual void renderingStats(WebKit::WebRenderingStats& stats) const {}
86 virtual void setShowFPSCounter(bool show);
87 virtual void setShowPaintRects(bool show);
[email protected]d3be0282013-02-07 19:00:2388 virtual void setShowDebugBorders(bool show);
[email protected]ba91a792013-02-06 09:48:2889 virtual void setContinuousPaintingEnabled(bool enabled);
[email protected]32802a32013-07-04 11:45:4190 virtual void setShowScrollBottleneckRects(bool show);
[email protected]ba91a792013-02-06 09:48:2891
92 // cc::LayerTreeHostClient implementation.
[email protected]408b5e22013-03-19 09:48:0993 virtual void WillBeginFrame() OVERRIDE;
94 virtual void DidBeginFrame() OVERRIDE;
95 virtual void Animate(double frame_begin_time) OVERRIDE;
96 virtual void Layout() OVERRIDE;
97 virtual void ApplyScrollAndScale(gfx::Vector2d scroll_delta,
[email protected]ba91a792013-02-06 09:48:2898 float page_scale) OVERRIDE;
[email protected]408b5e22013-03-19 09:48:0999 virtual scoped_ptr<cc::OutputSurface> CreateOutputSurface() OVERRIDE;
[email protected]14bd5542013-05-08 21:51:30100 virtual void DidInitializeOutputSurface(bool success) OVERRIDE;
[email protected]408b5e22013-03-19 09:48:09101 virtual void WillCommit() OVERRIDE;
102 virtual void DidCommit() OVERRIDE;
103 virtual void DidCommitAndDrawFrame() OVERRIDE;
104 virtual void DidCompleteSwapBuffers() OVERRIDE;
105 virtual void ScheduleComposite() OVERRIDE;
[email protected]0a451722013-02-22 20:32:05106 virtual scoped_refptr<cc::ContextProvider>
107 OffscreenContextProviderForMainThread() OVERRIDE;
108 virtual scoped_refptr<cc::ContextProvider>
109 OffscreenContextProviderForCompositorThread() OVERRIDE;
[email protected]ba91a792013-02-06 09:48:28110
[email protected]200a9c062013-05-20 04:34:37111 private:
[email protected]c5fa4c42013-07-20 05:47:37112 RenderWidgetCompositor(RenderWidget* widget, bool threaded);
[email protected]ba91a792013-02-06 09:48:28113
114 bool initialize(cc::LayerTreeSettings settings);
115
116 bool threaded_;
[email protected]9ed83fe2013-02-27 01:52:28117 bool suppress_schedule_composite_;
[email protected]ba91a792013-02-06 09:48:28118 RenderWidget* widget_;
[email protected]ba91a792013-02-06 09:48:28119 scoped_ptr<cc::LayerTreeHost> layer_tree_host_;
[email protected]ba91a792013-02-06 09:48:28120};
121
122} // namespace content
123
124#endif // CONTENT_RENDERER_GPU_RENDER_WIDGET_COMPOSITOR_H_