OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2015 Google Inc. | 2 * Copyright 2015 Google Inc. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 #include "SkImageSource.h" | 8 #include "SkImageSource.h" |
9 | 9 |
10 #include "SkCanvas.h" | 10 #include "SkCanvas.h" |
11 #include "SkImage.h" | 11 #include "SkImage.h" |
12 #include "SkReadBuffer.h" | 12 #include "SkReadBuffer.h" |
13 #include "SkSpecialImage.h" | 13 #include "SkSpecialImage.h" |
14 #include "SkSpecialSurface.h" | 14 #include "SkSpecialSurface.h" |
15 #include "SkWriteBuffer.h" | 15 #include "SkWriteBuffer.h" |
16 #include "SkString.h" | 16 #include "SkString.h" |
17 | 17 |
| 18 sk_sp<SkImageFilter> SkImageSource::Make(sk_sp<SkImage> image) { |
| 19 if (!image) { |
| 20 return nullptr; |
| 21 } |
| 22 |
| 23 return sk_sp<SkImageFilter>(new SkImageSource(std::move(image))); |
| 24 } |
| 25 |
| 26 sk_sp<SkImageFilter> SkImageSource::Make(sk_sp<SkImage> image, |
| 27 const SkRect& srcRect, |
| 28 const SkRect& dstRect, |
| 29 SkFilterQuality filterQuality) { |
| 30 if (!image) { |
| 31 return nullptr; |
| 32 } |
| 33 |
| 34 return sk_sp<SkImageFilter>(new SkImageSource(std::move(image), |
| 35 srcRect, dstRect, |
| 36 filterQuality)); |
| 37 } |
18 | 38 |
19 SkImageSource::SkImageSource(sk_sp<SkImage> image) | 39 SkImageSource::SkImageSource(sk_sp<SkImage> image) |
20 : INHERITED(nullptr, 0, nullptr) | 40 : INHERITED(nullptr, 0, nullptr) |
21 , fImage(std::move(image)) | 41 , fImage(std::move(image)) |
22 , fSrcRect(SkRect::MakeIWH(fImage->width(), fImage->height())) | 42 , fSrcRect(SkRect::MakeIWH(fImage->width(), fImage->height())) |
23 , fDstRect(fSrcRect) | 43 , fDstRect(fSrcRect) |
24 , fFilterQuality(kHigh_SkFilterQuality) { | 44 , fFilterQuality(kHigh_SkFilterQuality) { |
25 } | 45 } |
26 | 46 |
27 SkImageSource::SkImageSource(sk_sp<SkImage> image, | 47 SkImageSource::SkImageSource(sk_sp<SkImage> image, |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
115 void SkImageSource::toString(SkString* str) const { | 135 void SkImageSource::toString(SkString* str) const { |
116 str->appendf("SkImageSource: ("); | 136 str->appendf("SkImageSource: ("); |
117 str->appendf("src: (%f,%f,%f,%f) dst: (%f,%f,%f,%f) ", | 137 str->appendf("src: (%f,%f,%f,%f) dst: (%f,%f,%f,%f) ", |
118 fSrcRect.fLeft, fSrcRect.fTop, fSrcRect.fRight, fSrcRect.fBotto
m, | 138 fSrcRect.fLeft, fSrcRect.fTop, fSrcRect.fRight, fSrcRect.fBotto
m, |
119 fDstRect.fLeft, fDstRect.fTop, fDstRect.fRight, fDstRect.fBotto
m); | 139 fDstRect.fLeft, fDstRect.fTop, fDstRect.fRight, fDstRect.fBotto
m); |
120 str->appendf("image: (%d,%d)", | 140 str->appendf("image: (%d,%d)", |
121 fImage->width(), fImage->height()); | 141 fImage->width(), fImage->height()); |
122 str->append(")"); | 142 str->append(")"); |
123 } | 143 } |
124 #endif | 144 #endif |
OLD | NEW |