aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core/SkDevice.cpp
diff options
context:
space:
mode:
authorGravatar Cary Clark <caryclark@google.com>2017-03-03 20:27:13 +0000
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2017-03-03 20:27:22 +0000
commitbaf06bc89a0ee2ac4033281e7310f6c727faab79 (patch)
tree13aca9c2e88a457a91f2d0dcf0f3418411ea63fc /src/core/SkDevice.cpp
parent94fc0fe016bbfeb097c829df513673d4fcbb38b3 (diff)
Revert "Revert[2] "Remove SkDraw from device-draw methods, and enable device-centric clipping."""
This reverts commit cfaa63237b152ae216f1351207bce3ea9808814c. Reason for revert: speculative revert to fix Google3 Original change's description: > Revert[2] "Remove SkDraw from device-draw methods, and enable device-centric clipping."" > > passes new (augmented) CanvasClipType unittest > fixed rasterclipstack::setnewsize > > This reverts commit ea5e676a7b75600edcde3912886486004ccd7626. > > BUG=skia: > > Change-Id: I004653e0f4d01454662f8516fccab0046486f273 > Reviewed-on: https://skia-review.googlesource.com/9185 > Reviewed-by: Brian Salomon <bsalomon@google.com> > Commit-Queue: Mike Reed <reed@google.com> > TBR=bsalomon@google.com,reed@google.com,reviews@skia.org NOPRESUBMIT=true NOTREECHECKS=true NOTRY=true BUG=skia: Change-Id: Ibd7ee6383999f008eb6ee59c1c3f1c06a86044ea Reviewed-on: https://skia-review.googlesource.com/9230 Reviewed-by: Cary Clark <caryclark@google.com> Commit-Queue: Cary Clark <caryclark@google.com>
Diffstat (limited to 'src/core/SkDevice.cpp')
-rw-r--r--src/core/SkDevice.cpp85
1 files changed, 44 insertions, 41 deletions
diff --git a/src/core/SkDevice.cpp b/src/core/SkDevice.cpp
index fad73e9961..cd3bf502c7 100644
--- a/src/core/SkDevice.cpp
+++ b/src/core/SkDevice.cpp
@@ -71,36 +71,35 @@ static inline bool is_int(float x) {
return x == (float) sk_float_round2int(x);
}
-void SkBaseDevice::drawRegion(const SkRegion& region, const SkPaint& paint) {
- const SkMatrix& ctm = this->ctm();
- bool isNonTranslate = ctm.getType() & ~(SkMatrix::kTranslate_Mask);
+void SkBaseDevice::drawRegion(const SkDraw& draw, const SkRegion& region, const SkPaint& paint) {
+ bool isNonTranslate = draw.fMatrix->getType() & ~(SkMatrix::kTranslate_Mask);
bool complexPaint = paint.getStyle() != SkPaint::kFill_Style || paint.getMaskFilter() ||
paint.getPathEffect();
- bool antiAlias = paint.isAntiAlias() && (!is_int(ctm.getTranslateX()) ||
- !is_int(ctm.getTranslateY()));
+ bool antiAlias = paint.isAntiAlias() && (!is_int(draw.fMatrix->getTranslateX()) ||
+ !is_int(draw.fMatrix->getTranslateY()));
if (isNonTranslate || complexPaint || antiAlias) {
SkPath path;
region.getBoundaryPath(&path);
- return this->drawPath(path, paint, nullptr, false);
+ return this->drawPath(draw, path, paint, nullptr, false);
}
SkRegion::Iterator it(region);
while (!it.done()) {
- this->drawRect(SkRect::Make(it.rect()), paint);
+ this->drawRect(draw, SkRect::Make(it.rect()), paint);
it.next();
}
}
-void SkBaseDevice::drawArc(const SkRect& oval, SkScalar startAngle,
+void SkBaseDevice::drawArc(const SkDraw& draw, const SkRect& oval, SkScalar startAngle,
SkScalar sweepAngle, bool useCenter, const SkPaint& paint) {
SkPath path;
bool isFillNoPathEffect = SkPaint::kFill_Style == paint.getStyle() && !paint.getPathEffect();
SkPathPriv::CreateDrawArcPath(&path, oval, startAngle, sweepAngle, useCenter,
isFillNoPathEffect);
- this->drawPath(path, paint);
+ this->drawPath(draw, path, paint);
}
-void SkBaseDevice::drawDRRect(const SkRRect& outer,
+void SkBaseDevice::drawDRRect(const SkDraw& draw, const SkRRect& outer,
const SkRRect& inner, const SkPaint& paint) {
SkPath path;
path.addRRect(outer);
@@ -110,25 +109,25 @@ void SkBaseDevice::drawDRRect(const SkRRect& outer,
const SkMatrix* preMatrix = nullptr;
const bool pathIsMutable = true;
- this->drawPath(path, paint, preMatrix, pathIsMutable);
+ this->drawPath(draw, path, paint, preMatrix, pathIsMutable);
}
-void SkBaseDevice::drawPatch(const SkPoint cubics[12], const SkColor colors[4],
+void SkBaseDevice::drawPatch(const SkDraw& draw, const SkPoint cubics[12], const SkColor colors[4],
const SkPoint texCoords[4], SkBlendMode bmode, const SkPaint& paint) {
SkPatchUtils::VertexData data;
- SkISize lod = SkPatchUtils::GetLevelOfDetail(cubics, &this->ctm());
+ SkISize lod = SkPatchUtils::GetLevelOfDetail(cubics, draw.fMatrix);
// It automatically adjusts lodX and lodY in case it exceeds the number of indices.
// If it fails to generate the vertices, then we do not draw.
if (SkPatchUtils::getVertexData(&data, cubics, colors, texCoords, lod.width(), lod.height())) {
- this->drawVertices(SkCanvas::kTriangles_VertexMode, data.fVertexCount, data.fPoints,
+ this->drawVertices(draw, SkCanvas::kTriangles_VertexMode, data.fVertexCount, data.fPoints,
data.fTexCoords, data.fColors, bmode, data.fIndices, data.fIndexCount,
paint);
}
}
-void SkBaseDevice::drawTextBlob(const SkTextBlob* blob, SkScalar x, SkScalar y,
+void SkBaseDevice::drawTextBlob(const SkDraw& draw, const SkTextBlob* blob, SkScalar x, SkScalar y,
const SkPaint &paint, SkDrawFilter* drawFilter) {
SkPaint runPaint = paint;
@@ -151,14 +150,14 @@ void SkBaseDevice::drawTextBlob(const SkTextBlob* blob, SkScalar x, SkScalar y,
switch (it.positioning()) {
case SkTextBlob::kDefault_Positioning:
- this->drawText(it.glyphs(), textLen, x + offset.x(), y + offset.y(), runPaint);
+ this->drawText(draw, it.glyphs(), textLen, x + offset.x(), y + offset.y(), runPaint);
break;
case SkTextBlob::kHorizontal_Positioning:
- this->drawPosText(it.glyphs(), textLen, it.pos(), 1,
+ this->drawPosText(draw, it.glyphs(), textLen, it.pos(), 1,
SkPoint::Make(x, y + offset.y()), runPaint);
break;
case SkTextBlob::kFull_Positioning:
- this->drawPosText(it.glyphs(), textLen, it.pos(), 2,
+ this->drawPosText(draw, it.glyphs(), textLen, it.pos(), 2,
SkPoint::Make(x, y), runPaint);
break;
default:
@@ -172,66 +171,66 @@ void SkBaseDevice::drawTextBlob(const SkTextBlob* blob, SkScalar x, SkScalar y,
}
}
-void SkBaseDevice::drawImage(const SkImage* image, SkScalar x, SkScalar y,
+void SkBaseDevice::drawImage(const SkDraw& draw, const SkImage* image, SkScalar x, SkScalar y,
const SkPaint& paint) {
SkBitmap bm;
if (as_IB(image)->getROPixels(&bm, this->imageInfo().colorSpace())) {
- this->drawBitmap(bm, SkMatrix::MakeTrans(x, y), paint);
+ this->drawBitmap(draw, bm, SkMatrix::MakeTrans(x, y), paint);
}
}
-void SkBaseDevice::drawImageRect(const SkImage* image, const SkRect* src,
+void SkBaseDevice::drawImageRect(const SkDraw& draw, const SkImage* image, const SkRect* src,
const SkRect& dst, const SkPaint& paint,
SkCanvas::SrcRectConstraint constraint) {
SkBitmap bm;
if (as_IB(image)->getROPixels(&bm, this->imageInfo().colorSpace())) {
- this->drawBitmapRect(bm, src, dst, paint, constraint);
+ this->drawBitmapRect(draw, bm, src, dst, paint, constraint);
}
}
-void SkBaseDevice::drawImageNine(const SkImage* image, const SkIRect& center,
+void SkBaseDevice::drawImageNine(const SkDraw& draw, const SkImage* image, const SkIRect& center,
const SkRect& dst, const SkPaint& paint) {
SkLatticeIter iter(image->width(), image->height(), center, dst);
SkRect srcR, dstR;
while (iter.next(&srcR, &dstR)) {
- this->drawImageRect(image, &srcR, dstR, paint, SkCanvas::kStrict_SrcRectConstraint);
+ this->drawImageRect(draw, image, &srcR, dstR, paint, SkCanvas::kStrict_SrcRectConstraint);
}
}
-void SkBaseDevice::drawBitmapNine(const SkBitmap& bitmap, const SkIRect& center,
+void SkBaseDevice::drawBitmapNine(const SkDraw& draw, const SkBitmap& bitmap, const SkIRect& center,
const SkRect& dst, const SkPaint& paint) {
SkLatticeIter iter(bitmap.width(), bitmap.height(), center, dst);
SkRect srcR, dstR;
while (iter.next(&srcR, &dstR)) {
- this->drawBitmapRect(bitmap, &srcR, dstR, paint, SkCanvas::kStrict_SrcRectConstraint);
+ this->drawBitmapRect(draw, bitmap, &srcR, dstR, paint, SkCanvas::kStrict_SrcRectConstraint);
}
}
-void SkBaseDevice::drawImageLattice(const SkImage* image,
+void SkBaseDevice::drawImageLattice(const SkDraw& draw, const SkImage* image,
const SkCanvas::Lattice& lattice, const SkRect& dst,
const SkPaint& paint) {
SkLatticeIter iter(lattice, dst);
SkRect srcR, dstR;
while (iter.next(&srcR, &dstR)) {
- this->drawImageRect(image, &srcR, dstR, paint, SkCanvas::kStrict_SrcRectConstraint);
+ this->drawImageRect(draw, image, &srcR, dstR, paint, SkCanvas::kStrict_SrcRectConstraint);
}
}
-void SkBaseDevice::drawBitmapLattice(const SkBitmap& bitmap,
+void SkBaseDevice::drawBitmapLattice(const SkDraw& draw, const SkBitmap& bitmap,
const SkCanvas::Lattice& lattice, const SkRect& dst,
const SkPaint& paint) {
SkLatticeIter iter(lattice, dst);
SkRect srcR, dstR;
while (iter.next(&srcR, &dstR)) {
- this->drawBitmapRect(bitmap, &srcR, dstR, paint, SkCanvas::kStrict_SrcRectConstraint);
+ this->drawBitmapRect(draw, bitmap, &srcR, dstR, paint, SkCanvas::kStrict_SrcRectConstraint);
}
}
-void SkBaseDevice::drawAtlas(const SkImage* atlas, const SkRSXform xform[],
+void SkBaseDevice::drawAtlas(const SkDraw& draw, const SkImage* atlas, const SkRSXform xform[],
const SkRect tex[], const SkColor colors[], int count,
SkBlendMode mode, const SkPaint& paint) {
SkPath path;
@@ -261,23 +260,23 @@ void SkBaseDevice::drawAtlas(const SkImage* atlas, const SkRSXform xform[],
path.rewind();
path.addPoly(quad, 4, true);
path.setConvexity(SkPath::kConvex_Convexity);
- this->drawPath(path, pnt, nullptr, true);
+ this->drawPath(draw, path, pnt, nullptr, true);
}
}
-void SkBaseDevice::drawVerticesObject(sk_sp<SkVertices> vertices,
+void SkBaseDevice::drawVerticesObject(const SkDraw& draw, sk_sp<SkVertices> vertices,
SkBlendMode mode, const SkPaint& paint, uint32_t flags) {
const SkPoint* texs =
(flags & SkCanvas::kIgnoreTexCoords_VerticesFlag) ? nullptr : vertices->texCoords();
const SkColor* colors =
(flags & SkCanvas::kIgnoreColors_VerticesFlag) ? nullptr : vertices->colors();
- this->drawVertices(vertices->mode(), vertices->vertexCount(), vertices->positions(), texs,
+ this->drawVertices(draw, vertices->mode(), vertices->vertexCount(), vertices->positions(), texs,
colors, mode, vertices->indices(), vertices->indexCount(), paint);
}
///////////////////////////////////////////////////////////////////////////////////////////////////
-void SkBaseDevice::drawSpecial(SkSpecialImage*, int x, int y, const SkPaint&) {}
+void SkBaseDevice::drawSpecial(const SkDraw&, SkSpecialImage*, int x, int y, const SkPaint&) {}
sk_sp<SkSpecialImage> SkBaseDevice::makeSpecial(const SkBitmap&) { return nullptr; }
sk_sp<SkSpecialImage> SkBaseDevice::makeSpecial(const SkImage*) { return nullptr; }
sk_sp<SkSpecialImage> SkBaseDevice::snapSpecial() { return nullptr; }
@@ -393,13 +392,13 @@ static void morphpath(SkPath* dst, const SkPath& src, SkPathMeasure& meas,
}
}
-void SkBaseDevice::drawTextOnPath(const void* text, size_t byteLength,
+void SkBaseDevice::drawTextOnPath(const SkDraw& draw, const void* text, size_t byteLength,
const SkPath& follow, const SkMatrix* matrix,
const SkPaint& paint) {
SkASSERT(byteLength == 0 || text != nullptr);
// nothing to draw
- if (text == nullptr || byteLength == 0) {
+ if (text == nullptr || byteLength == 0 || draw.fRC->isEmpty()) {
return;
}
@@ -434,7 +433,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(draw, tmp, iter.getPaint(), nullptr, true);
}
}
}
@@ -449,7 +448,7 @@ static int count_utf16(const char* text) {
static int return_4(const char* text) { return 4; }
static int return_2(const char* text) { return 2; }
-void SkBaseDevice::drawTextRSXform(const void* text, size_t len,
+void SkBaseDevice::drawTextRSXform(const SkDraw& draw, const void* text, size_t len,
const SkRSXform xform[], const SkPaint& paint) {
CountTextProc proc = nullptr;
switch (paint.getTextEncoding()) {
@@ -467,15 +466,19 @@ void SkBaseDevice::drawTextRSXform(const void* text, size_t len,
break;
}
+ SkDraw localD(draw);
SkMatrix localM, currM;
const void* stopText = (const char*)text + len;
while ((const char*)text < (const char*)stopText) {
localM.setRSXform(*xform++);
- currM.setConcat(this->ctm(), localM);
+ currM.setConcat(*draw.fMatrix, localM);
+ localD.fMatrix = &currM;
+#ifdef SK_USE_DEVICE_CLIPPING
SkAutoDeviceCTMRestore adc(this, currM);
+#endif
int subLen = proc((const char*)text);
- this->drawText(text, subLen, 0, 0, paint);
+ this->drawText(localD, text, subLen, 0, 0, paint);
text = (const char*)text + subLen;
}
}