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

Side by Side Diff: third_party/WebKit/Source/core/html/Float32ImageData.h

Issue 2555213002: Implement color management for ImageData (Closed)
Patch Set: Addressing issues Created 4 years 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
(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 class ImageBitmapOptions;
47
48 class CORE_EXPORT Float32ImageData final
49 : public GarbageCollectedFinalized<Float32ImageData>,
50 public ScriptWrappable,
51 public ImageBitmapSource {
52 DEFINE_WRAPPERTYPEINFO();
53
54 public:
55 static Float32ImageData* create(const IntSize&);
56 static Float32ImageData* create(const IntSize&, DOMFloat32Array*);
57 static Float32ImageData* create(unsigned width,
58 unsigned height,
59 ExceptionState&);
60 static Float32ImageData* create(unsigned width,
61 unsigned height,
62 String colorSpace,
63 ExceptionState&);
64 static Float32ImageData* create(DOMFloat32Array*,
65 unsigned width,
66 ExceptionState&);
67 static Float32ImageData* create(DOMFloat32Array*,
68 unsigned width,
69 String colorSpace,
70 ExceptionState&);
71 static Float32ImageData* create(DOMFloat32Array*,
72 unsigned width,
73 unsigned height,
74 ExceptionState&);
75 static Float32ImageData* create(DOMFloat32Array*,
76 unsigned width,
77 unsigned height,
78 String colorSpace,
79 ExceptionState&);
80
81 IntSize size() const { return m_size; }
82 int width() const { return m_size.width(); }
83 int height() const { return m_size.height(); }
84 String colorSpace() const {
85 return ImageData::getImageDataColorSpaceName(m_colorSpace);
86 }
87 ImageDataColorSpace imageDataColorSpace() { return m_colorSpace; }
88 const DOMFloat32Array* data() const { return m_data.get(); }
89 DOMFloat32Array* data() { return m_data.get(); }
90
91 // ImageBitmapSource implementation
92 IntSize bitmapSourceSize() const override { return m_size; }
93 ScriptPromise createImageBitmap(ScriptState*,
94 EventTarget&,
95 Optional<IntRect> cropRect,
96 const ImageBitmapOptions&,
97 ExceptionState&) override;
98
99 DEFINE_INLINE_TRACE() { visitor->trace(m_data); }
100
101 WARN_UNUSED_RESULT v8::Local<v8::Object> associateWithWrapper(
102 v8::Isolate*,
103 const WrapperTypeInfo*,
104 v8::Local<v8::Object> wrapper) override;
105
106 private:
107 Float32ImageData(const IntSize&,
108 DOMFloat32Array*,
109 String = kLinearRGBImageDataColorSpaceName);
110
111 IntSize m_size;
112 ImageDataColorSpace m_colorSpace;
113 Member<DOMFloat32Array> m_data;
114
115 static bool validateConstructorArguments(const unsigned&,
116 const IntSize* = nullptr,
117 const unsigned& = 0,
118 const unsigned& = 0,
119 const DOMFloat32Array* = nullptr,
120 const String* = nullptr,
121 ExceptionState* = nullptr);
122
123 static DOMFloat32Array* allocateAndValidateFloat32Array(
124 const unsigned&,
125 ExceptionState* = nullptr);
126 };
127
128 } // namespace blink
129
130 #endif // Float32ImageData_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698