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