Remove prePathMatrix from SkDevice::drawPath
Change-Id: Id49d171252cab33378f00021bb395e6ae6991178 Reviewed-on: https://skia-review.googlesource.com/147101 Commit-Queue: Robert Phillips <robertphillips@google.com> Reviewed-by: Mike Reed <reed@google.com>
This commit is contained in:
parent
916c498c04
commit
137ca523a3
@ -99,7 +99,7 @@ public:
|
||||
void addDrawOp(const GrClip&, std::unique_ptr<GrAtlasTextOp> op) override;
|
||||
|
||||
void drawPath(const GrClip&, const SkPath&, const SkPaint&, const SkMatrix& viewMatrix,
|
||||
const SkMatrix* pathMatrix) override {
|
||||
bool pathIsMutable) override {
|
||||
SkDebugf("Path glyph??");
|
||||
}
|
||||
|
||||
|
@ -386,7 +386,7 @@ void SkBitmapDevice::drawOval(const SkRect& oval, const SkPaint& paint) {
|
||||
path.addOval(oval);
|
||||
// call the VIRTUAL version, so any subclasses who do handle drawPath aren't
|
||||
// required to override drawOval.
|
||||
this->drawPath(path, paint, nullptr, true);
|
||||
this->drawPath(path, paint, true);
|
||||
}
|
||||
|
||||
void SkBitmapDevice::drawRRect(const SkRRect& rrect, const SkPaint& paint) {
|
||||
@ -396,33 +396,25 @@ void SkBitmapDevice::drawRRect(const SkRRect& rrect, const SkPaint& paint) {
|
||||
path.addRRect(rrect);
|
||||
// call the VIRTUAL version, so any subclasses who do handle drawPath aren't
|
||||
// required to override drawRRect.
|
||||
this->drawPath(path, paint, nullptr, true);
|
||||
this->drawPath(path, paint, true);
|
||||
#else
|
||||
LOOP_TILER( drawRRect(rrect, paint), Bounder(rrect.getBounds(), paint))
|
||||
#endif
|
||||
}
|
||||
|
||||
void SkBitmapDevice::drawPath(const SkPath& path,
|
||||
const SkPaint& paint, const SkMatrix* prePathMatrix,
|
||||
const SkPaint& paint,
|
||||
bool pathIsMutable) {
|
||||
const SkRect* bounds = nullptr;
|
||||
SkRect storage;
|
||||
if (SkDrawTiler::NeedsTiling(this)) {
|
||||
if (!path.isInverseFillType()) {
|
||||
if (prePathMatrix) {
|
||||
prePathMatrix->mapRect(&storage, path.getBounds());
|
||||
bounds = &storage;
|
||||
} else {
|
||||
bounds = &path.getBounds();
|
||||
}
|
||||
}
|
||||
if (SkDrawTiler::NeedsTiling(this) && !path.isInverseFillType()) {
|
||||
bounds = &path.getBounds();
|
||||
}
|
||||
SkDrawTiler tiler(this, bounds ? Bounder(*bounds, paint).bounds() : nullptr);
|
||||
if (tiler.needsTiling()) {
|
||||
pathIsMutable = false;
|
||||
}
|
||||
while (const SkDraw* draw = tiler.next()) {
|
||||
draw->drawPath(path, paint, prePathMatrix, pathIsMutable);
|
||||
draw->drawPath(path, paint, nullptr, pathIsMutable);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -89,14 +89,8 @@ protected:
|
||||
* non-const pointer and modify it in place (as an optimization). Canvas
|
||||
* may do this to implement helpers such as drawOval, by placing a temp
|
||||
* path on the stack to hold the representation of the oval.
|
||||
*
|
||||
* If prePathMatrix is not null, it should logically be applied before any
|
||||
* stroking or other effects. If there are no effects on the paint that
|
||||
* affect the geometry/rasterization, then the pre matrix can just be
|
||||
* pre-concated with the current matrix.
|
||||
*/
|
||||
void drawPath(const SkPath&, const SkPaint&, const SkMatrix* prePathMatrix,
|
||||
bool pathIsMutable) override;
|
||||
void drawPath(const SkPath&, const SkPaint&, bool pathIsMutable) override;
|
||||
void drawBitmap(const SkBitmap&, SkScalar x, SkScalar y, const SkPaint&) override;
|
||||
void drawSprite(const SkBitmap&, int x, int y, const SkPaint&) override;
|
||||
|
||||
|
@ -97,7 +97,8 @@ void SkBaseDevice::drawRegion(const SkRegion& region, const SkPaint& paint) {
|
||||
if (isNonTranslate || complexPaint || antiAlias) {
|
||||
SkPath path;
|
||||
region.getBoundaryPath(&path);
|
||||
return this->drawPath(path, paint, nullptr, false);
|
||||
path.setIsVolatile(true);
|
||||
return this->drawPath(path, paint, true);
|
||||
}
|
||||
|
||||
SkRegion::Iterator it(region);
|
||||
@ -124,9 +125,7 @@ void SkBaseDevice::drawDRRect(const SkRRect& outer,
|
||||
path.setFillType(SkPath::kEvenOdd_FillType);
|
||||
path.setIsVolatile(true);
|
||||
|
||||
const SkMatrix* preMatrix = nullptr;
|
||||
const bool pathIsMutable = true;
|
||||
this->drawPath(path, paint, preMatrix, pathIsMutable);
|
||||
this->drawPath(path, paint, true);
|
||||
}
|
||||
|
||||
void SkBaseDevice::drawPatch(const SkPoint cubics[12], const SkColor colors[4],
|
||||
@ -425,7 +424,7 @@ void SkBaseDevice::drawTextOnPath(const void* text, size_t byteLength,
|
||||
m.postConcat(*matrix);
|
||||
}
|
||||
morphpath(&tmp, *iterPath, meas, m);
|
||||
this->drawPath(tmp, iter.getPaint(), nullptr, true);
|
||||
this->drawPath(tmp, iter.getPaint(), true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -180,15 +180,9 @@ protected:
|
||||
* non-const pointer and modify it in place (as an optimization). Canvas
|
||||
* may do this to implement helpers such as drawOval, by placing a temp
|
||||
* path on the stack to hold the representation of the oval.
|
||||
*
|
||||
* If prePathMatrix is not null, it should logically be applied before any
|
||||
* stroking or other effects. If there are no effects on the paint that
|
||||
* affect the geometry/rasterization, then the pre matrix can just be
|
||||
* pre-concated with the current matrix.
|
||||
*/
|
||||
virtual void drawPath(const SkPath& path,
|
||||
const SkPaint& paint,
|
||||
const SkMatrix* prePathMatrix = nullptr,
|
||||
bool pathIsMutable = false) = 0;
|
||||
virtual void drawBitmap(const SkBitmap& bitmap,
|
||||
SkScalar x,
|
||||
@ -418,7 +412,7 @@ protected:
|
||||
void drawRect(const SkRect&, const SkPaint&) override {}
|
||||
void drawOval(const SkRect&, const SkPaint&) override {}
|
||||
void drawRRect(const SkRRect&, const SkPaint&) override {}
|
||||
void drawPath(const SkPath&, const SkPaint&, const SkMatrix*, bool) override {}
|
||||
void drawPath(const SkPath&, const SkPaint&, bool) override {}
|
||||
void drawBitmap(const SkBitmap&, SkScalar x, SkScalar y, const SkPaint&) override {}
|
||||
void drawSprite(const SkBitmap&, int, int, const SkPaint&) override {}
|
||||
void drawBitmapRect(const SkBitmap&, const SkRect*, const SkRect&, const SkPaint&,
|
||||
|
@ -534,18 +534,22 @@ void SkDraw::drawPoints(SkCanvas::PointMode mode, size_t count,
|
||||
SkScalar radius = SkScalarHalf(width);
|
||||
|
||||
if (newPaint.getStrokeCap() == SkPaint::kRound_Cap) {
|
||||
SkPath path;
|
||||
SkMatrix preMatrix;
|
||||
if (device) {
|
||||
for (size_t i = 0; i < count; ++i) {
|
||||
SkRect r = SkRect::MakeLTRB(pts[i].fX - radius, pts[i].fY - radius,
|
||||
pts[i].fX + radius, pts[i].fY + radius);
|
||||
device->drawOval(r, newPaint);
|
||||
}
|
||||
} else {
|
||||
SkPath path;
|
||||
SkMatrix preMatrix;
|
||||
|
||||
path.addCircle(0, 0, radius);
|
||||
for (size_t i = 0; i < count; i++) {
|
||||
preMatrix.setTranslate(pts[i].fX, pts[i].fY);
|
||||
// pass true for the last point, since we can modify
|
||||
// then path then
|
||||
path.setIsVolatile((count-1) == i);
|
||||
if (device) {
|
||||
device->drawPath(path, newPaint, &preMatrix, (count-1) == i);
|
||||
} else {
|
||||
path.addCircle(0, 0, radius);
|
||||
for (size_t i = 0; i < count; i++) {
|
||||
preMatrix.setTranslate(pts[i].fX, pts[i].fY);
|
||||
// pass true for the last point, since we can modify
|
||||
// then path then
|
||||
path.setIsVolatile((count-1) == i);
|
||||
this->drawPath(path, newPaint, &preMatrix, (count-1) == i);
|
||||
}
|
||||
}
|
||||
@ -661,7 +665,7 @@ void SkDraw::drawPoints(SkCanvas::PointMode mode, size_t count,
|
||||
path.moveTo(pts[i]);
|
||||
path.lineTo(pts[i+1]);
|
||||
if (device) {
|
||||
device->drawPath(path, p, nullptr, true);
|
||||
device->drawPath(path, p, true);
|
||||
} else {
|
||||
this->drawPath(path, p, nullptr, true);
|
||||
}
|
||||
|
@ -267,41 +267,17 @@ void GrBlurUtils::drawPathWithMaskFilter(GrContext* context,
|
||||
void GrBlurUtils::drawPathWithMaskFilter(GrContext* context,
|
||||
GrRenderTargetContext* renderTargetContext,
|
||||
const GrClip& clip,
|
||||
const SkPath& origPath,
|
||||
const SkPath& path,
|
||||
const SkPaint& paint,
|
||||
const SkMatrix& origViewMatrix,
|
||||
const SkMatrix* prePathMatrix,
|
||||
const SkMatrix& viewMatrix,
|
||||
bool pathIsMutable) {
|
||||
if (context->abandoned()) {
|
||||
return;
|
||||
}
|
||||
|
||||
SkASSERT(!pathIsMutable || origPath.isVolatile());
|
||||
SkASSERT(!pathIsMutable || path.isVolatile());
|
||||
|
||||
GrStyle style(paint);
|
||||
// If we have a prematrix, apply it to the path, optimizing for the case
|
||||
// where the original path can in fact be modified in place (even though
|
||||
// its parameter type is const).
|
||||
|
||||
const SkPath* path = &origPath;
|
||||
SkTLazy<SkPath> tmpPath;
|
||||
|
||||
SkMatrix viewMatrix = origViewMatrix;
|
||||
|
||||
if (prePathMatrix) {
|
||||
// Styling, blurs, and shading are supposed to be applied *after* the prePathMatrix.
|
||||
if (!paint.getMaskFilter() && !paint.getShader() && !style.applies()) {
|
||||
viewMatrix.preConcat(*prePathMatrix);
|
||||
} else {
|
||||
SkPath* result = pathIsMutable ? const_cast<SkPath*>(path) : tmpPath.init();
|
||||
pathIsMutable = true;
|
||||
path->transform(*prePathMatrix, result);
|
||||
path = result;
|
||||
result->setIsVolatile(true);
|
||||
}
|
||||
}
|
||||
// at this point we're done with prePathMatrix
|
||||
SkDEBUGCODE(prePathMatrix = (const SkMatrix*)0x50FF8001;)
|
||||
|
||||
GrPaint grPaint;
|
||||
if (!SkPaintToGrPaint(context, renderTargetContext->colorSpaceInfo(), paint, viewMatrix,
|
||||
@ -313,8 +289,8 @@ void GrBlurUtils::drawPathWithMaskFilter(GrContext* context,
|
||||
if (mf && !mf->hasFragmentProcessor()) {
|
||||
// The MaskFilter wasn't already handled in SkPaintToGrPaint
|
||||
draw_path_with_mask_filter(context, renderTargetContext, clip, std::move(grPaint), aa,
|
||||
viewMatrix, mf, style, path, pathIsMutable);
|
||||
viewMatrix, mf, style, &path, pathIsMutable);
|
||||
} else {
|
||||
renderTargetContext->drawPath(clip, std::move(grPaint), aa, viewMatrix, *path, style);
|
||||
renderTargetContext->drawPath(clip, std::move(grPaint), aa, viewMatrix, path, style);
|
||||
}
|
||||
}
|
||||
|
@ -37,7 +37,6 @@ namespace GrBlurUtils {
|
||||
const SkPath& origSrcPath,
|
||||
const SkPaint& paint,
|
||||
const SkMatrix& origViewMatrix,
|
||||
const SkMatrix* prePathMatrix,
|
||||
bool pathIsMutable);
|
||||
|
||||
/**
|
||||
|
@ -69,10 +69,9 @@ public:
|
||||
}
|
||||
|
||||
void drawPath(const GrClip& clip, const SkPath& path, const SkPaint& paint,
|
||||
const SkMatrix& viewMatrix, const SkMatrix* pathMatrix) override {
|
||||
const SkMatrix& viewMatrix, bool pathIsMutable) override {
|
||||
GrBlurUtils::drawPathWithMaskFilter(fRenderTargetContext->fContext, fRenderTargetContext,
|
||||
clip, path, paint, viewMatrix, pathMatrix,
|
||||
false);
|
||||
clip, path, paint, viewMatrix, pathIsMutable);
|
||||
}
|
||||
|
||||
void makeGrPaint(GrMaskFormat maskFormat, const SkPaint& skPaint, const SkMatrix& viewMatrix,
|
||||
|
@ -383,7 +383,7 @@ void SkGpuDevice::drawRect(const SkRect& rect, const SkPaint& paint) {
|
||||
path.setIsVolatile(true);
|
||||
path.addRect(rect);
|
||||
GrBlurUtils::drawPathWithMaskFilter(fContext.get(), fRenderTargetContext.get(),
|
||||
this->clip(), path, paint, this->ctm(), nullptr, true);
|
||||
this->clip(), path, paint, this->ctm(), true);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -443,7 +443,7 @@ void SkGpuDevice::drawRRect(const SkRRect& rrect, const SkPaint& paint) {
|
||||
path.setIsVolatile(true);
|
||||
path.addRRect(rrect);
|
||||
GrBlurUtils::drawPathWithMaskFilter(fContext.get(), fRenderTargetContext.get(),
|
||||
this->clip(), path, paint, this->ctm(), nullptr, true);
|
||||
this->clip(), path, paint, this->ctm(), true);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -487,7 +487,7 @@ void SkGpuDevice::drawDRRect(const SkRRect& outer,
|
||||
path.setFillType(SkPath::kEvenOdd_FillType);
|
||||
|
||||
GrBlurUtils::drawPathWithMaskFilter(fContext.get(), fRenderTargetContext.get(), this->clip(),
|
||||
path, paint, this->ctm(), nullptr, true);
|
||||
path, paint, this->ctm(), true);
|
||||
}
|
||||
|
||||
|
||||
@ -497,7 +497,8 @@ void SkGpuDevice::drawRegion(const SkRegion& region, const SkPaint& paint) {
|
||||
if (paint.getMaskFilter()) {
|
||||
SkPath path;
|
||||
region.getBoundaryPath(&path);
|
||||
return this->drawPath(path, paint, nullptr, false);
|
||||
path.setIsVolatile(true);
|
||||
return this->drawPath(path, paint, true);
|
||||
}
|
||||
|
||||
GrPaint grPaint;
|
||||
@ -605,10 +606,10 @@ void SkGpuDevice::drawStrokedLine(const SkPoint points[2],
|
||||
}
|
||||
|
||||
void SkGpuDevice::drawPath(const SkPath& origSrcPath,
|
||||
const SkPaint& paint, const SkMatrix* prePathMatrix,
|
||||
const SkPaint& paint,
|
||||
bool pathIsMutable) {
|
||||
ASSERT_SINGLE_OWNER
|
||||
if (!origSrcPath.isInverseFillType() && !paint.getPathEffect() && !prePathMatrix) {
|
||||
if (!origSrcPath.isInverseFillType() && !paint.getPathEffect()) {
|
||||
SkPoint points[2];
|
||||
if (SkPaint::kStroke_Style == paint.getStyle() && paint.getStrokeWidth() > 0 &&
|
||||
!paint.getMaskFilter() && SkPaint::kRound_Cap != paint.getStrokeCap() &&
|
||||
@ -625,7 +626,7 @@ void SkGpuDevice::drawPath(const SkPath& origSrcPath,
|
||||
}
|
||||
|
||||
GR_CREATE_TRACE_MARKER_CONTEXT("SkGpuDevice", "drawPath", fContext.get());
|
||||
if (!prePathMatrix && !paint.getMaskFilter()) {
|
||||
if (!paint.getMaskFilter()) {
|
||||
GrPaint grPaint;
|
||||
if (!SkPaintToGrPaint(this->context(), fRenderTargetContext->colorSpaceInfo(), paint,
|
||||
this->ctm(), &grPaint)) {
|
||||
@ -636,8 +637,7 @@ void SkGpuDevice::drawPath(const SkPath& origSrcPath,
|
||||
return;
|
||||
}
|
||||
GrBlurUtils::drawPathWithMaskFilter(fContext.get(), fRenderTargetContext.get(), this->clip(),
|
||||
origSrcPath, paint, this->ctm(), prePathMatrix,
|
||||
pathIsMutable);
|
||||
origSrcPath, paint, this->ctm(), pathIsMutable);
|
||||
}
|
||||
|
||||
static const int kBmpSmallTileSize = 1 << 10;
|
||||
|
@ -73,16 +73,13 @@ public:
|
||||
const SkPaint& paint) override;
|
||||
void drawRect(const SkRect& r, const SkPaint& paint) override;
|
||||
void drawRRect(const SkRRect& r, const SkPaint& paint) override;
|
||||
void drawDRRect(const SkRRect& outer, const SkRRect& inner,
|
||||
const SkPaint& paint) override;
|
||||
void drawDRRect(const SkRRect& outer, const SkRRect& inner, const SkPaint& paint) override;
|
||||
void drawRegion(const SkRegion& r, const SkPaint& paint) override;
|
||||
void drawOval(const SkRect& oval, const SkPaint& paint) override;
|
||||
void drawArc(const SkRect& oval, SkScalar startAngle, SkScalar sweepAngle,
|
||||
bool useCenter, const SkPaint& paint) override;
|
||||
void drawPath(const SkPath& path, const SkPaint& paint,
|
||||
const SkMatrix* prePathMatrix, bool pathIsMutable) override;
|
||||
void drawBitmap(const SkBitmap&, SkScalar x, SkScalar y,
|
||||
const SkPaint&) override;
|
||||
void drawPath(const SkPath& path, const SkPaint& paint, bool pathIsMutable) override;
|
||||
void drawBitmap(const SkBitmap&, SkScalar x, SkScalar y, const SkPaint&) override;
|
||||
void drawBitmapRect(const SkBitmap&, const SkRect* srcOrNull, const SkRect& dst,
|
||||
const SkPaint& paint, SkCanvas::SrcRectConstraint) override;
|
||||
void drawSprite(const SkBitmap& bitmap, int x, int y,
|
||||
|
@ -9,6 +9,7 @@
|
||||
#include "GrBlurUtils.h"
|
||||
#include "GrClip.h"
|
||||
#include "GrContext.h"
|
||||
#include "GrStyle.h"
|
||||
#include "GrTextTarget.h"
|
||||
#include "SkColorFilter.h"
|
||||
#include "SkGlyphCache.h"
|
||||
@ -295,11 +296,31 @@ void GrTextBlob::flush(GrTextTarget* target, const SkSurfaceProps& props,
|
||||
GrTextBlob::Run::PathGlyph& pathGlyph = run.fPathGlyphs[i];
|
||||
calculate_translation(pathGlyph.fPreTransformed, viewMatrix, x, y,
|
||||
fInitialViewMatrix, fInitialX, fInitialY, &transX, &transY);
|
||||
const SkMatrix& ctm = pathGlyph.fPreTransformed ? SkMatrix::I() : viewMatrix;
|
||||
|
||||
const SkMatrix* ctm = pathGlyph.fPreTransformed ? &SkMatrix::I() : &viewMatrix;
|
||||
SkMatrix pathMatrix;
|
||||
pathMatrix.setScale(pathGlyph.fScale, pathGlyph.fScale);
|
||||
pathMatrix.postTranslate(pathGlyph.fX + transX, pathGlyph.fY + transY);
|
||||
target->drawPath(clip, pathGlyph.fPath, runPaint, ctm, &pathMatrix);
|
||||
|
||||
const SkPath* path = &pathGlyph.fPath;
|
||||
bool pathIsMutable = false;
|
||||
SkTLazy<SkPath> tmpPath;
|
||||
|
||||
GrStyle style(runPaint);
|
||||
|
||||
// Styling, blurs, and shading are supposed to be applied *after* the pathMatrix.
|
||||
if (!runPaint.getMaskFilter() && !runPaint.getShader() && !style.applies()) {
|
||||
pathMatrix.postConcat(*ctm);
|
||||
ctm = &pathMatrix;
|
||||
} else {
|
||||
SkPath* result = tmpPath.init();
|
||||
path->transform(pathMatrix, result);
|
||||
result->setIsVolatile(true);
|
||||
path = result;
|
||||
pathIsMutable = true;
|
||||
}
|
||||
|
||||
target->drawPath(clip, *path, runPaint, *ctm, pathIsMutable);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -31,7 +31,7 @@ public:
|
||||
virtual void addDrawOp(const GrClip&, std::unique_ptr<GrAtlasTextOp> op) = 0;
|
||||
|
||||
virtual void drawPath(const GrClip&, const SkPath&, const SkPaint&,
|
||||
const SkMatrix& viewMatrix, const SkMatrix* pathMatrix) = 0;
|
||||
const SkMatrix& viewMatrix, bool pathIsMutable) = 0;
|
||||
|
||||
virtual void makeGrPaint(GrMaskFormat, const SkPaint&, const SkMatrix& viewMatrix,
|
||||
GrPaint*) = 0;
|
||||
|
@ -787,7 +787,7 @@ void SkPDFDevice::drawRect(const SkRect& rect,
|
||||
if (paint.getPathEffect() || paint.getMaskFilter()) {
|
||||
SkPath path;
|
||||
path.addRect(r);
|
||||
this->drawPath(path, paint, nullptr, true);
|
||||
this->drawPath(path, paint, true);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -809,7 +809,7 @@ void SkPDFDevice::drawRRect(const SkRRect& rrect,
|
||||
replace_srcmode_on_opaque_paint(&paint);
|
||||
SkPath path;
|
||||
path.addRRect(rrect);
|
||||
this->drawPath(path, paint, nullptr, true);
|
||||
this->drawPath(path, paint, true);
|
||||
}
|
||||
|
||||
void SkPDFDevice::drawOval(const SkRect& oval,
|
||||
@ -822,28 +822,23 @@ void SkPDFDevice::drawOval(const SkRect& oval,
|
||||
replace_srcmode_on_opaque_paint(&paint);
|
||||
SkPath path;
|
||||
path.addOval(oval);
|
||||
this->drawPath(path, paint, nullptr, true);
|
||||
this->drawPath(path, paint, true);
|
||||
}
|
||||
|
||||
void SkPDFDevice::drawPath(const SkPath& origPath,
|
||||
const SkPaint& srcPaint,
|
||||
const SkMatrix* prePathMatrix,
|
||||
bool pathIsMutable) {
|
||||
this->internalDrawPath(
|
||||
this->cs(), this->ctm(), origPath, srcPaint, prePathMatrix, pathIsMutable);
|
||||
this->internalDrawPath(this->cs(), this->ctm(), origPath, srcPaint, pathIsMutable);
|
||||
}
|
||||
|
||||
void SkPDFDevice::internalDrawPathWithFilter(const SkClipStack& clipStack,
|
||||
const SkMatrix& ctm,
|
||||
const SkPath& origPath,
|
||||
const SkPaint& origPaint,
|
||||
const SkMatrix* prePathMatrix) {
|
||||
const SkPaint& origPaint) {
|
||||
SkASSERT(origPaint.getMaskFilter());
|
||||
SkPath path(origPath);
|
||||
SkTCopyOnFirstWrite<SkPaint> paint(origPaint);
|
||||
if (prePathMatrix) {
|
||||
path.transform(*prePathMatrix, &path);
|
||||
}
|
||||
|
||||
SkStrokeRec::InitStyle initStyle = paint->getFillPath(path, &path)
|
||||
? SkStrokeRec::kFill_InitStyle
|
||||
: SkStrokeRec::kHairline_InitStyle;
|
||||
@ -906,7 +901,6 @@ void SkPDFDevice::internalDrawPath(const SkClipStack& clipStack,
|
||||
const SkMatrix& ctm,
|
||||
const SkPath& origPath,
|
||||
const SkPaint& srcPaint,
|
||||
const SkMatrix* prePathMatrix,
|
||||
bool pathIsMutable) {
|
||||
if (clipStack.isEmpty(this->bounds())) {
|
||||
return;
|
||||
@ -918,22 +912,11 @@ void SkPDFDevice::internalDrawPath(const SkClipStack& clipStack,
|
||||
SkPath* pathPtr = const_cast<SkPath*>(&origPath);
|
||||
|
||||
if (paint.getMaskFilter()) {
|
||||
this->internalDrawPathWithFilter(clipStack, ctm, origPath, paint, prePathMatrix);
|
||||
this->internalDrawPathWithFilter(clipStack, ctm, origPath, paint);
|
||||
return;
|
||||
}
|
||||
|
||||
SkMatrix matrix = ctm;
|
||||
if (prePathMatrix) {
|
||||
if (paint.getPathEffect() || paint.getStyle() != SkPaint::kFill_Style) {
|
||||
if (!pathIsMutable) {
|
||||
pathPtr = &modifiedPath;
|
||||
pathIsMutable = true;
|
||||
}
|
||||
origPath.transform(*prePathMatrix, pathPtr);
|
||||
} else {
|
||||
matrix.preConcat(*prePathMatrix);
|
||||
}
|
||||
}
|
||||
|
||||
if (paint.getPathEffect()) {
|
||||
if (clipStack.isEmpty(this->bounds())) {
|
||||
@ -953,7 +936,7 @@ void SkPDFDevice::internalDrawPath(const SkClipStack& clipStack,
|
||||
paint.setPathEffect(nullptr);
|
||||
}
|
||||
|
||||
if (this->handleInversePath(*pathPtr, paint, pathIsMutable, prePathMatrix)) {
|
||||
if (this->handleInversePath(*pathPtr, paint, pathIsMutable)) {
|
||||
return;
|
||||
}
|
||||
if (matrix.getType() & SkMatrix::kPerspective_Mask) {
|
||||
@ -1118,7 +1101,7 @@ static void draw_glyph_run_as_path(SkPDFDevice* dev, const SkGlyphRun& glyphRun,
|
||||
glyphRun.positions().data(),
|
||||
&path);
|
||||
path.offset(offset.x(), offset.y());
|
||||
dev->drawPath(path, glyphRun.paint(), nullptr, true);
|
||||
dev->drawPath(path, glyphRun.paint(), true);
|
||||
}
|
||||
|
||||
static bool has_outline_glyph(SkGlyphID gid, SkGlyphCache* cache) {
|
||||
@ -1513,8 +1496,8 @@ std::unique_ptr<SkStreamAsset> SkPDFDevice::content() const {
|
||||
* in the first place.
|
||||
*/
|
||||
bool SkPDFDevice::handleInversePath(const SkPath& origPath,
|
||||
const SkPaint& paint, bool pathIsMutable,
|
||||
const SkMatrix* prePathMatrix) {
|
||||
const SkPaint& paint,
|
||||
bool pathIsMutable) {
|
||||
if (!origPath.isInverseFillType()) {
|
||||
return false;
|
||||
}
|
||||
@ -1539,7 +1522,7 @@ bool SkPDFDevice::handleInversePath(const SkPath& origPath,
|
||||
// To be consistent with the raster output, hairline strokes
|
||||
// are rendered as non-inverted.
|
||||
modifiedPath.toggleInverseFillType();
|
||||
this->drawPath(modifiedPath, paint, nullptr, true);
|
||||
this->drawPath(modifiedPath, paint, true);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@ -1548,9 +1531,7 @@ bool SkPDFDevice::handleInversePath(const SkPath& origPath,
|
||||
// (clip bounds are given in device space).
|
||||
SkMatrix transformInverse;
|
||||
SkMatrix totalMatrix = this->ctm();
|
||||
if (prePathMatrix) {
|
||||
totalMatrix.preConcat(*prePathMatrix);
|
||||
}
|
||||
|
||||
if (!totalMatrix.invert(&transformInverse)) {
|
||||
return false;
|
||||
}
|
||||
@ -1566,7 +1547,7 @@ bool SkPDFDevice::handleInversePath(const SkPath& origPath,
|
||||
return false;
|
||||
}
|
||||
|
||||
this->drawPath(modifiedPath, noInversePaint, prePathMatrix, true);
|
||||
this->drawPath(modifiedPath, noInversePaint, true);
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -1772,7 +1753,7 @@ void SkPDFDevice::finishContentEntry(SkBlendMode blendMode,
|
||||
SkPaint filledPaint;
|
||||
filledPaint.setColor(SK_ColorBLACK);
|
||||
filledPaint.setStyle(SkPaint::kFill_Style);
|
||||
this->internalDrawPath(clipStack, SkMatrix::I(), *shape, filledPaint, nullptr, true);
|
||||
this->internalDrawPath(clipStack, SkMatrix::I(), *shape, filledPaint, true);
|
||||
this->drawFormXObjectWithMask(this->addXObjectResource(dst.get()),
|
||||
this->makeFormXObjectFromDevice(),
|
||||
fExistingClipStack,
|
||||
@ -2099,7 +2080,7 @@ void SkPDFDevice::internalDrawImageRect(SkKeyedImage imageSubset,
|
||||
paint.setShader(imageSubset.image()->makeShader(&transform));
|
||||
SkPath path;
|
||||
path.addRect(dst); // handles non-integral clipping.
|
||||
this->internalDrawPath(this->cs(), this->ctm(), path, paint, nullptr, true);
|
||||
this->internalDrawPath(this->cs(), this->ctm(), path, paint, true);
|
||||
return;
|
||||
}
|
||||
transform.postConcat(ctm);
|
||||
|
@ -78,9 +78,7 @@ public:
|
||||
void drawRect(const SkRect& r, const SkPaint& paint) override;
|
||||
void drawOval(const SkRect& oval, const SkPaint& paint) override;
|
||||
void drawRRect(const SkRRect& rr, const SkPaint& paint) override;
|
||||
void drawPath(const SkPath& origpath,
|
||||
const SkPaint& paint, const SkMatrix* prePathMatrix,
|
||||
bool pathIsMutable) override;
|
||||
void drawPath(const SkPath& origpath, const SkPaint& paint, bool pathIsMutable) override;
|
||||
void drawBitmapRect(const SkBitmap& bitmap, const SkRect* src,
|
||||
const SkRect& dst, const SkPaint&, SkCanvas::SrcRectConstraint) override;
|
||||
void drawBitmap(const SkBitmap& bitmap, SkScalar x, SkScalar y, const SkPaint&) override;
|
||||
@ -255,18 +253,14 @@ private:
|
||||
const SkMatrix&,
|
||||
const SkPath&,
|
||||
const SkPaint&,
|
||||
const SkMatrix* prePathMatrix,
|
||||
bool pathIsMutable);
|
||||
|
||||
void internalDrawPathWithFilter(const SkClipStack& clipStack,
|
||||
const SkMatrix& ctm,
|
||||
const SkPath& origPath,
|
||||
const SkPaint& paint,
|
||||
const SkMatrix* prePathMatrix);
|
||||
const SkPaint& paint);
|
||||
|
||||
bool handleInversePath(const SkPath& origPath,
|
||||
const SkPaint& paint, bool pathIsMutable,
|
||||
const SkMatrix* prePathMatrix = nullptr);
|
||||
bool handleInversePath(const SkPath& origPath, const SkPaint& paint, bool pathIsMutable);
|
||||
|
||||
void addSMaskGraphicState(sk_sp<SkPDFDevice> maskDevice, SkDynamicMemoryWStream*);
|
||||
void clearMaskOnGraphicState(SkDynamicMemoryWStream*);
|
||||
|
@ -904,8 +904,7 @@ void SkSVGDevice::drawRRect(const SkRRect& rr, const SkPaint& paint) {
|
||||
elem.addPathAttributes(path);
|
||||
}
|
||||
|
||||
void SkSVGDevice::drawPath(const SkPath& path, const SkPaint& paint,
|
||||
const SkMatrix* prePathMatrix, bool pathIsMutable) {
|
||||
void SkSVGDevice::drawPath(const SkPath& path, const SkPaint& paint, bool pathIsMutable) {
|
||||
AutoElement elem("path", fWriter, fResourceBucket.get(), MxCp(this), paint);
|
||||
elem.addPathAttributes(path);
|
||||
|
||||
|
@ -27,7 +27,6 @@ protected:
|
||||
void drawRRect(const SkRRect& rr, const SkPaint& paint) override;
|
||||
void drawPath(const SkPath& path,
|
||||
const SkPaint& paint,
|
||||
const SkMatrix* prePathMatrix = nullptr,
|
||||
bool pathIsMutable = false) override;
|
||||
|
||||
void drawBitmap(const SkBitmap& bitmap, SkScalar x, SkScalar y, const SkPaint& paint) override;
|
||||
|
@ -1185,7 +1185,7 @@ void SkXPSDevice::drawRRect(const SkRRect& rr,
|
||||
const SkPaint& paint) {
|
||||
SkPath path;
|
||||
path.addRRect(rr);
|
||||
this->drawPath(path, paint, nullptr, true);
|
||||
this->drawPath(path, paint, true);
|
||||
}
|
||||
|
||||
static SkIRect size(const SkBaseDevice& dev) { return {0, 0, dev.width(), dev.height()}; }
|
||||
@ -1204,7 +1204,7 @@ void SkXPSDevice::internalDrawRect(const SkRect& r,
|
||||
SkPath tmp;
|
||||
tmp.addRect(r);
|
||||
tmp.setFillType(SkPath::kWinding_FillType);
|
||||
this->drawPath(tmp, paint, nullptr, true);
|
||||
this->drawPath(tmp, paint, true);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -1502,7 +1502,6 @@ HRESULT SkXPSDevice::shadePath(IXpsOMPath* shadedPath,
|
||||
|
||||
void SkXPSDevice::drawPath(const SkPath& platonicPath,
|
||||
const SkPaint& origPaint,
|
||||
const SkMatrix* prePathMatrix,
|
||||
bool pathIsMutable) {
|
||||
SkTCopyOnFirstWrite<SkPaint> paint(origPaint);
|
||||
|
||||
@ -1519,17 +1518,6 @@ void SkXPSDevice::drawPath(const SkPath& platonicPath,
|
||||
//Apply pre-path matrix [Platonic-path -> Skeletal-path].
|
||||
SkMatrix matrix = this->ctm();
|
||||
SkPath* skeletalPath = const_cast<SkPath*>(&platonicPath);
|
||||
if (prePathMatrix) {
|
||||
if (paintHasPathEffect) {
|
||||
if (!pathIsMutable) {
|
||||
skeletalPath = &modifiedPath;
|
||||
pathIsMutable = true;
|
||||
}
|
||||
platonicPath.transform(*prePathMatrix, skeletalPath);
|
||||
} else {
|
||||
matrix.preConcat(*prePathMatrix);
|
||||
}
|
||||
}
|
||||
|
||||
//Apply path effect [Skeletal-path -> Fillable-path].
|
||||
SkPath* fillablePath = skeletalPath;
|
||||
@ -2147,7 +2135,7 @@ SkBaseDevice* SkXPSDevice::onCreateDevice(const CreateInfo& info, const SkPaint*
|
||||
void SkXPSDevice::drawOval( const SkRect& o, const SkPaint& p) {
|
||||
SkPath path;
|
||||
path.addOval(o);
|
||||
this->drawPath(path, p, nullptr, true);
|
||||
this->drawPath(path, p, true);
|
||||
}
|
||||
|
||||
void SkXPSDevice::drawBitmapRect(const SkBitmap& bitmap,
|
||||
|
@ -85,7 +85,6 @@ protected:
|
||||
const SkPaint& paint) override;
|
||||
void drawPath(const SkPath& path,
|
||||
const SkPaint& paint,
|
||||
const SkMatrix* prePathMatrix = NULL,
|
||||
bool pathIsMutable = false) override;
|
||||
void drawBitmap(const SkBitmap& bitmap,
|
||||
SkScalar x,
|
||||
|
Loading…
Reference in New Issue
Block a user