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

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

Issue 2083853002: exo: Recreate Surface resources on context lost. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix browser test Created 4 years, 6 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 <memory>
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 62
63 class Compositor; 63 class Compositor;
64 class CompositorVSyncManager; 64 class CompositorVSyncManager;
65 class LatencyInfo; 65 class LatencyInfo;
66 class Layer; 66 class Layer;
67 class Reflector; 67 class Reflector;
68 class Texture; 68 class Texture;
69 69
70 const int kCompositorLockTimeoutMs = 67; 70 const int kCompositorLockTimeoutMs = 67;
71 71
72 class COMPOSITOR_EXPORT ContextFactoryObserver {
73 public:
74 virtual ~ContextFactoryObserver() {}
75
76 // Notifies that the ContextProvider returned from
77 // ui::ContextFactory::SharedMainThreadContextProvider was lost. When this
78 // is called, the old resources (e.g. shared context, GL helper) still
79 // exist, but are about to be destroyed. Getting a reference to those
80 // resources from the ContextFactory (e.g. through
81 // SharedMainThreadContextProvider()) will return newly recreated, valid
82 // resources.
83 virtual void OnLostResources() = 0;
84 };
85
72 // This class abstracts the creation of the 3D context for the compositor. It is 86 // This class abstracts the creation of the 3D context for the compositor. It is
73 // a global object. 87 // a global object.
74 class COMPOSITOR_EXPORT ContextFactory { 88 class COMPOSITOR_EXPORT ContextFactory {
75 public: 89 public:
76 virtual ~ContextFactory() {} 90 virtual ~ContextFactory();
77 91
78 // Creates an output surface for the given compositor. The factory may keep 92 // Creates an output surface for the given compositor. The factory may keep
79 // per-compositor data (e.g. a shared context), that needs to be cleaned up 93 // per-compositor data (e.g. a shared context), that needs to be cleaned up
80 // by calling RemoveCompositor when the compositor gets destroyed. 94 // by calling RemoveCompositor when the compositor gets destroyed.
81 virtual void CreateOutputSurface(base::WeakPtr<Compositor> compositor) = 0; 95 virtual void CreateOutputSurface(base::WeakPtr<Compositor> compositor) = 0;
82 96
83 // Creates a reflector that copies the content of the |mirrored_compositor| 97 // Creates a reflector that copies the content of the |mirrored_compositor|
84 // onto |mirroring_layer|. 98 // onto |mirroring_layer|.
85 virtual std::unique_ptr<Reflector> CreateReflector( 99 virtual std::unique_ptr<Reflector> CreateReflector(
86 Compositor* mirrored_compositor, 100 Compositor* mirrored_compositor,
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
121 virtual cc::SurfaceManager* GetSurfaceManager() = 0; 135 virtual cc::SurfaceManager* GetSurfaceManager() = 0;
122 136
123 // Resize the display corresponding to this compositor to a particular size. 137 // Resize the display corresponding to this compositor to a particular size.
124 virtual void ResizeDisplay(ui::Compositor* compositor, 138 virtual void ResizeDisplay(ui::Compositor* compositor,
125 const gfx::Size& size) = 0; 139 const gfx::Size& size) = 0;
126 140
127 virtual void SetAuthoritativeVSyncInterval(ui::Compositor* compositor, 141 virtual void SetAuthoritativeVSyncInterval(ui::Compositor* compositor,
128 base::TimeDelta interval) = 0; 142 base::TimeDelta interval) = 0;
129 143
130 virtual void SetOutputIsSecure(Compositor* compositor, bool secure) = 0; 144 virtual void SetOutputIsSecure(Compositor* compositor, bool secure) = 0;
145
146 void AddObserver(ContextFactoryObserver* observer);
147
148 void RemoveObserver(ContextFactoryObserver* observer);
149
150 protected:
151 ContextFactory();
152 base::ObserverList<ContextFactoryObserver> observer_list_;
piman 2016/06/21 01:14:13 Can we keep this class pure virtual? I realize you
131 }; 153 };
132 154
133 // This class represents a lock on the compositor, that can be used to prevent 155 // This class represents a lock on the compositor, that can be used to prevent
134 // commits to the compositor tree while we're waiting for an asynchronous 156 // commits to the compositor tree while we're waiting for an asynchronous
135 // event. The typical use case is when waiting for a renderer to produce a frame 157 // event. The typical use case is when waiting for a renderer to produce a frame
136 // at the right size. The caller keeps a reference on this object, and drops the 158 // at the right size. The caller keeps a reference on this object, and drops the
137 // reference once it desires to release the lock. 159 // reference once it desires to release the lock.
138 // By default, the lock will be cancelled after a short timeout to ensure 160 // By default, the lock will be cancelled after a short timeout to ensure
139 // responsiveness of the UI, so the compositor tree should be kept in a 161 // responsiveness of the UI, so the compositor tree should be kept in a
140 // "reasonable" state while the lock is held. If the compositor sets 162 // "reasonable" state while the lock is held. If the compositor sets
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after
376 scoped_refptr<cc::AnimationTimeline> animation_timeline_; 398 scoped_refptr<cc::AnimationTimeline> animation_timeline_;
377 399
378 base::WeakPtrFactory<Compositor> weak_ptr_factory_; 400 base::WeakPtrFactory<Compositor> weak_ptr_factory_;
379 401
380 DISALLOW_COPY_AND_ASSIGN(Compositor); 402 DISALLOW_COPY_AND_ASSIGN(Compositor);
381 }; 403 };
382 404
383 } // namespace ui 405 } // namespace ui
384 406
385 #endif // UI_COMPOSITOR_COMPOSITOR_H_ 407 #endif // UI_COMPOSITOR_COMPOSITOR_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698