OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (C) 2004, 2006, 2009, 2010 Apple Inc. All rights reserved. | 2 * Copyright (C) 2004, 2006, 2009, 2010 Apple Inc. All rights reserved. |
3 * Copyright (C) 2007 Alp Toker <alp@atoker.com> | 3 * Copyright (C) 2007 Alp Toker <alp@atoker.com> |
4 * Copyright (C) 2010 Torch Mobile (Beijing) Co. Ltd. All rights reserved. | 4 * Copyright (C) 2010 Torch Mobile (Beijing) Co. Ltd. All rights reserved. |
5 * | 5 * |
6 * Redistribution and use in source and binary forms, with or without | 6 * Redistribution and use in source and binary forms, with or without |
7 * modification, are permitted provided that the following conditions | 7 * modification, are permitted provided that the following conditions |
8 * are met: | 8 * are met: |
9 * 1. Redistributions of source code must retain the above copyright | 9 * 1. Redistributions of source code must retain the above copyright |
10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
(...skipping 13 matching lines...) Expand all Loading... | |
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
25 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 25 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 */ | 26 */ |
27 | 27 |
28 #ifndef HTMLCanvasElement_h | 28 #ifndef HTMLCanvasElement_h |
29 #define HTMLCanvasElement_h | 29 #define HTMLCanvasElement_h |
30 | 30 |
31 #include "bindings/core/v8/ScriptValue.h" | 31 #include "bindings/core/v8/ScriptValue.h" |
32 #include "bindings/core/v8/UnionTypesCore.h" | 32 #include "bindings/core/v8/UnionTypesCore.h" |
33 #include "core/CoreExport.h" | 33 #include "core/CoreExport.h" |
34 #include "core/dom/DOMTypedArray.h" | |
34 #include "core/dom/Document.h" | 35 #include "core/dom/Document.h" |
35 #include "core/dom/DocumentVisibilityObserver.h" | 36 #include "core/dom/DocumentVisibilityObserver.h" |
36 #include "core/fileapi/FileCallback.h" | 37 #include "core/fileapi/FileCallback.h" |
37 #include "core/html/HTMLElement.h" | 38 #include "core/html/HTMLElement.h" |
38 #include "core/html/canvas/CanvasImageSource.h" | 39 #include "core/html/canvas/CanvasImageSource.h" |
39 #include "platform/geometry/FloatRect.h" | 40 #include "platform/geometry/FloatRect.h" |
40 #include "platform/geometry/IntSize.h" | 41 #include "platform/geometry/IntSize.h" |
41 #include "platform/graphics/GraphicsTypes.h" | 42 #include "platform/graphics/GraphicsTypes.h" |
42 #include "platform/graphics/GraphicsTypes3D.h" | 43 #include "platform/graphics/GraphicsTypes3D.h" |
43 #include "platform/graphics/ImageBufferClient.h" | 44 #include "platform/graphics/ImageBufferClient.h" |
44 #include "platform/heap/Handle.h" | 45 #include "platform/heap/Handle.h" |
46 #include "public/platform/WebThread.h" | |
45 | 47 |
46 #define CanvasDefaultInterpolationQuality InterpolationLow | 48 #define CanvasDefaultInterpolationQuality InterpolationLow |
47 | 49 |
48 namespace blink { | 50 namespace blink { |
49 | 51 |
50 class AffineTransform; | 52 class AffineTransform; |
51 class CanvasContextCreationAttributes; | 53 class CanvasContextCreationAttributes; |
52 class CanvasRenderingContext; | 54 class CanvasRenderingContext; |
53 class CanvasRenderingContextFactory; | 55 class CanvasRenderingContextFactory; |
54 class GraphicsContext; | 56 class GraphicsContext; |
(...skipping 16 matching lines...) Expand all Loading... | |
71 DEFINE_INLINE_VIRTUAL_TRACE() { } | 73 DEFINE_INLINE_VIRTUAL_TRACE() { } |
72 }; | 74 }; |
73 | 75 |
74 class CORE_EXPORT HTMLCanvasElement final : public HTMLElement, public DocumentV isibilityObserver, public CanvasImageSource, public ImageBufferClient { | 76 class CORE_EXPORT HTMLCanvasElement final : public HTMLElement, public DocumentV isibilityObserver, public CanvasImageSource, public ImageBufferClient { |
75 DEFINE_WRAPPERTYPEINFO(); | 77 DEFINE_WRAPPERTYPEINFO(); |
76 WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(HTMLCanvasElement); | 78 WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(HTMLCanvasElement); |
77 public: | 79 public: |
78 DECLARE_NODE_FACTORY(HTMLCanvasElement); | 80 DECLARE_NODE_FACTORY(HTMLCanvasElement); |
79 ~HTMLCanvasElement() override; | 81 ~HTMLCanvasElement() override; |
80 | 82 |
83 static PassOwnPtr<WebThread> getToBlobThreadInstance(); | |
Justin Novosad
2015/09/24 20:51:31
This is not a proper use of PassOwnPtr. I really t
| |
84 static int s_numCanvasInstances; | |
85 | |
81 void addObserver(CanvasObserver*); | 86 void addObserver(CanvasObserver*); |
82 void removeObserver(CanvasObserver*); | 87 void removeObserver(CanvasObserver*); |
83 | 88 |
84 // Attributes and functions exposed to script | 89 // Attributes and functions exposed to script |
85 int width() const { return size().width(); } | 90 int width() const { return size().width(); } |
86 int height() const { return size().height(); } | 91 int height() const { return size().height(); } |
87 | 92 |
88 const IntSize& size() const { return m_size; } | 93 const IntSize& size() const { return m_size; } |
89 | 94 |
90 void setWidth(int); | 95 void setWidth(int); |
(...skipping 16 matching lines...) Expand all Loading... | |
107 ScriptValue getContext(ScriptState*, const String&, const CanvasContextCreat ionAttributes&); | 112 ScriptValue getContext(ScriptState*, const String&, const CanvasContextCreat ionAttributes&); |
108 // Called by Document::getCSSCanvasContext as well as above getContext(). | 113 // Called by Document::getCSSCanvasContext as well as above getContext(). |
109 CanvasRenderingContext* getCanvasRenderingContext(const String&, const Canva sContextCreationAttributes&); | 114 CanvasRenderingContext* getCanvasRenderingContext(const String&, const Canva sContextCreationAttributes&); |
110 | 115 |
111 bool isPaintable() const; | 116 bool isPaintable() const; |
112 | 117 |
113 static String toEncodingMimeType(const String& mimeType); | 118 static String toEncodingMimeType(const String& mimeType); |
114 String toDataURL(const String& mimeType, const ScriptValue& qualityArgument, ExceptionState&) const; | 119 String toDataURL(const String& mimeType, const ScriptValue& qualityArgument, ExceptionState&) const; |
115 String toDataURL(const String& mimeType, ExceptionState& exceptionState) con st { return toDataURL(mimeType, ScriptValue(), exceptionState); } | 120 String toDataURL(const String& mimeType, ExceptionState& exceptionState) con st { return toDataURL(mimeType, ScriptValue(), exceptionState); } |
116 | 121 |
117 void toBlob(FileCallback*, const String& mimeType, const ScriptValue& qualit yArgument, ExceptionState&) const; | 122 void toBlob(FileCallback*, const String& mimeType, const ScriptValue& qualit yArgument, ExceptionState&); |
118 void toBlob(FileCallback* callback, const String& mimeType, ExceptionState& exceptionState) { return toBlob(callback, mimeType, ScriptValue(), exceptionStat e); } | 123 void toBlob(FileCallback* callback, const String& mimeType, ExceptionState& exceptionState) { return toBlob(callback, mimeType, ScriptValue(), exceptionStat e); } |
119 | 124 |
120 // Used for rendering | 125 // Used for rendering |
121 void didDraw(const FloatRect&); | 126 void didDraw(const FloatRect&); |
122 void notifyObserversCanvasChanged(const FloatRect&); | 127 void notifyObserversCanvasChanged(const FloatRect&); |
123 | 128 |
124 void paint(GraphicsContext*, const LayoutRect&); | 129 void paint(GraphicsContext*, const LayoutRect&); |
125 | 130 |
126 SkCanvas* drawingCanvas() const; | 131 SkCanvas* drawingCanvas() const; |
127 void disableDeferral() const; | 132 void disableDeferral() const; |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
202 PassOwnPtr<ImageBufferSurface> createImageBufferSurface(const IntSize& devic eSize, int* msaaSampleCount); | 207 PassOwnPtr<ImageBufferSurface> createImageBufferSurface(const IntSize& devic eSize, int* msaaSampleCount); |
203 void createImageBuffer(); | 208 void createImageBuffer(); |
204 void createImageBufferInternal(PassOwnPtr<ImageBufferSurface> externalSurfac e); | 209 void createImageBufferInternal(PassOwnPtr<ImageBufferSurface> externalSurfac e); |
205 bool shouldUseDisplayList(const IntSize& deviceSize); | 210 bool shouldUseDisplayList(const IntSize& deviceSize); |
206 | 211 |
207 void setSurfaceSize(const IntSize&); | 212 void setSurfaceSize(const IntSize&); |
208 | 213 |
209 bool paintsIntoCanvasBuffer() const; | 214 bool paintsIntoCanvasBuffer() const; |
210 | 215 |
211 ImageData* toImageData(SourceDrawingBuffer) const; | 216 ImageData* toImageData(SourceDrawingBuffer) const; |
212 String toDataURLInternal(const String& mimeType, const double* quality, Sour ceDrawingBuffer) const; | 217 String toDataURLInternal(const String& mimeType, const double& quality, Sour ceDrawingBuffer) const; |
218 | |
219 void encodeImageAsync(DOMUint8ClampedArray* imagedata, IntSize imageSize, Fi leCallback*, const String& mimeType, double quality); | |
220 void createBlobAndCall(PassOwnPtr<Vector<char>> encodedImage, const String& mimeType, FileCallback*); | |
213 | 221 |
214 WillBeHeapHashSet<RawPtrWillBeWeakMember<CanvasObserver>> m_observers; | 222 WillBeHeapHashSet<RawPtrWillBeWeakMember<CanvasObserver>> m_observers; |
215 | 223 |
216 IntSize m_size; | 224 IntSize m_size; |
217 | 225 |
218 OwnPtrWillBeMember<CanvasRenderingContext> m_context; | 226 OwnPtrWillBeMember<CanvasRenderingContext> m_context; |
219 | 227 |
220 bool m_ignoreReset; | 228 bool m_ignoreReset; |
221 bool m_accelerationDisabled; | 229 bool m_accelerationDisabled; |
222 FloatRect m_dirtyRect; | 230 FloatRect m_dirtyRect; |
223 | 231 |
224 mutable intptr_t m_externallyAllocatedMemory; | 232 mutable intptr_t m_externallyAllocatedMemory; |
225 | 233 |
226 bool m_originClean; | 234 bool m_originClean; |
227 | 235 |
228 // It prevents HTMLCanvasElement::buffer() from continuously re-attempting t o allocate an imageBuffer | 236 // It prevents HTMLCanvasElement::buffer() from continuously re-attempting t o allocate an imageBuffer |
229 // after the first attempt failed. | 237 // after the first attempt failed. |
230 mutable bool m_didFailToCreateImageBuffer; | 238 mutable bool m_didFailToCreateImageBuffer; |
231 bool m_imageBufferIsClear; | 239 bool m_imageBufferIsClear; |
232 OwnPtr<ImageBuffer> m_imageBuffer; | 240 OwnPtr<ImageBuffer> m_imageBuffer; |
233 | 241 |
234 mutable RefPtr<Image> m_copiedImage; // FIXME: This is temporary for platfor ms that have to copy the image buffer to render (and for CSSCanvasValue). | 242 mutable RefPtr<Image> m_copiedImage; // FIXME: This is temporary for platfor ms that have to copy the image buffer to render (and for CSSCanvasValue). |
235 }; | 243 }; |
236 | 244 |
237 } // namespace blink | 245 } // namespace blink |
238 | 246 |
239 #endif // HTMLCanvasElement_h | 247 #endif // HTMLCanvasElement_h |
OLD | NEW |