Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(240)

Side by Side Diff: content/renderer/gpu/render_widget_compositor.h

Issue 2835763002: Use swap-promise to improve first* paint times (Closed)
Patch Set: address review comments Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CONTENT_RENDERER_GPU_RENDER_WIDGET_COMPOSITOR_H_ 5 #ifndef CONTENT_RENDERER_GPU_RENDER_WIDGET_COMPOSITOR_H_
6 #define CONTENT_RENDERER_GPU_RENDER_WIDGET_COMPOSITOR_H_ 6 #define CONTENT_RENDERER_GPU_RENDER_WIDGET_COMPOSITOR_H_
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include "base/callback.h" 10 #include "base/callback.h"
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 46
47 namespace content { 47 namespace content {
48 48
49 class RenderWidgetCompositorDelegate; 49 class RenderWidgetCompositorDelegate;
50 struct ScreenInfo; 50 struct ScreenInfo;
51 51
52 class CONTENT_EXPORT RenderWidgetCompositor 52 class CONTENT_EXPORT RenderWidgetCompositor
53 : NON_EXPORTED_BASE(public blink::WebLayerTreeView), 53 : NON_EXPORTED_BASE(public blink::WebLayerTreeView),
54 NON_EXPORTED_BASE(public cc::LayerTreeHostClient), 54 NON_EXPORTED_BASE(public cc::LayerTreeHostClient),
55 NON_EXPORTED_BASE(public cc::LayerTreeHostSingleThreadClient) { 55 NON_EXPORTED_BASE(public cc::LayerTreeHostSingleThreadClient) {
56 using ReportTimeCallback = base::Callback<void(bool, double)>;
57
56 public: 58 public:
57 // Attempt to construct and initialize a compositor instance for the widget 59 // Attempt to construct and initialize a compositor instance for the widget
58 // with the given settings. Returns NULL if initialization fails. 60 // with the given settings. Returns NULL if initialization fails.
59 static std::unique_ptr<RenderWidgetCompositor> Create( 61 static std::unique_ptr<RenderWidgetCompositor> Create(
60 RenderWidgetCompositorDelegate* delegate, 62 RenderWidgetCompositorDelegate* delegate,
61 CompositorDependencies* compositor_deps); 63 CompositorDependencies* compositor_deps);
62 64
63 ~RenderWidgetCompositor() override; 65 ~RenderWidgetCompositor() override;
64 66
65 static cc::LayerTreeSettings GenerateLayerTreeSettings( 67 static cc::LayerTreeSettings GenerateLayerTreeSettings(
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
160 void UpdateEventRectsForSubframeIfNecessary() override; 162 void UpdateEventRectsForSubframeIfNecessary() override;
161 blink::WebEventListenerProperties EventListenerProperties( 163 blink::WebEventListenerProperties EventListenerProperties(
162 blink::WebEventListenerClass eventClass) const override; 164 blink::WebEventListenerClass eventClass) const override;
163 void SetHaveScrollEventHandlers(bool) override; 165 void SetHaveScrollEventHandlers(bool) override;
164 bool HaveScrollEventHandlers() const override; 166 bool HaveScrollEventHandlers() const override;
165 int LayerTreeId() const override; 167 int LayerTreeId() const override;
166 void SetShowFPSCounter(bool show) override; 168 void SetShowFPSCounter(bool show) override;
167 void SetShowPaintRects(bool show) override; 169 void SetShowPaintRects(bool show) override;
168 void SetShowDebugBorders(bool show) override; 170 void SetShowDebugBorders(bool show) override;
169 void SetShowScrollBottleneckRects(bool show) override; 171 void SetShowScrollBottleneckRects(bool show) override;
172 void NotifySwapTime(base::Callback<void(bool, double)> callback) override;
170 173
171 void UpdateBrowserControlsState(blink::WebBrowserControlsState constraints, 174 void UpdateBrowserControlsState(blink::WebBrowserControlsState constraints,
172 blink::WebBrowserControlsState current, 175 blink::WebBrowserControlsState current,
173 bool animate) override; 176 bool animate) override;
174 void SetBrowserControlsHeight(float height, bool shrink) override; 177 void SetBrowserControlsHeight(float height, bool shrink) override;
175 void SetBrowserControlsShownRatio(float) override; 178 void SetBrowserControlsShownRatio(float) override;
176 // TODO(ianwen): Move this method to WebLayerTreeView and implement main 179 // TODO(ianwen): Move this method to WebLayerTreeView and implement main
177 // thread scrolling. 180 // thread scrolling.
178 virtual void setBottomControlsHeight(float height); 181 virtual void setBottomControlsHeight(float height);
179 182
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
212 215
213 protected: 216 protected:
214 friend class RenderViewImplScaleFactorTest; 217 friend class RenderViewImplScaleFactorTest;
215 218
216 RenderWidgetCompositor(RenderWidgetCompositorDelegate* delegate, 219 RenderWidgetCompositor(RenderWidgetCompositorDelegate* delegate,
217 CompositorDependencies* compositor_deps); 220 CompositorDependencies* compositor_deps);
218 221
219 cc::LayerTreeHost* layer_tree_host() { return layer_tree_host_.get(); } 222 cc::LayerTreeHost* layer_tree_host() { return layer_tree_host_.get(); }
220 223
221 private: 224 private:
225 class ReportTimeSwapPromise : public cc::SwapPromise {
226 public:
227 ReportTimeSwapPromise(
228 ReportTimeCallback callback,
229 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner);
230 ~ReportTimeSwapPromise() override;
231
232 void DidActivate() override {}
233 void WillSwap(cc::CompositorFrameMetadata* metadata) override {}
234 void DidSwap() override;
235 DidNotSwapAction DidNotSwap(DidNotSwapReason reason) override;
236
237 int64_t TraceId() const override;
238
239 private:
240 ReportTimeCallback callback_;
241 scoped_refptr<base::SingleThreadTaskRunner> task_runner_;
sunnyps 2017/05/02 01:20:46 nit: DISALLOW_COPY_AND_ASSIGN(ReportTimeSwapPromis
panicker 2017/05/02 21:21:36 Done.
242 };
243
222 void SetCompositorFrameSink( 244 void SetCompositorFrameSink(
223 std::unique_ptr<cc::CompositorFrameSink> compositor_frame_sink); 245 std::unique_ptr<cc::CompositorFrameSink> compositor_frame_sink);
224 void LayoutAndUpdateLayers(); 246 void LayoutAndUpdateLayers();
225 void InvokeLayoutAndPaintCallback(); 247 void InvokeLayoutAndPaintCallback();
226 bool CompositeIsSynchronous() const; 248 bool CompositeIsSynchronous() const;
227 void SynchronouslyComposite(); 249 void SynchronouslyComposite();
228 250
229 int num_failed_recreate_attempts_; 251 int num_failed_recreate_attempts_;
230 RenderWidgetCompositorDelegate* const delegate_; 252 RenderWidgetCompositorDelegate* const delegate_;
231 CompositorDependencies* const compositor_deps_; 253 CompositorDependencies* const compositor_deps_;
232 const bool threaded_; 254 const bool threaded_;
233 std::unique_ptr<cc::AnimationHost> animation_host_; 255 std::unique_ptr<cc::AnimationHost> animation_host_;
234 std::unique_ptr<cc::LayerTreeHost> layer_tree_host_; 256 std::unique_ptr<cc::LayerTreeHost> layer_tree_host_;
235 bool never_visible_; 257 bool never_visible_;
236 bool is_for_oopif_; 258 bool is_for_oopif_;
237 259
238 blink::WebLayoutAndPaintAsyncCallback* layout_and_paint_async_callback_; 260 blink::WebLayoutAndPaintAsyncCallback* layout_and_paint_async_callback_;
239 261
240 cc::FrameSinkId frame_sink_id_; 262 cc::FrameSinkId frame_sink_id_;
241 263
242 base::WeakPtrFactory<RenderWidgetCompositor> weak_factory_; 264 base::WeakPtrFactory<RenderWidgetCompositor> weak_factory_;
243 }; 265 };
244 266
245 } // namespace content 267 } // namespace content
246 268
247 #endif // CONTENT_RENDERER_GPU_RENDER_WIDGET_COMPOSITOR_H_ 269 #endif // CONTENT_RENDERER_GPU_RENDER_WIDGET_COMPOSITOR_H_
OLDNEW
« no previous file with comments | « no previous file | content/renderer/gpu/render_widget_compositor.cc » ('j') | content/renderer/gpu/render_widget_compositor.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698