Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(89)

Side by Side Diff: ui/snapshot/snapshot_aura.cc

Issue 2752373002: Use PrintWindow() to implement snapshots on windows 8.1+ (Closed)
Patch Set: cleanup Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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_aura.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 GrabViewSnapshotAura(gfx::NativeView view,
25 const gfx::Rect& snapshot_bounds, 25 const gfx::Rect& snapshot_bounds,
26 gfx::Image* image) { 26 gfx::Image* image) {
27 return GrabWindowSnapshot(view, snapshot_bounds, image); 27 return GrabWindowSnapshot(view, snapshot_bounds, image);
28 } 28 }
29 29
30 bool GrabWindowSnapshot(gfx::NativeWindow window, 30 bool GrabWindowSnapshotAura(gfx::NativeWindow window,
sky 2017/03/23 03:29:13 If we are adding aura specific functions, what is
31 const gfx::Rect& snapshot_bounds, 31 const gfx::Rect& snapshot_bounds,
32 gfx::Image* image) { 32 gfx::Image* image) {
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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 const gfx::Rect& source_rect, 75 const gfx::Rect& source_rect,
76 const cc::CopyOutputRequest::CopyOutputRequestCallback& callback) { 76 const cc::CopyOutputRequest::CopyOutputRequestCallback& callback) {
77 auto tracker = base::MakeUnique<aura::WindowTracker>(); 77 auto tracker = base::MakeUnique<aura::WindowTracker>();
78 tracker->Add(window); 78 tracker->Add(window);
79 MakeAsyncCopyRequest( 79 MakeAsyncCopyRequest(
80 window, source_rect, 80 window, source_rect,
81 base::Bind(&FinishedAsyncCopyRequest, base::Passed(&tracker), source_rect, 81 base::Bind(&FinishedAsyncCopyRequest, base::Passed(&tracker), source_rect,
82 callback, 0)); 82 callback, 0));
83 } 83 }
84 84
85 void GrabWindowSnapshotAndScaleAsync( 85 void GrabWindowSnapshotAndScaleAsyncAura(
86 gfx::NativeWindow window, 86 gfx::NativeWindow window,
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 GrabWindowSnapshotAsyncAura(
98 gfx::NativeWindow window,
99 const gfx::Rect& source_rect,
100 const GrabWindowSnapshotAsyncCallback& callback) {
101 MakeInitialAsyncCopyRequest(
102 window, source_rect,
103 base::Bind(&SnapshotAsync::RunCallbackWithCopyOutputResult, callback));
104 }
105
106 void GrabViewSnapshotAsyncAura(
107 gfx::NativeView view,
108 const gfx::Rect& source_rect,
109 const GrabWindowSnapshotAsyncCallback& callback) {
110 GrabWindowSnapshotAsyncAura(view, source_rect, callback);
111 }
112
113 #if !defined(OS_WIN)
114 bool GrabWindowSnapshot(gfx::NativeWindow window,
115 const gfx::Rect& snapshot_bounds,
116 gfx::Image* image) {
117 return GrabWindowSnapshotAura(window, snapshot_bounds, image);
118 }
119
120 bool GrabViewSnapshot(gfx::NativeView view,
121 const gfx::Rect& snapshot_bounds,
122 gfx::Image* image) {
123 return GrabViewSnapshotAura(view, snapshot_bounds, image);
124 }
125
126 void GrabWindowSnapshotAndScaleAsync(
127 gfx::NativeWindow window,
128 const gfx::Rect& source_rect,
129 const gfx::Size& target_size,
130 scoped_refptr<base::TaskRunner> background_task_runner,
131 const GrabWindowSnapshotAsyncCallback& callback) {
132 GrabWindowSnapshotAndScaleAsyncAura(window, source_rect, target_size,
133 background_task_runner, callback);
134 }
135
97 void GrabWindowSnapshotAsync(gfx::NativeWindow window, 136 void GrabWindowSnapshotAsync(gfx::NativeWindow window,
98 const gfx::Rect& source_rect, 137 const gfx::Rect& source_rect,
99 const GrabWindowSnapshotAsyncCallback& callback) { 138 const GrabWindowSnapshotAsyncCallback& callback) {
100 MakeInitialAsyncCopyRequest( 139 GrabWindowSnapshotAsyncAura(window, source_rect, callback);
101 window, source_rect,
102 base::Bind(&SnapshotAsync::RunCallbackWithCopyOutputResult, callback));
103 } 140 }
104 141
105 void GrabViewSnapshotAsync(gfx::NativeView view, 142 void GrabViewSnapshotAsync(gfx::NativeView view,
106 const gfx::Rect& source_rect, 143 const gfx::Rect& source_rect,
107 const GrabWindowSnapshotAsyncCallback& callback) { 144 const GrabWindowSnapshotAsyncCallback& callback) {
108 GrabWindowSnapshotAsync(view, source_rect, callback); 145 GrabViewSnapshotAsyncAura(view, source_rect, callback);
109 } 146 }
110 147
148 #endif
111 149
112 } // namespace ui 150 } // namespace ui
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698