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 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
102 } | 92 } |
103 | 93 |
104 #if defined(OS_MACOSX) | 94 #if defined(OS_MACOSX) |
105 void ImageTransportHelper::SendAcceleratedSurfaceBuffersSwapped( | 95 void ImageTransportHelper::SendAcceleratedSurfaceBuffersSwapped( |
106 GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params params) { | 96 GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params params) { |
107 // TRACE_EVENT for gpu tests: | 97 // TRACE_EVENT for gpu tests: |
108 TRACE_EVENT_INSTANT2("test_gpu", "SwapBuffers", | 98 TRACE_EVENT_INSTANT2("test_gpu", "SwapBuffers", |
109 TRACE_EVENT_SCOPE_THREAD, | 99 TRACE_EVENT_SCOPE_THREAD, |
110 "GLImpl", static_cast<int>(gfx::GetGLImplementation()), | 100 "GLImpl", static_cast<int>(gfx::GetGLImplementation()), |
111 "width", params.size.width()); | 101 "width", params.size.width()); |
112 params.surface_id = stub_->surface_id(); | 102 // On mac, handle_ is a surface id. See |
| 103 // GpuProcessTransportFactory::CreatePerCompositorData |
| 104 params.surface_id = handle_; |
113 params.route_id = route_id_; | 105 params.route_id = route_id_; |
114 manager_->Send(new GpuHostMsg_AcceleratedSurfaceBuffersSwapped(params)); | 106 manager_->Send(new GpuHostMsg_AcceleratedSurfaceBuffersSwapped(params)); |
115 } | 107 } |
116 #endif | 108 #endif |
117 | 109 |
118 void ImageTransportHelper::SetPreemptByFlag( | |
119 scoped_refptr<gpu::PreemptionFlag> preemption_flag) { | |
120 stub_->channel()->SetPreemptByFlag(preemption_flag); | |
121 } | |
122 | |
123 bool ImageTransportHelper::MakeCurrent() { | 110 bool ImageTransportHelper::MakeCurrent() { |
124 gpu::gles2::GLES2Decoder* decoder = Decoder(); | 111 gpu::gles2::GLES2Decoder* decoder = Decoder(); |
125 if (!decoder) | 112 if (!decoder) |
126 return false; | 113 return false; |
127 return decoder->MakeCurrent(); | 114 return decoder->MakeCurrent(); |
128 } | 115 } |
129 | 116 |
130 void ImageTransportHelper::SetSwapInterval(gfx::GLContext* context) { | 117 void ImageTransportHelper::SetSwapInterval(gfx::GLContext* context) { |
131 if (base::CommandLine::ForCurrentProcess()->HasSwitch( | 118 if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
132 switches::kDisableGpuVsync)) | 119 switches::kDisableGpuVsync)) |
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
285 void PassThroughImageTransportSurface::SendVSyncUpdateIfAvailable() { | 272 void PassThroughImageTransportSurface::SendVSyncUpdateIfAvailable() { |
286 gfx::VSyncProvider* vsync_provider = GetVSyncProvider(); | 273 gfx::VSyncProvider* vsync_provider = GetVSyncProvider(); |
287 if (vsync_provider) { | 274 if (vsync_provider) { |
288 vsync_provider->GetVSyncParameters( | 275 vsync_provider->GetVSyncParameters( |
289 base::Bind(&GpuCommandBufferStub::SendUpdateVSyncParameters, | 276 base::Bind(&GpuCommandBufferStub::SendUpdateVSyncParameters, |
290 helper_->stub()->AsWeakPtr())); | 277 helper_->stub()->AsWeakPtr())); |
291 } | 278 } |
292 } | 279 } |
293 | 280 |
294 } // namespace content | 281 } // namespace content |
OLD | NEW |