Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(23)

Side by Side Diff: src/effects/SkTestImageFilters.cpp

Issue 1893973002: Outline SkImageFilter Make methods (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: update to ToT Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/effects/SkPictureImageFilter.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
OLDNEW
« no previous file with comments | « src/effects/SkPictureImageFilter.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698