| 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" |
| 11 #include "cc/output/copy_output_request.h" | 11 #include "cc/output/copy_output_request.h" |
| 12 #include "third_party/skia/include/core/SkBitmap.h" | 12 #include "third_party/skia/include/core/SkBitmap.h" |
| 13 #include "ui/android/view_android.h" | 13 #include "ui/android/view_android.h" |
| 14 #include "ui/android/window_android.h" | 14 #include "ui/android/window_android.h" |
| 15 #include "ui/android/window_android_compositor.h" | 15 #include "ui/android/window_android_compositor.h" |
| 16 #include "ui/display/display.h" | 16 #include "ui/display/display.h" |
| 17 #include "ui/display/screen.h" | 17 #include "ui/display/screen.h" |
| 18 #include "ui/gfx/geometry/point_conversions.h" | 18 #include "ui/gfx/geometry/point_conversions.h" |
| 19 #include "ui/gfx/geometry/rect_conversions.h" | 19 #include "ui/gfx/geometry/rect_conversions.h" |
| 20 #include "ui/snapshot/snapshot_async.h" | 20 #include "ui/snapshot/snapshot_async.h" |
| 21 | 21 |
| 22 namespace ui { | 22 namespace ui { |
| 23 | 23 |
| 24 // Sync versions are not supported in Android. Callers should fall back | 24 // Sync versions are not supported in Android. Callers should fall back |
| 25 // to the async version. | 25 // to the async version. |
| 26 bool GrabViewSnapshot(gfx::NativeView view, | 26 bool GrabViewSnapshot(gfx::NativeView view, |
| 27 std::vector<unsigned char>* png_representation, | 27 const gfx::Rect& snapshot_bounds, |
| 28 const gfx::Rect& snapshot_bounds) { | 28 gfx::Image* image) { |
| 29 return GrabWindowSnapshot( | 29 return GrabWindowSnapshot(view->GetWindowAndroid(), snapshot_bounds, image); |
| 30 view->GetWindowAndroid(), png_representation, snapshot_bounds); | |
| 31 } | 30 } |
| 32 | 31 |
| 33 bool GrabWindowSnapshot(gfx::NativeWindow window, | 32 bool GrabWindowSnapshot(gfx::NativeWindow window, |
| 34 std::vector<unsigned char>* png_representation, | 33 const gfx::Rect& snapshot_bounds, |
| 35 const gfx::Rect& snapshot_bounds) { | 34 gfx::Image* image) { |
| 36 return false; | 35 return false; |
| 37 } | 36 } |
| 38 | 37 |
| 39 static void MakeAsyncCopyRequest( | 38 static void MakeAsyncCopyRequest( |
| 40 gfx::NativeWindow window, | 39 gfx::NativeWindow window, |
| 41 const gfx::Rect& source_rect, | 40 const gfx::Rect& source_rect, |
| 42 const cc::CopyOutputRequest::CopyOutputRequestCallback& callback) { | 41 const cc::CopyOutputRequest::CopyOutputRequestCallback& callback) { |
| 43 std::unique_ptr<cc::CopyOutputRequest> request = | 42 std::unique_ptr<cc::CopyOutputRequest> request = |
| 44 cc::CopyOutputRequest::CreateBitmapRequest(callback); | 43 cc::CopyOutputRequest::CreateBitmapRequest(callback); |
| 45 | 44 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 57 scoped_refptr<base::TaskRunner> background_task_runner, | 56 scoped_refptr<base::TaskRunner> background_task_runner, |
| 58 const GrabWindowSnapshotAsyncCallback& callback) { | 57 const GrabWindowSnapshotAsyncCallback& callback) { |
| 59 MakeAsyncCopyRequest(window, | 58 MakeAsyncCopyRequest(window, |
| 60 source_rect, | 59 source_rect, |
| 61 base::Bind(&SnapshotAsync::ScaleCopyOutputResult, | 60 base::Bind(&SnapshotAsync::ScaleCopyOutputResult, |
| 62 callback, | 61 callback, |
| 63 target_size, | 62 target_size, |
| 64 background_task_runner)); | 63 background_task_runner)); |
| 65 } | 64 } |
| 66 | 65 |
| 67 void GrabWindowSnapshotAsync( | 66 void GrabWindowSnapshotAsync(gfx::NativeWindow window, |
| 68 gfx::NativeWindow window, | 67 const gfx::Rect& source_rect, |
| 69 const gfx::Rect& source_rect, | 68 const GrabWindowSnapshotAsyncCallback& callback) { |
| 70 scoped_refptr<base::TaskRunner> background_task_runner, | 69 MakeAsyncCopyRequest( |
| 71 const GrabWindowSnapshotAsyncPNGCallback& callback) { | 70 window, source_rect, |
| 72 MakeAsyncCopyRequest(window, | 71 base::Bind(&SnapshotAsync::RunCallbackWithCopyOutputResult, callback)); |
| 73 source_rect, | |
| 74 base::Bind(&SnapshotAsync::EncodeCopyOutputResult, | |
| 75 callback, | |
| 76 background_task_runner)); | |
| 77 } | 72 } |
| 78 | 73 |
| 79 void GrabViewSnapshotAsync( | 74 void GrabViewSnapshotAsync(gfx::NativeView view, |
| 80 gfx::NativeView view, | 75 const gfx::Rect& source_rect, |
| 81 const gfx::Rect& source_rect, | 76 const GrabWindowSnapshotAsyncCallback& callback) { |
| 82 scoped_refptr<base::TaskRunner> background_task_runner, | 77 MakeAsyncCopyRequest( |
| 83 const GrabWindowSnapshotAsyncPNGCallback& callback) { | 78 view->GetWindowAndroid(), source_rect, |
| 84 MakeAsyncCopyRequest(view->GetWindowAndroid(), | 79 base::Bind(&SnapshotAsync::RunCallbackWithCopyOutputResult, callback)); |
| 85 source_rect, | |
| 86 base::Bind(&SnapshotAsync::EncodeCopyOutputResult, | |
| 87 callback, | |
| 88 background_task_runner)); | |
| 89 } | 80 } |
| 90 | 81 |
| 91 } // namespace ui | 82 } // namespace ui |
| OLD | NEW |