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 <deque> | |
9 #include <IOSurface/IOSurface.h> | |
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...) Expand all 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 struct PendingSwap { | |
tapted
2015/08/05 07:55:56
Since it's private, you could forward declare this
ccameron
2015/08/05 21:00:42
Done.
| |
57 PendingSwap(); | |
58 ~PendingSwap(); | |
59 // The IOSurface with new content for this swap. | |
60 base::ScopedCFTypeRef<IOSurfaceRef> io_surface; | |
61 | |
62 // A fence object, and the CGL context it was issued in. | |
63 base::ScopedTypeRef<CGLContextObj> cgl_context; | |
64 GLuint fence; | |
tapted
2015/08/05 07:55:57
could this be a scoped_ptr<GLFence>? (or GLFenceAP
ccameron
2015/08/05 21:00:43
I'll use a GLFenceAPPLE.
I don't really trust the
| |
65 | |
66 // The size of the full frame, in dip. | |
67 gfx::Size dip_size; | |
68 }; | |
69 | |
50 ~ImageTransportSurfaceOverlayMac() override; | 70 ~ImageTransportSurfaceOverlayMac() override; |
71 | |
72 gfx::SwapResult SwapBuffersInternal(const gfx::Rect& pixel_damage_rect); | |
73 | |
74 // Check the oldest swap in |pending_swaps_|, and, if its fence has passed, | |
75 // send the content to the window server by -[CALayer setContents:]. If | |
tapted
2015/08/05 07:55:56
If... (sentence fragment)
ccameron
2015/08/05 21:00:42
Meant to discuss force_immediate_display. Added.
| |
76 void CheckAndDisplayPendingSwaps(bool force_immediate_display); | |
77 | |
78 // Post a call to CheckAndDisplayPendingSwaps at the next midpoint of a | |
tapted
2015/08/05 07:55:57
optional: I usually see "Foo()" in comments to ref
ccameron
2015/08/05 21:00:42
Good point. If the style guide has a remark on thi
| |
79 // vsync period. | |
80 void PostCheckAndDisplayPendingSwaps(); | |
81 | |
51 scoped_ptr<ImageTransportHelper> helper_; | 82 scoped_ptr<ImageTransportHelper> helper_; |
52 base::scoped_nsobject<CAContext> ca_context_; | 83 base::scoped_nsobject<CAContext> ca_context_; |
53 base::scoped_nsobject<CALayer> layer_; | 84 base::scoped_nsobject<CALayer> layer_; |
54 | 85 |
55 // A phony NSView handle used to identify this. | |
56 gfx::AcceleratedWidget widget_; | |
57 | |
58 gfx::Size pixel_size_; | 86 gfx::Size pixel_size_; |
59 float scale_factor_; | 87 float scale_factor_; |
60 std::vector<ui::LatencyInfo> latency_info_; | 88 std::vector<ui::LatencyInfo> latency_info_; |
61 | 89 |
62 // Weak pointer to the image provided when ScheduleOverlayPlane is called. Is | 90 // Weak pointer to the image provided when ScheduleOverlayPlane is called. Is |
63 // consumed and reset when SwapBuffers is called. For now, only one overlay | 91 // consumed and reset when SwapBuffers is called. For now, only one overlay |
64 // plane is supported. | 92 // plane is supported. |
65 gfx::GLImage* pending_overlay_image_; | 93 gfx::GLImage* pending_overlay_image_; |
94 | |
95 // A queue of all frames that have been created by SwapBuffersInternal but | |
96 // have not yet been displayed by CheckAndDisplayPendingSwaps. | |
97 std::deque<PendingSwap> pending_swaps_; | |
98 | |
99 // The display link used to compute the delay for the posted task in | |
100 // PostCheckAndDisplayPendingSwaps. | |
101 scoped_refptr<ui::DisplayLinkMac> display_link_mac_; | |
102 | |
103 base::WeakPtrFactory<ImageTransportSurfaceOverlayMac> weak_factory_; | |
66 }; | 104 }; |
67 | 105 |
68 } // namespace content | 106 } // namespace content |
69 | 107 |
70 #endif // CONTENT_COMMON_GPU_IMAGE_TRANSPORT_SURFACE_OVERLAY_MAC_H_ | 108 #endif // CONTENT_COMMON_GPU_IMAGE_TRANSPORT_SURFACE_OVERLAY_MAC_H_ |
OLD | NEW |