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

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

Issue 2495183002: Pull up initFrameBuffer to ImageDecoder. (Closed)
Patch Set: Process feedback patch set 1 Created 4 years, 1 month 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 283 matching lines...) Expand 10 before | Expand all | Expand 10 after
294 294
295 virtual void clearFrameBuffer(size_t frameIndex); 295 virtual void clearFrameBuffer(size_t frameIndex);
296 296
297 // Decodes the image sufficiently to determine the image size. 297 // Decodes the image sufficiently to determine the image size.
298 virtual void decodeSize() = 0; 298 virtual void decodeSize() = 0;
299 299
300 // Decodes the image sufficiently to determine the number of frames and 300 // Decodes the image sufficiently to determine the number of frames and
301 // returns that number. 301 // returns that number.
302 virtual size_t decodeFrameCount() { return 1; } 302 virtual size_t decodeFrameCount() { return 1; }
303 303
304 // Called to initialize the frame buffer with the given index, based on the
305 // provided and previous frame's characteristics. Returns true on success. On
306 // failure, this will mark the image as failed. Before calling this method,
307 // the caller must verify that the frame exists.
308 bool initFrameBuffer(size_t);
309
304 // Performs any additional setup of the requested frame after it has been 310 // Performs any additional setup of the requested frame after it has been
305 // initially created, e.g. setting a duration or disposal method. 311 // initially created, e.g. setting a duration or disposal method.
306 virtual void initializeNewFrame(size_t) {} 312 virtual void initializeNewFrame(size_t) {}
307 313
308 // Decodes the requested frame. 314 // Decodes the requested frame.
309 virtual void decode(size_t) = 0; 315 virtual void decode(size_t) = 0;
310 316
311 RefPtr<SegmentReader> m_data; // The encoded data. 317 RefPtr<SegmentReader> m_data; // The encoded data.
312 Vector<ImageFrame, 1> m_frameBufferCache; 318 Vector<ImageFrame, 1> m_frameBufferCache;
313 const bool m_premultiplyAlpha; 319 const bool m_premultiplyAlpha;
(...skipping 20 matching lines...) Expand all
334 static SniffResult determineImageType(const char* data, size_t length); 340 static SniffResult determineImageType(const char* data, size_t length);
335 341
336 // Some code paths compute the size of the image as "width * height * 4" 342 // Some code paths compute the size of the image as "width * height * 4"
337 // and return it as a (signed) int. Avoid overflow. 343 // and return it as a (signed) int. Avoid overflow.
338 static bool sizeCalculationMayOverflow(unsigned width, unsigned height) { 344 static bool sizeCalculationMayOverflow(unsigned width, unsigned height) {
339 unsigned long long total_size = static_cast<unsigned long long>(width) * 345 unsigned long long total_size = static_cast<unsigned long long>(width) *
340 static_cast<unsigned long long>(height); 346 static_cast<unsigned long long>(height);
341 return total_size > ((1 << 29) - 1); 347 return total_size > ((1 << 29) - 1);
342 } 348 }
343 349
350 // This methods gets called at the end of initFrameBuffer. Subclasses can do
351 // format specific initialization, for e.g. alpha settings, here.
352 virtual void onInitFrameBuffer(size_t){};
353
354 // Called by initFrameBuffer to determine if it can take the bitmap of the
355 // previous frame. This condition is different for GIF and WEBP.
356 virtual bool canReusePreviousFrameBuffer(size_t) const { return false; }
scroggo_chromium 2016/11/14 16:44:12 I think this will only get called by WEBP, GIF, an
joostouwerling 2016/11/14 16:54:13 I picked false for the last reason you mentioned.
357
344 IntSize m_size; 358 IntSize m_size;
345 bool m_sizeAvailable = false; 359 bool m_sizeAvailable = false;
346 bool m_isAllDataReceived = false; 360 bool m_isAllDataReceived = false;
347 bool m_failed = false; 361 bool m_failed = false;
348 362
349 sk_sp<SkColorSpace> m_embeddedColorSpace = nullptr; 363 sk_sp<SkColorSpace> m_embeddedColorSpace = nullptr;
350 std::unique_ptr<SkColorSpaceXform> m_sourceToOutputDeviceColorTransform; 364 std::unique_ptr<SkColorSpaceXform> m_sourceToOutputDeviceColorTransform;
351 }; 365 };
352 366
353 } // namespace blink 367 } // namespace blink
354 368
355 #endif 369 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698