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

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

Issue 418653002: Allowing YUV data to be retrieved from the JPEG Decoder. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Fixed comments Created 6 years, 5 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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 // ImagePlanes can be used to decode color components into provided buffers inst ead of using an ImageFrame.
53 class ImagePlanes {
54 public:
55 ImagePlanes();
56
57 void set(void* planes[3], size_t rowBytes[3]);
58 void* plane(int);
59 size_t rowBytes(int) const;
60
61 private:
62 void* m_planes[3];
63 size_t m_rowBytes[3];
64 };
65
52 // ImageDecoder is a base for all format-specific decoders 66 // ImageDecoder is a base for all format-specific decoders
53 // (e.g. JPEGImageDecoder). This base manages the ImageFrame cache. 67 // (e.g. JPEGImageDecoder). This base manages the ImageFrame cache.
54 // 68 //
55 class PLATFORM_EXPORT ImageDecoder { 69 class PLATFORM_EXPORT ImageDecoder {
56 WTF_MAKE_NONCOPYABLE(ImageDecoder); WTF_MAKE_FAST_ALLOCATED; 70 WTF_MAKE_NONCOPYABLE(ImageDecoder); WTF_MAKE_FAST_ALLOCATED;
57 public: 71 public:
58 static const size_t noDecodedImageByteLimit = blink::Platform::noDecodedImag eByteLimit; 72 static const size_t noDecodedImageByteLimit = blink::Platform::noDecodedImag eByteLimit;
59 73
60 ImageDecoder(ImageSource::AlphaOption alphaOption, ImageSource::GammaAndColo rProfileOption gammaAndColorProfileOption, size_t maxDecodedBytes) 74 ImageDecoder(ImageSource::AlphaOption alphaOption, ImageSource::GammaAndColo rProfileOption gammaAndColorProfileOption, size_t maxDecodedBytes)
61 : m_premultiplyAlpha(alphaOption == ImageSource::AlphaPremultiplied) 75 : m_premultiplyAlpha(alphaOption == ImageSource::AlphaPremultiplied)
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 { 109 {
96 return !m_failed && m_sizeAvailable; 110 return !m_failed && m_sizeAvailable;
97 } 111 }
98 112
99 virtual IntSize size() const { return m_size; } 113 virtual IntSize size() const { return m_size; }
100 114
101 // Decoders which downsample images should override this method to 115 // Decoders which downsample images should override this method to
102 // return the actual decoded size. 116 // return the actual decoded size.
103 virtual IntSize decodedSize() const { return size(); } 117 virtual IntSize decodedSize() const { return size(); }
104 118
119 // Decoders which support YUV decoding can override this to
120 // give potentially different sizes per component.
121 virtual IntSize decodedYUVSize(int component = 0) const { return decodedSize (); }
122
105 // This will only differ from size() for ICO (where each frame is a 123 // This will only differ from size() for ICO (where each frame is a
106 // different icon) or other formats where different frames are different 124 // different icon) or other formats where different frames are different
107 // sizes. This does NOT differ from size() for GIF or WebP, since 125 // sizes. This does NOT differ from size() for GIF or WebP, since
108 // decoding GIF or WebP composites any smaller frames against previous 126 // decoding GIF or WebP composites any smaller frames against previous
109 // frames to create full-size frames. 127 // frames to create full-size frames.
110 virtual IntSize frameSizeAtIndex(size_t) const 128 virtual IntSize frameSizeAtIndex(size_t) const
111 { 129 {
112 return size(); 130 return size();
113 } 131 }
114 132
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
245 { 263 {
246 // FIXME: this doesn't work for images with multiple frames. 264 // FIXME: this doesn't work for images with multiple frames.
247 if (m_frameBufferCache.isEmpty()) { 265 if (m_frameBufferCache.isEmpty()) {
248 m_frameBufferCache.resize(1); 266 m_frameBufferCache.resize(1);
249 m_frameBufferCache[0].setRequiredPreviousFrameIndex( 267 m_frameBufferCache[0].setRequiredPreviousFrameIndex(
250 findRequiredPreviousFrame(0, false)); 268 findRequiredPreviousFrame(0, false));
251 } 269 }
252 m_frameBufferCache[0].setMemoryAllocator(allocator); 270 m_frameBufferCache[0].setMemoryAllocator(allocator);
253 } 271 }
254 272
273 virtual bool YUVDecoding() const { return false; }
274 virtual bool decodeToYUV() { return false; }
275 virtual void setImagePlanes(OwnPtr<ImagePlanes>&) { }
276
255 protected: 277 protected:
256 // Calculates the most recent frame whose image data may be needed in 278 // Calculates the most recent frame whose image data may be needed in
257 // order to decode frame |frameIndex|, based on frame disposal methods 279 // order to decode frame |frameIndex|, based on frame disposal methods
258 // and |frameRectIsOpaque|, where |frameRectIsOpaque| signifies whether 280 // and |frameRectIsOpaque|, where |frameRectIsOpaque| signifies whether
259 // the rectangle of frame at |frameIndex| is known to be opaque. 281 // the rectangle of frame at |frameIndex| is known to be opaque.
260 // If no previous frame's data is required, returns WTF::kNotFound. 282 // If no previous frame's data is required, returns WTF::kNotFound.
261 // 283 //
262 // This function requires that the previous frame's 284 // This function requires that the previous frame's
263 // |m_requiredPreviousFrameIndex| member has been set correctly. The 285 // |m_requiredPreviousFrameIndex| member has been set correctly. The
264 // easiest way to ensure this is for subclasses to call this method and 286 // 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
299 321
300 IntSize m_size; 322 IntSize m_size;
301 bool m_sizeAvailable; 323 bool m_sizeAvailable;
302 bool m_isAllDataReceived; 324 bool m_isAllDataReceived;
303 bool m_failed; 325 bool m_failed;
304 }; 326 };
305 327
306 } // namespace blink 328 } // namespace blink
307 329
308 #endif 330 #endif
OLDNEW
« no previous file with comments | « no previous file | Source/platform/image-decoders/ImageDecoder.cpp » ('j') | Source/platform/image-decoders/jpeg/JPEGImageDecoder.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698