OLD | NEW |
| (Empty) |
1 /* | |
2 * Copyright (C) 2016 Google Inc. All rights reserved. | |
3 * | |
4 * Redistribution and use in source and binary forms, with or without | |
5 * modification, are permitted provided that the following conditions | |
6 * are met: | |
7 * | |
8 * 1. Redistributions of source code must retain the above copyright | |
9 * notice, this list of conditions and the following disclaimer. | |
10 * 2. Redistributions in binary form must reproduce the above copyright | |
11 * notice, this list of conditions and the following disclaimer in the | |
12 * documentation and/or other materials provided with the distribution. | |
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 | |
15 * from this software without specific prior written permission. | |
16 * | |
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 | |
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 | |
21 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | |
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 | |
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 | |
26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
27 */ | |
28 | |
29 #ifndef Float32ImageData_h | |
30 #define Float32ImageData_h | |
31 | |
32 #include "bindings/core/v8/ScriptWrappable.h" | |
33 #include "core/CoreExport.h" | |
34 #include "core/dom/DOMTypedArray.h" | |
35 #include "core/html/ImageData.h" | |
36 #include "core/imagebitmap/ImageBitmapSource.h" | |
37 #include "platform/geometry/IntRect.h" | |
38 #include "platform/geometry/IntSize.h" | |
39 #include "platform/heap/Handle.h" | |
40 #include "wtf/Compiler.h" | |
41 #include "wtf/text/WTFString.h" | |
42 | |
43 namespace blink { | |
44 | |
45 class ExceptionState; | |
46 | |
47 class CORE_EXPORT Float32ImageData final | |
48 : public GarbageCollectedFinalized<Float32ImageData>, | |
49 public ScriptWrappable { | |
50 DEFINE_WRAPPERTYPEINFO(); | |
51 | |
52 public: | |
53 static Float32ImageData* create(const IntSize&); | |
54 static Float32ImageData* create(const IntSize&, DOMFloat32Array*); | |
55 static Float32ImageData* create(unsigned width, | |
56 unsigned height, | |
57 ExceptionState&); | |
58 static Float32ImageData* create(unsigned width, | |
59 unsigned height, | |
60 String colorSpace, | |
61 ExceptionState&); | |
62 static Float32ImageData* create(DOMFloat32Array*, | |
63 unsigned width, | |
64 ExceptionState&); | |
65 static Float32ImageData* create(DOMFloat32Array*, | |
66 unsigned width, | |
67 String colorSpace, | |
68 ExceptionState&); | |
69 static Float32ImageData* create(DOMFloat32Array*, | |
70 unsigned width, | |
71 unsigned height, | |
72 ExceptionState&); | |
73 static Float32ImageData* create(DOMFloat32Array*, | |
74 unsigned width, | |
75 unsigned height, | |
76 String colorSpace, | |
77 ExceptionState&); | |
78 | |
79 IntSize size() const { return m_size; } | |
80 int width() const { return m_size.width(); } | |
81 int height() const { return m_size.height(); } | |
82 String colorSpace() const { | |
83 return ImageData::getImageDataColorSpaceName(m_colorSpace); | |
84 } | |
85 ImageDataColorSpace imageDataColorSpace() { return m_colorSpace; } | |
86 const DOMFloat32Array* data() const { return m_data.get(); } | |
87 DOMFloat32Array* data() { return m_data.get(); } | |
88 | |
89 DEFINE_INLINE_TRACE() { visitor->trace(m_data); } | |
90 | |
91 WARN_UNUSED_RESULT v8::Local<v8::Object> associateWithWrapper( | |
92 v8::Isolate*, | |
93 const WrapperTypeInfo*, | |
94 v8::Local<v8::Object> wrapper) override; | |
95 | |
96 private: | |
97 Float32ImageData(const IntSize&, | |
98 DOMFloat32Array*, | |
99 String = kLinearRGBImageDataColorSpaceName); | |
100 | |
101 IntSize m_size; | |
102 ImageDataColorSpace m_colorSpace; | |
103 Member<DOMFloat32Array> m_data; | |
104 | |
105 static bool validateConstructorArguments(const unsigned&, | |
106 const IntSize* = nullptr, | |
107 const unsigned& = 0, | |
108 const unsigned& = 0, | |
109 const DOMFloat32Array* = nullptr, | |
110 const String* = nullptr, | |
111 ExceptionState* = nullptr); | |
112 | |
113 static DOMFloat32Array* allocateAndValidateFloat32Array( | |
114 const unsigned&, | |
115 ExceptionState* = nullptr); | |
116 }; | |
117 | |
118 } // namespace blink | |
119 | |
120 #endif // Float32ImageData_h | |
OLD | NEW |