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/debug/trace_event.h" | 10 #include "base/debug/trace_event.h" |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
48 manager_(manager), | 48 manager_(manager), |
49 stub_(stub->AsWeakPtr()), | 49 stub_(stub->AsWeakPtr()), |
50 handle_(handle) { | 50 handle_(handle) { |
51 route_id_ = manager_->GenerateRouteID(); | 51 route_id_ = manager_->GenerateRouteID(); |
52 manager_->AddRoute(route_id_, this); | 52 manager_->AddRoute(route_id_, this); |
53 } | 53 } |
54 | 54 |
55 ImageTransportHelper::~ImageTransportHelper() { | 55 ImageTransportHelper::~ImageTransportHelper() { |
56 if (stub_.get()) { | 56 if (stub_.get()) { |
57 stub_->SetLatencyInfoCallback( | 57 stub_->SetLatencyInfoCallback( |
58 base::Callback<void(const ui::LatencyInfo&)>()); | 58 base::Callback<void(const std::vector<ui::LatencyInfo>&)>()); |
59 } | 59 } |
60 manager_->RemoveRoute(route_id_); | 60 manager_->RemoveRoute(route_id_); |
61 } | 61 } |
62 | 62 |
63 bool ImageTransportHelper::Initialize() { | 63 bool ImageTransportHelper::Initialize() { |
64 gpu::gles2::GLES2Decoder* decoder = Decoder(); | 64 gpu::gles2::GLES2Decoder* decoder = Decoder(); |
65 | 65 |
66 if (!decoder) | 66 if (!decoder) |
67 return false; | 67 return false; |
68 | 68 |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
125 } | 125 } |
126 | 126 |
127 void ImageTransportHelper::SendUpdateVSyncParameters( | 127 void ImageTransportHelper::SendUpdateVSyncParameters( |
128 base::TimeTicks timebase, base::TimeDelta interval) { | 128 base::TimeTicks timebase, base::TimeDelta interval) { |
129 manager_->Send(new GpuHostMsg_UpdateVSyncParameters(stub_->surface_id(), | 129 manager_->Send(new GpuHostMsg_UpdateVSyncParameters(stub_->surface_id(), |
130 timebase, | 130 timebase, |
131 interval)); | 131 interval)); |
132 } | 132 } |
133 | 133 |
134 void ImageTransportHelper::SendLatencyInfo( | 134 void ImageTransportHelper::SendLatencyInfo( |
135 const ui::LatencyInfo& latency_info) { | 135 const std::vector<ui::LatencyInfo>& latency_info) { |
136 manager_->Send(new GpuHostMsg_FrameDrawn(latency_info)); | 136 manager_->Send(new GpuHostMsg_FrameDrawn(latency_info)); |
137 } | 137 } |
138 | 138 |
139 void ImageTransportHelper::SetScheduled(bool is_scheduled) { | 139 void ImageTransportHelper::SetScheduled(bool is_scheduled) { |
140 gpu::GpuScheduler* scheduler = Scheduler(); | 140 gpu::GpuScheduler* scheduler = Scheduler(); |
141 if (!scheduler) | 141 if (!scheduler) |
142 return; | 142 return; |
143 | 143 |
144 scheduler->SetScheduled(is_scheduled); | 144 scheduler->SetScheduled(is_scheduled); |
145 } | 145 } |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
202 void ImageTransportHelper::Resize(gfx::Size size, float scale_factor) { | 202 void ImageTransportHelper::Resize(gfx::Size size, float scale_factor) { |
203 surface_->OnResize(size, scale_factor); | 203 surface_->OnResize(size, scale_factor); |
204 | 204 |
205 #if defined(OS_ANDROID) | 205 #if defined(OS_ANDROID) |
206 manager_->gpu_memory_manager()->ScheduleManage( | 206 manager_->gpu_memory_manager()->ScheduleManage( |
207 GpuMemoryManager::kScheduleManageNow); | 207 GpuMemoryManager::kScheduleManageNow); |
208 #endif | 208 #endif |
209 } | 209 } |
210 | 210 |
211 void ImageTransportHelper::SetLatencyInfo( | 211 void ImageTransportHelper::SetLatencyInfo( |
212 const ui::LatencyInfo& latency_info) { | 212 const std::vector<ui::LatencyInfo>& latency_info) { |
213 surface_->SetLatencyInfo(latency_info); | 213 surface_->SetLatencyInfo(latency_info); |
214 } | 214 } |
215 | 215 |
216 PassThroughImageTransportSurface::PassThroughImageTransportSurface( | 216 PassThroughImageTransportSurface::PassThroughImageTransportSurface( |
217 GpuChannelManager* manager, | 217 GpuChannelManager* manager, |
218 GpuCommandBufferStub* stub, | 218 GpuCommandBufferStub* stub, |
219 gfx::GLSurface* surface, | 219 gfx::GLSurface* surface, |
220 bool transport) | 220 bool transport) |
221 : GLSurfaceAdapter(surface), | 221 : GLSurfaceAdapter(surface), |
222 transport_(transport), | 222 transport_(transport), |
(...skipping 20 matching lines...) Expand all Loading... | |
243 if (is_swap_buffers_pending_) { | 243 if (is_swap_buffers_pending_) { |
244 DCHECK(!did_unschedule_); | 244 DCHECK(!did_unschedule_); |
245 did_unschedule_ = true; | 245 did_unschedule_ = true; |
246 helper_->SetScheduled(false); | 246 helper_->SetScheduled(false); |
247 return true; | 247 return true; |
248 } | 248 } |
249 return false; | 249 return false; |
250 } | 250 } |
251 | 251 |
252 void PassThroughImageTransportSurface::SetLatencyInfo( | 252 void PassThroughImageTransportSurface::SetLatencyInfo( |
253 const ui::LatencyInfo& latency_info) { | 253 const std::vector<ui::LatencyInfo>& latency_info) { |
254 latency_info_ = latency_info; | 254 for (size_t i = 0; i < latency_info.size(); i++) |
255 latency_info_.push_back(latency_info[i]); | |
255 } | 256 } |
256 | 257 |
257 bool PassThroughImageTransportSurface::SwapBuffers() { | 258 bool PassThroughImageTransportSurface::SwapBuffers() { |
258 // GetVsyncValues before SwapBuffers to work around Mali driver bug: | 259 // GetVsyncValues before SwapBuffers to work around Mali driver bug: |
259 // crbug.com/223558. | 260 // crbug.com/223558. |
260 SendVSyncUpdateIfAvailable(); | 261 SendVSyncUpdateIfAvailable(); |
261 bool result = gfx::GLSurfaceAdapter::SwapBuffers(); | 262 bool result = gfx::GLSurfaceAdapter::SwapBuffers(); |
262 latency_info_.AddLatencyNumber( | 263 for (size_t i = 0; i < latency_info_.size(); i++) { |
263 ui::INPUT_EVENT_LATENCY_TERMINATED_FRAME_SWAP_COMPONENT, 0, 0); | 264 latency_info_[i].AddLatencyNumber( |
265 ui::INPUT_EVENT_LATENCY_TERMINATED_FRAME_SWAP_COMPONENT, 0, 0); | |
266 } | |
264 | 267 |
265 if (transport_) { | 268 if (transport_) { |
266 DCHECK(!is_swap_buffers_pending_); | 269 DCHECK(!is_swap_buffers_pending_); |
267 is_swap_buffers_pending_ = true; | 270 is_swap_buffers_pending_ = true; |
268 | 271 |
269 // Round trip to the browser UI thread, for throttling, by sending a dummy | 272 // Round trip to the browser UI thread, for throttling, by sending a dummy |
270 // SwapBuffers message. | 273 // SwapBuffers message. |
271 GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params params; | 274 GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params params; |
272 params.surface_handle = 0; | 275 params.surface_handle = 0; |
273 params.latency_info = latency_info_; | 276 params.latency_info = std::vector<ui::LatencyInfo>(); |
jbauman
2014/01/09 01:28:47
Why aren't you passing latency_info_ through here?
Yufeng Shen (Slow to review)
2014/01/09 22:41:40
Done.
| |
274 params.size = surface()->GetSize(); | 277 params.size = surface()->GetSize(); |
275 helper_->SendAcceleratedSurfaceBuffersSwapped(params); | 278 helper_->SendAcceleratedSurfaceBuffersSwapped(params); |
276 } else { | 279 } else { |
277 helper_->SendLatencyInfo(latency_info_); | 280 helper_->SendLatencyInfo(latency_info_); |
278 } | 281 } |
282 latency_info_.clear(); | |
279 return result; | 283 return result; |
280 } | 284 } |
281 | 285 |
282 bool PassThroughImageTransportSurface::PostSubBuffer( | 286 bool PassThroughImageTransportSurface::PostSubBuffer( |
283 int x, int y, int width, int height) { | 287 int x, int y, int width, int height) { |
284 SendVSyncUpdateIfAvailable(); | 288 SendVSyncUpdateIfAvailable(); |
285 bool result = gfx::GLSurfaceAdapter::PostSubBuffer(x, y, width, height); | 289 bool result = gfx::GLSurfaceAdapter::PostSubBuffer(x, y, width, height); |
286 latency_info_.AddLatencyNumber( | 290 for (size_t i = 0; i < latency_info_.size(); i++) { |
287 ui::INPUT_EVENT_LATENCY_TERMINATED_FRAME_SWAP_COMPONENT, 0, 0); | 291 latency_info_[i].AddLatencyNumber( |
292 ui::INPUT_EVENT_LATENCY_TERMINATED_FRAME_SWAP_COMPONENT, 0, 0); | |
293 } | |
288 | 294 |
289 if (transport_) { | 295 if (transport_) { |
290 DCHECK(!is_swap_buffers_pending_); | 296 DCHECK(!is_swap_buffers_pending_); |
291 is_swap_buffers_pending_ = true; | 297 is_swap_buffers_pending_ = true; |
292 | 298 |
293 // Round trip to the browser UI thread, for throttling, by sending a dummy | 299 // Round trip to the browser UI thread, for throttling, by sending a dummy |
294 // PostSubBuffer message. | 300 // PostSubBuffer message. |
295 GpuHostMsg_AcceleratedSurfacePostSubBuffer_Params params; | 301 GpuHostMsg_AcceleratedSurfacePostSubBuffer_Params params; |
296 params.surface_handle = 0; | 302 params.surface_handle = 0; |
297 params.latency_info = latency_info_; | 303 params.latency_info = std::vector<ui::LatencyInfo>(); |
jbauman
2014/01/09 01:28:47
Likewise, you need to pass latency_info_ through h
Yufeng Shen (Slow to review)
2014/01/09 22:41:40
Done.
| |
298 params.surface_size = surface()->GetSize(); | 304 params.surface_size = surface()->GetSize(); |
299 params.x = x; | 305 params.x = x; |
300 params.y = y; | 306 params.y = y; |
301 params.width = width; | 307 params.width = width; |
302 params.height = height; | 308 params.height = height; |
303 helper_->SendAcceleratedSurfacePostSubBuffer(params); | 309 helper_->SendAcceleratedSurfacePostSubBuffer(params); |
304 | 310 |
305 helper_->SetScheduled(false); | 311 helper_->SetScheduled(false); |
306 } else { | 312 } else { |
307 helper_->SendLatencyInfo(latency_info_); | 313 helper_->SendLatencyInfo(latency_info_); |
308 } | 314 } |
315 latency_info_.clear(); | |
309 return result; | 316 return result; |
310 } | 317 } |
311 | 318 |
312 bool PassThroughImageTransportSurface::OnMakeCurrent(gfx::GLContext* context) { | 319 bool PassThroughImageTransportSurface::OnMakeCurrent(gfx::GLContext* context) { |
313 if (!did_set_swap_interval_) { | 320 if (!did_set_swap_interval_) { |
314 ImageTransportHelper::SetSwapInterval(context); | 321 ImageTransportHelper::SetSwapInterval(context); |
315 did_set_swap_interval_ = true; | 322 did_set_swap_interval_ = true; |
316 } | 323 } |
317 return true; | 324 return true; |
318 } | 325 } |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
363 void PassThroughImageTransportSurface::SendVSyncUpdateIfAvailable() { | 370 void PassThroughImageTransportSurface::SendVSyncUpdateIfAvailable() { |
364 gfx::VSyncProvider* vsync_provider = GetVSyncProvider(); | 371 gfx::VSyncProvider* vsync_provider = GetVSyncProvider(); |
365 if (vsync_provider) { | 372 if (vsync_provider) { |
366 vsync_provider->GetVSyncParameters( | 373 vsync_provider->GetVSyncParameters( |
367 base::Bind(&ImageTransportHelper::SendUpdateVSyncParameters, | 374 base::Bind(&ImageTransportHelper::SendUpdateVSyncParameters, |
368 helper_->AsWeakPtr())); | 375 helper_->AsWeakPtr())); |
369 } | 376 } |
370 } | 377 } |
371 | 378 |
372 } // namespace content | 379 } // namespace content |
OLD | NEW |