| 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 #include "content/common/gpu/image_transport_surface.h" | 5 #include "content/common/gpu/image_transport_surface.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/trace_event/trace_event.h" | 10 #include "base/trace_event/trace_event.h" |
| 11 #include "content/common/gpu/gpu_channel.h" | 11 #include "content/common/gpu/gpu_channel.h" |
| 12 #include "content/common/gpu/gpu_channel_manager.h" | 12 #include "content/common/gpu/gpu_channel_manager.h" |
| 13 #include "content/common/gpu/gpu_command_buffer_stub.h" | 13 #include "content/common/gpu/gpu_command_buffer_stub.h" |
| 14 #include "content/common/gpu/gpu_messages.h" | 14 #include "content/common/gpu/gpu_messages.h" |
| 15 #include "content/public/common/content_switches.h" | |
| 16 #include "gpu/command_buffer/service/sync_point_manager.h" | 15 #include "gpu/command_buffer/service/sync_point_manager.h" |
| 17 #include "ui/gfx/vsync_provider.h" | 16 #include "ui/gfx/vsync_provider.h" |
| 18 #include "ui/gl/gl_context.h" | 17 #include "ui/gl/gl_context.h" |
| 19 #include "ui/gl/gl_implementation.h" | 18 #include "ui/gl/gl_implementation.h" |
| 20 #include "ui/gl/gl_switches.h" | 19 #include "ui/gl/gl_switches.h" |
| 21 | 20 |
| 22 namespace content { | 21 namespace content { |
| 23 | 22 |
| 24 ImageTransportSurface::ImageTransportSurface() {} | 23 ImageTransportSurface::ImageTransportSurface() {} |
| 25 | 24 |
| 26 ImageTransportSurface::~ImageTransportSurface() {} | 25 ImageTransportSurface::~ImageTransportSurface() {} |
| 27 | 26 |
| 28 scoped_refptr<gfx::GLSurface> ImageTransportSurface::CreateSurface( | 27 scoped_refptr<gfx::GLSurface> ImageTransportSurface::CreateSurface( |
| 29 GpuChannelManager* manager, | 28 GpuChannelManager* manager, |
| 30 GpuCommandBufferStub* stub, | 29 GpuCommandBufferStub* stub, |
| 31 const gfx::GLSurfaceHandle& handle) { | 30 const gfx::GLSurfaceHandle& handle) { |
| 32 scoped_refptr<gfx::GLSurface> surface; | 31 scoped_refptr<gfx::GLSurface> surface; |
| 33 if (handle.transport_type == gfx::NULL_TRANSPORT) { | 32 if (handle.transport_type == gfx::NULL_TRANSPORT) { |
| 34 GpuChannel* parent_channel = manager->LookupChannel( | |
| 35 handle.parent_client_id); | |
| 36 if (parent_channel) { | |
| 37 const base::CommandLine* command_line = | |
| 38 base::CommandLine::ForCurrentProcess(); | |
| 39 if (command_line->HasSwitch(switches::kUIPrioritizeInGpuProcess)) | |
| 40 stub->channel()->SetPreemptByFlag(parent_channel->GetPreemptionFlag()); | |
| 41 } | |
| 42 | |
| 43 surface = manager->GetDefaultOffscreenSurface(); | 33 surface = manager->GetDefaultOffscreenSurface(); |
| 44 } else { | 34 } else { |
| 45 surface = CreateNativeSurface(manager, stub, handle); | 35 surface = CreateNativeSurface(manager, stub, handle); |
| 46 if (!surface.get() || !surface->Initialize()) | 36 if (!surface.get() || !surface->Initialize()) |
| 47 return NULL; | 37 return NULL; |
| 48 } | 38 } |
| 49 | 39 |
| 50 return surface; | 40 return surface; |
| 51 } | 41 } |
| 52 | 42 |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 101 } | 91 } |
| 102 | 92 |
| 103 #if defined(OS_MACOSX) | 93 #if defined(OS_MACOSX) |
| 104 void ImageTransportHelper::SendAcceleratedSurfaceBuffersSwapped( | 94 void ImageTransportHelper::SendAcceleratedSurfaceBuffersSwapped( |
| 105 GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params params) { | 95 GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params params) { |
| 106 // TRACE_EVENT for gpu tests: | 96 // TRACE_EVENT for gpu tests: |
| 107 TRACE_EVENT_INSTANT2("test_gpu", "SwapBuffers", | 97 TRACE_EVENT_INSTANT2("test_gpu", "SwapBuffers", |
| 108 TRACE_EVENT_SCOPE_THREAD, | 98 TRACE_EVENT_SCOPE_THREAD, |
| 109 "GLImpl", static_cast<int>(gfx::GetGLImplementation()), | 99 "GLImpl", static_cast<int>(gfx::GetGLImplementation()), |
| 110 "width", params.size.width()); | 100 "width", params.size.width()); |
| 111 params.surface_id = stub_->surface_id(); | 101 // On mac, handle_ is a surface id. See |
| 102 // GpuProcessTransportFactory::CreatePerCompositorData |
| 103 params.surface_id = handle_; |
| 112 params.route_id = route_id_; | 104 params.route_id = route_id_; |
| 113 manager_->Send(new GpuHostMsg_AcceleratedSurfaceBuffersSwapped(params)); | 105 manager_->Send(new GpuHostMsg_AcceleratedSurfaceBuffersSwapped(params)); |
| 114 } | 106 } |
| 115 #endif | 107 #endif |
| 116 | 108 |
| 117 void ImageTransportHelper::SetPreemptByFlag( | 109 void ImageTransportHelper::SetPreemptByFlag( |
| 118 scoped_refptr<gpu::PreemptionFlag> preemption_flag) { | 110 scoped_refptr<gpu::PreemptionFlag> preemption_flag) { |
| 119 stub_->channel()->SetPreemptByFlag(preemption_flag); | 111 stub_->channel()->SetPreemptByFlag(preemption_flag); |
| 120 } | 112 } |
| 121 | 113 |
| (...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 284 void PassThroughImageTransportSurface::SendVSyncUpdateIfAvailable() { | 276 void PassThroughImageTransportSurface::SendVSyncUpdateIfAvailable() { |
| 285 gfx::VSyncProvider* vsync_provider = GetVSyncProvider(); | 277 gfx::VSyncProvider* vsync_provider = GetVSyncProvider(); |
| 286 if (vsync_provider) { | 278 if (vsync_provider) { |
| 287 vsync_provider->GetVSyncParameters( | 279 vsync_provider->GetVSyncParameters( |
| 288 base::Bind(&GpuCommandBufferStub::SendUpdateVSyncParameters, | 280 base::Bind(&GpuCommandBufferStub::SendUpdateVSyncParameters, |
| 289 helper_->stub()->AsWeakPtr())); | 281 helper_->stub()->AsWeakPtr())); |
| 290 } | 282 } |
| 291 } | 283 } |
| 292 | 284 |
| 293 } // namespace content | 285 } // namespace content |
| OLD | NEW |