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

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: 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
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(const WebKit::WebTouchEvent& touch, 134 virtual void ProcessAckedTouchEvent(const WebKit::WebTouchEvent& touch,
132 bool processed) OVERRIDE; 135 bool processed) OVERRIDE;
133 virtual void SetHasHorizontalScrollbar( 136 virtual void SetHasHorizontalScrollbar(
134 bool has_horizontal_scrollbar) OVERRIDE; 137 bool has_horizontal_scrollbar) OVERRIDE;
135 virtual void SetScrollOffsetPinning( 138 virtual void SetScrollOffsetPinning(
136 bool is_pinned_to_left, bool is_pinned_to_right) OVERRIDE; 139 bool is_pinned_to_left, bool is_pinned_to_right) OVERRIDE;
137 virtual gfx::GLSurfaceHandle GetCompositingSurface() OVERRIDE; 140 virtual gfx::GLSurfaceHandle GetCompositingSurface() OVERRIDE;
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
222 virtual void OnCompositingAborted(ui::Compositor* compositor) OVERRIDE; 225 virtual void OnCompositingAborted(ui::Compositor* compositor) OVERRIDE;
223 virtual void OnCompositingLockStateChanged( 226 virtual void OnCompositingLockStateChanged(
224 ui::Compositor* compositor) OVERRIDE; 227 ui::Compositor* compositor) OVERRIDE;
225 228
226 // Overridden from ImageTransportFactoryObserver: 229 // Overridden from ImageTransportFactoryObserver:
227 virtual void OnLostResources() OVERRIDE; 230 virtual void OnLostResources() OVERRIDE;
228 231
229 virtual ~RenderWidgetHostViewAura(); 232 virtual ~RenderWidgetHostViewAura();
230 233
231 void UpdateCursorIfOverSelf(); 234 void UpdateCursorIfOverSelf();
232 bool ShouldFastACK(uint64 surface_id); 235 bool ShouldSkipFrame(const gfx::Size& size);
233 void UpdateExternalTexture(); 236 void UpdateExternalTexture();
234 ui::InputMethod* GetInputMethod() const; 237 ui::InputMethod* GetInputMethod() const;
235 238
236 // Returns whether the widget needs an input grab to work properly. 239 // Returns whether the widget needs an input grab to work properly.
237 bool NeedsInputGrab(); 240 bool NeedsInputGrab();
238 241
239 // Confirm existing composition text in the webpage and ask the input method 242 // Confirm existing composition text in the webpage and ask the input method
240 // to cancel its ongoing composition session. 243 // to cancel its ongoing composition session.
241 void FinishImeCompositionSession(); 244 void FinishImeCompositionSession();
242 245
243 // This method computes movementX/Y and keeps track of mouse location for 246 // This method computes movementX/Y and keeps track of mouse location for
244 // mouse lock on all mouse move events. 247 // mouse lock on all mouse move events.
245 void ModifyEventMovementAndCoords(WebKit::WebMouseEvent* event); 248 void ModifyEventMovementAndCoords(WebKit::WebMouseEvent* event);
246 249
247 // If |clip| is non-empty and and doesn't contain |rect| or |clip| is empty 250 // If |clip| is non-empty and and doesn't contain |rect| or |clip| is empty
248 // SchedulePaint() is invoked for |rect|. 251 // SchedulePaint() is invoked for |rect|.
249 void SchedulePaintIfNotInClip(const gfx::Rect& rect, const gfx::Rect& clip); 252 void SchedulePaintIfNotInClip(const gfx::Rect& rect, const gfx::Rect& clip);
250 253
251 // Helper method to determine if, in mouse locked mode, the cursor should be 254 // Helper method to determine if, in mouse locked mode, the cursor should be
252 // moved to center. 255 // moved to center.
253 bool ShouldMoveToCenter(); 256 bool ShouldMoveToCenter();
254 257
255 // Run the compositing callbacks. 258 // Run the compositing callbacks.
256 void RunCompositingDidCommitCallbacks(ui::Compositor* compositor); 259 void RunCompositingDidCommitCallbacks();
260
261 struct BufferPresentedParams {
262 BufferPresentedParams(int route_id,
263 int gpu_host_id,
264 uint64 surface_handle);
265 ~BufferPresentedParams();
266
267 int32 route_id;
268 int gpu_host_id;
269 uint64 surface_handle;
270 scoped_refptr<ui::Texture> texture_to_produce;
271 };
257 272
258 // Insert a sync point into the compositor's command stream and acknowledge 273 // Insert a sync point into the compositor's command stream and acknowledge
259 // that we have presented the accelerated surface buffer. 274 // that we have presented the accelerated surface buffer.
260 static void InsertSyncPointAndACK(int32 route_id, 275 static void InsertSyncPointAndACK(const BufferPresentedParams& params);
261 int gpu_host_id,
262 bool presented,
263 ui::Compositor* compositor);
264 276
265 // Called when window_ gets added to a new window tree. 277 // Called when window_ gets added to a new window tree.
266 void AddingToRootWindow(); 278 void AddingToRootWindow();
267 279
268 // Called when window_ is removed from the window tree. 280 // Called when window_ is removed from the window tree.
269 void RemovingFromRootWindow(); 281 void RemovingFromRootWindow();
270 282
271 // After clearing |current_surface_|, and waiting for the compositor to finish 283 // Called after commit for the last reference to the texture going away
272 // using it, call this to inform the gpu process. 284 // after it was released as the frontbuffer.
273 void SetSurfaceNotInUseByCompositor(ui::Compositor* compositor); 285 void SetSurfaceNotInUseByCompositor(scoped_refptr<ui::Texture>);
274
275 // This is called every time |current_surface_| usage changes (by thumbnailer,
276 // compositor draws, and tab visibility). Every time usage of current surface
277 // changes between "may be used" and "certain to not be used" by the ui, we
278 // inform the gpu process.
279 void AdjustSurfaceProtection();
280 286
281 // Called after async thumbnailer task completes. Used to call 287 // Called after async thumbnailer task completes. Used to call
282 // AdjustSurfaceProtection. 288 // AdjustSurfaceProtection.
283 static void CopyFromCompositingSurfaceFinished( 289 static void CopyFromCompositingSurfaceFinished(
284 base::WeakPtr<RenderWidgetHostViewAura> render_widget_host_view, 290 base::WeakPtr<RenderWidgetHostViewAura> render_widget_host_view,
285 const base::Callback<void(bool)>& callback, 291 const base::Callback<void(bool)>& callback,
286 bool result); 292 bool result);
287 293
288 ui::Compositor* GetCompositor(); 294 ui::Compositor* GetCompositor();
289 295
290 // Detaches |this| from the input method object. 296 // Detaches |this| from the input method object.
291 void DetachFromInputMethod(); 297 void DetachFromInputMethod();
292 298
293 // Converts |rect| from window coordinate to screen coordinate. 299 // Converts |rect| from window coordinate to screen coordinate.
294 gfx::Rect ConvertRectToScreen(const gfx::Rect& rect); 300 gfx::Rect ConvertRectToScreen(const gfx::Rect& rect);
295 301
302 bool SwapBuffersPrepare(const gfx::Rect& surface_rect,
303 const gfx::Rect& damage_rect,
304 BufferPresentedParams& params);
305
306 void SwapBuffersCompleted(const BufferPresentedParams& params);
307
296 // The model object. 308 // The model object.
297 RenderWidgetHostImpl* host_; 309 RenderWidgetHostImpl* host_;
298 310
299 aura::Window* window_; 311 aura::Window* window_;
300 312
301 scoped_ptr<WindowObserver> window_observer_; 313 scoped_ptr<WindowObserver> window_observer_;
302 314
303 // Are we in the process of closing? Tracked so fullscreen views can avoid 315 // Are we in the process of closing? Tracked so fullscreen views can avoid
304 // sending a second shutdown request to the host when they lose the focus 316 // sending a second shutdown request to the host when they lose the focus
305 // after requesting shutdown for another reason (e.g. Escape key). 317 // after requesting shutdown for another reason (e.g. Escape key).
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
338 350
339 // Indicates if there is onging composition text. 351 // Indicates if there is onging composition text.
340 bool has_composition_text_; 352 bool has_composition_text_;
341 353
342 // Current tooltip text. 354 // Current tooltip text.
343 string16 tooltip_; 355 string16 tooltip_;
344 356
345 // The scale factor of the display the renderer is currently on. 357 // The scale factor of the display the renderer is currently on.
346 float device_scale_factor_; 358 float device_scale_factor_;
347 359
348 std::vector< base::Callback<void(ui::Compositor*)> > 360 std::vector<base::Closure> on_compositing_did_commit_callbacks_;
349 on_compositing_did_commit_callbacks_;
350 361
351 std::map<uint64, scoped_refptr<ui::Texture> > 362 std::map<uint64, scoped_refptr<ui::Texture> > image_transport_clients_;
352 image_transport_clients_;
353 363
364 // The identifier of the current frontbuffer.
354 uint64 current_surface_; 365 uint64 current_surface_;
355 366
356 // Protected means that the |current_surface_| may be in use by ui and cannot 367 // The damage in the previous buffer.
357 // be safely discarded. Things to consider are thumbnailer, compositor draw, 368 SkRegion previous_damage_;
jonathan.backer 2012/11/20 21:21:11 nit: I think that we can get away with just storin
jonathan.backer 2012/11/21 05:47:05 I think I got this wrong. We have to handle the c
no sievers 2012/12/01 00:58:38 yes, i thought about a rect too. I guess it would
358 // and tab visibility. 369
359 bool current_surface_is_protected_; 370 // Pending damage from previous frames that we skipped.
360 bool current_surface_in_use_by_compositor_; 371 SkRegion skipped_damage_;
372
373 // The size of the previously received frame.
374 gfx::Size previous_surface_size_;
361 375
362 int pending_thumbnail_tasks_; 376 int pending_thumbnail_tasks_;
363 377
364 // This id increments every time surface_is_protected changes. We tag IPC
365 // messages which rely on protection state with this id to stay in sync.
366 uint32 protection_state_id_;
367
368 int32 surface_route_id_;
369
370 gfx::GLSurfaceHandle shared_surface_handle_; 378 gfx::GLSurfaceHandle shared_surface_handle_;
371 379
372 // If non-NULL we're in OnPaint() and this is the supplied canvas. 380 // If non-NULL we're in OnPaint() and this is the supplied canvas.
373 gfx::Canvas* paint_canvas_; 381 gfx::Canvas* paint_canvas_;
374 382
375 // Used to record the last position of the mouse. 383 // Used to record the last position of the mouse.
376 // While the mouse is locked, they store the last known position just as mouse 384 // While the mouse is locked, they store the last known position just as mouse
377 // lock was entered. 385 // lock was entered.
378 // Relative to the upper-left corner of the view. 386 // Relative to the upper-left corner of the view.
379 gfx::Point unlocked_mouse_position_; 387 gfx::Point unlocked_mouse_position_;
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
419 NO_PENDING_COMMIT, 427 NO_PENDING_COMMIT,
420 }; 428 };
421 CanLockCompositorState can_lock_compositor_; 429 CanLockCompositorState can_lock_compositor_;
422 430
423 DISALLOW_COPY_AND_ASSIGN(RenderWidgetHostViewAura); 431 DISALLOW_COPY_AND_ASSIGN(RenderWidgetHostViewAura);
424 }; 432 };
425 433
426 } // namespace content 434 } // namespace content
427 435
428 #endif // CONTENT_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_VIEW_AURA_H_ 436 #endif // CONTENT_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_VIEW_AURA_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698