OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_H_ | 5 #ifndef CONTENT_COMMON_GPU_IMAGE_TRANSPORT_SURFACE_H_ |
6 #define CONTENT_COMMON_GPU_IMAGE_TRANSPORT_SURFACE_H_ | 6 #define CONTENT_COMMON_GPU_IMAGE_TRANSPORT_SURFACE_H_ |
7 | 7 |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/callback.h" | 10 #include "base/callback.h" |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
59 public: | 59 public: |
60 ImageTransportSurface(); | 60 ImageTransportSurface(); |
61 | 61 |
62 #if defined(OS_MACOSX) | 62 #if defined(OS_MACOSX) |
63 virtual void OnBufferPresented( | 63 virtual void OnBufferPresented( |
64 const AcceleratedSurfaceMsg_BufferPresented_Params& params) = 0; | 64 const AcceleratedSurfaceMsg_BufferPresented_Params& params) = 0; |
65 #endif | 65 #endif |
66 virtual void OnResize(gfx::Size size, float scale_factor) = 0; | 66 virtual void OnResize(gfx::Size size, float scale_factor) = 0; |
67 virtual void SetLatencyInfo( | 67 virtual void SetLatencyInfo( |
68 const std::vector<ui::LatencyInfo>& latency_info) = 0; | 68 const std::vector<ui::LatencyInfo>& latency_info) = 0; |
69 virtual void WakeUpGpu() = 0; | |
70 | 69 |
71 // Creates a surface with the given attributes. | 70 // Creates a surface with the given attributes. |
72 static scoped_refptr<gfx::GLSurface> CreateSurface( | 71 static scoped_refptr<gfx::GLSurface> CreateSurface( |
73 GpuChannelManager* manager, | 72 GpuChannelManager* manager, |
74 GpuCommandBufferStub* stub, | 73 GpuCommandBufferStub* stub, |
75 const gfx::GLSurfaceHandle& handle); | 74 const gfx::GLSurfaceHandle& handle); |
76 | 75 |
77 #if defined(OS_MACOSX) | 76 #if defined(OS_MACOSX) |
78 CONTENT_EXPORT static void SetAllowOSMesaForTesting(bool allow); | 77 CONTENT_EXPORT static void SetAllowOSMesaForTesting(bool allow); |
79 #endif | 78 #endif |
80 | 79 |
81 virtual gfx::Size GetSize() = 0; | 80 virtual gfx::Size GetSize() = 0; |
82 | 81 |
83 protected: | 82 protected: |
84 virtual ~ImageTransportSurface(); | 83 virtual ~ImageTransportSurface(); |
85 | 84 |
86 private: | 85 private: |
87 // Creates the appropriate native surface depending on the GL implementation. | 86 // Creates the appropriate native surface depending on the GL implementation. |
88 // This will be implemented separately by each platform. | 87 // This will be implemented separately by each platform. |
89 // | 88 // |
90 // This will not be called for texture transport surfaces which are | 89 // This will not be called for texture transport surfaces which are |
91 // cross-platform. The platform implementation should only create the | 90 // cross-platform. The platform implementation should only create the |
92 // surface and should not initialize it. On failure, a null scoped_refptr | 91 // surface and should not initialize it. On failure, a null scoped_refptr |
93 // should be returned. | 92 // should be returned. |
94 static scoped_refptr<gfx::GLSurface> CreateNativeSurface( | 93 static scoped_refptr<gfx::GLSurface> CreateNativeSurface( |
95 GpuChannelManager* manager, | 94 GpuChannelManager* manager, |
96 GpuCommandBufferStub* stub, | 95 GpuCommandBufferStub* stub, |
97 const gfx::GLSurfaceHandle& handle); | 96 const gfx::GLSurfaceHandle& handle); |
98 | 97 |
99 #if defined(OS_ANDROID) | |
100 static scoped_refptr<gfx::GLSurface> CreateTransportSurface( | |
101 GpuChannelManager* manager, | |
102 GpuCommandBufferStub* stub, | |
103 const gfx::GLSurfaceHandle& handle); | |
104 #endif | |
105 | |
106 DISALLOW_COPY_AND_ASSIGN(ImageTransportSurface); | 98 DISALLOW_COPY_AND_ASSIGN(ImageTransportSurface); |
107 }; | 99 }; |
108 | 100 |
109 class ImageTransportHelper | 101 class ImageTransportHelper |
110 : public IPC::Listener, | 102 : public IPC::Listener, |
111 public base::SupportsWeakPtr<ImageTransportHelper> { | 103 public base::SupportsWeakPtr<ImageTransportHelper> { |
112 public: | 104 public: |
113 // Takes weak pointers to objects that outlive the helper. | 105 // Takes weak pointers to objects that outlive the helper. |
114 ImageTransportHelper(ImageTransportSurface* surface, | 106 ImageTransportHelper(ImageTransportSurface* surface, |
115 GpuChannelManager* manager, | 107 GpuChannelManager* manager, |
(...skipping 26 matching lines...) Expand all Loading... |
142 GpuCommandBufferStub* stub() const { return stub_.get(); } | 134 GpuCommandBufferStub* stub() const { return stub_.get(); } |
143 | 135 |
144 private: | 136 private: |
145 gpu::gles2::GLES2Decoder* Decoder(); | 137 gpu::gles2::GLES2Decoder* Decoder(); |
146 | 138 |
147 // IPC::Message handlers. | 139 // IPC::Message handlers. |
148 #if defined(OS_MACOSX) | 140 #if defined(OS_MACOSX) |
149 void OnBufferPresented( | 141 void OnBufferPresented( |
150 const AcceleratedSurfaceMsg_BufferPresented_Params& params); | 142 const AcceleratedSurfaceMsg_BufferPresented_Params& params); |
151 #endif | 143 #endif |
152 void OnWakeUpGpu(); | |
153 | 144 |
154 // Backbuffer resize callback. | 145 // Backbuffer resize callback. |
155 void Resize(gfx::Size size, float scale_factor); | 146 void Resize(gfx::Size size, float scale_factor); |
156 | 147 |
157 void SetLatencyInfo(const std::vector<ui::LatencyInfo>& latency_info); | 148 void SetLatencyInfo(const std::vector<ui::LatencyInfo>& latency_info); |
158 | 149 |
159 // Weak pointers that point to objects that outlive this helper. | 150 // Weak pointers that point to objects that outlive this helper. |
160 ImageTransportSurface* surface_; | 151 ImageTransportSurface* surface_; |
161 GpuChannelManager* manager_; | 152 GpuChannelManager* manager_; |
162 | 153 |
(...skipping 23 matching lines...) Expand all Loading... |
186 | 177 |
187 // ImageTransportSurface implementation. | 178 // ImageTransportSurface implementation. |
188 #if defined(OS_MACOSX) | 179 #if defined(OS_MACOSX) |
189 void OnBufferPresented( | 180 void OnBufferPresented( |
190 const AcceleratedSurfaceMsg_BufferPresented_Params& params) override; | 181 const AcceleratedSurfaceMsg_BufferPresented_Params& params) override; |
191 #endif | 182 #endif |
192 void OnResize(gfx::Size size, float scale_factor) override; | 183 void OnResize(gfx::Size size, float scale_factor) override; |
193 gfx::Size GetSize() override; | 184 gfx::Size GetSize() override; |
194 void SetLatencyInfo( | 185 void SetLatencyInfo( |
195 const std::vector<ui::LatencyInfo>& latency_info) override; | 186 const std::vector<ui::LatencyInfo>& latency_info) override; |
196 void WakeUpGpu() override; | |
197 | 187 |
198 protected: | 188 protected: |
199 ~PassThroughImageTransportSurface() override; | 189 ~PassThroughImageTransportSurface() override; |
200 | 190 |
201 // If updated vsync parameters can be determined, send this information to | 191 // If updated vsync parameters can be determined, send this information to |
202 // the browser. | 192 // the browser. |
203 virtual void SendVSyncUpdateIfAvailable(); | 193 virtual void SendVSyncUpdateIfAvailable(); |
204 void SwapBuffersCallBack(std::vector<ui::LatencyInfo>* latency_info_ptr, | 194 void SwapBuffersCallBack(std::vector<ui::LatencyInfo>* latency_info_ptr, |
205 gfx::SwapResult result); | 195 gfx::SwapResult result); |
206 | 196 |
207 ImageTransportHelper* GetHelper() { return helper_.get(); } | 197 ImageTransportHelper* GetHelper() { return helper_.get(); } |
208 | 198 |
209 private: | 199 private: |
210 scoped_ptr<ImageTransportHelper> helper_; | 200 scoped_ptr<ImageTransportHelper> helper_; |
211 bool did_set_swap_interval_; | 201 bool did_set_swap_interval_; |
212 std::vector<ui::LatencyInfo> latency_info_; | 202 std::vector<ui::LatencyInfo> latency_info_; |
213 base::WeakPtrFactory<PassThroughImageTransportSurface> weak_ptr_factory_; | 203 base::WeakPtrFactory<PassThroughImageTransportSurface> weak_ptr_factory_; |
214 | 204 |
215 DISALLOW_COPY_AND_ASSIGN(PassThroughImageTransportSurface); | 205 DISALLOW_COPY_AND_ASSIGN(PassThroughImageTransportSurface); |
216 }; | 206 }; |
217 | 207 |
218 } // namespace content | 208 } // namespace content |
219 | 209 |
220 #endif // CONTENT_COMMON_GPU_IMAGE_TRANSPORT_SURFACE_H_ | 210 #endif // CONTENT_COMMON_GPU_IMAGE_TRANSPORT_SURFACE_H_ |
OLD | NEW |