Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(420)

Side by Side Diff: content/common/gpu/image_transport_surface.cc

Issue 1711533002: Decouple browser-specific GPU IPC messages from GPU service IPCs (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed another Windows Build issue Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 <stddef.h> 7 #include <stddef.h>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
11 #include "base/bind_helpers.h" 11 #include "base/bind_helpers.h"
12 #include "base/command_line.h" 12 #include "base/command_line.h"
13 #include "base/trace_event/trace_event.h" 13 #include "base/trace_event/trace_event.h"
14 #include "build/build_config.h" 14 #include "build/build_config.h"
15 #include "content/common/gpu/gpu_channel.h" 15 #include "content/common/gpu/gpu_channel.h"
16 #include "content/common/gpu/gpu_channel_manager.h" 16 #include "content/common/gpu/gpu_channel_manager.h"
17 #include "content/common/gpu/gpu_channel_manager_delegate.h"
17 #include "content/common/gpu/gpu_command_buffer_stub.h" 18 #include "content/common/gpu/gpu_command_buffer_stub.h"
18 #include "content/common/gpu/gpu_messages.h" 19 #include "content/common/gpu/gpu_messages.h"
19 #include "gpu/command_buffer/service/sync_point_manager.h" 20 #include "gpu/command_buffer/service/sync_point_manager.h"
20 #include "ui/gfx/vsync_provider.h" 21 #include "ui/gfx/vsync_provider.h"
21 #include "ui/gl/gl_context.h" 22 #include "ui/gl/gl_context.h"
22 #include "ui/gl/gl_implementation.h" 23 #include "ui/gl/gl_implementation.h"
23 #include "ui/gl/gl_switches.h" 24 #include "ui/gl/gl_switches.h"
24 25
26 #if defined(OS_MACOSX)
27 #include "content/common/gpu/accelerated_surface_buffers_swapped_params_mac.h"
28 #include "ui/accelerated_widget_mac/accelerated_widget_mac.h"
29 #endif
30
25 namespace content { 31 namespace content {
26 32
27 ImageTransportSurface::ImageTransportSurface() {} 33 ImageTransportSurface::ImageTransportSurface() {}
28 34
29 ImageTransportSurface::~ImageTransportSurface() {} 35 ImageTransportSurface::~ImageTransportSurface() {}
30 36
31 scoped_refptr<gfx::GLSurface> ImageTransportSurface::CreateSurface( 37 scoped_refptr<gfx::GLSurface> ImageTransportSurface::CreateSurface(
32 GpuChannelManager* manager, 38 GpuChannelManager* manager,
33 GpuCommandBufferStub* stub, 39 GpuCommandBufferStub* stub,
34 const gfx::GLSurfaceHandle& handle, 40 const gfx::GLSurfaceHandle& handle,
(...skipping 11 matching lines...) Expand all
46 } 52 }
47 53
48 ImageTransportHelper::ImageTransportHelper(ImageTransportSurface* surface, 54 ImageTransportHelper::ImageTransportHelper(ImageTransportSurface* surface,
49 GpuChannelManager* manager, 55 GpuChannelManager* manager,
50 GpuCommandBufferStub* stub, 56 GpuCommandBufferStub* stub,
51 gfx::PluginWindowHandle handle) 57 gfx::PluginWindowHandle handle)
52 : surface_(surface), 58 : surface_(surface),
53 manager_(manager), 59 manager_(manager),
54 stub_(stub->AsWeakPtr()), 60 stub_(stub->AsWeakPtr()),
55 handle_(handle) { 61 handle_(handle) {
56 route_id_ = manager_->GenerateRouteID(); 62 route_id_ = manager_->GenerateRouteID();
no sievers 2016/02/22 21:57:42 It doesn't seem right to use GenerateRouteID() her
Fady Samuel 2016/02/23 04:45:27 I've filed a bug to move code out of ImageTranspor
57 manager_->AddRoute(route_id_, this); 63 manager_->AddImageTransportSurface(route_id_, this);
58 } 64 }
59 65
60 ImageTransportHelper::~ImageTransportHelper() { 66 ImageTransportHelper::~ImageTransportHelper() {
61 if (stub_.get()) { 67 if (stub_.get()) {
62 stub_->SetLatencyInfoCallback( 68 stub_->SetLatencyInfoCallback(
63 base::Callback<void(const std::vector<ui::LatencyInfo>&)>()); 69 base::Callback<void(const std::vector<ui::LatencyInfo>&)>());
64 } 70 }
65 manager_->RemoveRoute(route_id_); 71 manager_->RemoveImageTransportSurface(route_id_);
66 } 72 }
67 73
68 bool ImageTransportHelper::Initialize(gfx::GLSurface::Format format) { 74 bool ImageTransportHelper::Initialize(gfx::GLSurface::Format format) {
69 gpu::gles2::GLES2Decoder* decoder = Decoder(); 75 gpu::gles2::GLES2Decoder* decoder = Decoder();
70 76
71 if (!decoder) 77 if (!decoder)
72 return false; 78 return false;
73 79
74 stub_->SetLatencyInfoCallback( 80 stub_->SetLatencyInfoCallback(
75 base::Bind(&ImageTransportHelper::SetLatencyInfo, 81 base::Bind(&ImageTransportHelper::SetLatencyInfo,
76 base::Unretained(this))); 82 base::Unretained(this)));
77 83
78 return true; 84 return true;
79 } 85 }
80 86
81 bool ImageTransportHelper::OnMessageReceived(const IPC::Message& message) {
82 #if defined(OS_MACOSX) 87 #if defined(OS_MACOSX)
83 bool handled = true; 88 void ImageTransportHelper::BufferPresented(
84 IPC_BEGIN_MESSAGE_MAP(ImageTransportHelper, message) 89 const BufferPresentedParams& params) {
85 IPC_MESSAGE_HANDLER(AcceleratedSurfaceMsg_BufferPresented, 90 surface_->BufferPresented(params);
86 OnBufferPresented)
87 IPC_MESSAGE_UNHANDLED(handled = false)
88 IPC_END_MESSAGE_MAP()
89 return handled;
90 #else
91 NOTREACHED();
92 return false;
93 #endif
94 } 91 }
95 92
96 #if defined(OS_MACOSX)
97 void ImageTransportHelper::SendAcceleratedSurfaceBuffersSwapped( 93 void ImageTransportHelper::SendAcceleratedSurfaceBuffersSwapped(
98 GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params params) { 94 AcceleratedSurfaceBuffersSwappedParams params) {
99 // TRACE_EVENT for gpu tests: 95 // TRACE_EVENT for gpu tests:
100 TRACE_EVENT_INSTANT2("test_gpu", "SwapBuffers", 96 TRACE_EVENT_INSTANT2("test_gpu", "SwapBuffers",
101 TRACE_EVENT_SCOPE_THREAD, 97 TRACE_EVENT_SCOPE_THREAD,
102 "GLImpl", static_cast<int>(gfx::GetGLImplementation()), 98 "GLImpl", static_cast<int>(gfx::GetGLImplementation()),
103 "width", params.size.width()); 99 "width", params.size.width());
104 // On mac, handle_ is a surface id. See 100 // On mac, handle_ is a surface id. See
105 // GpuProcessTransportFactory::CreatePerCompositorData 101 // GpuProcessTransportFactory::CreatePerCompositorData
106 params.surface_id = handle_; 102 params.surface_id = handle_;
107 params.route_id = route_id_; 103 params.route_id = route_id_;
108 manager_->Send(new GpuHostMsg_AcceleratedSurfaceBuffersSwapped(params)); 104 manager_->delegate()->SendAcceleratedSurfaceBuffersSwapped(params);
109 } 105 }
110 #endif 106 #endif
111 107
112 bool ImageTransportHelper::MakeCurrent() { 108 bool ImageTransportHelper::MakeCurrent() {
113 gpu::gles2::GLES2Decoder* decoder = Decoder(); 109 gpu::gles2::GLES2Decoder* decoder = Decoder();
114 if (!decoder) 110 if (!decoder)
115 return false; 111 return false;
116 return decoder->MakeCurrent(); 112 return decoder->MakeCurrent();
117 } 113 }
118 114
119 void ImageTransportHelper::SetSwapInterval(gfx::GLContext* context) { 115 void ImageTransportHelper::SetSwapInterval(gfx::GLContext* context) {
120 if (base::CommandLine::ForCurrentProcess()->HasSwitch( 116 if (base::CommandLine::ForCurrentProcess()->HasSwitch(
121 switches::kDisableGpuVsync)) 117 switches::kDisableGpuVsync))
122 context->ForceSwapIntervalZero(true); 118 context->ForceSwapIntervalZero(true);
123 else 119 else
124 context->SetSwapInterval(1); 120 context->SetSwapInterval(1);
125 } 121 }
126 122
127 gpu::gles2::GLES2Decoder* ImageTransportHelper::Decoder() { 123 gpu::gles2::GLES2Decoder* ImageTransportHelper::Decoder() {
128 if (!stub_.get()) 124 if (!stub_.get())
129 return NULL; 125 return NULL;
130 return stub_->decoder(); 126 return stub_->decoder();
131 } 127 }
132 128
133 #if defined(OS_MACOSX)
134 void ImageTransportHelper::OnBufferPresented(
135 const AcceleratedSurfaceMsg_BufferPresented_Params& params) {
136 surface_->OnBufferPresented(params);
137 }
138 #endif
139
140 void ImageTransportHelper::SetLatencyInfo( 129 void ImageTransportHelper::SetLatencyInfo(
141 const std::vector<ui::LatencyInfo>& latency_info) { 130 const std::vector<ui::LatencyInfo>& latency_info) {
142 surface_->SetLatencyInfo(latency_info); 131 surface_->SetLatencyInfo(latency_info);
143 } 132 }
144 133
145 PassThroughImageTransportSurface::PassThroughImageTransportSurface( 134 PassThroughImageTransportSurface::PassThroughImageTransportSurface(
146 GpuChannelManager* manager, 135 GpuChannelManager* manager,
147 GpuCommandBufferStub* stub, 136 GpuCommandBufferStub* stub,
148 gfx::GLSurface* surface) 137 gfx::GLSurface* surface)
149 : GLSurfaceAdapter(surface), 138 : GLSurfaceAdapter(surface),
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
233 222
234 bool PassThroughImageTransportSurface::OnMakeCurrent(gfx::GLContext* context) { 223 bool PassThroughImageTransportSurface::OnMakeCurrent(gfx::GLContext* context) {
235 if (!did_set_swap_interval_) { 224 if (!did_set_swap_interval_) {
236 ImageTransportHelper::SetSwapInterval(context); 225 ImageTransportHelper::SetSwapInterval(context);
237 did_set_swap_interval_ = true; 226 did_set_swap_interval_ = true;
238 } 227 }
239 return true; 228 return true;
240 } 229 }
241 230
242 #if defined(OS_MACOSX) 231 #if defined(OS_MACOSX)
243 void PassThroughImageTransportSurface::OnBufferPresented( 232 void PassThroughImageTransportSurface::BufferPresented(
244 const AcceleratedSurfaceMsg_BufferPresented_Params& /* params */) { 233 const BufferPresentedParams& /* params */) {
245 NOTREACHED(); 234 NOTREACHED();
246 } 235 }
247 #endif 236 #endif
248 237
249 gfx::Size PassThroughImageTransportSurface::GetSize() { 238 gfx::Size PassThroughImageTransportSurface::GetSize() {
250 return GLSurfaceAdapter::GetSize(); 239 return GLSurfaceAdapter::GetSize();
251 } 240 }
252 241
253 PassThroughImageTransportSurface::~PassThroughImageTransportSurface() {} 242 PassThroughImageTransportSurface::~PassThroughImageTransportSurface() {}
254 243
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
295 284
296 void PassThroughImageTransportSurface::FinishSwapBuffersAsync( 285 void PassThroughImageTransportSurface::FinishSwapBuffersAsync(
297 scoped_ptr<std::vector<ui::LatencyInfo>> latency_info, 286 scoped_ptr<std::vector<ui::LatencyInfo>> latency_info,
298 GLSurface::SwapCompletionCallback callback, 287 GLSurface::SwapCompletionCallback callback,
299 gfx::SwapResult result) { 288 gfx::SwapResult result) {
300 FinishSwapBuffers(std::move(latency_info), result); 289 FinishSwapBuffers(std::move(latency_info), result);
301 callback.Run(result); 290 callback.Run(result);
302 } 291 }
303 292
304 } // namespace content 293 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698