| 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 const gfx::Rect& snapshot_bounds, | 27 std::vector<unsigned char>* png_representation, |
| 28 gfx::Image* image) { | 28 const gfx::Rect& snapshot_bounds) { |
| 29 return GrabWindowSnapshot(view->GetWindowAndroid(), snapshot_bounds, image); | 29 return GrabWindowSnapshot( |
| 30 view->GetWindowAndroid(), png_representation, snapshot_bounds); |
| 30 } | 31 } |
| 31 | 32 |
| 32 bool GrabWindowSnapshot(gfx::NativeWindow window, | 33 bool GrabWindowSnapshot(gfx::NativeWindow window, |
| 33 const gfx::Rect& snapshot_bounds, | 34 std::vector<unsigned char>* png_representation, |
| 34 gfx::Image* image) { | 35 const gfx::Rect& snapshot_bounds) { |
| 35 return false; | 36 return false; |
| 36 } | 37 } |
| 37 | 38 |
| 38 static void MakeAsyncCopyRequest( | 39 static void MakeAsyncCopyRequest( |
| 39 gfx::NativeWindow window, | 40 gfx::NativeWindow window, |
| 40 const gfx::Rect& source_rect, | 41 const gfx::Rect& source_rect, |
| 41 const cc::CopyOutputRequest::CopyOutputRequestCallback& callback) { | 42 const cc::CopyOutputRequest::CopyOutputRequestCallback& callback) { |
| 42 std::unique_ptr<cc::CopyOutputRequest> request = | 43 std::unique_ptr<cc::CopyOutputRequest> request = |
| 43 cc::CopyOutputRequest::CreateBitmapRequest(callback); | 44 cc::CopyOutputRequest::CreateBitmapRequest(callback); |
| 44 | 45 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 56 scoped_refptr<base::TaskRunner> background_task_runner, | 57 scoped_refptr<base::TaskRunner> background_task_runner, |
| 57 const GrabWindowSnapshotAsyncCallback& callback) { | 58 const GrabWindowSnapshotAsyncCallback& callback) { |
| 58 MakeAsyncCopyRequest(window, | 59 MakeAsyncCopyRequest(window, |
| 59 source_rect, | 60 source_rect, |
| 60 base::Bind(&SnapshotAsync::ScaleCopyOutputResult, | 61 base::Bind(&SnapshotAsync::ScaleCopyOutputResult, |
| 61 callback, | 62 callback, |
| 62 target_size, | 63 target_size, |
| 63 background_task_runner)); | 64 background_task_runner)); |
| 64 } | 65 } |
| 65 | 66 |
| 66 void GrabWindowSnapshotAsync(gfx::NativeWindow window, | 67 void GrabWindowSnapshotAsync( |
| 67 const gfx::Rect& source_rect, | 68 gfx::NativeWindow window, |
| 68 const GrabWindowSnapshotAsyncCallback& callback) { | 69 const gfx::Rect& source_rect, |
| 69 MakeAsyncCopyRequest( | 70 scoped_refptr<base::TaskRunner> background_task_runner, |
| 70 window, source_rect, | 71 const GrabWindowSnapshotAsyncPNGCallback& callback) { |
| 71 base::Bind(&SnapshotAsync::RunCallbackWithCopyOutputResult, callback)); | 72 MakeAsyncCopyRequest(window, |
| 73 source_rect, |
| 74 base::Bind(&SnapshotAsync::EncodeCopyOutputResult, |
| 75 callback, |
| 76 background_task_runner)); |
| 72 } | 77 } |
| 73 | 78 |
| 74 void GrabViewSnapshotAsync(gfx::NativeView view, | 79 void GrabViewSnapshotAsync( |
| 75 const gfx::Rect& source_rect, | 80 gfx::NativeView view, |
| 76 const GrabWindowSnapshotAsyncCallback& callback) { | 81 const gfx::Rect& source_rect, |
| 77 MakeAsyncCopyRequest( | 82 scoped_refptr<base::TaskRunner> background_task_runner, |
| 78 view->GetWindowAndroid(), source_rect, | 83 const GrabWindowSnapshotAsyncPNGCallback& callback) { |
| 79 base::Bind(&SnapshotAsync::RunCallbackWithCopyOutputResult, callback)); | 84 MakeAsyncCopyRequest(view->GetWindowAndroid(), |
| 85 source_rect, |
| 86 base::Bind(&SnapshotAsync::EncodeCopyOutputResult, |
| 87 callback, |
| 88 background_task_runner)); |
| 80 } | 89 } |
| 81 | 90 |
| 82 } // namespace ui | 91 } // namespace ui |
| OLD | NEW |