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

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

Issue 2294383002: Make OffscreenCanvas a member of CanvasImageSource (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 years, 3 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
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/html/canvas/CanvasContextCreationAttributes.h" 8 #include "core/html/canvas/CanvasContextCreationAttributes.h"
9 #include "core/html/canvas/CanvasRenderingContext.h" 9 #include "core/html/canvas/CanvasRenderingContext.h"
10 #include "core/html/canvas/CanvasRenderingContextFactory.h" 10 #include "core/html/canvas/CanvasRenderingContextFactory.h"
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 return nullptr; 54 return nullptr;
55 } 55 }
56 ImageBitmap* image = m_context->transferToImageBitmap(exceptionState); 56 ImageBitmap* image = m_context->transferToImageBitmap(exceptionState);
57 if (!image) { 57 if (!image) {
58 // Undocumented exception (not in spec) 58 // Undocumented exception (not in spec)
59 exceptionState.throwDOMException(V8Error, "Out of memory"); 59 exceptionState.throwDOMException(V8Error, "Out of memory");
60 } 60 }
61 return image; 61 return image;
62 } 62 }
63 63
64 PassRefPtr<Image> OffscreenCanvas::getSourceImageForCanvas(SourceImageStatus* st atus, AccelerationHint, SnapshotReason reason, const FloatSize&) const
65 {
66 if (!m_context) {
67 *status = InvalidSourceImageStatus;
68 return nullptr;
69 }
70 *status = NormalSourceImageStatus;
71 return m_context->getImage(reason);
72 }
73
74 bool OffscreenCanvas::isOpaque() const
75 {
76 if (!m_context)
77 return false;
78 return !m_context->creationAttributes().hasAlpha();
79 }
80
64 CanvasRenderingContext* OffscreenCanvas::getCanvasRenderingContext(ScriptState* scriptState, const String& id, const CanvasContextCreationAttributes& attributes ) 81 CanvasRenderingContext* OffscreenCanvas::getCanvasRenderingContext(ScriptState* scriptState, const String& id, const CanvasContextCreationAttributes& attributes )
65 { 82 {
66 CanvasRenderingContext::ContextType contextType = CanvasRenderingContext::co ntextTypeFromId(id); 83 CanvasRenderingContext::ContextType contextType = CanvasRenderingContext::co ntextTypeFromId(id);
67 84
68 // Unknown type. 85 // Unknown type.
69 if (contextType == CanvasRenderingContext::ContextTypeCount) 86 if (contextType == CanvasRenderingContext::ContextTypeCount)
70 return nullptr; 87 return nullptr;
71 88
72 CanvasRenderingContextFactory* factory = getRenderingContextFactory(contextT ype); 89 CanvasRenderingContextFactory* factory = getRenderingContextFactory(contextT ype);
73 if (!factory) 90 if (!factory)
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
116 return ImageBuffer::canCreateImageBuffer(m_size); 133 return ImageBuffer::canCreateImageBuffer(m_size);
117 return m_context->isPaintable(); 134 return m_context->isPaintable();
118 } 135 }
119 136
120 DEFINE_TRACE(OffscreenCanvas) 137 DEFINE_TRACE(OffscreenCanvas)
121 { 138 {
122 visitor->trace(m_context); 139 visitor->trace(m_context);
123 } 140 }
124 141
125 } // namespace blink 142 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698