blob: c1578d50de1f89d5804072dfcff9d22b850dbdb4 [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]666d7cf2013-10-12 01:30:298#include "base/callback.h"
[email protected]200a9c062013-05-20 04:34:379#include "base/memory/weak_ptr.h"
[email protected]abb522162013-06-28 01:54:1610#include "base/time/time.h"
[email protected]752e2cf2013-10-21 21:41:1511#include "base/values.h"
[email protected]6be422b2013-12-08 06:47:3112#include "cc/base/swap_promise_monitor.h"
[email protected]9b003482013-05-21 14:00:1713#include "cc/input/top_controls_state.h"
[email protected]556fd292013-03-18 08:03:0414#include "cc/trees/layer_tree_host_client.h"
[email protected]943528e2013-11-07 05:01:3215#include "cc/trees/layer_tree_host_single_thread_client.h"
[email protected]556fd292013-03-18 08:03:0416#include "cc/trees/layer_tree_settings.h"
[email protected]5c30b5e02013-05-30 03:46:0817#include "third_party/WebKit/public/platform/WebLayerTreeView.h"
[email protected]9f4f6a32013-09-04 21:35:1218#include "third_party/skia/include/core/SkBitmap.h"
[email protected]0bc1f572013-04-17 01:46:3119#include "ui/gfx/rect.h"
[email protected]ba91a792013-02-06 09:48:2820
[email protected]4b157662013-05-29 04:05:0521namespace ui {
22struct LatencyInfo;
23}
24
[email protected]ba91a792013-02-06 09:48:2825namespace cc {
[email protected]200a9c062013-05-20 04:34:3726class InputHandler;
[email protected]f7837a92013-08-21 03:00:0527class Layer;
[email protected]ba91a792013-02-06 09:48:2828class LayerTreeHost;
29}
30
31namespace content {
32class RenderWidget;
33
[email protected]180ef242013-11-07 06:50:4634class RenderWidgetCompositor : public blink::WebLayerTreeView,
[email protected]943528e2013-11-07 05:01:3235 public cc::LayerTreeHostClient,
36 public cc::LayerTreeHostSingleThreadClient {
[email protected]ba91a792013-02-06 09:48:2837 public:
38 // Attempt to construct and initialize a compositor instance for the widget
39 // with the given settings. Returns NULL if initialization fails.
[email protected]c5fa4c42013-07-20 05:47:3740 static scoped_ptr<RenderWidgetCompositor> Create(RenderWidget* widget,
41 bool threaded);
[email protected]ba91a792013-02-06 09:48:2842
43 virtual ~RenderWidgetCompositor();
44
[email protected]200a9c062013-05-20 04:34:3745 const base::WeakPtr<cc::InputHandler>& GetInputHandler();
[email protected]9ed83fe2013-02-27 01:52:2846 void SetSuppressScheduleComposite(bool suppress);
[email protected]971728d2013-10-26 10:39:3147 bool BeginMainFrameRequested() const;
[email protected]e197af302014-02-07 09:36:4948 void UpdateAnimations(base::TimeTicks time);
[email protected]f0c2a242013-03-15 19:34:5249 void Composite(base::TimeTicks frame_begin_time);
[email protected]24ed0432013-04-24 07:50:3150 void SetNeedsDisplayOnAllLayers();
[email protected]206a3922013-05-17 06:34:1251 void SetRasterizeOnlyVisibleContent();
[email protected]9b003482013-05-21 14:00:1752 void UpdateTopControlsState(cc::TopControlsState constraints,
53 cc::TopControlsState current,
[email protected]452b4a92013-03-28 21:24:3854 bool animate);
[email protected]d9083762013-03-24 01:36:4055 void SetOverdrawBottomHeight(float overdraw_bottom_height);
[email protected]0bc1f572013-04-17 01:46:3156 void SetNeedsRedrawRect(gfx::Rect damage_rect);
[email protected]7d08a9352013-10-15 08:24:5657 // Like setNeedsRedraw but forces the frame to be drawn, without early-outs.
58 // Redraw will be forced after the next commit
59 void SetNeedsForcedRedraw();
[email protected]6be422b2013-12-08 06:47:3160 // Calling CreateLatencyInfoSwapPromiseMonitor() to get a scoped
61 // LatencyInfoSwapPromiseMonitor. During the life time of the
62 // LatencyInfoSwapPromiseMonitor, if SetNeedsCommit() or SetNeedsUpdateLayer()
63 // is called on LayerTreeHost, the original latency info will be turned
64 // into a LatencyInfoSwapPromise.
65 scoped_ptr<cc::SwapPromiseMonitor> CreateLatencyInfoSwapPromiseMonitor(
66 ui::LatencyInfo* latency);
[email protected]6e89eb72013-07-23 13:28:2267 int GetLayerTreeId() const;
[email protected]df09e052013-07-31 18:59:5068 void NotifyInputThrottledUntilCommit();
[email protected]f7837a92013-08-21 03:00:0569 const cc::Layer* GetRootLayer() const;
[email protected]666d7cf2013-10-12 01:30:2970 bool ScheduleMicroBenchmark(
71 const std::string& name,
[email protected]752e2cf2013-10-21 21:41:1572 scoped_ptr<base::Value> value,
[email protected]666d7cf2013-10-12 01:30:2973 const base::Callback<void(scoped_ptr<base::Value>)>& callback);
[email protected]9ed83fe2013-02-27 01:52:2874
[email protected]ba91a792013-02-06 09:48:2875 // WebLayerTreeView implementation.
76 virtual void setSurfaceReady();
[email protected]180ef242013-11-07 06:50:4677 virtual void setRootLayer(const blink::WebLayer& layer);
[email protected]ba91a792013-02-06 09:48:2878 virtual void clearRootLayer();
79 virtual void setViewportSize(
[email protected]180ef242013-11-07 06:50:4680 const blink::WebSize& unused_deprecated,
81 const blink::WebSize& device_viewport_size);
82 virtual blink::WebSize layoutViewportSize() const;
83 virtual blink::WebSize deviceViewportSize() const;
84 virtual blink::WebFloatPoint adjustEventPointForPinchZoom(
85 const blink::WebFloatPoint& point) const;
[email protected]ba91a792013-02-06 09:48:2886 virtual void setDeviceScaleFactor(float device_scale);
87 virtual float deviceScaleFactor() const;
[email protected]180ef242013-11-07 06:50:4688 virtual void setBackgroundColor(blink::WebColor color);
[email protected]ba91a792013-02-06 09:48:2889 virtual void setHasTransparentBackground(bool transparent);
[email protected]9f4f6a32013-09-04 21:35:1290 virtual void setOverhangBitmap(const SkBitmap& bitmap);
[email protected]ba91a792013-02-06 09:48:2891 virtual void setVisible(bool visible);
92 virtual void setPageScaleFactorAndLimits(float page_scale_factor,
93 float minimum,
94 float maximum);
[email protected]180ef242013-11-07 06:50:4695 virtual void startPageScaleAnimation(const blink::WebPoint& destination,
[email protected]ba91a792013-02-06 09:48:2896 bool use_anchor,
97 float new_page_scale,
98 double duration_sec);
[email protected]27a747d2014-04-30 10:23:0199 virtual void heuristicsForGpuRasterizationUpdated(bool matches_heuristics);
[email protected]8b9e52b2014-01-17 16:35:31100 virtual void setNeedsAnimate();
101 virtual bool commitRequested() const;
[email protected]ba91a792013-02-06 09:48:28102 virtual void didStopFlinging();
[email protected]180ef242013-11-07 06:50:46103 virtual bool compositeAndReadback(void *pixels, const blink::WebRect& rect);
[email protected]ba91a792013-02-06 09:48:28104 virtual void finishAllRendering();
105 virtual void setDeferCommits(bool defer_commits);
[email protected]180ef242013-11-07 06:50:46106 virtual void registerForAnimations(blink::WebLayer* layer);
[email protected]57ac9482013-09-17 21:13:39107 virtual void registerViewportLayers(
[email protected]180ef242013-11-07 06:50:46108 const blink::WebLayer* pageScaleLayer,
109 const blink::WebLayer* innerViewportScrollLayer,
110 const blink::WebLayer* outerViewportScrollLayer) OVERRIDE;
[email protected]57ac9482013-09-17 21:13:39111 virtual void clearViewportLayers() OVERRIDE;
[email protected]ba91a792013-02-06 09:48:28112 virtual void setShowFPSCounter(bool show);
113 virtual void setShowPaintRects(bool show);
[email protected]d3be0282013-02-07 19:00:23114 virtual void setShowDebugBorders(bool show);
[email protected]ba91a792013-02-06 09:48:28115 virtual void setContinuousPaintingEnabled(bool enabled);
[email protected]32802a32013-07-04 11:45:41116 virtual void setShowScrollBottleneckRects(bool show);
[email protected]ba91a792013-02-06 09:48:28117
118 // cc::LayerTreeHostClient implementation.
[email protected]33004772013-11-12 09:49:23119 virtual void WillBeginMainFrame(int frame_id) OVERRIDE;
[email protected]daea3d42013-10-23 17:04:50120 virtual void DidBeginMainFrame() OVERRIDE;
[email protected]e197af302014-02-07 09:36:49121 virtual void Animate(base::TimeTicks frame_begin_time) OVERRIDE;
[email protected]408b5e22013-03-19 09:48:09122 virtual void Layout() OVERRIDE;
[email protected]243e4f12014-02-05 09:18:42123 virtual void ApplyScrollAndScale(const gfx::Vector2d& scroll_delta,
[email protected]ba91a792013-02-06 09:48:28124 float page_scale) OVERRIDE;
[email protected]ebc0e1df2013-08-01 02:46:22125 virtual scoped_ptr<cc::OutputSurface> CreateOutputSurface(bool fallback)
126 OVERRIDE;
[email protected]da8e3b72b2014-04-25 02:33:45127 virtual void DidInitializeOutputSurface() OVERRIDE;
[email protected]408b5e22013-03-19 09:48:09128 virtual void WillCommit() OVERRIDE;
129 virtual void DidCommit() OVERRIDE;
130 virtual void DidCommitAndDrawFrame() OVERRIDE;
131 virtual void DidCompleteSwapBuffers() OVERRIDE;
[email protected]aeeb3372013-11-05 14:05:54132 virtual void RateLimitSharedMainThreadContext() OVERRIDE;
[email protected]ba91a792013-02-06 09:48:28133
[email protected]943528e2013-11-07 05:01:32134 // cc::LayerTreeHostSingleThreadClient implementation.
135 virtual void ScheduleComposite() OVERRIDE;
[email protected]e3067e32013-11-22 07:51:45136 virtual void ScheduleAnimation() OVERRIDE;
[email protected]4d7e46a2013-11-08 05:33:40137 virtual void DidPostSwapBuffers() OVERRIDE;
138 virtual void DidAbortSwapBuffers() OVERRIDE;
[email protected]943528e2013-11-07 05:01:32139
[email protected]200a9c062013-05-20 04:34:37140 private:
[email protected]c5fa4c42013-07-20 05:47:37141 RenderWidgetCompositor(RenderWidget* widget, bool threaded);
[email protected]ba91a792013-02-06 09:48:28142
[email protected]e96e3432013-12-19 18:56:07143 void Initialize(cc::LayerTreeSettings settings);
[email protected]ba91a792013-02-06 09:48:28144
145 bool threaded_;
[email protected]9ed83fe2013-02-27 01:52:28146 bool suppress_schedule_composite_;
[email protected]ba91a792013-02-06 09:48:28147 RenderWidget* widget_;
[email protected]ba91a792013-02-06 09:48:28148 scoped_ptr<cc::LayerTreeHost> layer_tree_host_;
[email protected]ba91a792013-02-06 09:48:28149};
150
151} // namespace content
152
153#endif // CONTENT_RENDERER_GPU_RENDER_WIDGET_COMPOSITOR_H_