OLD | NEW |
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 Loading... |
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 Loading... |
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 |
OLD | NEW |