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

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

Issue 2636533002: Revert of Implement color management for ImageData
Patch Set: Created 3 years, 11 months 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
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
(...skipping 13 matching lines...) Expand all
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 ImageData_h
30 #define ImageData_h 30 #define ImageData_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/DOMArrayBufferView.h"
35 #include "core/dom/DOMTypedArray.h" 34 #include "core/dom/DOMTypedArray.h"
36 #include "core/imagebitmap/ImageBitmapSource.h" 35 #include "core/imagebitmap/ImageBitmapSource.h"
37 #include "platform/geometry/IntRect.h" 36 #include "platform/geometry/IntRect.h"
38 #include "platform/geometry/IntSize.h" 37 #include "platform/geometry/IntSize.h"
39 #include "platform/heap/Handle.h" 38 #include "platform/heap/Handle.h"
40 #include "wtf/CheckedNumeric.h"
41 #include "wtf/Compiler.h" 39 #include "wtf/Compiler.h"
42 #include "wtf/text/WTFString.h"
43 40
44 namespace blink { 41 namespace blink {
45 42
46 class ExceptionState; 43 class ExceptionState;
47 class ImageBitmapOptions; 44 class ImageBitmapOptions;
48 45
49 enum ConstructorParams {
50 kParamSize = 1,
51 kParamWidth = 1 << 1,
52 kParamHeight = 1 << 2,
53 kParamData = 1 << 3,
54 kParamColorSpace = 1 << 4,
55 };
56
57 enum ImageDataType {
58 kUint8ClampedImageData,
59 kFloat32ImageData,
60 };
61
62 enum ImageDataColorSpace {
63 kLegacyImageDataColorSpace,
64 kSRGBImageDataColorSpace,
65 kLinearRGBImageDataColorSpace,
66 };
67
68 const char* const kLinearRGBImageDataColorSpaceName = "linear-rgb";
69 const char* const kSRGBImageDataColorSpaceName = "srgb";
70 const char* const kLegacyImageDataColorSpaceName = "legacy-srgb";
71
72 class CORE_EXPORT ImageData final : public GarbageCollectedFinalized<ImageData>, 46 class CORE_EXPORT ImageData final : public GarbageCollectedFinalized<ImageData>,
73 public ScriptWrappable, 47 public ScriptWrappable,
74 public ImageBitmapSource { 48 public ImageBitmapSource {
75 DEFINE_WRAPPERTYPEINFO(); 49 DEFINE_WRAPPERTYPEINFO();
76 50
77 public: 51 public:
78 static ImageData* create(const IntSize&); 52 static ImageData* create(const IntSize&);
79 static ImageData* create(const IntSize&, DOMUint8ClampedArray*); 53 static ImageData* create(const IntSize&, DOMUint8ClampedArray*);
80 static ImageData* create(unsigned width, unsigned height, ExceptionState&); 54 static ImageData* create(unsigned width, unsigned height, ExceptionState&);
81 static ImageData* create(DOMUint8ClampedArray*, 55 static ImageData* create(DOMUint8ClampedArray*,
82 unsigned width, 56 unsigned width,
83 ExceptionState&); 57 ExceptionState&);
84 static ImageData* create(DOMUint8ClampedArray*, 58 static ImageData* create(DOMUint8ClampedArray*,
85 unsigned width, 59 unsigned width,
86 unsigned height, 60 unsigned height,
87 ExceptionState&); 61 ExceptionState&);
88 62
89 static ImageData* createForTest(const IntSize&);
90
91 ImageData* createImageData(unsigned width,
92 unsigned height,
93 String colorSpace,
94 ExceptionState&);
95 ImageData* createImageData(DOMUint8ClampedArray*,
96 unsigned width,
97 String colorSpace,
98 ExceptionState&);
99 ImageData* createImageData(DOMUint8ClampedArray*,
100 unsigned width,
101 unsigned height,
102 String colorSpace,
103 ExceptionState&);
104
105 static ImageDataColorSpace getImageDataColorSpace(String);
106 static String getImageDataColorSpaceName(ImageDataColorSpace);
107
108 IntSize size() const { return m_size; } 63 IntSize size() const { return m_size; }
109 int width() const { return m_size.width(); } 64 int width() const { return m_size.width(); }
110 int height() const { return m_size.height(); } 65 int height() const { return m_size.height(); }
111 String colorSpace() const { return getImageDataColorSpaceName(m_colorSpace); }
112 ImageDataColorSpace imageDataColorSpace() { return m_colorSpace; }
113 const DOMUint8ClampedArray* data() const { return m_data.get(); } 66 const DOMUint8ClampedArray* data() const { return m_data.get(); }
114 DOMUint8ClampedArray* data() { return m_data.get(); } 67 DOMUint8ClampedArray* data() { return m_data.get(); }
115 68
116 // ImageBitmapSource implementation 69 // ImageBitmapSource implementation
117 IntSize bitmapSourceSize() const override { return m_size; } 70 IntSize bitmapSourceSize() const override { return m_size; }
118 ScriptPromise createImageBitmap(ScriptState*, 71 ScriptPromise createImageBitmap(ScriptState*,
119 EventTarget&, 72 EventTarget&,
120 Optional<IntRect> cropRect, 73 Optional<IntRect> cropRect,
121 const ImageBitmapOptions&, 74 const ImageBitmapOptions&,
122 ExceptionState&) override; 75 ExceptionState&) override;
123 76
124 DEFINE_INLINE_TRACE() { visitor->trace(m_data); } 77 DEFINE_INLINE_TRACE() { visitor->trace(m_data); }
125 78
126 WARN_UNUSED_RESULT v8::Local<v8::Object> associateWithWrapper( 79 WARN_UNUSED_RESULT v8::Local<v8::Object> associateWithWrapper(
127 v8::Isolate*, 80 v8::Isolate*,
128 const WrapperTypeInfo*, 81 const WrapperTypeInfo*,
129 v8::Local<v8::Object> wrapper) override; 82 v8::Local<v8::Object> wrapper) override;
130 83
131 static bool validateConstructorArguments( 84 private:
132 const unsigned&, 85 ImageData(const IntSize&, DOMUint8ClampedArray*);
133 const IntSize* = nullptr,
134 const unsigned& = 0,
135 const unsigned& = 0,
136 const DOMArrayBufferView* = nullptr,
137 const String* = nullptr,
138 ExceptionState* = nullptr,
139 ImageDataType = kUint8ClampedImageData);
140 86
141 private: 87 static bool validateConstructorArguments(DOMUint8ClampedArray*,
142 ImageData(const IntSize&, 88 unsigned width,
143 DOMUint8ClampedArray*, 89 unsigned&,
144 String = kLegacyImageDataColorSpaceName); 90 ExceptionState&);
145 91
146 IntSize m_size; 92 IntSize m_size;
147 ImageDataColorSpace m_colorSpace;
148 Member<DOMUint8ClampedArray> m_data; 93 Member<DOMUint8ClampedArray> m_data;
149
150 static DOMUint8ClampedArray* allocateAndValidateUint8ClampedArray(
151 const unsigned&,
152 ExceptionState* = nullptr);
153 }; 94 };
154 95
155 } // namespace blink 96 } // namespace blink
156 97
157 #endif // ImageData_h 98 #endif // ImageData_h
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/html/Float32ImageData.idl ('k') | third_party/WebKit/Source/core/html/ImageData.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698