| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2006 Samuel Weinig (sam.weinig@gmail.com) | 2 * Copyright (C) 2006 Samuel Weinig (sam.weinig@gmail.com) |
| 3 * Copyright (C) 2004, 2005, 2006, 2008 Apple Inc. All rights reserved. | 3 * Copyright (C) 2004, 2005, 2006, 2008 Apple Inc. 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 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 257 String BitmapImage::filenameExtension() const { | 257 String BitmapImage::filenameExtension() const { |
| 258 return m_source.filenameExtension(); | 258 return m_source.filenameExtension(); |
| 259 } | 259 } |
| 260 | 260 |
| 261 void BitmapImage::draw( | 261 void BitmapImage::draw( |
| 262 SkCanvas* canvas, | 262 SkCanvas* canvas, |
| 263 const SkPaint& paint, | 263 const SkPaint& paint, |
| 264 const FloatRect& dstRect, | 264 const FloatRect& dstRect, |
| 265 const FloatRect& srcRect, | 265 const FloatRect& srcRect, |
| 266 RespectImageOrientationEnum shouldRespectImageOrientation, | 266 RespectImageOrientationEnum shouldRespectImageOrientation, |
| 267 ImageClampingMode clampMode) { | 267 ImageClampingMode clampMode, |
| 268 const ColorBehavior& colorBehavior) { |
| 268 TRACE_EVENT0("skia", "BitmapImage::draw"); | 269 TRACE_EVENT0("skia", "BitmapImage::draw"); |
| 269 | 270 |
| 270 sk_sp<SkImage> image = imageForCurrentFrame(); | 271 sk_sp<SkImage> image = imageForCurrentFrame(colorBehavior); |
| 271 if (!image) | 272 if (!image) |
| 272 return; // It's too early and we don't have an image yet. | 273 return; // It's too early and we don't have an image yet. |
| 273 | 274 |
| 274 FloatRect adjustedSrcRect = srcRect; | 275 FloatRect adjustedSrcRect = srcRect; |
| 275 adjustedSrcRect.intersect(SkRect::Make(image->bounds())); | 276 adjustedSrcRect.intersect(SkRect::Make(image->bounds())); |
| 276 | 277 |
| 277 if (adjustedSrcRect.isEmpty() || dstRect.isEmpty()) | 278 if (adjustedSrcRect.isEmpty() || dstRect.isEmpty()) |
| 278 return; // Nothing to draw. | 279 return; // Nothing to draw. |
| 279 | 280 |
| 280 ImageOrientation orientation = DefaultImageOrientation; | 281 ImageOrientation orientation = DefaultImageOrientation; |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 363 return m_source.frameIsCompleteAtIndex(index); | 364 return m_source.frameIsCompleteAtIndex(index); |
| 364 } | 365 } |
| 365 | 366 |
| 366 float BitmapImage::frameDurationAtIndex(size_t index) const { | 367 float BitmapImage::frameDurationAtIndex(size_t index) const { |
| 367 if (index < m_frames.size() && m_frames[index].m_haveMetadata) | 368 if (index < m_frames.size() && m_frames[index].m_haveMetadata) |
| 368 return m_frames[index].m_duration; | 369 return m_frames[index].m_duration; |
| 369 | 370 |
| 370 return m_source.frameDurationAtIndex(index); | 371 return m_source.frameDurationAtIndex(index); |
| 371 } | 372 } |
| 372 | 373 |
| 373 sk_sp<SkImage> BitmapImage::imageForCurrentFrame() { | 374 sk_sp<SkImage> BitmapImage::imageForCurrentFrame( |
| 374 // TODO(ccameron): Allow the caller of imageForCurrentFrame to specify the | 375 const ColorBehavior& colorBehavior) { |
| 375 // the desired ColorBehavior. | |
| 376 // https://crbug.com/667420 | |
| 377 const ColorBehavior& colorBehavior = m_cachedFrameColorBehavior; | |
| 378 return frameAtIndex(currentFrame(), colorBehavior); | 376 return frameAtIndex(currentFrame(), colorBehavior); |
| 379 } | 377 } |
| 380 | 378 |
| 381 PassRefPtr<Image> BitmapImage::imageForDefaultFrame() { | 379 PassRefPtr<Image> BitmapImage::imageForDefaultFrame() { |
| 382 // TODO(ccameron): Determine the appropriate ColorBehavior for this situation. | 380 // TODO(ccameron): Determine the appropriate ColorBehavior for this situation. |
| 383 // https://crbug.com/667420 | 381 // https://crbug.com/667420 |
| 384 const ColorBehavior& colorBehavior = m_cachedFrameColorBehavior; | 382 const ColorBehavior& colorBehavior = m_cachedFrameColorBehavior; |
| 385 if (frameCount() > 1) { | 383 if (frameCount() > 1) { |
| 386 sk_sp<SkImage> firstFrame = frameAtIndex(0, colorBehavior); | 384 sk_sp<SkImage> firstFrame = frameAtIndex(0, colorBehavior); |
| 387 if (firstFrame) | 385 if (firstFrame) |
| (...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 653 getImageObserver()->animationAdvanced(this); | 651 getImageObserver()->animationAdvanced(this); |
| 654 | 652 |
| 655 return true; | 653 return true; |
| 656 } | 654 } |
| 657 | 655 |
| 658 void BitmapImage::notifyObserversOfAnimationAdvance(TimerBase*) { | 656 void BitmapImage::notifyObserversOfAnimationAdvance(TimerBase*) { |
| 659 getImageObserver()->animationAdvanced(this); | 657 getImageObserver()->animationAdvanced(this); |
| 660 } | 658 } |
| 661 | 659 |
| 662 } // namespace blink | 660 } // namespace blink |
| OLD | NEW |