blob: 37b66dabed8ab00a35b3ebda1b277127428866b3 [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]9f4f6a32013-09-04 21:35:1215#include "third_party/skia/include/core/SkBitmap.h"
[email protected]0bc1f572013-04-17 01:46:3116#include "ui/gfx/rect.h"
[email protected]ba91a792013-02-06 09:48:2817
[email protected]4b157662013-05-29 04:05:0518namespace ui {
19struct LatencyInfo;
20}
21
[email protected]ba91a792013-02-06 09:48:2822namespace cc {
[email protected]200a9c062013-05-20 04:34:3723class InputHandler;
[email protected]f7837a92013-08-21 03:00:0524class Layer;
[email protected]ba91a792013-02-06 09:48:2825class LayerTreeHost;
26}
27
28namespace content {
29class RenderWidget;
30
31class RenderWidgetCompositor : public WebKit::WebLayerTreeView,
32 public cc::LayerTreeHostClient {
33 public:
34 // Attempt to construct and initialize a compositor instance for the widget
35 // with the given settings. Returns NULL if initialization fails.
[email protected]c5fa4c42013-07-20 05:47:3736 static scoped_ptr<RenderWidgetCompositor> Create(RenderWidget* widget,
37 bool threaded);
[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);
[email protected]9b003482013-05-21 14:00:1748 void UpdateTopControlsState(cc::TopControlsState constraints,
49 cc::TopControlsState current,
[email protected]452b4a92013-03-28 21:24:3850 bool animate);
[email protected]d9083762013-03-24 01:36:4051 void SetOverdrawBottomHeight(float overdraw_bottom_height);
[email protected]0bc1f572013-04-17 01:46:3152 void SetNeedsRedrawRect(gfx::Rect damage_rect);
[email protected]4b157662013-05-29 04:05:0553 void SetLatencyInfo(const ui::LatencyInfo& latency_info);
[email protected]6e89eb72013-07-23 13:28:2254 int GetLayerTreeId() const;
[email protected]df09e052013-07-31 18:59:5055 void NotifyInputThrottledUntilCommit();
[email protected]f7837a92013-08-21 03:00:0556 const cc::Layer* GetRootLayer() const;
[email protected]9ed83fe2013-02-27 01:52:2857
[email protected]ba91a792013-02-06 09:48:2858 // WebLayerTreeView implementation.
59 virtual void setSurfaceReady();
60 virtual void setRootLayer(const WebKit::WebLayer& layer);
61 virtual void clearRootLayer();
62 virtual void setViewportSize(
[email protected]18ce59702013-04-09 04:58:4063 const WebKit::WebSize& unused_deprecated,
[email protected]ba91a792013-02-06 09:48:2864 const WebKit::WebSize& device_viewport_size);
65 virtual WebKit::WebSize layoutViewportSize() const;
66 virtual WebKit::WebSize deviceViewportSize() const;
67 virtual WebKit::WebFloatPoint adjustEventPointForPinchZoom(
68 const WebKit::WebFloatPoint& point) const;
69 virtual void setDeviceScaleFactor(float device_scale);
70 virtual float deviceScaleFactor() const;
71 virtual void setBackgroundColor(WebKit::WebColor color);
72 virtual void setHasTransparentBackground(bool transparent);
[email protected]9f4f6a32013-09-04 21:35:1273 virtual void setOverhangBitmap(const SkBitmap& bitmap);
[email protected]ba91a792013-02-06 09:48:2874 virtual void setVisible(bool visible);
75 virtual void setPageScaleFactorAndLimits(float page_scale_factor,
76 float minimum,
77 float maximum);
78 virtual void startPageScaleAnimation(const WebKit::WebPoint& destination,
79 bool use_anchor,
80 float new_page_scale,
81 double duration_sec);
82 virtual void setNeedsAnimate();
83 virtual void setNeedsRedraw();
84 virtual bool commitRequested() const;
[email protected]ba91a792013-02-06 09:48:2885 virtual void didStopFlinging();
86 virtual bool compositeAndReadback(void *pixels, const WebKit::WebRect& rect);
87 virtual void finishAllRendering();
88 virtual void setDeferCommits(bool defer_commits);
[email protected]cef1b392013-03-07 20:24:5889 virtual void registerForAnimations(WebKit::WebLayer* layer);
[email protected]ba91a792013-02-06 09:48:2890 virtual void renderingStats(WebKit::WebRenderingStats& stats) const {}
91 virtual void setShowFPSCounter(bool show);
92 virtual void setShowPaintRects(bool show);
[email protected]d3be0282013-02-07 19:00:2393 virtual void setShowDebugBorders(bool show);
[email protected]ba91a792013-02-06 09:48:2894 virtual void setContinuousPaintingEnabled(bool enabled);
[email protected]32802a32013-07-04 11:45:4195 virtual void setShowScrollBottleneckRects(bool show);
[email protected]ba91a792013-02-06 09:48:2896
97 // cc::LayerTreeHostClient implementation.
[email protected]408b5e22013-03-19 09:48:0998 virtual void WillBeginFrame() OVERRIDE;
99 virtual void DidBeginFrame() OVERRIDE;
100 virtual void Animate(double frame_begin_time) OVERRIDE;
101 virtual void Layout() OVERRIDE;
102 virtual void ApplyScrollAndScale(gfx::Vector2d scroll_delta,
[email protected]ba91a792013-02-06 09:48:28103 float page_scale) OVERRIDE;
[email protected]ebc0e1df2013-08-01 02:46:22104 virtual scoped_ptr<cc::OutputSurface> CreateOutputSurface(bool fallback)
105 OVERRIDE;
[email protected]14bd5542013-05-08 21:51:30106 virtual void DidInitializeOutputSurface(bool success) OVERRIDE;
[email protected]408b5e22013-03-19 09:48:09107 virtual void WillCommit() OVERRIDE;
108 virtual void DidCommit() OVERRIDE;
109 virtual void DidCommitAndDrawFrame() OVERRIDE;
110 virtual void DidCompleteSwapBuffers() OVERRIDE;
111 virtual void ScheduleComposite() OVERRIDE;
[email protected]0a451722013-02-22 20:32:05112 virtual scoped_refptr<cc::ContextProvider>
113 OffscreenContextProviderForMainThread() OVERRIDE;
114 virtual scoped_refptr<cc::ContextProvider>
115 OffscreenContextProviderForCompositorThread() OVERRIDE;
[email protected]ba91a792013-02-06 09:48:28116
[email protected]200a9c062013-05-20 04:34:37117 private:
[email protected]c5fa4c42013-07-20 05:47:37118 RenderWidgetCompositor(RenderWidget* widget, bool threaded);
[email protected]ba91a792013-02-06 09:48:28119
120 bool initialize(cc::LayerTreeSettings settings);
121
122 bool threaded_;
[email protected]9ed83fe2013-02-27 01:52:28123 bool suppress_schedule_composite_;
[email protected]ba91a792013-02-06 09:48:28124 RenderWidget* widget_;
[email protected]ba91a792013-02-06 09:48:28125 scoped_ptr<cc::LayerTreeHost> layer_tree_host_;
[email protected]ba91a792013-02-06 09:48:28126};
127
128} // namespace content
129
130#endif // CONTENT_RENDERER_GPU_RENDER_WIDGET_COMPOSITOR_H_