| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_COMMON_GPU_IMAGE_TRANSPORT_SURFACE_CALAYER_MAC_H_ | 5 #ifndef CONTENT_COMMON_GPU_IMAGE_TRANSPORT_SURFACE_CALAYER_MAC_H_ |
| 6 #define CONTENT_COMMON_GPU_IMAGE_TRANSPORT_SURFACE_CALAYER_MAC_H_ | 6 #define CONTENT_COMMON_GPU_IMAGE_TRANSPORT_SURFACE_CALAYER_MAC_H_ |
| 7 | 7 |
| 8 #include "base/mac/scoped_nsobject.h" | 8 #include "base/mac/scoped_nsobject.h" |
| 9 #include "content/common/gpu/image_transport_surface_fbo_mac.h" | 9 #include "content/common/gpu/image_transport_surface_fbo_mac.h" |
| 10 #include "ui/base/cocoa/remote_layer_api.h" | 10 #include "ui/base/cocoa/remote_layer_api.h" |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 public: | 21 public: |
| 22 CALayerStorageProvider(ImageTransportSurfaceFBO* transport_surface); | 22 CALayerStorageProvider(ImageTransportSurfaceFBO* transport_surface); |
| 23 virtual ~CALayerStorageProvider(); | 23 virtual ~CALayerStorageProvider(); |
| 24 | 24 |
| 25 // ImageTransportSurfaceFBO::StorageProvider implementation: | 25 // ImageTransportSurfaceFBO::StorageProvider implementation: |
| 26 virtual gfx::Size GetRoundedSize(gfx::Size size) OVERRIDE; | 26 virtual gfx::Size GetRoundedSize(gfx::Size size) OVERRIDE; |
| 27 virtual bool AllocateColorBufferStorage( | 27 virtual bool AllocateColorBufferStorage( |
| 28 CGLContextObj context, GLuint texture, | 28 CGLContextObj context, GLuint texture, |
| 29 gfx::Size pixel_size, float scale_factor) OVERRIDE; | 29 gfx::Size pixel_size, float scale_factor) OVERRIDE; |
| 30 virtual void FreeColorBufferStorage() OVERRIDE; | 30 virtual void FreeColorBufferStorage() OVERRIDE; |
| 31 virtual void SwapBuffers(const gfx::Size& size, float scale_factor) OVERRIDE; | 31 virtual uint64 GetSurfaceHandle() const OVERRIDE; |
| 32 virtual void WillWriteToBackbuffer() OVERRIDE; | 32 virtual void WillSwapBuffers() OVERRIDE; |
| 33 virtual void DiscardBackbuffer() OVERRIDE; | 33 virtual void CanFreeSwappedBuffer() OVERRIDE; |
| 34 virtual void SwapBuffersAckedByBrowser() OVERRIDE; | |
| 35 | 34 |
| 36 // Interface to ImageTransportLayer: | 35 // Interface to ImageTransportLayer: |
| 37 CGLContextObj LayerShareGroupContext(); | 36 CGLContextObj LayerShareGroupContext(); |
| 38 bool LayerCanDraw(); | 37 bool LayerCanDraw(); |
| 39 void LayerDoDraw(); | 38 void LayerDoDraw(); |
| 40 void LayerResetStorageProvider(); | |
| 41 | 39 |
| 42 private: | 40 private: |
| 43 void DrawWithVsyncDisabled(); | |
| 44 void SendPendingSwapToBrowserAfterFrameDrawn(); | |
| 45 | |
| 46 ImageTransportSurfaceFBO* transport_surface_; | 41 ImageTransportSurfaceFBO* transport_surface_; |
| 47 | 42 |
| 48 // Used to determine if we should use setNeedsDisplay or setAsynchronous to | |
| 49 // animate. | |
| 50 const bool gpu_vsync_disabled_; | |
| 51 | |
| 52 // Set when a new swap occurs, and un-set when |layer_| draws that frame. | 43 // Set when a new swap occurs, and un-set when |layer_| draws that frame. |
| 53 bool has_pending_draw_; | 44 bool has_pending_draw_; |
| 54 | 45 |
| 55 // A counter that is incremented whenever LayerCanDraw returns false. If this | 46 // A counter that is incremented whenever LayerCanDraw returns false. If this |
| 56 // reaches a threshold, then |layer_| is switched to synchronous drawing to | 47 // reaches a threshold, then |layer_| is switched to synchronous drawing to |
| 57 // save CPU work. | 48 // save CPU work. |
| 58 uint32 can_draw_returned_false_count_; | 49 uint32 can_draw_returned_false_count_; |
| 59 | 50 |
| 60 // The texture with the pixels to draw, and the share group it is allocated | 51 // The texture with the pixels to draw, and the share group it is allocated |
| 61 // in. | 52 // in. |
| 62 base::ScopedTypeRef<CGLContextObj> share_group_context_; | 53 base::ScopedTypeRef<CGLContextObj> share_group_context_; |
| 63 GLuint fbo_texture_; | 54 GLuint fbo_texture_; |
| 64 gfx::Size fbo_pixel_size_; | 55 gfx::Size fbo_pixel_size_; |
| 65 float fbo_scale_factor_; | |
| 66 | 56 |
| 67 // The CALayer that the current frame is being drawn into. | 57 // The CALayer that the current frame is being drawn into. |
| 68 base::scoped_nsobject<CAContext> context_; | 58 base::scoped_nsobject<CAContext> context_; |
| 69 base::scoped_nsobject<ImageTransportLayer> layer_; | 59 base::scoped_nsobject<ImageTransportLayer> layer_; |
| 70 | 60 |
| 71 base::WeakPtrFactory<CALayerStorageProvider> weak_factory_; | |
| 72 DISALLOW_COPY_AND_ASSIGN(CALayerStorageProvider); | 61 DISALLOW_COPY_AND_ASSIGN(CALayerStorageProvider); |
| 73 }; | 62 }; |
| 74 | 63 |
| 75 } // namespace content | 64 } // namespace content |
| 76 | 65 |
| 77 #endif // CONTENT_COMMON_GPU_IMAGE_TRANSPORT_CALAYER_MAC_H_ | 66 #endif // CONTENT_COMMON_GPU_IMAGE_TRANSPORT_CALAYER_MAC_H_ |
| OLD | NEW |