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

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

Issue 1855733002: change flattenable factory to return sk_sp (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: 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/SkMorphologyImageFilter.cpp ('k') | src/effects/SkPaintImageFilter.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 2012 The Android Open Source Project 2 * Copyright 2012 The Android Open Source Project
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 "SkOffsetImageFilter.h" 8 #include "SkOffsetImageFilter.h"
9 9
10 #include "SkCanvas.h" 10 #include "SkCanvas.h"
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 MapDirection direction) const { 75 MapDirection direction) const {
76 SkVector vec; 76 SkVector vec;
77 ctm.mapVectors(&vec, &fOffset, 1); 77 ctm.mapVectors(&vec, &fOffset, 1);
78 if (kReverse_MapDirection == direction) { 78 if (kReverse_MapDirection == direction) {
79 vec.negate(); 79 vec.negate();
80 } 80 }
81 81
82 return src.makeOffset(SkScalarCeilToInt(vec.fX), SkScalarCeilToInt(vec.fY)); 82 return src.makeOffset(SkScalarCeilToInt(vec.fX), SkScalarCeilToInt(vec.fY));
83 } 83 }
84 84
85 SkFlattenable* SkOffsetImageFilter::CreateProc(SkReadBuffer& buffer) { 85 sk_sp<SkFlattenable> SkOffsetImageFilter::CreateProc(SkReadBuffer& buffer) {
86 SK_IMAGEFILTER_UNFLATTEN_COMMON(common, 1); 86 SK_IMAGEFILTER_UNFLATTEN_COMMON(common, 1);
87 SkPoint offset; 87 SkPoint offset;
88 buffer.readPoint(&offset); 88 buffer.readPoint(&offset);
89 return Make(offset.x(), offset.y(), common.getInput(0), &common.cropRect()). release(); 89 return Make(offset.x(), offset.y(), common.getInput(0), &common.cropRect());
90 } 90 }
91 91
92 void SkOffsetImageFilter::flatten(SkWriteBuffer& buffer) const { 92 void SkOffsetImageFilter::flatten(SkWriteBuffer& buffer) const {
93 this->INHERITED::flatten(buffer); 93 this->INHERITED::flatten(buffer);
94 buffer.writePoint(fOffset); 94 buffer.writePoint(fOffset);
95 } 95 }
96 96
97 SkOffsetImageFilter::SkOffsetImageFilter(SkScalar dx, SkScalar dy, 97 SkOffsetImageFilter::SkOffsetImageFilter(SkScalar dx, SkScalar dy,
98 sk_sp<SkImageFilter> input, 98 sk_sp<SkImageFilter> input,
99 const CropRect* cropRect) 99 const CropRect* cropRect)
100 : INHERITED(&input, 1, cropRect) { 100 : INHERITED(&input, 1, cropRect) {
101 fOffset.set(dx, dy); 101 fOffset.set(dx, dy);
102 } 102 }
103 103
104 #ifndef SK_IGNORE_TO_STRING 104 #ifndef SK_IGNORE_TO_STRING
105 void SkOffsetImageFilter::toString(SkString* str) const { 105 void SkOffsetImageFilter::toString(SkString* str) const {
106 str->appendf("SkOffsetImageFilter: ("); 106 str->appendf("SkOffsetImageFilter: (");
107 str->appendf("offset: (%f, %f) ", fOffset.fX, fOffset.fY); 107 str->appendf("offset: (%f, %f) ", fOffset.fX, fOffset.fY);
108 str->append("input: ("); 108 str->append("input: (");
109 if (this->getInput(0)) { 109 if (this->getInput(0)) {
110 this->getInput(0)->toString(str); 110 this->getInput(0)->toString(str);
111 } 111 }
112 str->append("))"); 112 str->append("))");
113 } 113 }
114 #endif 114 #endif
OLDNEW
« no previous file with comments | « src/effects/SkMorphologyImageFilter.cpp ('k') | src/effects/SkPaintImageFilter.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698