Remove Matrix/Clip State collapse code
authorrobertphillips <robertphillips@google.com>
Mon, 11 Aug 2014 13:03:42 +0000 (06:03 -0700)
committerCommit bot <commit-bot@chromium.org>
Mon, 11 Aug 2014 13:03:42 +0000 (06:03 -0700)
Given recent & upcoming changes (e.g., removal of save flags & SkRecord picture backend) this will have to be reimplemented.

R=fmalita@google.com, fmalita@chromium.org

Author: robertphillips@google.com

Review URL: https://codereview.chromium.org/453133003

gyp/core.gypi
src/core/SkMatrixClipStateMgr.cpp [deleted file]
src/core/SkMatrixClipStateMgr.h [deleted file]
src/core/SkPictureRecord.cpp
src/core/SkPictureRecord.h

index 60d7859..a6d5635 100644 (file)
         '<(skia_src_path)/core/SkMaskGamma.h',
         '<(skia_src_path)/core/SkMath.cpp',
         '<(skia_src_path)/core/SkMatrix.cpp',
-        '<(skia_src_path)/core/SkMatrixClipStateMgr.cpp',
-        '<(skia_src_path)/core/SkMatrixClipStateMgr.h',
         '<(skia_src_path)/core/SkMessageBus.h',
         '<(skia_src_path)/core/SkMetaData.cpp',
         '<(skia_src_path)/core/SkMipMap.cpp',
diff --git a/src/core/SkMatrixClipStateMgr.cpp b/src/core/SkMatrixClipStateMgr.cpp
deleted file mode 100644 (file)
index 680cc36..0000000
+++ /dev/null
@@ -1,419 +0,0 @@
-/*
- * Copyright 2014 Google Inc.
- *
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#include "SkMatrixClipStateMgr.h"
-#include "SkPictureRecord.h"
-
-bool SkMatrixClipStateMgr::MatrixClipState::ClipInfo::clipPath(SkPictureRecord* picRecord,
-                                                               const SkPath& path,
-                                                               SkRegion::Op op,
-                                                               bool doAA,
-                                                               int matrixID) {
-    int pathID = picRecord->addPathToHeap(path);
-
-    ClipOp* newClip = fClips.append();
-    newClip->fClipType = kPath_ClipType;
-    newClip->fGeom.fPathID = pathID;
-    newClip->fOp = op;
-    newClip->fDoAA = doAA;
-    newClip->fMatrixID = matrixID;
-    return false;
-}
-
-bool SkMatrixClipStateMgr::MatrixClipState::ClipInfo::clipRegion(SkPictureRecord* picRecord,
-                                                                 int regionID,
-                                                                 SkRegion::Op op,
-                                                                 int matrixID) {
-    ClipOp* newClip = fClips.append();
-    newClip->fClipType = kRegion_ClipType;
-    newClip->fGeom.fRegionID = regionID;
-    newClip->fOp = op;
-    newClip->fDoAA = true;      // not necessary but sanity preserving
-    newClip->fMatrixID = matrixID;
-    return false;
-}
-
-void SkMatrixClipStateMgr::writeDeltaMat(int currentMatID, int desiredMatID) {
-    const SkMatrix& current = this->lookupMat(currentMatID);
-    const SkMatrix& desired = this->lookupMat(desiredMatID);
-
-    SkMatrix delta;
-    bool result = current.invert(&delta);
-    if (result) {
-        delta.preConcat(desired);
-    }
-    fPicRecord->recordConcat(delta);
-}
-
-// Note: this only writes out the clips for the current save state. To get the
-// entire clip stack requires iterating of the entire matrix/clip stack.
-void SkMatrixClipStateMgr::MatrixClipState::ClipInfo::writeClip(int* curMatID,
-                                                                SkMatrixClipStateMgr* mgr) {
-    for (int i = 0; i < fClips.count(); ++i) {
-        ClipOp& curClip = fClips[i];
-
-        // TODO: use the matrix ID to skip writing the identity matrix
-        // over and over, i.e.:
-        //  if (*curMatID != curClip.fMatrixID) {
-        //      mgr->writeDeltaMat...
-        //      *curMatID...
-        //  }
-        // Right now this optimization would throw off the testing harness.
-        // TODO: right now we're writing out the delta matrix from the prior
-        // matrix state. This is a side-effect of writing out the entire
-        // clip stack and should be resolved when that is fixed.
-        mgr->writeDeltaMat(*curMatID, curClip.fMatrixID);
-        *curMatID = curClip.fMatrixID;
-
-        size_t offset = 0;
-
-        switch (curClip.fClipType) {
-        case kRect_ClipType:
-            offset = mgr->getPicRecord()->recordClipRect(curClip.fGeom.fRRect.rect(),
-                                                         curClip.fOp, curClip.fDoAA);
-            break;
-        case kRRect_ClipType:
-            offset = mgr->getPicRecord()->recordClipRRect(curClip.fGeom.fRRect, curClip.fOp,
-                                                         curClip.fDoAA);
-            break;
-        case kPath_ClipType:
-            offset = mgr->getPicRecord()->recordClipPath(curClip.fGeom.fPathID, curClip.fOp,
-                                                         curClip.fDoAA);
-            break;
-        case kRegion_ClipType: {
-            const SkRegion* region = mgr->lookupRegion(curClip.fGeom.fRegionID);
-            offset = mgr->getPicRecord()->recordClipRegion(*region, curClip.fOp);
-            break;
-        }
-        default:
-            SkASSERT(0);
-        }
-
-        mgr->addClipOffset(offset);
-    }
-}
-
-SkMatrixClipStateMgr::SkMatrixClipStateMgr()
-    : fPicRecord(NULL)
-    , fMatrixClipStack(sizeof(MatrixClipState),
-                       fMatrixClipStackStorage,
-                       sizeof(fMatrixClipStackStorage))
-    , fCurOpenStateID(kIdentityWideOpenStateID) {
-
-    fSkipOffsets = SkNEW(SkTDArray<int>);
-
-    // The first slot in the matrix dictionary is reserved for the identity matrix
-    fMatrixDict.append()->reset();
-
-    fCurMCState = (MatrixClipState*)fMatrixClipStack.push_back();
-    new (fCurMCState) MatrixClipState(NULL);    // balanced in restore()
-
-#ifdef SK_DEBUG
-    fActualDepth = 0;
-#endif
-}
-
-SkMatrixClipStateMgr::~SkMatrixClipStateMgr() {
-    for (int i = 0; i < fRegionDict.count(); ++i) {
-        SkDELETE(fRegionDict[i]);
-    }
-
-    SkDELETE(fSkipOffsets);
-}
-
-
-int SkMatrixClipStateMgr::MCStackPush() {
-    MatrixClipState* newTop = (MatrixClipState*)fMatrixClipStack.push_back();
-    new (newTop) MatrixClipState(fCurMCState); // balanced in restore()
-    fCurMCState = newTop;
-
-    SkDEBUGCODE(this->validate();)
-
-    return fMatrixClipStack.count();
-}
-
-int SkMatrixClipStateMgr::save() {
-    SkDEBUGCODE(this->validate();)
-
-    return this->MCStackPush();
-}
-
-int SkMatrixClipStateMgr::saveLayer(const SkRect* bounds, const SkPaint* paint,
-                                    SkCanvas::SaveFlags flags) {
-#ifdef SK_DEBUG
-    if (fCurMCState->fIsSaveLayer) {
-        SkASSERT(0 == fSkipOffsets->count());
-    }
-#endif
-
-    // Since the saveLayer call draws something we need to potentially dump
-    // out the MC state
-    SkDEBUGCODE(bool saved =) this->call(kOther_CallType);
-
-    int result = this->MCStackPush();
-    ++fCurMCState->fLayerID;
-    fCurMCState->fIsSaveLayer = true;
-
-#ifdef SK_DEBUG
-    if (saved) {
-        fCurMCState->fExpectedDepth++; // 1 for nesting save
-    }
-    fCurMCState->fExpectedDepth++;   // 1 for saveLayer
-#endif
-
-    *fStateIDStack.append() = fCurOpenStateID;
-    fCurMCState->fSavedSkipOffsets = fSkipOffsets;
-
-    // TODO: recycle these rather then new & deleting them on every saveLayer/
-    // restore
-    fSkipOffsets = SkNEW(SkTDArray<int>);
-
-    fPicRecord->recordSaveLayer(bounds, paint, flags);
-#ifdef SK_DEBUG
-    fActualDepth++;
-#endif
-    return result;
-}
-
-void SkMatrixClipStateMgr::restore() {
-    SkDEBUGCODE(this->validate();)
-
-    if (fCurMCState->fIsSaveLayer) {
-        if (fCurMCState->fHasOpen) {
-            fCurMCState->fHasOpen = false;
-            fPicRecord->recordRestore(); // Close the open block inside the saveLayer
-#ifdef SK_DEBUG
-            SkASSERT(fActualDepth > 0);
-            fActualDepth--;
-#endif
-        } else {
-            SkASSERT(0 == fSkipOffsets->count());
-        }
-
-        // The saveLayer's don't carry any matrix or clip state in the
-        // new scheme so make sure the saveLayer's recordRestore doesn't
-        // try to finalize them (i.e., fill in their skip offsets).
-        fPicRecord->recordRestore(false); // close of saveLayer
-#ifdef SK_DEBUG
-        SkASSERT(fActualDepth > 0);
-        fActualDepth--;
-#endif
-
-        SkASSERT(fStateIDStack.count() >= 1);
-        fCurOpenStateID = fStateIDStack[fStateIDStack.count()-1];
-        fStateIDStack.pop();
-
-        SkASSERT(0 == fSkipOffsets->count());
-        SkASSERT(NULL != fCurMCState->fSavedSkipOffsets);
-
-        SkDELETE(fSkipOffsets);
-        fSkipOffsets = fCurMCState->fSavedSkipOffsets;
-    }
-
-    bool prevHadOpen = fCurMCState->fHasOpen;
-    bool prevWasSaveLayer = fCurMCState->fIsSaveLayer;
-
-    fCurMCState->~MatrixClipState();       // balanced in save()
-    fMatrixClipStack.pop_back();
-    fCurMCState = (MatrixClipState*)fMatrixClipStack.back();
-
-    if (!prevWasSaveLayer) {
-        fCurMCState->fHasOpen = prevHadOpen;
-    }
-
-    if (fCurMCState->fIsSaveLayer) {
-        if (0 != fSkipOffsets->count()) {
-            SkASSERT(fCurMCState->fHasOpen);
-        }
-    }
-
-    SkDEBUGCODE(this->validate();)
-}
-
-// kIdentityWideOpenStateID (0) is reserved for the identity/wide-open clip state
-int32_t SkMatrixClipStateMgr::NewMCStateID() {
-    // TODO: guard against wrap around
-    // TODO: make uint32_t
-    static int32_t gMCStateID = kIdentityWideOpenStateID;
-    ++gMCStateID;
-    return gMCStateID;
-}
-
-bool SkMatrixClipStateMgr::isNestingMCState(int stateID) {
-    return fStateIDStack.count() > 0 && fStateIDStack[fStateIDStack.count()-1] == fCurOpenStateID;
-}
-
-bool SkMatrixClipStateMgr::call(CallType callType) {
-    SkDEBUGCODE(this->validate();)
-
-    if (kMatrix_CallType == callType || kClip_CallType == callType) {
-        fCurMCState->fMCStateID = NewMCStateID();
-        SkDEBUGCODE(this->validate();)
-        return false;
-    }
-
-    SkASSERT(kOther_CallType == callType);
-
-    if (fCurMCState->fMCStateID == fCurOpenStateID) {
-        // Required MC state is already active one - nothing to do
-        SkDEBUGCODE(this->validate();)
-        return false;
-    }
-
-    if (kIdentityWideOpenStateID != fCurOpenStateID &&
-        !this->isNestingMCState(fCurOpenStateID)) {
-        // Don't write a restore if the open state is one in which a saveLayer
-        // is nested. The save after the saveLayer's restore will close it.
-        fPicRecord->recordRestore();    // Close the open block
-        fCurMCState->fHasOpen = false;
-#ifdef SK_DEBUG
-        SkASSERT(fActualDepth > 0);
-        fActualDepth--;
-#endif
-    }
-
-    // Install the required MC state as the active one
-    fCurOpenStateID = fCurMCState->fMCStateID;
-
-    if (kIdentityWideOpenStateID == fCurOpenStateID) {
-        SkASSERT(0 == fActualDepth);
-        SkASSERT(!fCurMCState->fHasOpen);
-        SkASSERT(0 == fSkipOffsets->count());
-        return false;
-    }
-
-    SkASSERT(!fCurMCState->fHasOpen);
-    SkASSERT(0 == fSkipOffsets->count());
-    fCurMCState->fHasOpen = true;
-    fPicRecord->recordSave();
-#ifdef SK_DEBUG
-    fActualDepth++;
-    SkASSERT(fActualDepth == fCurMCState->fExpectedDepth);
-#endif
-
-    // write out clips
-    SkDeque::Iter iter(fMatrixClipStack, SkDeque::Iter::kBack_IterStart);
-    const MatrixClipState* state;
-    // Loop back across the MC states until the last saveLayer. The MC
-    // state in front of the saveLayer has already been written out.
-    for (state = (const MatrixClipState*) iter.prev();
-         state != NULL;
-         state = (const MatrixClipState*) iter.prev()) {
-        if (state->fIsSaveLayer) {
-            break;
-        }
-    }
-
-    int curMatID;
-
-    if (NULL == state) {
-        // There was no saveLayer in the MC stack so we need to output them all
-        iter.reset(fMatrixClipStack, SkDeque::Iter::kFront_IterStart);
-        state = (const MatrixClipState*) iter.next();
-        curMatID = kIdentityMatID;
-    } else {
-        // SkDeque's iterators actually return the previous location so we
-        // need to reverse and go forward one to get back on track.
-        iter.next();
-        SkDEBUGCODE(const MatrixClipState* test = (const MatrixClipState*)) iter.next();
-        SkASSERT(test == state);
-
-        curMatID = state->fMatrixInfo->getID(this);
-
-        // TODO: this assumes that, in the case of Save|SaveLayer when the SaveLayer
-        // doesn't save the clip, that the SaveLayer doesn't add any additional clip state.
-        // This assumption will be removed when we explicitly store the clip state in
-        // self-contained objects. It is valid for the small set of skps.
-        if (NULL != state->fPrev && state->fClipInfo == state->fPrev->fClipInfo) {
-            // By the above assumption the SaveLayer's MC state has already been
-            // written out by the prior Save so don't output it again.
-            state = (const MatrixClipState*) iter.next();
-        }
-    }
-
-    for ( ; state != NULL; state = (const MatrixClipState*) iter.next()) {
-         state->fClipInfo->writeClip(&curMatID, this);
-    }
-
-    // write out matrix
-    // TODO: this test isn't quite right. It should be:
-    //   if (curMatID != fCurMCState->fMatrixInfo->getID(this)) {
-    // but right now the testing harness always expects a matrix if
-    // the matrices are non-I
-    if (kIdentityMatID != fCurMCState->fMatrixInfo->getID(this)) {
-        // TODO: writing out the delta matrix here is an artifact of the writing
-        // out of the entire clip stack (with its matrices). Ultimately we will
-        // write out the CTM here when the clip state is collapsed to a single path.
-        this->writeDeltaMat(curMatID, fCurMCState->fMatrixInfo->getID(this));
-    }
-
-    SkDEBUGCODE(this->validate();)
-    return true;
-}
-
-// Fill in the skip offsets for all the clips written in the current block
-void SkMatrixClipStateMgr::fillInSkips(SkWriter32* writer, int32_t restoreOffset) {
-    for (int i = 0; i < fSkipOffsets->count(); ++i) {
-        SkDEBUGCODE(int32_t peek = writer->readTAt<int32_t>((*fSkipOffsets)[i]);)
-        SkASSERT(-1 == peek);
-        writer->overwriteTAt<int32_t>((*fSkipOffsets)[i], restoreOffset);
-    }
-
-    fSkipOffsets->rewind();
-    SkASSERT(0 == fSkipOffsets->count());
-}
-
-void SkMatrixClipStateMgr::finish() {
-    if (kIdentityWideOpenStateID != fCurOpenStateID) {
-        fPicRecord->recordRestore();    // Close the open block
-        fCurMCState->fHasOpen = false;
-#ifdef SK_DEBUG
-        SkASSERT(fActualDepth > 0);
-        fActualDepth--;
-#endif
-        fCurOpenStateID = kIdentityWideOpenStateID;
-        SkASSERT(!fCurMCState->fHasOpen);
-    }
-}
-
-#ifdef SK_DEBUG
-void SkMatrixClipStateMgr::validate() {
-    if (fCurOpenStateID == fCurMCState->fMCStateID && !this->isNestingMCState(fCurOpenStateID)) {
-        // The current state is the active one so it should have a skip
-        // offset for each clip
-        SkDeque::Iter iter(fMatrixClipStack, SkDeque::Iter::kBack_IterStart);
-        int clipCount = 0;
-        for (const MatrixClipState* state = (const MatrixClipState*) iter.prev();
-             state != NULL;
-             state = (const MatrixClipState*) iter.prev()) {
-            if (NULL == state->fPrev || state->fPrev->fClipInfo != state->fClipInfo) {
-                clipCount += state->fClipInfo->numClips();
-            }
-            if (state->fIsSaveLayer) {
-                break;
-            }
-        }
-
-        SkASSERT(fSkipOffsets->count() == clipCount);
-    }
-}
-#endif
-
-int SkMatrixClipStateMgr::addRegionToDict(const SkRegion& region) {
-    int index = fRegionDict.count();
-    *fRegionDict.append() = SkNEW(SkRegion(region));
-    return index;
-}
-
-int SkMatrixClipStateMgr::addMatToDict(const SkMatrix& mat) {
-    if (mat.isIdentity()) {
-        return kIdentityMatID;
-    }
-
-    *fMatrixDict.append() = mat;
-    return fMatrixDict.count()-1;
-}
diff --git a/src/core/SkMatrixClipStateMgr.h b/src/core/SkMatrixClipStateMgr.h
deleted file mode 100644 (file)
index 9a80b01..0000000
+++ /dev/null
@@ -1,406 +0,0 @@
-/*
- * Copyright 2014 Google Inc.
- *
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-#ifndef SkMatrixClipStateMgr_DEFINED
-#define SkMatrixClipStateMgr_DEFINED
-
-#include "SkCanvas.h"
-#include "SkMatrix.h"
-#include "SkRegion.h"
-#include "SkRRect.h"
-#include "SkTypes.h"
-#include "SkTDArray.h"
-
-class SkPictureRecord;
-class SkWriter32;
-
-// The SkMatrixClipStateMgr collapses the matrix/clip state of an SkPicture into
-// a series of save/restore blocks of consistent matrix clip state, e.g.:
-//
-//   save
-//     clip(s)
-//     concat
-//     ... draw ops ...
-//   restore
-//
-// SaveLayers simply add another level, e.g.:
-//
-//   save
-//     clip(s)
-//     concat
-//     ... draw ops ...
-//     saveLayer
-//       save
-//         clip(s)
-//         concat
-//         ... draw ops ...
-//       restore
-//     restore
-//   restore
-//
-// As a side effect of this process all saves and saveLayers will become
-// kMatrixClip_SaveFlag style saves/saveLayers.
-
-// The SkMatrixClipStateMgr works by intercepting all the save*, restore, clip*,
-// and matrix calls sent to SkCanvas in order to track the current matrix/clip
-// state. All the other canvas calls get funnelled into a generic "call" entry
-// point that signals that a state block is required.
-class SkMatrixClipStateMgr {
-public:
-    static const int32_t kIdentityWideOpenStateID = 0;
-    static const int kIdentityMatID = 0;
-
-    class MatrixClipState : SkNoncopyable {
-    public:
-        class MatrixInfo {
-        public:
-            void reset() {
-                fMatrixID = kIdentityMatID;
-                fMatrix.reset();
-            }
-
-            void preTranslate(SkScalar dx, SkScalar dy) {
-                fMatrixID = -1;
-                fMatrix.preTranslate(dx, dy);
-            }
-
-            void preScale(SkScalar sx, SkScalar sy) {
-                fMatrixID = -1;
-                fMatrix.preScale(sx, sy);
-            }
-
-            void preRotate(SkScalar degrees) {
-                fMatrixID = -1;
-                fMatrix.preRotate(degrees);
-            }
-
-            void preSkew(SkScalar sx, SkScalar sy) {
-                fMatrixID = -1;
-                fMatrix.preSkew(sx, sy);
-            }
-
-            void preConcat(const SkMatrix& matrix) {
-                fMatrixID = -1;
-                fMatrix.preConcat(matrix);
-            }
-
-            void setMatrix(const SkMatrix& matrix) {
-                fMatrixID = -1;
-                fMatrix = matrix;
-            }
-
-            int getID(SkMatrixClipStateMgr* mgr) {
-                if (fMatrixID >= 0) {
-                    return fMatrixID;
-                }
-
-                fMatrixID = mgr->addMatToDict(fMatrix);
-                return fMatrixID;
-            }
-
-        private:
-            SkMatrix fMatrix;
-            int      fMatrixID;
-
-            typedef SkNoncopyable INHERITED;
-        };
-
-        class ClipInfo : SkNoncopyable {
-        public:
-            ClipInfo() {}
-
-            bool clipRect(const SkRect& rect,
-                          SkRegion::Op op,
-                          bool doAA,
-                          int matrixID) {
-                ClipOp* newClip = fClips.append();
-                newClip->fClipType = kRect_ClipType;
-                newClip->fGeom.fRRect.setRect(rect);   // storing the clipRect in the RRect
-                newClip->fOp = op;
-                newClip->fDoAA = doAA;
-                newClip->fMatrixID = matrixID;
-                return false;
-            }
-
-            bool clipRRect(const SkRRect& rrect,
-                           SkRegion::Op op,
-                           bool doAA,
-                           int matrixID) {
-                ClipOp* newClip = fClips.append();
-                newClip->fClipType = kRRect_ClipType;
-                newClip->fGeom.fRRect = rrect;
-                newClip->fOp = op;
-                newClip->fDoAA = doAA;
-                newClip->fMatrixID = matrixID;
-                return false;
-            }
-
-            bool clipPath(SkPictureRecord* picRecord,
-                          const SkPath& path,
-                          SkRegion::Op op,
-                          bool doAA,
-                          int matrixID);
-            bool clipRegion(SkPictureRecord* picRecord,
-                            int regionID,
-                            SkRegion::Op op,
-                            int matrixID);
-            void writeClip(int* curMatID, SkMatrixClipStateMgr* mgr);
-
-            SkDEBUGCODE(int numClips() const { return fClips.count(); })
-
-        private:
-            enum ClipType {
-                kRect_ClipType,
-                kRRect_ClipType,
-                kPath_ClipType,
-                kRegion_ClipType
-            };
-
-            class ClipOp {
-            public:
-                ClipType     fClipType;
-
-                union {
-                    SkRRect fRRect;        // also stores clip rect
-                    int     fPathID;
-                    int     fRegionID;
-                } fGeom;
-
-                bool         fDoAA;
-                SkRegion::Op fOp;
-
-                // The CTM in effect when this clip call was issued
-                int          fMatrixID;
-            };
-
-            SkTDArray<ClipOp> fClips;
-
-            typedef SkNoncopyable INHERITED;
-        };
-
-        MatrixClipState(MatrixClipState* prev)
-            : fPrev(prev)
-        {
-            fHasOpen = false;
-
-            if (NULL == prev) {
-                fLayerID = 0;
-
-                fMatrixInfoStorage.reset();
-                fMatrixInfo = &fMatrixInfoStorage;
-                fClipInfo = &fClipInfoStorage;  // ctor handles init of fClipInfoStorage
-
-                // The identity/wide-open-clip state is current by default
-                fMCStateID = kIdentityWideOpenStateID;
-#ifdef SK_DEBUG
-                fExpectedDepth = 1;
-#endif
-            }
-            else {
-                fLayerID = prev->fLayerID;
-
-                fMatrixInfoStorage = *prev->fMatrixInfo;
-                fMatrixInfo = &fMatrixInfoStorage;
-
-                // We don't copy the ClipOps of the previous clip states
-                fClipInfo = &fClipInfoStorage;
-
-                // Initially a new save/saveLayer represents the same MC state
-                // as its predecessor.
-                fMCStateID = prev->fMCStateID;
-#ifdef SK_DEBUG
-                fExpectedDepth = prev->fExpectedDepth;
-#endif
-            }
-
-            fIsSaveLayer = false;
-        }
-
-        MatrixInfo*  fMatrixInfo;
-        MatrixInfo   fMatrixInfoStorage;
-
-        ClipInfo*    fClipInfo;
-        ClipInfo     fClipInfoStorage;
-
-        // Tracks the current depth of saveLayers to support the isDrawingToLayer call
-        int          fLayerID;
-        // Does this MC state represent a saveLayer call?
-        bool         fIsSaveLayer;
-
-        // The next field is only valid when fIsSaveLayer is set.
-        SkTDArray<int>* fSavedSkipOffsets;
-
-        // Does the MC state have an open block in the skp?
-        bool         fHasOpen;
-
-        MatrixClipState* fPrev;
-
-#ifdef SK_DEBUG
-        int              fExpectedDepth;    // debugging aid
-#endif
-
-        int32_t     fMCStateID;
-    };
-
-    enum CallType {
-        kMatrix_CallType,
-        kClip_CallType,
-        kOther_CallType
-    };
-
-    SkMatrixClipStateMgr();
-    ~SkMatrixClipStateMgr();
-
-    void init(SkPictureRecord* picRecord) {
-        // Note: we're not taking a ref here. It is expected that the SkMatrixClipStateMgr
-        // is owned by the SkPictureRecord object
-        fPicRecord = picRecord;
-    }
-
-    SkPictureRecord* getPicRecord() { return fPicRecord; }
-
-    // TODO: need to override canvas' getSaveCount. Right now we pass the
-    // save* and restore calls on to the base SkCanvas in SkPictureRecord but
-    // this duplicates effort.
-    int getSaveCount() const { return fMatrixClipStack.count(); }
-
-    int save();
-
-    int saveLayer(const SkRect* bounds, const SkPaint* paint, SkCanvas::SaveFlags flags);
-
-    bool isDrawingToLayer() const {
-        return fCurMCState->fLayerID > 0;
-    }
-
-    void restore();
-
-    void translate(SkScalar dx, SkScalar dy) {
-        this->call(kMatrix_CallType);
-        fCurMCState->fMatrixInfo->preTranslate(dx, dy);
-    }
-
-    void scale(SkScalar sx, SkScalar sy) {
-        this->call(kMatrix_CallType);
-        fCurMCState->fMatrixInfo->preScale(sx, sy);
-    }
-
-    void rotate(SkScalar degrees) {
-        this->call(kMatrix_CallType);
-        fCurMCState->fMatrixInfo->preRotate(degrees);
-    }
-
-    void skew(SkScalar sx, SkScalar sy) {
-        this->call(kMatrix_CallType);
-        fCurMCState->fMatrixInfo->preSkew(sx, sy);
-    }
-
-    void concat(const SkMatrix& matrix) {
-        this->call(kMatrix_CallType);
-        fCurMCState->fMatrixInfo->preConcat(matrix);
-    }
-
-    void setMatrix(const SkMatrix& matrix) {
-        this->call(kMatrix_CallType);
-        fCurMCState->fMatrixInfo->setMatrix(matrix);
-    }
-
-    bool clipRect(const SkRect& rect, SkRegion::Op op, bool doAA) {
-        this->call(SkMatrixClipStateMgr::kClip_CallType);
-        return fCurMCState->fClipInfo->clipRect(rect, op, doAA,
-                                                fCurMCState->fMatrixInfo->getID(this));
-    }
-
-    bool clipRRect(const SkRRect& rrect, SkRegion::Op op, bool doAA) {
-        this->call(SkMatrixClipStateMgr::kClip_CallType);
-        return fCurMCState->fClipInfo->clipRRect(rrect, op, doAA,
-                                                 fCurMCState->fMatrixInfo->getID(this));
-    }
-
-    bool clipPath(const SkPath& path, SkRegion::Op op, bool doAA) {
-        this->call(SkMatrixClipStateMgr::kClip_CallType);
-        return fCurMCState->fClipInfo->clipPath(fPicRecord, path, op, doAA,
-                                                fCurMCState->fMatrixInfo->getID(this));
-    }
-
-    bool clipRegion(const SkRegion& region, SkRegion::Op op) {
-        this->call(SkMatrixClipStateMgr::kClip_CallType);
-        int regionID = this->addRegionToDict(region);
-        return fCurMCState->fClipInfo->clipRegion(fPicRecord, regionID, op,
-                                                  fCurMCState->fMatrixInfo->getID(this));
-    }
-
-    bool call(CallType callType);
-
-    void fillInSkips(SkWriter32* writer, int32_t restoreOffset);
-
-    void finish();
-
-protected:
-    SkPictureRecord* fPicRecord;
-
-    uint32_t         fMatrixClipStackStorage[43]; // sized to fit 2 clip states
-    SkDeque          fMatrixClipStack;
-    MatrixClipState* fCurMCState;
-
-    // This dictionary doesn't actually de-duplicate the matrices (except for the
-    // identity matrix). It merely stores the matrices and allows them to be looked
-    // up by ID later. The de-duplication mainly falls upon the matrix/clip stack
-    // which stores the ID so a revisited clip/matrix (via popping the stack) will
-    // use the same ID.
-    SkTDArray<SkMatrix> fMatrixDict;
-
-    SkTDArray<SkRegion*> fRegionDict;
-
-    // The MCStateID of the state currently in effect in the byte stream. 0 if none.
-    int32_t          fCurOpenStateID;
-    // The skip offsets for the current open state. These are the locations in the
-    // skp that must be filled in when the current open state is closed. These are
-    // here rather then distributed across the MatrixClipState's because saveLayers
-    // can cause MC states to be nested.
-    SkTDArray<int32_t>  *fSkipOffsets;  // TODO: should we store u32 or size_t instead?
-
-    SkDEBUGCODE(void validate();)
-
-    int MCStackPush();
-
-    void addClipOffset(size_t offset) {
-        SkASSERT(NULL != fSkipOffsets);
-        SkASSERT(kIdentityWideOpenStateID != fCurOpenStateID);
-        SkASSERT(fCurMCState->fHasOpen);
-        SkASSERT(!fCurMCState->fIsSaveLayer);
-
-        *fSkipOffsets->append() = SkToS32(offset);
-    }
-
-    void writeDeltaMat(int currentMatID, int desiredMatID);
-    static int32_t   NewMCStateID();
-
-    int addRegionToDict(const SkRegion& region);
-    const SkRegion* lookupRegion(int index) {
-        SkASSERT(index >= 0 && index < fRegionDict.count());
-        return fRegionDict[index];
-    }
-
-    // TODO: add stats to check if the dictionary really does
-    // reduce the size of the SkPicture.
-    int addMatToDict(const SkMatrix& mat);
-    const SkMatrix& lookupMat(int index) {
-        SkASSERT(index >= 0 && index < fMatrixDict.count());
-        return fMatrixDict[index];
-    }
-
-    bool isNestingMCState(int stateID);
-
-#ifdef SK_DEBUG
-    int fActualDepth;
-#endif
-
-    // save layers are nested within a specific MC state. This stack tracks
-    // the nesting MC state's ID as save layers are pushed and popped.
-    SkTDArray<int> fStateIDStack;
-};
-
-#endif
index 66aa46d..88975d2 100644 (file)
@@ -52,15 +52,8 @@ SkPictureRecord::SkPictureRecord(const SkISize& dimensions, uint32_t flags)
     fBitmapHeap = SkNEW(SkBitmapHeap);
     fFlattenableHeap.setBitmapStorage(fBitmapHeap);
 
-#ifndef SK_COLLAPSE_MATRIX_CLIP_STATE
     fFirstSavedLayerIndex = kNoSavedLayerIndex;
-#endif
-
     fInitialSaveCount = kNoInitialSave;
-
-#ifdef SK_COLLAPSE_MATRIX_CLIP_STATE
-    fMCMgr.init(this);
-#endif
 }
 
 SkPictureRecord::~SkPictureRecord() {
@@ -153,15 +146,10 @@ static inline size_t getPaintOffset(DrawType op, size_t opSize) {
 }
 
 void SkPictureRecord::willSave() {
-
-#ifdef SK_COLLAPSE_MATRIX_CLIP_STATE
-    fMCMgr.save();
-#else
     // record the offset to us, making it non-positive to distinguish a save
     // from a clip entry.
     fRestoreOffsetStack.push(-(int32_t)fWriter.bytesWritten());
     this->recordSave();
-#endif
 
     this->INHERITED::willSave();
 }
@@ -176,10 +164,6 @@ void SkPictureRecord::recordSave() {
 
 SkCanvas::SaveLayerStrategy SkPictureRecord::willSaveLayer(const SkRect* bounds,
                                                            const SkPaint* paint, SaveFlags flags) {
-
-#ifdef SK_COLLAPSE_MATRIX_CLIP_STATE
-    fMCMgr.saveLayer(bounds, paint, flags);
-#else
     // record the offset to us, making it non-positive to distinguish a save
     // from a clip entry.
     fRestoreOffsetStack.push(-(int32_t)fWriter.bytesWritten());
@@ -187,7 +171,6 @@ SkCanvas::SaveLayerStrategy SkPictureRecord::willSaveLayer(const SkRect* bounds,
     if (kNoSavedLayerIndex == fFirstSavedLayerIndex) {
         fFirstSavedLayerIndex = fRestoreOffsetStack.count();
     }
-#endif
 
     this->INHERITED::willSaveLayer(bounds, paint, flags);
     /*  No need for a (potentially very big) layer which we don't actually need
@@ -220,11 +203,7 @@ void SkPictureRecord::recordSaveLayer(const SkRect* bounds, const SkPaint* paint
 }
 
 bool SkPictureRecord::isDrawingToLayer() const {
-#ifdef SK_COLLAPSE_MATRIX_CLIP_STATE
-    return fMCMgr.isDrawingToLayer();
-#else
     return fFirstSavedLayerIndex != kNoSavedLayerIndex;
-#endif
 }
 
 /*
@@ -457,7 +436,6 @@ static bool merge_savelayer_paint_into_drawbitmp(SkWriter32* writer,
  */
 static bool remove_save_layer2(SkWriter32* writer, int32_t offset,
                                SkPaintDictionary* paintDict) {
-
     // back up to the save block
     // TODO: add a stack to track save*/restore offsets rather than searching backwards
     while (offset > 0) {
@@ -605,13 +583,6 @@ void SkPictureRecord::willRestore() {
     SkASSERT(fRestoreOffsetStack.count() > 1);
 #endif
 
-#ifdef SK_COLLAPSE_MATRIX_CLIP_STATE
-    if (fMCMgr.getSaveCount() == 1) {
-        return;
-    }
-
-    fMCMgr.restore();
-#else
     // check for underflow
     if (fRestoreOffsetStack.count() == 0) {
         return;
@@ -643,7 +614,6 @@ void SkPictureRecord::willRestore() {
     }
 
     fRestoreOffsetStack.pop();
-#endif
 
     this->INHERITED::willRestore();
 }
@@ -680,10 +650,6 @@ void SkPictureRecord::recordScale(const SkMatrix& m) {
 }
 
 void SkPictureRecord::didConcat(const SkMatrix& matrix) {
-
-#ifdef SK_COLLAPSE_MATRIX_CLIP_STATE
-    fMCMgr.concat(matrix);
-#else
     switch (matrix.getType()) {
         case SkMatrix::kTranslate_Mask:
             this->recordTranslate(matrix);
@@ -695,7 +661,6 @@ void SkPictureRecord::didConcat(const SkMatrix& matrix) {
             this->recordConcat(matrix);
             break;
     }
-#endif
     this->INHERITED::didConcat(matrix);
 }
 
@@ -709,17 +674,12 @@ void SkPictureRecord::recordConcat(const SkMatrix& matrix) {
 }
 
 void SkPictureRecord::didSetMatrix(const SkMatrix& matrix) {
-
-#ifdef SK_COLLAPSE_MATRIX_CLIP_STATE
-    fMCMgr.setMatrix(matrix);
-#else
     this->validate(fWriter.bytesWritten(), 0);
     // op + matrix
     size_t size = kUInt32Size + matrix.writeToMemory(NULL);
     size_t initialOffset = this->addDraw(SET_MATRIX, &size);
     this->addMatrix(matrix);
     this->validate(initialOffset, size);
-#endif
     this->INHERITED::didSetMatrix(matrix);
 }
 
@@ -739,11 +699,6 @@ static bool regionOpExpands(SkRegion::Op op) {
     }
 }
 
-#ifdef SK_COLLAPSE_MATRIX_CLIP_STATE
-void SkPictureRecord::fillRestoreOffsetPlaceholdersForCurrentStackLevel(uint32_t restoreOffset) {
-    fMCMgr.fillInSkips(&fWriter, restoreOffset);
-}
-#else
 void SkPictureRecord::fillRestoreOffsetPlaceholdersForCurrentStackLevel(uint32_t restoreOffset) {
     int32_t offset = fRestoreOffsetStack.top();
     while (offset > 0) {
@@ -759,7 +714,6 @@ void SkPictureRecord::fillRestoreOffsetPlaceholdersForCurrentStackLevel(uint32_t
     SkASSERT(SAVE == drawOp || SAVE_LAYER == drawOp);
 #endif
 }
-#endif
 
 void SkPictureRecord::beginRecording() {
     // we have to call this *after* our constructor, to ensure that it gets
@@ -771,18 +725,8 @@ void SkPictureRecord::beginRecording() {
 void SkPictureRecord::endRecording() {
     SkASSERT(kNoInitialSave != fInitialSaveCount);
     this->restoreToCount(fInitialSaveCount);
-#ifdef SK_COLLAPSE_MATRIX_CLIP_STATE
-    fMCMgr.finish();
-#endif
 }
 
-#ifdef SK_COLLAPSE_MATRIX_CLIP_STATE
-int SkPictureRecord::recordRestoreOffsetPlaceholder(SkRegion::Op op) {
-    size_t offset = fWriter.bytesWritten();
-    this->addInt(-1);
-    return offset;
-}
-#else
 size_t SkPictureRecord::recordRestoreOffsetPlaceholder(SkRegion::Op op) {
     if (fRestoreOffsetStack.isEmpty()) {
         return -1;
@@ -812,30 +756,20 @@ size_t SkPictureRecord::recordRestoreOffsetPlaceholder(SkRegion::Op op) {
     fRestoreOffsetStack.top() = SkToU32(offset);
     return offset;
 }
-#endif
 
 void SkPictureRecord::onClipRect(const SkRect& rect, SkRegion::Op op, ClipEdgeStyle edgeStyle) {
-
-#ifdef SK_COLLAPSE_MATRIX_CLIP_STATE
-    fMCMgr.clipRect(rect, op, doAA);
-#else
     this->recordClipRect(rect, op, kSoft_ClipEdgeStyle == edgeStyle);
-#endif
     this->INHERITED::onClipRect(rect, op, edgeStyle);
 }
 
 size_t SkPictureRecord::recordClipRect(const SkRect& rect, SkRegion::Op op, bool doAA) {
     // id + rect + clip params
     size_t size = 1 * kUInt32Size + sizeof(rect) + 1 * kUInt32Size;
-#ifdef SK_COLLAPSE_MATRIX_CLIP_STATE
-    size += kUInt32Size;    // + restore offset
-#else
     // recordRestoreOffsetPlaceholder doesn't always write an offset
     if (!fRestoreOffsetStack.isEmpty()) {
         // + restore offset
         size += kUInt32Size;
     }
-#endif
     size_t initialOffset = this->addDraw(CLIP_RECT, &size);
     this->addRect(rect);
     this->addInt(ClipParams_pack(op, doAA));
@@ -846,27 +780,18 @@ size_t SkPictureRecord::recordClipRect(const SkRect& rect, SkRegion::Op op, bool
 }
 
 void SkPictureRecord::onClipRRect(const SkRRect& rrect, SkRegion::Op op, ClipEdgeStyle edgeStyle) {
-
-#ifdef SK_COLLAPSE_MATRIX_CLIP_STATE
-    fMCMgr.clipRRect(rrect, op, doAA);
-#else
     this->recordClipRRect(rrect, op, kSoft_ClipEdgeStyle == edgeStyle);
-#endif
     this->updateClipConservativelyUsingBounds(rrect.getBounds(), op, false);
 }
 
 size_t SkPictureRecord::recordClipRRect(const SkRRect& rrect, SkRegion::Op op, bool doAA) {
     // op + rrect + clip params
     size_t size = 1 * kUInt32Size + SkRRect::kSizeInMemory + 1 * kUInt32Size;
-#ifdef SK_COLLAPSE_MATRIX_CLIP_STATE
-    size += kUInt32Size;    // + restore offset
-#else
     // recordRestoreOffsetPlaceholder doesn't always write an offset
     if (!fRestoreOffsetStack.isEmpty()) {
         // + restore offset
         size += kUInt32Size;
     }
-#endif
     size_t initialOffset = this->addDraw(CLIP_RRECT, &size);
     this->addRRect(rrect);
     this->addInt(ClipParams_pack(op, doAA));
@@ -876,13 +801,8 @@ size_t SkPictureRecord::recordClipRRect(const SkRRect& rrect, SkRegion::Op op, b
 }
 
 void SkPictureRecord::onClipPath(const SkPath& path, SkRegion::Op op, ClipEdgeStyle edgeStyle) {
-
-#ifdef SK_COLLAPSE_MATRIX_CLIP_STATE
-    fMCMgr.clipPath(path, op, doAA);
-#else
     int pathID = this->addPathToHeap(path);
     this->recordClipPath(pathID, op, kSoft_ClipEdgeStyle == edgeStyle);
-#endif
 
     this->updateClipConservativelyUsingBounds(path.getBounds(), op,
                                               path.isInverseFillType());
@@ -891,15 +811,11 @@ void SkPictureRecord::onClipPath(const SkPath& path, SkRegion::Op op, ClipEdgeSt
 size_t SkPictureRecord::recordClipPath(int pathID, SkRegion::Op op, bool doAA) {
     // op + path index + clip params
     size_t size = 3 * kUInt32Size;
-#ifdef SK_COLLAPSE_MATRIX_CLIP_STATE
-    size += kUInt32Size;    // + restore offset
-#else
     // recordRestoreOffsetPlaceholder doesn't always write an offset
     if (!fRestoreOffsetStack.isEmpty()) {
         // + restore offset
         size += kUInt32Size;
     }
-#endif
     size_t initialOffset = this->addDraw(CLIP_PATH, &size);
     this->addInt(pathID);
     this->addInt(ClipParams_pack(op, doAA));
@@ -909,27 +825,18 @@ size_t SkPictureRecord::recordClipPath(int pathID, SkRegion::Op op, bool doAA) {
 }
 
 void SkPictureRecord::onClipRegion(const SkRegion& region, SkRegion::Op op) {
-
-#ifdef SK_COLLAPSE_MATRIX_CLIP_STATE
-    fMCMgr.clipRegion(region, op);
-#else
     this->recordClipRegion(region, op);
-#endif
     this->INHERITED::onClipRegion(region, op);
 }
 
 size_t SkPictureRecord::recordClipRegion(const SkRegion& region, SkRegion::Op op) {
     // op + clip params + region
     size_t size = 2 * kUInt32Size + region.writeToMemory(NULL);
-#ifdef SK_COLLAPSE_MATRIX_CLIP_STATE
-    size += kUInt32Size;    // + restore offset
-#else
     // recordRestoreOffsetPlaceholder doesn't always write an offset
     if (!fRestoreOffsetStack.isEmpty()) {
         // + restore offset
         size += kUInt32Size;
     }
-#endif
     size_t initialOffset = this->addDraw(CLIP_REGION, &size);
     this->addRegion(region);
     this->addInt(ClipParams_pack(op, false));
@@ -940,11 +847,6 @@ size_t SkPictureRecord::recordClipRegion(const SkRegion& region, SkRegion::Op op
 }
 
 void SkPictureRecord::clear(SkColor color) {
-
-#ifdef SK_COLLAPSE_MATRIX_CLIP_STATE
-    fMCMgr.call(SkMatrixClipStateMgr::kOther_CallType);
-#endif
-
     // op + color
     size_t size = 2 * kUInt32Size;
     size_t initialOffset = this->addDraw(DRAW_CLEAR, &size);
@@ -953,11 +855,6 @@ void SkPictureRecord::clear(SkColor color) {
 }
 
 void SkPictureRecord::drawPaint(const SkPaint& paint) {
-
-#ifdef SK_COLLAPSE_MATRIX_CLIP_STATE
-    fMCMgr.call(SkMatrixClipStateMgr::kOther_CallType);
-#endif
-
     // op + paint index
     size_t size = 2 * kUInt32Size;
     size_t initialOffset = this->addDraw(DRAW_PAINT, &size);
@@ -968,10 +865,6 @@ void SkPictureRecord::drawPaint(const SkPaint& paint) {
 
 void SkPictureRecord::drawPoints(PointMode mode, size_t count, const SkPoint pts[],
                                  const SkPaint& paint) {
-
-#ifdef SK_COLLAPSE_MATRIX_CLIP_STATE
-    fMCMgr.call(SkMatrixClipStateMgr::kOther_CallType);
-#endif
     fContentInfo.onDrawPoints(count, paint);
 
     // op + paint index + mode + count + point data
@@ -987,11 +880,6 @@ void SkPictureRecord::drawPoints(PointMode mode, size_t count, const SkPoint pts
 }
 
 void SkPictureRecord::drawOval(const SkRect& oval, const SkPaint& paint) {
-
-#ifdef SK_COLLAPSE_MATRIX_CLIP_STATE
-    fMCMgr.call(SkMatrixClipStateMgr::kOther_CallType);
-#endif
-
     // op + paint index + rect
     size_t size = 2 * kUInt32Size + sizeof(oval);
     size_t initialOffset = this->addDraw(DRAW_OVAL, &size);
@@ -1002,11 +890,6 @@ void SkPictureRecord::drawOval(const SkRect& oval, const SkPaint& paint) {
 }
 
 void SkPictureRecord::drawRect(const SkRect& rect, const SkPaint& paint) {
-
-#ifdef SK_COLLAPSE_MATRIX_CLIP_STATE
-    fMCMgr.call(SkMatrixClipStateMgr::kOther_CallType);
-#endif
-
     // op + paint index + rect
     size_t size = 2 * kUInt32Size + sizeof(rect);
     size_t initialOffset = this->addDraw(DRAW_RECT, &size);
@@ -1017,11 +900,6 @@ void SkPictureRecord::drawRect(const SkRect& rect, const SkPaint& paint) {
 }
 
 void SkPictureRecord::drawRRect(const SkRRect& rrect, const SkPaint& paint) {
-
-#ifdef SK_COLLAPSE_MATRIX_CLIP_STATE
-    fMCMgr.call(SkMatrixClipStateMgr::kOther_CallType);
-#endif
-
     if (rrect.isRect() && kBeClever) {
         this->SkPictureRecord::drawRect(rrect.getBounds(), paint);
     } else if (rrect.isOval() && kBeClever) {
@@ -1039,11 +917,6 @@ void SkPictureRecord::drawRRect(const SkRRect& rrect, const SkPaint& paint) {
 
 void SkPictureRecord::onDrawDRRect(const SkRRect& outer, const SkRRect& inner,
                                    const SkPaint& paint) {
-
-#ifdef SK_COLLAPSE_MATRIX_CLIP_STATE
-    fMCMgr.call(SkMatrixClipStateMgr::kOther_CallType);
-#endif
-
     // op + paint index + rrects
     size_t size = 2 * kUInt32Size + SkRRect::kSizeInMemory * 2;
     size_t initialOffset = this->addDraw(DRAW_DRRECT, &size);
@@ -1055,13 +928,8 @@ void SkPictureRecord::onDrawDRRect(const SkRRect& outer, const SkRRect& inner,
 }
 
 void SkPictureRecord::drawPath(const SkPath& path, const SkPaint& paint) {
-
     fContentInfo.onDrawPath(path, paint);
 
-#ifdef SK_COLLAPSE_MATRIX_CLIP_STATE
-    fMCMgr.call(SkMatrixClipStateMgr::kOther_CallType);
-#endif
-
     // op + paint index + path index
     size_t size = 3 * kUInt32Size;
     size_t initialOffset = this->addDraw(DRAW_PATH, &size);
@@ -1077,10 +945,6 @@ void SkPictureRecord::drawBitmap(const SkBitmap& bitmap, SkScalar left, SkScalar
         return;
     }
 
-#ifdef SK_COLLAPSE_MATRIX_CLIP_STATE
-    fMCMgr.call(SkMatrixClipStateMgr::kOther_CallType);
-#endif
-
     // op + paint index + bitmap index + left + top
     size_t size = 3 * kUInt32Size + 2 * sizeof(SkScalar);
     size_t initialOffset = this->addDraw(DRAW_BITMAP, &size);
@@ -1099,9 +963,6 @@ void SkPictureRecord::drawBitmapRectToRect(const SkBitmap& bitmap, const SkRect*
         return;
     }
 
-#ifdef SK_COLLAPSE_MATRIX_CLIP_STATE
-    fMCMgr.call(SkMatrixClipStateMgr::kOther_CallType);
-#endif
     // id + paint index + bitmap index + bool for 'src' + flags
     size_t size = 5 * kUInt32Size;
     if (NULL != src) {
@@ -1126,10 +987,6 @@ void SkPictureRecord::drawBitmapMatrix(const SkBitmap& bitmap, const SkMatrix& m
         return;
     }
 
-#ifdef SK_COLLAPSE_MATRIX_CLIP_STATE
-    fMCMgr.call(SkMatrixClipStateMgr::kOther_CallType);
-#endif
-
     // id + paint index + bitmap index + matrix
     size_t size = 3 * kUInt32Size + matrix.writeToMemory(NULL);
     size_t initialOffset = this->addDraw(DRAW_BITMAP_MATRIX, &size);
@@ -1146,10 +1003,6 @@ void SkPictureRecord::drawBitmapNine(const SkBitmap& bitmap, const SkIRect& cent
         return;
     }
 
-#ifdef SK_COLLAPSE_MATRIX_CLIP_STATE
-    fMCMgr.call(SkMatrixClipStateMgr::kOther_CallType);
-#endif
-
     // op + paint index + bitmap id + center + dst rect
     size_t size = 3 * kUInt32Size + sizeof(center) + sizeof(dst);
     size_t initialOffset = this->addDraw(DRAW_BITMAP_NINE, &size);
@@ -1167,10 +1020,6 @@ void SkPictureRecord::drawSprite(const SkBitmap& bitmap, int left, int top,
         return;
     }
 
-#ifdef SK_COLLAPSE_MATRIX_CLIP_STATE
-    fMCMgr.call(SkMatrixClipStateMgr::kOther_CallType);
-#endif
-
     // op + paint index + bitmap index + left + top
     size_t size = 5 * kUInt32Size;
     size_t initialOffset = this->addDraw(DRAW_SPRITE, &size);
@@ -1203,11 +1052,6 @@ void SkPictureRecord::addFontMetricsTopBottom(const SkPaint& paint, const SkFlat
 
 void SkPictureRecord::onDrawText(const void* text, size_t byteLength, SkScalar x, SkScalar y,
                                  const SkPaint& paint) {
-
-#ifdef SK_COLLAPSE_MATRIX_CLIP_STATE
-    fMCMgr.call(SkMatrixClipStateMgr::kOther_CallType);
-#endif
-
     bool fast = !paint.isVerticalText() && paint.canComputeFastBounds() && kBeClever;
 
     // op + paint index + length + 'length' worth of chars + x + y
@@ -1232,11 +1076,6 @@ void SkPictureRecord::onDrawText(const void* text, size_t byteLength, SkScalar x
 
 void SkPictureRecord::onDrawPosText(const void* text, size_t byteLength, const SkPoint pos[],
                                     const SkPaint& paint) {
-
-#ifdef SK_COLLAPSE_MATRIX_CLIP_STATE
-    fMCMgr.call(SkMatrixClipStateMgr::kOther_CallType);
-#endif
-
     int points = paint.countText(text, byteLength);
     if (0 == points)
         return;
@@ -1321,10 +1160,6 @@ void SkPictureRecord::onDrawPosText(const void* text, size_t byteLength, const S
 
 void SkPictureRecord::onDrawPosTextH(const void* text, size_t byteLength, const SkScalar xpos[],
                                      SkScalar constY, const SkPaint& paint) {
-#ifdef SK_COLLAPSE_MATRIX_CLIP_STATE
-    fMCMgr.call(SkMatrixClipStateMgr::kOther_CallType);
-#endif
-
     const SkFlatData* flatPaintData = this->getFlatPaintData(paint);
     this->drawPosTextHImpl(text, byteLength, xpos, constY, paint, flatPaintData);
 }
@@ -1371,10 +1206,6 @@ void SkPictureRecord::drawPosTextHImpl(const void* text, size_t byteLength,
 
 void SkPictureRecord::onDrawTextOnPath(const void* text, size_t byteLength, const SkPath& path,
                                        const SkMatrix* matrix, const SkPaint& paint) {
-#ifdef SK_COLLAPSE_MATRIX_CLIP_STATE
-    fMCMgr.call(SkMatrixClipStateMgr::kOther_CallType);
-#endif
-
     // op + paint index + length + 'length' worth of data + path index + matrix
     const SkMatrix& m = matrix ? *matrix : SkMatrix::I();
     size_t size = 3 * kUInt32Size + SkAlign4(byteLength) + kUInt32Size + m.writeToMemory(NULL);
@@ -1389,11 +1220,6 @@ void SkPictureRecord::onDrawTextOnPath(const void* text, size_t byteLength, cons
 
 void SkPictureRecord::onDrawPicture(const SkPicture* picture, const SkMatrix* matrix,
                                     const SkPaint* paint) {
-
-#ifdef SK_COLLAPSE_MATRIX_CLIP_STATE
-    fMCMgr.call(SkMatrixClipStateMgr::kOther_CallType);
-#endif
-
     // op + picture index
     size_t size = 2 * kUInt32Size;
     size_t initialOffset;
@@ -1417,11 +1243,6 @@ void SkPictureRecord::drawVertices(VertexMode vmode, int vertexCount,
                           const SkColor colors[], SkXfermode* xfer,
                           const uint16_t indices[], int indexCount,
                           const SkPaint& paint) {
-
-#ifdef SK_COLLAPSE_MATRIX_CLIP_STATE
-    fMCMgr.call(SkMatrixClipStateMgr::kOther_CallType);
-#endif
-
     uint32_t flags = 0;
     if (texs) {
         flags |= DRAW_VERTICES_HAS_TEXS;
@@ -1481,10 +1302,6 @@ void SkPictureRecord::drawVertices(VertexMode vmode, int vertexCount,
 }
 
 void SkPictureRecord::drawPatch(const SkPatch& patch, const SkPaint& paint) {
-#ifdef SK_COLLAPSE_MATRIX_CLIP_STATE
-    fMCMgr.call(SkMatrixClipStateMgr::kOther_CallType);
-#endif
-    
     // op + paint index + patch 12 control points + patch 4 colors
     size_t size = 2 * kUInt32Size + SkPatch::kNumCtrlPts * sizeof(SkPoint) +
                     SkPatch::kNumColors * sizeof(SkColor);
@@ -1496,11 +1313,6 @@ void SkPictureRecord::drawPatch(const SkPatch& patch, const SkPaint& paint) {
 }
 
 void SkPictureRecord::drawData(const void* data, size_t length) {
-
-#ifdef SK_COLLAPSE_MATRIX_CLIP_STATE
-    fMCMgr.call(SkMatrixClipStateMgr::kOther_CallType);
-#endif
-
     // op + length + 'length' worth of data
     size_t size = 2 * kUInt32Size + SkAlign4(length);
     size_t initialOffset = this->addDraw(DRAW_DATA, &size);
index 21c1197..ef556b2 100644 (file)
@@ -10,9 +10,6 @@
 
 #include "SkCanvas.h"
 #include "SkFlattenable.h"
-#ifdef SK_COLLAPSE_MATRIX_CLIP_STATE
-#include "SkMatrixClipStateMgr.h"
-#endif
 #include "SkPathHeap.h"
 #include "SkPicture.h"
 #include "SkPictureData.h"
@@ -120,13 +117,11 @@ private:
     size_t recordRestoreOffsetPlaceholder(SkRegion::Op);
     void fillRestoreOffsetPlaceholdersForCurrentStackLevel(uint32_t restoreOffset);
 
-#ifndef SK_COLLAPSE_MATRIX_CLIP_STATE
     SkTDArray<int32_t> fRestoreOffsetStack;
     int fFirstSavedLayerIndex;
     enum {
         kNoSavedLayerIndex = -1
     };
-#endif
 
     SkTDArray<uint32_t> fCullOffsetStack;
 
@@ -310,7 +305,6 @@ protected:
 
 private:
     friend class MatrixClipState; // for access to *Impl methods
-    friend class SkMatrixClipStateMgr; // for access to *Impl methods
 
     SkPictureContentInfo fContentInfo;
     SkAutoTUnref<SkPathHeap> fPathHeap;
@@ -331,10 +325,6 @@ private:
     friend class SkPictureData;   // for SkPictureData's SkPictureRecord-based constructor
     friend class SkPictureTester; // for unit testing
 
-#ifdef SK_COLLAPSE_MATRIX_CLIP_STATE
-    SkMatrixClipStateMgr fMCMgr;
-#endif
-
     typedef SkCanvas INHERITED;
 };