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

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

Issue 2555213002: Implement color management for ImageData (Closed)
Patch Set: Work in progress 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 kLegacyImageDataColorSpaceName = "linear-rgb";
54 const char* const kSRGBImageDataColorSpaceName = "srgb";
55 const char* const kLinearRGBImageDataColorSpaceName = "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&);
62 82
63 IntSize size() const { return m_size; } 83 IntSize size() const { return m_size; }
64 int width() const { return m_size.width(); } 84 int width() const { return m_size.width(); }
65 int height() const { return m_size.height(); } 85 int height() const { return m_size.height(); }
86 String colorSpace() const { return m_colorSpace; }
66 const DOMUint8ClampedArray* data() const { return m_data.get(); } 87 const DOMUint8ClampedArray* data() const { return m_data.get(); }
67 DOMUint8ClampedArray* data() { return m_data.get(); } 88 DOMUint8ClampedArray* data() { return m_data.get(); }
68 89
69 // ImageBitmapSource implementation 90 // ImageBitmapSource implementation
70 IntSize bitmapSourceSize() const override { return m_size; } 91 IntSize bitmapSourceSize() const override { return m_size; }
71 ScriptPromise createImageBitmap(ScriptState*, 92 ScriptPromise createImageBitmap(ScriptState*,
72 EventTarget&, 93 EventTarget&,
73 Optional<IntRect> cropRect, 94 Optional<IntRect> cropRect,
74 const ImageBitmapOptions&, 95 const ImageBitmapOptions&,
75 ExceptionState&) override; 96 ExceptionState&) override;
76 97
77 DEFINE_INLINE_TRACE() { visitor->trace(m_data); } 98 DEFINE_INLINE_TRACE() { visitor->trace(m_data); }
78 99
79 WARN_UNUSED_RESULT v8::Local<v8::Object> associateWithWrapper( 100 WARN_UNUSED_RESULT v8::Local<v8::Object> associateWithWrapper(
80 v8::Isolate*, 101 v8::Isolate*,
81 const WrapperTypeInfo*, 102 const WrapperTypeInfo*,
82 v8::Local<v8::Object> wrapper) override; 103 v8::Local<v8::Object> wrapper) override;
83 104
84 private: 105 private:
85 ImageData(const IntSize&, DOMUint8ClampedArray*); 106 ImageData(const IntSize&,
107 DOMUint8ClampedArray*,
108 String = kLegacyImageDataColorSpaceName);
86 109
87 static bool validateConstructorArguments(DOMUint8ClampedArray*, 110 static bool validateConstructorArguments(DOMUint8ClampedArray*,
88 unsigned width, 111 unsigned width,
89 unsigned&, 112 unsigned&,
90 ExceptionState&); 113 ExceptionState&);
114 static bool validateConstructorArguments(DOMUint8ClampedArray*,
115 unsigned width,
116 unsigned&,
117 String,
118 ExceptionState&);
91 119
92 IntSize m_size; 120 IntSize m_size;
121 String m_colorSpace;
Justin Novosad 2016/12/08 18:16:35 You should store this as an enum, and use an attri
zakerinasab 2016/12/08 20:40:52 Fixed.
93 Member<DOMUint8ClampedArray> m_data; 122 Member<DOMUint8ClampedArray> m_data;
94 }; 123 };
95 124
96 } // namespace blink 125 } // namespace blink
97 126
98 #endif // ImageData_h 127 #endif // ImageData_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698