OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2011 Google Inc. | 2 * Copyright 2011 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 "SkTestImageFilters.h" | 8 #include "SkTestImageFilters.h" |
9 #include "SkCanvas.h" | 9 #include "SkCanvas.h" |
10 #include "SkReadBuffer.h" | 10 #include "SkReadBuffer.h" |
11 #include "SkSpecialImage.h" | 11 #include "SkSpecialImage.h" |
12 #include "SkSpecialSurface.h" | 12 #include "SkSpecialSurface.h" |
13 #include "SkWriteBuffer.h" | 13 #include "SkWriteBuffer.h" |
14 | 14 |
15 /////////////////////////////////////////////////////////////////////////////// | 15 /////////////////////////////////////////////////////////////////////////////// |
16 | 16 |
| 17 sk_sp<SkImageFilter> SkDownSampleImageFilter::Make(SkScalar scale, sk_sp<SkImage
Filter> input) { |
| 18 if (!SkScalarIsFinite(scale)) { |
| 19 return nullptr; |
| 20 } |
| 21 // we don't support scale in this range |
| 22 if (scale > SK_Scalar1 || scale <= 0) { |
| 23 return nullptr; |
| 24 } |
| 25 return sk_sp<SkImageFilter>(new SkDownSampleImageFilter(scale, std::move(inp
ut))); |
| 26 } |
| 27 |
17 sk_sp<SkSpecialImage> SkDownSampleImageFilter::onFilterImage(SkSpecialImage* sou
rce, | 28 sk_sp<SkSpecialImage> SkDownSampleImageFilter::onFilterImage(SkSpecialImage* sou
rce, |
18 const Context& ctx, | 29 const Context& ctx, |
19 SkIPoint* offset) c
onst { | 30 SkIPoint* offset) c
onst { |
20 if (fScale > SK_Scalar1 || fScale <= 0) { | 31 if (fScale > SK_Scalar1 || fScale <= 0) { |
21 return nullptr; | 32 return nullptr; |
22 } | 33 } |
23 | 34 |
24 int dstW = SkScalarRoundToInt(source->width() * fScale); | 35 int dstW = SkScalarRoundToInt(source->width() * fScale); |
25 int dstH = SkScalarRoundToInt(source->height() * fScale); | 36 int dstH = SkScalarRoundToInt(source->height() * fScale); |
26 if (dstW < 1) { | 37 if (dstW < 1) { |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
89 this->INHERITED::flatten(buffer); | 100 this->INHERITED::flatten(buffer); |
90 buffer.writeScalar(fScale); | 101 buffer.writeScalar(fScale); |
91 } | 102 } |
92 | 103 |
93 #ifndef SK_IGNORE_TO_STRING | 104 #ifndef SK_IGNORE_TO_STRING |
94 void SkDownSampleImageFilter::toString(SkString* str) const { | 105 void SkDownSampleImageFilter::toString(SkString* str) const { |
95 str->appendf("SkDownSampleImageFilter: ("); | 106 str->appendf("SkDownSampleImageFilter: ("); |
96 str->append(")"); | 107 str->append(")"); |
97 } | 108 } |
98 #endif | 109 #endif |
OLD | NEW |