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 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
241 } | 241 } |
242 | 242 |
243 bool Failed() const { return failed_; } | 243 bool Failed() const { return failed_; } |
244 | 244 |
245 // Clears decoded pixel data from all frames except the provided frame. If | 245 // Clears decoded pixel data from all frames except the provided frame. If |
246 // subsequent frames depend on this frame's required previous frame, then that | 246 // subsequent frames depend on this frame's required previous frame, then that |
247 // frame is also kept in cache to prevent re-decoding from the beginning. | 247 // frame is also kept in cache to prevent re-decoding from the beginning. |
248 // Callers may pass WTF::kNotFound to clear all frames. | 248 // Callers may pass WTF::kNotFound to clear all frames. |
249 // Note: If |frame_buffer_cache_| contains only one frame, it won't be | 249 // Note: If |frame_buffer_cache_| contains only one frame, it won't be |
250 // cleared. Returns the number of bytes of frame data actually cleared. | 250 // cleared. Returns the number of bytes of frame data actually cleared. |
251 // | |
252 // This is a virtual method because MockImageDecoder needs to override it in | |
253 // order to run the test ImageFrameGeneratorTest::ClearMultiFrameDecode. | |
254 // | |
255 // @TODO Let MockImageDecoder override ImageFrame::ClearFrameBuffer instead, | |
256 // so this method can be made non-virtual. It is used in the test | |
257 // ImageFrameGeneratorTest::ClearMultiFrameDecode. The test needs to | |
258 // be modified since two frames may be kept in cache, instead of | |
259 // always just one, with this ClearCacheExceptFrame implementation. | |
260 virtual size_t ClearCacheExceptFrame(size_t); | 251 virtual size_t ClearCacheExceptFrame(size_t); |
261 | 252 |
262 // If the image has a cursor hot-spot, stores it in the argument | 253 // If the image has a cursor hot-spot, stores it in the argument |
263 // and returns true. Otherwise returns false. | 254 // and returns true. Otherwise returns false. |
264 virtual bool HotSpot(IntPoint&) const { return false; } | 255 virtual bool HotSpot(IntPoint&) const { return false; } |
265 | 256 |
266 virtual void SetMemoryAllocator(SkBitmap::Allocator* allocator) { | 257 virtual void SetMemoryAllocator(SkBitmap::Allocator* allocator) { |
267 // FIXME: this doesn't work for images with multiple frames. | 258 // FIXME: this doesn't work for images with multiple frames. |
268 if (frame_buffer_cache_.IsEmpty()) { | 259 if (frame_buffer_cache_.IsEmpty()) { |
269 // Ensure that InitializeNewFrame is called, after parsing if | 260 // Ensure that InitializeNewFrame is called, after parsing if |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
389 // The default condition is that the frame status needs to be FramePartial or | 380 // The default condition is that the frame status needs to be FramePartial or |
390 // FrameComplete, since the data of previous frames is copied in | 381 // FrameComplete, since the data of previous frames is copied in |
391 // InitFrameBuffer() before setting the status to FramePartial. For WebP, | 382 // InitFrameBuffer() before setting the status to FramePartial. For WebP, |
392 // however, the status needs to be FrameComplete since the complete buffer is | 383 // however, the status needs to be FrameComplete since the complete buffer is |
393 // used to do alpha blending in WEBPImageDecoder::ApplyPostProcessing(). | 384 // used to do alpha blending in WEBPImageDecoder::ApplyPostProcessing(). |
394 // | 385 // |
395 // Before calling this, verify that frame |index| exists by checking that | 386 // Before calling this, verify that frame |index| exists by checking that |
396 // |index| is smaller than |frame_buffer_cache_|.size(). | 387 // |index| is smaller than |frame_buffer_cache_|.size(). |
397 virtual bool FrameStatusSufficientForSuccessors(size_t index) { | 388 virtual bool FrameStatusSufficientForSuccessors(size_t index) { |
398 DCHECK(index < frame_buffer_cache_.size()); | 389 DCHECK(index < frame_buffer_cache_.size()); |
399 return frame_buffer_cache_[index].GetStatus() != ImageFrame::kFrameEmpty; | 390 ImageFrame::Status frame_status = frame_buffer_cache_[index].GetStatus(); |
| 391 return frame_status == ImageFrame::kFramePartial || |
| 392 frame_status == ImageFrame::kFrameComplete; |
400 } | 393 } |
401 | 394 |
402 private: | 395 private: |
403 // Some code paths compute the size of the image as "width * height * 4" | 396 // Some code paths compute the size of the image as "width * height * 4" |
404 // and return it as a (signed) int. Avoid overflow. | 397 // and return it as a (signed) int. Avoid overflow. |
405 static bool SizeCalculationMayOverflow(unsigned width, unsigned height) { | 398 static bool SizeCalculationMayOverflow(unsigned width, unsigned height) { |
406 unsigned long long total_size = static_cast<unsigned long long>(width) * | 399 unsigned long long total_size = static_cast<unsigned long long>(width) * |
407 static_cast<unsigned long long>(height); | 400 static_cast<unsigned long long>(height); |
408 return total_size > ((1 << 29) - 1); | 401 return total_size > ((1 << 29) - 1); |
409 } | 402 } |
(...skipping 15 matching lines...) Expand all Loading... |
425 bool has_histogrammed_color_space_ = false; | 418 bool has_histogrammed_color_space_ = false; |
426 | 419 |
427 sk_sp<SkColorSpace> embedded_color_space_ = nullptr; | 420 sk_sp<SkColorSpace> embedded_color_space_ = nullptr; |
428 bool source_to_target_color_transform_needs_update_ = false; | 421 bool source_to_target_color_transform_needs_update_ = false; |
429 std::unique_ptr<SkColorSpaceXform> source_to_target_color_transform_; | 422 std::unique_ptr<SkColorSpaceXform> source_to_target_color_transform_; |
430 }; | 423 }; |
431 | 424 |
432 } // namespace blink | 425 } // namespace blink |
433 | 426 |
434 #endif | 427 #endif |
OLD | NEW |