OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (C) 2008, 2009 Apple Inc. All rights reserved. | 2 * Copyright (C) 2008, 2009 Apple Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
6 * are met: | 6 * are met: |
7 * | 7 * |
8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
11 * notice, this list of conditions and the following disclaimer in the | 11 * notice, this list of conditions and the following disclaimer in the |
12 * documentation and/or other materials provided with the distribution. | 12 * documentation and/or other materials provided with the distribution. |
13 * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of | 13 * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of |
14 * its contributors may be used to endorse or promote products derived | 14 * its contributors may be used to endorse or promote products derived |
15 * from this software without specific prior written permission. | 15 * from this software without specific prior written permission. |
16 * | 16 * |
17 * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY | 17 * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY |
18 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | 18 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
19 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | 19 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
20 * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY | 20 * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY |
21 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | 21 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
22 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | 22 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
23 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | 23 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
24 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 24 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | 25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
27 */ | 27 */ |
28 | 28 |
29 #ifndef ImageData_h | 29 #ifndef Float32ImageData_h |
30 #define ImageData_h | 30 #define Float32ImageData_h |
31 | 31 |
32 #include "bindings/core/v8/ScriptWrappable.h" | 32 #include "bindings/core/v8/ScriptWrappable.h" |
33 #include "core/CoreExport.h" | 33 #include "core/CoreExport.h" |
34 #include "core/dom/DOMTypedArray.h" | 34 #include "core/dom/DOMTypedArray.h" |
35 #include "core/html/ImageData.h" | |
Justin Novosad
2016/12/08 18:16:34
Why is this needed?
zakerinasab
2016/12/08 20:40:52
To have access to ImageDataColorSpace enum and str
| |
35 #include "core/imagebitmap/ImageBitmapSource.h" | 36 #include "core/imagebitmap/ImageBitmapSource.h" |
36 #include "platform/geometry/IntRect.h" | 37 #include "platform/geometry/IntRect.h" |
37 #include "platform/geometry/IntSize.h" | 38 #include "platform/geometry/IntSize.h" |
38 #include "platform/heap/Handle.h" | 39 #include "platform/heap/Handle.h" |
39 #include "wtf/Compiler.h" | 40 #include "wtf/Compiler.h" |
41 #include "wtf/text/WTFString.h" | |
40 | 42 |
41 namespace blink { | 43 namespace blink { |
42 | 44 |
43 class ExceptionState; | 45 class ExceptionState; |
44 class ImageBitmapOptions; | 46 class ImageBitmapOptions; |
45 | 47 |
46 class CORE_EXPORT ImageData final : public GarbageCollectedFinalized<ImageData>, | 48 class CORE_EXPORT Float32ImageData final |
47 public ScriptWrappable, | 49 : public GarbageCollectedFinalized<Float32ImageData>, |
48 public ImageBitmapSource { | 50 public ScriptWrappable, |
51 public ImageBitmapSource { | |
49 DEFINE_WRAPPERTYPEINFO(); | 52 DEFINE_WRAPPERTYPEINFO(); |
50 | 53 |
51 public: | 54 public: |
52 static ImageData* create(const IntSize&); | 55 static Float32ImageData* create(const IntSize&); |
53 static ImageData* create(const IntSize&, DOMUint8ClampedArray*); | 56 static Float32ImageData* create(const IntSize&, DOMFloat32Array*); |
54 static ImageData* create(unsigned width, unsigned height, ExceptionState&); | 57 static Float32ImageData* create(unsigned width, |
55 static ImageData* create(DOMUint8ClampedArray*, | 58 unsigned height, |
56 unsigned width, | 59 ExceptionState&); |
57 ExceptionState&); | 60 static Float32ImageData* create(unsigned width, |
58 static ImageData* create(DOMUint8ClampedArray*, | 61 unsigned height, |
59 unsigned width, | 62 String colorSpace, |
60 unsigned height, | 63 ExceptionState&); |
61 ExceptionState&); | 64 static Float32ImageData* create(DOMFloat32Array*, |
65 unsigned width, | |
66 ExceptionState&); | |
67 static Float32ImageData* create(DOMFloat32Array*, | |
68 unsigned width, | |
69 unsigned height, | |
70 ExceptionState&); | |
71 static Float32ImageData* create(DOMFloat32Array*, | |
72 unsigned width, | |
73 unsigned height, | |
74 String colorSpace, | |
75 ExceptionState&); | |
62 | 76 |
63 IntSize size() const { return m_size; } | 77 IntSize size() const { return m_size; } |
64 int width() const { return m_size.width(); } | 78 int width() const { return m_size.width(); } |
65 int height() const { return m_size.height(); } | 79 int height() const { return m_size.height(); } |
66 const DOMUint8ClampedArray* data() const { return m_data.get(); } | 80 String colorSpace() const { return m_colorSpace; } |
67 DOMUint8ClampedArray* data() { return m_data.get(); } | 81 const DOMFloat32Array* data() const { return m_data.get(); } |
82 DOMFloat32Array* data() { return m_data.get(); } | |
68 | 83 |
69 // ImageBitmapSource implementation | 84 // ImageBitmapSource implementation |
70 IntSize bitmapSourceSize() const override { return m_size; } | 85 IntSize bitmapSourceSize() const override { return m_size; } |
71 ScriptPromise createImageBitmap(ScriptState*, | 86 ScriptPromise createImageBitmap(ScriptState*, |
72 EventTarget&, | 87 EventTarget&, |
73 Optional<IntRect> cropRect, | 88 Optional<IntRect> cropRect, |
74 const ImageBitmapOptions&, | 89 const ImageBitmapOptions&, |
75 ExceptionState&) override; | 90 ExceptionState&) override; |
76 | 91 |
77 DEFINE_INLINE_TRACE() { visitor->trace(m_data); } | 92 DEFINE_INLINE_TRACE() { visitor->trace(m_data); } |
78 | 93 |
79 WARN_UNUSED_RESULT v8::Local<v8::Object> associateWithWrapper( | 94 WARN_UNUSED_RESULT v8::Local<v8::Object> associateWithWrapper( |
80 v8::Isolate*, | 95 v8::Isolate*, |
81 const WrapperTypeInfo*, | 96 const WrapperTypeInfo*, |
82 v8::Local<v8::Object> wrapper) override; | 97 v8::Local<v8::Object> wrapper) override; |
83 | 98 |
84 private: | 99 private: |
85 ImageData(const IntSize&, DOMUint8ClampedArray*); | 100 Float32ImageData(const IntSize&, |
101 DOMFloat32Array*, | |
102 String = kLegacyImageDataColorSpaceName); | |
86 | 103 |
87 static bool validateConstructorArguments(DOMUint8ClampedArray*, | 104 static bool validateConstructorArguments(DOMFloat32Array*, |
88 unsigned width, | 105 unsigned width, |
89 unsigned&, | 106 unsigned&, |
90 ExceptionState&); | 107 ExceptionState&); |
108 static bool validateConstructorArguments(DOMFloat32Array*, | |
109 unsigned width, | |
110 unsigned&, | |
111 String, | |
112 ExceptionState&); | |
91 | 113 |
92 IntSize m_size; | 114 IntSize m_size; |
93 Member<DOMUint8ClampedArray> m_data; | 115 String m_colorSpace; |
Justin Novosad
2016/12/08 18:16:35
You should not store this as a string. Use an enum
zakerinasab
2016/12/08 20:40:52
This is an older version. Fixed now.
| |
116 Member<DOMFloat32Array> m_data; | |
94 }; | 117 }; |
95 | 118 |
96 } // namespace blink | 119 } // namespace blink |
97 | 120 |
98 #endif // ImageData_h | 121 #endif // Float32ImageData_h |
OLD | NEW |