diff --git a/src/utils/SkCanvasStack.cpp b/src/utils/SkCanvasStack.cpp
new file mode 100644
index 0000000..db5a8b2
--- /dev/null
+++ b/src/utils/SkCanvasStack.cpp
@@ -0,0 +1,108 @@
+
+/*
+ * Copyright 2013 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+#include "SkCanvasStack.h"
+
+SkCanvasStack::SkCanvasStack(int width, int height)
+        : INHERITED(width, height) {}
+
+SkCanvasStack::~SkCanvasStack() {
+    this->removeAll();
+}
+
+void SkCanvasStack::pushCanvas(SkCanvas* canvas, const SkIPoint& origin) {
+    if (canvas) {
+        // compute the bounds of this canvas
+        const SkIRect canvasBounds = SkIRect::MakeSize(canvas->getDeviceSize());
+
+        // push the canvas onto the stack
+        this->INHERITED::addCanvas(canvas);
+
+        // push the canvas data onto the stack
+        CanvasData* data = &fCanvasData.push_back();
+        data->origin = origin;
+        data->requiredClip.setRect(canvasBounds);
+
+        // subtract this region from the canvas objects already on the stack.
+        // This ensures they do not draw into the space occupied by the layers
+        // above them.
+        for (int i = fList.count() - 1; i > 0; --i) {
+            SkIRect localBounds = canvasBounds;
+            localBounds.offset(origin - fCanvasData[i-1].origin);
+
+            fCanvasData[i-1].requiredClip.op(localBounds, SkRegion::kDifference_Op);
+            fList[i-i]->clipRegion(fCanvasData[i-1].requiredClip);
+        }
+    }
+    SkASSERT(fList.count() == fCanvasData.count());
+}
+
+void SkCanvasStack::removeAll() {
+    fCanvasData.reset();
+    this->INHERITED::removeAll();
+}
+
+/**
+ * Traverse all canvases (e.g. layers) the stack and ensure that they are clipped
+ * to their bounds and that the area covered by any canvas higher in the stack is
+ * also clipped out.
+ */
+void SkCanvasStack::clipToZOrderedBounds() {
+    SkASSERT(fList.count() == fCanvasData.count());
+    for (int i = 0; i < fList.count(); ++i) {
+        fList[i]->clipRegion(fCanvasData[i].requiredClip, SkRegion::kIntersect_Op);
+    }
+}
+
+////////////////////////////////////////////////////////////////////////////////
+
+/**
+ * We need to handle setMatrix specially as it overwrites the matrix in each
+ * canvas unlike all other matrix operations (i.e. translate, scale, etc) which
+ * just pre-concatenate with the existing matrix.
+ */
+void SkCanvasStack::setMatrix(const SkMatrix& matrix) {
+    SkASSERT(fList.count() == fCanvasData.count());
+    for (int i = 0; i < fList.count(); ++i) {
+
+        SkMatrix tempMatrix = matrix;
+        tempMatrix.postTranslate(SkIntToScalar(-fCanvasData[i].origin.x()),
+                                 SkIntToScalar(-fCanvasData[i].origin.y()));
+        fList[i]->setMatrix(tempMatrix);
+    }
+    this->SkCanvas::setMatrix(matrix);
+}
+
+bool SkCanvasStack::clipRect(const SkRect& r, SkRegion::Op op, bool aa) {
+    bool result = this->INHERITED::clipRect(r, op, aa);
+    this->clipToZOrderedBounds();
+    return result;
+}
+
+bool SkCanvasStack::clipRRect(const SkRRect& rr, SkRegion::Op op, bool aa) {
+    bool result = this->INHERITED::clipRRect(rr, op, aa);
+    this->clipToZOrderedBounds();
+    return result;
+}
+
+bool SkCanvasStack::clipPath(const SkPath& p, SkRegion::Op op, bool aa) {
+    bool result = this->INHERITED::clipPath(p, op, aa);
+    this->clipToZOrderedBounds();
+    return result;
+}
+
+bool SkCanvasStack::clipRegion(const SkRegion& deviceRgn, SkRegion::Op op) {
+    SkASSERT(fList.count() == fCanvasData.count());
+    for (int i = 0; i < fList.count(); ++i) {
+        SkRegion tempRegion;
+        deviceRgn.translate(-fCanvasData[i].origin.x(),
+                            -fCanvasData[i].origin.y(), &tempRegion);
+        tempRegion.op(fCanvasData[i].requiredClip, SkRegion::kIntersect_Op);
+        fList[i]->clipRegion(tempRegion, op);
+    }
+    return this->SkCanvas::clipRegion(deviceRgn, op);
+}
diff --git a/src/utils/SkCanvasStack.h b/src/utils/SkCanvasStack.h
new file mode 100644
index 0000000..2137d30
--- /dev/null
+++ b/src/utils/SkCanvasStack.h
@@ -0,0 +1,52 @@
+
+/*
+ * Copyright 2013 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#ifndef SkCanvasStack_DEFINED
+#define SkCanvasStack_DEFINED
+
+#include "SkNWayCanvas.h"
+#include "SkTArray.h"
+
+class SkCanvasStack : public SkNWayCanvas {
+public:
+    SkCanvasStack(int width, int height);
+    virtual ~SkCanvasStack();
+
+    void pushCanvas(SkCanvas* canvas, const SkIPoint& origin);
+    virtual void removeAll() SK_OVERRIDE;
+
+    /*
+     * The following add/remove canvas methods are overrides from SkNWayCanvas
+     * that do not make sense in the context of our CanvasStack, but since we
+     * can share most of the other implementation of NWay we override those
+     * methods to be no-ops.
+     */
+    virtual void addCanvas(SkCanvas*) SK_OVERRIDE { SkASSERT(!"Invalid Op"); }
+    virtual void removeCanvas(SkCanvas*) SK_OVERRIDE { SkASSERT(!"Invalid Op"); }
+
+    virtual void setMatrix(const SkMatrix& matrix) SK_OVERRIDE;
+    virtual bool clipRect(const SkRect&, SkRegion::Op, bool) SK_OVERRIDE;
+    virtual bool clipRRect(const SkRRect&, SkRegion::Op, bool) SK_OVERRIDE;
+    virtual bool clipPath(const SkPath&, SkRegion::Op, bool) SK_OVERRIDE;
+    virtual bool clipRegion(const SkRegion& deviceRgn,
+                            SkRegion::Op) SK_OVERRIDE;
+
+private:
+    void clipToZOrderedBounds();
+
+    struct CanvasData {
+        SkIPoint origin;
+        SkRegion requiredClip;
+    };
+
+    SkTArray<CanvasData> fCanvasData;
+
+    typedef SkNWayCanvas INHERITED;
+};
+
+#endif
diff --git a/src/utils/SkCanvasStateUtils.cpp b/src/utils/SkCanvasStateUtils.cpp
index c4232c2..cd79a44 100644
--- a/src/utils/SkCanvasStateUtils.cpp
+++ b/src/utils/SkCanvasStateUtils.cpp
@@ -9,7 +9,7 @@
 
 #include "SkBitmapDevice.h"
 #include "SkCanvas.h"
-#include "SkNWayCanvas.h"
+#include "SkCanvasStack.h"
 #include "SkWriter32.h"
 
 #define CANVAS_STATE_VERSION 1
@@ -316,18 +316,19 @@
         return NULL;
     }
 
-    SkAutoTUnref<SkNWayCanvas> canvas(SkNEW_ARGS(SkNWayCanvas, (state->width, state->height)));
+    SkAutoTUnref<SkCanvasStack> canvas(SkNEW_ARGS(SkCanvasStack, (state->width, state->height)));
 
     // setup the matrix and clip on the n-way canvas
     setup_canvas_from_MC_state(state->mcState, canvas);
 
     // Iterate over the layers and add them to the n-way canvas
-    for (int i = 0; i < state->layerCount; ++i) {
+    for (int i = state->layerCount - 1; i >= 0; --i) {
         SkAutoTUnref<SkCanvas> canvasLayer(create_canvas_from_canvas_layer(state->layers[i]));
         if (!canvasLayer.get()) {
             return NULL;
         }
-        canvas->addCanvas(canvasLayer.get());
+        canvas->pushCanvas(canvasLayer.get(), SkIPoint::Make(state->layers[i].x,
+                                                             state->layers[i].y));
     }
 
     return canvas.detach();
