diff options
Diffstat (limited to 'gm/lighting.cpp')
-rw-r--r-- | gm/lighting.cpp | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/gm/lighting.cpp b/gm/lighting.cpp index f16e781db0..330e0ee5fe 100644 --- a/gm/lighting.cpp +++ b/gm/lighting.cpp @@ -44,9 +44,10 @@ protected: void drawClippedBitmap(SkCanvas* canvas, const SkPaint& paint, int x, int y) { canvas->save(); - canvas->clipRect(SkRect::MakeXYWH(SkIntToScalar(x), SkIntToScalar(y), - SkIntToScalar(fBitmap.width()), SkIntToScalar(fBitmap.height()))); - canvas->drawBitmap(fBitmap, SkIntToScalar(x), SkIntToScalar(y), &paint); + canvas->translate(SkIntToScalar(x), SkIntToScalar(y)); + canvas->clipRect(SkRect::MakeWH( + SkIntToScalar(fBitmap.width()), SkIntToScalar(fBitmap.height()))); + canvas->drawBitmap(fBitmap, 0, 0, &paint); canvas->restore(); } @@ -91,18 +92,24 @@ protected: const SkIRect* cr = (i == 0) ? NULL : &cropRect; paint.setImageFilter(SkLightingImageFilter::CreatePointLitDiffuse(pointLocation, white, surfaceScale, kd, NULL, cr))->unref(); drawClippedBitmap(canvas, paint, 0, y); + paint.setImageFilter(SkLightingImageFilter::CreateDistantLitDiffuse(distantDirection, white, surfaceScale, kd, NULL, cr))->unref(); drawClippedBitmap(canvas, paint, 110, y); + paint.setImageFilter(SkLightingImageFilter::CreateSpotLitDiffuse(spotLocation, spotTarget, spotExponent, cutoffAngle, white, surfaceScale, kd, NULL, cr))->unref(); drawClippedBitmap(canvas, paint, 220, y); y += 110; + paint.setImageFilter(SkLightingImageFilter::CreatePointLitSpecular(pointLocation, white, surfaceScale, ks, shininess, NULL, cr))->unref(); drawClippedBitmap(canvas, paint, 0, y); + paint.setImageFilter(SkLightingImageFilter::CreateDistantLitSpecular(distantDirection, white, surfaceScale, ks, shininess, NULL, cr))->unref(); drawClippedBitmap(canvas, paint, 110, y); + paint.setImageFilter(SkLightingImageFilter::CreateSpotLitSpecular(spotLocation, spotTarget, spotExponent, cutoffAngle, white, surfaceScale, ks, shininess, NULL, cr))->unref(); drawClippedBitmap(canvas, paint, 220, y); + y += 110; } } |