| 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 "ui/snapshot/snapshot.h" | 5 #include "ui/snapshot/snapshot.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 42 std::unique_ptr<cc::CopyOutputRequest> request = | 42 std::unique_ptr<cc::CopyOutputRequest> request = |
| 43 cc::CopyOutputRequest::CreateBitmapRequest(callback); | 43 cc::CopyOutputRequest::CreateBitmapRequest(callback); |
| 44 | 44 |
| 45 const display::Display& display = | 45 const display::Display& display = |
| 46 display::Screen::GetScreen()->GetPrimaryDisplay(); | 46 display::Screen::GetScreen()->GetPrimaryDisplay(); |
| 47 float device_scale_factor = display.device_scale_factor(); | 47 float device_scale_factor = display.device_scale_factor(); |
| 48 gfx::Rect source_rect_in_pixel = | 48 gfx::Rect source_rect_in_pixel = |
| 49 gfx::ScaleToEnclosingRect(source_rect, device_scale_factor); | 49 gfx::ScaleToEnclosingRect(source_rect, device_scale_factor); |
| 50 | 50 |
| 51 // Account for the toolbar offset. | 51 // Account for the toolbar offset. |
| 52 gfx::Vector2dF offset = window->content_offset(); | 52 gfx::Vector2dF offset_in_pixel = |
| 53 gfx::Rect adjusted_source_rect(gfx::ToRoundedPoint( | 53 gfx::ScaleVector2d(window->content_offset(), device_scale_factor); |
| 54 gfx::PointF(source_rect_in_pixel.x() + offset.x(), | 54 gfx::Rect adjusted_source_rect( |
| 55 source_rect_in_pixel.y() + offset.y())), | 55 gfx::ToRoundedPoint( |
| 56 gfx::PointF(source_rect_in_pixel.x() + offset_in_pixel.x(), |
| 57 source_rect_in_pixel.y() + offset_in_pixel.y())), |
| 56 source_rect_in_pixel.size()); | 58 source_rect_in_pixel.size()); |
| 57 | 59 |
| 58 request->set_area(adjusted_source_rect); | 60 request->set_area(adjusted_source_rect); |
| 59 window->GetCompositor()->RequestCopyOfOutputOnRootLayer(std::move(request)); | 61 window->GetCompositor()->RequestCopyOfOutputOnRootLayer(std::move(request)); |
| 60 } | 62 } |
| 61 | 63 |
| 62 void GrabWindowSnapshotAndScaleAsync( | 64 void GrabWindowSnapshotAndScaleAsync( |
| 63 gfx::NativeWindow window, | 65 gfx::NativeWindow window, |
| 64 const gfx::Rect& source_rect, | 66 const gfx::Rect& source_rect, |
| 65 const gfx::Size& target_size, | 67 const gfx::Size& target_size, |
| (...skipping 22 matching lines...) Expand all Loading... |
| 88 void GrabViewSnapshotAsync( | 90 void GrabViewSnapshotAsync( |
| 89 gfx::NativeView view, | 91 gfx::NativeView view, |
| 90 const gfx::Rect& source_rect, | 92 const gfx::Rect& source_rect, |
| 91 scoped_refptr<base::TaskRunner> background_task_runner, | 93 scoped_refptr<base::TaskRunner> background_task_runner, |
| 92 const GrabWindowSnapshotAsyncPNGCallback& callback) { | 94 const GrabWindowSnapshotAsyncPNGCallback& callback) { |
| 93 GrabWindowSnapshotAsync( | 95 GrabWindowSnapshotAsync( |
| 94 view->GetWindowAndroid(), source_rect, background_task_runner, callback); | 96 view->GetWindowAndroid(), source_rect, background_task_runner, callback); |
| 95 } | 97 } |
| 96 | 98 |
| 97 } // namespace ui | 99 } // namespace ui |
| OLD | NEW |