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

Side by Side Diff: content/common/gpu/image_transport_surface_calayer_mac.h

Issue 505053002: Fix assorted issues with remote CoreAnimation (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@clean_up_accel_layers
Patch Set: Clean up timer logic Created 6 years, 3 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
OLDNEW
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
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 uint64 GetSurfaceHandle() const OVERRIDE; 31 virtual void DiscardBackbuffer() OVERRIDE;
32 virtual void WillSwapBuffers() OVERRIDE; 32 virtual uint64 SwapBuffersAndGetSurfaceHandle() OVERRIDE;
33 virtual void CanFreeSwappedBuffer() OVERRIDE; 33 virtual void CanFreeSwappedBuffer() OVERRIDE;
34 34
35 // Interface to ImageTransportLayer: 35 // Interface to ImageTransportLayer:
36 CGLContextObj LayerShareGroupContext(); 36 CGLContextObj LayerShareGroupContext();
37 bool LayerCanDraw(); 37 bool LayerCanDraw();
38 void LayerDoDraw(); 38 void LayerDoDraw();
39 void LayerResetStorageProvider();
39 40
40 private: 41 private:
42 void DisplayTimeoutFired();
43 void UnblockIfNeededAfterPendingFrameDrawn();
44
41 ImageTransportSurfaceFBO* transport_surface_; 45 ImageTransportSurfaceFBO* transport_surface_;
42 46
47 // Used to determine if we should use setNeedsDisplay or setAsynchronous to
48 // animate.
49 const bool gpu_vsync_disabled_;
50
43 // Set when a new swap occurs, and un-set when |layer_| draws that frame. 51 // Set when a new swap occurs, and un-set when |layer_| draws that frame.
44 bool has_pending_draw_; 52 bool has_pending_draw_;
45 53
46 // A counter that is incremented whenever LayerCanDraw returns false. If this 54 // A counter that is incremented whenever LayerCanDraw returns false. If this
47 // reaches a threshold, then |layer_| is switched to synchronous drawing to 55 // reaches a threshold, then |layer_| is switched to synchronous drawing to
48 // save CPU work. 56 // save CPU work.
49 uint32 can_draw_returned_false_count_; 57 uint32 can_draw_returned_false_count_;
50 58
51 // The texture with the pixels to draw, and the share group it is allocated 59 // The texture with the pixels to draw, and the share group it is allocated
52 // in. 60 // in.
53 base::ScopedTypeRef<CGLContextObj> share_group_context_; 61 base::ScopedTypeRef<CGLContextObj> share_group_context_;
54 GLuint fbo_texture_; 62 GLuint fbo_texture_;
55 gfx::Size fbo_pixel_size_; 63 gfx::Size fbo_pixel_size_;
64 float fbo_scale_factor_;
56 65
57 // The CALayer that the current frame is being drawn into. 66 // The CALayer that the current frame is being drawn into.
58 base::scoped_nsobject<CAContext> context_; 67 base::scoped_nsobject<CAContext> context_;
59 base::scoped_nsobject<ImageTransportLayer> layer_; 68 base::scoped_nsobject<ImageTransportLayer> layer_;
60 69
70 // CoreAnimation places back-pressure on the browser compositor (which then
71 // places back-pressure on the renderer) by by descheduling the command buffer
72 // until CoreAnimation tells us it's time to draw. Sometimes this callback is
73 // simply skipped, which can lead to hangs. Prevent hangs by always
74 // acknowledging the frame after timeout of 1/6th of a second has passed.
75 base::DelayTimer<CALayerStorageProvider> display_timeout_timer_;
76
61 DISALLOW_COPY_AND_ASSIGN(CALayerStorageProvider); 77 DISALLOW_COPY_AND_ASSIGN(CALayerStorageProvider);
62 }; 78 };
63 79
64 } // namespace content 80 } // namespace content
65 81
66 #endif // CONTENT_COMMON_GPU_IMAGE_TRANSPORT_CALAYER_MAC_H_ 82 #endif // CONTENT_COMMON_GPU_IMAGE_TRANSPORT_CALAYER_MAC_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698