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