Chromium Code Reviews| 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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 42 #if USE(QCMSLIB) | 42 #if USE(QCMSLIB) |
| 43 #include "qcms.h" | 43 #include "qcms.h" |
| 44 #if OS(MACOSX) | 44 #if OS(MACOSX) |
| 45 #include <ApplicationServices/ApplicationServices.h> | 45 #include <ApplicationServices/ApplicationServices.h> |
| 46 #include "wtf/RetainPtr.h" | 46 #include "wtf/RetainPtr.h" |
| 47 #endif | 47 #endif |
| 48 #endif | 48 #endif |
| 49 | 49 |
| 50 namespace blink { | 50 namespace blink { |
| 51 | 51 |
| 52 // DecodingBuffers can be used to decode color components into provided buffers instead of using an ImageFrame. | |
| 53 class DecodingBuffers { | |
| 54 public: | |
| 55 DecodingBuffers() | |
| 56 { | |
| 57 for (int i = 0; i < 3; ++i) { | |
|
Peter Kasting
2014/07/23 22:17:37
Nit: For these methods that require more than a li
sugoi1
2014/07/24 15:48:30
Done.
| |
| 58 m_planes[i] = 0; | |
| 59 m_rowBytes[i] = 0; | |
| 60 } | |
| 61 } | |
| 62 | |
| 63 void set(void* planes[3], size_t rowBytes[3]) | |
| 64 { | |
| 65 for (int i = 0; i < 3; ++i) { | |
| 66 m_planes[i] = planes[i]; | |
| 67 m_rowBytes[i] = rowBytes[i]; | |
| 68 } | |
| 69 } | |
| 70 | |
| 71 void* getPlane(int i) const | |
| 72 { | |
| 73 return ((i >= 0) && i < 3) ? m_planes[i] : 0; | |
|
Stephen White
2014/07/23 21:45:53
Should this be an assert instead?
sugoi1
2014/07/24 15:48:30
Done.
| |
| 74 } | |
| 75 | |
| 76 size_t getRowBytes(int i) const | |
| 77 { | |
| 78 return ((i >= 0) && i < 3) ? m_rowBytes[i] : 0; | |
|
Stephen White
2014/07/23 21:45:53
Same here.
sugoi1
2014/07/24 15:48:30
Done.
| |
| 79 } | |
| 80 private: | |
|
Peter Kasting
2014/07/23 22:17:37
Nit: Blank line above this
sugoi1
2014/07/24 15:48:30
Done.
| |
| 81 void* m_planes[3]; | |
| 82 size_t m_rowBytes[3]; | |
| 83 }; | |
| 84 | |
| 52 // ImageDecoder is a base for all format-specific decoders | 85 // ImageDecoder is a base for all format-specific decoders |
| 53 // (e.g. JPEGImageDecoder). This base manages the ImageFrame cache. | 86 // (e.g. JPEGImageDecoder). This base manages the ImageFrame cache. |
| 54 // | 87 // |
| 55 class PLATFORM_EXPORT ImageDecoder { | 88 class PLATFORM_EXPORT ImageDecoder { |
| 56 WTF_MAKE_NONCOPYABLE(ImageDecoder); WTF_MAKE_FAST_ALLOCATED; | 89 WTF_MAKE_NONCOPYABLE(ImageDecoder); WTF_MAKE_FAST_ALLOCATED; |
| 57 public: | 90 public: |
| 58 static const size_t noDecodedImageByteLimit = blink::Platform::noDecodedImag eByteLimit; | 91 static const size_t noDecodedImageByteLimit = blink::Platform::noDecodedImag eByteLimit; |
| 59 | 92 |
| 60 ImageDecoder(ImageSource::AlphaOption alphaOption, ImageSource::GammaAndColo rProfileOption gammaAndColorProfileOption, size_t maxDecodedBytes) | 93 ImageDecoder(ImageSource::AlphaOption alphaOption, ImageSource::GammaAndColo rProfileOption gammaAndColorProfileOption, size_t maxDecodedBytes) |
| 61 : m_premultiplyAlpha(alphaOption == ImageSource::AlphaPremultiplied) | 94 : m_premultiplyAlpha(alphaOption == ImageSource::AlphaPremultiplied) |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 93 // decode call out and use it here. | 126 // decode call out and use it here. |
| 94 virtual bool isSizeAvailable() | 127 virtual bool isSizeAvailable() |
| 95 { | 128 { |
| 96 return !m_failed && m_sizeAvailable; | 129 return !m_failed && m_sizeAvailable; |
| 97 } | 130 } |
| 98 | 131 |
| 99 virtual IntSize size() const { return m_size; } | 132 virtual IntSize size() const { return m_size; } |
| 100 | 133 |
| 101 // Decoders which downsample images should override this method to | 134 // Decoders which downsample images should override this method to |
| 102 // return the actual decoded size. | 135 // return the actual decoded size. |
| 103 virtual IntSize decodedSize() const { return size(); } | 136 virtual IntSize decodedSize(int component = 0) const { return size(); } |
| 104 | 137 |
| 105 // This will only differ from size() for ICO (where each frame is a | 138 // This will only differ from size() for ICO (where each frame is a |
| 106 // different icon) or other formats where different frames are different | 139 // different icon) or other formats where different frames are different |
| 107 // sizes. This does NOT differ from size() for GIF or WebP, since | 140 // sizes. This does NOT differ from size() for GIF or WebP, since |
| 108 // decoding GIF or WebP composites any smaller frames against previous | 141 // decoding GIF or WebP composites any smaller frames against previous |
| 109 // frames to create full-size frames. | 142 // frames to create full-size frames. |
| 110 virtual IntSize frameSizeAtIndex(size_t) const | 143 virtual IntSize frameSizeAtIndex(size_t) const |
| 111 { | 144 { |
| 112 return size(); | 145 return size(); |
| 113 } | 146 } |
| (...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 245 { | 278 { |
| 246 // FIXME: this doesn't work for images with multiple frames. | 279 // FIXME: this doesn't work for images with multiple frames. |
| 247 if (m_frameBufferCache.isEmpty()) { | 280 if (m_frameBufferCache.isEmpty()) { |
| 248 m_frameBufferCache.resize(1); | 281 m_frameBufferCache.resize(1); |
| 249 m_frameBufferCache[0].setRequiredPreviousFrameIndex( | 282 m_frameBufferCache[0].setRequiredPreviousFrameIndex( |
| 250 findRequiredPreviousFrame(0, false)); | 283 findRequiredPreviousFrame(0, false)); |
| 251 } | 284 } |
| 252 m_frameBufferCache[0].setMemoryAllocator(allocator); | 285 m_frameBufferCache[0].setMemoryAllocator(allocator); |
| 253 } | 286 } |
| 254 | 287 |
| 288 virtual void setHardwareDecoding(bool) { } | |
| 289 virtual bool hardwareDecoding() const { return false; } | |
| 290 virtual bool doHardwareDecoding() { return false; } | |
| 291 virtual void setDecodingBuffers(OwnPtr<DecodingBuffers>&) { } | |
| 292 | |
| 255 protected: | 293 protected: |
| 256 // Calculates the most recent frame whose image data may be needed in | 294 // Calculates the most recent frame whose image data may be needed in |
| 257 // order to decode frame |frameIndex|, based on frame disposal methods | 295 // order to decode frame |frameIndex|, based on frame disposal methods |
| 258 // and |frameRectIsOpaque|, where |frameRectIsOpaque| signifies whether | 296 // and |frameRectIsOpaque|, where |frameRectIsOpaque| signifies whether |
| 259 // the rectangle of frame at |frameIndex| is known to be opaque. | 297 // the rectangle of frame at |frameIndex| is known to be opaque. |
| 260 // If no previous frame's data is required, returns WTF::kNotFound. | 298 // If no previous frame's data is required, returns WTF::kNotFound. |
| 261 // | 299 // |
| 262 // This function requires that the previous frame's | 300 // This function requires that the previous frame's |
| 263 // |m_requiredPreviousFrameIndex| member has been set correctly. The | 301 // |m_requiredPreviousFrameIndex| member has been set correctly. The |
| 264 // easiest way to ensure this is for subclasses to call this method and | 302 // easiest way to ensure this is for subclasses to call this method and |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 299 | 337 |
| 300 IntSize m_size; | 338 IntSize m_size; |
| 301 bool m_sizeAvailable; | 339 bool m_sizeAvailable; |
| 302 bool m_isAllDataReceived; | 340 bool m_isAllDataReceived; |
| 303 bool m_failed; | 341 bool m_failed; |
| 304 }; | 342 }; |
| 305 | 343 |
| 306 } // namespace blink | 344 } // namespace blink |
| 307 | 345 |
| 308 #endif | 346 #endif |
| OLD | NEW |