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

Side by Side Diff: components/test_runner/pixel_dump.cc

Issue 2025373002: Add error messages for canvas creation failures (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 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
« no previous file with comments | « no previous file | skia/ext/bitmap_platform_device_win.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "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
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
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
OLDNEW
« no previous file with comments | « no previous file | skia/ext/bitmap_platform_device_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698