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

Side by Side Diff: include/effects/SkLightingImageFilter.h

Issue 132453008: remove SkScalarMul from public headers (Closed) Base URL: https://skia.googlecode.com/svn/trunk
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 | Annotate | Revision Log
« no previous file with comments | « include/core/SkScalar.h ('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
9 #ifndef SkLightingImageFilter_DEFINED 8 #ifndef SkLightingImageFilter_DEFINED
10 #define SkLightingImageFilter_DEFINED 9 #define SkLightingImageFilter_DEFINED
11 10
12 #include "SkImageFilter.h" 11 #include "SkImageFilter.h"
13 #include "SkColor.h" 12 #include "SkColor.h"
14 13
15 class SK_API SkPoint3 { 14 class SK_API SkPoint3 {
16 public: 15 public:
17 SkPoint3() {} 16 SkPoint3() {}
18 SkPoint3(SkScalar x, SkScalar y, SkScalar z) 17 SkPoint3(SkScalar x, SkScalar y, SkScalar z)
19 : fX(x), fY(y), fZ(z) {} 18 : fX(x), fY(y), fZ(z) {}
20 SkScalar dot(const SkPoint3& other) const { 19 SkScalar dot(const SkPoint3& other) const {
21 return SkScalarMul(fX, other.fX) 20 return fX * other.fX + fY * other.fY + fZ * other.fZ;
22 + SkScalarMul(fY, other.fY)
23 + SkScalarMul(fZ, other.fZ);
24 } 21 }
25 SkScalar maxComponent() const { 22 SkScalar maxComponent() const {
26 return fX > fY ? (fX > fZ ? fX : fZ) : (fY > fZ ? fY : fZ); 23 return fX > fY ? (fX > fZ ? fX : fZ) : (fY > fZ ? fY : fZ);
27 } 24 }
28 void normalize() { 25 void normalize() {
29 // Small epsilon is added to prevent division by 0. 26 // Small epsilon is added to prevent division by 0.
30 SkScalar scale = SkScalarInvert(SkScalarSqrt(dot(*this)) + SK_ScalarNear lyZero); 27 SkScalar scale = SkScalarInvert(SkScalarSqrt(dot(*this)) + SK_ScalarNear lyZero);
31 fX = SkScalarMul(fX, scale); 28 fX = fX * scale;
32 fY = SkScalarMul(fY, scale); 29 fY = fY * scale;
33 fZ = SkScalarMul(fZ, scale); 30 fZ = fZ * scale;
34 } 31 }
35 SkPoint3 operator*(SkScalar scalar) const { 32 SkPoint3 operator*(SkScalar scalar) const {
36 return SkPoint3(SkScalarMul(fX, scalar), 33 return SkPoint3(fX * scalar, fY * scalar, fZ * scalar);
37 SkScalarMul(fY, scalar),
38 SkScalarMul(fZ, scalar));
39 } 34 }
40 SkPoint3 operator-(const SkPoint3& other) const { 35 SkPoint3 operator-(const SkPoint3& other) const {
41 return SkPoint3(fX - other.fX, fY - other.fY, fZ - other.fZ); 36 return SkPoint3(fX - other.fX, fY - other.fY, fZ - other.fZ);
42 } 37 }
43 bool operator==(const SkPoint3& other) const { 38 bool operator==(const SkPoint3& other) const {
44 return fX == other.fX && fY == other.fY && fZ == other.fZ; 39 return fX == other.fX && fY == other.fY && fZ == other.fZ;
45 } 40 }
46 SkScalar fX, fY, fZ; 41 SkScalar fX, fY, fZ;
47 }; 42 };
48 43
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 const SkLight* light() const { return fLight; } 79 const SkLight* light() const { return fLight; }
85 SkScalar surfaceScale() const { return fSurfaceScale; } 80 SkScalar surfaceScale() const { return fSurfaceScale; }
86 81
87 private: 82 private:
88 typedef SkImageFilter INHERITED; 83 typedef SkImageFilter INHERITED;
89 SkLight* fLight; 84 SkLight* fLight;
90 SkScalar fSurfaceScale; 85 SkScalar fSurfaceScale;
91 }; 86 };
92 87
93 #endif 88 #endif
OLDNEW
« no previous file with comments | « include/core/SkScalar.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698