use SkPath for GrPath, removing GrPathIter entirely

http://codereview.appspot.com/4515071/



git-svn-id: http://skia.googlecode.com/svn/trunk@1335 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/gpu/include/GrClipIterator.h b/gpu/include/GrClipIterator.h
index 1fcbdd1..f7f74a7 100644
--- a/gpu/include/GrClipIterator.h
+++ b/gpu/include/GrClipIterator.h
@@ -47,7 +47,7 @@
      * Return the current path. It is an error to call this when isDone() is
      * true or when getType() is kRect_Type.
      */
-    virtual GrPathIter* getPathIter() = 0;
+    virtual const GrPath* getPath() = 0;
 
     /**
      * Return the fill rule for the path. It is an error to call this when
diff --git a/gpu/include/GrContext.h b/gpu/include/GrContext.h
index 951c0e6..c29526a 100644
--- a/gpu/include/GrContext.h
+++ b/gpu/include/GrContext.h
@@ -25,7 +25,6 @@
 class GrFontCache;
 class GrGpu;
 struct GrGpuStats;
-class GrPathIter;
 class GrVertexBufferAllocPool;
 class GrIndexBufferAllocPool;
 class GrInOrderDrawBuffer;
@@ -323,22 +322,14 @@
      * Draws a path.
      *
      * @param paint         describes how to color pixels.
-     * @param pathIter      the path to draw
+     * @param path          the path to draw
      * @param fill          the path filling rule to use.
      * @param translate     optional additional translation applied to the
      *                      path.
      */
-    void drawPath(const GrPaint& paint,
-                  GrPathIter* pathIter,
-                  GrPathFill fill,
+    void drawPath(const GrPaint& paint, const GrPath& path, GrPathFill fill,
                   const GrPoint* translate = NULL);
-    /**
-     * Helper version of drawPath that takes a GrPath
-     */
-    void drawPath(const GrPaint& paint,
-                  const GrPath& path,
-                  GrPathFill fill,
-                  const GrPoint* translate = NULL);
+
     /**
      * Draws vertices with a paint.
      *
@@ -585,9 +576,7 @@
 
     void drawClipIntoStencil();
 
-    GrPathRenderer* getPathRenderer(const GrDrawTarget* target,
-                                    GrPathIter* path,
-                                    GrPathFill fill);
+    GrPathRenderer* getPathRenderer(const GrDrawTarget*, const GrPath&, GrPathFill);
 
     struct OffscreenRecord;
     // we currently only expose stage 0 through the paint so use stage 1. We
diff --git a/gpu/include/GrFontScaler.h b/gpu/include/GrFontScaler.h
index 77730d7..ab73ea4 100644
--- a/gpu/include/GrFontScaler.h
+++ b/gpu/include/GrFontScaler.h
@@ -21,7 +21,7 @@
 #include "GrGlyph.h"
 #include "GrKey.h"
 
-class GrPath;
+class SkPath;
 
 /**
  *  This is a virtual base class which Gr's interface to the host platform's
@@ -37,7 +37,7 @@
     virtual bool getPackedGlyphBounds(GrGlyph::PackedID, GrIRect* bounds) = 0;
     virtual bool getPackedGlyphImage(GrGlyph::PackedID, int width, int height,
                                      int rowBytes, void* image) = 0;
-    virtual bool getGlyphPath(uint16_t glyphID, GrPath*) = 0;
+    virtual bool getGlyphPath(uint16_t glyphID, SkPath*) = 0;
 };
 
 #endif
diff --git a/gpu/include/GrGpu.h b/gpu/include/GrGpu.h
index e44956f..1bb5c54 100644
--- a/gpu/include/GrGpu.h
+++ b/gpu/include/GrGpu.h
@@ -513,8 +513,7 @@
     void prepareIndexPool();
 
     // determines the path renderer used to draw a clip path element.
-    GrPathRenderer* getClipPathRenderer(GrPathIter* path,
-                                        GrPathFill fill);
+    GrPathRenderer* getClipPathRenderer(const SkPath& path, GrPathFill fill);
 
     void handleDirtyContext() {
         if (fContextIsDirty) {
diff --git a/gpu/include/GrPath.h b/gpu/include/GrPath.h
index f958329..c23cfc4 100644
--- a/gpu/include/GrPath.h
+++ b/gpu/include/GrPath.h
@@ -18,91 +18,10 @@
 #ifndef GrPath_DEFINED
 #define GrPath_DEFINED
 
-#include "GrPathSink.h"
-#include "GrPathIter.h"
-#include "GrTDArray.h"
-#include "GrPoint.h"
-#include "GrRect.h"
+#include "GrTypes.h"
+#include "SkPath.h"
 
-class GrPath : public GrPathSink {
-public:
-    GrPath();
-    GrPath(const GrPath&);
-    explicit GrPath(GrPathIter&);
-    virtual ~GrPath();
-
-    GrConvexHint getConvexHint() const { return fConvexHint; }
-    void setConvexHint(GrConvexHint hint) { fConvexHint = hint; }
-
-    const GrRect& getConservativeBounds() const { return fConservativeBounds; }
-
-    void resetFromIter(GrPathIter*);
-
-    bool operator ==(const GrPath& path) const;
-    bool operator !=(const GrPath& path) const { return !(*this == path); }
-    // overrides from GrPathSink
-
-    virtual void moveTo(GrScalar x, GrScalar y);
-    virtual void lineTo(GrScalar x, GrScalar y);
-    virtual void quadTo(GrScalar x0, GrScalar y0, GrScalar x1, GrScalar y1);
-    virtual void cubicTo(GrScalar x0, GrScalar y0, GrScalar x1, GrScalar y1,
-                         GrScalar x2, GrScalar y2);
-    virtual void close();
-
-    /**
-     *  Offset the path by (tx, ty), adding tx to the horizontal position
-     *  and adds ty to the vertical position of every point.
-     */
-    void offset(GrScalar tx, GrScalar ty);
-
-    class Iter : public GrPathIter {
-    public:
-        /**
-         * Creates an uninitialized iterator
-         */
-        Iter();
-
-        Iter(const GrPath& path);
-
-        // overrides from GrPathIter
-        virtual GrPathCmd next(GrPoint points[]);
-        virtual GrConvexHint convexHint() const;
-        virtual GrPathCmd next();
-        virtual void rewind();
-        virtual bool getConservativeBounds(GrRect* rect) const;
-
-        /**
-         * Sets iterator to begining of path
-         */
-        void reset(const GrPath& path);
-    private:
-        const GrPath* fPath;
-        GrPoint       fLastPt;
-        int           fCmdIndex;
-        int           fPtIndex;
-    };
-
-    static void ConvexUnitTest();
-
-private:
-
-    GrTDArray<GrPathCmd>    fCmds;
-    GrTDArray<GrPoint>      fPts;
-    GrConvexHint            fConvexHint;
-    GrRect                  fConservativeBounds;
-
-    // this ensures we have a moveTo at the start of each contour
-    inline void ensureMoveTo();
-
-    bool wasLastVerb(GrPathCmd cmd) const {
-        int count = fCmds.count();
-        return count > 0 && cmd == fCmds[count - 1];
-    }
-
-    friend class Iter;
-
-    typedef GrPathSink INHERITED;
-};
+typedef SkPath GrPath;
 
 #endif
 
diff --git a/gpu/include/GrPathIter.h b/gpu/include/GrPathIter.h
deleted file mode 100644
index e67ff69..0000000
--- a/gpu/include/GrPathIter.h
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
-    Copyright 2010 Google Inc.
-
-    Licensed under the Apache License, Version 2.0 (the "License");
-    you may not use this file except in compliance with the License.
-    You may obtain a copy of the License at
-
-         http://www.apache.org/licenses/LICENSE-2.0
-
-    Unless required by applicable law or agreed to in writing, software
-    distributed under the License is distributed on an "AS IS" BASIS,
-    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-    See the License for the specific language governing permissions and
-    limitations under the License.
- */
-
-
-#ifndef GrPathIter_DEFINED
-#define GrPathIter_DEFINED
-
-#include "GrRect.h"
-
-/**
- 2D Path iterator. Porting layer creates a subclass of this. It allows Ganesh to
- parse the top-level API's 2D paths. Supports lines, quadratics, and cubic
- pieces and moves (multi-part paths).
- */
-class GrPathIter {
-public:
-
-    virtual ~GrPathIter() {};
-
-    /**
-     * Iterates through the path. Should not be called after
-     * kEnd_Command has been returned once. This version retrieves the
-     * points for the command.
-     * @param points  The points relevant to returned commend. See Command
-     *               enum for number of points valid for each command.
-     * @return The next command of the path.
-     */
-    virtual GrPathCmd next(GrPoint points[4]) = 0;
-
-    /**
-     * If the host API has knowledge of the convexity of the path
-     * it can be communicated by this hint. Gr can analyze the path
-     * as it is iterated. So it is not necessary to do additional work to
-     * compute convexity status if it isn't already determined.
-     *
-     * @return a hint about the convexity of the path.
-     */
-    virtual GrConvexHint convexHint() const = 0;
-
-     /**
-      * Iterates through the path. Should not be called after
-      * kEnd_Command has been returned once. This version does not retrieve the
-      * points for the command.
-      * @return The next command of the path.
-      */
-     virtual GrPathCmd next() = 0;
-
-     /**
-      * Returns conservative bounds on the path points. If returns false then
-      * no bounds are available.
-      */
-     virtual bool getConservativeBounds(GrRect* rect) const = 0;
-
-    /**
-     Restarts iteration from the beginning.
-     */
-    virtual void rewind() = 0;
-
-};
-
-#endif
diff --git a/gpu/include/GrPathRenderer.h b/gpu/include/GrPathRenderer.h
index 21cab6b..1ebad4f 100644
--- a/gpu/include/GrPathRenderer.h
+++ b/gpu/include/GrPathRenderer.h
@@ -19,7 +19,7 @@
 
 #include "GrDrawTarget.h"
 
-class GrPathIter;
+class SkPath;
 struct GrPoint;
 
 /**
@@ -37,8 +37,7 @@
      *
      * @return  true if the path can be drawn by this object, false otherwise.
      */
-    virtual bool canDrawPath(const GrDrawTarget* target,
-                             GrPathIter* path,
+    virtual bool canDrawPath(const GrDrawTarget* target, const SkPath& path,
                              GrPathFill fill) const = 0;
 
     /**
@@ -57,7 +56,7 @@
      */
     virtual void drawPath(GrDrawTarget* target,
                           GrDrawTarget::StageBitfield stages,
-                          GrPathIter* path,
+                          const SkPath& path,
                           GrPathFill fill,
                           const GrPoint* translate) = 0;
 
@@ -80,7 +79,7 @@
      *         clips.
      */
     virtual bool requiresStencilPass(const GrDrawTarget* target,
-                                     GrPathIter* path,
+                                     const SkPath& path,
                                      GrPathFill fill) const { return false; }
 
     /**
@@ -102,7 +101,7 @@
      *                              the path. NULL means (0,0).
      */
     virtual void drawPathToStencil(GrDrawTarget* target,
-                                   GrPathIter* path,
+                                   const SkPath& path,
                                    GrPathFill fill,
                                    const GrPoint* translate) {
         GrCrash("Unexpected call to drawPathToStencil.");
@@ -113,7 +112,7 @@
      * having FSAA enabled for a render target)
      */
     virtual bool supportsAA(GrDrawTarget* target,
-                            GrPathIter* path,
+                            const SkPath& path,
                             GrPathFill fill) { return false; }
 
     /**
@@ -138,26 +137,26 @@
                           bool stencilWrapOpsSupport);
 
     virtual bool canDrawPath(const GrDrawTarget* target,
-                             GrPathIter* path,
+                             const SkPath& path,
                              GrPathFill fill) const { return true; }
 
     virtual void drawPath(GrDrawTarget* target,
                           GrDrawTarget::StageBitfield stages,
-                          GrPathIter* path,
+                          const SkPath& path,
                           GrPathFill fill,
                           const GrPoint* translate);
     virtual bool requiresStencilPass(const GrDrawTarget* target,
-                                     GrPathIter* path,
+                                     const SkPath& path,
                                      GrPathFill fill) const;
     virtual void drawPathToStencil(GrDrawTarget* target,
-                                   GrPathIter* path,
+                                   const SkPath& path,
                                    GrPathFill fill,
                                    const GrPoint* translate);
 private:
 
     void onDrawPath(GrDrawTarget* target,
                     GrDrawTarget::StageBitfield stages,
-                    GrPathIter* path,
+                    const SkPath& path,
                     GrPathFill fill,
                     const GrPoint* translate,
                     bool stencilOnly);
diff --git a/gpu/include/GrTesselatedPathRenderer.h b/gpu/include/GrTesselatedPathRenderer.h
index accd114..e37e66b 100644
--- a/gpu/include/GrTesselatedPathRenderer.h
+++ b/gpu/include/GrTesselatedPathRenderer.h
@@ -25,22 +25,22 @@
 
     virtual void drawPath(GrDrawTarget* target,
                           GrDrawTarget::StageBitfield stages,
-                          GrPathIter* path,
+                          const GrPath& path,
                           GrPathFill fill,
                           const GrPoint* translate);
     virtual bool canDrawPath(const GrDrawTarget* target,
-                             GrPathIter* path,
+                             const GrPath& path,
                              GrPathFill fill) const;
 
     virtual bool requiresStencilPass(const GrDrawTarget* target,
-                                     GrPathIter* path,
+                                     const GrPath& path,
                                      GrPathFill fill) const { return false; }
     virtual void drawPathToStencil(GrDrawTarget* target,
-                                   GrPathIter* path,
+                                   const GrPath& path,
                                    GrPathFill fill,
                                    const GrPoint* translate);
     virtual bool supportsAA(GrDrawTarget* target,
-                            GrPathIter* path,
+                            const GrPath& path,
                             GrPathFill fill);
 };