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 13 matching lines...) Expand all Loading... | |
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 void SwapBuffers(const gfx::Size& size, float scale_factor) override; |
32 virtual void WillWriteToBackbuffer() override; | 32 virtual void WillWriteToBackbuffer() override; |
33 virtual void DiscardBackbuffer() override; | 33 virtual void DiscardBackbuffer() override; |
34 virtual void SwapBuffersAckedByBrowser() override; | 34 virtual void SwapBuffersAckedByBrowser(bool disable_throttling) override; |
35 | 35 |
36 // Interface to ImageTransportLayer: | 36 // Interface to ImageTransportLayer: |
37 CGLContextObj LayerShareGroupContext(); | 37 CGLContextObj LayerShareGroupContext(); |
38 bool LayerCanDraw(); | 38 bool LayerCanDraw(); |
39 void LayerDoDraw(); | 39 void LayerDoDraw(); |
40 void LayerResetStorageProvider(); | 40 void LayerResetStorageProvider(); |
41 | 41 |
42 private: | 42 private: |
43 void DrawWithVsyncDisabled(); | 43 void DrawImmediatelyAndUnblockBrowser(); |
44 void SendPendingSwapToBrowserAfterFrameDrawn(); | 44 |
45 // The browser will be blocked while there is a frame that was sent to it but | |
46 // hasn't drawn yet. This call will un-block the browser. | |
47 void UnblockBrowserIfNeeded(); | |
45 | 48 |
46 ImageTransportSurfaceFBO* transport_surface_; | 49 ImageTransportSurfaceFBO* transport_surface_; |
47 | 50 |
48 // Used to determine if we should use setNeedsDisplay or setAsynchronous to | 51 // Used to determine if we should use setNeedsDisplay or setAsynchronous to |
49 // animate. | 52 // animate. |
50 const bool gpu_vsync_disabled_; | 53 const bool gpu_vsync_disabled_; |
51 | 54 |
55 // Used also to determine if we should wait for CoreAnimation to call our | |
56 // drawInCGLContext, or if we should force it with displayIfNeeded. | |
57 bool throttling_disabled_; | |
58 | |
52 // Set when a new swap occurs, and un-set when |layer_| draws that frame. | 59 // Set when a new swap occurs, and un-set when |layer_| draws that frame. |
53 bool has_pending_draw_; | 60 bool has_pending_draw_; |
54 | 61 |
62 // Weak factory against which a timeout task for forcing a draw is created. | |
63 base::WeakPtrFactory<CALayerStorageProvider> pending_draw_weak_factory_; | |
piman
2014/10/08 01:22:15
Why not keep as last member? It's usually done to
ccameron
2014/10/08 18:44:00
Moved back (thought to put it next to pending_draw
| |
64 | |
55 // A counter that is incremented whenever LayerCanDraw returns false. If this | 65 // A counter that is incremented whenever LayerCanDraw returns false. If this |
56 // reaches a threshold, then |layer_| is switched to synchronous drawing to | 66 // reaches a threshold, then |layer_| is switched to synchronous drawing to |
57 // save CPU work. | 67 // save CPU work. |
58 uint32 can_draw_returned_false_count_; | 68 uint32 can_draw_returned_false_count_; |
59 | 69 |
60 // The texture with the pixels to draw, and the share group it is allocated | 70 // The texture with the pixels to draw, and the share group it is allocated |
61 // in. | 71 // in. |
62 base::ScopedTypeRef<CGLContextObj> share_group_context_; | 72 base::ScopedTypeRef<CGLContextObj> share_group_context_; |
63 GLuint fbo_texture_; | 73 GLuint fbo_texture_; |
64 gfx::Size fbo_pixel_size_; | 74 gfx::Size fbo_pixel_size_; |
65 float fbo_scale_factor_; | 75 float fbo_scale_factor_; |
66 | 76 |
67 // The CALayer that the current frame is being drawn into. | 77 // The CALayer that the current frame is being drawn into. |
68 base::scoped_nsobject<CAContext> context_; | 78 base::scoped_nsobject<CAContext> context_; |
69 base::scoped_nsobject<ImageTransportLayer> layer_; | 79 base::scoped_nsobject<ImageTransportLayer> layer_; |
70 | 80 |
71 base::WeakPtrFactory<CALayerStorageProvider> weak_factory_; | |
72 DISALLOW_COPY_AND_ASSIGN(CALayerStorageProvider); | 81 DISALLOW_COPY_AND_ASSIGN(CALayerStorageProvider); |
73 }; | 82 }; |
74 | 83 |
75 } // namespace content | 84 } // namespace content |
76 | 85 |
77 #endif // CONTENT_COMMON_GPU_IMAGE_TRANSPORT_CALAYER_MAC_H_ | 86 #endif // CONTENT_COMMON_GPU_IMAGE_TRANSPORT_CALAYER_MAC_H_ |
OLD | NEW |