| 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 |
| (...skipping 15 matching lines...) Expand all Loading... |
| 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" | 34 #include "core/dom/DOMArrayBufferView.h" |
| 35 #include "core/dom/DOMTypedArray.h" | 35 #include "core/dom/DOMTypedArray.h" |
| 36 #include "core/dom/MaybeShared.h" |
| 36 #include "core/imagebitmap/ImageBitmapSource.h" | 37 #include "core/imagebitmap/ImageBitmapSource.h" |
| 37 #include "platform/geometry/IntRect.h" | 38 #include "platform/geometry/IntRect.h" |
| 38 #include "platform/geometry/IntSize.h" | 39 #include "platform/geometry/IntSize.h" |
| 39 #include "platform/heap/Handle.h" | 40 #include "platform/heap/Handle.h" |
| 40 #include "third_party/skia/include/core/SkColorSpace.h" | 41 #include "third_party/skia/include/core/SkColorSpace.h" |
| 41 #include "wtf/CheckedNumeric.h" | 42 #include "wtf/CheckedNumeric.h" |
| 42 #include "wtf/Compiler.h" | 43 #include "wtf/Compiler.h" |
| 43 #include "wtf/text/WTFString.h" | 44 #include "wtf/text/WTFString.h" |
| 44 | 45 |
| 45 namespace blink { | 46 namespace blink { |
| (...skipping 24 matching lines...) Expand all Loading... |
| 70 const char* const kSRGBImageDataColorSpaceName = "srgb"; | 71 const char* const kSRGBImageDataColorSpaceName = "srgb"; |
| 71 const char* const kLegacyImageDataColorSpaceName = "legacy-srgb"; | 72 const char* const kLegacyImageDataColorSpaceName = "legacy-srgb"; |
| 72 | 73 |
| 73 class CORE_EXPORT ImageData final : public GarbageCollectedFinalized<ImageData>, | 74 class CORE_EXPORT ImageData final : public GarbageCollectedFinalized<ImageData>, |
| 74 public ScriptWrappable, | 75 public ScriptWrappable, |
| 75 public ImageBitmapSource { | 76 public ImageBitmapSource { |
| 76 DEFINE_WRAPPERTYPEINFO(); | 77 DEFINE_WRAPPERTYPEINFO(); |
| 77 | 78 |
| 78 public: | 79 public: |
| 79 static ImageData* create(const IntSize&); | 80 static ImageData* create(const IntSize&); |
| 80 static ImageData* create(const IntSize&, DOMUint8ClampedArray*); | |
| 81 static ImageData* create(const IntSize&, | 81 static ImageData* create(const IntSize&, |
| 82 DOMUint8ClampedArray*, | 82 const MaybeShared<DOMUint8ClampedArray>&); |
| 83 static ImageData* create(const IntSize&, |
| 84 const MaybeShared<DOMUint8ClampedArray>&, |
| 83 const String&); | 85 const String&); |
| 84 static ImageData* create(unsigned width, unsigned height, ExceptionState&); | 86 static ImageData* create(unsigned width, unsigned height, ExceptionState&); |
| 85 static ImageData* create(DOMUint8ClampedArray*, | 87 static ImageData* create(const MaybeShared<DOMUint8ClampedArray>&, |
| 86 unsigned width, | 88 unsigned width, |
| 87 ExceptionState&); | 89 ExceptionState&); |
| 88 static ImageData* create(DOMUint8ClampedArray*, | 90 static ImageData* create(const MaybeShared<DOMUint8ClampedArray>&, |
| 89 unsigned width, | 91 unsigned width, |
| 90 unsigned height, | 92 unsigned height, |
| 91 ExceptionState&); | 93 ExceptionState&); |
| 92 | 94 |
| 93 static ImageData* createForTest(const IntSize&); | 95 static ImageData* createForTest(const IntSize&); |
| 94 | 96 |
| 95 ImageData* createImageData(unsigned width, | 97 ImageData* createImageData(unsigned width, |
| 96 unsigned height, | 98 unsigned height, |
| 97 String colorSpace, | 99 String colorSpace, |
| 98 ExceptionState&); | 100 ExceptionState&); |
| 99 ImageData* createImageData(DOMUint8ClampedArray*, | 101 ImageData* createImageData(const MaybeShared<DOMUint8ClampedArray>&, |
| 100 unsigned width, | 102 unsigned width, |
| 101 String colorSpace, | 103 String colorSpace, |
| 102 ExceptionState&); | 104 ExceptionState&); |
| 103 ImageData* createImageData(DOMUint8ClampedArray*, | 105 ImageData* createImageData(const MaybeShared<DOMUint8ClampedArray>&, |
| 104 unsigned width, | 106 unsigned width, |
| 105 unsigned height, | 107 unsigned height, |
| 106 String colorSpace, | 108 String colorSpace, |
| 107 ExceptionState&); | 109 ExceptionState&); |
| 108 | 110 |
| 109 static ImageDataColorSpace getImageDataColorSpace(String); | 111 static ImageDataColorSpace getImageDataColorSpace(String); |
| 110 static String getImageDataColorSpaceName(ImageDataColorSpace); | 112 static String getImageDataColorSpaceName(ImageDataColorSpace); |
| 111 static sk_sp<SkColorSpace> imageDataColorSpaceToSkColorSpace( | 113 static sk_sp<SkColorSpace> imageDataColorSpaceToSkColorSpace( |
| 112 ImageDataColorSpace); | 114 ImageDataColorSpace); |
| 113 | 115 |
| (...skipping 25 matching lines...) Expand all Loading... |
| 139 static bool validateConstructorArguments( | 141 static bool validateConstructorArguments( |
| 140 const unsigned&, | 142 const unsigned&, |
| 141 const IntSize* = nullptr, | 143 const IntSize* = nullptr, |
| 142 const unsigned& = 0, | 144 const unsigned& = 0, |
| 143 const unsigned& = 0, | 145 const unsigned& = 0, |
| 144 const DOMArrayBufferView* = nullptr, | 146 const DOMArrayBufferView* = nullptr, |
| 145 const String* = nullptr, | 147 const String* = nullptr, |
| 146 ExceptionState* = nullptr, | 148 ExceptionState* = nullptr, |
| 147 ImageDataType = kUint8ClampedImageData); | 149 ImageDataType = kUint8ClampedImageData); |
| 148 | 150 |
| 151 template <typename T> |
| 152 static bool validateDataArgumentIsNotShared(const MaybeShared<T>& maybeShared, |
| 153 ExceptionState* exceptionState) { |
| 154 if (maybeShared.isShared()) { |
| 155 if (exceptionState) { |
| 156 exceptionState->throwTypeError( |
| 157 "The data is backed by a SharedArrayBuffer."); |
| 158 } |
| 159 return false; |
| 160 } |
| 161 return true; |
| 162 } |
| 163 |
| 149 private: | 164 private: |
| 150 ImageData(const IntSize&, | 165 ImageData(const IntSize&, |
| 151 DOMUint8ClampedArray*, | 166 DOMUint8ClampedArray*, |
| 152 String = kLegacyImageDataColorSpaceName); | 167 String = kLegacyImageDataColorSpaceName); |
| 153 | 168 |
| 154 IntSize m_size; | 169 IntSize m_size; |
| 155 ImageDataColorSpace m_colorSpace; | 170 ImageDataColorSpace m_colorSpace; |
| 156 Member<DOMUint8ClampedArray> m_data; | 171 Member<DOMUint8ClampedArray> m_data; |
| 157 | 172 |
| 158 static DOMUint8ClampedArray* allocateAndValidateUint8ClampedArray( | 173 static DOMUint8ClampedArray* allocateAndValidateUint8ClampedArray( |
| 159 const unsigned&, | 174 const unsigned&, |
| 160 ExceptionState* = nullptr); | 175 ExceptionState* = nullptr); |
| 161 }; | 176 }; |
| 162 | 177 |
| 163 } // namespace blink | 178 } // namespace blink |
| 164 | 179 |
| 165 #endif // ImageData_h | 180 #endif // ImageData_h |
| OLD | NEW |