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 #if defined(ENABLE_GPU) | 5 #if defined(ENABLE_GPU) |
6 | 6 |
7 #include "content/common/gpu/image_transport_surface.h" | 7 #include "content/common/gpu/image_transport_surface.h" |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
165 scheduler->DeferToFence(task); | 165 scheduler->DeferToFence(task); |
166 } | 166 } |
167 | 167 |
168 bool ImageTransportHelper::MakeCurrent() { | 168 bool ImageTransportHelper::MakeCurrent() { |
169 gpu::gles2::GLES2Decoder* decoder = Decoder(); | 169 gpu::gles2::GLES2Decoder* decoder = Decoder(); |
170 if (!decoder) | 170 if (!decoder) |
171 return false; | 171 return false; |
172 return decoder->MakeCurrent(); | 172 return decoder->MakeCurrent(); |
173 } | 173 } |
174 | 174 |
175 void ImageTransportHelper::SetSwapInterval() { | 175 void ImageTransportHelper::SetSwapInterval(gfx::GLContext* context) { |
176 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kDisableGpuVsync)) | 176 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kDisableGpuVsync)) |
177 Decoder()->GetGLContext()->SetSwapInterval(0); | 177 context->SetSwapInterval(0); |
178 else | 178 else |
179 Decoder()->GetGLContext()->SetSwapInterval(1); | 179 context->SetSwapInterval(1); |
180 } | 180 } |
181 | 181 |
182 void ImageTransportHelper::Suspend() { | 182 void ImageTransportHelper::Suspend() { |
183 manager_->Send(new GpuHostMsg_AcceleratedSurfaceSuspend(stub_->surface_id())); | 183 manager_->Send(new GpuHostMsg_AcceleratedSurfaceSuspend(stub_->surface_id())); |
184 } | 184 } |
185 | 185 |
186 gpu::GpuScheduler* ImageTransportHelper::Scheduler() { | 186 gpu::GpuScheduler* ImageTransportHelper::Scheduler() { |
187 if (!stub_.get()) | 187 if (!stub_.get()) |
188 return NULL; | 188 return NULL; |
189 return stub_->scheduler(); | 189 return stub_->scheduler(); |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
223 #endif | 223 #endif |
224 | 224 |
225 surface_->OnResize(size); | 225 surface_->OnResize(size); |
226 | 226 |
227 #if defined(OS_ANDROID) | 227 #if defined(OS_ANDROID) |
228 manager_->gpu_memory_manager()->ScheduleManage(); | 228 manager_->gpu_memory_manager()->ScheduleManage(); |
229 #endif | 229 #endif |
230 | 230 |
231 #if defined(OS_WIN) | 231 #if defined(OS_WIN) |
232 Decoder()->MakeCurrent(); | 232 Decoder()->MakeCurrent(); |
233 SetSwapInterval(); | 233 SetSwapInterval(Decoder()->GetGLContext()); |
234 #endif | 234 #endif |
235 } | 235 } |
236 | 236 |
237 PassThroughImageTransportSurface::PassThroughImageTransportSurface( | 237 PassThroughImageTransportSurface::PassThroughImageTransportSurface( |
238 GpuChannelManager* manager, | 238 GpuChannelManager* manager, |
239 GpuCommandBufferStub* stub, | 239 GpuCommandBufferStub* stub, |
240 gfx::GLSurface* surface, | 240 gfx::GLSurface* surface, |
241 bool transport) | 241 bool transport) |
242 : GLSurfaceAdapter(surface), | 242 : GLSurfaceAdapter(surface), |
243 transport_(transport), | 243 transport_(transport), |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
291 params.height = height; | 291 params.height = height; |
292 helper_->SendAcceleratedSurfacePostSubBuffer(params); | 292 helper_->SendAcceleratedSurfacePostSubBuffer(params); |
293 | 293 |
294 helper_->SetScheduled(false); | 294 helper_->SetScheduled(false); |
295 } | 295 } |
296 return result; | 296 return result; |
297 } | 297 } |
298 | 298 |
299 bool PassThroughImageTransportSurface::OnMakeCurrent(gfx::GLContext* context) { | 299 bool PassThroughImageTransportSurface::OnMakeCurrent(gfx::GLContext* context) { |
300 if (!did_set_swap_interval_) { | 300 if (!did_set_swap_interval_) { |
301 helper_->SetSwapInterval(); | 301 ImageTransportHelper::SetSwapInterval(context); |
302 did_set_swap_interval_ = true; | 302 did_set_swap_interval_ = true; |
303 } | 303 } |
304 return true; | 304 return true; |
305 } | 305 } |
306 | 306 |
307 void PassThroughImageTransportSurface::OnNewSurfaceACK( | 307 void PassThroughImageTransportSurface::OnNewSurfaceACK( |
308 uint64 surface_handle, | 308 uint64 surface_handle, |
309 TransportDIB::Handle shm_handle) { | 309 TransportDIB::Handle shm_handle) { |
310 } | 310 } |
311 | 311 |
(...skipping 21 matching lines...) Expand all Loading... |
333 helper_->SendResizeView(size); | 333 helper_->SendResizeView(size); |
334 helper_->SetScheduled(false); | 334 helper_->SetScheduled(false); |
335 } else { | 335 } else { |
336 Resize(new_size_); | 336 Resize(new_size_); |
337 } | 337 } |
338 } | 338 } |
339 | 339 |
340 PassThroughImageTransportSurface::~PassThroughImageTransportSurface() {} | 340 PassThroughImageTransportSurface::~PassThroughImageTransportSurface() {} |
341 | 341 |
342 #endif // defined(ENABLE_GPU) | 342 #endif // defined(ENABLE_GPU) |
OLD | NEW |