parent
528f97ff14
commit
de358a9946
@ -1081,7 +1081,7 @@ public:
|
||||
* @return the current clip stack ("list" of individual clip elements)
|
||||
*/
|
||||
const SkClipStack* getClipStack() const {
|
||||
return &fClipStack;
|
||||
return fClipStack;
|
||||
}
|
||||
|
||||
typedef SkCanvasClipVisitor ClipVisitor;
|
||||
@ -1243,7 +1243,7 @@ protected:
|
||||
private:
|
||||
class MCRec;
|
||||
|
||||
SkClipStack fClipStack;
|
||||
SkAutoTUnref<SkClipStack> fClipStack;
|
||||
SkDeque fMCStack;
|
||||
// points to top of stack
|
||||
MCRec* fMCRec;
|
||||
|
@ -24,7 +24,7 @@ class SkCanvasClipVisitor;
|
||||
// (i.e., the fSaveCount in force when it was added). Restores are thus
|
||||
// implemented by removing clips from fDeque that have an fSaveCount larger
|
||||
// then the freshly decremented count.
|
||||
class SK_API SkClipStack {
|
||||
class SK_API SkClipStack : public SkNVRefCnt<SkClipStack> {
|
||||
public:
|
||||
enum BoundsType {
|
||||
// The bounding box contains all the pixels that can be written to
|
||||
|
@ -22,8 +22,8 @@ struct SkIRect;
|
||||
*/
|
||||
class GrClipData : SkNoncopyable {
|
||||
public:
|
||||
const SkClipStack* fClipStack;
|
||||
SkIPoint fOrigin;
|
||||
SkAutoTUnref<const SkClipStack> fClipStack;
|
||||
SkIPoint fOrigin;
|
||||
|
||||
GrClipData()
|
||||
: fClipStack(NULL) {
|
||||
|
@ -700,7 +700,7 @@ public:
|
||||
AutoClip(GrContext* context, InitialClip SkDEBUGCODE(initialState))
|
||||
: fContext(context) {
|
||||
SkASSERT(kWideOpen_InitialClip == initialState);
|
||||
fNewClipData.fClipStack = &fNewClipStack;
|
||||
fNewClipData.fClipStack.reset(SkRef(&fNewClipStack));
|
||||
|
||||
fOldClip = context->getClip();
|
||||
context->setClip(&fNewClipData);
|
||||
@ -709,7 +709,7 @@ public:
|
||||
AutoClip(GrContext* context, const SkRect& newClipRect)
|
||||
: fContext(context)
|
||||
, fNewClipStack(newClipRect) {
|
||||
fNewClipData.fClipStack = &fNewClipStack;
|
||||
fNewClipData.fClipStack.reset(SkRef(&fNewClipStack));
|
||||
|
||||
fOldClip = fContext->getClip();
|
||||
fContext->setClip(&fNewClipData);
|
||||
|
@ -232,7 +232,7 @@ public:
|
||||
fCanvas = canvas;
|
||||
canvas->updateDeviceCMCache();
|
||||
|
||||
fClipStack = &canvas->fClipStack;
|
||||
fClipStack = canvas->fClipStack.get();
|
||||
fCurrLayer = canvas->fMCRec->fTopLayer;
|
||||
fSkipEmptyClips = skipEmptyClips;
|
||||
}
|
||||
@ -442,6 +442,8 @@ SkBaseDevice* SkCanvas::init(SkBaseDevice* device, InitFlags flags) {
|
||||
|
||||
fSurfaceBase = NULL;
|
||||
|
||||
fClipStack.reset(SkNEW(SkClipStack));
|
||||
|
||||
if (device) {
|
||||
device->initForRootLayer(fProps.pixelGeometry());
|
||||
if (device->forceConservativeRasterClip()) {
|
||||
@ -788,11 +790,11 @@ void SkCanvas::updateDeviceCMCache() {
|
||||
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;
|
||||
@ -869,7 +871,7 @@ void SkCanvas::internalSave() {
|
||||
new (newTop) MCRec(*fMCRec); // balanced in restore()
|
||||
fMCRec = newTop;
|
||||
|
||||
fClipStack.save();
|
||||
fClipStack->save();
|
||||
}
|
||||
|
||||
static bool bounds_affects_clip(SkCanvas::SaveFlags flags) {
|
||||
@ -911,7 +913,7 @@ bool SkCanvas::clipRectBounds(const SkRect* bounds, SaveFlags flags,
|
||||
}
|
||||
|
||||
if (bounds_affects_clip(flags)) {
|
||||
fClipStack.clipDevRect(ir, op);
|
||||
fClipStack->clipDevRect(ir, op);
|
||||
// early exit if the clip is now empty
|
||||
if (!fMCRec->fRasterClip.op(ir, op)) {
|
||||
return false;
|
||||
@ -1033,7 +1035,7 @@ void SkCanvas::internalRestore() {
|
||||
fDeviceCMDirty = true;
|
||||
fCachedLocalClipBoundsDirty = true;
|
||||
|
||||
fClipStack.restore();
|
||||
fClipStack->restore();
|
||||
|
||||
// reserve our layer (if any)
|
||||
DeviceCM* layer = fMCRec->fLayer; // may be null
|
||||
@ -1338,7 +1340,7 @@ void SkCanvas::onClipRect(const SkRect& rect, SkRegion::Op op, ClipEdgeStyle edg
|
||||
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
|
||||
@ -1378,7 +1380,7 @@ void SkCanvas::onClipRRect(const SkRRect& rrect, SkRegion::Op op, ClipEdgeStyle
|
||||
edgeStyle = kHard_ClipEdgeStyle;
|
||||
}
|
||||
|
||||
fClipStack.clipDevRRect(transformedRRect, op, kSoft_ClipEdgeStyle == edgeStyle);
|
||||
fClipStack->clipDevRRect(transformedRRect, op, kSoft_ClipEdgeStyle == edgeStyle);
|
||||
|
||||
SkPath devPath;
|
||||
devPath.addRRect(transformedRRect);
|
||||
@ -1443,7 +1445,7 @@ void SkCanvas::onClipPath(const SkPath& path, SkRegion::Op op, ClipEdgeStyle edg
|
||||
}
|
||||
|
||||
// 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);
|
||||
@ -1470,7 +1472,7 @@ void SkCanvas::onClipRegion(const SkRegion& rgn, SkRegion::Op op) {
|
||||
|
||||
// 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);
|
||||
}
|
||||
@ -1488,7 +1490,7 @@ void SkCanvas::validateClip() const {
|
||||
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()) {
|
||||
@ -1511,7 +1513,7 @@ void SkCanvas::validateClip() const {
|
||||
#endif
|
||||
|
||||
void SkCanvas::replayClips(ClipVisitor* visitor) const {
|
||||
SkClipStack::B2TIter iter(fClipStack);
|
||||
SkClipStack::B2TIter iter(*fClipStack);
|
||||
const SkClipStack::Element* element;
|
||||
|
||||
while ((element = iter.next()) != NULL) {
|
||||
|
@ -880,7 +880,7 @@ GrDrawTarget::AutoClipRestore::AutoClipRestore(GrDrawTarget* target, const SkIRe
|
||||
fClip = fTarget->getClip();
|
||||
fStack.init();
|
||||
fStack.get()->clipDevRect(newClip, SkRegion::kReplace_Op);
|
||||
fReplacementClip.fClipStack = fStack.get();
|
||||
fReplacementClip.fClipStack.reset(SkRef(fStack.get()));
|
||||
target->setClip(&fReplacementClip);
|
||||
}
|
||||
|
||||
|
@ -280,12 +280,12 @@ void SkGpuDevice::onAttachToCanvas(SkCanvas* canvas) {
|
||||
INHERITED::onAttachToCanvas(canvas);
|
||||
|
||||
// Canvas promises that this ptr is valid until onDetachFromCanvas is called
|
||||
fClipData.fClipStack = canvas->getClipStack();
|
||||
fClipData.fClipStack.reset(SkRef(canvas->getClipStack()));
|
||||
}
|
||||
|
||||
void SkGpuDevice::onDetachFromCanvas() {
|
||||
INHERITED::onDetachFromCanvas();
|
||||
fClipData.fClipStack = NULL;
|
||||
fClipData.fClipStack.reset(NULL);
|
||||
}
|
||||
|
||||
// call this every draw call, to ensure that the context reflects our state,
|
||||
|
@ -86,7 +86,7 @@ static void test_clip_bounds(skiatest::Reporter* reporter, GrContext* context) {
|
||||
|
||||
// wrap the SkClipStack in a GrClipData
|
||||
GrClipData clipData;
|
||||
clipData.fClipStack = &stack;
|
||||
clipData.fClipStack.reset(SkRef(&stack));
|
||||
|
||||
SkIRect devGrClipDataBound;
|
||||
clipData.getConservativeBounds(texture,
|
||||
|
@ -249,7 +249,7 @@ bool GrDrawTarget::programUnitTest(int maxStages) {
|
||||
|
||||
// wrap the SkClipStack in a GrClipData
|
||||
GrClipData clipData;
|
||||
clipData.fClipStack = &stack;
|
||||
clipData.fClipStack.reset(SkRef(&stack));
|
||||
this->setClip(&clipData);
|
||||
|
||||
SkRandom random;
|
||||
|
Loading…
Reference in New Issue
Block a user