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 "components/test_runner/pixel_dump.h" | 5 #include "components/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 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
89 void CapturePixelsForPrinting(std::unique_ptr<PixelsDumpRequest> dump_request) { | 89 void CapturePixelsForPrinting(std::unique_ptr<PixelsDumpRequest> dump_request) { |
90 dump_request->web_view->updateAllLifecyclePhases(); | 90 dump_request->web_view->updateAllLifecyclePhases(); |
91 | 91 |
92 blink::WebSize page_size_in_pixels = dump_request->web_view->size(); | 92 blink::WebSize page_size_in_pixels = dump_request->web_view->size(); |
93 blink::WebFrame* web_frame = dump_request->web_view->mainFrame(); | 93 blink::WebFrame* web_frame = dump_request->web_view->mainFrame(); |
94 | 94 |
95 int page_count = web_frame->printBegin(page_size_in_pixels); | 95 int page_count = web_frame->printBegin(page_size_in_pixels); |
96 int totalHeight = page_count * (page_size_in_pixels.height + 1) - 1; | 96 int totalHeight = page_count * (page_size_in_pixels.height + 1) - 1; |
97 | 97 |
98 bool is_opaque = false; | 98 bool is_opaque = false; |
99 sk_sp<SkCanvas> canvas(skia::TryCreateBitmapCanvas( | 99 std::unique_ptr<SkCanvas> canvas = skia::TryCreateBitmapCanvas( |
100 page_size_in_pixels.width, totalHeight, is_opaque)); | 100 page_size_in_pixels.width, totalHeight, is_opaque); |
101 if (!canvas) { | 101 if (!canvas) { |
102 LOG(ERROR) << "Failed to create canvas width=" | 102 LOG(ERROR) << "Failed to create canvas width=" |
103 << page_size_in_pixels.width << " height=" << totalHeight; | 103 << page_size_in_pixels.width << " height=" << totalHeight; |
104 dump_request->callback.Run(SkBitmap()); | 104 dump_request->callback.Run(SkBitmap()); |
105 return; | 105 return; |
106 } | 106 } |
107 web_frame->printPagesWithBoundaries(canvas.get(), page_size_in_pixels); | 107 web_frame->printPagesWithBoundaries(canvas.get(), page_size_in_pixels); |
108 web_frame->printEnd(); | 108 web_frame->printEnd(); |
109 | 109 |
110 DrawSelectionRect(*dump_request, canvas.get()); | 110 DrawSelectionRect(*dump_request, canvas.get()); |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
199 | 199 |
200 blink::WebImage image = static_cast<blink::WebMockClipboard*>( | 200 blink::WebImage image = static_cast<blink::WebMockClipboard*>( |
201 blink::Platform::current()->clipboard()) | 201 blink::Platform::current()->clipboard()) |
202 ->readRawImage(blink::WebClipboard::Buffer()); | 202 ->readRawImage(blink::WebClipboard::Buffer()); |
203 const SkBitmap& bitmap = image.getSkBitmap(); | 203 const SkBitmap& bitmap = image.getSkBitmap(); |
204 SkAutoLockPixels autoLock(bitmap); | 204 SkAutoLockPixels autoLock(bitmap); |
205 callback.Run(bitmap); | 205 callback.Run(bitmap); |
206 } | 206 } |
207 | 207 |
208 } // namespace test_runner | 208 } // namespace test_runner |
OLD | NEW |