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

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

Issue 1460523002: GIF decoding to Index8, unit tests and misusing unit test as benchmark (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: cleanup. tableChanged was wrong - do proper check. Created 5 years 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 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
161 161
162 // Calls decodeFrameCount() to get the frame count (if possible), without 162 // Calls decodeFrameCount() to get the frame count (if possible), without
163 // decoding the individual frames. Resizes m_frameBufferCache to the 163 // decoding the individual frames. Resizes m_frameBufferCache to the
164 // correct size and returns its size. 164 // correct size and returns its size.
165 size_t frameCount(); 165 size_t frameCount();
166 166
167 virtual int repetitionCount() const { return cAnimationNone; } 167 virtual int repetitionCount() const { return cAnimationNone; }
168 168
169 // Decodes as much of the requested frame as possible, and returns an 169 // Decodes as much of the requested frame as possible, and returns an
170 // ImageDecoder-owned pointer. 170 // ImageDecoder-owned pointer.
171 ImageFrame* frameBufferAtIndex(size_t); 171 ImageFrame* frameBufferAtIndex(size_t, ImageFrame::ColorType = ImageFrame::N 32);
scroggo_chromium 2015/12/03 21:47:21 It seems odd to me that the client asks for a part
aleksandar.stojiljkovic 2015/12/04 00:07:34 1st Reason is in discussion we had here: https://c
172 172
173 // Whether the requested frame has alpha. 173 // Whether the requested frame has alpha.
174 virtual bool frameHasAlphaAtIndex(size_t) const; 174 virtual bool frameHasAlphaAtIndex(size_t) const;
175 175
176 // Whether or not the frame is fully received. 176 // Whether or not the frame is fully received.
177 virtual bool frameIsCompleteAtIndex(size_t) const; 177 virtual bool frameIsCompleteAtIndex(size_t) const;
178 178
179 // Duration for displaying a frame in seconds. This method is only used by 179 // Duration for displaying a frame in seconds. This method is only used by
180 // animated images. 180 // animated images.
181 virtual float frameDurationAtIndex(size_t) const { return 0; } 181 virtual float frameDurationAtIndex(size_t) const { return 0; }
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
285 m_frameBufferCache.resize(1); 285 m_frameBufferCache.resize(1);
286 m_frameBufferCache[0].setRequiredPreviousFrameIndex( 286 m_frameBufferCache[0].setRequiredPreviousFrameIndex(
287 findRequiredPreviousFrame(0, false)); 287 findRequiredPreviousFrame(0, false));
288 } 288 }
289 m_frameBufferCache[0].setMemoryAllocator(allocator); 289 m_frameBufferCache[0].setMemoryAllocator(allocator);
290 } 290 }
291 291
292 virtual bool canDecodeToYUV() { return false; } 292 virtual bool canDecodeToYUV() { return false; }
293 virtual bool decodeToYUV() { return false; } 293 virtual bool decodeToYUV() { return false; }
294 virtual void setImagePlanes(PassOwnPtr<ImagePlanes>) { } 294 virtual void setImagePlanes(PassOwnPtr<ImagePlanes>) { }
295 virtual bool canDecodeTo(size_t index, ImageFrame::ColorType outputType)
296 {
297 return outputType == ImageFrame::N32;
298 }
295 299
296 protected: 300 protected:
297 // Calculates the most recent frame whose image data may be needed in 301 // Calculates the most recent frame whose image data may be needed in
298 // order to decode frame |frameIndex|, based on frame disposal methods 302 // order to decode frame |frameIndex|, based on frame disposal methods
299 // and |frameRectIsOpaque|, where |frameRectIsOpaque| signifies whether 303 // and |frameRectIsOpaque|, where |frameRectIsOpaque| signifies whether
300 // the rectangle of frame at |frameIndex| is known to be opaque. 304 // the rectangle of frame at |frameIndex| is known to be opaque.
301 // If no previous frame's data is required, returns WTF::kNotFound. 305 // If no previous frame's data is required, returns WTF::kNotFound.
302 // 306 //
303 // This function requires that the previous frame's 307 // This function requires that the previous frame's
304 // |m_requiredPreviousFrameIndex| member has been set correctly. The 308 // |m_requiredPreviousFrameIndex| member has been set correctly. The
(...skipping 16 matching lines...) Expand all
321 // Decodes the image sufficiently to determine the number of frames and 325 // Decodes the image sufficiently to determine the number of frames and
322 // returns that number. 326 // returns that number.
323 virtual size_t decodeFrameCount() { return 1; } 327 virtual size_t decodeFrameCount() { return 1; }
324 328
325 // Performs any additional setup of the requested frame after it has been 329 // Performs any additional setup of the requested frame after it has been
326 // initially created, e.g. setting a duration or disposal method. 330 // initially created, e.g. setting a duration or disposal method.
327 virtual void initializeNewFrame(size_t) { } 331 virtual void initializeNewFrame(size_t) { }
328 332
329 // Decodes the requested frame. 333 // Decodes the requested frame.
330 virtual void decode(size_t) = 0; 334 virtual void decode(size_t) = 0;
335 // Decodes the requested frame to specified color type output.
336 virtual void decodeTo(size_t index, ImageFrame::ColorType outputColor)
scroggo_chromium 2015/12/03 21:47:21 If we need to pass outputColor, why not merge this
aleksandar.stojiljkovic 2015/12/04 00:07:34 Didn't want to change code in other decoders, that
337 {
338 if (!canDecodeTo(index, outputColor))
scroggo_chromium 2015/12/03 21:47:21 So the subclass can override decodeTo and not call
aleksandar.stojiljkovic 2015/12/04 00:07:34 This would keep the existing decoders unchanged, j
339 return;
scroggo_chromium 2015/12/03 21:47:21 So this will silently fail?
aleksandar.stojiljkovic 2015/12/04 00:07:34 If there is no frame in cache, ImageFrameGenerator
340 // this is the default implementation that is just wrapping decode().
341 // subclasses need to override this and canDecodeTo for supported colorT ypes.
342 decode(index);
343 }
331 344
332 RefPtr<SharedBuffer> m_data; // The encoded data. 345 RefPtr<SharedBuffer> m_data; // The encoded data.
333 Vector<ImageFrame, 1> m_frameBufferCache; 346 Vector<ImageFrame, 1> m_frameBufferCache;
334 bool m_premultiplyAlpha; 347 bool m_premultiplyAlpha;
335 bool m_ignoreGammaAndColorProfile; 348 bool m_ignoreGammaAndColorProfile;
336 ImageOrientation m_orientation; 349 ImageOrientation m_orientation;
337 350
338 // The maximum amount of memory a decoded image should require. Ideally, 351 // The maximum amount of memory a decoded image should require. Ideally,
339 // image decoders should downsample large images to fit under this limit 352 // image decoders should downsample large images to fit under this limit
340 // (and then return the downsampled size from decodedSize()). Ignoring 353 // (and then return the downsampled size from decodedSize()). Ignoring
(...skipping 13 matching lines...) Expand all
354 367
355 IntSize m_size; 368 IntSize m_size;
356 bool m_sizeAvailable; 369 bool m_sizeAvailable;
357 bool m_isAllDataReceived; 370 bool m_isAllDataReceived;
358 bool m_failed; 371 bool m_failed;
359 }; 372 };
360 373
361 } // namespace blink 374 } // namespace blink
362 375
363 #endif 376 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698