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 "third_party/skia/include/core/SkCanvas.h" | 10 #include "third_party/skia/include/core/SkCanvas.h" |
11 #include "third_party/skia/include/core/SkImage.h" | 11 #include "third_party/skia/include/core/SkImage.h" |
12 #include "third_party/skia/include/core/SkPaint.h" | 12 #include "third_party/skia/include/core/SkPaint.h" |
13 #include "wtf/PtrUtil.h" | 13 #include "wtf/PtrUtil.h" |
14 #include <memory> | 14 #include <memory> |
15 | 15 |
16 namespace blink { | 16 namespace blink { |
17 | 17 |
18 PassRefPtr<StaticBitmapImage> StaticBitmapImage::create(PassRefPtr<SkImage> imag e) | 18 PassRefPtr<StaticBitmapImage> StaticBitmapImage::create(sk_sp<SkImage> image) |
19 { | 19 { |
20 if (!image) | 20 if (!image) |
21 return nullptr; | 21 return nullptr; |
22 if (image->isTextureBacked()) | 22 if (image->isTextureBacked()) |
23 return AcceleratedStaticBitmapImage::create(image); | 23 return AcceleratedStaticBitmapImage::create(std::move(image)); |
24 return adoptRef(new StaticBitmapImage(image)); | 24 return adoptRef(new StaticBitmapImage(std::move(image))); |
25 } | 25 } |
26 | 26 |
27 StaticBitmapImage::StaticBitmapImage(PassRefPtr<SkImage> image) : m_image(image) | 27 StaticBitmapImage::StaticBitmapImage(sk_sp<SkImage> image) : m_image(image) |
f(malita)
2016/09/01 03:55:38
std::move(image)
Łukasz Anforowicz
2016/09/01 20:50:58
Done.
| |
28 { | 28 { |
29 ASSERT(m_image); | 29 ASSERT(m_image); |
30 } | 30 } |
31 | 31 |
32 IntSize StaticBitmapImage::size() const | 32 IntSize StaticBitmapImage::size() const |
33 { | 33 { |
34 return IntSize(m_image->width(), m_image->height()); | 34 return IntSize(m_image->width(), m_image->height()); |
35 } | 35 } |
36 | 36 |
37 bool StaticBitmapImage::isTextureBacked() | 37 bool StaticBitmapImage::isTextureBacked() |
(...skipping 15 matching lines...) Expand all Loading... | |
53 if (dstRect.isEmpty() || adjustedSrcRect.isEmpty()) | 53 if (dstRect.isEmpty() || adjustedSrcRect.isEmpty()) |
54 return; // Nothing to draw. | 54 return; // Nothing to draw. |
55 | 55 |
56 canvas->drawImageRect(m_image.get(), adjustedSrcRect, dstRect, &paint, | 56 canvas->drawImageRect(m_image.get(), adjustedSrcRect, dstRect, &paint, |
57 WebCoreClampingModeToSkiaRectConstraint(clampMode)); | 57 WebCoreClampingModeToSkiaRectConstraint(clampMode)); |
58 | 58 |
59 if (ImageObserver* observer = getImageObserver()) | 59 if (ImageObserver* observer = getImageObserver()) |
60 observer->didDraw(this); | 60 observer->didDraw(this); |
61 } | 61 } |
62 | 62 |
63 PassRefPtr<SkImage> StaticBitmapImage::imageForCurrentFrame() | 63 sk_sp<SkImage> StaticBitmapImage::imageForCurrentFrame() |
64 { | 64 { |
65 return m_image; | 65 return m_image; |
66 } | 66 } |
67 | 67 |
68 } // namespace blink | 68 } // namespace blink |
OLD | NEW |