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

Side by Side Diff: content/shell/test_runner/pixel_dump.cc

Issue 2855503003: Replace uses of legacy SkBitmap::copyTo() API (Closed)
Patch Set: Remove braces Created 3 years, 7 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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 "content/shell/test_runner/pixel_dump.h" 5 #include "content/shell/test_runner/pixel_dump.h"
6 6
7 #include <memory> 7 #include <memory>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/bind_helpers.h" 10 #include "base/bind_helpers.h"
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
124 124
125 void CaptureCallback::DidCompositeAndReadback(const SkBitmap& bitmap) { 125 void CaptureCallback::DidCompositeAndReadback(const SkBitmap& bitmap) {
126 TRACE_EVENT2("shell", "CaptureCallback::didCompositeAndReadback", "x", 126 TRACE_EVENT2("shell", "CaptureCallback::didCompositeAndReadback", "x",
127 bitmap.info().width(), "y", bitmap.info().height()); 127 bitmap.info().width(), "y", bitmap.info().height());
128 if (!wait_for_popup_) { 128 if (!wait_for_popup_) {
129 callback_.Run(bitmap); 129 callback_.Run(bitmap);
130 delete this; 130 delete this;
131 return; 131 return;
132 } 132 }
133 if (main_bitmap_.isNull()) { 133 if (main_bitmap_.isNull()) {
134 bitmap.deepCopyTo(&main_bitmap_); 134 if (main_bitmap_.tryAllocPixels(bitmap.info())) {
135 bitmap.readPixels(main_bitmap_.info(), main_bitmap_.getPixels(),
136 main_bitmap_.rowBytes(), 0, 0);
137 }
135 return; 138 return;
136 } 139 }
137 SkCanvas canvas(main_bitmap_); 140 SkCanvas canvas(main_bitmap_);
138 canvas.drawBitmap(bitmap, popup_position_.x(), popup_position_.y()); 141 canvas.drawBitmap(bitmap, popup_position_.x(), popup_position_.y());
139 callback_.Run(main_bitmap_); 142 callback_.Run(main_bitmap_);
140 delete this; 143 delete this;
141 } 144 }
142 145
143 void DidCapturePixelsAsync(std::unique_ptr<PixelsDumpRequest> dump_request, 146 void DidCapturePixelsAsync(std::unique_ptr<PixelsDumpRequest> dump_request,
144 const SkBitmap& bitmap) { 147 const SkBitmap& bitmap) {
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
201 return; 204 return;
202 } 205 }
203 206
204 blink::WebImage image = static_cast<blink::WebMockClipboard*>( 207 blink::WebImage image = static_cast<blink::WebMockClipboard*>(
205 blink::Platform::Current()->Clipboard()) 208 blink::Platform::Current()->Clipboard())
206 ->ReadRawImage(blink::WebClipboard::Buffer()); 209 ->ReadRawImage(blink::WebClipboard::Buffer());
207 callback.Run(image.GetSkBitmap()); 210 callback.Run(image.GetSkBitmap());
208 } 211 }
209 212
210 } // namespace test_runner 213 } // namespace test_runner
OLDNEW
« no previous file with comments | « content/renderer/pepper/pepper_plugin_instance_impl.cc ('k') | headless/lib/browser/headless_clipboard.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698