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

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

Issue 2630563003: Fix ImageBitmap constructor from ImageData to consider the color space tags (Closed)
Patch Set: Rebaseline 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 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/DOMArrayBufferView.h" 34 #include "core/dom/DOMArrayBufferView.h"
35 #include "core/dom/DOMTypedArray.h" 35 #include "core/dom/DOMTypedArray.h"
36 #include "core/imagebitmap/ImageBitmapSource.h" 36 #include "core/imagebitmap/ImageBitmapSource.h"
37 #include "platform/geometry/IntRect.h" 37 #include "platform/geometry/IntRect.h"
38 #include "platform/geometry/IntSize.h" 38 #include "platform/geometry/IntSize.h"
39 #include "platform/heap/Handle.h" 39 #include "platform/heap/Handle.h"
40 #include "third_party/skia/include/core/SkColorSpace.h"
40 #include "wtf/CheckedNumeric.h" 41 #include "wtf/CheckedNumeric.h"
41 #include "wtf/Compiler.h" 42 #include "wtf/Compiler.h"
42 #include "wtf/text/WTFString.h" 43 #include "wtf/text/WTFString.h"
43 44
44 namespace blink { 45 namespace blink {
45 46
46 class ExceptionState; 47 class ExceptionState;
47 class ImageBitmapOptions; 48 class ImageBitmapOptions;
48 49
49 enum ConstructorParams { 50 enum ConstructorParams {
(...skipping 20 matching lines...) Expand all
70 const char* const kLegacyImageDataColorSpaceName = "legacy-srgb"; 71 const char* const kLegacyImageDataColorSpaceName = "legacy-srgb";
71 72
72 class CORE_EXPORT ImageData final : public GarbageCollectedFinalized<ImageData>, 73 class CORE_EXPORT ImageData final : public GarbageCollectedFinalized<ImageData>,
73 public ScriptWrappable, 74 public ScriptWrappable,
74 public ImageBitmapSource { 75 public ImageBitmapSource {
75 DEFINE_WRAPPERTYPEINFO(); 76 DEFINE_WRAPPERTYPEINFO();
76 77
77 public: 78 public:
78 static ImageData* create(const IntSize&); 79 static ImageData* create(const IntSize&);
79 static ImageData* create(const IntSize&, DOMUint8ClampedArray*); 80 static ImageData* create(const IntSize&, DOMUint8ClampedArray*);
81 static ImageData* create(const IntSize&,
82 DOMUint8ClampedArray*,
83 const String&);
80 static ImageData* create(unsigned width, unsigned height, ExceptionState&); 84 static ImageData* create(unsigned width, unsigned height, ExceptionState&);
81 static ImageData* create(DOMUint8ClampedArray*, 85 static ImageData* create(DOMUint8ClampedArray*,
82 unsigned width, 86 unsigned width,
83 ExceptionState&); 87 ExceptionState&);
84 static ImageData* create(DOMUint8ClampedArray*, 88 static ImageData* create(DOMUint8ClampedArray*,
85 unsigned width, 89 unsigned width,
86 unsigned height, 90 unsigned height,
87 ExceptionState&); 91 ExceptionState&);
88 92
89 static ImageData* createForTest(const IntSize&); 93 static ImageData* createForTest(const IntSize&);
90 94
91 ImageData* createImageData(unsigned width, 95 ImageData* createImageData(unsigned width,
92 unsigned height, 96 unsigned height,
93 String colorSpace, 97 String colorSpace,
94 ExceptionState&); 98 ExceptionState&);
95 ImageData* createImageData(DOMUint8ClampedArray*, 99 ImageData* createImageData(DOMUint8ClampedArray*,
96 unsigned width, 100 unsigned width,
97 String colorSpace, 101 String colorSpace,
98 ExceptionState&); 102 ExceptionState&);
99 ImageData* createImageData(DOMUint8ClampedArray*, 103 ImageData* createImageData(DOMUint8ClampedArray*,
100 unsigned width, 104 unsigned width,
101 unsigned height, 105 unsigned height,
102 String colorSpace, 106 String colorSpace,
103 ExceptionState&); 107 ExceptionState&);
104 108
105 static ImageDataColorSpace getImageDataColorSpace(String); 109 static ImageDataColorSpace getImageDataColorSpace(String);
106 static String getImageDataColorSpaceName(ImageDataColorSpace); 110 static String getImageDataColorSpaceName(ImageDataColorSpace);
111 static sk_sp<SkColorSpace> imageDataColorSpaceToSkColorSpace(
112 ImageDataColorSpace);
107 113
108 IntSize size() const { return m_size; } 114 IntSize size() const { return m_size; }
109 int width() const { return m_size.width(); } 115 int width() const { return m_size.width(); }
110 int height() const { return m_size.height(); } 116 int height() const { return m_size.height(); }
111 String colorSpace() const { return getImageDataColorSpaceName(m_colorSpace); } 117 String colorSpace() const { return getImageDataColorSpaceName(m_colorSpace); }
112 ImageDataColorSpace imageDataColorSpace() { return m_colorSpace; } 118 ImageDataColorSpace imageDataColorSpace() { return m_colorSpace; }
113 const DOMUint8ClampedArray* data() const { return m_data.get(); } 119 const DOMUint8ClampedArray* data() const { return m_data.get(); }
114 DOMUint8ClampedArray* data() { return m_data.get(); } 120 DOMUint8ClampedArray* data() { return m_data.get(); }
115 121
122 sk_sp<SkColorSpace> getSkColorSpace();
123
116 // ImageBitmapSource implementation 124 // ImageBitmapSource implementation
117 IntSize bitmapSourceSize() const override { return m_size; } 125 IntSize bitmapSourceSize() const override { return m_size; }
118 ScriptPromise createImageBitmap(ScriptState*, 126 ScriptPromise createImageBitmap(ScriptState*,
119 EventTarget&, 127 EventTarget&,
120 Optional<IntRect> cropRect, 128 Optional<IntRect> cropRect,
121 const ImageBitmapOptions&, 129 const ImageBitmapOptions&,
122 ExceptionState&) override; 130 ExceptionState&) override;
123 131
124 DEFINE_INLINE_TRACE() { visitor->trace(m_data); } 132 DEFINE_INLINE_TRACE() { visitor->trace(m_data); }
125 133
(...skipping 22 matching lines...) Expand all
148 Member<DOMUint8ClampedArray> m_data; 156 Member<DOMUint8ClampedArray> m_data;
149 157
150 static DOMUint8ClampedArray* allocateAndValidateUint8ClampedArray( 158 static DOMUint8ClampedArray* allocateAndValidateUint8ClampedArray(
151 const unsigned&, 159 const unsigned&,
152 ExceptionState* = nullptr); 160 ExceptionState* = nullptr);
153 }; 161 };
154 162
155 } // namespace blink 163 } // namespace blink
156 164
157 #endif // ImageData_h 165 #endif // ImageData_h
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/frame/ImageBitmapTest.cpp ('k') | third_party/WebKit/Source/core/html/ImageData.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698