Remove SkDrawProcs

TBR=reed@google.com

Review URL: https://codereview.chromium.org/1476563002
diff --git a/include/core/SkDraw.h b/include/core/SkDraw.h
index c6e8bcd..b8cf802 100644
--- a/include/core/SkDraw.h
+++ b/include/core/SkDraw.h
@@ -147,7 +147,6 @@
 
     const SkClipStack* fClipStack;  // optional
     SkBaseDevice*   fDevice;        // optional
-    SkDrawProcs*    fProcs;         // optional
 
 #ifdef SK_DEBUG
     void validate() const;
diff --git a/src/core/SkDraw.cpp b/src/core/SkDraw.cpp
index ef073f8..e1a49d3 100644
--- a/src/core/SkDraw.cpp
+++ b/src/core/SkDraw.cpp
@@ -1423,8 +1423,48 @@
 #endif
 
 ////////////////////////////////////////////////////////////////////////////////////////////////////
+struct SkDraw1Glyph {
+    const SkDraw* fDraw;
+    const SkRegion* fClip;
+    const SkAAClip* fAAClip;
+    SkBlitter* fBlitter;
+    SkGlyphCache* fCache;
+    const SkPaint* fPaint;
+    SkIRect fClipBounds;
+    /** Half the sampling frequency of the rasterized glyph in x. */
+    SkScalar fHalfSampleX;
+    /** Half the sampling frequency of the rasterized glyph in y. */
+    SkScalar fHalfSampleY;
 
-static void D1G_RectClip(const SkDraw1Glyph& state, Sk48Dot16 fx, Sk48Dot16 fy, const SkGlyph& glyph) {
+    /** Draws one glyph.
+     *
+     *  The x and y are pre-biased, so implementations may just truncate them.
+     *  i.e. half the sampling frequency has been added.
+     *  e.g. 1/2 or 1/(2^(SkGlyph::kSubBits+1)) has already been added.
+     *  This added bias can be found in fHalfSampleX,Y.
+     */
+    typedef void (*Proc)(const SkDraw1Glyph&, Sk48Dot16 x, Sk48Dot16 y, const SkGlyph&);
+
+    Proc init(const SkDraw* draw, SkBlitter* blitter, SkGlyphCache* cache,
+              const SkPaint&);
+
+    // call this instead of fBlitter->blitMask() since this wrapper will handle
+    // the case when the mask is ARGB32_Format
+    //
+    void blitMask(const SkMask& mask, const SkIRect& clip) const {
+        if (SkMask::kARGB32_Format == mask.fFormat) {
+            this->blitMaskAsSprite(mask);
+        } else {
+            fBlitter->blitMask(mask, clip);
+        }
+    }
+
+    // mask must be kARGB32_Format
+    void blitMaskAsSprite(const SkMask& mask) const;
+};
+
+static void D1G_RectClip(const SkDraw1Glyph& state, Sk48Dot16 fx, Sk48Dot16 fy,
+                         const SkGlyph& glyph) {
     // Prevent glyphs from being drawn outside of or straddling the edge of device space.
     if ((fx >> 16) > INT_MAX - (INT16_MAX + UINT16_MAX) ||
         (fx >> 16) < INT_MIN - (INT16_MIN + 0 /*UINT16_MIN*/) ||
@@ -1474,7 +1514,8 @@
     state.blitMask(mask, *bounds);
 }
 
-static void D1G_RgnClip(const SkDraw1Glyph& state, Sk48Dot16 fx, Sk48Dot16 fy, const SkGlyph& glyph) {
+static void D1G_RgnClip(const SkDraw1Glyph& state, Sk48Dot16 fx, Sk48Dot16 fy,
+                        const SkGlyph& glyph) {
     int left = Sk48Dot16FloorToInt(fx);
     int top = Sk48Dot16FloorToInt(fy);
     SkASSERT(glyph.fWidth > 0 && glyph.fHeight > 0);
@@ -1505,14 +1546,6 @@
     }
 }
 
-static bool hasCustomD1GProc(const SkDraw& draw) {
-    return draw.fProcs && draw.fProcs->fD1GProc;
-}
-
-static bool needsRasterTextBlit(const SkDraw& draw) {
-    return !hasCustomD1GProc(draw);
-}
-
 SkDraw1Glyph::Proc SkDraw1Glyph::init(const SkDraw* draw, SkBlitter* blitter, SkGlyphCache* cache,
                                       const SkPaint& pnt) {
     fDraw = draw;
@@ -1526,13 +1559,6 @@
         fHalfSampleX = fHalfSampleY = SK_ScalarHalf;
     }
 
-    if (hasCustomD1GProc(*draw)) {
-        // todo: fix this assumption about clips w/ custom
-        fClip = draw->fClip;
-        fClipBounds = fClip->getBounds();
-        return draw->fProcs->fD1GProc;
-    }
-
     if (draw->fRC->isBW()) {
         fAAClip = nullptr;
         fClip = &draw->fRC->bwRgn();
@@ -1583,20 +1609,13 @@
     SkAutoGlyphCache    autoCache(paint, &fDevice->surfaceProps(), fMatrix);
     SkGlyphCache*       cache = autoCache.getCache();
 
-    SkAAClipBlitter     aaBlitter;
-    SkAutoBlitterChoose blitterChooser;
-    SkBlitter*          blitter = nullptr;
-    if (needsRasterTextBlit(*this)) {
-        blitterChooser.choose(fDst, *fMatrix, paint);
-        blitter = blitterChooser.get();
-        if (fRC->isAA()) {
-            aaBlitter.init(blitter, &fRC->aaRgn());
-            blitter = &aaBlitter;
-        }
-    }
+
+    // The Blitter Choose needs to be live while using the blitter below.
+    SkAutoBlitterChoose    blitterChooser(fDst, *fMatrix, paint);
+    SkAAClipBlitterWrapper wrapper(*fRC, blitterChooser.get());
 
     SkDraw1Glyph        d1g;
-    SkDraw1Glyph::Proc  proc = d1g.init(this, blitter, cache, paint);
+    SkDraw1Glyph::Proc  proc = d1g.init(this, wrapper.getBlitter(), cache, paint);
 
     SkFindAndPlaceGlyph::ProcessText(
         paint.getTextEncoding(), text, byteLength,
@@ -1678,22 +1697,13 @@
     }
 
     // The Blitter Choose needs to be live while using the blitter below.
-    SkAutoBlitterChoose    blitterChooser;
-    SkAAClipBlitterWrapper wrapper;
-    SkBlitter*             blitter = nullptr;
-    if (needsRasterTextBlit(*this)) {
-        blitterChooser.choose(fDst, *fMatrix, paint);
-        blitter = blitterChooser.get();
-        if (fRC->isAA()) {
-            wrapper.init(*fRC, blitter);
-            blitter = wrapper.getBlitter();
-        }
-    }
+    SkAutoBlitterChoose    blitterChooser(fDst, *fMatrix, paint);
+    SkAAClipBlitterWrapper wrapper(*fRC, blitterChooser.get());
 
     SkAutoGlyphCache   autoCache(paint, &fDevice->surfaceProps(), fMatrix);
     SkGlyphCache*      cache = autoCache.getCache();
     SkDraw1Glyph       d1g;
-    SkDraw1Glyph::Proc proc = d1g.init(this, blitter, cache, paint);
+    SkDraw1Glyph::Proc proc = d1g.init(this, wrapper.getBlitter(), cache, paint);
     SkPaint::Align     textAlignment = paint.getTextAlign();
 
     SkFindAndPlaceGlyph::ProcessPosText(
diff --git a/src/core/SkDrawProcs.h b/src/core/SkDrawProcs.h
index 0a18823..a861a0a 100644
--- a/src/core/SkDrawProcs.h
+++ b/src/core/SkDrawProcs.h
@@ -8,57 +8,9 @@
 #ifndef SkDrawProcs_DEFINED
 #define SkDrawProcs_DEFINED
 
-#include "SkBlitter.h"
 #include "SkDraw.h"
 #include "SkGlyph.h"
 
-class SkAAClip;
-class SkBlitter;
-
-struct SkDraw1Glyph {
-    const SkDraw* fDraw;
-    const SkRegion* fClip;
-    const SkAAClip* fAAClip;
-    SkBlitter* fBlitter;
-    SkGlyphCache* fCache;
-    const SkPaint* fPaint;
-    SkIRect fClipBounds;
-    /** Half the sampling frequency of the rasterized glyph in x. */
-    SkScalar fHalfSampleX;
-    /** Half the sampling frequency of the rasterized glyph in y. */
-    SkScalar fHalfSampleY;
-
-    /** Draws one glyph.
-     *
-     *  The x and y are pre-biased, so implementations may just truncate them.
-     *  i.e. half the sampling frequency has been added.
-     *  e.g. 1/2 or 1/(2^(SkGlyph::kSubBits+1)) has already been added.
-     *  This added bias can be found in fHalfSampleX,Y.
-     */
-    typedef void (*Proc)(const SkDraw1Glyph&, Sk48Dot16 x, Sk48Dot16 y, const SkGlyph&);
-
-    Proc init(const SkDraw* draw, SkBlitter* blitter, SkGlyphCache* cache,
-              const SkPaint&);
-
-    // call this instead of fBlitter->blitMask() since this wrapper will handle
-    // the case when the mask is ARGB32_Format
-    //
-    void blitMask(const SkMask& mask, const SkIRect& clip) const {
-        if (SkMask::kARGB32_Format == mask.fFormat) {
-            this->blitMaskAsSprite(mask);
-        } else {
-            fBlitter->blitMask(mask, clip);
-        }
-    }
-
-    // mask must be kARGB32_Format
-    void blitMaskAsSprite(const SkMask& mask) const;
-};
-
-struct SkDrawProcs {
-    SkDraw1Glyph::Proc  fD1GProc;
-};
-
 bool SkDrawTreatAAStrokeAsHairline(SkScalar strokeWidth, const SkMatrix&,
                                    SkScalar* coverage);
 
diff --git a/src/device/xps/SkXPSDevice.cpp b/src/device/xps/SkXPSDevice.cpp
index f971598..86c729c 100644
--- a/src/device/xps/SkXPSDevice.cpp
+++ b/src/device/xps/SkXPSDevice.cpp
@@ -23,7 +23,6 @@
 #include "SkConstexprMath.h"
 #include "SkData.h"
 #include "SkDraw.h"
-#include "SkDrawProcs.h"
 #include "SkEndian.h"
 #include "SkFindAndPlaceGlyph.h"
 #include "SkGeometry.h"
diff --git a/src/gpu/SkGpuDevice.cpp b/src/gpu/SkGpuDevice.cpp
index 803f8a0..929b57c 100644
--- a/src/gpu/SkGpuDevice.cpp
+++ b/src/gpu/SkGpuDevice.cpp
@@ -9,6 +9,7 @@
 
 #include "GrBlurUtils.h"
 #include "GrContext.h"
+#include "SkDraw.h"
 #include "GrDrawContext.h"
 #include "GrFontScaler.h"
 #include "GrGpu.h"
@@ -20,7 +21,6 @@
 #include "GrTextContext.h"
 #include "GrTracing.h"
 #include "SkCanvasPriv.h"
-#include "SkDrawProcs.h"
 #include "SkErrorInternals.h"
 #include "SkGlyphCache.h"
 #include "SkGrTexturePixelRef.h"
@@ -113,15 +113,6 @@
 
 ///////////////////////////////////////////////////////////////////////////////
 
-struct GrSkDrawProcs : public SkDrawProcs {
-public:
-    GrContext* fContext;
-    GrTextContext* fTextContext;
-    GrFontScaler* fFontScaler;  // cached in the skia glyphcache
-};
-
-///////////////////////////////////////////////////////////////////////////////
-
 /** Checks that the alpha type is legal and gets constructor flags. Returns false if device creation
     should fail. */
 bool SkGpuDevice::CheckAlphaTypeAndGetFlags(
@@ -181,8 +172,6 @@
                          const SkSurfaceProps* props, unsigned flags)
     : INHERITED(SkSurfacePropsCopyOrDefault(props))
 {
-    fDrawProcs = nullptr;
-
     fContext = SkRef(rt->getContext());
     fNeedClear = SkToBool(flags & kNeedClear_Flag);
     fOpaque = SkToBool(flags & kIsOpaque_Flag);
@@ -238,10 +227,6 @@
 }
 
 SkGpuDevice::~SkGpuDevice() {
-    if (fDrawProcs) {
-        delete fDrawProcs;
-    }
-
     fRenderTarget->unref();
     fContext->unref();
 }
@@ -404,9 +389,9 @@
     if (count == 2) {
         // We do not antialias as long as the primary axis of the line is integer-aligned, even if
         // the other coordinates are not. This does mean the two end pixels of the line will be
-        // sharp even when they shouldn't be, but turning antialiasing on (as things stand 
+        // sharp even when they shouldn't be, but turning antialiasing on (as things stand
         // currently) means that the line will turn into a two-pixel-wide blur. While obviously a
-        // more complete fix is possible down the road, for the time being we accept the error on 
+        // more complete fix is possible down the road, for the time being we accept the error on
         // the two end pixels as being the lesser of two evils.
         if (pts[0].fX == pts[1].fX) {
             return ((int) pts[0].fX) != pts[0].fX;
@@ -444,7 +429,7 @@
 
     // we only handle non-antialiased hairlines and paints without path effects or mask filters,
     // else we let the SkDraw call our drawPath()
-    if (width > 0 || paint.getPathEffect() || paint.getMaskFilter() || 
+    if (width > 0 || paint.getPathEffect() || paint.getMaskFilter() ||
         (paint.isAntiAlias() && needs_antialiasing(mode, count, pts))) {
         draw.drawPoints(mode, count, pts, paint, true);
         return;
@@ -625,8 +610,8 @@
         path.addOval(oval);
         this->drawPath(draw, path, paint, nullptr, true);
         return;
-    } 
-    
+    }
+
     if (paint.getMaskFilter()) {
         // The RRect path can handle special case blurring
         SkRRect rr = SkRRect::MakeOval(oval);
@@ -1688,7 +1673,7 @@
 
     CHECK_SHOULD_DRAW(draw);
     GR_CREATE_TRACE_MARKER_CONTEXT("SkGpuDevice::drawText", fContext);
-    
+
     SkPaint p(paint);
     p.setShader(atlas->newShader(SkShader::kClamp_TileMode, SkShader::kClamp_TileMode))->unref();
 
diff --git a/src/gpu/SkGpuDevice.h b/src/gpu/SkGpuDevice.h
index 1408a71..5bf074d 100644
--- a/src/gpu/SkGpuDevice.h
+++ b/src/gpu/SkGpuDevice.h
@@ -18,9 +18,6 @@
 #include "GrContext.h"
 #include "GrSurfacePriv.h"
 
-struct SkDrawProcs;
-struct GrSkDrawProcs;
-
 class GrAccelData;
 class GrTextureProducer;
 struct GrCachedLayer;
@@ -154,7 +151,6 @@
 
 private:
     GrContext*                      fContext;
-    GrSkDrawProcs*                  fDrawProcs;
     SkAutoTUnref<const SkClipStack> fClipStack;
     SkIPoint                        fClipOrigin;
     GrClip                          fClip;