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

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

Issue 173633003: Factory methods for heap-allocated SkMaskFilter objects. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 years, 10 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
OLDNEW
1 1
2 /* 2 /*
3 * Copyright 2006 The Android Open Source Project 3 * Copyright 2006 The Android Open Source Project
4 * 4 *
5 * Use of this source code is governed by a BSD-style license that can be 5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file. 6 * found in the LICENSE file.
7 */ 7 */
8 8
9 9
10 #include "SkEmbossMaskFilter.h" 10 #include "SkEmbossMaskFilter.h"
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 42
43 // specular should be 0..15.99 as a scalar 43 // specular should be 0..15.99 as a scalar
44 int sp = pin2byte(SkScalarToFixed(specular) >> 12); 44 int sp = pin2byte(SkScalarToFixed(specular) >> 12);
45 45
46 SkEmbossMaskFilter::Light light; 46 SkEmbossMaskFilter::Light light;
47 47
48 memcpy(light.fDirection, direction, sizeof(light.fDirection)); 48 memcpy(light.fDirection, direction, sizeof(light.fDirection));
49 light.fAmbient = SkToU8(am); 49 light.fAmbient = SkToU8(am);
50 light.fSpecular = SkToU8(sp); 50 light.fSpecular = SkToU8(sp);
51 51
52 return SkNEW_ARGS(SkEmbossMaskFilter, (blurSigma, light)); 52 return SkEmbossMaskFilter::Create(blurSigma, light);
53 } 53 }
54 54
55 /////////////////////////////////////////////////////////////////////////////// 55 ///////////////////////////////////////////////////////////////////////////////
56 56
57 static void normalize(SkScalar v[3]) { 57 static void normalize(SkScalar v[3]) {
58 SkScalar mag = SkScalarSquare(v[0]) + SkScalarSquare(v[1]) + SkScalarSquare( v[2]); 58 SkScalar mag = SkScalarSquare(v[0]) + SkScalarSquare(v[1]) + SkScalarSquare( v[2]);
59 mag = SkScalarSqrt(mag); 59 mag = SkScalarSqrt(mag);
60 60
61 for (int i = 0; i < 3; i++) { 61 for (int i = 0; i < 3; i++) {
62 v[i] = SkScalarDiv(v[i], mag); 62 v[i] = SkScalarDiv(v[i], mag);
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
160 str->append(") "); 160 str->append(") ");
161 161
162 str->appendf("ambient: %d specular: %d ", 162 str->appendf("ambient: %d specular: %d ",
163 fLight.fAmbient, fLight.fSpecular); 163 fLight.fAmbient, fLight.fSpecular);
164 164
165 str->append("blurSigma: "); 165 str->append("blurSigma: ");
166 str->appendScalar(fBlurSigma); 166 str->appendScalar(fBlurSigma);
167 str->append(")"); 167 str->append(")");
168 } 168 }
169 #endif 169 #endif
OLDNEW
« include/effects/SkTableMaskFilter.h ('K') | « samplecode/SampleEmboss.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698