fCanvas = canvas;
canvas->updateDeviceCMCache();
- fClipStack = canvas->fClipStack.get();
+ fClipStack = &canvas->fClipStack;
fCurrLayer = canvas->fMCRec->fTopLayer;
fSkipEmptyClips = skipEmptyClips;
}
fMCRec = (MCRec*)fMCStack.push_back();
new (fMCRec) MCRec(fConservativeRasterClip);
- fMCRec->fLayer = SkNEW_ARGS(DeviceCM, (NULL, NULL, NULL, fConservativeRasterClip));
+ SkASSERT(sizeof(DeviceCM) <= sizeof(fBaseLayerStorage));
+ fMCRec->fLayer = (DeviceCM*)fBaseLayerStorage;
+ new (fBaseLayerStorage) DeviceCM(NULL, NULL, NULL, fConservativeRasterClip);
+
fMCRec->fTopLayer = fMCRec->fLayer;
fSurfaceBase = NULL;
- fClipStack.reset(SkNEW(SkClipStack));
-
if (device) {
device->initForRootLayer(fProps.pixelGeometry());
if (device->forceConservativeRasterClip()) {
DeviceCM* layer = fMCRec->fTopLayer;
if (NULL == layer->fNext) { // only one layer
- layer->updateMC(totalMatrix, totalClip, *fClipStack, NULL);
+ layer->updateMC(totalMatrix, totalClip, fClipStack, NULL);
} else {
SkRasterClip clip(totalClip);
do {
- layer->updateMC(totalMatrix, clip, *fClipStack, &clip);
+ layer->updateMC(totalMatrix, clip, fClipStack, &clip);
} while ((layer = layer->fNext) != NULL);
}
fDeviceCMDirty = false;
new (newTop) MCRec(*fMCRec); // balanced in restore()
fMCRec = newTop;
- fClipStack->save();
+ fClipStack.save();
}
static bool bounds_affects_clip(SkCanvas::SaveFlags flags) {
if (bounds_affects_clip(flags)) {
// Simplify the current clips since they will be applied properly during restore()
fCachedLocalClipBoundsDirty = true;
- fClipStack->clipDevRect(ir, SkRegion::kReplace_Op);
+ fClipStack.clipDevRect(ir, SkRegion::kReplace_Op);
fMCRec->fRasterClip.setRect(ir);
}
fDeviceCMDirty = true;
fCachedLocalClipBoundsDirty = true;
- fClipStack->restore();
+ fClipStack.restore();
// reserve our layer (if any)
DeviceCM* layer = fMCRec->fLayer; // may be null
layer->fPaint);
// reset this, since internalDrawDevice will have set it to true
fDeviceCMDirty = true;
+ SkDELETE(layer);
+ } else {
+ // we're at the root
+ SkASSERT(layer == (void*)fBaseLayerStorage);
+ layer->~DeviceCM();
}
- SkDELETE(layer);
}
}
SkRect r;
fMCRec->fMatrix.mapRect(&r, rect);
- fClipStack->clipDevRect(r, op, kSoft_ClipEdgeStyle == edgeStyle);
+ fClipStack.clipDevRect(r, op, kSoft_ClipEdgeStyle == edgeStyle);
fMCRec->fRasterClip.op(r, this->getBaseLayerSize(), op, kSoft_ClipEdgeStyle == edgeStyle);
} else {
// since we're rotated or some such thing, we convert the rect to a path
edgeStyle = kHard_ClipEdgeStyle;
}
- fClipStack->clipDevRRect(transformedRRect, op, kSoft_ClipEdgeStyle == edgeStyle);
+ fClipStack.clipDevRRect(transformedRRect, op, kSoft_ClipEdgeStyle == edgeStyle);
SkPath devPath;
devPath.addRRect(transformedRRect);
}
// if we called path.swap() we could avoid a deep copy of this path
- fClipStack->clipDevPath(devPath, op, kSoft_ClipEdgeStyle == edgeStyle);
+ fClipStack.clipDevPath(devPath, op, kSoft_ClipEdgeStyle == edgeStyle);
if (fAllowSimplifyClip) {
bool clipIsAA = getClipStack()->asPath(&devPath);
// todo: signal fClipStack that we have a region, and therefore (I guess)
// we have to ignore it, and use the region directly?
- fClipStack->clipDevRect(rgn.getBounds(), op);
+ fClipStack.clipDevRect(rgn.getBounds(), op);
fMCRec->fRasterClip.op(rgn, op);
}
ir.set(0, 0, device->width(), device->height());
SkRasterClip tmpClip(ir, fConservativeRasterClip);
- SkClipStack::B2TIter iter(*fClipStack);
+ SkClipStack::B2TIter iter(fClipStack);
const SkClipStack::Element* element;
while ((element = iter.next()) != NULL) {
switch (element->getType()) {
#endif
void SkCanvas::replayClips(ClipVisitor* visitor) const {
- SkClipStack::B2TIter iter(*fClipStack);
+ SkClipStack::B2TIter iter(fClipStack);
const SkClipStack::Element* element;
while ((element = iter.next()) != NULL) {