| 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 <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/callback.h" | 10 #include "base/callback.h" |
| 11 #include "base/memory/ptr_util.h" | 11 #include "base/memory/ptr_util.h" |
| 12 #include "base/task_runner_util.h" | 12 #include "base/task_runner_util.h" |
| 13 #include "cc/output/copy_output_request.h" | 13 #include "cc/output/copy_output_request.h" |
| 14 #include "third_party/skia/include/core/SkBitmap.h" | 14 #include "third_party/skia/include/core/SkBitmap.h" |
| 15 #include "ui/aura/window.h" | 15 #include "ui/aura/window.h" |
| 16 #include "ui/aura/window_tracker.h" | 16 #include "ui/aura/window_tracker.h" |
| 17 #include "ui/compositor/compositor.h" | 17 #include "ui/compositor/compositor.h" |
| 18 #include "ui/compositor/dip_util.h" | 18 #include "ui/compositor/dip_util.h" |
| 19 #include "ui/compositor/layer.h" | 19 #include "ui/compositor/layer.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 bool GrabViewSnapshot(gfx::NativeView view, | 24 bool GrabViewSnapshot(gfx::NativeView view, |
| 25 const gfx::Rect& snapshot_bounds, | 25 std::vector<unsigned char>* png_representation, |
| 26 gfx::Image* image) { | 26 const gfx::Rect& snapshot_bounds) { |
| 27 return GrabWindowSnapshot(view, snapshot_bounds, image); | 27 return GrabWindowSnapshot(view, png_representation, snapshot_bounds); |
| 28 } | 28 } |
| 29 | 29 |
| 30 bool GrabWindowSnapshot(gfx::NativeWindow window, | 30 bool GrabWindowSnapshot(gfx::NativeWindow window, |
| 31 const gfx::Rect& snapshot_bounds, | 31 std::vector<unsigned char>* png_representation, |
| 32 gfx::Image* image) { | 32 const gfx::Rect& snapshot_bounds) { |
| 33 // Not supported in Aura. Callers should fall back to the async version. | 33 // Not supported in Aura. Callers should fall back to the async version. |
| 34 return false; | 34 return false; |
| 35 } | 35 } |
| 36 | 36 |
| 37 static void MakeAsyncCopyRequest( | 37 static void MakeAsyncCopyRequest( |
| 38 gfx::NativeWindow window, | 38 gfx::NativeWindow window, |
| 39 const gfx::Rect& source_rect, | 39 const gfx::Rect& source_rect, |
| 40 const cc::CopyOutputRequest::CopyOutputRequestCallback& callback) { | 40 const cc::CopyOutputRequest::CopyOutputRequestCallback& callback) { |
| 41 std::unique_ptr<cc::CopyOutputRequest> request = | 41 std::unique_ptr<cc::CopyOutputRequest> request = |
| 42 cc::CopyOutputRequest::CreateBitmapRequest(callback); | 42 cc::CopyOutputRequest::CreateBitmapRequest(callback); |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 87 const gfx::Rect& source_rect, | 87 const gfx::Rect& source_rect, |
| 88 const gfx::Size& target_size, | 88 const gfx::Size& target_size, |
| 89 scoped_refptr<base::TaskRunner> background_task_runner, | 89 scoped_refptr<base::TaskRunner> background_task_runner, |
| 90 const GrabWindowSnapshotAsyncCallback& callback) { | 90 const GrabWindowSnapshotAsyncCallback& callback) { |
| 91 MakeInitialAsyncCopyRequest( | 91 MakeInitialAsyncCopyRequest( |
| 92 window, source_rect, | 92 window, source_rect, |
| 93 base::Bind(&SnapshotAsync::ScaleCopyOutputResult, callback, target_size, | 93 base::Bind(&SnapshotAsync::ScaleCopyOutputResult, callback, target_size, |
| 94 background_task_runner)); | 94 background_task_runner)); |
| 95 } | 95 } |
| 96 | 96 |
| 97 void GrabWindowSnapshotAsync(gfx::NativeWindow window, | 97 void GrabWindowSnapshotAsync( |
| 98 const gfx::Rect& source_rect, | 98 gfx::NativeWindow window, |
| 99 const GrabWindowSnapshotAsyncCallback& callback) { | 99 const gfx::Rect& source_rect, |
| 100 MakeInitialAsyncCopyRequest( | 100 scoped_refptr<base::TaskRunner> background_task_runner, |
| 101 window, source_rect, | 101 const GrabWindowSnapshotAsyncPNGCallback& callback) { |
| 102 base::Bind(&SnapshotAsync::RunCallbackWithCopyOutputResult, callback)); | 102 MakeInitialAsyncCopyRequest(window, source_rect, |
| 103 base::Bind(&SnapshotAsync::EncodeCopyOutputResult, |
| 104 callback, background_task_runner)); |
| 103 } | 105 } |
| 104 | 106 |
| 105 void GrabViewSnapshotAsync(gfx::NativeView view, | 107 void GrabViewSnapshotAsync( |
| 106 const gfx::Rect& source_rect, | 108 gfx::NativeView view, |
| 107 const GrabWindowSnapshotAsyncCallback& callback) { | 109 const gfx::Rect& source_rect, |
| 108 GrabWindowSnapshotAsync(view, source_rect, callback); | 110 scoped_refptr<base::TaskRunner> background_task_runner, |
| 111 const GrabWindowSnapshotAsyncPNGCallback& callback) { |
| 112 GrabWindowSnapshotAsync(view, source_rect, background_task_runner, callback); |
| 109 } | 113 } |
| 110 | 114 |
| 111 | 115 |
| 112 } // namespace ui | 116 } // namespace ui |
| OLD | NEW |