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

Side by Side Diff: src/effects/SkLightingImageFilter.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/SkLayerRasterizer.cpp ('k') | src/effects/SkLumaColorFilter.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 "SkLightingImageFilter.h" 8 #include "SkLightingImageFilter.h"
9 #include "SkBitmap.h" 9 #include "SkBitmap.h"
10 #include "SkColorPriv.h" 10 #include "SkColorPriv.h"
(...skipping 1192 matching lines...) Expand 10 before | Expand all | Expand 10 after
1203 SkDiffuseLightingImageFilter::SkDiffuseLightingImageFilter(SkImageFilterLight* l ight, 1203 SkDiffuseLightingImageFilter::SkDiffuseLightingImageFilter(SkImageFilterLight* l ight,
1204 SkScalar surfaceScale , 1204 SkScalar surfaceScale ,
1205 SkScalar kd, 1205 SkScalar kd,
1206 SkImageFilter* input, 1206 SkImageFilter* input,
1207 const CropRect* cropR ect) 1207 const CropRect* cropR ect)
1208 : INHERITED(light, surfaceScale, input, cropRect), 1208 : INHERITED(light, surfaceScale, input, cropRect),
1209 fKD(kd) 1209 fKD(kd)
1210 { 1210 {
1211 } 1211 }
1212 1212
1213 SkFlattenable* SkDiffuseLightingImageFilter::CreateProc(SkReadBuffer& buffer) { 1213 sk_sp<SkFlattenable> SkDiffuseLightingImageFilter::CreateProc(SkReadBuffer& buff er) {
1214 SK_IMAGEFILTER_UNFLATTEN_COMMON(common, 1); 1214 SK_IMAGEFILTER_UNFLATTEN_COMMON(common, 1);
1215 SkAutoTUnref<SkImageFilterLight> light(SkImageFilterLight::UnflattenLight(bu ffer)); 1215 SkAutoTUnref<SkImageFilterLight> light(SkImageFilterLight::UnflattenLight(bu ffer));
1216 SkScalar surfaceScale = buffer.readScalar(); 1216 SkScalar surfaceScale = buffer.readScalar();
1217 SkScalar kd = buffer.readScalar(); 1217 SkScalar kd = buffer.readScalar();
1218 return Create(light, surfaceScale, kd, common.getInput(0).get(), &common.cro pRect()); 1218 return sk_sp<SkFlattenable>(Create(light, surfaceScale, kd, common.getInput( 0).get(),
1219 &common.cropRect()));
1219 } 1220 }
1220 1221
1221 void SkDiffuseLightingImageFilter::flatten(SkWriteBuffer& buffer) const { 1222 void SkDiffuseLightingImageFilter::flatten(SkWriteBuffer& buffer) const {
1222 this->INHERITED::flatten(buffer); 1223 this->INHERITED::flatten(buffer);
1223 buffer.writeScalar(fKD); 1224 buffer.writeScalar(fKD);
1224 } 1225 }
1225 1226
1226 bool SkDiffuseLightingImageFilter::onFilterImageDeprecated(Proxy* proxy, 1227 bool SkDiffuseLightingImageFilter::onFilterImageDeprecated(Proxy* proxy,
1227 const SkBitmap& sourc e, 1228 const SkBitmap& sourc e,
1228 const Context& ctx, 1229 const Context& ctx,
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
1345 SkScalar ks, 1346 SkScalar ks,
1346 SkScalar shininess, 1347 SkScalar shininess,
1347 SkImageFilter* inpu t, 1348 SkImageFilter* inpu t,
1348 const CropRect* cro pRect) 1349 const CropRect* cro pRect)
1349 : INHERITED(light, surfaceScale, input, cropRect), 1350 : INHERITED(light, surfaceScale, input, cropRect),
1350 fKS(ks), 1351 fKS(ks),
1351 fShininess(shininess) 1352 fShininess(shininess)
1352 { 1353 {
1353 } 1354 }
1354 1355
1355 SkFlattenable* SkSpecularLightingImageFilter::CreateProc(SkReadBuffer& buffer) { 1356 sk_sp<SkFlattenable> SkSpecularLightingImageFilter::CreateProc(SkReadBuffer& buf fer) {
1356 SK_IMAGEFILTER_UNFLATTEN_COMMON(common, 1); 1357 SK_IMAGEFILTER_UNFLATTEN_COMMON(common, 1);
1357 SkAutoTUnref<SkImageFilterLight> light(SkImageFilterLight::UnflattenLight(bu ffer)); 1358 SkAutoTUnref<SkImageFilterLight> light(SkImageFilterLight::UnflattenLight(bu ffer));
1358 SkScalar surfaceScale = buffer.readScalar(); 1359 SkScalar surfaceScale = buffer.readScalar();
1359 SkScalar ks = buffer.readScalar(); 1360 SkScalar ks = buffer.readScalar();
1360 SkScalar shine = buffer.readScalar(); 1361 SkScalar shine = buffer.readScalar();
1361 return Create(light, surfaceScale, ks, shine, common.getInput(0).get(), &com mon.cropRect()); 1362 return sk_sp<SkFlattenable>(Create(light, surfaceScale, ks, shine, common.ge tInput(0).get(),
1363 &common.cropRect()));
1362 } 1364 }
1363 1365
1364 void SkSpecularLightingImageFilter::flatten(SkWriteBuffer& buffer) const { 1366 void SkSpecularLightingImageFilter::flatten(SkWriteBuffer& buffer) const {
1365 this->INHERITED::flatten(buffer); 1367 this->INHERITED::flatten(buffer);
1366 buffer.writeScalar(fKS); 1368 buffer.writeScalar(fKS);
1367 buffer.writeScalar(fShininess); 1369 buffer.writeScalar(fShininess);
1368 } 1370 }
1369 1371
1370 bool SkSpecularLightingImageFilter::onFilterImageDeprecated(Proxy* proxy, 1372 bool SkSpecularLightingImageFilter::onFilterImageDeprecated(Proxy* proxy,
1371 const SkBitmap& sour ce, 1373 const SkBitmap& sour ce,
(...skipping 746 matching lines...) Expand 10 before | Expand all | Expand 10 after
2118 2120
2119 fragBuilder->codeAppendf("%s(%s)", fLightColorFunc.c_str(), surfaceToLight); 2121 fragBuilder->codeAppendf("%s(%s)", fLightColorFunc.c_str(), surfaceToLight);
2120 } 2122 }
2121 2123
2122 #endif 2124 #endif
2123 2125
2124 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(SkLightingImageFilter) 2126 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(SkLightingImageFilter)
2125 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkDiffuseLightingImageFilter) 2127 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkDiffuseLightingImageFilter)
2126 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkSpecularLightingImageFilter) 2128 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkSpecularLightingImageFilter)
2127 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END 2129 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END
OLDNEW
« no previous file with comments | « src/effects/SkLayerRasterizer.cpp ('k') | src/effects/SkLumaColorFilter.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698