| 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 15 matching lines...) Expand all Loading... |
| 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 "platform/PlatformExport.h" | 31 #include "platform/PlatformExport.h" |
| 32 #include "platform/SharedBuffer.h" | 32 #include "platform/SharedBuffer.h" |
| 33 #include "platform/graphics/ImageOrientation.h" | 33 #include "platform/graphics/ImageOrientation.h" |
| 34 #include "platform/image-decoders/ImageAnimation.h" | 34 #include "platform/image-decoders/ImageAnimation.h" |
| 35 #include "platform/image-decoders/ImageFrame.h" | 35 #include "platform/image-decoders/ImageFrame.h" |
| 36 #include "platform/image-decoders/SegmentReader.h" | |
| 37 #include "public/platform/Platform.h" | 36 #include "public/platform/Platform.h" |
| 38 #include "wtf/Assertions.h" | 37 #include "wtf/Assertions.h" |
| 39 #include "wtf/PassOwnPtr.h" | 38 #include "wtf/PassOwnPtr.h" |
| 40 #include "wtf/RefPtr.h" | 39 #include "wtf/RefPtr.h" |
| 41 #include "wtf/Threading.h" | 40 #include "wtf/Threading.h" |
| 42 #include "wtf/Vector.h" | 41 #include "wtf/Vector.h" |
| 43 #include "wtf/text/WTFString.h" | 42 #include "wtf/text/WTFString.h" |
| 44 | 43 |
| 45 #if USE(QCMSLIB) | 44 #if USE(QCMSLIB) |
| 46 #include "qcms.h" | 45 #include "qcms.h" |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 116 , m_sizeAvailable(false) | 115 , m_sizeAvailable(false) |
| 117 , m_isAllDataReceived(false) | 116 , m_isAllDataReceived(false) |
| 118 , m_failed(false) { } | 117 , m_failed(false) { } |
| 119 | 118 |
| 120 virtual ~ImageDecoder() { } | 119 virtual ~ImageDecoder() { } |
| 121 | 120 |
| 122 // Returns a caller-owned decoder of the appropriate type. Returns 0 if | 121 // Returns a caller-owned decoder of the appropriate type. Returns 0 if |
| 123 // we can't sniff a supported type from the provided data (possibly | 122 // we can't sniff a supported type from the provided data (possibly |
| 124 // because there isn't enough data yet). | 123 // because there isn't enough data yet). |
| 125 // Sets m_maxDecodedBytes to Platform::maxImageDecodedBytes(). | 124 // Sets m_maxDecodedBytes to Platform::maxImageDecodedBytes(). |
| 126 static PassOwnPtr<ImageDecoder> create(const char* data, size_t length, Alph
aOption, GammaAndColorProfileOption); | 125 static PassOwnPtr<ImageDecoder> create(const SharedBuffer& data, AlphaOption
, GammaAndColorProfileOption); |
| 127 static PassOwnPtr<ImageDecoder> create(const SharedBuffer&, AlphaOption, Gam
maAndColorProfileOption); | |
| 128 static PassOwnPtr<ImageDecoder> create(const SegmentReader&, AlphaOption, Ga
mmaAndColorProfileOption); | |
| 129 | 126 |
| 130 virtual String filenameExtension() const = 0; | 127 virtual String filenameExtension() const = 0; |
| 131 | 128 |
| 132 bool isAllDataReceived() const { return m_isAllDataReceived; } | 129 bool isAllDataReceived() const { return m_isAllDataReceived; } |
| 133 | 130 |
| 134 void setData(PassRefPtr<SegmentReader> data, bool allDataReceived) | 131 void setData(SharedBuffer* data, bool allDataReceived) |
| 135 { | 132 { |
| 136 if (m_failed) | 133 if (m_failed) |
| 137 return; | 134 return; |
| 138 m_data = data; | 135 m_data = data; |
| 139 m_isAllDataReceived = allDataReceived; | 136 m_isAllDataReceived = allDataReceived; |
| 140 onSetData(m_data.get()); | 137 onSetData(data); |
| 141 } | 138 } |
| 142 | 139 |
| 143 void setData(PassRefPtr<SharedBuffer> data, bool allDataReceived) | 140 virtual void onSetData(SharedBuffer* data) { } |
| 144 { | |
| 145 setData(SegmentReader::createFromSharedBuffer(data), allDataReceived); | |
| 146 } | |
| 147 | |
| 148 virtual void onSetData(SegmentReader* data) { } | |
| 149 | 141 |
| 150 bool isSizeAvailable() | 142 bool isSizeAvailable() |
| 151 { | 143 { |
| 152 if (m_failed) | 144 if (m_failed) |
| 153 return false; | 145 return false; |
| 154 if (!m_sizeAvailable) | 146 if (!m_sizeAvailable) |
| 155 decodeSize(); | 147 decodeSize(); |
| 156 return isDecodedSizeAvailable(); | 148 return isDecodedSizeAvailable(); |
| 157 } | 149 } |
| 158 | 150 |
| (...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 311 // returns that number. | 303 // returns that number. |
| 312 virtual size_t decodeFrameCount() { return 1; } | 304 virtual size_t decodeFrameCount() { return 1; } |
| 313 | 305 |
| 314 // Performs any additional setup of the requested frame after it has been | 306 // Performs any additional setup of the requested frame after it has been |
| 315 // initially created, e.g. setting a duration or disposal method. | 307 // initially created, e.g. setting a duration or disposal method. |
| 316 virtual void initializeNewFrame(size_t) { } | 308 virtual void initializeNewFrame(size_t) { } |
| 317 | 309 |
| 318 // Decodes the requested frame. | 310 // Decodes the requested frame. |
| 319 virtual void decode(size_t) = 0; | 311 virtual void decode(size_t) = 0; |
| 320 | 312 |
| 321 RefPtr<SegmentReader> m_data; // The encoded data. | 313 RefPtr<SharedBuffer> m_data; // The encoded data. |
| 322 Vector<ImageFrame, 1> m_frameBufferCache; | 314 Vector<ImageFrame, 1> m_frameBufferCache; |
| 323 bool m_premultiplyAlpha; | 315 bool m_premultiplyAlpha; |
| 324 bool m_ignoreGammaAndColorProfile; | 316 bool m_ignoreGammaAndColorProfile; |
| 325 ImageOrientation m_orientation; | 317 ImageOrientation m_orientation; |
| 326 | 318 |
| 327 // The maximum amount of memory a decoded image should require. Ideally, | 319 // The maximum amount of memory a decoded image should require. Ideally, |
| 328 // image decoders should downsample large images to fit under this limit | 320 // image decoders should downsample large images to fit under this limit |
| 329 // (and then return the downsampled size from decodedSize()). Ignoring | 321 // (and then return the downsampled size from decodedSize()). Ignoring |
| 330 // this limit can cause excessive memory use or even crashes on low- | 322 // this limit can cause excessive memory use or even crashes on low- |
| 331 // memory devices. | 323 // memory devices. |
| (...skipping 15 matching lines...) Expand all Loading... |
| 347 bool m_failed; | 339 bool m_failed; |
| 348 | 340 |
| 349 #if USE(QCMSLIB) | 341 #if USE(QCMSLIB) |
| 350 OwnPtr<qcms_transform> m_sourceToOutputDeviceColorTransform; | 342 OwnPtr<qcms_transform> m_sourceToOutputDeviceColorTransform; |
| 351 #endif | 343 #endif |
| 352 }; | 344 }; |
| 353 | 345 |
| 354 } // namespace blink | 346 } // namespace blink |
| 355 | 347 |
| 356 #endif | 348 #endif |
| OLD | NEW |