diff --git a/src/gpu/GrDrawContext.cpp b/src/gpu/GrDrawContext.cpp
index 48ff636..5d77f85 100644
--- a/src/gpu/GrDrawContext.cpp
+++ b/src/gpu/GrDrawContext.cpp
@@ -19,6 +19,7 @@
 #include "GrStencilAndCoverTextContext.h"
 
 #include "batches/GrBatch.h"
+#include "batches/GrDrawAtlasBatch.h"
 #include "batches/GrStrokeRectBatch.h"
 
 #include "SkGr.h"
@@ -695,167 +696,6 @@
 
 ///////////////////////////////////////////////////////////////////////////////
 
-class DrawAtlasBatch : public GrBatch {
-public:
-    struct Geometry {
-        GrColor fColor;
-        SkTDArray<SkPoint> fPositions;
-        SkTDArray<GrColor> fColors;
-        SkTDArray<SkPoint> fLocalCoords;
-    };
-    
-    static GrBatch* Create(const Geometry& geometry, const SkMatrix& viewMatrix,
-                           const SkPoint* positions, int vertexCount,
-                           const GrColor* colors, const SkPoint* localCoords,
-                           const SkRect& bounds) {
-        return SkNEW_ARGS(DrawAtlasBatch, (geometry, viewMatrix, positions,
-                                           vertexCount, colors, localCoords, bounds));
-    }
-    
-    const char* name() const override { return "DrawAtlasBatch"; }
-    
-    void getInvariantOutputColor(GrInitInvariantOutput* out) const override {
-        // When this is called on a batch, there is only one geometry bundle
-        if (this->hasColors()) {
-            out->setUnknownFourComponents();
-        } else {
-            out->setKnownFourComponents(fGeoData[0].fColor);
-        }
-    }
-    
-    void getInvariantOutputCoverage(GrInitInvariantOutput* out) const override {
-        out->setKnownSingleComponent(0xff);
-    }
-    
-    void initBatchTracker(const GrPipelineInfo& init) override {
-        // Handle any color overrides
-        if (!init.readsColor()) {
-            fGeoData[0].fColor = GrColor_ILLEGAL;
-        }
-        init.getOverrideColorIfSet(&fGeoData[0].fColor);
-        
-        // setup batch properties
-        fColorIgnored = !init.readsColor();
-        fColor = fGeoData[0].fColor;
-        SkASSERT(init.readsLocalCoords());
-        fCoverageIgnored = !init.readsCoverage();
-    }
-    
-    void generateGeometry(GrBatchTarget* batchTarget) override {
-        int colorOffset = -1, texOffset = -1;
-        // Setup geometry processor
-        SkAutoTUnref<const GrGeometryProcessor> gp(
-                                set_vertex_attributes(true, this->hasColors(), &colorOffset,
-                                                      &texOffset, this->color(), this->viewMatrix(),
-                                                      this->coverageIgnored()));
-        
-        batchTarget->initDraw(gp, this->pipeline());
-        
-        int instanceCount = fGeoData.count();
-        size_t vertexStride = gp->getVertexStride();
-        SkASSERT(vertexStride == sizeof(SkPoint) + sizeof(SkPoint)
-                 + (this->hasColors() ? sizeof(GrColor) : 0));
-        
-        QuadHelper helper;
-        int numQuads = this->vertexCount()/4;
-        void* verts = helper.init(batchTarget, vertexStride, numQuads);
-        if (!verts) {
-            SkDebugf("Could not allocate vertices\n");
-            return;
-        }
-        
-        int vertexOffset = 0;
-        for (int i = 0; i < instanceCount; i++) {
-            const Geometry& args = fGeoData[i];
-            
-            for (int j = 0; j < args.fPositions.count(); ++j) {
-                *((SkPoint*)verts) = args.fPositions[j];
-                if (this->hasColors()) {
-                    *(GrColor*)((intptr_t)verts + colorOffset) = args.fColors[j];
-                }
-                *(SkPoint*)((intptr_t)verts + texOffset) = args.fLocalCoords[j];
-                verts = (void*)((intptr_t)verts + vertexStride);
-                vertexOffset++;
-            }
-        }
-        helper.issueDraw(batchTarget);
-    }
-    
-    SkSTArray<1, Geometry, true>* geoData() { return &fGeoData; }
-    
-private:
-    DrawAtlasBatch(const Geometry& geometry, const SkMatrix& viewMatrix,
-                   const SkPoint* positions, int vertexCount,
-                   const GrColor* colors, const SkPoint* localCoords, const SkRect& bounds) {
-        this->initClassID<DrawVerticesBatch>();
-        SkASSERT(positions);
-        SkASSERT(localCoords);
-        
-        fViewMatrix = viewMatrix;
-        Geometry& installedGeo = fGeoData.push_back(geometry);
-        
-        installedGeo.fPositions.append(vertexCount, positions);
-        
-        if (colors) {
-            installedGeo.fColors.append(vertexCount, colors);
-            fHasColors = true;
-        } else {
-            fHasColors = false;
-        }
-        
-        installedGeo.fLocalCoords.append(vertexCount, localCoords);
-        fVertexCount = vertexCount;
-        
-        this->setBounds(bounds);
-    }
-    
-    GrColor color() const { return fColor; }
-    bool colorIgnored() const { return fColorIgnored; }
-    const SkMatrix& viewMatrix() const { return fViewMatrix; }
-    bool hasColors() const { return fHasColors; }
-    int vertexCount() const { return fVertexCount; }
-    bool coverageIgnored() const { return fCoverageIgnored; }
-    
-    bool onCombineIfPossible(GrBatch* t) override {
-        if (!this->pipeline()->isEqual(*t->pipeline())) {
-            return false;
-        }
-        
-        DrawAtlasBatch* that = t->cast<DrawAtlasBatch>();
-        
-        // We currently use a uniform viewmatrix for this batch
-        if (!this->viewMatrix().cheapEqualTo(that->viewMatrix())) {
-            return false;
-        }
-        
-        if (this->hasColors() != that->hasColors()) {
-            return false;
-        }
-        
-        if (!this->hasColors() && this->color() != that->color()) {
-            return false;
-        }
-        
-        if (this->color() != that->color()) {
-            fColor = GrColor_ILLEGAL;
-        }
-        fGeoData.push_back_n(that->geoData()->count(), that->geoData()->begin());
-        fVertexCount += that->vertexCount();
-        
-        this->joinBounds(that->bounds());
-        return true;
-    }
-    
-    SkSTArray<1, Geometry, true> fGeoData;
-    
-    SkMatrix fViewMatrix;
-    GrColor  fColor;
-    int      fVertexCount;
-    bool     fColorIgnored;
-    bool     fCoverageIgnored;
-    bool     fHasColors;
-};
-
 void GrDrawContext::drawAtlas(GrRenderTarget* rt,
                               const GrClip& clip,
                               const GrPaint& paint,
@@ -925,10 +765,10 @@
     texs = verts + vertCount;
     vertCols = colorStorage.get();
     
-    DrawAtlasBatch::Geometry geometry;
+    GrDrawAtlasBatch::Geometry geometry;
     geometry.fColor = paint.getColor();
-    SkAutoTUnref<GrBatch> batch(DrawAtlasBatch::Create(geometry, viewMatrix, verts, vertCount,
-                                                       vertCols, texs, bounds));
+    SkAutoTUnref<GrBatch> batch(GrDrawAtlasBatch::Create(geometry, viewMatrix, verts, vertCount,
+                                                         vertCols, texs, bounds));
     
     fDrawTarget->drawBatch(pipelineBuilder, batch);
 }
