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" |
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 { |
67 DOMUint8ClampedArray* data() { return m_data.get(); } | 81 return ImageData::getImageDataColorSpaceName(m_colorSpace); |
| 82 } |
| 83 ImageDataColorSpace imageDataColorSpace() { return m_colorSpace; } |
| 84 const DOMFloat32Array* data() const { return m_data.get(); } |
| 85 DOMFloat32Array* data() { return m_data.get(); } |
68 | 86 |
69 // ImageBitmapSource implementation | 87 // ImageBitmapSource implementation |
70 IntSize bitmapSourceSize() const override { return m_size; } | 88 IntSize bitmapSourceSize() const override { return m_size; } |
71 ScriptPromise createImageBitmap(ScriptState*, | 89 ScriptPromise createImageBitmap(ScriptState*, |
72 EventTarget&, | 90 EventTarget&, |
73 Optional<IntRect> cropRect, | 91 Optional<IntRect> cropRect, |
74 const ImageBitmapOptions&, | 92 const ImageBitmapOptions&, |
75 ExceptionState&) override; | 93 ExceptionState&) override; |
76 | 94 |
77 DEFINE_INLINE_TRACE() { visitor->trace(m_data); } | 95 DEFINE_INLINE_TRACE() { visitor->trace(m_data); } |
78 | 96 |
79 WARN_UNUSED_RESULT v8::Local<v8::Object> associateWithWrapper( | 97 WARN_UNUSED_RESULT v8::Local<v8::Object> associateWithWrapper( |
80 v8::Isolate*, | 98 v8::Isolate*, |
81 const WrapperTypeInfo*, | 99 const WrapperTypeInfo*, |
82 v8::Local<v8::Object> wrapper) override; | 100 v8::Local<v8::Object> wrapper) override; |
83 | 101 |
84 private: | 102 private: |
85 ImageData(const IntSize&, DOMUint8ClampedArray*); | 103 Float32ImageData(const IntSize&, |
| 104 DOMFloat32Array*, |
| 105 String = kLegacyImageDataColorSpaceName); |
86 | 106 |
87 static bool validateConstructorArguments(DOMUint8ClampedArray*, | 107 static bool validateConstructorArguments(DOMFloat32Array*, |
88 unsigned width, | 108 unsigned width, |
89 unsigned&, | 109 unsigned&, |
90 ExceptionState&); | 110 ExceptionState&); |
| 111 static bool validateConstructorArguments(DOMFloat32Array*, |
| 112 unsigned width, |
| 113 unsigned&, |
| 114 String, |
| 115 ExceptionState&); |
91 | 116 |
92 IntSize m_size; | 117 IntSize m_size; |
93 Member<DOMUint8ClampedArray> m_data; | 118 ImageDataColorSpace m_colorSpace; |
| 119 Member<DOMFloat32Array> m_data; |
94 }; | 120 }; |
95 | 121 |
96 } // namespace blink | 122 } // namespace blink |
97 | 123 |
98 #endif // ImageData_h | 124 #endif // Float32ImageData_h |
OLD | NEW |