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

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

Issue 2592983002: [devtools] Support different encodings for Page.CaptureScreenshot. (Closed)
Patch Set: Encode in ui snapshot methods instead. Created 3 years, 11 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.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 std::vector<unsigned char>* png_representation, 25 std::vector<unsigned char>* png_representation,
26 const gfx::Rect& snapshot_bounds) { 26 const gfx::Rect& snapshot_bounds,
27 return GrabWindowSnapshot(view, png_representation, snapshot_bounds); 27 SnapshotEncoding encoding,
28 SnapshotQuality quality) {
29 return GrabWindowSnapshot(view, png_representation, snapshot_bounds, encoding,
30 quality);
28 } 31 }
29 32
30 bool GrabWindowSnapshot(gfx::NativeWindow window, 33 bool GrabWindowSnapshot(gfx::NativeWindow window,
31 std::vector<unsigned char>* png_representation, 34 std::vector<unsigned char>* png_representation,
32 const gfx::Rect& snapshot_bounds) { 35 const gfx::Rect& snapshot_bounds,
36 SnapshotEncoding encoding,
37 SnapshotQuality quality) {
33 // Not supported in Aura. Callers should fall back to the async version. 38 // Not supported in Aura. Callers should fall back to the async version.
34 return false; 39 return false;
35 } 40 }
36 41
37 static void MakeAsyncCopyRequest( 42 static void MakeAsyncCopyRequest(
38 gfx::NativeWindow window, 43 gfx::NativeWindow window,
39 const gfx::Rect& source_rect, 44 const gfx::Rect& source_rect,
40 const cc::CopyOutputRequest::CopyOutputRequestCallback& callback) { 45 const cc::CopyOutputRequest::CopyOutputRequestCallback& callback) {
41 std::unique_ptr<cc::CopyOutputRequest> request = 46 std::unique_ptr<cc::CopyOutputRequest> request =
42 cc::CopyOutputRequest::CreateBitmapRequest(callback); 47 cc::CopyOutputRequest::CreateBitmapRequest(callback);
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 MakeInitialAsyncCopyRequest( 96 MakeInitialAsyncCopyRequest(
92 window, source_rect, 97 window, source_rect,
93 base::Bind(&SnapshotAsync::ScaleCopyOutputResult, callback, target_size, 98 base::Bind(&SnapshotAsync::ScaleCopyOutputResult, callback, target_size,
94 background_task_runner)); 99 background_task_runner));
95 } 100 }
96 101
97 void GrabWindowSnapshotAsync( 102 void GrabWindowSnapshotAsync(
98 gfx::NativeWindow window, 103 gfx::NativeWindow window,
99 const gfx::Rect& source_rect, 104 const gfx::Rect& source_rect,
100 scoped_refptr<base::TaskRunner> background_task_runner, 105 scoped_refptr<base::TaskRunner> background_task_runner,
101 const GrabWindowSnapshotAsyncPNGCallback& callback) { 106 const GrabWindowSnapshotAsyncEncodedCallback& callback,
102 MakeInitialAsyncCopyRequest(window, source_rect, 107 SnapshotEncoding encoding,
103 base::Bind(&SnapshotAsync::EncodeCopyOutputResult, 108 SnapshotQuality quality) {
104 callback, background_task_runner)); 109 MakeInitialAsyncCopyRequest(
110 window, source_rect,
111 base::Bind(&SnapshotAsync::EncodeCopyOutputResult, callback,
112 background_task_runner, encoding, quality));
105 } 113 }
106 114
107 void GrabViewSnapshotAsync( 115 void GrabViewSnapshotAsync(
108 gfx::NativeView view, 116 gfx::NativeView view,
109 const gfx::Rect& source_rect, 117 const gfx::Rect& source_rect,
110 scoped_refptr<base::TaskRunner> background_task_runner, 118 scoped_refptr<base::TaskRunner> background_task_runner,
111 const GrabWindowSnapshotAsyncPNGCallback& callback) { 119 const GrabWindowSnapshotAsyncEncodedCallback& callback,
112 GrabWindowSnapshotAsync(view, source_rect, background_task_runner, callback); 120 SnapshotEncoding encoding,
121 SnapshotQuality quality) {
122 GrabWindowSnapshotAsync(view, source_rect, background_task_runner, callback,
123 encoding, quality);
113 } 124 }
114 125
115 126
116 } // namespace ui 127 } // namespace ui
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698