| 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 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 203 // animated images. | 203 // animated images. |
| 204 virtual float frameDurationAtIndex(size_t) const { return 0; } | 204 virtual float frameDurationAtIndex(size_t) const { return 0; } |
| 205 | 205 |
| 206 // Number of bytes in the decoded frame. Returns 0 if the decoder doesn't | 206 // Number of bytes in the decoded frame. Returns 0 if the decoder doesn't |
| 207 // have this frame cached (either because it hasn't been decoded, or because | 207 // have this frame cached (either because it hasn't been decoded, or because |
| 208 // it has been cleared). | 208 // it has been cleared). |
| 209 virtual size_t frameBytesAtIndex(size_t) const; | 209 virtual size_t frameBytesAtIndex(size_t) const; |
| 210 | 210 |
| 211 ImageOrientation orientation() const { return m_orientation; } | 211 ImageOrientation orientation() const { return m_orientation; } |
| 212 | 212 |
| 213 bool ignoresGammaAndColorProfile() const { | 213 bool ignoresColorSpace() const { return m_ignoreColorSpace; } |
| 214 return m_ignoreGammaAndColorProfile; | |
| 215 } | |
| 216 static void setTargetColorProfile(const WebVector<char>&); | 214 static void setTargetColorProfile(const WebVector<char>&); |
| 217 | 215 |
| 218 // Note that hasColorProfile refers to the existence of a not-ignored | 216 // Note that hasColorSpace refers to the existence of a not-ignored |
| 219 // embedded color profile, and is independent of whether or not that | 217 // embedded color space, and is independent of whether or not that |
| 220 // profile's transform has been baked into the pixel values. | 218 // space's transform has been baked into the pixel values. |
| 221 bool hasColorProfile() const { return m_hasColorProfile; } | 219 bool hasColorSpace() const { return m_srcSpace.get(); } |
| 222 void setColorSpaceAndComputeTransform(const char* iccData, | 220 void setColorSpaceAndComputeTransform(const char* iccData, |
| 223 unsigned iccLength, | 221 unsigned iccLength); |
| 224 bool useSRGB); | 222 void setColorSpaceAndComputeTransform(sk_sp<SkColorSpace> srcSpace); |
| 225 | 223 |
| 226 // Transformation from encoded color space to target color space. | 224 // Transformation from encoded color space to target color space. |
| 227 SkColorSpaceXform* colorTransform() { | 225 SkColorSpaceXform* colorTransform() { |
| 228 return m_sourceToOutputDeviceColorTransform.get(); | 226 return m_sourceToOutputDeviceColorTransform.get(); |
| 229 } | 227 } |
| 230 | 228 |
| 231 // Sets the "decode failure" flag. For caller convenience (since so | 229 // Sets the "decode failure" flag. For caller convenience (since so |
| 232 // many callers want to return false after calling this), returns false | 230 // many callers want to return false after calling this), returns false |
| 233 // to enable easy tailcalling. Subclasses may override this to also | 231 // to enable easy tailcalling. Subclasses may override this to also |
| 234 // clean up any local data. | 232 // clean up any local data. |
| (...skipping 26 matching lines...) Expand all Loading... |
| 261 | 259 |
| 262 virtual bool canDecodeToYUV() { return false; } | 260 virtual bool canDecodeToYUV() { return false; } |
| 263 virtual bool decodeToYUV() { return false; } | 261 virtual bool decodeToYUV() { return false; } |
| 264 virtual void setImagePlanes(std::unique_ptr<ImagePlanes>) {} | 262 virtual void setImagePlanes(std::unique_ptr<ImagePlanes>) {} |
| 265 | 263 |
| 266 protected: | 264 protected: |
| 267 ImageDecoder(AlphaOption alphaOption, | 265 ImageDecoder(AlphaOption alphaOption, |
| 268 GammaAndColorProfileOption colorOptions, | 266 GammaAndColorProfileOption colorOptions, |
| 269 size_t maxDecodedBytes) | 267 size_t maxDecodedBytes) |
| 270 : m_premultiplyAlpha(alphaOption == AlphaPremultiplied), | 268 : m_premultiplyAlpha(alphaOption == AlphaPremultiplied), |
| 271 m_ignoreGammaAndColorProfile(colorOptions == | 269 m_ignoreColorSpace(colorOptions == GammaAndColorProfileIgnored), |
| 272 GammaAndColorProfileIgnored), | |
| 273 m_maxDecodedBytes(maxDecodedBytes), | 270 m_maxDecodedBytes(maxDecodedBytes), |
| 274 m_purgeAggressively(false) {} | 271 m_purgeAggressively(false) {} |
| 275 | 272 |
| 276 // Calculates the most recent frame whose image data may be needed in | 273 // Calculates the most recent frame whose image data may be needed in |
| 277 // order to decode frame |frameIndex|, based on frame disposal methods | 274 // order to decode frame |frameIndex|, based on frame disposal methods |
| 278 // and |frameRectIsOpaque|, where |frameRectIsOpaque| signifies whether | 275 // and |frameRectIsOpaque|, where |frameRectIsOpaque| signifies whether |
| 279 // the rectangle of frame at |frameIndex| is known to be opaque. | 276 // the rectangle of frame at |frameIndex| is known to be opaque. |
| 280 // If no previous frame's data is required, returns WTF::kNotFound. | 277 // If no previous frame's data is required, returns WTF::kNotFound. |
| 281 // | 278 // |
| 282 // This function requires that the previous frame's | 279 // This function requires that the previous frame's |
| (...skipping 18 matching lines...) Expand all Loading... |
| 301 // returns that number. | 298 // returns that number. |
| 302 virtual size_t decodeFrameCount() { return 1; } | 299 virtual size_t decodeFrameCount() { return 1; } |
| 303 | 300 |
| 304 // Performs any additional setup of the requested frame after it has been | 301 // Performs any additional setup of the requested frame after it has been |
| 305 // initially created, e.g. setting a duration or disposal method. | 302 // initially created, e.g. setting a duration or disposal method. |
| 306 virtual void initializeNewFrame(size_t) {} | 303 virtual void initializeNewFrame(size_t) {} |
| 307 | 304 |
| 308 // Decodes the requested frame. | 305 // Decodes the requested frame. |
| 309 virtual void decode(size_t) = 0; | 306 virtual void decode(size_t) = 0; |
| 310 | 307 |
| 311 // Returns the embedded image color profile. | 308 // Returns the embedded image color space. |
| 312 const ImageFrame::ICCProfile& colorProfile() const { return m_colorProfile; } | 309 sk_sp<SkColorSpace> colorSpace() const { return m_srcSpace; } |
| 313 | 310 |
| 314 RefPtr<SegmentReader> m_data; // The encoded data. | 311 RefPtr<SegmentReader> m_data; // The encoded data. |
| 315 Vector<ImageFrame, 1> m_frameBufferCache; | 312 Vector<ImageFrame, 1> m_frameBufferCache; |
| 316 const bool m_premultiplyAlpha; | 313 const bool m_premultiplyAlpha; |
| 317 const bool m_ignoreGammaAndColorProfile; | 314 const bool m_ignoreColorSpace; |
| 318 ImageOrientation m_orientation; | 315 ImageOrientation m_orientation; |
| 319 | 316 |
| 320 // The maximum amount of memory a decoded image should require. Ideally, | 317 // The maximum amount of memory a decoded image should require. Ideally, |
| 321 // image decoders should downsample large images to fit under this limit | 318 // image decoders should downsample large images to fit under this limit |
| 322 // (and then return the downsampled size from decodedSize()). Ignoring | 319 // (and then return the downsampled size from decodedSize()). Ignoring |
| 323 // 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- |
| 324 // memory devices. | 321 // memory devices. |
| 325 const size_t m_maxDecodedBytes; | 322 const size_t m_maxDecodedBytes; |
| 326 | 323 |
| 327 // While decoding, we may learn that there are so many animation frames that | 324 // While decoding, we may learn that there are so many animation frames that |
| (...skipping 14 matching lines...) Expand all Loading... |
| 342 unsigned long long total_size = static_cast<unsigned long long>(width) * | 339 unsigned long long total_size = static_cast<unsigned long long>(width) * |
| 343 static_cast<unsigned long long>(height); | 340 static_cast<unsigned long long>(height); |
| 344 return total_size > ((1 << 29) - 1); | 341 return total_size > ((1 << 29) - 1); |
| 345 } | 342 } |
| 346 | 343 |
| 347 IntSize m_size; | 344 IntSize m_size; |
| 348 bool m_sizeAvailable = false; | 345 bool m_sizeAvailable = false; |
| 349 bool m_isAllDataReceived = false; | 346 bool m_isAllDataReceived = false; |
| 350 bool m_failed = false; | 347 bool m_failed = false; |
| 351 | 348 |
| 352 bool m_hasColorProfile = false; | 349 sk_sp<SkColorSpace> m_srcSpace = nullptr; |
| 353 ImageFrame::ICCProfile m_colorProfile; | |
| 354 | |
| 355 std::unique_ptr<SkColorSpaceXform> m_sourceToOutputDeviceColorTransform; | 350 std::unique_ptr<SkColorSpaceXform> m_sourceToOutputDeviceColorTransform; |
| 356 }; | 351 }; |
| 357 | 352 |
| 358 } // namespace blink | 353 } // namespace blink |
| 359 | 354 |
| 360 #endif | 355 #endif |
| OLD | NEW |