| 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 286 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 297 size_t clearCacheExceptTwoFrames(size_t, size_t); | 297 size_t clearCacheExceptTwoFrames(size_t, size_t); |
| 298 virtual void clearFrameBuffer(size_t frameIndex); | 298 virtual void clearFrameBuffer(size_t frameIndex); |
| 299 | 299 |
| 300 // Decodes the image sufficiently to determine the image size. | 300 // Decodes the image sufficiently to determine the image size. |
| 301 virtual void decodeSize() = 0; | 301 virtual void decodeSize() = 0; |
| 302 | 302 |
| 303 // Decodes the image sufficiently to determine the number of frames and | 303 // Decodes the image sufficiently to determine the number of frames and |
| 304 // returns that number. | 304 // returns that number. |
| 305 virtual size_t decodeFrameCount() { return 1; } | 305 virtual size_t decodeFrameCount() { return 1; } |
| 306 | 306 |
| 307 // Called to initialize the frame buffer with the given index, based on the |
| 308 // provided and previous frame's characteristics. Returns true on success. On |
| 309 // failure, this will mark the image as failed. Before calling this method, |
| 310 // the caller must verify that the frame exists. |
| 311 bool initFrameBuffer(size_t); |
| 312 |
| 307 // Performs any additional setup of the requested frame after it has been | 313 // Performs any additional setup of the requested frame after it has been |
| 308 // initially created, e.g. setting a duration or disposal method. | 314 // initially created, e.g. setting a duration or disposal method. |
| 309 virtual void initializeNewFrame(size_t) {} | 315 virtual void initializeNewFrame(size_t) {} |
| 310 | 316 |
| 311 // Decodes the requested frame. | 317 // Decodes the requested frame. |
| 312 virtual void decode(size_t) = 0; | 318 virtual void decode(size_t) = 0; |
| 313 | 319 |
| 314 // This method is only required for animated images. It returns a vector with | 320 // This method is only required for animated images. It returns a vector with |
| 315 // all frame indices that need to be decoded in order to succesfully decode | 321 // all frame indices that need to be decoded in order to succesfully decode |
| 316 // the provided frame. The indices are returned in reverse order, so the | 322 // the provided frame. The indices are returned in reverse order, so the |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 351 // Some code paths compute the size of the image as "width * height * 4" | 357 // Some code paths compute the size of the image as "width * height * 4" |
| 352 // and return it as a (signed) int. Avoid overflow. | 358 // and return it as a (signed) int. Avoid overflow. |
| 353 static bool sizeCalculationMayOverflow(unsigned width, unsigned height) { | 359 static bool sizeCalculationMayOverflow(unsigned width, unsigned height) { |
| 354 unsigned long long total_size = static_cast<unsigned long long>(width) * | 360 unsigned long long total_size = static_cast<unsigned long long>(width) * |
| 355 static_cast<unsigned long long>(height); | 361 static_cast<unsigned long long>(height); |
| 356 return total_size > ((1 << 29) - 1); | 362 return total_size > ((1 << 29) - 1); |
| 357 } | 363 } |
| 358 | 364 |
| 359 bool m_purgeAggressively; | 365 bool m_purgeAggressively; |
| 360 | 366 |
| 367 // This methods gets called at the end of initFrameBuffer. Subclasses can do |
| 368 // format specific initialization, for e.g. alpha settings, here. |
| 369 virtual void onInitFrameBuffer(size_t){}; |
| 370 |
| 371 // Called by initFrameBuffer to determine if it can take the bitmap of the |
| 372 // previous frame. This condition is different for GIF and WEBP. |
| 373 virtual bool canReusePreviousFrameBuffer(size_t) const { return false; } |
| 374 |
| 361 IntSize m_size; | 375 IntSize m_size; |
| 362 bool m_sizeAvailable = false; | 376 bool m_sizeAvailable = false; |
| 363 bool m_isAllDataReceived = false; | 377 bool m_isAllDataReceived = false; |
| 364 bool m_failed = false; | 378 bool m_failed = false; |
| 365 bool m_hasHistogrammedColorSpace = false; | 379 bool m_hasHistogrammedColorSpace = false; |
| 366 | 380 |
| 367 sk_sp<SkColorSpace> m_embeddedColorSpace = nullptr; | 381 sk_sp<SkColorSpace> m_embeddedColorSpace = nullptr; |
| 368 std::unique_ptr<SkColorSpaceXform> m_sourceToOutputDeviceColorTransform; | 382 std::unique_ptr<SkColorSpaceXform> m_sourceToOutputDeviceColorTransform; |
| 369 }; | 383 }; |
| 370 | 384 |
| 371 } // namespace blink | 385 } // namespace blink |
| 372 | 386 |
| 373 #endif | 387 #endif |
| OLD | NEW |