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_ACCELERATED_COMPOSITING_VIEW_MAC_H | 5 #ifndef CONTENT_BROWSER_RENDERER_HOST_ACCELERATED_COMPOSITING_VIEW_MAC_H |
6 #define CONTENT_BROWSER_RENDERER_HOST_ACCELERATED_COMPOSITING_VIEW_MAC_H | 6 #define CONTENT_BROWSER_RENDERER_HOST_ACCELERATED_COMPOSITING_VIEW_MAC_H |
7 | 7 |
8 #import <Cocoa/Cocoa.h> | 8 #import <Cocoa/Cocoa.h> |
9 #import <QuartzCore/CVDisplayLink.h> | 9 #import <QuartzCore/CVDisplayLink.h> |
10 #include <QuartzCore/QuartzCore.h> | 10 #include <QuartzCore/QuartzCore.h> |
(...skipping 12 matching lines...) Expand all Loading... |
23 #include "ui/gfx/size.h" | 23 #include "ui/gfx/size.h" |
24 | 24 |
25 class IOSurfaceSupport; | 25 class IOSurfaceSupport; |
26 | 26 |
27 namespace gfx { | 27 namespace gfx { |
28 class Rect; | 28 class Rect; |
29 } | 29 } |
30 | 30 |
31 namespace content { | 31 namespace content { |
32 | 32 |
| 33 class RenderWidgetHostViewFrameSubscriber; |
| 34 |
33 // This class manages an OpenGL context and IOSurface for the accelerated | 35 // This class manages an OpenGL context and IOSurface for the accelerated |
34 // compositing code path. The GL context is attached to | 36 // compositing code path. The GL context is attached to |
35 // RenderWidgetHostViewCocoa for blitting the IOSurface. | 37 // RenderWidgetHostViewCocoa for blitting the IOSurface. |
36 class CompositingIOSurfaceMac { | 38 class CompositingIOSurfaceMac { |
37 public: | 39 public: |
38 // Passed to Create() to specify the ordering of the surface relative to the | 40 // Passed to Create() to specify the ordering of the surface relative to the |
39 // containing window. | 41 // containing window. |
40 enum SurfaceOrder { | 42 enum SurfaceOrder { |
41 SURFACE_ORDER_ABOVE_WINDOW, | 43 SURFACE_ORDER_ABOVE_WINDOW, |
42 SURFACE_ORDER_BELOW_WINDOW | 44 SURFACE_ORDER_BELOW_WINDOW |
43 }; | 45 }; |
44 | 46 |
45 // Returns NULL if IOSurface support is missing or GL APIs fail. Specify in | 47 // Returns NULL if IOSurface support is missing or GL APIs fail. Specify in |
46 // |order| the desired ordering relationship of the surface to the containing | 48 // |order| the desired ordering relationship of the surface to the containing |
47 // window. | 49 // window. |
48 static CompositingIOSurfaceMac* Create(SurfaceOrder order); | 50 static CompositingIOSurfaceMac* Create(SurfaceOrder order); |
49 ~CompositingIOSurfaceMac(); | 51 ~CompositingIOSurfaceMac(); |
50 | 52 |
51 // Set IOSurface that will be drawn on the next NSView drawRect. | 53 // Set IOSurface that will be drawn on the next NSView drawRect. |
52 void SetIOSurface(uint64 io_surface_handle, | 54 void SetIOSurface(uint64 io_surface_handle, |
53 const gfx::Size& size); | 55 const gfx::Size& size); |
54 | 56 |
55 // Blit the IOSurface at the upper-left corner of the |view|. If |view| window | 57 // Blit the IOSurface at the upper-left corner of the |view|. If |view| window |
56 // size is larger than the IOSurface, the remaining right and bottom edges | 58 // size is larger than the IOSurface, the remaining right and bottom edges |
57 // will be white. |scaleFactor| is 1 in normal views, 2 in HiDPI views. | 59 // will be white. |scaleFactor| is 1 in normal views, 2 in HiDPI views. |
58 void DrawIOSurface(NSView* view, float scale_factor); | 60 // |frame_subscriber| listens to this draw event and provides output buffer |
| 61 // for copying this frame into. |
| 62 void DrawIOSurface(NSView* view, float scale_factor, |
| 63 RenderWidgetHostViewFrameSubscriber* frame_subscriber); |
59 | 64 |
60 // Copy the data of the "live" OpenGL texture referring to this IOSurfaceRef | 65 // Copy the data of the "live" OpenGL texture referring to this IOSurfaceRef |
61 // into |out|. The copied region is specified with |src_pixel_subrect| and | 66 // into |out|. The copied region is specified with |src_pixel_subrect| and |
62 // the data is transformed so that it fits in |dst_pixel_size|. | 67 // the data is transformed so that it fits in |dst_pixel_size|. |
63 // |src_pixel_subrect| and |dst_pixel_size| are not in DIP but in pixel. | 68 // |src_pixel_subrect| and |dst_pixel_size| are not in DIP but in pixel. |
64 // Caller must ensure that |out| is allocated to dimensions that match | 69 // Caller must ensure that |out| is allocated to dimensions that match |
65 // dst_pixel_size, with no additional padding. | 70 // dst_pixel_size, with no additional padding. |
66 // |callback| is invoked when the operation is completed or failed. | 71 // |callback| is invoked when the operation is completed or failed. |
67 // Do no call this method again before |callback| is invoked. | 72 // Do no call this method again before |callback| is invoked. |
68 void CopyTo(const gfx::Rect& src_pixel_subrect, | 73 void CopyTo(const gfx::Rect& src_pixel_subrect, |
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
221 | 226 |
222 void CalculateVsyncParametersLockHeld(const CVTimeStamp* time); | 227 void CalculateVsyncParametersLockHeld(const CVTimeStamp* time); |
223 | 228 |
224 // Prevent from spinning on CGLFlushDrawable when it fails to throttle to | 229 // Prevent from spinning on CGLFlushDrawable when it fails to throttle to |
225 // VSync frequency. | 230 // VSync frequency. |
226 void RateLimitDraws(); | 231 void RateLimitDraws(); |
227 | 232 |
228 void StartOrContinueDisplayLink(); | 233 void StartOrContinueDisplayLink(); |
229 void StopDisplayLink(); | 234 void StopDisplayLink(); |
230 | 235 |
| 236 // Copy current frame to |target| video frame. This method must be called |
| 237 // within a CGL context. Returns a callback that should be called outside |
| 238 // of the CGL context. |
| 239 base::Closure CopyToVideoFrameInternal( |
| 240 const gfx::Rect& src_subrect, |
| 241 float src_scale_factor, |
| 242 const scoped_refptr<media::VideoFrame>& target, |
| 243 const base::Callback<void(bool)>& callback); |
| 244 |
231 // Two implementations of CopyTo() in synchronous and asynchronous mode. | 245 // Two implementations of CopyTo() in synchronous and asynchronous mode. |
232 // These may copy regions smaller than the requested |src_pixel_subrect| if | 246 // These may copy regions smaller than the requested |src_pixel_subrect| if |
233 // the iosurface is smaller than |src_pixel_subrect|. | 247 // the iosurface is smaller than |src_pixel_subrect|. |
234 bool SynchronousCopyTo(const gfx::Rect& src_pixel_subrect, | 248 bool SynchronousCopyTo(const gfx::Rect& src_pixel_subrect, |
235 float src_scale_factor, | 249 float src_scale_factor, |
236 const gfx::Size& dst_pixel_size, | 250 const gfx::Size& dst_pixel_size, |
237 const SkBitmap& out); | 251 const SkBitmap& out); |
238 bool AsynchronousCopyTo( | 252 bool AsynchronousCopyTo( |
239 const gfx::Rect& src_pixel_subrect, | 253 const gfx::Rect& src_pixel_subrect, |
240 float src_scale_factor, | 254 float src_scale_factor, |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
301 uint32 vsync_interval_denominator_; | 315 uint32 vsync_interval_denominator_; |
302 | 316 |
303 bool initialized_is_intel_; | 317 bool initialized_is_intel_; |
304 bool is_intel_; | 318 bool is_intel_; |
305 GLint screen_; | 319 GLint screen_; |
306 }; | 320 }; |
307 | 321 |
308 } // namespace content | 322 } // namespace content |
309 | 323 |
310 #endif // CONTENT_BROWSER_RENDERER_HOST_ACCELERATED_COMPOSITING_VIEW_MAC_H | 324 #endif // CONTENT_BROWSER_RENDERER_HOST_ACCELERATED_COMPOSITING_VIEW_MAC_H |
OLD | NEW |