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

Side by Side Diff: ui/compositor/compositor.h

Issue 138903025: Read compositor VSync information from platform, when possible (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: 287efe04 Rebase, oshima@ nits. Created 6 years, 10 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 | Annotate | Revision Log
« no previous file with comments | « ui/aura/bench/bench_main.cc ('k') | ui/compositor/compositor.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 UI_COMPOSITOR_COMPOSITOR_H_ 5 #ifndef UI_COMPOSITOR_COMPOSITOR_H_
6 #define UI_COMPOSITOR_COMPOSITOR_H_ 6 #define UI_COMPOSITOR_COMPOSITOR_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "base/containers/hash_tables.h" 10 #include "base/containers/hash_tables.h"
(...skipping 25 matching lines...) Expand all
36 } 36 }
37 37
38 namespace gfx { 38 namespace gfx {
39 class Rect; 39 class Rect;
40 class Size; 40 class Size;
41 } 41 }
42 42
43 namespace ui { 43 namespace ui {
44 44
45 class Compositor; 45 class Compositor;
46 class CompositorVSyncManager;
46 class Layer; 47 class Layer;
47 class PostedSwapQueue; 48 class PostedSwapQueue;
48 class Reflector; 49 class Reflector;
49 class Texture; 50 class Texture;
50 struct LatencyInfo; 51 struct LatencyInfo;
51 52
52 // This class abstracts the creation of the 3D context for the compositor. It is 53 // This class abstracts the creation of the 3D context for the compositor. It is
53 // a global object. 54 // a global object.
54 class COMPOSITOR_EXPORT ContextFactory { 55 class COMPOSITOR_EXPORT ContextFactory {
55 public: 56 public:
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
156 DISALLOW_COPY_AND_ASSIGN(CompositorLock); 157 DISALLOW_COPY_AND_ASSIGN(CompositorLock);
157 }; 158 };
158 159
159 // Compositor object to take care of GPU painting. 160 // Compositor object to take care of GPU painting.
160 // A Browser compositor object is responsible for generating the final 161 // A Browser compositor object is responsible for generating the final
161 // displayable form of pixels comprising a single widget's contents. It draws an 162 // displayable form of pixels comprising a single widget's contents. It draws an
162 // appropriately transformed texture for each transformed view in the widget's 163 // appropriately transformed texture for each transformed view in the widget's
163 // view hierarchy. 164 // view hierarchy.
164 class COMPOSITOR_EXPORT Compositor 165 class COMPOSITOR_EXPORT Compositor
165 : NON_EXPORTED_BASE(public cc::LayerTreeHostClient), 166 : NON_EXPORTED_BASE(public cc::LayerTreeHostClient),
166 NON_EXPORTED_BASE(public cc::LayerTreeHostSingleThreadClient), 167 NON_EXPORTED_BASE(public cc::LayerTreeHostSingleThreadClient) {
167 public base::SupportsWeakPtr<Compositor> {
168 public: 168 public:
169 explicit Compositor(gfx::AcceleratedWidget widget); 169 explicit Compositor(gfx::AcceleratedWidget widget);
170 virtual ~Compositor(); 170 virtual ~Compositor();
171 171
172 static void Initialize(); 172 static void Initialize();
173 static bool WasInitializedWithThread(); 173 static bool WasInitializedWithThread();
174 static scoped_refptr<base::MessageLoopProxy> GetCompositorMessageLoop(); 174 static scoped_refptr<base::MessageLoopProxy> GetCompositorMessageLoop();
175 static void Terminate(); 175 static void Terminate();
176 176
177 // Schedules a redraw of the layer tree associated with this compositor. 177 // Schedules a redraw of the layer tree associated with this compositor.
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
215 // Returns the size of the widget that is being drawn to in pixel coordinates. 215 // Returns the size of the widget that is being drawn to in pixel coordinates.
216 const gfx::Size& size() const { return size_; } 216 const gfx::Size& size() const { return size_; }
217 217
218 // Sets the background color used for areas that aren't covered by 218 // Sets the background color used for areas that aren't covered by
219 // the |root_layer|. 219 // the |root_layer|.
220 void SetBackgroundColor(SkColor color); 220 void SetBackgroundColor(SkColor color);
221 221
222 // Returns the widget for this compositor. 222 // Returns the widget for this compositor.
223 gfx::AcceleratedWidget widget() const { return widget_; } 223 gfx::AcceleratedWidget widget() const { return widget_; }
224 224
225 // Returns the vsync manager for this compositor.
226 scoped_refptr<CompositorVSyncManager> vsync_manager() const;
227
225 // Compositor does not own observers. It is the responsibility of the 228 // Compositor does not own observers. It is the responsibility of the
226 // observer to remove itself when it is done observing. 229 // observer to remove itself when it is done observing.
227 void AddObserver(CompositorObserver* observer); 230 void AddObserver(CompositorObserver* observer);
228 void RemoveObserver(CompositorObserver* observer); 231 void RemoveObserver(CompositorObserver* observer);
229 bool HasObserver(CompositorObserver* observer); 232 bool HasObserver(CompositorObserver* observer);
230 233
231 // Creates a compositor lock. Returns NULL if it is not possible to lock at 234 // Creates a compositor lock. Returns NULL if it is not possible to lock at
232 // this time (i.e. we're waiting to complete a previous unlock). 235 // this time (i.e. we're waiting to complete a previous unlock).
233 scoped_refptr<CompositorLock> GetCompositorLock(); 236 scoped_refptr<CompositorLock> GetCompositorLock();
234 237
235 // Internal functions, called back by command-buffer contexts on swap buffer 238 // Internal functions, called back by command-buffer contexts on swap buffer
236 // events. 239 // events.
237 240
238 // Signals swap has been posted. 241 // Signals swap has been posted.
239 void OnSwapBuffersPosted(); 242 void OnSwapBuffersPosted();
240 243
241 // Signals swap has completed. 244 // Signals swap has completed.
242 void OnSwapBuffersComplete(); 245 void OnSwapBuffersComplete();
243 246
244 // Signals swap has aborted (e.g. lost context). 247 // Signals swap has aborted (e.g. lost context).
245 void OnSwapBuffersAborted(); 248 void OnSwapBuffersAborted();
246 249
247 void OnUpdateVSyncParameters(base::TimeTicks timebase,
248 base::TimeDelta interval);
249
250 // LayerTreeHostClient implementation. 250 // LayerTreeHostClient implementation.
251 virtual void WillBeginMainFrame(int frame_id) OVERRIDE {} 251 virtual void WillBeginMainFrame(int frame_id) OVERRIDE {}
252 virtual void DidBeginMainFrame() OVERRIDE {} 252 virtual void DidBeginMainFrame() OVERRIDE {}
253 virtual void Animate(base::TimeTicks frame_begin_time) OVERRIDE {} 253 virtual void Animate(base::TimeTicks frame_begin_time) OVERRIDE {}
254 virtual void Layout() OVERRIDE; 254 virtual void Layout() OVERRIDE;
255 virtual void ApplyScrollAndScale(const gfx::Vector2d& scroll_delta, 255 virtual void ApplyScrollAndScale(const gfx::Vector2d& scroll_delta,
256 float page_scale) OVERRIDE {} 256 float page_scale) OVERRIDE {}
257 virtual scoped_ptr<cc::OutputSurface> CreateOutputSurface(bool fallback) 257 virtual scoped_ptr<cc::OutputSurface> CreateOutputSurface(bool fallback)
258 OVERRIDE; 258 OVERRIDE;
259 virtual void DidInitializeOutputSurface(bool success) OVERRIDE {} 259 virtual void DidInitializeOutputSurface(bool success) OVERRIDE {}
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
295 295
296 // The root of the Layer tree drawn by this compositor. 296 // The root of the Layer tree drawn by this compositor.
297 Layer* root_layer_; 297 Layer* root_layer_;
298 298
299 ObserverList<CompositorObserver> observer_list_; 299 ObserverList<CompositorObserver> observer_list_;
300 300
301 gfx::AcceleratedWidget widget_; 301 gfx::AcceleratedWidget widget_;
302 scoped_refptr<cc::Layer> root_web_layer_; 302 scoped_refptr<cc::Layer> root_web_layer_;
303 scoped_ptr<cc::LayerTreeHost> host_; 303 scoped_ptr<cc::LayerTreeHost> host_;
304 304
305 // The manager of vsync parameters for this compositor.
306 scoped_refptr<CompositorVSyncManager> vsync_manager_;
307
305 // Used to verify that we have at most one draw swap in flight. 308 // Used to verify that we have at most one draw swap in flight.
306 scoped_ptr<PostedSwapQueue> posted_swaps_; 309 scoped_ptr<PostedSwapQueue> posted_swaps_;
307 310
308 // The device scale factor of the monitor that this compositor is compositing 311 // The device scale factor of the monitor that this compositor is compositing
309 // layers on. 312 // layers on.
310 float device_scale_factor_; 313 float device_scale_factor_;
311 314
312 int last_started_frame_; 315 int last_started_frame_;
313 int last_ended_frame_; 316 int last_ended_frame_;
314 317
(...skipping 11 matching lines...) Expand all
326 bool draw_on_compositing_end_; 329 bool draw_on_compositing_end_;
327 330
328 base::WeakPtrFactory<Compositor> schedule_draw_factory_; 331 base::WeakPtrFactory<Compositor> schedule_draw_factory_;
329 332
330 DISALLOW_COPY_AND_ASSIGN(Compositor); 333 DISALLOW_COPY_AND_ASSIGN(Compositor);
331 }; 334 };
332 335
333 } // namespace ui 336 } // namespace ui
334 337
335 #endif // UI_COMPOSITOR_COMPOSITOR_H_ 338 #endif // UI_COMPOSITOR_COMPOSITOR_H_
OLDNEW
« no previous file with comments | « ui/aura/bench/bench_main.cc ('k') | ui/compositor/compositor.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698