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 "content/common/gpu/gpu_channel.h" | 12 #include "content/common/gpu/gpu_channel.h" |
13 #include "content/common/gpu/gpu_channel_manager.h" | 13 #include "content/common/gpu/gpu_channel_manager.h" |
14 #include "content/common/gpu/gpu_command_buffer_stub.h" | 14 #include "content/common/gpu/gpu_command_buffer_stub.h" |
15 #include "content/common/gpu/gpu_messages.h" | 15 #include "content/common/gpu/gpu_messages.h" |
16 #include "gpu/command_buffer/service/gpu_scheduler.h" | 16 #include "gpu/command_buffer/service/gpu_scheduler.h" |
17 #include "ui/gfx/gl/gl_switches.h" | 17 #include "ui/gfx/gl/gl_switches.h" |
18 | 18 |
19 ImageTransportSurface::ImageTransportSurface() { | 19 ImageTransportSurface::ImageTransportSurface() { |
20 } | 20 } |
21 | 21 |
22 ImageTransportSurface::~ImageTransportSurface() { | 22 ImageTransportSurface::~ImageTransportSurface() { |
23 } | 23 } |
24 | 24 |
| 25 void ImageTransportSurface::GetRegionsToCopy( |
| 26 const gfx::Rect& previous_damage_rect, |
| 27 const gfx::Rect& new_damage_rect, |
| 28 std::vector<gfx::Rect>* regions) { |
| 29 gfx::Rect intersection = previous_damage_rect.Intersect(new_damage_rect); |
| 30 |
| 31 if (intersection.IsEmpty()) { |
| 32 regions->push_back(previous_damage_rect); |
| 33 return; |
| 34 } |
| 35 |
| 36 // Top (above the intersection). |
| 37 regions->push_back(gfx::Rect(previous_damage_rect.x(), |
| 38 previous_damage_rect.y(), |
| 39 previous_damage_rect.width(), |
| 40 intersection.y() - previous_damage_rect.y())); |
| 41 |
| 42 // Left (of the intersection). |
| 43 regions->push_back(gfx::Rect(previous_damage_rect.x(), |
| 44 intersection.y(), |
| 45 intersection.x() - previous_damage_rect.x(), |
| 46 intersection.height())); |
| 47 |
| 48 // Right (of the intersection). |
| 49 regions->push_back(gfx::Rect(intersection.right(), |
| 50 intersection.y(), |
| 51 previous_damage_rect.right() - intersection.right(), |
| 52 intersection.height())); |
| 53 |
| 54 // Bottom (below the intersection). |
| 55 regions->push_back(gfx::Rect(previous_damage_rect.x(), |
| 56 intersection.bottom(), |
| 57 previous_damage_rect.width(), |
| 58 previous_damage_rect.bottom() - intersection.bottom())); |
| 59 } |
| 60 |
25 ImageTransportHelper::ImageTransportHelper(ImageTransportSurface* surface, | 61 ImageTransportHelper::ImageTransportHelper(ImageTransportSurface* surface, |
26 GpuChannelManager* manager, | 62 GpuChannelManager* manager, |
27 GpuCommandBufferStub* stub, | 63 GpuCommandBufferStub* stub, |
28 gfx::PluginWindowHandle handle) | 64 gfx::PluginWindowHandle handle) |
29 : surface_(surface), | 65 : surface_(surface), |
30 manager_(manager), | 66 manager_(manager), |
31 stub_(stub->AsWeakPtr()), | 67 stub_(stub->AsWeakPtr()), |
32 handle_(handle) { | 68 handle_(handle) { |
33 route_id_ = manager_->GenerateRouteID(); | 69 route_id_ = manager_->GenerateRouteID(); |
34 manager_->AddRoute(route_id_, this); | 70 manager_->AddRoute(route_id_, this); |
(...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
290 | 326 |
291 if (transport_) { | 327 if (transport_) { |
292 helper_->SendResizeView(size); | 328 helper_->SendResizeView(size); |
293 helper_->SetScheduled(false); | 329 helper_->SetScheduled(false); |
294 } else { | 330 } else { |
295 Resize(new_size_); | 331 Resize(new_size_); |
296 } | 332 } |
297 } | 333 } |
298 | 334 |
299 #endif // defined(ENABLE_GPU) | 335 #endif // defined(ENABLE_GPU) |
OLD | NEW |