diff options
author | robertphillips <robertphillips@google.com> | 2015-07-13 13:16:44 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-07-13 13:16:44 -0700 |
commit | 3d32d768cd8b66c49c070495c08f7933b9dd2423 (patch) | |
tree | 6676e917988dcecc00b5f33f5e33a4e7c2849344 /bench | |
parent | 52e7657cd850f95e66eb23c6d138ee45149a1039 (diff) |
Add new SkPoint3 class
The existing Light filter and the upcoming Lighting Shader both need a Point3 class
Review URL: https://codereview.chromium.org/1229693009
Diffstat (limited to 'bench')
-rw-r--r-- | bench/LightingBench.cpp | 107 |
1 files changed, 55 insertions, 52 deletions
diff --git a/bench/LightingBench.cpp b/bench/LightingBench.cpp index a56ed226e2..ce6c11989d 100644 --- a/bench/LightingBench.cpp +++ b/bench/LightingBench.cpp @@ -9,6 +9,7 @@ #include "SkCanvas.h" #include "SkDevice.h" #include "SkLightingImageFilter.h" +#include "SkPoint3.h" #define FILTER_WIDTH_SMALL SkIntToScalar(32) #define FILTER_HEIGHT_SMALL SkIntToScalar(32) @@ -30,63 +31,65 @@ protected: } } - static SkPoint3 getPointLocation() { - static SkPoint3 pointLocation(0, 0, SkIntToScalar(10)); + static SkPoint3 GetPointLocation() { + static SkPoint3 pointLocation = SkPoint3::Make(0, 0, SkIntToScalar(10)); return pointLocation; } - static SkPoint3 getDistantDirection() { + static SkPoint3 GetDistantDirection() { static SkScalar azimuthRad = SkDegreesToRadians(SkIntToScalar(225)); static SkScalar elevationRad = SkDegreesToRadians(SkIntToScalar(5)); - static SkPoint3 distantDirection(SkScalarMul(SkScalarCos(azimuthRad), - SkScalarCos(elevationRad)), - SkScalarMul(SkScalarSin(azimuthRad), - SkScalarCos(elevationRad)), - SkScalarSin(elevationRad)); + static SkPoint3 distantDirection = SkPoint3::Make(SkScalarMul(SkScalarCos(azimuthRad), + SkScalarCos(elevationRad)), + SkScalarMul(SkScalarSin(azimuthRad), + SkScalarCos(elevationRad)), + SkScalarSin(elevationRad)); return distantDirection; } - static SkPoint3 getSpotLocation() { - static SkPoint3 spotLocation(SkIntToScalar(-10), SkIntToScalar(-10), SkIntToScalar(20)); + static SkPoint3 GetSpotLocation() { + static SkPoint3 spotLocation = SkPoint3::Make(SkIntToScalar(-10), + SkIntToScalar(-10), + SkIntToScalar(20)); return spotLocation; } - static SkPoint3 getSpotTarget() { - static SkPoint3 spotTarget(SkIntToScalar(40), SkIntToScalar(40), 0); + static SkPoint3 GetSpotTarget() { + static SkPoint3 spotTarget = SkPoint3::Make(SkIntToScalar(40), SkIntToScalar(40), 0); return spotTarget; } - static SkScalar getSpotExponent() { + static SkScalar GetSpotExponent() { static SkScalar spotExponent = SK_Scalar1; return spotExponent; } - static SkScalar getCutoffAngle() { + static SkScalar GetCutoffAngle() { static SkScalar cutoffAngle = SkIntToScalar(15); return cutoffAngle; } - static SkScalar getKd() { + static SkScalar GetKd() { static SkScalar kd = SkIntToScalar(2); return kd; } - static SkScalar getKs() { + static SkScalar GetKs() { static SkScalar ks = SkIntToScalar(1); return ks; } - static SkScalar getShininess() { + static SkScalar GetShininess() { static SkScalar shininess = SkIntToScalar(8); return shininess; } - static SkScalar getSurfaceScale() { + static SkScalar GetSurfaceScale() { static SkScalar surfaceScale = SkIntToScalar(1); return surfaceScale; } - static SkColor getWhite() { + static SkColor GetWhite() { static SkColor white(0xFFFFFFFF); return white; } @@ -106,10 +109,10 @@ protected: } void onDraw(const int loops, SkCanvas* canvas) override { - draw(loops, canvas, SkLightingImageFilter::CreatePointLitDiffuse(getPointLocation(), - getWhite(), - getSurfaceScale(), - getKd())); + draw(loops, canvas, SkLightingImageFilter::CreatePointLitDiffuse(GetPointLocation(), + GetWhite(), + GetSurfaceScale(), + GetKd())); } private: @@ -127,10 +130,10 @@ protected: } void onDraw(const int loops, SkCanvas* canvas) override { - draw(loops, canvas, SkLightingImageFilter::CreateDistantLitDiffuse(getDistantDirection(), - getWhite(), - getSurfaceScale(), - getKd())); + draw(loops, canvas, SkLightingImageFilter::CreateDistantLitDiffuse(GetDistantDirection(), + GetWhite(), + GetSurfaceScale(), + GetKd())); } private: @@ -148,13 +151,13 @@ protected: } void onDraw(const int loops, SkCanvas* canvas) override { - draw(loops, canvas, SkLightingImageFilter::CreateSpotLitDiffuse(getSpotLocation(), - getSpotTarget(), - getSpotExponent(), - getCutoffAngle(), - getWhite(), - getSurfaceScale(), - getKd())); + draw(loops, canvas, SkLightingImageFilter::CreateSpotLitDiffuse(GetSpotLocation(), + GetSpotTarget(), + GetSpotExponent(), + GetCutoffAngle(), + GetWhite(), + GetSurfaceScale(), + GetKd())); } private: @@ -172,11 +175,11 @@ protected: } void onDraw(const int loops, SkCanvas* canvas) override { - draw(loops, canvas, SkLightingImageFilter::CreatePointLitSpecular(getPointLocation(), - getWhite(), - getSurfaceScale(), - getKs(), - getShininess())); + draw(loops, canvas, SkLightingImageFilter::CreatePointLitSpecular(GetPointLocation(), + GetWhite(), + GetSurfaceScale(), + GetKs(), + GetShininess())); } private: @@ -194,11 +197,11 @@ protected: } void onDraw(const int loops, SkCanvas* canvas) override { - draw(loops, canvas, SkLightingImageFilter::CreateDistantLitSpecular(getDistantDirection(), - getWhite(), - getSurfaceScale(), - getKs(), - getShininess())); + draw(loops, canvas, SkLightingImageFilter::CreateDistantLitSpecular(GetDistantDirection(), + GetWhite(), + GetSurfaceScale(), + GetKs(), + GetShininess())); } private: @@ -216,14 +219,14 @@ protected: } void onDraw(const int loops, SkCanvas* canvas) override { - draw(loops, canvas, SkLightingImageFilter::CreateSpotLitSpecular(getSpotLocation(), - getSpotTarget(), - getSpotExponent(), - getCutoffAngle(), - getWhite(), - getSurfaceScale(), - getKs(), - getShininess())); + draw(loops, canvas, SkLightingImageFilter::CreateSpotLitSpecular(GetSpotLocation(), + GetSpotTarget(), + GetSpotExponent(), + GetCutoffAngle(), + GetWhite(), + GetSurfaceScale(), + GetKs(), + GetShininess())); } private: |