diff options
Diffstat (limited to 'src/gpu/SkGpuDevice.cpp')
-rw-r--r-- | src/gpu/SkGpuDevice.cpp | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/src/gpu/SkGpuDevice.cpp b/src/gpu/SkGpuDevice.cpp index 0197a6e663..791d4353c7 100644 --- a/src/gpu/SkGpuDevice.cpp +++ b/src/gpu/SkGpuDevice.cpp @@ -236,7 +236,12 @@ bool SkGpuDevice::onAccessPixels(SkPixmap* pmap) { void SkGpuDevice::prepareDraw(const SkDraw& draw) { ASSERT_SINGLE_OWNER +#ifdef SK_USE_DEVICE_CLIPPING + SkASSERT(*draw.fMatrix == this->ctm()); + fClip.reset(&fClipStack, nullptr); +#else fClip.reset(draw.fClipStack, &this->getOrigin()); +#endif } GrRenderTargetContext* SkGpuDevice::accessRenderTargetContext() { @@ -1820,4 +1825,54 @@ SkImageFilterCache* SkGpuDevice::getImageFilterCache() { return SkImageFilterCache::Create(SkImageFilterCache::kDefaultTransientSize); } +/////////////////////////////////////////////////////////////////////////////////////////////////// + +void SkGpuDevice::onSave() { + fClipStack.save(); +} + +void SkGpuDevice::onRestore() { + fClipStack.restore(); +} + +void SkGpuDevice::onClipRect(const SkRect& rect, SkClipOp op, bool aa) { + fClipStack.clipRect(rect, this->ctm(), op, aa); +} + +void SkGpuDevice::onClipRRect(const SkRRect& rrect, SkClipOp op, bool aa) { + fClipStack.clipRRect(rrect, this->ctm(), op, aa); +} + +void SkGpuDevice::onClipPath(const SkPath& path, SkClipOp op, bool aa) { + fClipStack.clipPath(path, this->ctm(), op, aa); +} + +void SkGpuDevice::onClipRegion(const SkRegion& rgn, SkClipOp op) { + SkIPoint origin = this->getOrigin(); + SkRegion tmp; + const SkRegion* ptr = &rgn; + if (origin.fX | origin.fY) { + // translate from "global/canvas" coordinates to relative to this device + rgn.translate(-origin.fX, -origin.fY, &tmp); + ptr = &tmp; + } + fClipStack.clipDevRect(ptr->getBounds(), op); +} + +void SkGpuDevice::onSetDeviceClipRestriction(SkIRect* clipRestriction) { + if (clipRestriction->isEmpty()) { + fClipStack.setDeviceClipRestriction(*clipRestriction); + } else { + SkIPoint origin = this->getOrigin(); + SkIRect rect = clipRestriction->makeOffset(-origin.x(), -origin.y()); + fClipStack.setDeviceClipRestriction(rect); + fClipStack.clipDevRect(rect, SkClipOp::kIntersect); + } +} + +void SkGpuDevice::validateDevBounds(const SkIRect& drawClipBounds) { +#ifdef SK_DEBUG +#endif +} + #endif |