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

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

Issue 10690168: Aura: Resize locks with --ui-enable-threaded-compositing (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: OSX compile fix. Created 8 years, 1 month 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/root_window.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 "base/hash_tables.h" 8 #include "base/hash_tables.h"
9 #include "base/memory/ref_counted.h" 9 #include "base/memory/ref_counted.h"
10 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
119 // An interface to allow the compositor to communicate with its owner. 119 // An interface to allow the compositor to communicate with its owner.
120 class COMPOSITOR_EXPORT CompositorDelegate { 120 class COMPOSITOR_EXPORT CompositorDelegate {
121 public: 121 public:
122 // Requests the owner to schedule a redraw of the layer tree. 122 // Requests the owner to schedule a redraw of the layer tree.
123 virtual void ScheduleDraw() = 0; 123 virtual void ScheduleDraw() = 0;
124 124
125 protected: 125 protected:
126 virtual ~CompositorDelegate() {} 126 virtual ~CompositorDelegate() {}
127 }; 127 };
128 128
129 // This class represents a lock on the compositor, that can be used to prevent
130 // commits to the compositor tree while we're waiting for an asynchronous
131 // event. The typical use case is when waiting for a renderer to produce a frame
132 // at the right size. The caller keeps a reference on this object, and drops the
133 // reference once it desires to release the lock.
134 // Note however that the lock is cancelled after a short timeout to ensure
135 // responsiveness of the UI, so the compositor tree should be kept in a
136 // "reasonable" state while the lock is held.
137 // Don't instantiate this class directly, use Compositor::GetCompositorLock.
138 class COMPOSITOR_EXPORT CompositorLock
139 : public base::RefCounted<CompositorLock>,
140 public base::SupportsWeakPtr<CompositorLock> {
141 private:
142 friend class base::RefCounted<CompositorLock>;
143 friend class Compositor;
144
145 explicit CompositorLock(Compositor* compositor);
146 ~CompositorLock();
147
148 void CancelLock();
149
150 Compositor* compositor_;
151 DISALLOW_COPY_AND_ASSIGN(CompositorLock);
152 };
153
154
129 // Compositor object to take care of GPU painting. 155 // Compositor object to take care of GPU painting.
130 // A Browser compositor object is responsible for generating the final 156 // A Browser compositor object is responsible for generating the final
131 // displayable form of pixels comprising a single widget's contents. It draws an 157 // displayable form of pixels comprising a single widget's contents. It draws an
132 // appropriately transformed texture for each transformed view in the widget's 158 // appropriately transformed texture for each transformed view in the widget's
133 // view hierarchy. 159 // view hierarchy.
134 class COMPOSITOR_EXPORT Compositor 160 class COMPOSITOR_EXPORT Compositor
135 : NON_EXPORTED_BASE(public WebKit::WebLayerTreeViewClient) { 161 : NON_EXPORTED_BASE(public WebKit::WebLayerTreeViewClient) {
136 public: 162 public:
137 Compositor(CompositorDelegate* delegate, 163 Compositor(CompositorDelegate* delegate,
138 gfx::AcceleratedWidget widget); 164 gfx::AcceleratedWidget widget);
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
189 // Compositor does not own observers. It is the responsibility of the 215 // Compositor does not own observers. It is the responsibility of the
190 // observer to remove itself when it is done observing. 216 // observer to remove itself when it is done observing.
191 void AddObserver(CompositorObserver* observer); 217 void AddObserver(CompositorObserver* observer);
192 void RemoveObserver(CompositorObserver* observer); 218 void RemoveObserver(CompositorObserver* observer);
193 bool HasObserver(CompositorObserver* observer); 219 bool HasObserver(CompositorObserver* observer);
194 220
195 // Returns whether a draw is pending, that is, if we're between the Draw call 221 // Returns whether a draw is pending, that is, if we're between the Draw call
196 // and the OnCompositingEnded. 222 // and the OnCompositingEnded.
197 bool DrawPending() const { return swap_posted_; } 223 bool DrawPending() const { return swap_posted_; }
198 224
199 // Returns whether the drawing is issued from a separate thread 225 // Creates a compositor lock. Returns NULL if it is not possible to lock at
200 // (i.e. |Compositor::Initialize(true)| was called). 226 // this time (i.e. we're waiting to complete a previous unlock).
201 bool IsThreaded() const; 227 scoped_refptr<CompositorLock> GetCompositorLock();
202 228
203 // Internal functions, called back by command-buffer contexts on swap buffer 229 // Internal functions, called back by command-buffer contexts on swap buffer
204 // events. 230 // events.
205 231
206 // Signals swap has been posted. 232 // Signals swap has been posted.
207 void OnSwapBuffersPosted(); 233 void OnSwapBuffersPosted();
208 234
209 // Signals swap has completed. 235 // Signals swap has completed.
210 void OnSwapBuffersComplete(); 236 void OnSwapBuffersComplete();
211 237
212 // Signals swap has aborted (e.g. lost context). 238 // Signals swap has aborted (e.g. lost context).
213 void OnSwapBuffersAborted(); 239 void OnSwapBuffersAborted();
214 240
215 // WebLayerTreeViewClient implementation. 241 // WebLayerTreeViewClient implementation.
216 virtual void updateAnimations(double frameBeginTime); 242 virtual void updateAnimations(double frameBeginTime);
217 virtual void layout(); 243 virtual void layout();
218 virtual void applyScrollAndScale(const WebKit::WebSize& scrollDelta, 244 virtual void applyScrollAndScale(const WebKit::WebSize& scrollDelta,
219 float scaleFactor); 245 float scaleFactor);
220 virtual WebKit::WebCompositorOutputSurface* createOutputSurface(); 246 virtual WebKit::WebCompositorOutputSurface* createOutputSurface();
221 virtual void didRecreateOutputSurface(bool success); 247 virtual void didRecreateOutputSurface(bool success);
222 virtual void didCommit(); 248 virtual void didCommit();
223 virtual void didCommitAndDrawFrame(); 249 virtual void didCommitAndDrawFrame();
224 virtual void didCompleteSwapBuffers(); 250 virtual void didCompleteSwapBuffers();
225 virtual void scheduleComposite(); 251 virtual void scheduleComposite();
226 252
227 int last_started_frame() { return last_started_frame_; } 253 int last_started_frame() { return last_started_frame_; }
228 int last_ended_frame() { return last_ended_frame_; } 254 int last_ended_frame() { return last_ended_frame_; }
229 255
256 bool IsLocked() { return compositor_lock_ != NULL; }
257
230 private: 258 private:
231 friend class base::RefCounted<Compositor>; 259 friend class base::RefCounted<Compositor>;
260 friend class CompositorLock;
261
262 // Called by CompositorLock.
263 void UnlockCompositor();
264
265 // Called to release any pending CompositorLock
266 void CancelCompositorLock();
232 267
233 // Notifies the compositor that compositing is complete. 268 // Notifies the compositor that compositing is complete.
234 void NotifyEnd(); 269 void NotifyEnd();
235 270
236 CompositorDelegate* delegate_; 271 CompositorDelegate* delegate_;
237 gfx::Size size_; 272 gfx::Size size_;
238 273
239 // The root of the Layer tree drawn by this compositor. 274 // The root of the Layer tree drawn by this compositor.
240 Layer* root_layer_; 275 Layer* root_layer_;
241 276
242 ObserverList<CompositorObserver> observer_list_; 277 ObserverList<CompositorObserver> observer_list_;
243 278
244 gfx::AcceleratedWidget widget_; 279 gfx::AcceleratedWidget widget_;
245 scoped_ptr<WebKit::WebLayer> root_web_layer_; 280 scoped_ptr<WebKit::WebLayer> root_web_layer_;
246 scoped_ptr<WebKit::WebLayerTreeView> host_; 281 scoped_ptr<WebKit::WebLayerTreeView> host_;
247 282
248 // This is set to true when the swap buffers has been posted and we're waiting 283 // This is set to true when the swap buffers has been posted and we're waiting
249 // for completion. 284 // for completion.
250 bool swap_posted_; 285 bool swap_posted_;
251 286
252 // The device scale factor of the monitor that this compositor is compositing 287 // The device scale factor of the monitor that this compositor is compositing
253 // layers on. 288 // layers on.
254 float device_scale_factor_; 289 float device_scale_factor_;
255 290
256 int last_started_frame_; 291 int last_started_frame_;
257 int last_ended_frame_; 292 int last_ended_frame_;
258 293
259 bool disable_schedule_composite_; 294 bool disable_schedule_composite_;
260 295
296 CompositorLock* compositor_lock_;
297
261 DISALLOW_COPY_AND_ASSIGN(Compositor); 298 DISALLOW_COPY_AND_ASSIGN(Compositor);
262 }; 299 };
263 300
264 } // namespace ui 301 } // namespace ui
265 302
266 #endif // UI_COMPOSITOR_COMPOSITOR_H_ 303 #endif // UI_COMPOSITOR_COMPOSITOR_H_
OLDNEW
« no previous file with comments | « ui/aura/root_window.cc ('k') | ui/compositor/compositor.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698