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" |
11 #include "base/command_line.h" | 11 #include "base/command_line.h" |
12 #include "base/debug/trace_event.h" | 12 #include "base/debug/trace_event.h" |
13 #include "content/common/gpu/gpu_channel.h" | 13 #include "content/common/gpu/gpu_channel.h" |
14 #include "content/common/gpu/gpu_channel_manager.h" | 14 #include "content/common/gpu/gpu_channel_manager.h" |
15 #include "content/common/gpu/gpu_command_buffer_stub.h" | 15 #include "content/common/gpu/gpu_command_buffer_stub.h" |
16 #include "content/common/gpu/gpu_messages.h" | 16 #include "content/common/gpu/gpu_messages.h" |
17 #include "gpu/command_buffer/service/gpu_scheduler.h" | 17 #include "gpu/command_buffer/service/gpu_scheduler.h" |
18 #include "ui/gl/gl_switches.h" | 18 #include "ui/gl/gl_switches.h" |
19 #include "ui/gl/gl_implementation.h" | 19 #include "ui/gl/gl_implementation.h" |
20 | 20 |
21 namespace content { | 21 namespace content { |
22 | 22 |
23 ImageTransportSurface::ImageTransportSurface() {} | 23 ImageTransportSurface::ImageTransportSurface() {} |
24 | 24 |
25 ImageTransportSurface::~ImageTransportSurface() {} | 25 ImageTransportSurface::~ImageTransportSurface() {} |
26 | 26 |
27 void ImageTransportSurface::OnSetFrontSurfaceIsProtected( | |
28 bool is_protected, uint32 protection_state_id) { | |
29 } | |
30 | |
31 void ImageTransportSurface::GetRegionsToCopy( | 27 void ImageTransportSurface::GetRegionsToCopy( |
32 const gfx::Rect& previous_damage_rect, | 28 const gfx::Rect& previous_damage_rect, |
33 const gfx::Rect& new_damage_rect, | 29 const gfx::Rect& new_damage_rect, |
34 std::vector<gfx::Rect>* regions) { | 30 std::vector<gfx::Rect>* regions) { |
35 gfx::Rect intersection = | 31 gfx::Rect intersection = |
36 gfx::IntersectRects(previous_damage_rect, new_damage_rect); | 32 gfx::IntersectRects(previous_damage_rect, new_damage_rect); |
37 | 33 |
38 if (intersection.IsEmpty()) { | 34 if (intersection.IsEmpty()) { |
39 regions->push_back(previous_damage_rect); | 35 regions->push_back(previous_damage_rect); |
40 return; | 36 return; |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
93 return true; | 89 return true; |
94 } | 90 } |
95 | 91 |
96 void ImageTransportHelper::Destroy() {} | 92 void ImageTransportHelper::Destroy() {} |
97 | 93 |
98 bool ImageTransportHelper::OnMessageReceived(const IPC::Message& message) { | 94 bool ImageTransportHelper::OnMessageReceived(const IPC::Message& message) { |
99 bool handled = true; | 95 bool handled = true; |
100 IPC_BEGIN_MESSAGE_MAP(ImageTransportHelper, message) | 96 IPC_BEGIN_MESSAGE_MAP(ImageTransportHelper, message) |
101 IPC_MESSAGE_HANDLER(AcceleratedSurfaceMsg_BufferPresented, | 97 IPC_MESSAGE_HANDLER(AcceleratedSurfaceMsg_BufferPresented, |
102 OnBufferPresented) | 98 OnBufferPresented) |
103 IPC_MESSAGE_HANDLER(AcceleratedSurfaceMsg_SetFrontSurfaceIsProtected, | |
104 OnSetFrontSurfaceIsProtected) | |
105 IPC_MESSAGE_HANDLER(AcceleratedSurfaceMsg_ResizeViewACK, OnResizeViewACK); | 99 IPC_MESSAGE_HANDLER(AcceleratedSurfaceMsg_ResizeViewACK, OnResizeViewACK); |
106 IPC_MESSAGE_UNHANDLED(handled = false) | 100 IPC_MESSAGE_UNHANDLED(handled = false) |
107 IPC_END_MESSAGE_MAP() | 101 IPC_END_MESSAGE_MAP() |
108 return handled; | 102 return handled; |
109 } | 103 } |
110 | 104 |
111 void ImageTransportHelper::SendAcceleratedSurfaceNew( | 105 void ImageTransportHelper::SendAcceleratedSurfaceNew( |
112 GpuHostMsg_AcceleratedSurfaceNew_Params params) { | 106 GpuHostMsg_AcceleratedSurfaceNew_Params params) { |
113 params.surface_id = stub_->surface_id(); | 107 params.surface_id = stub_->surface_id(); |
114 params.route_id = route_id_; | 108 params.route_id = route_id_; |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
205 return NULL; | 199 return NULL; |
206 return stub_->scheduler(); | 200 return stub_->scheduler(); |
207 } | 201 } |
208 | 202 |
209 gpu::gles2::GLES2Decoder* ImageTransportHelper::Decoder() { | 203 gpu::gles2::GLES2Decoder* ImageTransportHelper::Decoder() { |
210 if (!stub_.get()) | 204 if (!stub_.get()) |
211 return NULL; | 205 return NULL; |
212 return stub_->decoder(); | 206 return stub_->decoder(); |
213 } | 207 } |
214 | 208 |
215 void ImageTransportHelper::OnSetFrontSurfaceIsProtected( | 209 void ImageTransportHelper::OnBufferPresented(uint64 surface_handle, |
216 bool is_protected, uint32 protection_state_id) { | |
217 surface_->OnSetFrontSurfaceIsProtected(is_protected, protection_state_id); | |
218 } | |
219 | |
220 void ImageTransportHelper::OnBufferPresented(bool presented, | |
221 uint32 sync_point) { | 210 uint32 sync_point) { |
222 surface_->OnBufferPresented(presented, sync_point); | 211 surface_->OnBufferPresented(surface_handle, sync_point); |
223 } | 212 } |
224 | 213 |
225 void ImageTransportHelper::OnResizeViewACK() { | 214 void ImageTransportHelper::OnResizeViewACK() { |
226 surface_->OnResizeViewACK(); | 215 surface_->OnResizeViewACK(); |
227 } | 216 } |
228 | 217 |
229 void ImageTransportHelper::Resize(gfx::Size size) { | 218 void ImageTransportHelper::Resize(gfx::Size size) { |
230 // On windows, the surface is recreated and, in case the newly allocated | 219 // On windows, the surface is recreated and, in case the newly allocated |
231 // surface happens to have the same address, it should be invalidated on the | 220 // surface happens to have the same address, it should be invalidated on the |
232 // decoder so that future calls to MakeCurrent do not early out on the | 221 // decoder so that future calls to MakeCurrent do not early out on the |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
315 | 304 |
316 bool PassThroughImageTransportSurface::OnMakeCurrent(gfx::GLContext* context) { | 305 bool PassThroughImageTransportSurface::OnMakeCurrent(gfx::GLContext* context) { |
317 if (!did_set_swap_interval_) { | 306 if (!did_set_swap_interval_) { |
318 ImageTransportHelper::SetSwapInterval(context); | 307 ImageTransportHelper::SetSwapInterval(context); |
319 did_set_swap_interval_ = true; | 308 did_set_swap_interval_ = true; |
320 } | 309 } |
321 return true; | 310 return true; |
322 } | 311 } |
323 | 312 |
324 void PassThroughImageTransportSurface::OnBufferPresented( | 313 void PassThroughImageTransportSurface::OnBufferPresented( |
325 bool /* presented */, | 314 uint64 /* surface_handle */, |
326 uint32 /* sync_point */) { | 315 uint32 /* sync_point */) { |
327 DCHECK(transport_); | 316 DCHECK(transport_); |
328 helper_->SetScheduled(true); | 317 helper_->SetScheduled(true); |
329 } | 318 } |
330 | 319 |
331 void PassThroughImageTransportSurface::OnResizeViewACK() { | 320 void PassThroughImageTransportSurface::OnResizeViewACK() { |
332 DCHECK(transport_); | 321 DCHECK(transport_); |
333 Resize(new_size_); | 322 Resize(new_size_); |
334 | 323 |
335 helper_->SetScheduled(true); | 324 helper_->SetScheduled(true); |
(...skipping 18 matching lines...) Expand all Loading... |
354 | 343 |
355 void PassThroughImageTransportSurface::SendVSyncUpdateIfAvailable() { | 344 void PassThroughImageTransportSurface::SendVSyncUpdateIfAvailable() { |
356 GetVSyncParameters( | 345 GetVSyncParameters( |
357 base::Bind(&ImageTransportHelper::SendUpdateVSyncParameters, | 346 base::Bind(&ImageTransportHelper::SendUpdateVSyncParameters, |
358 helper_->AsWeakPtr())); | 347 helper_->AsWeakPtr())); |
359 } | 348 } |
360 | 349 |
361 } // namespace content | 350 } // namespace content |
362 | 351 |
363 #endif // defined(ENABLE_GPU) | 352 #endif // defined(ENABLE_GPU) |
OLD | NEW |