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

Side by Side Diff: third_party/WebKit/Source/platform/image-decoders/ImageDecoder.h

Issue 2426723005: Use SkColorSpaceXform to handle color conversions in decoders (Closed)
Patch Set: Remove ifdefs - fixes blink_platform_unittests Created 4 years, 2 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) 2006 Apple Computer, Inc. All rights reserved. 2 * Copyright (C) 2006 Apple Computer, Inc. All rights reserved.
3 * Copyright (C) Research In Motion Limited 2009-2010. All rights reserved. 3 * Copyright (C) Research In Motion Limited 2009-2010. All rights reserved.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions 6 * modification, are permitted provided that the following conditions
7 * are met: 7 * are met:
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 10 matching lines...) Expand all
21 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY 21 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
22 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 22 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
24 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 */ 25 */
26 26
27 #ifndef ImageDecoder_h 27 #ifndef ImageDecoder_h
28 #define ImageDecoder_h 28 #define ImageDecoder_h
29 29
30 #include "SkColorPriv.h" 30 #include "SkColorPriv.h"
31 #include "SkColorSpaceXform.h"
31 #include "platform/PlatformExport.h" 32 #include "platform/PlatformExport.h"
32 #include "platform/SharedBuffer.h" 33 #include "platform/SharedBuffer.h"
33 #include "platform/graphics/ImageOrientation.h" 34 #include "platform/graphics/ImageOrientation.h"
34 #include "platform/image-decoders/ImageAnimation.h" 35 #include "platform/image-decoders/ImageAnimation.h"
35 #include "platform/image-decoders/ImageFrame.h" 36 #include "platform/image-decoders/ImageFrame.h"
36 #include "platform/image-decoders/SegmentReader.h" 37 #include "platform/image-decoders/SegmentReader.h"
37 #include "public/platform/Platform.h" 38 #include "public/platform/Platform.h"
38 #include "wtf/Assertions.h" 39 #include "wtf/Assertions.h"
39 #include "wtf/RefPtr.h" 40 #include "wtf/RefPtr.h"
40 #include "wtf/Threading.h" 41 #include "wtf/Threading.h"
41 #include "wtf/Vector.h" 42 #include "wtf/Vector.h"
42 #include "wtf/text/WTFString.h" 43 #include "wtf/text/WTFString.h"
43 #include <memory> 44 #include <memory>
44 45
45 #if USE(QCMSLIB)
46 #include "qcms.h"
47 #endif
48
49 namespace blink { 46 namespace blink {
50 47
51 #if USE(QCMSLIB) 48 #if SK_B32_SHIFT
52 struct QCMSTransformDeleter { 49 inline SkColorSpaceXform::ColorFormat xformColorFormat() {
53 void operator()(qcms_transform* transform) { 50 return SkColorSpaceXform::kRGBA_8888_ColorFormat;
54 if (transform) 51 }
55 qcms_transform_release(transform); 52 #else
56 } 53 inline SkColorSpaceXform::ColorFormat xformColorFormat() {
57 }; 54 return SkColorSpaceXform::kBGRA_8888_ColorFormat;
58 55 }
59 using QCMSTransformUniquePtr = 56 #endif
60 std::unique_ptr<qcms_transform, QCMSTransformDeleter>;
61 #endif // USE(QCMSLIB)
62 57
63 // ImagePlanes can be used to decode color components into provided buffers 58 // ImagePlanes can be used to decode color components into provided buffers
64 // instead of using an ImageFrame. 59 // instead of using an ImageFrame.
65 class PLATFORM_EXPORT ImagePlanes final { 60 class PLATFORM_EXPORT ImagePlanes final {
66 USING_FAST_MALLOC(ImagePlanes); 61 USING_FAST_MALLOC(ImagePlanes);
67 WTF_MAKE_NONCOPYABLE(ImagePlanes); 62 WTF_MAKE_NONCOPYABLE(ImagePlanes);
68 63
69 public: 64 public:
70 ImagePlanes(); 65 ImagePlanes();
71 ImagePlanes(void* planes[3], const size_t rowBytes[3]); 66 ImagePlanes(void* planes[3], const size_t rowBytes[3]);
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
217 212
218 bool ignoresGammaAndColorProfile() const { 213 bool ignoresGammaAndColorProfile() const {
219 return m_ignoreGammaAndColorProfile; 214 return m_ignoreGammaAndColorProfile;
220 } 215 }
221 static void setTargetColorProfile(const WebVector<char>&); 216 static void setTargetColorProfile(const WebVector<char>&);
222 217
223 // Note that hasColorProfile refers to the existence of a not-ignored 218 // Note that hasColorProfile refers to the existence of a not-ignored
224 // embedded color profile, and is independent of whether or not that 219 // embedded color profile, and is independent of whether or not that
225 // profile's transform has been baked into the pixel values. 220 // profile's transform has been baked into the pixel values.
226 bool hasColorProfile() const { return m_hasColorProfile; } 221 bool hasColorProfile() const { return m_hasColorProfile; }
227 void setColorProfileAndComputeTransform(const char* iccData, 222 void setColorSpaceAndComputeTransform(const char* iccData,
228 unsigned iccLength, 223 unsigned iccLength,
229 bool hasAlpha, 224 bool useSRGB);
230 bool useSRGB);
231 225
232 #if USE(QCMSLIB) 226 // Transformation from encoded color space to target color space.
233 // In contrast with hasColorProfile, this refers to the transform that has 227 SkColorSpaceXform* colorTransform() {
234 // been baked into the pixels.
235 qcms_transform* colorTransform() {
236 return m_sourceToOutputDeviceColorTransform.get(); 228 return m_sourceToOutputDeviceColorTransform.get();
237 } 229 }
238 #endif
239 230
240 // Sets the "decode failure" flag. For caller convenience (since so 231 // Sets the "decode failure" flag. For caller convenience (since so
241 // many callers want to return false after calling this), returns false 232 // many callers want to return false after calling this), returns false
242 // to enable easy tailcalling. Subclasses may override this to also 233 // to enable easy tailcalling. Subclasses may override this to also
243 // clean up any local data. 234 // clean up any local data.
244 virtual bool setFailed() { 235 virtual bool setFailed() {
245 m_failed = true; 236 m_failed = true;
246 return false; 237 return false;
247 } 238 }
248 239
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
354 } 345 }
355 346
356 IntSize m_size; 347 IntSize m_size;
357 bool m_sizeAvailable = false; 348 bool m_sizeAvailable = false;
358 bool m_isAllDataReceived = false; 349 bool m_isAllDataReceived = false;
359 bool m_failed = false; 350 bool m_failed = false;
360 351
361 bool m_hasColorProfile = false; 352 bool m_hasColorProfile = false;
362 ImageFrame::ICCProfile m_colorProfile; 353 ImageFrame::ICCProfile m_colorProfile;
363 354
364 #if USE(QCMSLIB) 355 std::unique_ptr<SkColorSpaceXform> m_sourceToOutputDeviceColorTransform;
365 QCMSTransformUniquePtr m_sourceToOutputDeviceColorTransform;
366 #endif
367 }; 356 };
368 357
369 } // namespace blink 358 } // namespace blink
370 359
371 #endif 360 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698