Revert of Add GM/slide to simulate Android-style reveal clip (patchset #6 id:100001...
authorrobertphillips <robertphillips@google.com>
Wed, 7 Sep 2016 18:34:05 +0000 (11:34 -0700)
committerCommit bot <commit-bot@chromium.org>
Wed, 7 Sep 2016 18:34:05 +0000 (11:34 -0700)
Reason for revert:
Shader compilation failure

Original issue's description:
> Add GM/slide to simulate Android-style reveal clip
>
> Hopefully, this will let us play w/ geometric and shader-based solutions.
>
> GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2316593003
>
> Committed: https://skia.googlesource.com/skia/+/ffac5c4aae18fc706e4077763c190a89c8507fb0

TBR=jvanverth@google.com,djsollen@google.com
# Skipping CQ checks because original CL landed less than 1 days ago.
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true

Review-Url: https://codereview.chromium.org/2316303002

gm/reveal.cpp [deleted file]
include/effects/SkGaussianEdgeShader.h
src/effects/SkGaussianEdgeShader.cpp
src/ports/SkGlobalInitialization_default.cpp

diff --git a/gm/reveal.cpp b/gm/reveal.cpp
deleted file mode 100644 (file)
index 2fbc819..0000000
+++ /dev/null
@@ -1,310 +0,0 @@
-/*
- * Copyright 2016 Google Inc.
- *
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#include "gm.h"
-#include "SkAnimTimer.h"
-#include "SkGaussianEdgeShader.h"
-#include "SkPath.h"
-#include "SkPathOps.h"
-#include "SkRRect.h"
-#include "SkStroke.h"
-
-constexpr int kNumCols = 2;
-constexpr int kNumRows = 5;
-constexpr int kCellSize = 128;
-constexpr SkScalar kPad = 8.0f;
-constexpr SkScalar kPeriod = 8.0f;
-constexpr int kClipOffset = 32;
-
-///////////////////////////////////////////////////////////////////////////////////////////////////
-typedef SkPath (*PFDrawMthd)(SkCanvas*, const SkRect&, bool);
-
-static SkPath draw_rrect(SkCanvas* canvas, const SkRect& r, bool stroked) {
-    SkRRect rr = SkRRect::MakeRectXY(r, 2*kPad, 2*kPad);
-
-    SkPaint paint;
-    paint.setAntiAlias(true);
-    if (stroked) {
-        paint.setStyle(SkPaint::kStroke_Style);
-        paint.setColor(SK_ColorRED);
-    } else {
-        // G channel is an F6.2 radius
-        paint.setColor(SkColorSetARGB(255, 255, (unsigned char)(4*kPad), 0));
-        paint.setShader(SkGaussianEdgeShader::Make());
-    }
-    canvas->drawRRect(rr, paint);
-
-    SkPath p;
-    p.addRoundRect(r, 2*kPad, 2*kPad);
-    return p;
-}
-
-static SkPath draw_stroked_rrect(SkCanvas* canvas, const SkRect& r, bool stroked) {
-    SkRect insetRect = r;
-    insetRect.inset(kPad, kPad);
-    SkRRect rr = SkRRect::MakeRectXY(insetRect, 2*kPad, 2*kPad);
-
-    SkPaint paint;
-    paint.setAntiAlias(true);
-    paint.setStyle(SkPaint::kStroke_Style);
-    paint.setStrokeWidth(kPad);
-
-    if (stroked) {
-        // In this case we want to draw a stroked representation of the stroked rrect
-        SkPath p, stroked;
-        p.addRRect(rr);
-        SkStroke stroke(paint);
-        stroke.strokePath(p, &stroked);
-
-        paint.setStrokeWidth(0);
-        paint.setColor(SK_ColorRED);
-        canvas->drawPath(stroked, paint);
-    } else {
-        // G channel is an F6.2 radius
-        paint.setColor(SkColorSetARGB(255, 255, (unsigned char)(4*kPad), 0));
-        paint.setShader(SkGaussianEdgeShader::Make());
-
-        canvas->drawRRect(rr, paint);
-    }
-
-    SkPath p;
-    insetRect.outset(kPad/2.0f, kPad/2.0f);
-    p.addRoundRect(insetRect, 2*kPad, 2*kPad);
-    return p;
-}
-
-static SkPath draw_oval(SkCanvas* canvas, const SkRect& r, bool stroked) {
-    SkRRect rr = SkRRect::MakeOval(r);
-
-    SkPaint paint;
-    paint.setAntiAlias(true);
-    if (stroked) {
-        paint.setStyle(SkPaint::kStroke_Style);
-        paint.setColor(SK_ColorRED);
-    } else {
-        // G channel is an F6.2 radius
-        paint.setColor(SkColorSetARGB(255, 255, (unsigned char)(4*kPad), 0));
-        paint.setShader(SkGaussianEdgeShader::Make());
-    }
-    canvas->drawRRect(rr, paint);
-
-    SkPath p;
-    p.addOval(r);
-    return p;
-}
-
-static SkPath draw_square(SkCanvas* canvas, const SkRect& r, bool stroked) {
-    SkPaint paint;
-    paint.setAntiAlias(true);
-    if (stroked) {
-        paint.setStyle(SkPaint::kStroke_Style);
-        paint.setColor(SK_ColorRED);
-    } else {
-        // G channel is an F6.2 radius
-        paint.setColor(SkColorSetARGB(255, 255, (unsigned char)(4*kPad), 0));
-        paint.setShader(SkGaussianEdgeShader::Make());
-    }
-    canvas->drawRect(r, paint);
-
-    SkPath p;
-    p.addRect(r);
-    return p;
-}
-
-static SkPath draw_pentagon(SkCanvas* canvas, const SkRect& r, bool stroked) {
-    SkPath p;
-
-    SkPoint points[5] = {
-        {  0.000000f, -1.000000f },
-        { -0.951056f, -0.309017f },
-        { -0.587785f,  0.809017f },
-        {  0.587785f,  0.809017f },
-        {  0.951057f, -0.309017f },
-    };
-
-    SkScalar height = r.height()/2.0f;
-    SkScalar width = r.width()/2.0f;
-
-    p.moveTo(r.centerX() + points[0].fX * width, r.centerY() + points[0].fY * height);
-    p.lineTo(r.centerX() + points[1].fX * width, r.centerY() + points[1].fY * height);
-    p.lineTo(r.centerX() + points[2].fX * width, r.centerY() + points[2].fY * height);
-    p.lineTo(r.centerX() + points[3].fX * width, r.centerY() + points[3].fY * height);
-    p.lineTo(r.centerX() + points[4].fX * width, r.centerY() + points[4].fY * height);
-    p.close();
-
-    SkPaint paint;
-    paint.setAntiAlias(true);
-    if (stroked) {
-        paint.setStyle(SkPaint::kStroke_Style);
-        paint.setColor(SK_ColorRED);
-    } else {
-        // G channel is an F6.2 radius
-        paint.setColor(SkColorSetARGB(255, 255, (unsigned char)(4*kPad), 0));
-        // This currently goes through the GrAAConvexPathRenderer and produces a
-        // AAConvexPathBatch (i.e., it doesn't have a analytic distance)
-        // paint.setShader(SkGaussianEdgeShader::Make());
-    }
-    canvas->drawPath(p, paint);
-
-    return p;
-}
-
-///////////////////////////////////////////////////////////////////////////////////////////////////
-typedef void (*PFClipMthd)(SkCanvas* canvas, const SkPoint&, SkScalar);
-
-static void circle_clip(SkCanvas* canvas, const SkPoint& center, SkScalar rad) {
-    SkRect r = SkRect::MakeLTRB(center.fX - rad, center.fY - rad, center.fX + rad, center.fY + rad);
-    SkRRect rr = SkRRect::MakeOval(r);
-
-    canvas->clipRRect(rr);
-}
-
-static void square_clip(SkCanvas* canvas, const SkPoint& center, SkScalar size) {
-    SkScalar newSize = SK_ScalarRoot2Over2 * size;
-    SkRect r = SkRect::MakeLTRB(center.fX - newSize, center.fY - newSize,
-                                center.fX + newSize, center.fY + newSize);
-
-    canvas->clipRect(r);
-}
-
-///////////////////////////////////////////////////////////////////////////////////////////////////
-// These are stand alone methods (rather than just, say, returning the SkPath for the clip 
-// object) so that we can catch the clip-contains-victim case.
-typedef SkPath (*PFGeometricClipMthd)(const SkPoint&, SkScalar, const SkPath&);
-
-static SkPath circle_geometric_clip(const SkPoint& center, SkScalar rad, const SkPath& victim) {
-    const SkRect bound = victim.getBounds();
-    SkPoint pts[4];
-    bound.toQuad(pts);
-
-    bool clipContainsVictim = true;
-    for (int i = 0; i < 4; ++i) {
-        SkScalar distSq = (pts[i].fX - center.fX) * (pts[i].fX - center.fX) +
-                          (pts[i].fY - center.fY) * (pts[i].fY - center.fY);
-        if (distSq >= rad*rad) {
-            clipContainsVictim = false;
-        }
-    }
-
-    if (clipContainsVictim) {
-        return victim;
-    }
-
-    // Add victim contains clip test?
-
-    SkPath clipPath;
-    clipPath.addCircle(center.fX, center.fY, rad);
-
-    SkPath result;
-    SkAssertResult(Op(clipPath, victim, kIntersect_SkPathOp, &result));
-
-    return result;
-}
-
-static SkPath square_geometric_clip(const SkPoint& center, SkScalar size, const SkPath& victim) {
-    SkScalar newSize = SK_ScalarRoot2Over2 * size;
-    SkRect r = SkRect::MakeLTRB(center.fX - newSize, center.fY - newSize,
-                                center.fX + newSize, center.fY + newSize);
-
-    const SkRect bound = victim.getBounds();
-
-    if (r.contains(bound)) {
-        return victim;
-    }
-
-    // Add victim contains clip test?
-
-    SkPath clipPath;
-    clipPath.addRect(r);
-
-    SkPath result;
-    SkAssertResult(Op(clipPath, victim, kIntersect_SkPathOp, &result));
-
-    return result;
-}
-
-///////////////////////////////////////////////////////////////////////////////////////////////////
-namespace skiagm {
-
-// This GM attempts to mimic Android's reveal animation
-class RevealGM : public GM {
-public:
-    RevealGM() : fFraction(0.5f) {
-        this->setBGColor(sk_tool_utils::color_to_565(0xFFCCCCCC));
-    }
-
-protected:
-
-    SkString onShortName() override {
-        return SkString("reveal");
-    }
-
-    SkISize onISize() override {
-        return SkISize::Make(kNumCols * kCellSize, kNumRows * kCellSize);
-    }
-
-    void onDraw(SkCanvas* canvas) override {
-        PFClipMthd clips[kNumCols] = { circle_clip, square_clip };
-        PFGeometricClipMthd geometricClips[kNumCols] = {
-            circle_geometric_clip, 
-            square_geometric_clip
-        };
-        PFDrawMthd draws[kNumRows] = {
-            draw_rrect,
-            draw_stroked_rrect,
-            draw_oval,
-            draw_square,
-            draw_pentagon
-        };
-
-        SkPaint strokePaint;
-        strokePaint.setColor(SK_ColorGREEN);
-        strokePaint.setStyle(SkPaint::kStroke_Style);
-        strokePaint.setStrokeWidth(0.0f);
-
-        for (int y = 0; y < kNumRows; ++y) {
-            for (int x = 0; x < kNumCols; ++x) {
-                SkRect cell = SkRect::MakeXYWH(SkIntToScalar(x*kCellSize),
-                                               SkIntToScalar(y*kCellSize),
-                                               SkIntToScalar(kCellSize),
-                                               SkIntToScalar(kCellSize));
-
-                cell.inset(kPad, kPad);
-                SkPoint clipCenter = SkPoint::Make(cell.centerX() - kClipOffset,
-                                                   cell.centerY() + kClipOffset);
-
-                SkScalar curSize = kCellSize * fFraction;
-
-                // The goal is to replace this clipped draw (which clips the 
-                // shadow) with a draw using the geometric clip
-                canvas->save();
-                      (*clips[x])(canvas, clipCenter, curSize);
-                      (*draws[y])(canvas, cell, false);
-                canvas->restore();
-
-                SkPath drawnPath = (*draws[y])(canvas, cell, true);
-                SkPath clippedPath = (*geometricClips[x])(clipCenter, curSize, drawnPath);
-                canvas->drawPath(clippedPath, strokePaint);
-            }
-        }
-    }
-
-    bool onAnimate(const SkAnimTimer& timer) override {
-        fFraction = timer.pingPong(kPeriod, 0.0f, 0.0f, 1.0f);
-        return true;
-    }
-
-private:
-    SkScalar fFraction;
-
-    typedef GM INHERITED;
-};
-
-//////////////////////////////////////////////////////////////////////////////
-
-DEF_GM(return new RevealGM;)
-}
index ef54ece..59a2889 100644 (file)
@@ -19,9 +19,6 @@ public:
     static sk_sp<SkShader> Make();
 
     SK_DECLARE_FLATTENABLE_REGISTRAR_GROUP()
-
-private:
-    SkGaussianEdgeShader(); // can't be instantiated
 };
 
 #endif
index efcfbbf..d73bfad 100644 (file)
@@ -133,6 +133,7 @@ sk_sp<SkFlattenable> SkGaussianEdgeShaderImpl::CreateProc(SkReadBuffer& buf) {
 }
 
 void SkGaussianEdgeShaderImpl::flatten(SkWriteBuffer& buf) const {
+    this->INHERITED::flatten(buf);
 }
 
 ///////////////////////////////////////////////////////////////////////////////
index 1f19736..fdafd96 100644 (file)
@@ -24,7 +24,6 @@
 #include "SkDisplacementMapEffect.h"
 #include "SkDropShadowImageFilter.h"
 #include "SkEmbossMaskFilter.h"
-#include "SkGaussianEdgeShader.h"
 #include "SkGradientShader.h"
 #include "SkImageSource.h"
 #include "SkLayerDrawLooper.h"
@@ -90,7 +89,7 @@ void SkFlattenable::PrivateInitializer::InitEffects() {
     SkGradientShader::InitializeFlattenables();
     SkLightingShader::InitializeFlattenables();
     SkNormalSource::InitializeFlattenables();
-    SkGaussianEdgeShader::InitializeFlattenables();
+
 
     // PathEffect
     SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkArcToPathEffect)