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 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
53 // The ImageTransportSurfaceHelper provides some glue to the outside world: | 53 // The ImageTransportSurfaceHelper provides some glue to the outside world: |
54 // making sure outside events reach the ImageTransportSurface and | 54 // making sure outside events reach the ImageTransportSurface and |
55 // allowing the ImageTransportSurface to send events to the outside world. | 55 // allowing the ImageTransportSurface to send events to the outside world. |
56 | 56 |
57 class ImageTransportSurface { | 57 class ImageTransportSurface { |
58 public: | 58 public: |
59 ImageTransportSurface(); | 59 ImageTransportSurface(); |
60 | 60 |
61 virtual void OnBufferPresented( | 61 virtual void OnBufferPresented( |
62 const AcceleratedSurfaceMsg_BufferPresented_Params& params) = 0; | 62 const AcceleratedSurfaceMsg_BufferPresented_Params& params) = 0; |
63 virtual void OnResizeViewACK() = 0; | |
64 virtual void OnResize(gfx::Size size, float scale_factor) = 0; | 63 virtual void OnResize(gfx::Size size, float scale_factor) = 0; |
65 virtual void SetLatencyInfo( | 64 virtual void SetLatencyInfo( |
66 const std::vector<ui::LatencyInfo>& latency_info) = 0; | 65 const std::vector<ui::LatencyInfo>& latency_info) = 0; |
67 virtual void WakeUpGpu() = 0; | 66 virtual void WakeUpGpu() = 0; |
68 | 67 |
69 // Creates a surface with the given attributes. | 68 // Creates a surface with the given attributes. |
70 static scoped_refptr<gfx::GLSurface> CreateSurface( | 69 static scoped_refptr<gfx::GLSurface> CreateSurface( |
71 GpuChannelManager* manager, | 70 GpuChannelManager* manager, |
72 GpuCommandBufferStub* stub, | 71 GpuCommandBufferStub* stub, |
73 const gfx::GLSurfaceHandle& handle); | 72 const gfx::GLSurfaceHandle& handle); |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
114 // IPC::Listener implementation: | 113 // IPC::Listener implementation: |
115 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; | 114 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; |
116 | 115 |
117 // Helper send functions. Caller fills in the surface specific params | 116 // Helper send functions. Caller fills in the surface specific params |
118 // like size and surface id. The helper fills in the rest. | 117 // like size and surface id. The helper fills in the rest. |
119 void SendAcceleratedSurfaceBuffersSwapped( | 118 void SendAcceleratedSurfaceBuffersSwapped( |
120 GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params params); | 119 GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params params); |
121 void SendAcceleratedSurfacePostSubBuffer( | 120 void SendAcceleratedSurfacePostSubBuffer( |
122 GpuHostMsg_AcceleratedSurfacePostSubBuffer_Params params); | 121 GpuHostMsg_AcceleratedSurfacePostSubBuffer_Params params); |
123 void SendAcceleratedSurfaceRelease(); | 122 void SendAcceleratedSurfaceRelease(); |
124 void SendResizeView(const gfx::Size& size); | |
125 void SendUpdateVSyncParameters( | 123 void SendUpdateVSyncParameters( |
126 base::TimeTicks timebase, base::TimeDelta interval); | 124 base::TimeTicks timebase, base::TimeDelta interval); |
127 | 125 |
128 void SendLatencyInfo(const std::vector<ui::LatencyInfo>& latency_info); | 126 void SendLatencyInfo(const std::vector<ui::LatencyInfo>& latency_info); |
129 | 127 |
130 // Whether or not we should execute more commands. | 128 // Whether or not we should execute more commands. |
131 void SetScheduled(bool is_scheduled); | 129 void SetScheduled(bool is_scheduled); |
132 | 130 |
133 void DeferToFence(base::Closure task); | 131 void DeferToFence(base::Closure task); |
134 | 132 |
(...skipping 11 matching lines...) Expand all Loading... |
146 GpuChannelManager* manager() const { return manager_; } | 144 GpuChannelManager* manager() const { return manager_; } |
147 GpuCommandBufferStub* stub() const { return stub_.get(); } | 145 GpuCommandBufferStub* stub() const { return stub_.get(); } |
148 | 146 |
149 private: | 147 private: |
150 gpu::GpuScheduler* Scheduler(); | 148 gpu::GpuScheduler* Scheduler(); |
151 gpu::gles2::GLES2Decoder* Decoder(); | 149 gpu::gles2::GLES2Decoder* Decoder(); |
152 | 150 |
153 // IPC::Message handlers. | 151 // IPC::Message handlers. |
154 void OnBufferPresented( | 152 void OnBufferPresented( |
155 const AcceleratedSurfaceMsg_BufferPresented_Params& params); | 153 const AcceleratedSurfaceMsg_BufferPresented_Params& params); |
156 void OnResizeViewACK(); | |
157 void OnWakeUpGpu(); | 154 void OnWakeUpGpu(); |
158 | 155 |
159 // Backbuffer resize callback. | 156 // Backbuffer resize callback. |
160 void Resize(gfx::Size size, float scale_factor); | 157 void Resize(gfx::Size size, float scale_factor); |
161 | 158 |
162 void SetLatencyInfo(const std::vector<ui::LatencyInfo>& latency_info); | 159 void SetLatencyInfo(const std::vector<ui::LatencyInfo>& latency_info); |
163 | 160 |
164 // Weak pointers that point to objects that outlive this helper. | 161 // Weak pointers that point to objects that outlive this helper. |
165 ImageTransportSurface* surface_; | 162 ImageTransportSurface* surface_; |
166 GpuChannelManager* manager_; | 163 GpuChannelManager* manager_; |
167 | 164 |
168 base::WeakPtr<GpuCommandBufferStub> stub_; | 165 base::WeakPtr<GpuCommandBufferStub> stub_; |
169 int32 route_id_; | 166 int32 route_id_; |
170 gfx::PluginWindowHandle handle_; | 167 gfx::PluginWindowHandle handle_; |
171 | 168 |
172 DISALLOW_COPY_AND_ASSIGN(ImageTransportHelper); | 169 DISALLOW_COPY_AND_ASSIGN(ImageTransportHelper); |
173 }; | 170 }; |
174 | 171 |
175 // An implementation of ImageTransportSurface that implements GLSurface through | 172 // An implementation of ImageTransportSurface that implements GLSurface through |
176 // GLSurfaceAdapter, thereby forwarding GLSurface methods through to it. | 173 // GLSurfaceAdapter, thereby forwarding GLSurface methods through to it. |
177 class PassThroughImageTransportSurface | 174 class PassThroughImageTransportSurface |
178 : public gfx::GLSurfaceAdapter, | 175 : public gfx::GLSurfaceAdapter, |
179 public ImageTransportSurface { | 176 public ImageTransportSurface { |
180 public: | 177 public: |
181 PassThroughImageTransportSurface(GpuChannelManager* manager, | 178 PassThroughImageTransportSurface(GpuChannelManager* manager, |
182 GpuCommandBufferStub* stub, | 179 GpuCommandBufferStub* stub, |
183 gfx::GLSurface* surface, | 180 gfx::GLSurface* surface); |
184 bool transport); | |
185 | 181 |
186 // GLSurface implementation. | 182 // GLSurface implementation. |
187 virtual bool Initialize() OVERRIDE; | 183 virtual bool Initialize() OVERRIDE; |
188 virtual void Destroy() OVERRIDE; | 184 virtual void Destroy() OVERRIDE; |
189 virtual bool DeferDraws() OVERRIDE; | |
190 virtual bool SwapBuffers() OVERRIDE; | 185 virtual bool SwapBuffers() OVERRIDE; |
191 virtual bool PostSubBuffer(int x, int y, int width, int height) OVERRIDE; | 186 virtual bool PostSubBuffer(int x, int y, int width, int height) OVERRIDE; |
192 virtual bool OnMakeCurrent(gfx::GLContext* context) OVERRIDE; | 187 virtual bool OnMakeCurrent(gfx::GLContext* context) OVERRIDE; |
193 | 188 |
194 // ImageTransportSurface implementation. | 189 // ImageTransportSurface implementation. |
195 virtual void OnBufferPresented( | 190 virtual void OnBufferPresented( |
196 const AcceleratedSurfaceMsg_BufferPresented_Params& params) OVERRIDE; | 191 const AcceleratedSurfaceMsg_BufferPresented_Params& params) OVERRIDE; |
197 virtual void OnResizeViewACK() OVERRIDE; | |
198 virtual void OnResize(gfx::Size size, float scale_factor) OVERRIDE; | 192 virtual void OnResize(gfx::Size size, float scale_factor) OVERRIDE; |
199 virtual gfx::Size GetSize() OVERRIDE; | 193 virtual gfx::Size GetSize() OVERRIDE; |
200 virtual void SetLatencyInfo( | 194 virtual void SetLatencyInfo( |
201 const std::vector<ui::LatencyInfo>& latency_info) OVERRIDE; | 195 const std::vector<ui::LatencyInfo>& latency_info) OVERRIDE; |
202 virtual void WakeUpGpu() OVERRIDE; | 196 virtual void WakeUpGpu() OVERRIDE; |
203 | 197 |
204 protected: | 198 protected: |
205 virtual ~PassThroughImageTransportSurface(); | 199 virtual ~PassThroughImageTransportSurface(); |
206 | 200 |
207 // If updated vsync parameters can be determined, send this information to | 201 // If updated vsync parameters can be determined, send this information to |
208 // the browser. | 202 // the browser. |
209 virtual void SendVSyncUpdateIfAvailable(); | 203 virtual void SendVSyncUpdateIfAvailable(); |
210 | 204 |
211 ImageTransportHelper* GetHelper() { return helper_.get(); } | 205 ImageTransportHelper* GetHelper() { return helper_.get(); } |
212 | 206 |
213 private: | 207 private: |
214 scoped_ptr<ImageTransportHelper> helper_; | 208 scoped_ptr<ImageTransportHelper> helper_; |
215 gfx::Size new_size_; | |
216 bool transport_; | |
217 bool did_set_swap_interval_; | 209 bool did_set_swap_interval_; |
218 bool did_unschedule_; | |
219 bool is_swap_buffers_pending_; | |
220 std::vector<ui::LatencyInfo> latency_info_; | 210 std::vector<ui::LatencyInfo> latency_info_; |
221 | 211 |
222 DISALLOW_COPY_AND_ASSIGN(PassThroughImageTransportSurface); | 212 DISALLOW_COPY_AND_ASSIGN(PassThroughImageTransportSurface); |
223 }; | 213 }; |
224 | 214 |
225 } // namespace content | 215 } // namespace content |
226 | 216 |
227 #endif // CONTENT_COMMON_GPU_IMAGE_TRANSPORT_SURFACE_H_ | 217 #endif // CONTENT_COMMON_GPU_IMAGE_TRANSPORT_SURFACE_H_ |
OLD | NEW |