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

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

Issue 1868363002: Replace scoped_ptr with std::unique_ptr in //ui (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@scopedptrcc
Patch Set: scopedptrui: rebase-make_scoped_ptr Created 4 years, 8 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) 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 <stdint.h> 8 #include <stdint.h>
9 9
10 #include <memory>
10 #include <string> 11 #include <string>
11 12
12 #include "base/containers/hash_tables.h" 13 #include "base/containers/hash_tables.h"
13 #include "base/macros.h" 14 #include "base/macros.h"
14 #include "base/memory/ref_counted.h" 15 #include "base/memory/ref_counted.h"
15 #include "base/memory/scoped_ptr.h"
16 #include "base/observer_list.h" 16 #include "base/observer_list.h"
17 #include "base/single_thread_task_runner.h" 17 #include "base/single_thread_task_runner.h"
18 #include "base/time/time.h" 18 #include "base/time/time.h"
19 #include "cc/output/begin_frame_args.h" 19 #include "cc/output/begin_frame_args.h"
20 #include "cc/surfaces/surface_sequence.h" 20 #include "cc/surfaces/surface_sequence.h"
21 #include "cc/trees/layer_tree_host_client.h" 21 #include "cc/trees/layer_tree_host_client.h"
22 #include "cc/trees/layer_tree_host_single_thread_client.h" 22 #include "cc/trees/layer_tree_host_single_thread_client.h"
23 #include "third_party/skia/include/core/SkColor.h" 23 #include "third_party/skia/include/core/SkColor.h"
24 #include "ui/compositor/compositor_animation_observer.h" 24 #include "ui/compositor/compositor_animation_observer.h"
25 #include "ui/compositor/compositor_export.h" 25 #include "ui/compositor/compositor_export.h"
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 public: 74 public:
75 virtual ~ContextFactory() {} 75 virtual ~ContextFactory() {}
76 76
77 // Creates an output surface for the given compositor. The factory may keep 77 // Creates an output surface for the given compositor. The factory may keep
78 // per-compositor data (e.g. a shared context), that needs to be cleaned up 78 // per-compositor data (e.g. a shared context), that needs to be cleaned up
79 // by calling RemoveCompositor when the compositor gets destroyed. 79 // by calling RemoveCompositor when the compositor gets destroyed.
80 virtual void CreateOutputSurface(base::WeakPtr<Compositor> compositor) = 0; 80 virtual void CreateOutputSurface(base::WeakPtr<Compositor> compositor) = 0;
81 81
82 // Creates a reflector that copies the content of the |mirrored_compositor| 82 // Creates a reflector that copies the content of the |mirrored_compositor|
83 // onto |mirroring_layer|. 83 // onto |mirroring_layer|.
84 virtual scoped_ptr<Reflector> CreateReflector(Compositor* mirrored_compositor, 84 virtual std::unique_ptr<Reflector> CreateReflector(
85 Layer* mirroring_layer) = 0; 85 Compositor* mirrored_compositor,
86 Layer* mirroring_layer) = 0;
86 // Removes the reflector, which stops the mirroring. 87 // Removes the reflector, which stops the mirroring.
87 virtual void RemoveReflector(Reflector* reflector) = 0; 88 virtual void RemoveReflector(Reflector* reflector) = 0;
88 89
89 // Return a reference to a shared offscreen context provider usable from the 90 // Return a reference to a shared offscreen context provider usable from the
90 // main thread. 91 // main thread.
91 virtual scoped_refptr<cc::ContextProvider> 92 virtual scoped_refptr<cc::ContextProvider>
92 SharedMainThreadContextProvider() = 0; 93 SharedMainThreadContextProvider() = 0;
93 94
94 // Destroys per-compositor data. 95 // Destroys per-compositor data.
95 virtual void RemoveCompositor(Compositor* compositor) = 0; 96 virtual void RemoveCompositor(Compositor* compositor) = 0;
96 97
97 // When true, the factory uses test contexts that do not do real GL 98 // When true, the factory uses test contexts that do not do real GL
98 // operations. 99 // operations.
99 virtual bool DoesCreateTestContexts() = 0; 100 virtual bool DoesCreateTestContexts() = 0;
100 101
101 // Returns the OpenGL target to use for image textures. 102 // Returns the OpenGL target to use for image textures.
102 virtual uint32_t GetImageTextureTarget(gfx::BufferFormat format, 103 virtual uint32_t GetImageTextureTarget(gfx::BufferFormat format,
103 gfx::BufferUsage usage) = 0; 104 gfx::BufferUsage usage) = 0;
104 105
105 // Gets the shared bitmap manager for software mode. 106 // Gets the shared bitmap manager for software mode.
106 virtual cc::SharedBitmapManager* GetSharedBitmapManager() = 0; 107 virtual cc::SharedBitmapManager* GetSharedBitmapManager() = 0;
107 108
108 // Gets the GPU memory buffer manager. 109 // Gets the GPU memory buffer manager.
109 virtual gpu::GpuMemoryBufferManager* GetGpuMemoryBufferManager() = 0; 110 virtual gpu::GpuMemoryBufferManager* GetGpuMemoryBufferManager() = 0;
110 111
111 // Gets the task graph runner. 112 // Gets the task graph runner.
112 virtual cc::TaskGraphRunner* GetTaskGraphRunner() = 0; 113 virtual cc::TaskGraphRunner* GetTaskGraphRunner() = 0;
113 114
114 // Creates a Surface ID allocator with a new namespace. 115 // Creates a Surface ID allocator with a new namespace.
115 virtual scoped_ptr<cc::SurfaceIdAllocator> CreateSurfaceIdAllocator() = 0; 116 virtual std::unique_ptr<cc::SurfaceIdAllocator>
117 CreateSurfaceIdAllocator() = 0;
116 118
117 // Resize the display corresponding to this compositor to a particular size. 119 // Resize the display corresponding to this compositor to a particular size.
118 virtual void ResizeDisplay(ui::Compositor* compositor, 120 virtual void ResizeDisplay(ui::Compositor* compositor,
119 const gfx::Size& size) = 0; 121 const gfx::Size& size) = 0;
120 }; 122 };
121 123
122 // This class represents a lock on the compositor, that can be used to prevent 124 // This class represents a lock on the compositor, that can be used to prevent
123 // commits to the compositor tree while we're waiting for an asynchronous 125 // commits to the compositor tree while we're waiting for an asynchronous
124 // event. The typical use case is when waiting for a renderer to produce a frame 126 // event. The typical use case is when waiting for a renderer to produce a frame
125 // at the right size. The caller keeps a reference on this object, and drops the 127 // at the right size. The caller keeps a reference on this object, and drops the
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
160 class COMPOSITOR_EXPORT Compositor 162 class COMPOSITOR_EXPORT Compositor
161 : NON_EXPORTED_BASE(public cc::LayerTreeHostClient), 163 : NON_EXPORTED_BASE(public cc::LayerTreeHostClient),
162 NON_EXPORTED_BASE(public cc::LayerTreeHostSingleThreadClient) { 164 NON_EXPORTED_BASE(public cc::LayerTreeHostSingleThreadClient) {
163 public: 165 public:
164 Compositor(ui::ContextFactory* context_factory, 166 Compositor(ui::ContextFactory* context_factory,
165 scoped_refptr<base::SingleThreadTaskRunner> task_runner); 167 scoped_refptr<base::SingleThreadTaskRunner> task_runner);
166 ~Compositor() override; 168 ~Compositor() override;
167 169
168 ui::ContextFactory* context_factory() { return context_factory_; } 170 ui::ContextFactory* context_factory() { return context_factory_; }
169 171
170 void SetOutputSurface(scoped_ptr<cc::OutputSurface> surface); 172 void SetOutputSurface(std::unique_ptr<cc::OutputSurface> surface);
171 173
172 // Schedules a redraw of the layer tree associated with this compositor. 174 // Schedules a redraw of the layer tree associated with this compositor.
173 void ScheduleDraw(); 175 void ScheduleDraw();
174 176
175 // Sets the root of the layer tree drawn by this Compositor. The root layer 177 // Sets the root of the layer tree drawn by this Compositor. The root layer
176 // must have no parent. The compositor's root layer is reset if the root layer 178 // must have no parent. The compositor's root layer is reset if the root layer
177 // is destroyed. NULL can be passed to reset the root layer, in which case the 179 // is destroyed. NULL can be passed to reset the root layer, in which case the
178 // compositor will stop drawing anything. 180 // compositor will stop drawing anything.
179 // The Compositor does not own the root layer. 181 // The Compositor does not own the root layer.
180 const Layer* root_layer() const { return root_layer_; } 182 const Layer* root_layer() const { return root_layer_; }
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
301 void RequestNewOutputSurface() override; 303 void RequestNewOutputSurface() override;
302 void DidInitializeOutputSurface() override; 304 void DidInitializeOutputSurface() override;
303 void DidFailToInitializeOutputSurface() override; 305 void DidFailToInitializeOutputSurface() override;
304 void WillCommit() override {} 306 void WillCommit() override {}
305 void DidCommit() override; 307 void DidCommit() override;
306 void DidCommitAndDrawFrame() override; 308 void DidCommitAndDrawFrame() override;
307 void DidCompleteSwapBuffers() override; 309 void DidCompleteSwapBuffers() override;
308 void DidCompletePageScaleAnimation() override {} 310 void DidCompletePageScaleAnimation() override {}
309 void SendBeginFramesToChildren(const cc::BeginFrameArgs& args) override; 311 void SendBeginFramesToChildren(const cc::BeginFrameArgs& args) override;
310 void RecordFrameTimingEvents( 312 void RecordFrameTimingEvents(
311 scoped_ptr<cc::FrameTimingTracker::CompositeTimingSet> composite_events, 313 std::unique_ptr<cc::FrameTimingTracker::CompositeTimingSet>
312 scoped_ptr<cc::FrameTimingTracker::MainFrameTimingSet> main_frame_events) 314 composite_events,
313 override {} 315 std::unique_ptr<cc::FrameTimingTracker::MainFrameTimingSet>
316 main_frame_events) override {}
314 317
315 // cc::LayerTreeHostSingleThreadClient implementation. 318 // cc::LayerTreeHostSingleThreadClient implementation.
316 void DidPostSwapBuffers() override; 319 void DidPostSwapBuffers() override;
317 void DidAbortSwapBuffers() override; 320 void DidAbortSwapBuffers() override;
318 321
319 bool IsLocked() { return compositor_lock_ != NULL; } 322 bool IsLocked() { return compositor_lock_ != NULL; }
320 323
321 void SetOutputIsSecure(bool output_is_secure); 324 void SetOutputIsSecure(bool output_is_secure);
322 325
323 const cc::LayerTreeDebugState& GetLayerTreeDebugState() const; 326 const cc::LayerTreeDebugState& GetLayerTreeDebugState() const;
(...skipping 26 matching lines...) Expand all
350 Layer* root_layer_; 353 Layer* root_layer_;
351 354
352 base::ObserverList<CompositorObserver, true> observer_list_; 355 base::ObserverList<CompositorObserver, true> observer_list_;
353 base::ObserverList<CompositorAnimationObserver> animation_observer_list_; 356 base::ObserverList<CompositorAnimationObserver> animation_observer_list_;
354 base::ObserverList<CompositorBeginFrameObserver, true> 357 base::ObserverList<CompositorBeginFrameObserver, true>
355 begin_frame_observer_list_; 358 begin_frame_observer_list_;
356 359
357 gfx::AcceleratedWidget widget_; 360 gfx::AcceleratedWidget widget_;
358 bool widget_valid_; 361 bool widget_valid_;
359 bool output_surface_requested_; 362 bool output_surface_requested_;
360 scoped_ptr<cc::SurfaceIdAllocator> surface_id_allocator_; 363 std::unique_ptr<cc::SurfaceIdAllocator> surface_id_allocator_;
361 scoped_refptr<cc::Layer> root_web_layer_; 364 scoped_refptr<cc::Layer> root_web_layer_;
362 scoped_ptr<cc::LayerTreeHost> host_; 365 std::unique_ptr<cc::LayerTreeHost> host_;
363 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; 366 scoped_refptr<base::SingleThreadTaskRunner> task_runner_;
364 367
365 // The manager of vsync parameters for this compositor. 368 // The manager of vsync parameters for this compositor.
366 scoped_refptr<CompositorVSyncManager> vsync_manager_; 369 scoped_refptr<CompositorVSyncManager> vsync_manager_;
367 370
368 // The device scale factor of the monitor that this compositor is compositing 371 // The device scale factor of the monitor that this compositor is compositing
369 // layers on. 372 // layers on.
370 float device_scale_factor_; 373 float device_scale_factor_;
371 374
372 int last_started_frame_; 375 int last_started_frame_;
373 int last_ended_frame_; 376 int last_ended_frame_;
374 377
375 bool locks_will_time_out_; 378 bool locks_will_time_out_;
376 CompositorLock* compositor_lock_; 379 CompositorLock* compositor_lock_;
377 380
378 LayerAnimatorCollection layer_animator_collection_; 381 LayerAnimatorCollection layer_animator_collection_;
379 scoped_refptr<cc::AnimationTimeline> animation_timeline_; 382 scoped_refptr<cc::AnimationTimeline> animation_timeline_;
380 383
381 // Used to send to any new CompositorBeginFrameObserver immediately. 384 // Used to send to any new CompositorBeginFrameObserver immediately.
382 cc::BeginFrameArgs missed_begin_frame_args_; 385 cc::BeginFrameArgs missed_begin_frame_args_;
383 386
384 base::WeakPtrFactory<Compositor> weak_ptr_factory_; 387 base::WeakPtrFactory<Compositor> weak_ptr_factory_;
385 388
386 DISALLOW_COPY_AND_ASSIGN(Compositor); 389 DISALLOW_COPY_AND_ASSIGN(Compositor);
387 }; 390 };
388 391
389 } // namespace ui 392 } // namespace ui
390 393
391 #endif // UI_COMPOSITOR_COMPOSITOR_H_ 394 #endif // UI_COMPOSITOR_COMPOSITOR_H_
OLDNEW
« no previous file with comments | « ui/compositor/callback_layer_animation_observer_unittest.cc ('k') | ui/compositor/compositor.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698