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

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

Issue 1310053004: Fix clipped lighting image filters. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 3 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 | « gm/imagefiltersclipped.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 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 1199 matching lines...) Expand 10 before | Expand all | Expand 10 after
1210 1210
1211 SkAutoLockPixels alp(src); 1211 SkAutoLockPixels alp(src);
1212 if (!src.getPixels()) { 1212 if (!src.getPixels()) {
1213 return false; 1213 return false;
1214 } 1214 }
1215 1215
1216 if (!dst->tryAllocPixels(src.info().makeWH(bounds.width(), bounds.height())) ) { 1216 if (!dst->tryAllocPixels(src.info().makeWH(bounds.width(), bounds.height())) ) {
1217 return false; 1217 return false;
1218 } 1218 }
1219 1219
1220 SkAutoTUnref<SkImageFilterLight> transformedLight(light()->transform(ctx.ctm ())); 1220 SkMatrix matrix(ctx.ctm());
1221 matrix.postTranslate(SkIntToScalar(-srcOffset.x()), SkIntToScalar(-srcOffset .y()));
1222 SkAutoTUnref<SkImageFilterLight> transformedLight(light()->transform(matrix) );
1221 1223
1222 DiffuseLightingType lightingType(fKD); 1224 DiffuseLightingType lightingType(fKD);
1223 offset->fX = bounds.left(); 1225 offset->fX = bounds.left();
1224 offset->fY = bounds.top(); 1226 offset->fY = bounds.top();
1225 bounds.offset(-srcOffset); 1227 bounds.offset(-srcOffset);
1226 switch (transformedLight->type()) { 1228 switch (transformedLight->type()) {
1227 case SkImageFilterLight::kDistant_LightType: 1229 case SkImageFilterLight::kDistant_LightType:
1228 lightBitmap<DiffuseLightingType, SkDistantLight>(lightingType, 1230 lightBitmap<DiffuseLightingType, SkDistantLight>(lightingType,
1229 transformedLight, 1231 transformedLight,
1230 src, 1232 src,
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
1355 return false; 1357 return false;
1356 } 1358 }
1357 1359
1358 if (!dst->tryAllocPixels(src.info().makeWH(bounds.width(), bounds.height())) ) { 1360 if (!dst->tryAllocPixels(src.info().makeWH(bounds.width(), bounds.height())) ) {
1359 return false; 1361 return false;
1360 } 1362 }
1361 1363
1362 SpecularLightingType lightingType(fKS, fShininess); 1364 SpecularLightingType lightingType(fKS, fShininess);
1363 offset->fX = bounds.left(); 1365 offset->fX = bounds.left();
1364 offset->fY = bounds.top(); 1366 offset->fY = bounds.top();
1367 SkMatrix matrix(ctx.ctm());
1368 matrix.postTranslate(SkIntToScalar(-srcOffset.x()), SkIntToScalar(-srcOffset .y()));
1369 SkAutoTUnref<SkImageFilterLight> transformedLight(light()->transform(matrix) );
1365 bounds.offset(-srcOffset); 1370 bounds.offset(-srcOffset);
1366 SkAutoTUnref<SkImageFilterLight> transformedLight(light()->transform(ctx.ctm ()));
1367 switch (transformedLight->type()) { 1371 switch (transformedLight->type()) {
1368 case SkImageFilterLight::kDistant_LightType: 1372 case SkImageFilterLight::kDistant_LightType:
1369 lightBitmap<SpecularLightingType, SkDistantLight>(lightingType, 1373 lightBitmap<SpecularLightingType, SkDistantLight>(lightingType,
1370 transformedLight, 1374 transformedLight,
1371 src, 1375 src,
1372 dst, 1376 dst,
1373 surfaceScale(), 1377 surfaceScale(),
1374 bounds); 1378 bounds);
1375 break; 1379 break;
1376 case SkImageFilterLight::kPoint_LightType: 1380 case SkImageFilterLight::kPoint_LightType:
(...skipping 658 matching lines...) Expand 10 before | Expand all | Expand 10 after
2035 2039
2036 fsBuilder->codeAppendf("%s(%s)", fLightColorFunc.c_str(), surfaceToLight); 2040 fsBuilder->codeAppendf("%s(%s)", fLightColorFunc.c_str(), surfaceToLight);
2037 } 2041 }
2038 2042
2039 #endif 2043 #endif
2040 2044
2041 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(SkLightingImageFilter) 2045 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(SkLightingImageFilter)
2042 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkDiffuseLightingImageFilter) 2046 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkDiffuseLightingImageFilter)
2043 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkSpecularLightingImageFilter) 2047 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkSpecularLightingImageFilter)
2044 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END 2048 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END
OLDNEW
« no previous file with comments | « gm/imagefiltersclipped.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698