diff options
author | Jim Van Verth <jvanverth@google.com> | 2017-05-15 10:44:22 -0400 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2017-05-15 16:01:43 +0000 |
commit | 78c8f30d6167b4bf40937c6a8814cd448e2228a6 (patch) | |
tree | d1ccb54f60f7eef479fab4cb4344d6fcab4ebc7c /gm/shadowutils.cpp | |
parent | e334c596546c7ec79f2b0e55b3a1c2839a94f352 (diff) |
Add filled occluders to shadow_utils GM, take 2
Classifies fully visible opaque shadows differently
than transparent to avoid cache collisions.
Change-Id: Iba5aab2b2cbe08f70205c343e86fe92b0cab7497
Reviewed-on: https://skia-review.googlesource.com/16858
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Jim Van Verth <jvanverth@google.com>
Diffstat (limited to 'gm/shadowutils.cpp')
-rw-r--r-- | gm/shadowutils.cpp | 32 |
1 files changed, 26 insertions, 6 deletions
diff --git a/gm/shadowutils.cpp b/gm/shadowutils.cpp index 9d9eaae405..17e2620164 100644 --- a/gm/shadowutils.cpp +++ b/gm/shadowutils.cpp @@ -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); +} |