Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "platform/graphics/StaticBitmapImage.h" | 5 #include "platform/graphics/StaticBitmapImage.h" |
| 6 | 6 |
| 7 #include "platform/graphics/AcceleratedStaticBitmapImage.h" | 7 #include "platform/graphics/AcceleratedStaticBitmapImage.h" |
| 8 #include "platform/graphics/GraphicsContext.h" | 8 #include "platform/graphics/GraphicsContext.h" |
| 9 #include "platform/graphics/ImageObserver.h" | 9 #include "platform/graphics/ImageObserver.h" |
| 10 #include "platform/graphics/UnacceleratedStaticBitmapImage.h" | 10 #include "platform/graphics/UnacceleratedStaticBitmapImage.h" |
| 11 #include "platform/graphics/paint/PaintImage.h" | |
| 11 #include "third_party/skia/include/core/SkCanvas.h" | 12 #include "third_party/skia/include/core/SkCanvas.h" |
| 12 #include "third_party/skia/include/core/SkImage.h" | 13 #include "third_party/skia/include/core/SkImage.h" |
| 13 #include "third_party/skia/include/core/SkPaint.h" | 14 #include "third_party/skia/include/core/SkPaint.h" |
| 14 | 15 |
| 15 namespace blink { | 16 namespace blink { |
| 16 | 17 |
| 17 PassRefPtr<StaticBitmapImage> StaticBitmapImage::Create(sk_sp<SkImage> image) { | 18 PassRefPtr<StaticBitmapImage> StaticBitmapImage::Create(sk_sp<SkImage> image) { |
| 18 if (!image) | 19 if (!image) |
| 19 return nullptr; | 20 return nullptr; |
| 20 if (image->isTextureBacked()) | 21 if (image->isTextureBacked()) |
| 21 return AcceleratedStaticBitmapImage::CreateFromSharedContextImage( | 22 return AcceleratedStaticBitmapImage::CreateFromSharedContextImage( |
| 22 std::move(image)); | 23 std::move(image)); |
| 23 return UnacceleratedStaticBitmapImage::Create(std::move(image)); | 24 return UnacceleratedStaticBitmapImage::Create(std::move(image)); |
| 24 } | 25 } |
| 25 | 26 |
| 26 void StaticBitmapImage::DrawHelper(PaintCanvas* canvas, | 27 void StaticBitmapImage::DrawHelper(PaintCanvas* canvas, |
| 27 const PaintFlags& flags, | 28 const PaintFlags& flags, |
| 28 const FloatRect& dst_rect, | 29 const FloatRect& dst_rect, |
| 29 const FloatRect& src_rect, | 30 const FloatRect& src_rect, |
| 30 ImageClampingMode clamp_mode, | 31 ImageClampingMode clamp_mode, |
| 31 sk_sp<SkImage> image) { | 32 sk_sp<SkImage> image) { |
| 32 FloatRect adjusted_src_rect = src_rect; | 33 FloatRect adjusted_src_rect = src_rect; |
| 33 adjusted_src_rect.Intersect(SkRect::Make(image->bounds())); | 34 adjusted_src_rect.Intersect(SkRect::Make(image->bounds())); |
| 34 | 35 |
| 35 if (dst_rect.IsEmpty() || adjusted_src_rect.IsEmpty()) | 36 if (dst_rect.IsEmpty() || adjusted_src_rect.IsEmpty()) |
| 36 return; // Nothing to draw. | 37 return; // Nothing to draw. |
| 37 | 38 |
| 38 canvas->drawImageRect(std::move(image), adjusted_src_rect, dst_rect, &flags, | 39 auto animation_type = MaybeAnimated() ? PaintImage::AnimationType::ANIMATED |
|
pdr.
2017/04/12 17:37:05
WDYT of just changing the return type of MaybeAnim
vmpstr
2017/04/12 18:58:44
Hmm, there are callers outside of graphics that us
| |
| 39 WebCoreClampingModeToSkiaRectConstraint(clamp_mode)); | 40 : PaintImage::AnimationType::STATIC; |
| 41 auto completion_state = CurrentFrameIsComplete() | |
| 42 ? PaintImage::CompletionState::DONE | |
| 43 : PaintImage::CompletionState::PARTIALLY_DONE; | |
| 44 canvas->drawImageRect( | |
| 45 PaintImage(std::move(image), animation_type, completion_state), | |
| 46 adjusted_src_rect, dst_rect, &flags, | |
| 47 WebCoreClampingModeToSkiaRectConstraint(clamp_mode)); | |
| 40 } | 48 } |
| 41 | 49 |
| 42 } // namespace blink | 50 } // namespace blink |
| OLD | NEW |