aboutsummaryrefslogtreecommitdiffhomepage
path: root/gm/lighting.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'gm/lighting.cpp')
-rw-r--r--gm/lighting.cpp61
1 files changed, 52 insertions, 9 deletions
diff --git a/gm/lighting.cpp b/gm/lighting.cpp
index 36c8ba0e45..0bfbb47a95 100644
--- a/gm/lighting.cpp
+++ b/gm/lighting.cpp
@@ -7,9 +7,10 @@
#include "gm.h"
#include "SkLightingImageFilter.h"
+#include "SkOffsetImageFilter.h"
#define WIDTH 330
-#define HEIGHT 440
+#define HEIGHT 660
namespace skiagm {
@@ -86,28 +87,70 @@ protected:
SkPaint paint;
SkImageFilter::CropRect cropRect(SkRect::MakeXYWH(20, 10, 60, 65));
+ SkImageFilter::CropRect fullSizeCropRect(SkRect::MakeXYWH(0, 0, 100, 100));
+ SkAutoTUnref<SkImageFilter> noopCropped(SkOffsetImageFilter::Create(0, 0, NULL, &cropRect));
int y = 0;
- for (int i = 0; i < 2; i++) {
- const SkImageFilter::CropRect* cr = (i == 0) ? NULL : &cropRect;
- paint.setImageFilter(SkLightingImageFilter::CreatePointLitDiffuse(pointLocation, white, surfaceScale, kd, NULL, cr))->unref();
+ for (int i = 0; i < 3; i++) {
+ const SkImageFilter::CropRect* cr = (i == 1) ? &cropRect : (i == 2) ? &fullSizeCropRect : NULL;
+ SkImageFilter* input = (i == 2) ? noopCropped.get() : NULL;
+ paint.setImageFilter(SkLightingImageFilter::CreatePointLitDiffuse(pointLocation,
+ white,
+ surfaceScale,
+ kd,
+ input,
+ cr))->unref();
drawClippedBitmap(canvas, paint, 0, y);
- paint.setImageFilter(SkLightingImageFilter::CreateDistantLitDiffuse(distantDirection, white, surfaceScale, kd, NULL, cr))->unref();
+ paint.setImageFilter(SkLightingImageFilter::CreateDistantLitDiffuse(distantDirection,
+ white,
+ surfaceScale,
+ kd,
+ input,
+ cr))->unref();
drawClippedBitmap(canvas, paint, 110, y);
- paint.setImageFilter(SkLightingImageFilter::CreateSpotLitDiffuse(spotLocation, spotTarget, spotExponent, cutoffAngle, white, surfaceScale, kd, NULL, cr))->unref();
+ paint.setImageFilter(SkLightingImageFilter::CreateSpotLitDiffuse(spotLocation,
+ spotTarget,
+ spotExponent,
+ cutoffAngle,
+ white,
+ surfaceScale,
+ kd,
+ input,
+ cr))->unref();
drawClippedBitmap(canvas, paint, 220, y);
y += 110;
- paint.setImageFilter(SkLightingImageFilter::CreatePointLitSpecular(pointLocation, white, surfaceScale, ks, shininess, NULL, cr))->unref();
+ paint.setImageFilter(SkLightingImageFilter::CreatePointLitSpecular(pointLocation,
+ white,
+ surfaceScale,
+ ks,
+ shininess,
+ input,
+ cr))->unref();
drawClippedBitmap(canvas, paint, 0, y);
- paint.setImageFilter(SkLightingImageFilter::CreateDistantLitSpecular(distantDirection, white, surfaceScale, ks, shininess, NULL, cr))->unref();
+ paint.setImageFilter(SkLightingImageFilter::CreateDistantLitSpecular(distantDirection,
+ white,
+ surfaceScale,
+ ks,
+ shininess,
+ input,
+ cr))->unref();
drawClippedBitmap(canvas, paint, 110, y);
- paint.setImageFilter(SkLightingImageFilter::CreateSpotLitSpecular(spotLocation, spotTarget, spotExponent, cutoffAngle, white, surfaceScale, ks, shininess, NULL, cr))->unref();
+ paint.setImageFilter(SkLightingImageFilter::CreateSpotLitSpecular(spotLocation,
+ spotTarget,
+ spotExponent,
+ cutoffAngle,
+ white,
+ surfaceScale,
+ ks,
+ shininess,
+ input,
+ cr))->unref();
drawClippedBitmap(canvas, paint, 220, y);
y += 110;