| OLD | NEW |
| 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 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 202 // Number of bytes in the decoded frame. Returns 0 if the decoder doesn't | 202 // Number of bytes in the decoded frame. Returns 0 if the decoder doesn't |
| 203 // have this frame cached (either because it hasn't been decoded, or because | 203 // have this frame cached (either because it hasn't been decoded, or because |
| 204 // it has been cleared). | 204 // it has been cleared). |
| 205 virtual size_t frameBytesAtIndex(size_t) const; | 205 virtual size_t frameBytesAtIndex(size_t) const; |
| 206 | 206 |
| 207 ImageOrientation orientation() const { return m_orientation; } | 207 ImageOrientation orientation() const { return m_orientation; } |
| 208 | 208 |
| 209 bool ignoresColorSpace() const { return m_ignoreColorSpace; } | 209 bool ignoresColorSpace() const { return m_ignoreColorSpace; } |
| 210 static void setTargetColorProfile(const WebVector<char>&); | 210 static void setTargetColorProfile(const WebVector<char>&); |
| 211 | 211 |
| 212 // Note that hasColorSpace refers to the existence of a not-ignored | 212 // This returns the color space of this image. If the image had no embedded |
| 213 // embedded color space, and is independent of whether or not that | 213 // color profile, this will return sRGB. Returns nullptr if color correct |
| 214 // space's transform has been baked into the pixel values. | 214 // rendering is not enabled. |
| 215 bool hasColorSpace() const { return m_srcSpace.get(); } | 215 sk_sp<SkColorSpace> colorSpace() const; |
| 216 void setColorSpaceAndComputeTransform(const char* iccData, | 216 |
| 217 unsigned iccLength); | 217 // This returns whether or not the image included a not-ignored embedded |
| 218 // color space. This is independent of whether or not that space's transform |
| 219 // has been baked into the pixel values. |
| 220 bool hasEmbeddedColorSpace() const { return m_embeddedColorSpace.get(); } |
| 221 |
| 222 // Set the embedded color space directly or via ICC profile. |
| 223 void setColorProfileAndComputeTransform(const char* iccData, |
| 224 unsigned iccLength); |
| 218 void setColorSpaceAndComputeTransform(sk_sp<SkColorSpace> srcSpace); | 225 void setColorSpaceAndComputeTransform(sk_sp<SkColorSpace> srcSpace); |
| 219 | 226 |
| 220 // Transformation from encoded color space to target color space. | 227 // Transformation from encoded color space to target color space. |
| 221 SkColorSpaceXform* colorTransform() { | 228 SkColorSpaceXform* colorTransform() { |
| 222 return m_sourceToOutputDeviceColorTransform.get(); | 229 return m_sourceToOutputDeviceColorTransform.get(); |
| 223 } | 230 } |
| 224 | 231 |
| 225 // Sets the "decode failure" flag. For caller convenience (since so | 232 // Sets the "decode failure" flag. For caller convenience (since so |
| 226 // many callers want to return false after calling this), returns false | 233 // many callers want to return false after calling this), returns false |
| 227 // to enable easy tailcalling. Subclasses may override this to also | 234 // to enable easy tailcalling. Subclasses may override this to also |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 294 // returns that number. | 301 // returns that number. |
| 295 virtual size_t decodeFrameCount() { return 1; } | 302 virtual size_t decodeFrameCount() { return 1; } |
| 296 | 303 |
| 297 // Performs any additional setup of the requested frame after it has been | 304 // Performs any additional setup of the requested frame after it has been |
| 298 // initially created, e.g. setting a duration or disposal method. | 305 // initially created, e.g. setting a duration or disposal method. |
| 299 virtual void initializeNewFrame(size_t) {} | 306 virtual void initializeNewFrame(size_t) {} |
| 300 | 307 |
| 301 // Decodes the requested frame. | 308 // Decodes the requested frame. |
| 302 virtual void decode(size_t) = 0; | 309 virtual void decode(size_t) = 0; |
| 303 | 310 |
| 304 // Returns the embedded image color space. | |
| 305 sk_sp<SkColorSpace> colorSpace() const { return m_srcSpace; } | |
| 306 | |
| 307 RefPtr<SegmentReader> m_data; // The encoded data. | 311 RefPtr<SegmentReader> m_data; // The encoded data. |
| 308 Vector<ImageFrame, 1> m_frameBufferCache; | 312 Vector<ImageFrame, 1> m_frameBufferCache; |
| 309 const bool m_premultiplyAlpha; | 313 const bool m_premultiplyAlpha; |
| 310 const bool m_ignoreColorSpace; | 314 const bool m_ignoreColorSpace; |
| 311 ImageOrientation m_orientation; | 315 ImageOrientation m_orientation; |
| 312 | 316 |
| 313 // The maximum amount of memory a decoded image should require. Ideally, | 317 // The maximum amount of memory a decoded image should require. Ideally, |
| 314 // image decoders should downsample large images to fit under this limit | 318 // image decoders should downsample large images to fit under this limit |
| 315 // (and then return the downsampled size from decodedSize()). Ignoring | 319 // (and then return the downsampled size from decodedSize()). Ignoring |
| 316 // this limit can cause excessive memory use or even crashes on low- | 320 // this limit can cause excessive memory use or even crashes on low- |
| (...skipping 18 matching lines...) Expand all Loading... |
| 335 unsigned long long total_size = static_cast<unsigned long long>(width) * | 339 unsigned long long total_size = static_cast<unsigned long long>(width) * |
| 336 static_cast<unsigned long long>(height); | 340 static_cast<unsigned long long>(height); |
| 337 return total_size > ((1 << 29) - 1); | 341 return total_size > ((1 << 29) - 1); |
| 338 } | 342 } |
| 339 | 343 |
| 340 IntSize m_size; | 344 IntSize m_size; |
| 341 bool m_sizeAvailable = false; | 345 bool m_sizeAvailable = false; |
| 342 bool m_isAllDataReceived = false; | 346 bool m_isAllDataReceived = false; |
| 343 bool m_failed = false; | 347 bool m_failed = false; |
| 344 | 348 |
| 345 sk_sp<SkColorSpace> m_srcSpace = nullptr; | 349 sk_sp<SkColorSpace> m_embeddedColorSpace = nullptr; |
| 346 std::unique_ptr<SkColorSpaceXform> m_sourceToOutputDeviceColorTransform; | 350 std::unique_ptr<SkColorSpaceXform> m_sourceToOutputDeviceColorTransform; |
| 347 }; | 351 }; |
| 348 | 352 |
| 349 } // namespace blink | 353 } // namespace blink |
| 350 | 354 |
| 351 #endif | 355 #endif |
| OLD | NEW |