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

Side by Side Diff: content/browser/renderer_host/render_widget_host_view_aura.h

Issue 11194042: Implement TextureImageTransportSurface using texture mailbox (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: address comments Created 8 years 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
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 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/gtest_prod_util.h" 12 #include "base/gtest_prod_util.h"
13 #include "base/memory/linked_ptr.h" 13 #include "base/memory/linked_ptr.h"
14 #include "base/memory/ref_counted.h" 14 #include "base/memory/ref_counted.h"
15 #include "base/memory/scoped_ptr.h"
15 #include "base/memory/weak_ptr.h" 16 #include "base/memory/weak_ptr.h"
16 #include "content/browser/renderer_host/image_transport_factory.h" 17 #include "content/browser/renderer_host/image_transport_factory.h"
17 #include "content/browser/renderer_host/render_widget_host_view_base.h" 18 #include "content/browser/renderer_host/render_widget_host_view_base.h"
18 #include "content/common/content_export.h" 19 #include "content/common/content_export.h"
20 #include "third_party/skia/include/core/SkRegion.h"
19 #include "ui/aura/client/activation_delegate.h" 21 #include "ui/aura/client/activation_delegate.h"
20 #include "ui/aura/window_delegate.h" 22 #include "ui/aura/window_delegate.h"
21 #include "ui/base/ime/text_input_client.h" 23 #include "ui/base/ime/text_input_client.h"
24 #include "ui/compositor/compositor.h"
22 #include "ui/compositor/compositor_observer.h" 25 #include "ui/compositor/compositor_observer.h"
23 #include "ui/gfx/display_observer.h" 26 #include "ui/gfx/display_observer.h"
24 #include "ui/gfx/rect.h" 27 #include "ui/gfx/rect.h"
25 #include "webkit/glue/webcursor.h" 28 #include "webkit/glue/webcursor.h"
26 29
27 namespace aura { 30 namespace aura {
28 class WindowTracker; 31 class WindowTracker;
29 } 32 }
30 33
31 namespace gfx { 34 namespace gfx {
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
114 skia::PlatformBitmap* output) OVERRIDE; 117 skia::PlatformBitmap* output) OVERRIDE;
115 virtual void OnAcceleratedCompositingStateChange() OVERRIDE; 118 virtual void OnAcceleratedCompositingStateChange() OVERRIDE;
116 virtual void AcceleratedSurfaceBuffersSwapped( 119 virtual void AcceleratedSurfaceBuffersSwapped(
117 const GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params& params_in_pixel, 120 const GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params& params_in_pixel,
118 int gpu_host_id) OVERRIDE; 121 int gpu_host_id) OVERRIDE;
119 virtual void AcceleratedSurfacePostSubBuffer( 122 virtual void AcceleratedSurfacePostSubBuffer(
120 const GpuHostMsg_AcceleratedSurfacePostSubBuffer_Params& params_in_pixel, 123 const GpuHostMsg_AcceleratedSurfacePostSubBuffer_Params& params_in_pixel,
121 int gpu_host_id) OVERRIDE; 124 int gpu_host_id) OVERRIDE;
122 virtual void AcceleratedSurfaceSuspend() OVERRIDE; 125 virtual void AcceleratedSurfaceSuspend() OVERRIDE;
123 virtual bool HasAcceleratedSurface(const gfx::Size& desired_size) OVERRIDE; 126 virtual bool HasAcceleratedSurface(const gfx::Size& desired_size) OVERRIDE;
124 virtual void AcceleratedSurfaceNew( 127 virtual void AcceleratedSurfaceNew(int32 width_in_pixel,
125 int32 width_in_pixel, 128 int32 height_in_pixel,
126 int32 height_in_pixel, 129 uint64 surface_id,
127 uint64 surface_id) OVERRIDE; 130 const std::string& mailbox_name) OVERRIDE;
128 virtual void AcceleratedSurfaceRelease(uint64 surface_id) OVERRIDE; 131 virtual void AcceleratedSurfaceRelease(uint64 surface_id) OVERRIDE;
129 virtual void GetScreenInfo(WebKit::WebScreenInfo* results) OVERRIDE; 132 virtual void GetScreenInfo(WebKit::WebScreenInfo* results) OVERRIDE;
130 virtual gfx::Rect GetBoundsInRootWindow() OVERRIDE; 133 virtual gfx::Rect GetBoundsInRootWindow() OVERRIDE;
131 virtual void ProcessAckedTouchEvent( 134 virtual void ProcessAckedTouchEvent(
132 const WebKit::WebTouchEvent& touch, 135 const WebKit::WebTouchEvent& touch,
133 InputEventAckState ack_result) OVERRIDE; 136 InputEventAckState ack_result) OVERRIDE;
134 virtual void SetHasHorizontalScrollbar( 137 virtual void SetHasHorizontalScrollbar(
135 bool has_horizontal_scrollbar) OVERRIDE; 138 bool has_horizontal_scrollbar) OVERRIDE;
136 virtual void SetScrollOffsetPinning( 139 virtual void SetScrollOffsetPinning(
137 bool is_pinned_to_left, bool is_pinned_to_right) OVERRIDE; 140 bool is_pinned_to_left, bool is_pinned_to_right) OVERRIDE;
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
224 virtual void OnCompositingAborted(ui::Compositor* compositor) OVERRIDE; 227 virtual void OnCompositingAborted(ui::Compositor* compositor) OVERRIDE;
225 virtual void OnCompositingLockStateChanged( 228 virtual void OnCompositingLockStateChanged(
226 ui::Compositor* compositor) OVERRIDE; 229 ui::Compositor* compositor) OVERRIDE;
227 230
228 // Overridden from ImageTransportFactoryObserver: 231 // Overridden from ImageTransportFactoryObserver:
229 virtual void OnLostResources() OVERRIDE; 232 virtual void OnLostResources() OVERRIDE;
230 233
231 virtual ~RenderWidgetHostViewAura(); 234 virtual ~RenderWidgetHostViewAura();
232 235
233 void UpdateCursorIfOverSelf(); 236 void UpdateCursorIfOverSelf();
234 bool ShouldFastACK(uint64 surface_id); 237 bool ShouldSkipFrame(const gfx::Size& size);
235 void UpdateExternalTexture(); 238 void UpdateExternalTexture();
236 ui::InputMethod* GetInputMethod() const; 239 ui::InputMethod* GetInputMethod() const;
237 240
238 // Returns whether the widget needs an input grab to work properly. 241 // Returns whether the widget needs an input grab to work properly.
239 bool NeedsInputGrab(); 242 bool NeedsInputGrab();
240 243
241 // Confirm existing composition text in the webpage and ask the input method 244 // Confirm existing composition text in the webpage and ask the input method
242 // to cancel its ongoing composition session. 245 // to cancel its ongoing composition session.
243 void FinishImeCompositionSession(); 246 void FinishImeCompositionSession();
244 247
245 // This method computes movementX/Y and keeps track of mouse location for 248 // This method computes movementX/Y and keeps track of mouse location for
246 // mouse lock on all mouse move events. 249 // mouse lock on all mouse move events.
247 void ModifyEventMovementAndCoords(WebKit::WebMouseEvent* event); 250 void ModifyEventMovementAndCoords(WebKit::WebMouseEvent* event);
248 251
249 // If |clip| is non-empty and and doesn't contain |rect| or |clip| is empty 252 // If |clip| is non-empty and and doesn't contain |rect| or |clip| is empty
250 // SchedulePaint() is invoked for |rect|. 253 // SchedulePaint() is invoked for |rect|.
251 void SchedulePaintIfNotInClip(const gfx::Rect& rect, const gfx::Rect& clip); 254 void SchedulePaintIfNotInClip(const gfx::Rect& rect, const gfx::Rect& clip);
252 255
253 // Helper method to determine if, in mouse locked mode, the cursor should be 256 // Helper method to determine if, in mouse locked mode, the cursor should be
254 // moved to center. 257 // moved to center.
255 bool ShouldMoveToCenter(); 258 bool ShouldMoveToCenter();
256 259
257 // Run the compositing callbacks. 260 // Run the compositing callbacks.
258 void RunCompositingDidCommitCallbacks(ui::Compositor* compositor); 261 void RunCompositingDidCommitCallbacks();
262
263 struct BufferPresentedParams {
264 BufferPresentedParams(int route_id,
265 int gpu_host_id,
266 uint64 surface_handle);
267 ~BufferPresentedParams();
268
269 int32 route_id;
270 int gpu_host_id;
271 uint64 surface_handle;
272 scoped_refptr<ui::Texture> texture_to_produce;
273 };
259 274
260 // Insert a sync point into the compositor's command stream and acknowledge 275 // Insert a sync point into the compositor's command stream and acknowledge
261 // that we have presented the accelerated surface buffer. 276 // that we have presented the accelerated surface buffer.
262 static void InsertSyncPointAndACK(int32 route_id, 277 static void InsertSyncPointAndACK(const BufferPresentedParams& params);
jonathan.backer 2012/12/04 19:15:13 nit: Maybe this should be in the anonymous namespa
no sievers 2012/12/05 22:02:34 I left it here for now, because if I moved it to t
263 int gpu_host_id,
264 bool presented,
265 ui::Compositor* compositor);
266 278
267 // Called when window_ gets added to a new window tree. 279 // Called when window_ gets added to a new window tree.
268 void AddingToRootWindow(); 280 void AddingToRootWindow();
269 281
270 // Called when window_ is removed from the window tree. 282 // Called when window_ is removed from the window tree.
271 void RemovingFromRootWindow(); 283 void RemovingFromRootWindow();
272 284
273 // After clearing |current_surface_|, and waiting for the compositor to finish 285 // Called after commit for the last reference to the texture going away
274 // using it, call this to inform the gpu process. 286 // after it was released as the frontbuffer.
275 void SetSurfaceNotInUseByCompositor(ui::Compositor* compositor); 287 void SetSurfaceNotInUseByCompositor(scoped_refptr<ui::Texture>);
276
277 // This is called every time |current_surface_| usage changes (by thumbnailer,
278 // compositor draws, and tab visibility). Every time usage of current surface
279 // changes between "may be used" and "certain to not be used" by the ui, we
280 // inform the gpu process.
281 void AdjustSurfaceProtection();
282 288
283 // Called after async thumbnailer task completes. Used to call 289 // Called after async thumbnailer task completes. Used to call
284 // AdjustSurfaceProtection. 290 // AdjustSurfaceProtection.
285 static void CopyFromCompositingSurfaceFinished( 291 static void CopyFromCompositingSurfaceFinished(
286 base::WeakPtr<RenderWidgetHostViewAura> render_widget_host_view, 292 base::WeakPtr<RenderWidgetHostViewAura> render_widget_host_view,
287 const base::Callback<void(bool)>& callback, 293 const base::Callback<void(bool)>& callback,
288 bool result); 294 bool result);
289 295
290 ui::Compositor* GetCompositor(); 296 ui::Compositor* GetCompositor();
291 297
292 // Detaches |this| from the input method object. 298 // Detaches |this| from the input method object.
293 void DetachFromInputMethod(); 299 void DetachFromInputMethod();
294 300
295 // Converts |rect| from window coordinate to screen coordinate. 301 // Converts |rect| from window coordinate to screen coordinate.
296 gfx::Rect ConvertRectToScreen(const gfx::Rect& rect); 302 gfx::Rect ConvertRectToScreen(const gfx::Rect& rect);
297 303
304 bool SwapBuffersPrepare(const gfx::Rect& surface_rect,
305 const gfx::Rect& damage_rect,
306 BufferPresentedParams* params);
307
308 void SwapBuffersCompleted(const BufferPresentedParams& params);
309
298 // The model object. 310 // The model object.
299 RenderWidgetHostImpl* host_; 311 RenderWidgetHostImpl* host_;
300 312
301 aura::Window* window_; 313 aura::Window* window_;
302 314
303 scoped_ptr<WindowObserver> window_observer_; 315 scoped_ptr<WindowObserver> window_observer_;
304 316
305 // Are we in the process of closing? Tracked so fullscreen views can avoid 317 // Are we in the process of closing? Tracked so fullscreen views can avoid
306 // sending a second shutdown request to the host when they lose the focus 318 // sending a second shutdown request to the host when they lose the focus
307 // after requesting shutdown for another reason (e.g. Escape key). 319 // after requesting shutdown for another reason (e.g. Escape key).
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
340 352
341 // Indicates if there is onging composition text. 353 // Indicates if there is onging composition text.
342 bool has_composition_text_; 354 bool has_composition_text_;
343 355
344 // Current tooltip text. 356 // Current tooltip text.
345 string16 tooltip_; 357 string16 tooltip_;
346 358
347 // The scale factor of the display the renderer is currently on. 359 // The scale factor of the display the renderer is currently on.
348 float device_scale_factor_; 360 float device_scale_factor_;
349 361
350 std::vector< base::Callback<void(ui::Compositor*)> > 362 std::vector<base::Closure> on_compositing_did_commit_callbacks_;
351 on_compositing_did_commit_callbacks_;
352 363
353 std::map<uint64, scoped_refptr<ui::Texture> > 364 std::map<uint64, scoped_refptr<ui::Texture> > image_transport_clients_;
354 image_transport_clients_;
355 365
366 // The identifier of the current frontbuffer.
356 uint64 current_surface_; 367 uint64 current_surface_;
357 368
358 // Protected means that the |current_surface_| may be in use by ui and cannot 369 // The damage in the previous buffer.
jonathan.backer 2012/12/04 19:15:13 nit: |previous_damage_| and |previous_surface_size
no sievers 2012/12/05 22:02:34 Done.
359 // be safely discarded. Things to consider are thumbnailer, compositor draw, 370 SkRegion previous_damage_;
360 // and tab visibility. 371
361 bool current_surface_is_protected_; 372 // Pending damage from previous frames that we skipped.
362 bool current_surface_in_use_by_compositor_; 373 SkRegion skipped_damage_;
374
375 // The size of the previously received frame.
376 gfx::Size previous_surface_size_;
363 377
364 int pending_thumbnail_tasks_; 378 int pending_thumbnail_tasks_;
365 379
366 // This id increments every time surface_is_protected changes. We tag IPC
367 // messages which rely on protection state with this id to stay in sync.
368 uint32 protection_state_id_;
369
370 int32 surface_route_id_;
371
372 gfx::GLSurfaceHandle shared_surface_handle_; 380 gfx::GLSurfaceHandle shared_surface_handle_;
373 381
374 // If non-NULL we're in OnPaint() and this is the supplied canvas. 382 // If non-NULL we're in OnPaint() and this is the supplied canvas.
375 gfx::Canvas* paint_canvas_; 383 gfx::Canvas* paint_canvas_;
376 384
377 // Used to record the last position of the mouse. 385 // Used to record the last position of the mouse.
378 // While the mouse is locked, they store the last known position just as mouse 386 // While the mouse is locked, they store the last known position just as mouse
379 // lock was entered. 387 // lock was entered.
380 // Relative to the upper-left corner of the view. 388 // Relative to the upper-left corner of the view.
381 gfx::Point unlocked_mouse_position_; 389 gfx::Point unlocked_mouse_position_;
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
425 // Whether or not the ui::Event* being processed currently would cause 433 // Whether or not the ui::Event* being processed currently would cause
426 // |window_| to be activated. 434 // |window_| to be activated.
427 bool pointer_activate_; 435 bool pointer_activate_;
428 436
429 DISALLOW_COPY_AND_ASSIGN(RenderWidgetHostViewAura); 437 DISALLOW_COPY_AND_ASSIGN(RenderWidgetHostViewAura);
430 }; 438 };
431 439
432 } // namespace content 440 } // namespace content
433 441
434 #endif // CONTENT_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_VIEW_AURA_H_ 442 #endif // CONTENT_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_VIEW_AURA_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698