OLD | NEW |
---|---|
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 CONTENT_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_VIEW_AURA_H_ | 5 #ifndef CONTENT_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_VIEW_AURA_H_ |
6 #define CONTENT_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_VIEW_AURA_H_ | 6 #define CONTENT_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_VIEW_AURA_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
11 #include "base/callback.h" | 11 #include "base/callback.h" |
12 #include "base/memory/linked_ptr.h" | 12 #include "base/memory/linked_ptr.h" |
13 #include "base/memory/ref_counted.h" | 13 #include "base/memory/ref_counted.h" |
14 #include "base/memory/weak_ptr.h" | 14 #include "base/memory/weak_ptr.h" |
15 #include "content/browser/renderer_host/image_transport_factory.h" | 15 #include "content/browser/renderer_host/image_transport_factory.h" |
16 #include "content/browser/renderer_host/render_widget_host_view_base.h" | 16 #include "content/browser/renderer_host/render_widget_host_view_base.h" |
17 #include "content/common/content_export.h" | 17 #include "content/common/content_export.h" |
18 #include "ui/aura/client/activation_delegate.h" | 18 #include "ui/aura/client/activation_delegate.h" |
19 #include "ui/aura/window_delegate.h" | 19 #include "ui/aura/window_delegate.h" |
20 #include "ui/base/ime/text_input_client.h" | 20 #include "ui/base/ime/text_input_client.h" |
21 #include "ui/compositor/compositor_observer.h" | 21 #include "ui/compositor/compositor_observer.h" |
22 #include "ui/gfx/rect.h" | 22 #include "ui/gfx/rect.h" |
23 #include "webkit/glue/webcursor.h" | 23 #include "webkit/glue/webcursor.h" |
24 | 24 |
25 namespace aura { | 25 namespace aura { |
26 class CompositorLock; | |
27 class WindowTracker; | 26 class WindowTracker; |
28 } | 27 } |
29 | 28 |
30 namespace gfx { | 29 namespace gfx { |
31 class Canvas; | 30 class Canvas; |
32 } | 31 } |
33 | 32 |
34 namespace ui { | 33 namespace ui { |
34 class CompositorLock; | |
35 class InputMethod; | 35 class InputMethod; |
36 class Texture; | 36 class Texture; |
37 } | 37 } |
38 | 38 |
39 namespace WebKit { | 39 namespace WebKit { |
40 class WebTouchEvent; | 40 class WebTouchEvent; |
41 } | 41 } |
42 | 42 |
43 namespace content { | 43 namespace content { |
44 class RenderWidgetHostImpl; | 44 class RenderWidgetHostImpl; |
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
199 | 199 |
200 // Should construct only via RenderWidgetHostView::CreateViewForWidget. | 200 // Should construct only via RenderWidgetHostView::CreateViewForWidget. |
201 explicit RenderWidgetHostViewAura(RenderWidgetHost* host); | 201 explicit RenderWidgetHostViewAura(RenderWidgetHost* host); |
202 | 202 |
203 private: | 203 private: |
204 class WindowObserver; | 204 class WindowObserver; |
205 friend class WindowObserver; | 205 friend class WindowObserver; |
206 | 206 |
207 // Overridden from ui::CompositorObserver: | 207 // Overridden from ui::CompositorObserver: |
208 virtual void OnCompositingDidCommit(ui::Compositor* compositor) OVERRIDE; | 208 virtual void OnCompositingDidCommit(ui::Compositor* compositor) OVERRIDE; |
209 virtual void OnCompositingWillStart(ui::Compositor* compositor) OVERRIDE; | |
210 virtual void OnCompositingStarted(ui::Compositor* compositor) OVERRIDE; | 209 virtual void OnCompositingStarted(ui::Compositor* compositor) OVERRIDE; |
211 virtual void OnCompositingEnded(ui::Compositor* compositor) OVERRIDE; | 210 virtual void OnCompositingEnded(ui::Compositor* compositor) OVERRIDE; |
212 virtual void OnCompositingAborted(ui::Compositor* compositor) OVERRIDE; | 211 virtual void OnCompositingAborted(ui::Compositor* compositor) OVERRIDE; |
212 virtual void OnCompositingLockStateChanged( | |
213 ui::Compositor* compositor) OVERRIDE; | |
213 | 214 |
214 // Overridden from ImageTransportFactoryObserver: | 215 // Overridden from ImageTransportFactoryObserver: |
215 virtual void OnLostResources() OVERRIDE; | 216 virtual void OnLostResources() OVERRIDE; |
216 | 217 |
217 virtual ~RenderWidgetHostViewAura(); | 218 virtual ~RenderWidgetHostViewAura(); |
218 | 219 |
219 void UpdateCursorIfOverSelf(); | 220 void UpdateCursorIfOverSelf(); |
221 bool ShouldFastACK(uint64 surface_id); | |
220 void UpdateExternalTexture(); | 222 void UpdateExternalTexture(); |
221 ui::InputMethod* GetInputMethod() const; | 223 ui::InputMethod* GetInputMethod() const; |
222 | 224 |
223 // Returns whether the widget needs an input grab to work properly. | 225 // Returns whether the widget needs an input grab to work properly. |
224 bool NeedsInputGrab(); | 226 bool NeedsInputGrab(); |
225 | 227 |
226 // Confirm existing composition text in the webpage and ask the input method | 228 // Confirm existing composition text in the webpage and ask the input method |
227 // to cancel its ongoing composition session. | 229 // to cancel its ongoing composition session. |
228 void FinishImeCompositionSession(); | 230 void FinishImeCompositionSession(); |
229 | 231 |
230 // This method computes movementX/Y and keeps track of mouse location for | 232 // This method computes movementX/Y and keeps track of mouse location for |
231 // mouse lock on all mouse move events. | 233 // mouse lock on all mouse move events. |
232 void ModifyEventMovementAndCoords(WebKit::WebMouseEvent* event); | 234 void ModifyEventMovementAndCoords(WebKit::WebMouseEvent* event); |
233 | 235 |
234 // If |clip| is non-empty and and doesn't contain |rect| or |clip| is empty | 236 // If |clip| is non-empty and and doesn't contain |rect| or |clip| is empty |
235 // SchedulePaint() is invoked for |rect|. | 237 // SchedulePaint() is invoked for |rect|. |
236 void SchedulePaintIfNotInClip(const gfx::Rect& rect, const gfx::Rect& clip); | 238 void SchedulePaintIfNotInClip(const gfx::Rect& rect, const gfx::Rect& clip); |
237 | 239 |
238 // Helper method to determine if, in mouse locked mode, the cursor should be | 240 // Helper method to determine if, in mouse locked mode, the cursor should be |
239 // moved to center. | 241 // moved to center. |
240 bool ShouldMoveToCenter(); | 242 bool ShouldMoveToCenter(); |
241 | 243 |
242 // Run the compositing callbacks. | 244 // Run the compositing callbacks. |
243 void RunCompositingDidCommitCallbacks(ui::Compositor* compositor); | 245 void RunCompositingDidCommitCallbacks(ui::Compositor* compositor); |
244 void RunCompositingWillStartCallbacks(ui::Compositor* compositor); | |
245 | 246 |
246 // Insert a sync point into the compositor's command stream and acknowledge | 247 // Insert a sync point into the compositor's command stream and acknowledge |
247 // that we have presented the accelerated surface buffer. | 248 // that we have presented the accelerated surface buffer. |
248 static void InsertSyncPointAndACK(int32 route_id, | 249 static void InsertSyncPointAndACK(int32 route_id, |
249 int gpu_host_id, | 250 int gpu_host_id, |
251 bool presented, | |
250 ui::Compositor* compositor); | 252 ui::Compositor* compositor); |
251 | 253 |
252 // Called when window_ is removed from the window tree. | 254 // Called when window_ is removed from the window tree. |
253 void RemovingFromRootWindow(); | 255 void RemovingFromRootWindow(); |
254 | 256 |
255 // After clearing |current_surface_|, and waiting for the compositor to finish | 257 // After clearing |current_surface_|, and waiting for the compositor to finish |
256 // using it, call this to inform the gpu process. | 258 // using it, call this to inform the gpu process. |
257 void SetSurfaceNotInUseByCompositor(ui::Compositor* compositor); | 259 void SetSurfaceNotInUseByCompositor(ui::Compositor* compositor); |
258 | 260 |
259 // This is called every time |current_surface_| usage changes (by thumbnailer, | 261 // This is called every time |current_surface_| usage changes (by thumbnailer, |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
323 | 325 |
324 // Current tooltip text. | 326 // Current tooltip text. |
325 string16 tooltip_; | 327 string16 tooltip_; |
326 | 328 |
327 // The scale factor of the display the renderer is currently on. | 329 // The scale factor of the display the renderer is currently on. |
328 float device_scale_factor_; | 330 float device_scale_factor_; |
329 | 331 |
330 std::vector< base::Callback<void(ui::Compositor*)> > | 332 std::vector< base::Callback<void(ui::Compositor*)> > |
331 on_compositing_did_commit_callbacks_; | 333 on_compositing_did_commit_callbacks_; |
332 | 334 |
333 std::vector< base::Callback<void(ui::Compositor*)> > | |
334 on_compositing_will_start_callbacks_; | |
335 | |
336 std::map<uint64, scoped_refptr<ui::Texture> > | 335 std::map<uint64, scoped_refptr<ui::Texture> > |
337 image_transport_clients_; | 336 image_transport_clients_; |
338 | 337 |
339 uint64 current_surface_; | 338 uint64 current_surface_; |
340 | 339 |
341 // Protected means that the |current_surface_| may be in use by ui and cannot | 340 // Protected means that the |current_surface_| may be in use by ui and cannot |
342 // be safely discarded. Things to consider are thumbnailer, compositor draw, | 341 // be safely discarded. Things to consider are thumbnailer, compositor draw, |
343 // and tab visibility. | 342 // and tab visibility. |
344 bool current_surface_is_protected_; | 343 bool current_surface_is_protected_; |
345 bool current_surface_in_use_by_compositor_; | 344 bool current_surface_in_use_by_compositor_; |
(...skipping 26 matching lines...) Expand all Loading... | |
372 // events vs. normal mouse move events. | 371 // events vs. normal mouse move events. |
373 bool synthetic_move_sent_; | 372 bool synthetic_move_sent_; |
374 | 373 |
375 // Signals that the accelerated compositing has been turned on or off. | 374 // Signals that the accelerated compositing has been turned on or off. |
376 // This is used to signal to turn off the external texture as soon as the | 375 // This is used to signal to turn off the external texture as soon as the |
377 // software backing store is updated. | 376 // software backing store is updated. |
378 bool accelerated_compositing_state_changed_; | 377 bool accelerated_compositing_state_changed_; |
379 | 378 |
380 // Used to prevent further resizes while a resize is pending. | 379 // Used to prevent further resizes while a resize is pending. |
381 class ResizeLock; | 380 class ResizeLock; |
381 typedef std::vector<linked_ptr<ResizeLock> > ResizeLockList; | |
382 | |
382 // These locks are the ones waiting for a texture of the right size to come | 383 // These locks are the ones waiting for a texture of the right size to come |
383 // back from the renderer/GPU process. | 384 // back from the renderer/GPU process. |
384 std::vector<linked_ptr<ResizeLock> > resize_locks_; | 385 ResizeLockList resize_locks_; |
385 // These locks are the ones waiting for a frame to be drawn. | 386 // These locks are the ones waiting for a frame to be committed. |
386 std::vector<linked_ptr<ResizeLock> > locks_pending_draw_; | 387 ResizeLockList locks_pending_commit_; |
387 | 388 |
388 // This lock is for waiting for a front surface to become available to draw. | 389 // This lock is for waiting for a front surface to become available to draw. |
389 scoped_refptr<aura::CompositorLock> released_front_lock_; | 390 scoped_refptr<ui::CompositorLock> released_front_lock_; |
390 | 391 |
391 // Used to track the state of the window we're created from. Only used when | 392 // Used to track the state of the window we're created from. Only used when |
392 // created fullscreen. | 393 // created fullscreen. |
393 scoped_ptr<aura::WindowTracker> host_tracker_; | 394 scoped_ptr<aura::WindowTracker> host_tracker_; |
394 | 395 |
396 enum CanLockCompositorState { | |
397 YES, | |
398 // We locked, so at some point we'll need to kick a frame. | |
399 YES_DID_LOCK, | |
400 // No. A lock timed out, we need to kick a new frame before locking again. | |
piman
2012/10/17 21:26:32
Since the lock timed out, we just "kicked" a frame
jonathan.backer
2012/10/18 20:20:35
Fast ACKs complicate the logic. When we fast ACK,
| |
401 NO_PENDING_FRAME, | |
402 // No. We've got a frame, but it hasn't been committed. | |
403 NO_PENDING_COMMIT, | |
404 }; | |
405 CanLockCompositorState can_lock_compositor_; | |
406 | |
395 DISALLOW_COPY_AND_ASSIGN(RenderWidgetHostViewAura); | 407 DISALLOW_COPY_AND_ASSIGN(RenderWidgetHostViewAura); |
396 }; | 408 }; |
397 | 409 |
398 } // namespace content | 410 } // namespace content |
399 | 411 |
400 #endif // CONTENT_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_VIEW_AURA_H_ | 412 #endif // CONTENT_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_VIEW_AURA_H_ |
OLD | NEW |