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

Side by Side Diff: third_party/WebKit/Source/core/offscreencanvas/OffscreenCanvas.cpp

Issue 2550443002: Fix a minor issue in OffscreenCanvas.drawImage (Closed)
Patch Set: address comments Created 4 years 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 | « third_party/WebKit/LayoutTests/fast/canvas/OffscreenCanvas-2d-drawImage-no-context.html ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "core/offscreencanvas/OffscreenCanvas.h" 5 #include "core/offscreencanvas/OffscreenCanvas.h"
6 6
7 #include "core/dom/ExceptionCode.h" 7 #include "core/dom/ExceptionCode.h"
8 #include "core/fileapi/Blob.h" 8 #include "core/fileapi/Blob.h"
9 #include "core/html/ImageData.h" 9 #include "core/html/ImageData.h"
10 #include "core/html/canvas/CanvasAsyncBlobCreator.h" 10 #include "core/html/canvas/CanvasAsyncBlobCreator.h"
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 return image; 86 return image;
87 } 87 }
88 88
89 PassRefPtr<Image> OffscreenCanvas::getSourceImageForCanvas( 89 PassRefPtr<Image> OffscreenCanvas::getSourceImageForCanvas(
90 SourceImageStatus* status, 90 SourceImageStatus* status,
91 AccelerationHint hint, 91 AccelerationHint hint,
92 SnapshotReason reason, 92 SnapshotReason reason,
93 const FloatSize& size) const { 93 const FloatSize& size) const {
94 if (!m_context) { 94 if (!m_context) {
95 *status = InvalidSourceImageStatus; 95 *status = InvalidSourceImageStatus;
96 return nullptr; 96 sk_sp<SkSurface> surface =
97 SkSurface::MakeRasterN32Premul(m_size.width(), m_size.height());
98 return surface ? StaticBitmapImage::create(surface->makeImageSnapshot())
99 : nullptr;
97 } 100 }
98 if (!size.width() || !size.height()) { 101 if (!size.width() || !size.height()) {
99 *status = ZeroSizeCanvasSourceImageStatus; 102 *status = ZeroSizeCanvasSourceImageStatus;
100 return nullptr; 103 return nullptr;
101 } 104 }
102 RefPtr<Image> image = m_context->getImage(hint, reason); 105 RefPtr<Image> image = m_context->getImage(hint, reason);
103 if (!image) { 106 if (!image) {
104 *status = InvalidSourceImageStatus; 107 *status = InvalidSourceImageStatus;
105 } else { 108 } else {
106 *status = NormalSourceImageStatus; 109 *status = NormalSourceImageStatus;
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
240 return resolver->promise(); 243 return resolver->promise();
241 } 244 }
242 245
243 DEFINE_TRACE(OffscreenCanvas) { 246 DEFINE_TRACE(OffscreenCanvas) {
244 visitor->trace(m_context); 247 visitor->trace(m_context);
245 visitor->trace(m_executionContext); 248 visitor->trace(m_executionContext);
246 EventTargetWithInlineData::trace(visitor); 249 EventTargetWithInlineData::trace(visitor);
247 } 250 }
248 251
249 } // namespace blink 252 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/LayoutTests/fast/canvas/OffscreenCanvas-2d-drawImage-no-context.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698