OLD | NEW |
---|---|
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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_OVERLAY_MAC_H_ | 5 #ifndef CONTENT_COMMON_GPU_IMAGE_TRANSPORT_SURFACE_OVERLAY_MAC_H_ |
6 #define CONTENT_COMMON_GPU_IMAGE_TRANSPORT_SURFACE_OVERLAY_MAC_H_ | 6 #define CONTENT_COMMON_GPU_IMAGE_TRANSPORT_SURFACE_OVERLAY_MAC_H_ |
7 | 7 |
8 #include <list> | |
9 | |
8 #import "base/mac/scoped_nsobject.h" | 10 #import "base/mac/scoped_nsobject.h" |
9 #include "content/common/gpu/gpu_command_buffer_stub.h" | 11 #include "content/common/gpu/gpu_command_buffer_stub.h" |
10 #include "content/common/gpu/image_transport_surface.h" | 12 #include "content/common/gpu/image_transport_surface.h" |
13 #include "ui/accelerated_widget_mac/display_link_mac.h" | |
11 #include "ui/gl/gl_surface.h" | 14 #include "ui/gl/gl_surface.h" |
12 | 15 |
13 @class CAContext; | 16 @class CAContext; |
14 @class CALayer; | 17 @class CALayer; |
15 | 18 |
16 namespace content { | 19 namespace content { |
17 | 20 |
18 class ImageTransportSurfaceOverlayMac : public gfx::GLSurface, | 21 class ImageTransportSurfaceOverlayMac : public gfx::GLSurface, |
19 public ImageTransportSurface { | 22 public ImageTransportSurface { |
20 public: | 23 public: |
(...skipping 19 matching lines...) Expand all Loading... | |
40 bool IsSurfaceless() const override; | 43 bool IsSurfaceless() const override; |
41 | 44 |
42 // ImageTransportSurface implementation | 45 // ImageTransportSurface implementation |
43 void OnBufferPresented( | 46 void OnBufferPresented( |
44 const AcceleratedSurfaceMsg_BufferPresented_Params& params) override; | 47 const AcceleratedSurfaceMsg_BufferPresented_Params& params) override; |
45 void OnResize(gfx::Size pixel_size, float scale_factor) override; | 48 void OnResize(gfx::Size pixel_size, float scale_factor) override; |
46 void SetLatencyInfo(const std::vector<ui::LatencyInfo>&) override; | 49 void SetLatencyInfo(const std::vector<ui::LatencyInfo>&) override; |
47 void WakeUpGpu() override; | 50 void WakeUpGpu() override; |
48 | 51 |
49 private: | 52 private: |
53 class PendingSwap; | |
54 | |
50 ~ImageTransportSurfaceOverlayMac() override; | 55 ~ImageTransportSurfaceOverlayMac() override; |
56 | |
57 gfx::SwapResult SwapBuffersInternal(const gfx::Rect& pixel_damage_rect); | |
58 | |
59 // Check the oldest swap in |pending_swaps_|, and, if its fence has passed, | |
60 // send the content to the window server by -[CALayer setContents:]. If | |
61 // |force_immediate_display| is true then skip the fence check and immediately | |
62 // call -[CALayer setContents:]. | |
63 void CheckAndDisplayPendingSwaps(bool force_immediate_display); | |
64 | |
65 // Post a call to CheckAndDisplayPendingSwaps at the next midpoint of a | |
66 // vsync period. | |
67 void PostCheckAndDisplayPendingSwaps(); | |
68 | |
69 // Force all pending swaps to display immediately. | |
70 void FinishAllPendingSwaps(); | |
71 | |
51 scoped_ptr<ImageTransportHelper> helper_; | 72 scoped_ptr<ImageTransportHelper> helper_; |
52 base::scoped_nsobject<CAContext> ca_context_; | 73 base::scoped_nsobject<CAContext> ca_context_; |
53 base::scoped_nsobject<CALayer> layer_; | 74 base::scoped_nsobject<CALayer> layer_; |
54 | 75 |
55 // A phony NSView handle used to identify this. | |
56 gfx::AcceleratedWidget widget_; | |
57 | |
58 gfx::Size pixel_size_; | 76 gfx::Size pixel_size_; |
59 float scale_factor_; | 77 float scale_factor_; |
60 std::vector<ui::LatencyInfo> latency_info_; | 78 std::vector<ui::LatencyInfo> latency_info_; |
61 | 79 |
62 // Weak pointer to the image provided when ScheduleOverlayPlane is called. Is | 80 // Weak pointer to the image provided when ScheduleOverlayPlane is called. Is |
63 // consumed and reset when SwapBuffers is called. For now, only one overlay | 81 // consumed and reset when SwapBuffers is called. For now, only one overlay |
64 // plane is supported. | 82 // plane is supported. |
65 gfx::GLImage* pending_overlay_image_; | 83 gfx::GLImage* pending_overlay_image_; |
84 | |
85 // A queue of all frames that have been created by SwapBuffersInternal but | |
86 // have not yet been displayed by CheckAndDisplayPendingSwaps. | |
87 std::list<scoped_refptr<PendingSwap>> pending_swaps_; | |
dcheng
2015/08/07 00:28:37
How about using linked_ptr instead of refcounting?
ccameron
2015/08/07 22:14:16
Done.
| |
88 | |
89 // The display link used to compute the delay for the posted task in | |
90 // PostCheckAndDisplayPendingSwaps. | |
91 scoped_refptr<ui::DisplayLinkMac> display_link_mac_; | |
92 | |
93 base::WeakPtrFactory<ImageTransportSurfaceOverlayMac> weak_factory_; | |
66 }; | 94 }; |
67 | 95 |
68 } // namespace content | 96 } // namespace content |
69 | 97 |
70 #endif // CONTENT_COMMON_GPU_IMAGE_TRANSPORT_SURFACE_OVERLAY_MAC_H_ | 98 #endif // CONTENT_COMMON_GPU_IMAGE_TRANSPORT_SURFACE_OVERLAY_MAC_H_ |
OLD | NEW |