Rename SkDevice::ctm() to localToDevice()
This helps differentiate the SkCanvas' total CTM (canvas transform matrix), from the device-specific transform matrix that maps draws from local to device space. Bug: 9545 Change-Id: I67f40d9b1bc92377bf0520fbc9245f1058e179e6 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/249424 Commit-Queue: Michael Ludwig <michaelludwig@google.com> Reviewed-by: Mike Reed <reed@google.com>
This commit is contained in:
parent
3085d9ac7d
commit
c89d1b56e5
@ -91,7 +91,7 @@ public:
|
|||||||
// fSrcBounds = devBounds.roundOut();
|
// fSrcBounds = devBounds.roundOut();
|
||||||
// The problem being that the promotion of clipR to SkRect was unreliable
|
// The problem being that the promotion of clipR to SkRect was unreliable
|
||||||
//
|
//
|
||||||
fSrcBounds = dev->ctm().mapRect(*bounds).roundOut();
|
fSrcBounds = dev->localToDevice().mapRect(*bounds).roundOut();
|
||||||
if (fSrcBounds.intersect(clipR)) {
|
if (fSrcBounds.intersect(clipR)) {
|
||||||
// Check again, now that we have computed srcbounds.
|
// Check again, now that we have computed srcbounds.
|
||||||
fNeedsTiling = fSrcBounds.right() > kMaxDim || fSrcBounds.bottom() > kMaxDim;
|
fNeedsTiling = fSrcBounds.right() > kMaxDim || fSrcBounds.bottom() > kMaxDim;
|
||||||
@ -113,7 +113,7 @@ public:
|
|||||||
} else {
|
} else {
|
||||||
// don't reference fSrcBounds, as it may not have been set
|
// don't reference fSrcBounds, as it may not have been set
|
||||||
fDraw.fDst = fRootPixmap;
|
fDraw.fDst = fRootPixmap;
|
||||||
fDraw.fMatrix = &dev->ctm();
|
fDraw.fMatrix = &dev->localToDevice();
|
||||||
fDraw.fRC = &dev->fRCStack.rc();
|
fDraw.fRC = &dev->fRCStack.rc();
|
||||||
fOrigin.set(0, 0);
|
fOrigin.set(0, 0);
|
||||||
|
|
||||||
@ -165,7 +165,7 @@ private:
|
|||||||
SkASSERT_RELEASE(success);
|
SkASSERT_RELEASE(success);
|
||||||
// now don't use bounds, since fDst has the clipped dimensions.
|
// now don't use bounds, since fDst has the clipped dimensions.
|
||||||
|
|
||||||
fTileMatrix = fDevice->ctm();
|
fTileMatrix = fDevice->localToDevice();
|
||||||
fTileMatrix.postTranslate(SkIntToScalar(-fOrigin.x()), SkIntToScalar(-fOrigin.y()));
|
fTileMatrix.postTranslate(SkIntToScalar(-fOrigin.x()), SkIntToScalar(-fOrigin.y()));
|
||||||
fDevice->fRCStack.rc().translate(-fOrigin.x(), -fOrigin.y(), &fTileRC);
|
fDevice->fRCStack.rc().translate(-fOrigin.x(), -fOrigin.y(), &fTileRC);
|
||||||
fTileRC.op(SkIRect::MakeWH(fDraw.fDst.width(), fDraw.fDst.height()),
|
fTileRC.op(SkIRect::MakeWH(fDraw.fDst.width(), fDraw.fDst.height()),
|
||||||
@ -192,7 +192,7 @@ public:
|
|||||||
// NoDrawDevice uses us (why?) so we have to catch this case w/ no pixels
|
// NoDrawDevice uses us (why?) so we have to catch this case w/ no pixels
|
||||||
fDst.reset(dev->imageInfo(), nullptr, 0);
|
fDst.reset(dev->imageInfo(), nullptr, 0);
|
||||||
}
|
}
|
||||||
fMatrix = &dev->ctm();
|
fMatrix = &dev->localToDevice();
|
||||||
fRC = &dev->fRCStack.rc();
|
fRC = &dev->fRCStack.rc();
|
||||||
fCoverage = dev->accessCoverage();
|
fCoverage = dev->accessCoverage();
|
||||||
}
|
}
|
||||||
@ -446,7 +446,7 @@ void SkBitmapDevice::drawBitmapRect(const SkBitmap& bitmap,
|
|||||||
}
|
}
|
||||||
matrix.setRectToRect(tmpSrc, dst, SkMatrix::kFill_ScaleToFit);
|
matrix.setRectToRect(tmpSrc, dst, SkMatrix::kFill_ScaleToFit);
|
||||||
|
|
||||||
LogDrawScaleFactor(this->ctm(), matrix, paint.getFilterQuality());
|
LogDrawScaleFactor(this->localToDevice(), matrix, paint.getFilterQuality());
|
||||||
|
|
||||||
const SkRect* dstPtr = &dst;
|
const SkRect* dstPtr = &dst;
|
||||||
const SkBitmap* bitmapPtr = &bitmap;
|
const SkBitmap* bitmapPtr = &bitmap;
|
||||||
@ -565,7 +565,8 @@ void SkBitmapDevice::drawDevice(SkBaseDevice* device, int x, int y, const SkPain
|
|||||||
// todo: can we unify with similar adjustment in SkGpuDevice?
|
// todo: can we unify with similar adjustment in SkGpuDevice?
|
||||||
SkTCopyOnFirstWrite<SkPaint> paint(origPaint);
|
SkTCopyOnFirstWrite<SkPaint> paint(origPaint);
|
||||||
if (paint->getMaskFilter()) {
|
if (paint->getMaskFilter()) {
|
||||||
paint.writable()->setMaskFilter(paint->getMaskFilter()->makeWithMatrix(this->ctm()));
|
paint.writable()->setMaskFilter(
|
||||||
|
paint->getMaskFilter()->makeWithMatrix(this->localToDevice()));
|
||||||
}
|
}
|
||||||
|
|
||||||
// hack to test coverage
|
// hack to test coverage
|
||||||
@ -603,20 +604,20 @@ class SkAutoDeviceClipRestore {
|
|||||||
public:
|
public:
|
||||||
SkAutoDeviceClipRestore(SkBaseDevice* device, const SkIRect& clip)
|
SkAutoDeviceClipRestore(SkBaseDevice* device, const SkIRect& clip)
|
||||||
: fDevice(device)
|
: fDevice(device)
|
||||||
, fPrevCTM(device->ctm()) {
|
, fPrevLocalToDevice(device->localToDevice()) {
|
||||||
fDevice->save();
|
fDevice->save();
|
||||||
fDevice->setCTM(SkMatrix::I());
|
fDevice->setLocalToDevice(SkMatrix::I());
|
||||||
fDevice->clipRect(SkRect::Make(clip), SkClipOp::kIntersect, false);
|
fDevice->clipRect(SkRect::Make(clip), SkClipOp::kIntersect, false);
|
||||||
fDevice->setCTM(fPrevCTM);
|
fDevice->setLocalToDevice(fPrevLocalToDevice);
|
||||||
}
|
}
|
||||||
|
|
||||||
~SkAutoDeviceClipRestore() {
|
~SkAutoDeviceClipRestore() {
|
||||||
fDevice->restore(fPrevCTM);
|
fDevice->restoreLocal(fPrevLocalToDevice);
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
SkBaseDevice* fDevice;
|
SkBaseDevice* fDevice;
|
||||||
const SkMatrix fPrevCTM;
|
const SkMatrix fPrevLocalToDevice;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // anonymous ns
|
} // anonymous ns
|
||||||
@ -631,7 +632,7 @@ void SkBitmapDevice::drawSpecial(SkSpecialImage* src, int x, int y, const SkPain
|
|||||||
if (SkImageFilter* filter = paint->getImageFilter()) {
|
if (SkImageFilter* filter = paint->getImageFilter()) {
|
||||||
SkIPoint offset = SkIPoint::Make(0, 0);
|
SkIPoint offset = SkIPoint::Make(0, 0);
|
||||||
const SkMatrix matrix = SkMatrix::Concat(
|
const SkMatrix matrix = SkMatrix::Concat(
|
||||||
SkMatrix::MakeTrans(SkIntToScalar(-x), SkIntToScalar(-y)), this->ctm());
|
SkMatrix::MakeTrans(SkIntToScalar(-x), SkIntToScalar(-y)), this->localToDevice());
|
||||||
const SkIRect clipBounds = fRCStack.rc().getBounds().makeOffset(-x, -y);
|
const SkIRect clipBounds = fRCStack.rc().getBounds().makeOffset(-x, -y);
|
||||||
sk_sp<SkImageFilterCache> cache(this->getImageFilterCache());
|
sk_sp<SkImageFilterCache> cache(this->getImageFilterCache());
|
||||||
SkImageFilter_Base::Context ctx(matrix, clipBounds, cache.get(), fBitmap.colorType(),
|
SkImageFilter_Base::Context ctx(matrix, clipBounds, cache.get(), fBitmap.colorType(),
|
||||||
@ -649,7 +650,8 @@ void SkBitmapDevice::drawSpecial(SkSpecialImage* src, int x, int y, const SkPain
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (paint->getMaskFilter()) {
|
if (paint->getMaskFilter()) {
|
||||||
paint.writable()->setMaskFilter(paint->getMaskFilter()->makeWithMatrix(this->ctm()));
|
paint.writable()->setMaskFilter(
|
||||||
|
paint->getMaskFilter()->makeWithMatrix(this->localToDevice()));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!clipImage) {
|
if (!clipImage) {
|
||||||
@ -666,7 +668,7 @@ void SkBitmapDevice::drawSpecial(SkSpecialImage* src, int x, int y, const SkPain
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const SkMatrix totalMatrix = SkMatrix::Concat(this->ctm(), clipMatrix);
|
const SkMatrix totalMatrix = SkMatrix::Concat(this->localToDevice(), clipMatrix);
|
||||||
SkRect clipBounds;
|
SkRect clipBounds;
|
||||||
totalMatrix.mapRect(&clipBounds, SkRect::Make(clipImage->bounds()));
|
totalMatrix.mapRect(&clipBounds, SkRect::Make(clipImage->bounds()));
|
||||||
const SkIRect srcBounds = srcImage->bounds().makeOffset(x, y);
|
const SkIRect srcBounds = srcImage->bounds().makeOffset(x, y);
|
||||||
@ -708,7 +710,7 @@ void SkBitmapDevice::drawSpecial(SkSpecialImage* src, int x, int y, const SkPain
|
|||||||
shaderMatrix = SkMatrix::MakeTrans(x - maskBounds.x(), y - maskBounds.y());
|
shaderMatrix = SkMatrix::MakeTrans(x - maskBounds.x(), y - maskBounds.y());
|
||||||
}
|
}
|
||||||
|
|
||||||
SkAutoDeviceCTMRestore adctmr(this, maskMatrix);
|
SkAutoDeviceTransformRestore adr(this, maskMatrix);
|
||||||
paint.writable()->setShader(srcImage->makeShader(&shaderMatrix));
|
paint.writable()->setShader(srcImage->makeShader(&shaderMatrix));
|
||||||
this->drawImageRect(mask.get(), nullptr,
|
this->drawImageRect(mask.get(), nullptr,
|
||||||
SkRect::MakeXYWH(maskBounds.x(), maskBounds.y(),
|
SkRect::MakeXYWH(maskBounds.x(), maskBounds.y(),
|
||||||
@ -756,15 +758,15 @@ void SkBitmapDevice::onRestore() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void SkBitmapDevice::onClipRect(const SkRect& rect, SkClipOp op, bool aa) {
|
void SkBitmapDevice::onClipRect(const SkRect& rect, SkClipOp op, bool aa) {
|
||||||
fRCStack.clipRect(this->ctm(), rect, op, aa);
|
fRCStack.clipRect(this->localToDevice(), rect, op, aa);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SkBitmapDevice::onClipRRect(const SkRRect& rrect, SkClipOp op, bool aa) {
|
void SkBitmapDevice::onClipRRect(const SkRRect& rrect, SkClipOp op, bool aa) {
|
||||||
fRCStack.clipRRect(this->ctm(), rrect, op, aa);
|
fRCStack.clipRRect(this->localToDevice(), rrect, op, aa);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SkBitmapDevice::onClipPath(const SkPath& path, SkClipOp op, bool aa) {
|
void SkBitmapDevice::onClipPath(const SkPath& path, SkClipOp op, bool aa) {
|
||||||
fRCStack.clipPath(this->ctm(), path, op, aa);
|
fRCStack.clipPath(this->localToDevice(), path, op, aa);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SkBitmapDevice::onClipRegion(const SkRegion& rgn, SkClipOp op) {
|
void SkBitmapDevice::onClipRegion(const SkRegion& rgn, SkClipOp op) {
|
||||||
|
@ -1028,11 +1028,11 @@ void SkCanvas::DrawDeviceWithFilter(SkBaseDevice* src, const SkImageFilter* filt
|
|||||||
|
|
||||||
// Manually setting the device's CTM requires accounting for the device's origin.
|
// Manually setting the device's CTM requires accounting for the device's origin.
|
||||||
// TODO (michaelludwig) - This could be simpler if the dst device had its origin configured
|
// TODO (michaelludwig) - This could be simpler if the dst device had its origin configured
|
||||||
// before filtering the backdrop device, and if SkAutoDeviceCTMRestore had a way to accept
|
// before filtering the backdrop device, and if SkAutoDeviceTransformRestore had a way to accept
|
||||||
// a global CTM instead of a device CTM.
|
// a global CTM instead of a device CTM.
|
||||||
SkMatrix dstCTM = toRoot;
|
SkMatrix dstCTM = toRoot;
|
||||||
dstCTM.postTranslate(-dstOrigin.x(), -dstOrigin.y());
|
dstCTM.postTranslate(-dstOrigin.x(), -dstOrigin.y());
|
||||||
SkAutoDeviceCTMRestore acr(dst, dstCTM);
|
SkAutoDeviceTransformRestore adr(dst, dstCTM);
|
||||||
|
|
||||||
// And because devices don't have a special-image draw function that supports arbitrary
|
// And because devices don't have a special-image draw function that supports arbitrary
|
||||||
// matrices, we are abusing the asImage() functionality here...
|
// matrices, we are abusing the asImage() functionality here...
|
||||||
@ -2434,7 +2434,7 @@ void SkCanvas::onDrawImage(const SkImage* image, SkScalar x, SkScalar y, const S
|
|||||||
const SkPaint& pnt = draw.paint();
|
const SkPaint& pnt = draw.paint();
|
||||||
if (special) {
|
if (special) {
|
||||||
SkPoint pt;
|
SkPoint pt;
|
||||||
iter.fDevice->ctm().mapXY(x, y, &pt);
|
iter.fDevice->localToDevice().mapXY(x, y, &pt);
|
||||||
iter.fDevice->drawSpecial(special.get(),
|
iter.fDevice->drawSpecial(special.get(),
|
||||||
SkScalarRoundToInt(pt.fX),
|
SkScalarRoundToInt(pt.fX),
|
||||||
SkScalarRoundToInt(pt.fY), pnt,
|
SkScalarRoundToInt(pt.fY), pnt,
|
||||||
@ -2512,7 +2512,7 @@ void SkCanvas::onDrawBitmap(const SkBitmap& bitmap, SkScalar x, SkScalar y, cons
|
|||||||
const SkPaint& pnt = draw.paint();
|
const SkPaint& pnt = draw.paint();
|
||||||
if (special) {
|
if (special) {
|
||||||
SkPoint pt;
|
SkPoint pt;
|
||||||
iter.fDevice->ctm().mapXY(x, y, &pt);
|
iter.fDevice->localToDevice().mapXY(x, y, &pt);
|
||||||
iter.fDevice->drawSpecial(special.get(),
|
iter.fDevice->drawSpecial(special.get(),
|
||||||
SkScalarRoundToInt(pt.fX),
|
SkScalarRoundToInt(pt.fX),
|
||||||
SkScalarRoundToInt(pt.fY), pnt,
|
SkScalarRoundToInt(pt.fY), pnt,
|
||||||
@ -3003,7 +3003,7 @@ SkBaseDevice* SkCanvas::LayerIter::device() const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const SkMatrix& SkCanvas::LayerIter::matrix() const {
|
const SkMatrix& SkCanvas::LayerIter::matrix() const {
|
||||||
return fImpl->fDevice->ctm();
|
return fImpl->fDevice->localToDevice();
|
||||||
}
|
}
|
||||||
|
|
||||||
const SkPaint& SkCanvas::LayerIter::paint() const {
|
const SkPaint& SkCanvas::LayerIter::paint() const {
|
||||||
|
@ -28,15 +28,15 @@ void SkClipStackDevice::onRestore() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void SkClipStackDevice::onClipRect(const SkRect& rect, SkClipOp op, bool aa) {
|
void SkClipStackDevice::onClipRect(const SkRect& rect, SkClipOp op, bool aa) {
|
||||||
fClipStack.clipRect(rect, this->ctm(), op, aa);
|
fClipStack.clipRect(rect, this->localToDevice(), op, aa);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SkClipStackDevice::onClipRRect(const SkRRect& rrect, SkClipOp op, bool aa) {
|
void SkClipStackDevice::onClipRRect(const SkRRect& rrect, SkClipOp op, bool aa) {
|
||||||
fClipStack.clipRRect(rrect, this->ctm(), op, aa);
|
fClipStack.clipRRect(rrect, this->localToDevice(), op, aa);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SkClipStackDevice::onClipPath(const SkPath& path, SkClipOp op, bool aa) {
|
void SkClipStackDevice::onClipPath(const SkPath& path, SkClipOp op, bool aa) {
|
||||||
fClipStack.clipPath(path, this->ctm(), op, aa);
|
fClipStack.clipPath(path, this->localToDevice(), op, aa);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SkClipStackDevice::onClipRegion(const SkRegion& rgn, SkClipOp op) {
|
void SkClipStackDevice::onClipRegion(const SkRegion& rgn, SkClipOp op) {
|
||||||
|
@ -37,19 +37,19 @@ SkBaseDevice::SkBaseDevice(const SkImageInfo& info, const SkSurfaceProps& surfac
|
|||||||
, fSurfaceProps(surfaceProps)
|
, fSurfaceProps(surfaceProps)
|
||||||
{
|
{
|
||||||
fOrigin = {0, 0};
|
fOrigin = {0, 0};
|
||||||
fCTM.reset();
|
fLocalToDevice.reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
void SkBaseDevice::setOrigin(const SkMatrix& globalCTM, int x, int y) {
|
void SkBaseDevice::setOrigin(const SkMatrix& globalCTM, int x, int y) {
|
||||||
fOrigin.set(x, y);
|
fOrigin.set(x, y);
|
||||||
fCTM = globalCTM;
|
fLocalToDevice = globalCTM;
|
||||||
fCTM.postTranslate(SkIntToScalar(-x), SkIntToScalar(-y));
|
fLocalToDevice.postTranslate(SkIntToScalar(-x), SkIntToScalar(-y));
|
||||||
}
|
}
|
||||||
|
|
||||||
void SkBaseDevice::setGlobalCTM(const SkMatrix& ctm) {
|
void SkBaseDevice::setGlobalCTM(const SkMatrix& ctm) {
|
||||||
fCTM = ctm;
|
fLocalToDevice = ctm;
|
||||||
if (fOrigin.fX | fOrigin.fY) {
|
if (fOrigin.fX | fOrigin.fY) {
|
||||||
fCTM.postTranslate(-SkIntToScalar(fOrigin.fX), -SkIntToScalar(fOrigin.fY));
|
fLocalToDevice.postTranslate(-SkIntToScalar(fOrigin.fX), -SkIntToScalar(fOrigin.fY));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -83,12 +83,12 @@ static inline bool is_int(float x) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void SkBaseDevice::drawRegion(const SkRegion& region, const SkPaint& paint) {
|
void SkBaseDevice::drawRegion(const SkRegion& region, const SkPaint& paint) {
|
||||||
const SkMatrix& ctm = this->ctm();
|
const SkMatrix& localToDevice = this->localToDevice();
|
||||||
bool isNonTranslate = ctm.getType() & ~(SkMatrix::kTranslate_Mask);
|
bool isNonTranslate = localToDevice.getType() & ~(SkMatrix::kTranslate_Mask);
|
||||||
bool complexPaint = paint.getStyle() != SkPaint::kFill_Style || paint.getMaskFilter() ||
|
bool complexPaint = paint.getStyle() != SkPaint::kFill_Style || paint.getMaskFilter() ||
|
||||||
paint.getPathEffect();
|
paint.getPathEffect();
|
||||||
bool antiAlias = paint.isAntiAlias() && (!is_int(ctm.getTranslateX()) ||
|
bool antiAlias = paint.isAntiAlias() && (!is_int(localToDevice.getTranslateX()) ||
|
||||||
!is_int(ctm.getTranslateY()));
|
!is_int(localToDevice.getTranslateY()));
|
||||||
if (isNonTranslate || complexPaint || antiAlias) {
|
if (isNonTranslate || complexPaint || antiAlias) {
|
||||||
SkPath path;
|
SkPath path;
|
||||||
region.getBoundaryPath(&path);
|
region.getBoundaryPath(&path);
|
||||||
@ -125,7 +125,7 @@ void SkBaseDevice::drawDRRect(const SkRRect& outer,
|
|||||||
|
|
||||||
void SkBaseDevice::drawPatch(const SkPoint cubics[12], const SkColor colors[4],
|
void SkBaseDevice::drawPatch(const SkPoint cubics[12], const SkColor colors[4],
|
||||||
const SkPoint texCoords[4], SkBlendMode bmode, const SkPaint& paint) {
|
const SkPoint texCoords[4], SkBlendMode bmode, const SkPaint& paint) {
|
||||||
SkISize lod = SkPatchUtils::GetLevelOfDetail(cubics, &this->ctm());
|
SkISize lod = SkPatchUtils::GetLevelOfDetail(cubics, &this->localToDevice());
|
||||||
auto vertices = SkPatchUtils::MakeVertices(cubics, colors, texCoords, lod.width(), lod.height(),
|
auto vertices = SkPatchUtils::MakeVertices(cubics, colors, texCoords, lod.width(), lod.height(),
|
||||||
this->imageInfo().colorSpace());
|
this->imageInfo().colorSpace());
|
||||||
if (vertices) {
|
if (vertices) {
|
||||||
@ -270,7 +270,7 @@ void SkBaseDevice::drawEdgeAAImageSet(const SkCanvas::ImageSetEntry images[], in
|
|||||||
SkASSERT(!paint.getPathEffect());
|
SkASSERT(!paint.getPathEffect());
|
||||||
|
|
||||||
SkPaint entryPaint = paint;
|
SkPaint entryPaint = paint;
|
||||||
const SkMatrix baseCTM = this->ctm();
|
const SkMatrix baseLocalToDevice = this->localToDevice();
|
||||||
int clipIndex = 0;
|
int clipIndex = 0;
|
||||||
for (int i = 0; i < count; ++i) {
|
for (int i = 0; i < count; ++i) {
|
||||||
// TODO: Handle per-edge AA. Right now this mirrors the SkiaRenderer component of Chrome
|
// TODO: Handle per-edge AA. Right now this mirrors the SkiaRenderer component of Chrome
|
||||||
@ -283,8 +283,8 @@ void SkBaseDevice::drawEdgeAAImageSet(const SkCanvas::ImageSetEntry images[], in
|
|||||||
SkASSERT(images[i].fMatrixIndex < 0 || preViewMatrices);
|
SkASSERT(images[i].fMatrixIndex < 0 || preViewMatrices);
|
||||||
if (images[i].fMatrixIndex >= 0) {
|
if (images[i].fMatrixIndex >= 0) {
|
||||||
this->save();
|
this->save();
|
||||||
this->setGlobalCTM(SkMatrix::Concat(
|
this->setLocalToDevice(SkMatrix::Concat(
|
||||||
baseCTM, preViewMatrices[images[i].fMatrixIndex]));
|
baseLocalToDevice, preViewMatrices[images[i].fMatrixIndex]));
|
||||||
needsRestore = true;
|
needsRestore = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -303,7 +303,7 @@ void SkBaseDevice::drawEdgeAAImageSet(const SkCanvas::ImageSetEntry images[], in
|
|||||||
this->drawImageRect(images[i].fImage.get(), &images[i].fSrcRect, images[i].fDstRect,
|
this->drawImageRect(images[i].fImage.get(), &images[i].fSrcRect, images[i].fDstRect,
|
||||||
entryPaint, constraint);
|
entryPaint, constraint);
|
||||||
if (needsRestore) {
|
if (needsRestore) {
|
||||||
this->restore(baseCTM);
|
this->restoreLocal(baseLocalToDevice);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -366,8 +366,8 @@ bool SkBaseDevice::peekPixels(SkPixmap* pmap) {
|
|||||||
void SkBaseDevice::drawGlyphRunRSXform(const SkFont& font, const SkGlyphID glyphs[],
|
void SkBaseDevice::drawGlyphRunRSXform(const SkFont& font, const SkGlyphID glyphs[],
|
||||||
const SkRSXform xform[], int count, SkPoint origin,
|
const SkRSXform xform[], int count, SkPoint origin,
|
||||||
const SkPaint& paint) {
|
const SkPaint& paint) {
|
||||||
const SkMatrix originalCTM = this->ctm();
|
const SkMatrix originalLocalToDevice = this->localToDevice();
|
||||||
if (!originalCTM.isFinite() || !SkScalarIsFinite(font.getSize()) ||
|
if (!originalLocalToDevice.isFinite() || !SkScalarIsFinite(font.getSize()) ||
|
||||||
!SkScalarIsFinite(font.getScaleX()) ||
|
!SkScalarIsFinite(font.getScaleX()) ||
|
||||||
!SkScalarIsFinite(font.getSkewX())) {
|
!SkScalarIsFinite(font.getSkewX())) {
|
||||||
return;
|
return;
|
||||||
@ -387,8 +387,8 @@ void SkBaseDevice::drawGlyphRunRSXform(const SkFont& font, const SkGlyphID glyph
|
|||||||
glyphID = glyphs[i];
|
glyphID = glyphs[i];
|
||||||
// now "glyphRun" is pointing at the current glyphID
|
// now "glyphRun" is pointing at the current glyphID
|
||||||
|
|
||||||
SkMatrix ctm;
|
SkMatrix glyphToDevice;
|
||||||
ctm.setRSXform(xform[i]).postTranslate(origin.fX, origin.fY);
|
glyphToDevice.setRSXform(xform[i]).postTranslate(origin.fX, origin.fY);
|
||||||
|
|
||||||
// We want to rotate each glyph by the rsxform, but we don't want to rotate "space"
|
// We want to rotate each glyph by the rsxform, but we don't want to rotate "space"
|
||||||
// (i.e. the shader that cares about the ctm) so we have to undo our little ctm trick
|
// (i.e. the shader that cares about the ctm) so we have to undo our little ctm trick
|
||||||
@ -397,19 +397,19 @@ void SkBaseDevice::drawGlyphRunRSXform(const SkFont& font, const SkGlyphID glyph
|
|||||||
auto shader = transformingPaint.getShader();
|
auto shader = transformingPaint.getShader();
|
||||||
if (shader) {
|
if (shader) {
|
||||||
SkMatrix inverse;
|
SkMatrix inverse;
|
||||||
if (ctm.invert(&inverse)) {
|
if (glyphToDevice.invert(&inverse)) {
|
||||||
transformingPaint.setShader(shader->makeWithLocalMatrix(inverse));
|
transformingPaint.setShader(shader->makeWithLocalMatrix(inverse));
|
||||||
} else {
|
} else {
|
||||||
transformingPaint.setShader(nullptr); // can't handle this xform
|
transformingPaint.setShader(nullptr); // can't handle this xform
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ctm.setConcat(originalCTM, ctm);
|
glyphToDevice.postConcat(originalLocalToDevice);
|
||||||
this->setCTM(ctm);
|
this->setLocalToDevice(glyphToDevice);
|
||||||
|
|
||||||
this->drawGlyphRunList(SkGlyphRunList{glyphRun, transformingPaint});
|
this->drawGlyphRunList(SkGlyphRunList{glyphRun, transformingPaint});
|
||||||
}
|
}
|
||||||
this->setCTM(originalCTM);
|
this->setLocalToDevice(originalLocalToDevice);
|
||||||
}
|
}
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
@ -103,6 +103,10 @@ public:
|
|||||||
this->onRestore();
|
this->onRestore();
|
||||||
this->setGlobalCTM(ctm);
|
this->setGlobalCTM(ctm);
|
||||||
}
|
}
|
||||||
|
void restoreLocal(const SkMatrix& localToDevice) {
|
||||||
|
this->onRestore();
|
||||||
|
this->setLocalToDevice(localToDevice);
|
||||||
|
}
|
||||||
void clipRect(const SkRect& rect, SkClipOp op, bool aa) {
|
void clipRect(const SkRect& rect, SkClipOp op, bool aa) {
|
||||||
this->onClipRect(rect, op, aa);
|
this->onClipRect(rect, op, aa);
|
||||||
}
|
}
|
||||||
@ -120,9 +124,9 @@ public:
|
|||||||
}
|
}
|
||||||
bool clipIsWideOpen() const;
|
bool clipIsWideOpen() const;
|
||||||
|
|
||||||
const SkMatrix& ctm() const { return fCTM; }
|
const SkMatrix& localToDevice() const { return fLocalToDevice; }
|
||||||
void setCTM(const SkMatrix& ctm) {
|
void setLocalToDevice(const SkMatrix& localToDevice) {
|
||||||
fCTM = ctm;
|
fLocalToDevice = localToDevice;
|
||||||
}
|
}
|
||||||
void setGlobalCTM(const SkMatrix& ctm);
|
void setGlobalCTM(const SkMatrix& ctm);
|
||||||
virtual void validateDevBounds(const SkIRect&) {}
|
virtual void validateDevBounds(const SkIRect&) {}
|
||||||
@ -372,7 +376,7 @@ private:
|
|||||||
SkIPoint fOrigin;
|
SkIPoint fOrigin;
|
||||||
const SkImageInfo fInfo;
|
const SkImageInfo fInfo;
|
||||||
const SkSurfaceProps fSurfaceProps;
|
const SkSurfaceProps fSurfaceProps;
|
||||||
SkMatrix fCTM;
|
SkMatrix fLocalToDevice;
|
||||||
|
|
||||||
typedef SkRefCnt INHERITED;
|
typedef SkRefCnt INHERITED;
|
||||||
};
|
};
|
||||||
@ -432,21 +436,21 @@ private:
|
|||||||
typedef SkBaseDevice INHERITED;
|
typedef SkBaseDevice INHERITED;
|
||||||
};
|
};
|
||||||
|
|
||||||
class SkAutoDeviceCTMRestore : SkNoncopyable {
|
class SkAutoDeviceTransformRestore : SkNoncopyable {
|
||||||
public:
|
public:
|
||||||
SkAutoDeviceCTMRestore(SkBaseDevice* device, const SkMatrix& ctm)
|
SkAutoDeviceTransformRestore(SkBaseDevice* device, const SkMatrix& localToDevice)
|
||||||
: fDevice(device)
|
: fDevice(device)
|
||||||
, fPrevCTM(device->ctm())
|
, fPrevLocalToDevice(device->localToDevice())
|
||||||
{
|
{
|
||||||
fDevice->setCTM(ctm);
|
fDevice->setLocalToDevice(localToDevice);
|
||||||
}
|
}
|
||||||
~SkAutoDeviceCTMRestore() {
|
~SkAutoDeviceTransformRestore() {
|
||||||
fDevice->setCTM(fPrevCTM);
|
fDevice->setLocalToDevice(fPrevLocalToDevice);
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
SkBaseDevice* fDevice;
|
SkBaseDevice* fDevice;
|
||||||
const SkMatrix fPrevCTM;
|
const SkMatrix fPrevLocalToDevice;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -333,7 +333,7 @@ protected:
|
|||||||
GrTextContext::SanitizeOptions(&options);
|
GrTextContext::SanitizeOptions(&options);
|
||||||
|
|
||||||
fPainter.processGlyphRunList(glyphRunList,
|
fPainter.processGlyphRunList(glyphRunList,
|
||||||
this->ctm(),
|
this->localToDevice(),
|
||||||
this->surfaceProps(),
|
this->surfaceProps(),
|
||||||
fDFTSupport,
|
fDFTSupport,
|
||||||
options,
|
options,
|
||||||
|
@ -162,7 +162,7 @@ sk_sp<SkSpecialImage> SkGpuDevice::filterTexture(SkSpecialImage* srcImg,
|
|||||||
SkASSERT(srcImg->isTextureBacked());
|
SkASSERT(srcImg->isTextureBacked());
|
||||||
SkASSERT(filter);
|
SkASSERT(filter);
|
||||||
|
|
||||||
SkMatrix matrix = this->ctm();
|
SkMatrix matrix = this->localToDevice();
|
||||||
matrix.postTranslate(SkIntToScalar(-left), SkIntToScalar(-top));
|
matrix.postTranslate(SkIntToScalar(-left), SkIntToScalar(-top));
|
||||||
const SkIRect clipBounds = this->devClipBounds().makeOffset(-left, -top);
|
const SkIRect clipBounds = this->devClipBounds().makeOffset(-left, -top);
|
||||||
sk_sp<SkImageFilterCache> cache(this->getImageFilterCache());
|
sk_sp<SkImageFilterCache> cache(this->getImageFilterCache());
|
||||||
@ -265,12 +265,12 @@ void SkGpuDevice::drawPaint(const SkPaint& paint) {
|
|||||||
GR_CREATE_TRACE_MARKER_CONTEXT("SkGpuDevice", "drawPaint", fContext.get());
|
GR_CREATE_TRACE_MARKER_CONTEXT("SkGpuDevice", "drawPaint", fContext.get());
|
||||||
|
|
||||||
GrPaint grPaint;
|
GrPaint grPaint;
|
||||||
if (!SkPaintToGrPaint(this->context(), fRenderTargetContext->colorInfo(), paint, this->ctm(),
|
if (!SkPaintToGrPaint(this->context(), fRenderTargetContext->colorInfo(), paint,
|
||||||
&grPaint)) {
|
this->localToDevice(), &grPaint)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
fRenderTargetContext->drawPaint(this->clip(), std::move(grPaint), this->ctm());
|
fRenderTargetContext->drawPaint(this->clip(), std::move(grPaint), this->localToDevice());
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline GrPrimitiveType point_mode_to_primitive_type(SkCanvas::PointMode mode) {
|
static inline GrPrimitiveType point_mode_to_primitive_type(SkCanvas::PointMode mode) {
|
||||||
@ -298,7 +298,7 @@ void SkGpuDevice::drawPoints(SkCanvas::PointMode mode,
|
|||||||
GrStyle style(paint, SkPaint::kStroke_Style);
|
GrStyle style(paint, SkPaint::kStroke_Style);
|
||||||
GrPaint grPaint;
|
GrPaint grPaint;
|
||||||
if (!SkPaintToGrPaint(this->context(), fRenderTargetContext->colorInfo(), paint,
|
if (!SkPaintToGrPaint(this->context(), fRenderTargetContext->colorInfo(), paint,
|
||||||
this->ctm(), &grPaint)) {
|
this->localToDevice(), &grPaint)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
SkPath path;
|
SkPath path;
|
||||||
@ -306,21 +306,21 @@ void SkGpuDevice::drawPoints(SkCanvas::PointMode mode,
|
|||||||
path.moveTo(pts[0]);
|
path.moveTo(pts[0]);
|
||||||
path.lineTo(pts[1]);
|
path.lineTo(pts[1]);
|
||||||
fRenderTargetContext->drawPath(this->clip(), std::move(grPaint), GrAA(paint.isAntiAlias()),
|
fRenderTargetContext->drawPath(this->clip(), std::move(grPaint), GrAA(paint.isAntiAlias()),
|
||||||
this->ctm(), path, style);
|
this->localToDevice(), path, style);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
SkScalar scales[2];
|
SkScalar scales[2];
|
||||||
bool isHairline = (0 == width) || (1 == width && this->ctm().getMinMaxScales(scales) &&
|
bool isHairline = (0 == width) ||
|
||||||
SkScalarNearlyEqual(scales[0], 1.f) &&
|
(1 == width && this->localToDevice().getMinMaxScales(scales) &&
|
||||||
SkScalarNearlyEqual(scales[1], 1.f));
|
SkScalarNearlyEqual(scales[0], 1.f) && SkScalarNearlyEqual(scales[1], 1.f));
|
||||||
// we only handle non-antialiased hairlines and paints without path effects or mask filters,
|
// we only handle non-antialiased hairlines and paints without path effects or mask filters,
|
||||||
// else we let the SkDraw call our drawPath()
|
// else we let the SkDraw call our drawPath()
|
||||||
if (!isHairline || paint.getPathEffect() || paint.getMaskFilter() || paint.isAntiAlias()) {
|
if (!isHairline || paint.getPathEffect() || paint.getMaskFilter() || paint.isAntiAlias()) {
|
||||||
SkRasterClip rc(this->devClipBounds());
|
SkRasterClip rc(this->devClipBounds());
|
||||||
SkDraw draw;
|
SkDraw draw;
|
||||||
draw.fDst = SkPixmap(SkImageInfo::MakeUnknown(this->width(), this->height()), nullptr, 0);
|
draw.fDst = SkPixmap(SkImageInfo::MakeUnknown(this->width(), this->height()), nullptr, 0);
|
||||||
draw.fMatrix = &this->ctm();
|
draw.fMatrix = &this->localToDevice();
|
||||||
draw.fRC = &rc;
|
draw.fRC = &rc;
|
||||||
draw.drawPoints(mode, count, pts, paint, this);
|
draw.drawPoints(mode, count, pts, paint, this);
|
||||||
return;
|
return;
|
||||||
@ -328,7 +328,7 @@ void SkGpuDevice::drawPoints(SkCanvas::PointMode mode,
|
|||||||
|
|
||||||
GrPrimitiveType primitiveType = point_mode_to_primitive_type(mode);
|
GrPrimitiveType primitiveType = point_mode_to_primitive_type(mode);
|
||||||
|
|
||||||
const SkMatrix* viewMatrix = &this->ctm();
|
const SkMatrix* viewMatrix = &this->localToDevice();
|
||||||
#ifdef SK_BUILD_FOR_ANDROID_FRAMEWORK
|
#ifdef SK_BUILD_FOR_ANDROID_FRAMEWORK
|
||||||
// This offsetting in device space matches the expectations of the Android framework for non-AA
|
// This offsetting in device space matches the expectations of the Android framework for non-AA
|
||||||
// points and lines.
|
// points and lines.
|
||||||
@ -368,18 +368,18 @@ void SkGpuDevice::drawRect(const SkRect& rect, const SkPaint& paint) {
|
|||||||
GrShape shape(rect, style);
|
GrShape shape(rect, style);
|
||||||
|
|
||||||
GrBlurUtils::drawShapeWithMaskFilter(fContext.get(), fRenderTargetContext.get(),
|
GrBlurUtils::drawShapeWithMaskFilter(fContext.get(), fRenderTargetContext.get(),
|
||||||
this->clip(), paint, this->ctm(), shape);
|
this->clip(), paint, this->localToDevice(), shape);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
GrPaint grPaint;
|
GrPaint grPaint;
|
||||||
if (!SkPaintToGrPaint(this->context(), fRenderTargetContext->colorInfo(), paint, this->ctm(),
|
if (!SkPaintToGrPaint(this->context(), fRenderTargetContext->colorInfo(), paint,
|
||||||
&grPaint)) {
|
this->localToDevice(), &grPaint)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
fRenderTargetContext->drawRect(this->clip(), std::move(grPaint), GrAA(paint.isAntiAlias()),
|
fRenderTargetContext->drawRect(this->clip(), std::move(grPaint), GrAA(paint.isAntiAlias()),
|
||||||
this->ctm(), rect, &style);
|
this->localToDevice(), rect, &style);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SkGpuDevice::drawEdgeAAQuad(const SkRect& rect, const SkPoint clip[4],
|
void SkGpuDevice::drawEdgeAAQuad(const SkRect& rect, const SkPoint clip[4],
|
||||||
@ -401,11 +401,11 @@ void SkGpuDevice::drawEdgeAAQuad(const SkRect& rect, const SkPoint clip[4],
|
|||||||
if (clip) {
|
if (clip) {
|
||||||
// Use fillQuadWithEdgeAA
|
// Use fillQuadWithEdgeAA
|
||||||
fRenderTargetContext->fillQuadWithEdgeAA(this->clip(), std::move(grPaint), GrAA::kYes, grAA,
|
fRenderTargetContext->fillQuadWithEdgeAA(this->clip(), std::move(grPaint), GrAA::kYes, grAA,
|
||||||
this->ctm(), clip, nullptr);
|
this->localToDevice(), clip, nullptr);
|
||||||
} else {
|
} else {
|
||||||
// Use fillRectWithEdgeAA to preserve mathematical properties of dst being rectangular
|
// Use fillRectWithEdgeAA to preserve mathematical properties of dst being rectangular
|
||||||
fRenderTargetContext->fillRectWithEdgeAA(this->clip(), std::move(grPaint), GrAA::kYes, grAA,
|
fRenderTargetContext->fillRectWithEdgeAA(this->clip(), std::move(grPaint), GrAA::kYes, grAA,
|
||||||
this->ctm(), rect);
|
this->localToDevice(), rect);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -429,20 +429,20 @@ void SkGpuDevice::drawRRect(const SkRRect& rrect, const SkPaint& paint) {
|
|||||||
GrShape shape(rrect, style);
|
GrShape shape(rrect, style);
|
||||||
|
|
||||||
GrBlurUtils::drawShapeWithMaskFilter(fContext.get(), fRenderTargetContext.get(),
|
GrBlurUtils::drawShapeWithMaskFilter(fContext.get(), fRenderTargetContext.get(),
|
||||||
this->clip(), paint, this->ctm(), shape);
|
this->clip(), paint, this->localToDevice(), shape);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
SkASSERT(!style.pathEffect());
|
SkASSERT(!style.pathEffect());
|
||||||
|
|
||||||
GrPaint grPaint;
|
GrPaint grPaint;
|
||||||
if (!SkPaintToGrPaint(this->context(), fRenderTargetContext->colorInfo(), paint, this->ctm(),
|
if (!SkPaintToGrPaint(this->context(), fRenderTargetContext->colorInfo(), paint,
|
||||||
&grPaint)) {
|
this->localToDevice(), &grPaint)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
fRenderTargetContext->drawRRect(this->clip(), std::move(grPaint), GrAA(paint.isAntiAlias()),
|
fRenderTargetContext->drawRRect(this->clip(), std::move(grPaint), GrAA(paint.isAntiAlias()),
|
||||||
this->ctm(), rrect, style);
|
this->localToDevice(), rrect, style);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -462,12 +462,13 @@ void SkGpuDevice::drawDRRect(const SkRRect& outer, const SkRRect& inner, const S
|
|||||||
if (stroke.isFillStyle() && !paint.getMaskFilter() && !paint.getPathEffect()) {
|
if (stroke.isFillStyle() && !paint.getMaskFilter() && !paint.getPathEffect()) {
|
||||||
GrPaint grPaint;
|
GrPaint grPaint;
|
||||||
if (!SkPaintToGrPaint(this->context(), fRenderTargetContext->colorInfo(), paint,
|
if (!SkPaintToGrPaint(this->context(), fRenderTargetContext->colorInfo(), paint,
|
||||||
this->ctm(), &grPaint)) {
|
this->localToDevice(), &grPaint)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
fRenderTargetContext->drawDRRect(this->clip(), std::move(grPaint),
|
fRenderTargetContext->drawDRRect(this->clip(), std::move(grPaint),
|
||||||
GrAA(paint.isAntiAlias()), this->ctm(), outer, inner);
|
GrAA(paint.isAntiAlias()), this->localToDevice(),
|
||||||
|
outer, inner);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -482,7 +483,7 @@ void SkGpuDevice::drawDRRect(const SkRRect& outer, const SkRRect& inner, const S
|
|||||||
GrShape shape(path, paint);
|
GrShape shape(path, paint);
|
||||||
|
|
||||||
GrBlurUtils::drawShapeWithMaskFilter(fContext.get(), fRenderTargetContext.get(), this->clip(),
|
GrBlurUtils::drawShapeWithMaskFilter(fContext.get(), fRenderTargetContext.get(), this->clip(),
|
||||||
paint, this->ctm(), shape);
|
paint, this->localToDevice(), shape);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -497,13 +498,13 @@ void SkGpuDevice::drawRegion(const SkRegion& region, const SkPaint& paint) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
GrPaint grPaint;
|
GrPaint grPaint;
|
||||||
if (!SkPaintToGrPaint(this->context(), fRenderTargetContext->colorInfo(), paint, this->ctm(),
|
if (!SkPaintToGrPaint(this->context(), fRenderTargetContext->colorInfo(), paint,
|
||||||
&grPaint)) {
|
this->localToDevice(), &grPaint)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
fRenderTargetContext->drawRegion(this->clip(), std::move(grPaint), GrAA(paint.isAntiAlias()),
|
fRenderTargetContext->drawRegion(this->clip(), std::move(grPaint), GrAA(paint.isAntiAlias()),
|
||||||
this->ctm(), region, GrStyle(paint));
|
this->localToDevice(), region, GrStyle(paint));
|
||||||
}
|
}
|
||||||
|
|
||||||
void SkGpuDevice::drawOval(const SkRect& oval, const SkPaint& paint) {
|
void SkGpuDevice::drawOval(const SkRect& oval, const SkPaint& paint) {
|
||||||
@ -517,13 +518,13 @@ void SkGpuDevice::drawOval(const SkRect& oval, const SkPaint& paint) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
GrPaint grPaint;
|
GrPaint grPaint;
|
||||||
if (!SkPaintToGrPaint(this->context(), fRenderTargetContext->colorInfo(), paint, this->ctm(),
|
if (!SkPaintToGrPaint(this->context(), fRenderTargetContext->colorInfo(), paint,
|
||||||
&grPaint)) {
|
this->localToDevice(), &grPaint)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
fRenderTargetContext->drawOval(this->clip(), std::move(grPaint), GrAA(paint.isAntiAlias()),
|
fRenderTargetContext->drawOval(this->clip(), std::move(grPaint), GrAA(paint.isAntiAlias()),
|
||||||
this->ctm(), oval, GrStyle(paint));
|
this->localToDevice(), oval, GrStyle(paint));
|
||||||
}
|
}
|
||||||
|
|
||||||
void SkGpuDevice::drawArc(const SkRect& oval, SkScalar startAngle,
|
void SkGpuDevice::drawArc(const SkRect& oval, SkScalar startAngle,
|
||||||
@ -535,13 +536,13 @@ void SkGpuDevice::drawArc(const SkRect& oval, SkScalar startAngle,
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
GrPaint grPaint;
|
GrPaint grPaint;
|
||||||
if (!SkPaintToGrPaint(this->context(), fRenderTargetContext->colorInfo(), paint, this->ctm(),
|
if (!SkPaintToGrPaint(this->context(), fRenderTargetContext->colorInfo(), paint,
|
||||||
&grPaint)) {
|
this->localToDevice(), &grPaint)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
fRenderTargetContext->drawArc(this->clip(), std::move(grPaint), GrAA(paint.isAntiAlias()),
|
fRenderTargetContext->drawArc(this->clip(), std::move(grPaint), GrAA(paint.isAntiAlias()),
|
||||||
this->ctm(), oval, startAngle, sweepAngle, useCenter,
|
this->localToDevice(), oval, startAngle, sweepAngle, useCenter,
|
||||||
GrStyle(paint));
|
GrStyle(paint));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -588,7 +589,7 @@ void SkGpuDevice::drawStrokedLine(const SkPoint points[2],
|
|||||||
|
|
||||||
SkMatrix local = m;
|
SkMatrix local = m;
|
||||||
|
|
||||||
m.postConcat(this->ctm());
|
m.postConcat(this->localToDevice());
|
||||||
|
|
||||||
GrPaint grPaint;
|
GrPaint grPaint;
|
||||||
if (!SkPaintToGrPaint(this->context(), fRenderTargetContext->colorInfo(), newPaint, m,
|
if (!SkPaintToGrPaint(this->context(), fRenderTargetContext->colorInfo(), newPaint, m,
|
||||||
@ -606,9 +607,9 @@ void SkGpuDevice::drawPath(const SkPath& origSrcPath, const SkPaint& paint, bool
|
|||||||
SkPoint points[2];
|
SkPoint points[2];
|
||||||
if (SkPaint::kStroke_Style == paint.getStyle() && paint.getStrokeWidth() > 0 &&
|
if (SkPaint::kStroke_Style == paint.getStyle() && paint.getStrokeWidth() > 0 &&
|
||||||
!paint.getMaskFilter() && SkPaint::kRound_Cap != paint.getStrokeCap() &&
|
!paint.getMaskFilter() && SkPaint::kRound_Cap != paint.getStrokeCap() &&
|
||||||
this->ctm().preservesRightAngles() && origSrcPath.isLine(points)) {
|
this->localToDevice().preservesRightAngles() && origSrcPath.isLine(points)) {
|
||||||
// Path-based stroking looks better for thin rects
|
// Path-based stroking looks better for thin rects
|
||||||
SkScalar strokeWidth = this->ctm().getMaxScale() * paint.getStrokeWidth();
|
SkScalar strokeWidth = this->localToDevice().getMaxScale() * paint.getStrokeWidth();
|
||||||
if (strokeWidth >= 1.0f) {
|
if (strokeWidth >= 1.0f) {
|
||||||
// Round capping support is currently disabled b.c. it would require a RRect
|
// Round capping support is currently disabled b.c. it would require a RRect
|
||||||
// GrDrawOp that takes a localMatrix.
|
// GrDrawOp that takes a localMatrix.
|
||||||
@ -622,11 +623,11 @@ void SkGpuDevice::drawPath(const SkPath& origSrcPath, const SkPaint& paint, bool
|
|||||||
if (!paint.getMaskFilter()) {
|
if (!paint.getMaskFilter()) {
|
||||||
GrPaint grPaint;
|
GrPaint grPaint;
|
||||||
if (!SkPaintToGrPaint(this->context(), fRenderTargetContext->colorInfo(), paint,
|
if (!SkPaintToGrPaint(this->context(), fRenderTargetContext->colorInfo(), paint,
|
||||||
this->ctm(), &grPaint)) {
|
this->localToDevice(), &grPaint)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
fRenderTargetContext->drawPath(this->clip(), std::move(grPaint), GrAA(paint.isAntiAlias()),
|
fRenderTargetContext->drawPath(this->clip(), std::move(grPaint), GrAA(paint.isAntiAlias()),
|
||||||
this->ctm(), origSrcPath, GrStyle(paint));
|
this->localToDevice(), origSrcPath, GrStyle(paint));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -634,7 +635,7 @@ void SkGpuDevice::drawPath(const SkPath& origSrcPath, const SkPaint& paint, bool
|
|||||||
GrShape shape(origSrcPath, paint);
|
GrShape shape(origSrcPath, paint);
|
||||||
|
|
||||||
GrBlurUtils::drawShapeWithMaskFilter(fContext.get(), fRenderTargetContext.get(), this->clip(),
|
GrBlurUtils::drawShapeWithMaskFilter(fContext.get(), fRenderTargetContext.get(), this->clip(),
|
||||||
paint, this->ctm(), shape);
|
paint, this->localToDevice(), shape);
|
||||||
}
|
}
|
||||||
|
|
||||||
static const int kBmpSmallTileSize = 1 << 10;
|
static const int kBmpSmallTileSize = 1 << 10;
|
||||||
@ -1028,7 +1029,7 @@ void SkGpuDevice::drawSpecial(SkSpecialImage* special, int left, int top, const
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
SkMatrix ctm = this->ctm();
|
SkMatrix ctm = this->localToDevice();
|
||||||
ctm.postTranslate(-SkIntToScalar(left), -SkIntToScalar(top));
|
ctm.postTranslate(-SkIntToScalar(left), -SkIntToScalar(top));
|
||||||
|
|
||||||
SkPaint tmpUnfiltered(paint);
|
SkPaint tmpUnfiltered(paint);
|
||||||
@ -1163,7 +1164,7 @@ void SkGpuDevice::drawBitmapRect(const SkBitmap& bitmap,
|
|||||||
GrSamplerState sampleState;
|
GrSamplerState sampleState;
|
||||||
bool doBicubic;
|
bool doBicubic;
|
||||||
GrSamplerState::Filter textureFilterMode = GrSkFilterQualityToGrFilterMode(
|
GrSamplerState::Filter textureFilterMode = GrSkFilterQualityToGrFilterMode(
|
||||||
bitmap.width(), bitmap.height(), paint.getFilterQuality(), this->ctm(),
|
bitmap.width(), bitmap.height(), paint.getFilterQuality(), this->localToDevice(),
|
||||||
srcToDstMatrix, fContext->priv().options().fSharpenMipmappedTextures, &doBicubic);
|
srcToDstMatrix, fContext->priv().options().fSharpenMipmappedTextures, &doBicubic);
|
||||||
|
|
||||||
int tileFilterPad;
|
int tileFilterPad;
|
||||||
@ -1178,16 +1179,16 @@ void SkGpuDevice::drawBitmapRect(const SkBitmap& bitmap,
|
|||||||
sampleState.setFilterMode(textureFilterMode);
|
sampleState.setFilterMode(textureFilterMode);
|
||||||
|
|
||||||
int maxTileSizeForFilter = this->caps()->maxTileSize() - 2 * tileFilterPad;
|
int maxTileSizeForFilter = this->caps()->maxTileSize() - 2 * tileFilterPad;
|
||||||
if (this->shouldTileImageID(bitmap.getGenerationID(), bitmap.getSubset(), this->ctm(),
|
if (this->shouldTileImageID(bitmap.getGenerationID(), bitmap.getSubset(),
|
||||||
srcToDstMatrix, sampleState, src, maxTileSizeForFilter,
|
this->localToDevice(), srcToDstMatrix, sampleState, src,
|
||||||
&tileSize, &clippedSrcRect)) {
|
maxTileSizeForFilter, &tileSize, &clippedSrcRect)) {
|
||||||
this->drawTiledBitmap(bitmap, this->ctm(), srcToDstMatrix, *src, clippedSrcRect,
|
this->drawTiledBitmap(bitmap, this->localToDevice(), srcToDstMatrix, *src, clippedSrcRect,
|
||||||
sampleState, paint, constraint, tileSize, doBicubic);
|
sampleState, paint, constraint, tileSize, doBicubic);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
GrBitmapTextureMaker maker(fContext.get(), bitmap);
|
GrBitmapTextureMaker maker(fContext.get(), bitmap);
|
||||||
this->drawTextureProducer(&maker, src, dst, constraint, this->ctm(), paint, true);
|
this->drawTextureProducer(&maker, src, dst, constraint, this->localToDevice(), paint, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
sk_sp<SkSpecialImage> SkGpuDevice::makeSpecial(const SkBitmap& bitmap) {
|
sk_sp<SkSpecialImage> SkGpuDevice::makeSpecial(const SkBitmap& bitmap) {
|
||||||
@ -1369,7 +1370,7 @@ void SkGpuDevice::drawProducerLattice(GrTextureProducer* producer,
|
|||||||
auto csxf = GrColorSpaceXform::Make(producer->colorSpace(), producer->alphaType(),
|
auto csxf = GrColorSpaceXform::Make(producer->colorSpace(), producer->alphaType(),
|
||||||
dstColorSpace, kPremul_SkAlphaType);
|
dstColorSpace, kPremul_SkAlphaType);
|
||||||
|
|
||||||
fRenderTargetContext->drawImageLattice(this->clip(), std::move(grPaint), this->ctm(),
|
fRenderTargetContext->drawImageLattice(this->clip(), std::move(grPaint), this->localToDevice(),
|
||||||
std::move(proxy), producer->colorType(), std::move(csxf),
|
std::move(proxy), producer->colorType(), std::move(csxf),
|
||||||
filter, std::move(iter), dst);
|
filter, std::move(iter), dst);
|
||||||
}
|
}
|
||||||
@ -1490,7 +1491,7 @@ void SkGpuDevice::wireframeVertices(SkVertices::VertexMode vmode, int vertexCoun
|
|||||||
GrPrimitiveType primitiveType = GrPrimitiveType::kLines;
|
GrPrimitiveType primitiveType = GrPrimitiveType::kLines;
|
||||||
fRenderTargetContext->drawVertices(this->clip(),
|
fRenderTargetContext->drawVertices(this->clip(),
|
||||||
std::move(grPaint),
|
std::move(grPaint),
|
||||||
this->ctm(),
|
this->localToDevice(),
|
||||||
builder.detach(),
|
builder.detach(),
|
||||||
bones,
|
bones,
|
||||||
boneCount,
|
boneCount,
|
||||||
@ -1513,11 +1514,11 @@ void SkGpuDevice::drawVertices(const SkVertices* vertices, const SkVertices::Bon
|
|||||||
paint);
|
paint);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!init_vertices_paint(fContext.get(), fRenderTargetContext->colorInfo(), paint, this->ctm(),
|
if (!init_vertices_paint(fContext.get(), fRenderTargetContext->colorInfo(), paint,
|
||||||
mode, hasTexs, hasColors, &grPaint)) {
|
this->localToDevice(), mode, hasTexs, hasColors, &grPaint)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
fRenderTargetContext->drawVertices(this->clip(), std::move(grPaint), this->ctm(),
|
fRenderTargetContext->drawVertices(this->clip(), std::move(grPaint), this->localToDevice(),
|
||||||
sk_ref_sp(const_cast<SkVertices*>(vertices)),
|
sk_ref_sp(const_cast<SkVertices*>(vertices)),
|
||||||
bones, boneCount);
|
bones, boneCount);
|
||||||
}
|
}
|
||||||
@ -1529,7 +1530,7 @@ void SkGpuDevice::drawShadow(const SkPath& path, const SkDrawShadowRec& rec) {
|
|||||||
ASSERT_SINGLE_OWNER
|
ASSERT_SINGLE_OWNER
|
||||||
GR_CREATE_TRACE_MARKER_CONTEXT("SkGpuDevice", "drawShadow", fContext.get());
|
GR_CREATE_TRACE_MARKER_CONTEXT("SkGpuDevice", "drawShadow", fContext.get());
|
||||||
|
|
||||||
if (!fRenderTargetContext->drawFastShadow(this->clip(), this->ctm(), path, rec)) {
|
if (!fRenderTargetContext->drawFastShadow(this->clip(), this->localToDevice(), path, rec)) {
|
||||||
// failed to find an accelerated case
|
// failed to find an accelerated case
|
||||||
this->INHERITED::drawShadow(path, rec);
|
this->INHERITED::drawShadow(path, rec);
|
||||||
}
|
}
|
||||||
@ -1549,18 +1550,18 @@ void SkGpuDevice::drawAtlas(const SkImage* atlas, const SkRSXform xform[],
|
|||||||
GrPaint grPaint;
|
GrPaint grPaint;
|
||||||
if (colors) {
|
if (colors) {
|
||||||
if (!SkPaintToGrPaintWithXfermode(this->context(), fRenderTargetContext->colorInfo(), p,
|
if (!SkPaintToGrPaintWithXfermode(this->context(), fRenderTargetContext->colorInfo(), p,
|
||||||
this->ctm(), (SkBlendMode)mode, &grPaint)) {
|
this->localToDevice(), (SkBlendMode)mode, &grPaint)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (!SkPaintToGrPaint(this->context(), fRenderTargetContext->colorInfo(), p, this->ctm(),
|
if (!SkPaintToGrPaint(this->context(), fRenderTargetContext->colorInfo(), p,
|
||||||
&grPaint)) {
|
this->localToDevice(), &grPaint)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fRenderTargetContext->drawAtlas(
|
fRenderTargetContext->drawAtlas(
|
||||||
this->clip(), std::move(grPaint), this->ctm(), count, xform, texRect, colors);
|
this->clip(), std::move(grPaint), this->localToDevice(), count, xform, texRect, colors);
|
||||||
}
|
}
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
@ -1570,12 +1571,11 @@ void SkGpuDevice::drawGlyphRunList(const SkGlyphRunList& glyphRunList) {
|
|||||||
GR_CREATE_TRACE_MARKER_CONTEXT("SkGpuDevice", "drawGlyphRunList", fContext.get());
|
GR_CREATE_TRACE_MARKER_CONTEXT("SkGpuDevice", "drawGlyphRunList", fContext.get());
|
||||||
|
|
||||||
// Check for valid input
|
// Check for valid input
|
||||||
const SkMatrix& ctm = this->ctm();
|
if (!this->localToDevice().isFinite() || !glyphRunList.allFontsFinite()) {
|
||||||
if (!ctm.isFinite() || !glyphRunList.allFontsFinite()) {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
fRenderTargetContext->drawGlyphRunList(this->clip(), ctm, glyphRunList);
|
fRenderTargetContext->drawGlyphRunList(this->clip(), this->localToDevice(), glyphRunList);
|
||||||
}
|
}
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
@ -376,7 +376,7 @@ void SkGpuDevice::drawImageQuad(const SkImage* image, const SkRect* srcRect, con
|
|||||||
bool attemptDrawTexture = !useDecal; // rtc->drawTexture() only clamps
|
bool attemptDrawTexture = !useDecal; // rtc->drawTexture() only clamps
|
||||||
|
|
||||||
// Get final CTM matrix
|
// Get final CTM matrix
|
||||||
SkMatrix ctm = this->ctm();
|
SkMatrix ctm = this->localToDevice();
|
||||||
if (preViewMatrix) {
|
if (preViewMatrix) {
|
||||||
ctm.preConcat(*preViewMatrix);
|
ctm.preConcat(*preViewMatrix);
|
||||||
}
|
}
|
||||||
@ -497,8 +497,8 @@ void SkGpuDevice::drawEdgeAAImageSet(const SkCanvas::ImageSetEntry set[], int co
|
|||||||
set[base].fImage->colorSpace(), set[base].fImage->alphaType(),
|
set[base].fImage->colorSpace(), set[base].fImage->alphaType(),
|
||||||
fRenderTargetContext->colorInfo().colorSpace(), kPremul_SkAlphaType);
|
fRenderTargetContext->colorInfo().colorSpace(), kPremul_SkAlphaType);
|
||||||
fRenderTargetContext->drawTextureSet(this->clip(), textures.get() + base, n,
|
fRenderTargetContext->drawTextureSet(this->clip(), textures.get() + base, n,
|
||||||
filter, mode, GrAA::kYes, constraint, this->ctm(),
|
filter, mode, GrAA::kYes, constraint,
|
||||||
std::move(textureXform));
|
this->localToDevice(), std::move(textureXform));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
int dstClipIndex = 0;
|
int dstClipIndex = 0;
|
||||||
|
@ -225,7 +225,7 @@ public:
|
|||||||
fDevice->setUpContentEntry(clipStack, matrix, paint, textScale, &fDstFormXObject);
|
fDevice->setUpContentEntry(clipStack, matrix, paint, textScale, &fDstFormXObject);
|
||||||
}
|
}
|
||||||
ScopedContentEntry(SkPDFDevice* dev, const SkPaint& paint, SkScalar textScale = 0)
|
ScopedContentEntry(SkPDFDevice* dev, const SkPaint& paint, SkScalar textScale = 0)
|
||||||
: ScopedContentEntry(dev, &dev->cs(), dev->ctm(), paint, textScale) {}
|
: ScopedContentEntry(dev, &dev->cs(), dev->localToDevice(), paint, textScale) {}
|
||||||
|
|
||||||
~ScopedContentEntry() {
|
~ScopedContentEntry() {
|
||||||
if (fContentStream) {
|
if (fContentStream) {
|
||||||
@ -321,7 +321,7 @@ void SkPDFDevice::drawAnnotation(const SkRect& rect, const char key[], SkData* v
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!strcmp(SkAnnotationKeys::Define_Named_Dest_Key(), key)) {
|
if (!strcmp(SkAnnotationKeys::Define_Named_Dest_Key(), key)) {
|
||||||
SkPoint p = deviceOffset + this->ctm().mapXY(rect.x(), rect.y());
|
SkPoint p = deviceOffset + this->localToDevice().mapXY(rect.x(), rect.y());
|
||||||
pageXform.mapPoints(&p, 1);
|
pageXform.mapPoints(&p, 1);
|
||||||
auto pg = fDocument->currentPage();
|
auto pg = fDocument->currentPage();
|
||||||
fDocument->fNamedDestinations.push_back(SkPDFNamedDestination{sk_ref_sp(value), p, pg});
|
fDocument->fNamedDestinations.push_back(SkPDFNamedDestination{sk_ref_sp(value), p, pg});
|
||||||
@ -330,7 +330,7 @@ void SkPDFDevice::drawAnnotation(const SkRect& rect, const char key[], SkData* v
|
|||||||
}
|
}
|
||||||
// Convert to path to handle non-90-degree rotations.
|
// Convert to path to handle non-90-degree rotations.
|
||||||
SkPath path = to_path(rect);
|
SkPath path = to_path(rect);
|
||||||
path.transform(this->ctm(), &path);
|
path.transform(this->localToDevice(), &path);
|
||||||
SkPath clip;
|
SkPath clip;
|
||||||
(void)this->cs().asPath(&clip);
|
(void)this->cs().asPath(&clip);
|
||||||
Op(clip, path, kIntersect_SkPathOp, &path);
|
Op(clip, path, kIntersect_SkPathOp, &path);
|
||||||
@ -351,7 +351,7 @@ void SkPDFDevice::drawAnnotation(const SkRect& rect, const char key[], SkData* v
|
|||||||
|
|
||||||
void SkPDFDevice::drawPaint(const SkPaint& srcPaint) {
|
void SkPDFDevice::drawPaint(const SkPaint& srcPaint) {
|
||||||
SkMatrix inverse;
|
SkMatrix inverse;
|
||||||
if (!this->ctm().invert(&inverse)) {
|
if (!this->localToDevice().invert(&inverse)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
SkRect bbox = this->cs().bounds(this->bounds());
|
SkRect bbox = this->cs().bounds(this->bounds());
|
||||||
@ -388,7 +388,7 @@ void SkPDFDevice::drawPoints(SkCanvas::PointMode mode,
|
|||||||
// of multiple calls to setUpContentEntry it causes.
|
// of multiple calls to setUpContentEntry it causes.
|
||||||
if (paint->getPathEffect()) {
|
if (paint->getPathEffect()) {
|
||||||
draw_points(mode, count, points, *paint,
|
draw_points(mode, count, points, *paint,
|
||||||
this->devClipBounds(), this->ctm(), this);
|
this->devClipBounds(), this->localToDevice(), this);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -449,23 +449,23 @@ void SkPDFDevice::drawPoints(SkCanvas::PointMode mode,
|
|||||||
void SkPDFDevice::drawRect(const SkRect& rect, const SkPaint& paint) {
|
void SkPDFDevice::drawRect(const SkRect& rect, const SkPaint& paint) {
|
||||||
SkRect r = rect;
|
SkRect r = rect;
|
||||||
r.sort();
|
r.sort();
|
||||||
this->internalDrawPath(this->cs(), this->ctm(), to_path(r), paint, true);
|
this->internalDrawPath(this->cs(), this->localToDevice(), to_path(r), paint, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SkPDFDevice::drawRRect(const SkRRect& rrect, const SkPaint& paint) {
|
void SkPDFDevice::drawRRect(const SkRRect& rrect, const SkPaint& paint) {
|
||||||
SkPath path;
|
SkPath path;
|
||||||
path.addRRect(rrect);
|
path.addRRect(rrect);
|
||||||
this->internalDrawPath(this->cs(), this->ctm(), path, paint, true);
|
this->internalDrawPath(this->cs(), this->localToDevice(), path, paint, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SkPDFDevice::drawOval(const SkRect& oval, const SkPaint& paint) {
|
void SkPDFDevice::drawOval(const SkRect& oval, const SkPaint& paint) {
|
||||||
SkPath path;
|
SkPath path;
|
||||||
path.addOval(oval);
|
path.addOval(oval);
|
||||||
this->internalDrawPath(this->cs(), this->ctm(), path, paint, true);
|
this->internalDrawPath(this->cs(), this->localToDevice(), path, paint, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SkPDFDevice::drawPath(const SkPath& path, const SkPaint& paint, bool pathIsMutable) {
|
void SkPDFDevice::drawPath(const SkPath& path, const SkPaint& paint, bool pathIsMutable) {
|
||||||
this->internalDrawPath(this->cs(), this->ctm(), path, paint, pathIsMutable);
|
this->internalDrawPath(this->cs(), this->localToDevice(), path, paint, pathIsMutable);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SkPDFDevice::internalDrawPathWithFilter(const SkClipStack& clipStack,
|
void SkPDFDevice::internalDrawPathWithFilter(const SkClipStack& clipStack,
|
||||||
@ -613,7 +613,7 @@ void SkPDFDevice::drawImageRect(const SkImage* image,
|
|||||||
SkCanvas::SrcRectConstraint) {
|
SkCanvas::SrcRectConstraint) {
|
||||||
SkASSERT(image);
|
SkASSERT(image);
|
||||||
this->internalDrawImageRect(SkKeyedImage(sk_ref_sp(const_cast<SkImage*>(image))),
|
this->internalDrawImageRect(SkKeyedImage(sk_ref_sp(const_cast<SkImage*>(image))),
|
||||||
src, dst, paint, this->ctm());
|
src, dst, paint, this->localToDevice());
|
||||||
}
|
}
|
||||||
|
|
||||||
void SkPDFDevice::drawBitmapRect(const SkBitmap& bm,
|
void SkPDFDevice::drawBitmapRect(const SkBitmap& bm,
|
||||||
@ -622,7 +622,7 @@ void SkPDFDevice::drawBitmapRect(const SkBitmap& bm,
|
|||||||
const SkPaint& paint,
|
const SkPaint& paint,
|
||||||
SkCanvas::SrcRectConstraint) {
|
SkCanvas::SrcRectConstraint) {
|
||||||
SkASSERT(!bm.drawsNothing());
|
SkASSERT(!bm.drawsNothing());
|
||||||
this->internalDrawImageRect(SkKeyedImage(bm), src, dst, paint, this->ctm());
|
this->internalDrawImageRect(SkKeyedImage(bm), src, dst, paint, this->localToDevice());
|
||||||
}
|
}
|
||||||
|
|
||||||
void SkPDFDevice::drawSprite(const SkBitmap& bm, int x, int y, const SkPaint& paint) {
|
void SkPDFDevice::drawSprite(const SkBitmap& bm, int x, int y, const SkPaint& paint) {
|
||||||
@ -751,7 +751,7 @@ void SkPDFDevice::drawGlyphRunAsPath(
|
|||||||
}
|
}
|
||||||
rec->fPos += 1; // move to the next glyph's position
|
rec->fPos += 1; // move to the next glyph's position
|
||||||
}, &rec);
|
}, &rec);
|
||||||
this->internalDrawPath(this->cs(), this->ctm(), path, runPaint, true);
|
this->internalDrawPath(this->cs(), this->localToDevice(), path, runPaint, true);
|
||||||
|
|
||||||
SkFont transparentFont = glyphRun.font();
|
SkFont transparentFont = glyphRun.font();
|
||||||
transparentFont.setEmbolden(false); // Stop Recursion
|
transparentFont.setEmbolden(false); // Stop Recursion
|
||||||
@ -760,11 +760,9 @@ void SkPDFDevice::drawGlyphRunAsPath(
|
|||||||
SkPaint transparent;
|
SkPaint transparent;
|
||||||
transparent.setColor(SK_ColorTRANSPARENT);
|
transparent.setColor(SK_ColorTRANSPARENT);
|
||||||
|
|
||||||
if (this->ctm().hasPerspective()) {
|
if (this->localToDevice().hasPerspective()) {
|
||||||
SkMatrix prevCTM = this->ctm();
|
SkAutoDeviceTransformRestore adr(this, SkMatrix::I());
|
||||||
this->setCTM(SkMatrix::I());
|
|
||||||
this->internalDrawGlyphRun(tmpGlyphRun, offset, transparent);
|
this->internalDrawGlyphRun(tmpGlyphRun, offset, transparent);
|
||||||
this->setCTM(prevCTM);
|
|
||||||
} else {
|
} else {
|
||||||
this->internalDrawGlyphRun(tmpGlyphRun, offset, transparent);
|
this->internalDrawGlyphRun(tmpGlyphRun, offset, transparent);
|
||||||
}
|
}
|
||||||
@ -800,7 +798,7 @@ void SkPDFDevice::internalDrawGlyphRun(
|
|||||||
if (runPaint.getPathEffect()
|
if (runPaint.getPathEffect()
|
||||||
|| runPaint.getMaskFilter()
|
|| runPaint.getMaskFilter()
|
||||||
|| glyphRunFont.isEmbolden()
|
|| glyphRunFont.isEmbolden()
|
||||||
|| this->ctm().hasPerspective()
|
|| this->localToDevice().hasPerspective()
|
||||||
|| SkPaint::kFill_Style != runPaint.getStyle()) {
|
|| SkPaint::kFill_Style != runPaint.getStyle()) {
|
||||||
// Stroked Text doesn't work well with Type3 fonts.
|
// Stroked Text doesn't work well with Type3 fonts.
|
||||||
this->drawGlyphRunAsPath(glyphRun, offset, runPaint);
|
this->drawGlyphRunAsPath(glyphRun, offset, runPaint);
|
||||||
@ -916,7 +914,7 @@ void SkPDFDevice::internalDrawGlyphRun(
|
|||||||
// Do a glyph-by-glyph bounds-reject if positions are absolute.
|
// Do a glyph-by-glyph bounds-reject if positions are absolute.
|
||||||
SkRect glyphBounds = get_glyph_bounds_device_space(
|
SkRect glyphBounds = get_glyph_bounds_device_space(
|
||||||
glyphs[index], textScaleX, textScaleY,
|
glyphs[index], textScaleX, textScaleY,
|
||||||
xy + offset, this->ctm());
|
xy + offset, this->localToDevice());
|
||||||
if (glyphBounds.isEmpty()) {
|
if (glyphBounds.isEmpty()) {
|
||||||
if (!contains(clipStackBounds, {glyphBounds.x(), glyphBounds.y()})) {
|
if (!contains(clipStackBounds, {glyphBounds.x(), glyphBounds.y()})) {
|
||||||
continue;
|
continue;
|
||||||
@ -1081,7 +1079,7 @@ bool SkPDFDevice::handleInversePath(const SkPath& origPath,
|
|||||||
// To be consistent with the raster output, hairline strokes
|
// To be consistent with the raster output, hairline strokes
|
||||||
// are rendered as non-inverted.
|
// are rendered as non-inverted.
|
||||||
modifiedPath.toggleInverseFillType();
|
modifiedPath.toggleInverseFillType();
|
||||||
this->internalDrawPath(this->cs(), this->ctm(), modifiedPath, paint, true);
|
this->internalDrawPath(this->cs(), this->localToDevice(), modifiedPath, paint, true);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1089,7 +1087,7 @@ bool SkPDFDevice::handleInversePath(const SkPath& origPath,
|
|||||||
// Get bounds of clip in current transform space
|
// Get bounds of clip in current transform space
|
||||||
// (clip bounds are given in device space).
|
// (clip bounds are given in device space).
|
||||||
SkMatrix transformInverse;
|
SkMatrix transformInverse;
|
||||||
SkMatrix totalMatrix = this->ctm();
|
SkMatrix totalMatrix = this->localToDevice();
|
||||||
|
|
||||||
if (!totalMatrix.invert(&transformInverse)) {
|
if (!totalMatrix.invert(&transformInverse)) {
|
||||||
return false;
|
return false;
|
||||||
@ -1106,7 +1104,7 @@ bool SkPDFDevice::handleInversePath(const SkPath& origPath,
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
this->internalDrawPath(this->cs(), this->ctm(), modifiedPath, noInversePaint, true);
|
this->internalDrawPath(this->cs(), this->localToDevice(), modifiedPath, noInversePaint, true);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1578,7 +1576,7 @@ void SkPDFDevice::internalDrawImageRect(SkKeyedImage imageSubset,
|
|||||||
if (paint->getMaskFilter()) {
|
if (paint->getMaskFilter()) {
|
||||||
paint.writable()->setShader(imageSubset.image()->makeShader(&transform));
|
paint.writable()->setShader(imageSubset.image()->makeShader(&transform));
|
||||||
SkPath path = to_path(dst); // handles non-integral clipping.
|
SkPath path = to_path(dst); // handles non-integral clipping.
|
||||||
this->internalDrawPath(this->cs(), this->ctm(), path, *paint, true);
|
this->internalDrawPath(this->cs(), this->localToDevice(), path, *paint, true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
transform.postConcat(ctm);
|
transform.postConcat(ctm);
|
||||||
@ -1725,7 +1723,7 @@ void SkPDFDevice::drawSpecial(SkSpecialImage* srcImg, int x, int y, const SkPain
|
|||||||
SkImageFilter* filter = paint.getImageFilter();
|
SkImageFilter* filter = paint.getImageFilter();
|
||||||
if (filter) {
|
if (filter) {
|
||||||
SkIPoint offset = SkIPoint::Make(0, 0);
|
SkIPoint offset = SkIPoint::Make(0, 0);
|
||||||
SkMatrix matrix = this->ctm();
|
SkMatrix matrix = this->localToDevice();
|
||||||
matrix.postTranslate(SkIntToScalar(-x), SkIntToScalar(-y));
|
matrix.postTranslate(SkIntToScalar(-x), SkIntToScalar(-y));
|
||||||
const SkIRect clipBounds =
|
const SkIRect clipBounds =
|
||||||
this->cs().bounds(this->bounds()).roundOut().makeOffset(-x, -y);
|
this->cs().bounds(this->bounds()).roundOut().makeOffset(-x, -y);
|
||||||
|
@ -231,7 +231,7 @@ struct SkSVGDevice::MxCp {
|
|||||||
const SkClipStack* fClipStack;
|
const SkClipStack* fClipStack;
|
||||||
|
|
||||||
MxCp(const SkMatrix* mx, const SkClipStack* cs) : fMatrix(mx), fClipStack(cs) {}
|
MxCp(const SkMatrix* mx, const SkClipStack* cs) : fMatrix(mx), fClipStack(cs) {}
|
||||||
MxCp(SkSVGDevice* device) : fMatrix(&device->ctm()), fClipStack(&device->cs()) {}
|
MxCp(SkSVGDevice* device) : fMatrix(&device->localToDevice()), fClipStack(&device->cs()) {}
|
||||||
};
|
};
|
||||||
|
|
||||||
class SkSVGDevice::AutoElement : ::SkNoncopyable {
|
class SkSVGDevice::AutoElement : ::SkNoncopyable {
|
||||||
@ -764,7 +764,7 @@ void SkSVGDevice::drawAnnotation(const SkRect& rect, const char key[], SkData* v
|
|||||||
if (!strcmp(SkAnnotationKeys::URL_Key(), key) ||
|
if (!strcmp(SkAnnotationKeys::URL_Key(), key) ||
|
||||||
!strcmp(SkAnnotationKeys::Link_Named_Dest_Key(), key)) {
|
!strcmp(SkAnnotationKeys::Link_Named_Dest_Key(), key)) {
|
||||||
this->cs().save();
|
this->cs().save();
|
||||||
this->cs().clipRect(rect, this->ctm(), kIntersect_SkClipOp, true);
|
this->cs().clipRect(rect, this->localToDevice(), kIntersect_SkClipOp, true);
|
||||||
SkRect transformedRect = this->cs().bounds(this->getGlobalBounds());
|
SkRect transformedRect = this->cs().bounds(this->getGlobalBounds());
|
||||||
this->cs().restore();
|
this->cs().restore();
|
||||||
if (transformedRect.isEmpty()) {
|
if (transformedRect.isEmpty()) {
|
||||||
@ -910,14 +910,14 @@ void SkSVGDevice::drawBitmapRect(const SkBitmap& bm, const SkRect* srcOrNull,
|
|||||||
SkClipStack::AutoRestore ar(cs, false);
|
SkClipStack::AutoRestore ar(cs, false);
|
||||||
if (srcOrNull && *srcOrNull != SkRect::Make(bm.bounds())) {
|
if (srcOrNull && *srcOrNull != SkRect::Make(bm.bounds())) {
|
||||||
cs->save();
|
cs->save();
|
||||||
cs->clipRect(dst, this->ctm(), kIntersect_SkClipOp, paint.isAntiAlias());
|
cs->clipRect(dst, this->localToDevice(), kIntersect_SkClipOp, paint.isAntiAlias());
|
||||||
}
|
}
|
||||||
|
|
||||||
SkMatrix adjustedMatrix;
|
SkMatrix adjustedMatrix;
|
||||||
adjustedMatrix.setRectToRect(srcOrNull ? *srcOrNull : SkRect::Make(bm.bounds()),
|
adjustedMatrix.setRectToRect(srcOrNull ? *srcOrNull : SkRect::Make(bm.bounds()),
|
||||||
dst,
|
dst,
|
||||||
SkMatrix::kFill_ScaleToFit);
|
SkMatrix::kFill_ScaleToFit);
|
||||||
adjustedMatrix.postConcat(this->ctm());
|
adjustedMatrix.postConcat(this->localToDevice());
|
||||||
|
|
||||||
drawBitmapCommon(MxCp(&adjustedMatrix, cs), bm, paint);
|
drawBitmapCommon(MxCp(&adjustedMatrix, cs), bm, paint);
|
||||||
}
|
}
|
||||||
|
@ -571,10 +571,11 @@ void SkBaseDevice::drawShadow(const SkPath& path, const SkDrawShadowRec& rec) {
|
|||||||
// For perspective shadows we've already computed the shadow in world space,
|
// For perspective shadows we've already computed the shadow in world space,
|
||||||
// and we can't translate it without changing it. Otherwise we concat the
|
// and we can't translate it without changing it. Otherwise we concat the
|
||||||
// change in translation from the cached version.
|
// change in translation from the cached version.
|
||||||
SkAutoDeviceCTMRestore adr(
|
SkAutoDeviceTransformRestore adr(
|
||||||
this,
|
this,
|
||||||
hasPerspective ? SkMatrix::I()
|
hasPerspective ? SkMatrix::I()
|
||||||
: SkMatrix::Concat(this->ctm(), SkMatrix::MakeTrans(tx, ty)));
|
: SkMatrix::Concat(this->localToDevice(),
|
||||||
|
SkMatrix::MakeTrans(tx, ty)));
|
||||||
this->drawVertices(vertices, nullptr, 0, mode, paint);
|
this->drawVertices(vertices, nullptr, 0, mode, paint);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -583,8 +584,8 @@ void SkBaseDevice::drawShadow(const SkPath& path, const SkDrawShadowRec& rec) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
SkMatrix viewMatrix = this->ctm();
|
SkMatrix viewMatrix = this->localToDevice();
|
||||||
SkAutoDeviceCTMRestore adr(this, SkMatrix::I());
|
SkAutoDeviceTransformRestore adr(this, SkMatrix::I());
|
||||||
|
|
||||||
ShadowedPath shadowedPath(&path, &viewMatrix);
|
ShadowedPath shadowedPath(&path, &viewMatrix);
|
||||||
|
|
||||||
@ -752,7 +753,7 @@ void SkBaseDevice::drawShadow(const SkPath& path, const SkDrawShadowRec& rec) {
|
|||||||
&shadowMatrix, &radius)) {
|
&shadowMatrix, &radius)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
SkAutoDeviceCTMRestore adr(this, shadowMatrix);
|
SkAutoDeviceTransformRestore adr(this, shadowMatrix);
|
||||||
|
|
||||||
SkPaint paint;
|
SkPaint paint;
|
||||||
paint.setColor(rec.fSpotColor);
|
paint.setColor(rec.fSpotColor);
|
||||||
|
@ -1179,7 +1179,7 @@ void SkXPSDevice::internalDrawRect(const SkRect& r,
|
|||||||
}
|
}
|
||||||
|
|
||||||
//Path the rect if we can't optimize it.
|
//Path the rect if we can't optimize it.
|
||||||
if (rect_must_be_pathed(paint, this->ctm())) {
|
if (rect_must_be_pathed(paint, this->localToDevice())) {
|
||||||
SkPath tmp;
|
SkPath tmp;
|
||||||
tmp.addRect(r);
|
tmp.addRect(r);
|
||||||
tmp.setFillType(SkPath::kWinding_FillType);
|
tmp.setFillType(SkPath::kWinding_FillType);
|
||||||
@ -1204,13 +1204,13 @@ void SkXPSDevice::internalDrawRect(const SkRect& r,
|
|||||||
//Set the brushes.
|
//Set the brushes.
|
||||||
BOOL fill = FALSE;
|
BOOL fill = FALSE;
|
||||||
BOOL stroke = FALSE;
|
BOOL stroke = FALSE;
|
||||||
HRV(this->shadePath(shadedPath.get(), paint, this->ctm(), &fill, &stroke));
|
HRV(this->shadePath(shadedPath.get(), paint, this->localToDevice(), &fill, &stroke));
|
||||||
|
|
||||||
bool xpsTransformsPath = true;
|
bool xpsTransformsPath = true;
|
||||||
//Transform the geometry.
|
//Transform the geometry.
|
||||||
if (transformRect && xpsTransformsPath) {
|
if (transformRect && xpsTransformsPath) {
|
||||||
SkTScopedComPtr<IXpsOMMatrixTransform> xpsTransform;
|
SkTScopedComPtr<IXpsOMMatrixTransform> xpsTransform;
|
||||||
HRV(this->createXpsTransform(this->ctm(), &xpsTransform));
|
HRV(this->createXpsTransform(this->localToDevice(), &xpsTransform));
|
||||||
if (xpsTransform.get()) {
|
if (xpsTransform.get()) {
|
||||||
HRVM(shadedGeometry->SetTransformLocal(xpsTransform.get()),
|
HRVM(shadedGeometry->SetTransformLocal(xpsTransform.get()),
|
||||||
"Could not set transform for rect.");
|
"Could not set transform for rect.");
|
||||||
@ -1229,7 +1229,7 @@ void SkXPSDevice::internalDrawRect(const SkRect& r,
|
|||||||
{ r.fRight, r.fTop },
|
{ r.fRight, r.fTop },
|
||||||
};
|
};
|
||||||
if (!xpsTransformsPath && transformRect) {
|
if (!xpsTransformsPath && transformRect) {
|
||||||
this->ctm().mapPoints(points, SK_ARRAY_COUNT(points));
|
this->localToDevice().mapPoints(points, SK_ARRAY_COUNT(points));
|
||||||
}
|
}
|
||||||
HRV(this->createXpsQuad(points, stroke, fill, &rectFigure));
|
HRV(this->createXpsQuad(points, stroke, fill, &rectFigure));
|
||||||
}
|
}
|
||||||
@ -1495,7 +1495,7 @@ void SkXPSDevice::drawPath(const SkPath& platonicPath,
|
|||||||
|| paint->getStyle() != SkPaint::kFill_Style;
|
|| paint->getStyle() != SkPaint::kFill_Style;
|
||||||
|
|
||||||
//Apply pre-path matrix [Platonic-path -> Skeletal-path].
|
//Apply pre-path matrix [Platonic-path -> Skeletal-path].
|
||||||
SkMatrix matrix = this->ctm();
|
SkMatrix matrix = this->localToDevice();
|
||||||
SkPath* skeletalPath = const_cast<SkPath*>(&platonicPath);
|
SkPath* skeletalPath = const_cast<SkPath*>(&platonicPath);
|
||||||
|
|
||||||
//Apply path effect [Skeletal-path -> Fillable-path].
|
//Apply path effect [Skeletal-path -> Fillable-path].
|
||||||
@ -1545,7 +1545,7 @@ void SkXPSDevice::drawPath(const SkPath& platonicPath,
|
|||||||
BOOL stroke;
|
BOOL stroke;
|
||||||
HRV(this->shadePath(shadedPath.get(),
|
HRV(this->shadePath(shadedPath.get(),
|
||||||
*paint,
|
*paint,
|
||||||
this->ctm(),
|
this->localToDevice(),
|
||||||
&fill,
|
&fill,
|
||||||
&stroke));
|
&stroke));
|
||||||
|
|
||||||
@ -1898,7 +1898,8 @@ void SkXPSDevice::drawGlyphRunList(const SkGlyphRunList& glyphRunList) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
TypefaceUse* typeface;
|
TypefaceUse* typeface;
|
||||||
if (FAILED(CreateTypefaceUse(font, &typeface)) || text_must_be_pathed(paint, this->ctm())) {
|
if (FAILED(CreateTypefaceUse(font, &typeface)) ||
|
||||||
|
text_must_be_pathed(paint, this->localToDevice())) {
|
||||||
SkPath path;
|
SkPath path;
|
||||||
//TODO: make this work, Draw currently does not handle as well.
|
//TODO: make this work, Draw currently does not handle as well.
|
||||||
//paint.getTextPath(text, byteLength, x, y, &path);
|
//paint.getTextPath(text, byteLength, x, y, &path);
|
||||||
@ -1937,7 +1938,7 @@ void SkXPSDevice::drawGlyphRunList(const SkGlyphRunList& glyphRunList) {
|
|||||||
&origin,
|
&origin,
|
||||||
SkScalarToFLOAT(font.getSize()),
|
SkScalarToFLOAT(font.getSize()),
|
||||||
XPS_STYLE_SIMULATION_NONE,
|
XPS_STYLE_SIMULATION_NONE,
|
||||||
this->ctm(),
|
this->localToDevice(),
|
||||||
paint));
|
paint));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -32,7 +32,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
void drawRect(const SkRect& r, const SkPaint& paint) override {
|
void drawRect(const SkRect& r, const SkPaint& paint) override {
|
||||||
fLastMatrix = this->ctm();
|
fLastMatrix = this->localToDevice();
|
||||||
this->INHERITED::drawRect(r, paint);
|
this->INHERITED::drawRect(r, paint);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user