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

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

Issue 2555213002: Implement color management for ImageData (Closed)
Patch Set: Addressing comments. 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
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 19 matching lines...) Expand all
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/DOMTypedArray.h" 34 #include "core/dom/DOMTypedArray.h"
35 #include "core/imagebitmap/ImageBitmapSource.h" 35 #include "core/imagebitmap/ImageBitmapSource.h"
36 #include "platform/geometry/IntRect.h" 36 #include "platform/geometry/IntRect.h"
37 #include "platform/geometry/IntSize.h" 37 #include "platform/geometry/IntSize.h"
38 #include "platform/heap/Handle.h" 38 #include "platform/heap/Handle.h"
39 #include "wtf/Compiler.h" 39 #include "wtf/Compiler.h"
40 #include "wtf/text/WTFString.h"
40 41
41 namespace blink { 42 namespace blink {
42 43
43 class ExceptionState; 44 class ExceptionState;
44 class ImageBitmapOptions; 45 class ImageBitmapOptions;
45 46
47 enum ImageDataColorSpace {
48 kLegacyImageDataColorSpace,
49 kSRGBImageDataColorSpace,
50 kLinearRGBImageDataColorSpace,
51 };
52
53 const char* const kLinearRGBImageDataColorSpaceName = "linear-rgb";
54 const char* const kSRGBImageDataColorSpaceName = "srgb";
55 const char* const kLegacyImageDataColorSpaceName = "legacy-srgb";
56
46 class CORE_EXPORT ImageData final : public GarbageCollectedFinalized<ImageData>, 57 class CORE_EXPORT ImageData final : public GarbageCollectedFinalized<ImageData>,
47 public ScriptWrappable, 58 public ScriptWrappable,
48 public ImageBitmapSource { 59 public ImageBitmapSource {
49 DEFINE_WRAPPERTYPEINFO(); 60 DEFINE_WRAPPERTYPEINFO();
50 61
51 public: 62 public:
52 static ImageData* create(const IntSize&); 63 static ImageData* create(const IntSize&);
53 static ImageData* create(const IntSize&, DOMUint8ClampedArray*); 64 static ImageData* create(const IntSize&, DOMUint8ClampedArray*);
54 static ImageData* create(unsigned width, unsigned height, ExceptionState&); 65 static ImageData* create(unsigned width, unsigned height, ExceptionState&);
66 static ImageData* create(unsigned width,
67 unsigned height,
68 String colorSpace,
69 ExceptionState&);
55 static ImageData* create(DOMUint8ClampedArray*, 70 static ImageData* create(DOMUint8ClampedArray*,
56 unsigned width, 71 unsigned width,
57 ExceptionState&); 72 ExceptionState&);
58 static ImageData* create(DOMUint8ClampedArray*, 73 static ImageData* create(DOMUint8ClampedArray*,
59 unsigned width, 74 unsigned width,
60 unsigned height, 75 unsigned height,
61 ExceptionState&); 76 ExceptionState&);
77 static ImageData* create(DOMUint8ClampedArray*,
78 unsigned width,
79 unsigned height,
80 String colorSpace,
81 ExceptionState&);
82
83 static ImageDataColorSpace getImageDataColorSpace(String);
84 static String getImageDataColorSpaceName(ImageDataColorSpace);
62 85
63 IntSize size() const { return m_size; } 86 IntSize size() const { return m_size; }
64 int width() const { return m_size.width(); } 87 int width() const { return m_size.width(); }
65 int height() const { return m_size.height(); } 88 int height() const { return m_size.height(); }
89 String colorSpace() const { return getImageDataColorSpaceName(m_colorSpace); }
90 ImageDataColorSpace imageDataColorSpace() { return m_colorSpace; }
66 const DOMUint8ClampedArray* data() const { return m_data.get(); } 91 const DOMUint8ClampedArray* data() const { return m_data.get(); }
67 DOMUint8ClampedArray* data() { return m_data.get(); } 92 DOMUint8ClampedArray* data() { return m_data.get(); }
68 93
69 // ImageBitmapSource implementation 94 // ImageBitmapSource implementation
70 IntSize bitmapSourceSize() const override { return m_size; } 95 IntSize bitmapSourceSize() const override { return m_size; }
71 ScriptPromise createImageBitmap(ScriptState*, 96 ScriptPromise createImageBitmap(ScriptState*,
72 EventTarget&, 97 EventTarget&,
73 Optional<IntRect> cropRect, 98 Optional<IntRect> cropRect,
74 const ImageBitmapOptions&, 99 const ImageBitmapOptions&,
75 ExceptionState&) override; 100 ExceptionState&) override;
76 101
77 DEFINE_INLINE_TRACE() { visitor->trace(m_data); } 102 DEFINE_INLINE_TRACE() { visitor->trace(m_data); }
78 103
79 WARN_UNUSED_RESULT v8::Local<v8::Object> associateWithWrapper( 104 WARN_UNUSED_RESULT v8::Local<v8::Object> associateWithWrapper(
80 v8::Isolate*, 105 v8::Isolate*,
81 const WrapperTypeInfo*, 106 const WrapperTypeInfo*,
82 v8::Local<v8::Object> wrapper) override; 107 v8::Local<v8::Object> wrapper) override;
83 108
84 private: 109 private:
85 ImageData(const IntSize&, DOMUint8ClampedArray*); 110 ImageData(const IntSize&,
111 DOMUint8ClampedArray*,
112 String = kLegacyImageDataColorSpaceName);
86 113
87 static bool validateConstructorArguments(DOMUint8ClampedArray*, 114 static bool validateConstructorArguments(DOMUint8ClampedArray*,
88 unsigned width, 115 unsigned width,
89 unsigned&, 116 unsigned&,
90 ExceptionState&); 117 ExceptionState&);
91 118 static bool validateConstructorArguments(DOMUint8ClampedArray*,
119 unsigned width,
120 unsigned&,
121 String,
122 ExceptionState&);
92 IntSize m_size; 123 IntSize m_size;
124 ImageDataColorSpace m_colorSpace;
93 Member<DOMUint8ClampedArray> m_data; 125 Member<DOMUint8ClampedArray> m_data;
94 }; 126 };
95 127
96 } // namespace blink 128 } // namespace blink
97 129
98 #endif // ImageData_h 130 #endif // ImageData_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698