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

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

Issue 15689003: Part 3/3 (RWH/IOSurface) of adding with device scale factor to transport surfaces (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add missed lines Created 7 years, 7 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 | 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_COMPOSITING_IOSURFACE_MAC_H_ 5 #ifndef CONTENT_BROWSER_RENDERER_HOST_COMPOSITING_IOSURFACE_MAC_H_
6 #define CONTENT_BROWSER_RENDERER_HOST_COMPOSITING_IOSURFACE_MAC_H_ 6 #define CONTENT_BROWSER_RENDERER_HOST_COMPOSITING_IOSURFACE_MAC_H_
7 7
8 #include <deque> 8 #include <deque>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 52
53 // Returns NULL if IOSurface support is missing or GL APIs fail. Specify in 53 // Returns NULL if IOSurface support is missing or GL APIs fail. Specify in
54 // |order| the desired ordering relationship of the surface to the containing 54 // |order| the desired ordering relationship of the surface to the containing
55 // window. 55 // window.
56 static CompositingIOSurfaceMac* Create(int window_number, 56 static CompositingIOSurfaceMac* Create(int window_number,
57 SurfaceOrder order); 57 SurfaceOrder order);
58 ~CompositingIOSurfaceMac(); 58 ~CompositingIOSurfaceMac();
59 59
60 // Set IOSurface that will be drawn on the next NSView drawRect. 60 // Set IOSurface that will be drawn on the next NSView drawRect.
61 void SetIOSurface(uint64 io_surface_handle, 61 void SetIOSurface(uint64 io_surface_handle,
62 const gfx::Size& size); 62 const gfx::Size& size,
63 float scale_factor);
63 64
64 // Get the CGL renderer ID currently associated with this context. 65 // Get the CGL renderer ID currently associated with this context.
65 int GetRendererID(); 66 int GetRendererID();
66 67
67 // Blit the IOSurface at the upper-left corner of the |view|. If |view| window 68 // Blit the IOSurface at the upper-left corner of the |view|. If |view| window
68 // size is larger than the IOSurface, the remaining right and bottom edges 69 // size is larger than the IOSurface, the remaining right and bottom edges
69 // will be white. |scaleFactor| is 1 in normal views, 2 in HiDPI views. 70 // will be white. |scaleFactor| is 1 in normal views, 2 in HiDPI views.
70 // |frame_subscriber| listens to this draw event and provides output buffer 71 // |frame_subscriber| listens to this draw event and provides output buffer
71 // for copying this frame into. 72 // for copying this frame into.
72 void DrawIOSurface(NSView* view, 73 void DrawIOSurface(NSView* view,
73 float scale_factor, 74 float scale_factor,
74 int window_number, 75 int window_number,
75 SurfaceOrder surface_order, 76 SurfaceOrder surface_order,
76 RenderWidgetHostViewFrameSubscriber* frame_subscriber); 77 RenderWidgetHostViewFrameSubscriber* frame_subscriber);
77 78
78 // Copy the data of the "live" OpenGL texture referring to this IOSurfaceRef 79 // Copy the data of the "live" OpenGL texture referring to this IOSurfaceRef
79 // into |out|. The copied region is specified with |src_pixel_subrect| and 80 // into |out|. The copied region is specified with |src_pixel_subrect| and
80 // the data is transformed so that it fits in |dst_pixel_size|. 81 // the data is transformed so that it fits in |dst_pixel_size|.
81 // |src_pixel_subrect| and |dst_pixel_size| are not in DIP but in pixel. 82 // |src_pixel_subrect| and |dst_pixel_size| are not in DIP but in pixel.
82 // Caller must ensure that |out| is allocated to dimensions that match 83 // Caller must ensure that |out| is allocated to dimensions that match
83 // dst_pixel_size, with no additional padding. 84 // dst_pixel_size, with no additional padding.
84 // |callback| is invoked when the operation is completed or failed. 85 // |callback| is invoked when the operation is completed or failed.
85 // Do no call this method again before |callback| is invoked. 86 // Do no call this method again before |callback| is invoked.
86 void CopyTo(const gfx::Rect& src_pixel_subrect, 87 void CopyTo(const gfx::Rect& src_pixel_subrect,
87 float src_scale_factor,
88 const gfx::Size& dst_pixel_size, 88 const gfx::Size& dst_pixel_size,
89 const base::Callback<void(bool, const SkBitmap&)>& callback); 89 const base::Callback<void(bool, const SkBitmap&)>& callback);
90 90
91 // Transfer the contents of the surface to an already-allocated YV12 91 // Transfer the contents of the surface to an already-allocated YV12
92 // VideoFrame, and invoke a callback to indicate success or failure. 92 // VideoFrame, and invoke a callback to indicate success or failure.
93 void CopyToVideoFrame( 93 void CopyToVideoFrame(
94 const gfx::Rect& src_subrect, 94 const gfx::Rect& src_subrect,
95 float src_scale_factor,
96 const scoped_refptr<media::VideoFrame>& target, 95 const scoped_refptr<media::VideoFrame>& target,
97 const base::Callback<void(bool)>& callback); 96 const base::Callback<void(bool)>& callback);
98 97
99 // Unref the IOSurface and delete the associated GL texture. If the GPU 98 // Unref the IOSurface and delete the associated GL texture. If the GPU
100 // process is no longer referencing it, this will delete the IOSurface. 99 // process is no longer referencing it, this will delete the IOSurface.
101 void UnrefIOSurface(); 100 void UnrefIOSurface();
102 101
103 // Call when globalFrameDidChange is received on the NSView. 102 // Call when globalFrameDidChange is received on the NSView.
104 void GlobalFrameDidChange(); 103 void GlobalFrameDidChange();
105 104
106 // Disassociate the GL context with the NSView and unref the IOSurface. Do 105 // Disassociate the GL context with the NSView and unref the IOSurface. Do
107 // this to switch to software drawing mode. 106 // this to switch to software drawing mode.
108 void ClearDrawable(); 107 void ClearDrawable();
109 108
110 bool HasIOSurface() { return !!io_surface_.get(); } 109 bool HasIOSurface() { return !!io_surface_.get(); }
111 110
112 const gfx::Size& pixel_io_surface_size() const { 111 const gfx::Size& pixel_io_surface_size() const {
113 return pixel_io_surface_size_; 112 return pixel_io_surface_size_;
114 } 113 }
115 // In cocoa view units / DIPs. 114 // In cocoa view units / DIPs.
116 const gfx::Size& io_surface_size() const { return io_surface_size_; } 115 const gfx::Size& dip_io_surface_size() const { return dip_io_surface_size_; }
117
118 void SetDeviceScaleFactor(float scale_factor);
119 116
120 bool is_vsync_disabled() const; 117 bool is_vsync_disabled() const;
121 118
122 // Get vsync scheduling parameters. 119 // Get vsync scheduling parameters.
123 // |interval_numerator/interval_denominator| equates to fractional number of 120 // |interval_numerator/interval_denominator| equates to fractional number of
124 // seconds between vsyncs. 121 // seconds between vsyncs.
125 void GetVSyncParameters(base::TimeTicks* timebase, 122 void GetVSyncParameters(base::TimeTicks* timebase,
126 uint32* interval_numerator, 123 uint32* interval_numerator,
127 uint32* interval_denominator); 124 uint32* interval_denominator);
128 125
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
258 void StartOrContinueDisplayLink(); 255 void StartOrContinueDisplayLink();
259 void StopDisplayLink(); 256 void StopDisplayLink();
260 257
261 // Copy current frame to |target| video frame. This method must be called 258 // Copy current frame to |target| video frame. This method must be called
262 // within a CGL context. Returns a callback that should be called outside 259 // within a CGL context. Returns a callback that should be called outside
263 // of the CGL context. 260 // of the CGL context.
264 // If |called_within_draw| is true this method is called within a drawing 261 // If |called_within_draw| is true this method is called within a drawing
265 // operations. This allow certain optimizations. 262 // operations. This allow certain optimizations.
266 base::Closure CopyToVideoFrameWithinContext( 263 base::Closure CopyToVideoFrameWithinContext(
267 const gfx::Rect& src_subrect, 264 const gfx::Rect& src_subrect,
268 float src_scale_factor,
269 bool called_within_draw, 265 bool called_within_draw,
270 const scoped_refptr<media::VideoFrame>& target, 266 const scoped_refptr<media::VideoFrame>& target,
271 const base::Callback<void(bool)>& callback); 267 const base::Callback<void(bool)>& callback);
272 268
273 // Common GPU-readback copy path. Only one of |bitmap_output| or 269 // Common GPU-readback copy path. Only one of |bitmap_output| or
274 // |video_frame_output| may be specified: Either ARGB is written to 270 // |video_frame_output| may be specified: Either ARGB is written to
275 // |bitmap_output| or letter-boxed YV12 is written to |video_frame_output|. 271 // |bitmap_output| or letter-boxed YV12 is written to |video_frame_output|.
276 base::Closure CopyToSelectedOutputWithinContext( 272 base::Closure CopyToSelectedOutputWithinContext(
277 const gfx::Rect& src_pixel_subrect, 273 const gfx::Rect& src_pixel_subrect,
278 float src_scale_factor,
279 const gfx::Rect& dst_pixel_rect, 274 const gfx::Rect& dst_pixel_rect,
280 bool called_within_draw, 275 bool called_within_draw,
281 const SkBitmap* bitmap_output, 276 const SkBitmap* bitmap_output,
282 const scoped_refptr<media::VideoFrame>& video_frame_output, 277 const scoped_refptr<media::VideoFrame>& video_frame_output,
283 const base::Callback<void(bool)>& done_callback); 278 const base::Callback<void(bool)>& done_callback);
284 279
285 // TODO(hclam): These two methods should be static. 280 // TODO(hclam): These two methods should be static.
286 void AsynchronousReadbackForCopy( 281 void AsynchronousReadbackForCopy(
287 const gfx::Rect& dst_pixel_rect, 282 const gfx::Rect& dst_pixel_rect,
288 bool called_within_draw, 283 bool called_within_draw,
289 CopyContext* copy_context, 284 CopyContext* copy_context,
290 const SkBitmap* bitmap_output, 285 const SkBitmap* bitmap_output,
291 const scoped_refptr<media::VideoFrame>& video_frame_output); 286 const scoped_refptr<media::VideoFrame>& video_frame_output);
292 bool SynchronousReadbackForCopy( 287 bool SynchronousReadbackForCopy(
293 const gfx::Rect& dst_pixel_rect, 288 const gfx::Rect& dst_pixel_rect,
294 CopyContext* copy_context, 289 CopyContext* copy_context,
295 const SkBitmap* bitmap_output, 290 const SkBitmap* bitmap_output,
296 const scoped_refptr<media::VideoFrame>& video_frame_output); 291 const scoped_refptr<media::VideoFrame>& video_frame_output);
297 292
298 // Scan the list of started asynchronous copies and test if each one has 293 // Scan the list of started asynchronous copies and test if each one has
299 // completed. 294 // completed.
300 void FinishAllCopies(); 295 void FinishAllCopies();
301 void FinishAllCopiesWithinContext( 296 void FinishAllCopiesWithinContext(
302 std::vector<base::Closure>* done_callbacks); 297 std::vector<base::Closure>* done_callbacks);
303 298
304 void FailAllCopies(); 299 void FailAllCopies();
305 void DestroyAllCopyContextsWithinContext(); 300 void DestroyAllCopyContextsWithinContext();
306 301
307 gfx::Rect IntersectWithIOSurface(const gfx::Rect& rect, 302 gfx::Rect IntersectWithIOSurface(const gfx::Rect& rect) const;
308 float scale_factor) const;
309 303
310 // Cached pointer to IOSurfaceSupport Singleton. 304 // Cached pointer to IOSurfaceSupport Singleton.
311 IOSurfaceSupport* io_surface_support_; 305 IOSurfaceSupport* io_surface_support_;
312 306
313 // GL context, and parameters for context sharing. This may change when 307 // GL context, and parameters for context sharing. This may change when
314 // moving between windows, but will never be NULL. 308 // moving between windows, but will never be NULL.
315 scoped_refptr<CompositingIOSurfaceContext> context_; 309 scoped_refptr<CompositingIOSurfaceContext> context_;
316 310
317 // IOSurface data. 311 // IOSurface data.
318 uint64 io_surface_handle_; 312 uint64 io_surface_handle_;
319 base::mac::ScopedCFTypeRef<CFTypeRef> io_surface_; 313 base::mac::ScopedCFTypeRef<CFTypeRef> io_surface_;
320 314
321 // The width and height of the io surface. 315 // The width and height of the io surface.
322 gfx::Size pixel_io_surface_size_; // In pixels. 316 gfx::Size pixel_io_surface_size_; // In pixels.
323 gfx::Size io_surface_size_; // In view units. 317 gfx::Size dip_io_surface_size_; // In view / density independent pixels.
324 318
325 // The "live" OpenGL texture referring to this IOSurfaceRef. Note 319 // The "live" OpenGL texture referring to this IOSurfaceRef. Note
326 // that per the CGLTexImageIOSurface2D API we do not need to 320 // that per the CGLTexImageIOSurface2D API we do not need to
327 // explicitly update this texture's contents once created. All we 321 // explicitly update this texture's contents once created. All we
328 // need to do is ensure it is re-bound before attempting to draw 322 // need to do is ensure it is re-bound before attempting to draw
329 // with it. 323 // with it.
330 GLuint texture_; 324 GLuint texture_;
331 325
332 // A pool of CopyContexts with OpenGL objects ready for re-use. Prefer to 326 // A pool of CopyContexts with OpenGL objects ready for re-use. Prefer to
333 // pull one from the pool before creating a new CopyContext. 327 // pull one from the pool before creating a new CopyContext.
(...skipping 24 matching lines...) Expand all
358 uint32 vsync_interval_denominator_; 352 uint32 vsync_interval_denominator_;
359 353
360 bool initialized_is_intel_; 354 bool initialized_is_intel_;
361 bool is_intel_; 355 bool is_intel_;
362 GLint screen_; 356 GLint screen_;
363 }; 357 };
364 358
365 } // namespace content 359 } // namespace content
366 360
367 #endif // CONTENT_BROWSER_RENDERER_HOST_COMPOSITING_IOSURFACE_MAC_H_ 361 #endif // CONTENT_BROWSER_RENDERER_HOST_COMPOSITING_IOSURFACE_MAC_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698