Add filled occluders to shadow_utils GM

Change-Id: I70a927261b6530d2352d8d5a713b309aa518e6b0
Reviewed-on: https://skia-review.googlesource.com/16545
Commit-Queue: Jim Van Verth <jvanverth@google.com>
Reviewed-by: Mike Reed <reed@google.com>
Reviewed-by: Brian Salomon <bsalomon@google.com>
This commit is contained in:
Jim Van Verth 2017-05-12 10:38:38 -04:00 committed by Skia Commit-Bot
parent 57a75c4727
commit 737169965f

View File

@ -22,7 +22,7 @@ void draw_shadow(SkCanvas* canvas, const SkPath& path, int height, SkColor color
static constexpr int kW = 800;
static constexpr int kH = 800;
DEF_SIMPLE_GM(shadow_utils, canvas, kW, kH) {
void draw_paths(SkCanvas* canvas, bool hideOccluders) {
SkTArray<SkPath> paths;
paths.push_back().addRoundRect(SkRect::MakeWH(50, 50), 10, 10);
SkRRect oddRRect;
@ -34,7 +34,7 @@ DEF_SIMPLE_GM(shadow_utils, canvas, kW, kH) {
paths.push_back().addOval(SkRect::MakeWH(20, 60));
static constexpr SkScalar kPad = 15.f;
static constexpr SkPoint3 kLightPos = {250, 400, 500};
static constexpr SkPoint3 kLightPos = { 250, 400, 500 };
static constexpr SkScalar kLightR = 100.f;
static constexpr SkScalar kHeight = 50.f;
canvas->translate(3 * kPad, 3 * kPad);
@ -47,7 +47,7 @@ DEF_SIMPLE_GM(shadow_utils, canvas, kW, kH) {
m->setRotate(33.f, 25.f, 25.f);
m->postScale(1.2f, 0.8f, 25.f, 25.f);
for (auto& m : matrices) {
for (auto flags : {kNone_ShadowFlag, kTransparentOccluder_ShadowFlag}) {
for (auto flags : { kNone_ShadowFlag, kTransparentOccluder_ShadowFlag }) {
for (const auto& path : paths) {
SkRect postMBounds = path.getBounds();
m.mapRect(&postMBounds);
@ -68,10 +68,22 @@ DEF_SIMPLE_GM(shadow_utils, canvas, kW, kH) {
// Draw the path outline in green on top of the ambient and spot shadows.
SkPaint paint;
paint.setColor(SK_ColorGREEN);
paint.setAntiAlias(true);
paint.setStyle(SkPaint::kStroke_Style);
paint.setStrokeWidth(0);
if (hideOccluders) {
if (SkToBool(flags & kTransparentOccluder_ShadowFlag)) {
paint.setColor(SK_ColorCYAN);
} else {
paint.setColor(SK_ColorGREEN);
}
paint.setStyle(SkPaint::kStroke_Style);
paint.setStrokeWidth(0);
} else {
paint.setColor(SK_ColorLTGRAY);
if (SkToBool(flags & kTransparentOccluder_ShadowFlag)) {
paint.setAlpha(128);
}
paint.setStyle(SkPaint::kFill_Style);
}
canvas->drawPath(path, paint);
canvas->restore();
@ -93,3 +105,11 @@ DEF_SIMPLE_GM(shadow_utils, canvas, kW, kH) {
canvas->restore();
}
}
DEF_SIMPLE_GM(shadow_utils, canvas, kW, kH) {
draw_paths(canvas, true);
}
DEF_SIMPLE_GM(shadow_utils_occl, canvas, kW, kH) {
draw_paths(canvas, false);
}