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

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

Issue 1877783003: Update DisplacementMapEffect to sk_sp (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Fix bug 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 "SkDisplacementMapEffect.h" 8 #include "SkDisplacementMapEffect.h"
9 9
10 #include "SkBitmap.h" 10 #include "SkBitmap.h"
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
156 default: 156 default:
157 break; 157 break;
158 } 158 }
159 return false; 159 return false;
160 } 160 }
161 161
162 } // end namespace 162 } // end namespace
163 163
164 /////////////////////////////////////////////////////////////////////////////// 164 ///////////////////////////////////////////////////////////////////////////////
165 165
166 SkImageFilter* SkDisplacementMapEffect::Create(ChannelSelectorType xChannelSelec tor, 166 sk_sp<SkImageFilter> SkDisplacementMapEffect::Make(ChannelSelectorType xChannelS elector,
167 ChannelSelectorType yChannelSelec tor, 167 ChannelSelectorType yChannelS elector,
168 SkScalar scale, 168 SkScalar scale,
169 SkImageFilter* displacement, 169 sk_sp<SkImageFilter> displace ment,
170 SkImageFilter* color, 170 sk_sp<SkImageFilter> color,
171 const CropRect* cropRect) { 171 const CropRect* cropRect) {
172 if (!channel_selector_type_is_valid(xChannelSelector) || 172 if (!channel_selector_type_is_valid(xChannelSelector) ||
173 !channel_selector_type_is_valid(yChannelSelector)) { 173 !channel_selector_type_is_valid(yChannelSelector)) {
174 return nullptr; 174 return nullptr;
175 } 175 }
176 176
177 SkImageFilter* inputs[2] = { displacement, color }; 177 sk_sp<SkImageFilter> inputs[2] = { std::move(displacement), std::move(color) };
178 return new SkDisplacementMapEffect(xChannelSelector, yChannelSelector, scale , inputs, cropRect); 178 return sk_sp<SkImageFilter>(new SkDisplacementMapEffect(xChannelSelector,
179 yChannelSelector,
180 scale, inputs, cropR ect));
179 } 181 }
180 182
181 SkDisplacementMapEffect::SkDisplacementMapEffect(ChannelSelectorType xChannelSel ector, 183 SkDisplacementMapEffect::SkDisplacementMapEffect(ChannelSelectorType xChannelSel ector,
182 ChannelSelectorType yChannelSel ector, 184 ChannelSelectorType yChannelSel ector,
183 SkScalar scale, 185 SkScalar scale,
184 SkImageFilter* inputs[2], 186 sk_sp<SkImageFilter> inputs[2],
185 const CropRect* cropRect) 187 const CropRect* cropRect)
186 : INHERITED(2, inputs, cropRect) 188 : INHERITED(inputs, 2, cropRect)
187 , fXChannelSelector(xChannelSelector) 189 , fXChannelSelector(xChannelSelector)
188 , fYChannelSelector(yChannelSelector) 190 , fYChannelSelector(yChannelSelector)
189 , fScale(scale) { 191 , fScale(scale) {
190 } 192 }
191 193
192 SkDisplacementMapEffect::~SkDisplacementMapEffect() { 194 SkDisplacementMapEffect::~SkDisplacementMapEffect() {
193 } 195 }
194 196
195 sk_sp<SkFlattenable> SkDisplacementMapEffect::CreateProc(SkReadBuffer& buffer) { 197 sk_sp<SkFlattenable> SkDisplacementMapEffect::CreateProc(SkReadBuffer& buffer) {
196 SK_IMAGEFILTER_UNFLATTEN_COMMON(common, 2); 198 SK_IMAGEFILTER_UNFLATTEN_COMMON(common, 2);
197 ChannelSelectorType xsel = (ChannelSelectorType)buffer.readInt(); 199 ChannelSelectorType xsel = (ChannelSelectorType)buffer.readInt();
198 ChannelSelectorType ysel = (ChannelSelectorType)buffer.readInt(); 200 ChannelSelectorType ysel = (ChannelSelectorType)buffer.readInt();
199 SkScalar scale = buffer.readScalar(); 201 SkScalar scale = buffer.readScalar();
200 return sk_sp<SkFlattenable>(Create(xsel, ysel, scale, common.getInput(0).get (), 202 return Make(xsel, ysel, scale,
201 common.getInput(1).get(), &common.cropRec t())); 203 common.getInput(0), common.getInput(1),
204 &common.cropRect());
202 } 205 }
203 206
204 void SkDisplacementMapEffect::flatten(SkWriteBuffer& buffer) const { 207 void SkDisplacementMapEffect::flatten(SkWriteBuffer& buffer) const {
205 this->INHERITED::flatten(buffer); 208 this->INHERITED::flatten(buffer);
206 buffer.writeInt((int) fXChannelSelector); 209 buffer.writeInt((int) fXChannelSelector);
207 buffer.writeInt((int) fYChannelSelector); 210 buffer.writeInt((int) fYChannelSelector);
208 buffer.writeScalar(fScale); 211 buffer.writeScalar(fScale);
209 } 212 }
210 213
211 #if SK_SUPPORT_GPU 214 #if SK_SUPPORT_GPU
(...skipping 413 matching lines...) Expand 10 before | Expand all | Expand 10 after
625 void GrGLDisplacementMapEffect::GenKey(const GrProcessor& proc, 628 void GrGLDisplacementMapEffect::GenKey(const GrProcessor& proc,
626 const GrGLSLCaps&, GrProcessorKeyBuilder* b) { 629 const GrGLSLCaps&, GrProcessorKeyBuilder* b) {
627 const GrDisplacementMapEffect& displacementMap = proc.cast<GrDisplacementMap Effect>(); 630 const GrDisplacementMapEffect& displacementMap = proc.cast<GrDisplacementMap Effect>();
628 631
629 uint32_t xKey = displacementMap.xChannelSelector(); 632 uint32_t xKey = displacementMap.xChannelSelector();
630 uint32_t yKey = displacementMap.yChannelSelector() << kChannelSelectorKeyBit s; 633 uint32_t yKey = displacementMap.yChannelSelector() << kChannelSelectorKeyBit s;
631 634
632 b->add32(xKey | yKey); 635 b->add32(xKey | yKey);
633 } 636 }
634 #endif 637 #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