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

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

Issue 1882113002: Update TileImageFilter to sk_sp (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 | « samplecode/SampleFilterFuzz.cpp ('k') | tests/ImageFilterTest.cpp » ('j') | 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 2013 Google Inc. 2 * Copyright 2013 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 "SkTileImageFilter.h" 8 #include "SkTileImageFilter.h"
9 9
10 #include "SkCanvas.h" 10 #include "SkCanvas.h"
11 #include "SkImage.h" 11 #include "SkImage.h"
12 #include "SkMatrix.h" 12 #include "SkMatrix.h"
13 #include "SkOffsetImageFilter.h" 13 #include "SkOffsetImageFilter.h"
14 #include "SkPaint.h" 14 #include "SkPaint.h"
15 #include "SkReadBuffer.h" 15 #include "SkReadBuffer.h"
16 #include "SkShader.h" 16 #include "SkShader.h"
17 #include "SkSpecialImage.h" 17 #include "SkSpecialImage.h"
18 #include "SkSpecialSurface.h" 18 #include "SkSpecialSurface.h"
19 #include "SkSurface.h" 19 #include "SkSurface.h"
20 #include "SkValidationUtils.h" 20 #include "SkValidationUtils.h"
21 #include "SkWriteBuffer.h" 21 #include "SkWriteBuffer.h"
22 22
23 SkImageFilter* SkTileImageFilter::Create(const SkRect& srcRect, const SkRect& ds tRect, 23 sk_sp<SkImageFilter> SkTileImageFilter::Make(const SkRect& srcRect, const SkRect & dstRect,
24 SkImageFilter* input) { 24 sk_sp<SkImageFilter> input) {
25 if (!SkIsValidRect(srcRect) || !SkIsValidRect(dstRect)) { 25 if (!SkIsValidRect(srcRect) || !SkIsValidRect(dstRect)) {
26 return nullptr; 26 return nullptr;
27 } 27 }
28 if (srcRect.width() == dstRect.width() && srcRect.height() == dstRect.height ()) { 28 if (srcRect.width() == dstRect.width() && srcRect.height() == dstRect.height ()) {
29 SkRect ir = dstRect; 29 SkRect ir = dstRect;
30 if (!ir.intersect(srcRect)) { 30 if (!ir.intersect(srcRect)) {
31 return SkSafeRef(input); 31 return input;
32 } 32 }
33 CropRect cropRect(ir); 33 CropRect cropRect(ir);
34 return SkOffsetImageFilter::Make(dstRect.x() - srcRect.x(), 34 return SkOffsetImageFilter::Make(dstRect.x() - srcRect.x(),
35 dstRect.y() - srcRect.y(), 35 dstRect.y() - srcRect.y(),
36 sk_ref_sp<SkImageFilter>(input), 36 std::move(input),
37 &cropRect).release(); 37 &cropRect);
38 } 38 }
39 return new SkTileImageFilter(srcRect, dstRect, input); 39 return sk_sp<SkImageFilter>(new SkTileImageFilter(srcRect, dstRect, std::mov e(input)));
40 } 40 }
41 41
42 sk_sp<SkSpecialImage> SkTileImageFilter::onFilterImage(SkSpecialImage* source, 42 sk_sp<SkSpecialImage> SkTileImageFilter::onFilterImage(SkSpecialImage* source,
43 const Context& ctx, 43 const Context& ctx,
44 SkIPoint* offset) const { 44 SkIPoint* offset) const {
45 SkIPoint inputOffset = SkIPoint::Make(0, 0); 45 SkIPoint inputOffset = SkIPoint::Make(0, 0);
46 sk_sp<SkSpecialImage> input(this->filterInput(0, source, ctx, &inputOffset)) ; 46 sk_sp<SkSpecialImage> input(this->filterInput(0, source, ctx, &inputOffset)) ;
47 if (!input) { 47 if (!input) {
48 return nullptr; 48 return nullptr;
49 } 49 }
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
136 136
137 SkRect SkTileImageFilter::computeFastBounds(const SkRect& src) const { 137 SkRect SkTileImageFilter::computeFastBounds(const SkRect& src) const {
138 return fDstRect; 138 return fDstRect;
139 } 139 }
140 140
141 sk_sp<SkFlattenable> SkTileImageFilter::CreateProc(SkReadBuffer& buffer) { 141 sk_sp<SkFlattenable> SkTileImageFilter::CreateProc(SkReadBuffer& buffer) {
142 SK_IMAGEFILTER_UNFLATTEN_COMMON(common, 1); 142 SK_IMAGEFILTER_UNFLATTEN_COMMON(common, 1);
143 SkRect src, dst; 143 SkRect src, dst;
144 buffer.readRect(&src); 144 buffer.readRect(&src);
145 buffer.readRect(&dst); 145 buffer.readRect(&dst);
146 return sk_sp<SkFlattenable>(Create(src, dst, common.getInput(0).get())); 146 return Make(src, dst, common.getInput(0));
147 } 147 }
148 148
149 void SkTileImageFilter::flatten(SkWriteBuffer& buffer) const { 149 void SkTileImageFilter::flatten(SkWriteBuffer& buffer) const {
150 this->INHERITED::flatten(buffer); 150 this->INHERITED::flatten(buffer);
151 buffer.writeRect(fSrcRect); 151 buffer.writeRect(fSrcRect);
152 buffer.writeRect(fDstRect); 152 buffer.writeRect(fDstRect);
153 } 153 }
154 154
155 #ifndef SK_IGNORE_TO_STRING 155 #ifndef SK_IGNORE_TO_STRING
156 void SkTileImageFilter::toString(SkString* str) const { 156 void SkTileImageFilter::toString(SkString* str) const {
157 str->appendf("SkTileImageFilter: ("); 157 str->appendf("SkTileImageFilter: (");
158 str->appendf("src: %.2f %.2f %.2f %.2f", 158 str->appendf("src: %.2f %.2f %.2f %.2f",
159 fSrcRect.fLeft, fSrcRect.fTop, fSrcRect.fRight, fSrcRect.fBotto m); 159 fSrcRect.fLeft, fSrcRect.fTop, fSrcRect.fRight, fSrcRect.fBotto m);
160 str->appendf(" dst: %.2f %.2f %.2f %.2f", 160 str->appendf(" dst: %.2f %.2f %.2f %.2f",
161 fDstRect.fLeft, fDstRect.fTop, fDstRect.fRight, fDstRect.fBotto m); 161 fDstRect.fLeft, fDstRect.fTop, fDstRect.fRight, fDstRect.fBotto m);
162 if (this->getInput(0)) { 162 if (this->getInput(0)) {
163 str->appendf("input: ("); 163 str->appendf("input: (");
164 this->getInput(0)->toString(str); 164 this->getInput(0)->toString(str);
165 str->appendf(")"); 165 str->appendf(")");
166 } 166 }
167 str->append(")"); 167 str->append(")");
168 } 168 }
169 #endif 169 #endif
OLDNEW
« no previous file with comments | « samplecode/SampleFilterFuzz.cpp ('k') | tests/ImageFilterTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698