| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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_LAYER_MAC_H_ | 5 #ifndef CONTENT_BROWSER_RENDERER_HOST_COMPOSITING_IOSURFACE_LAYER_MAC_H_ |
| 6 #define CONTENT_BROWSER_RENDERER_HOST_COMPOSITING_IOSURFACE_LAYER_MAC_H_ | 6 #define CONTENT_BROWSER_RENDERER_HOST_COMPOSITING_IOSURFACE_LAYER_MAC_H_ |
| 7 | 7 |
| 8 #import <Cocoa/Cocoa.h> | 8 #import <Cocoa/Cocoa.h> |
| 9 | 9 |
| 10 #include "base/mac/scoped_cftyperef.h" | 10 #include "base/mac/scoped_cftyperef.h" |
| 11 #include "base/memory/ref_counted.h" | 11 #include "base/memory/ref_counted.h" |
| 12 #include "base/timer/timer.h" |
| 12 | 13 |
| 13 namespace content { | 14 namespace content { |
| 14 class CompositingIOSurfaceMac; | 15 class CompositingIOSurfaceMac; |
| 15 class CompositingIOSurfaceContext; | 16 class CompositingIOSurfaceContext; |
| 17 class CompositingIOSurfaceLayerHelper; |
| 16 | 18 |
| 17 class CompositingIOSurfaceLayerClient { | 19 class CompositingIOSurfaceLayerClient { |
| 18 public: | 20 public: |
| 19 virtual void AcceleratedLayerDidDrawFrame(bool succeeded) = 0; | 21 virtual void AcceleratedLayerDidDrawFrame(bool succeeded) = 0; |
| 20 virtual bool AcceleratedLayerHasNotAckedPendingFrame() const = 0; | |
| 21 }; | 22 }; |
| 22 | 23 |
| 23 } | 24 } |
| 24 | 25 |
| 25 // The CoreAnimation layer for drawing accelerated content. | 26 // The CoreAnimation layer for drawing accelerated content. |
| 26 @interface CompositingIOSurfaceLayer : CAOpenGLLayer { | 27 @interface CompositingIOSurfaceLayer : CAOpenGLLayer { |
| 27 @private | 28 @private |
| 28 content::CompositingIOSurfaceLayerClient* client_; | 29 content::CompositingIOSurfaceLayerClient* client_; |
| 29 scoped_refptr<content::CompositingIOSurfaceMac> iosurface_; | 30 scoped_refptr<content::CompositingIOSurfaceMac> iosurface_; |
| 30 scoped_refptr<content::CompositingIOSurfaceContext> context_; | 31 scoped_refptr<content::CompositingIOSurfaceContext> context_; |
| 31 | 32 |
| 33 // The browser places back-pressure on the GPU by not acknowledging swap |
| 34 // calls until they appear on the screen. This can lead to hangs if the |
| 35 // view is moved offscreen (among other things). Prevent hangs by always |
| 36 // acknowledging the frame after timeout of 1/6th of a second has passed. |
| 37 scoped_ptr<content::CompositingIOSurfaceLayerHelper> helper_; |
| 38 scoped_ptr<base::DelayTimer<content::CompositingIOSurfaceLayerHelper>> timer_; |
| 39 |
| 32 // Used to track when canDrawInCGLContext should return YES. This can be | 40 // Used to track when canDrawInCGLContext should return YES. This can be |
| 33 // in response to receiving a new compositor frame, or from any of the events | 41 // in response to receiving a new compositor frame, or from any of the events |
| 34 // that cause setNeedsDisplay to be called on the layer. | 42 // that cause setNeedsDisplay to be called on the layer. |
| 35 BOOL needs_display_; | 43 BOOL needs_display_; |
| 36 | 44 |
| 45 // This is set when a frame is received, and un-set when the frame is drawn. |
| 46 BOOL has_pending_frame_; |
| 47 |
| 37 // Incremented every time that this layer is asked to draw but does not have | 48 // Incremented every time that this layer is asked to draw but does not have |
| 38 // new content to draw. | 49 // new content to draw. |
| 39 uint64 did_not_draw_counter_; | 50 uint64 did_not_draw_counter_; |
| 40 } | 51 } |
| 41 | 52 |
| 42 - (content::CompositingIOSurfaceMac*)iosurface; | 53 - (content::CompositingIOSurfaceMac*)iosurface; |
| 43 - (content::CompositingIOSurfaceContext*)context; | 54 - (content::CompositingIOSurfaceContext*)context; |
| 44 | 55 |
| 45 - (id)initWithIOSurface:(scoped_refptr<content::CompositingIOSurfaceMac>) | 56 - (id)initWithIOSurface:(scoped_refptr<content::CompositingIOSurfaceMac>) |
| 46 iosurface | 57 iosurface |
| 47 withClient:(content::CompositingIOSurfaceLayerClient*)client; | 58 withClient:(content::CompositingIOSurfaceLayerClient*)client; |
| 48 | 59 |
| 49 // Mark that the client is no longer valid and cannot be called back into. | 60 // Mark that the client is no longer valid and cannot be called back into. |
| 50 - (void)resetClient; | 61 - (void)resetClient; |
| 51 | 62 |
| 52 // Called when a new frame is received. | 63 // Called when a new frame is received. |
| 53 - (void)gotNewFrame; | 64 - (void)gotNewFrame; |
| 54 | 65 |
| 55 @end | 66 @end |
| 56 | 67 |
| 57 #endif // CONTENT_BROWSER_RENDERER_HOST_COMPOSITING_IOSURFACE_LAYER_MAC_H_ | 68 #endif // CONTENT_BROWSER_RENDERER_HOST_COMPOSITING_IOSURFACE_LAYER_MAC_H_ |
| OLD | NEW |