aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorGravatar Mike Reed <reed@google.com>2017-02-22 11:01:08 -0500
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2017-02-22 16:54:48 +0000
commit99330ba6227137866a0dbd63478d36f335203ebd (patch)
tree70e79529df61d1836840f70e5c814ce0be6c7d2f /src
parentf3ee34f1eca8f32fa0ec5494c335ce75382420a7 (diff)
remove device field from SkDraw
BUG=skia:6214 Change-Id: I5d57feb3e92f2c1691231c982e74020560febeca Reviewed-on: https://skia-review.googlesource.com/8837 Reviewed-by: Mike Reed <reed@google.com> Commit-Queue: Mike Reed <reed@google.com>
Diffstat (limited to 'src')
-rw-r--r--src/core/SkBitmapDevice.cpp7
-rw-r--r--src/core/SkCanvas.cpp8
-rw-r--r--src/core/SkDraw.cpp75
-rw-r--r--src/core/SkDraw.h18
-rw-r--r--src/gpu/SkGpuDevice.cpp2
-rw-r--r--src/pdf/SkPDFDevice.cpp4
-rw-r--r--src/xps/SkXPSDevice.cpp2
7 files changed, 52 insertions, 64 deletions
diff --git a/src/core/SkBitmapDevice.cpp b/src/core/SkBitmapDevice.cpp
index 9ea4937e9a..e6bb9331d2 100644
--- a/src/core/SkBitmapDevice.cpp
+++ b/src/core/SkBitmapDevice.cpp
@@ -214,7 +214,7 @@ void SkBitmapDevice::drawPaint(const SkDraw& draw, const SkPaint& paint) {
void SkBitmapDevice::drawPoints(const SkDraw& draw, SkCanvas::PointMode mode, size_t count,
const SkPoint pts[], const SkPaint& paint) {
- PREPARE_DRAW(draw).drawPoints(mode, count, pts, paint);
+ PREPARE_DRAW(draw).drawPoints(mode, count, pts, paint, nullptr);
}
void SkBitmapDevice::drawRect(const SkDraw& draw, const SkRect& r, const SkPaint& paint) {
@@ -375,13 +375,14 @@ void SkBitmapDevice::drawSprite(const SkDraw& draw, const SkBitmap& bitmap,
void SkBitmapDevice::drawText(const SkDraw& draw, const void* text, size_t len,
SkScalar x, SkScalar y, const SkPaint& paint) {
- PREPARE_DRAW(draw).drawText((const char*)text, len, x, y, paint);
+ PREPARE_DRAW(draw).drawText((const char*)text, len, x, y, paint, &fSurfaceProps);
}
void SkBitmapDevice::drawPosText(const SkDraw& draw, const void* text, size_t len,
const SkScalar xpos[], int scalarsPerPos,
const SkPoint& offset, const SkPaint& paint) {
- PREPARE_DRAW(draw).drawPosText((const char*)text, len, xpos, scalarsPerPos, offset, paint);
+ PREPARE_DRAW(draw).drawPosText((const char*)text, len, xpos, scalarsPerPos, offset,
+ paint, &fSurfaceProps);
}
void SkBitmapDevice::drawVertices(const SkDraw& draw, SkCanvas::VertexMode vmode,
diff --git a/src/core/SkCanvas.cpp b/src/core/SkCanvas.cpp
index 6edf5368c3..d2bfb59f84 100644
--- a/src/core/SkCanvas.cpp
+++ b/src/core/SkCanvas.cpp
@@ -327,7 +327,7 @@ static SkIRect compute_device_bounds(SkBaseDevice* device) {
class SkDrawIter : public SkDraw {
public:
- SkDrawIter(SkCanvas* canvas) {
+ SkDrawIter(SkCanvas* canvas) : fDevice(nullptr) {
canvas->updateDeviceCMCache();
fClipStack = canvas->getClipStack();
@@ -380,13 +380,14 @@ public:
return false;
}
- SkBaseDevice* getDevice() const { return fDevice; }
const SkRasterClip& getClip() const { return *fRC; }
int getX() const { return fDevice->getOrigin().x(); }
int getY() const { return fDevice->getOrigin().y(); }
const SkMatrix& getMatrix() const { return *fMatrix; }
const SkPaint* getPaint() const { return fPaint; }
+ SkBaseDevice* fDevice;
+
private:
const DeviceCM* fCurrLayer;
const SkPaint* fPaint; // May be null.
@@ -1145,7 +1146,6 @@ void SkCanvas::DrawDeviceWithFilter(SkBaseDevice* src, const SkImageFilter* filt
draw.fMatrix = &SkMatrix::I();
draw.fRC = &rc;
draw.fClipStack = clipStack;
- draw.fDevice = dst;
SkPaint p;
p.setImageFilter(filter->makeWithLocalMatrix(ctm));
@@ -3318,7 +3318,7 @@ void SkCanvas::LayerIter::next() {
}
SkBaseDevice* SkCanvas::LayerIter::device() const {
- return fImpl->getDevice();
+ return fImpl->fDevice;
}
const SkMatrix& SkCanvas::LayerIter::matrix() const {
diff --git a/src/core/SkDraw.cpp b/src/core/SkDraw.cpp
index 4182ef3a72..a60325c8f7 100644
--- a/src/core/SkDraw.cpp
+++ b/src/core/SkDraw.cpp
@@ -513,7 +513,7 @@ PtProcRec::Proc PtProcRec::chooseProc(SkBlitter** blitterPtr) {
void SkDraw::drawPoints(SkCanvas::PointMode mode, size_t count,
const SkPoint pts[], const SkPaint& paint,
- bool forceUseDevice) const {
+ SkBaseDevice* device) const {
// if we're in lines mode, force count to be even
if (SkCanvas::kLines_PointMode == mode) {
count &= ~(size_t)1;
@@ -532,7 +532,7 @@ void SkDraw::drawPoints(SkCanvas::PointMode mode, size_t count,
}
PtProcRec rec;
- if (!forceUseDevice && rec.init(mode, paint, fMatrix, fRC)) {
+ if (!device && rec.init(mode, paint, fMatrix, fRC)) {
SkAutoBlitterChoose blitter(fDst, *fMatrix, paint);
SkPoint devPts[MAX_DEV_PTS];
@@ -576,8 +576,8 @@ void SkDraw::drawPoints(SkCanvas::PointMode mode, size_t count,
// pass true for the last point, since we can modify
// then path then
path.setIsVolatile((count-1) == i);
- if (fDevice) {
- fDevice->drawPath(*this, path, newPaint, &preMatrix,
+ if (device) {
+ device->drawPath(*this, path, newPaint, &preMatrix,
(count-1) == i);
} else {
this->drawPath(path, newPaint, &preMatrix,
@@ -592,8 +592,8 @@ void SkDraw::drawPoints(SkCanvas::PointMode mode, size_t count,
r.fTop = pts[i].fY - radius;
r.fRight = r.fLeft + width;
r.fBottom = r.fTop + width;
- if (fDevice) {
- fDevice->drawRect(*this, r, newPaint);
+ if (device) {
+ device->drawRect(*this, r, newPaint);
} else {
this->drawRect(r, newPaint);
}
@@ -623,16 +623,16 @@ void SkDraw::drawPoints(SkCanvas::PointMode mode, size_t count,
newP.setStyle(SkPaint::kFill_Style);
if (!pointData.fFirst.isEmpty()) {
- if (fDevice) {
- fDevice->drawPath(*this, pointData.fFirst, newP);
+ if (device) {
+ device->drawPath(*this, pointData.fFirst, newP);
} else {
this->drawPath(pointData.fFirst, newP);
}
}
if (!pointData.fLast.isEmpty()) {
- if (fDevice) {
- fDevice->drawPath(*this, pointData.fLast, newP);
+ if (device) {
+ device->drawPath(*this, pointData.fLast, newP);
} else {
this->drawPath(pointData.fLast, newP);
}
@@ -648,8 +648,8 @@ void SkDraw::drawPoints(SkCanvas::PointMode mode, size_t count,
newP.setStrokeCap(SkPaint::kButt_Cap);
}
- if (fDevice) {
- fDevice->drawPoints(*this,
+ if (device) {
+ device->drawPoints(*this,
SkCanvas::kPoints_PointMode,
pointData.fNumPoints,
pointData.fPoints,
@@ -659,7 +659,7 @@ void SkDraw::drawPoints(SkCanvas::PointMode mode, size_t count,
pointData.fNumPoints,
pointData.fPoints,
newP,
- forceUseDevice);
+ device);
}
break;
} else {
@@ -674,8 +674,8 @@ void SkDraw::drawPoints(SkCanvas::PointMode mode, size_t count,
pointData.fPoints[i].fY - pointData.fSize.fY,
pointData.fPoints[i].fX + pointData.fSize.fX,
pointData.fPoints[i].fY + pointData.fSize.fY);
- if (fDevice) {
- fDevice->drawRect(*this, r, newP);
+ if (device) {
+ device->drawRect(*this, r, newP);
} else {
this->drawRect(r, newP);
}
@@ -696,8 +696,8 @@ void SkDraw::drawPoints(SkCanvas::PointMode mode, size_t count,
for (size_t i = 0; i < count; i += inc) {
path.moveTo(pts[i]);
path.lineTo(pts[i+1]);
- if (fDevice) {
- fDevice->drawPath(*this, path, p, nullptr, true);
+ if (device) {
+ device->drawPath(*this, path, p, nullptr, true);
} else {
this->drawPath(path, p, nullptr, true);
}
@@ -1406,8 +1406,7 @@ bool SkDraw::ShouldDrawTextAsPaths(const SkPaint& paint, const SkMatrix& ctm) {
return SkPaint::TooBigToUseCache(ctm, *paint.setTextMatrix(&textM));
}
-void SkDraw::drawText_asPaths(const char text[], size_t byteLength,
- SkScalar x, SkScalar y,
+void SkDraw::drawText_asPaths(const char text[], size_t byteLength, SkScalar x, SkScalar y,
const SkPaint& paint) const {
SkDEBUGCODE(this->validate();)
@@ -1424,11 +1423,7 @@ void SkDraw::drawText_asPaths(const char text[], size_t byteLength,
matrix.postTranslate(xpos - prevXPos, 0);
if (iterPath) {
const SkPaint& pnt = iter.getPaint();
- if (fDevice) {
- fDevice->drawPath(*this, *iterPath, pnt, &matrix, false);
- } else {
- this->drawPath(*iterPath, pnt, &matrix, false);
- }
+ this->drawPath(*iterPath, pnt, &matrix, false);
}
prevXPos = xpos;
}
@@ -1560,14 +1555,14 @@ private:
uint32_t SkDraw::scalerContextFlags() const {
uint32_t flags = SkPaint::kBoostContrast_ScalerContextFlag;
- if (!fDevice->imageInfo().colorSpace()) {
+ if (!fDst.colorSpace()) {
flags |= SkPaint::kFakeGamma_ScalerContextFlag;
}
return flags;
}
-void SkDraw::drawText(const char text[], size_t byteLength,
- SkScalar x, SkScalar y, const SkPaint& paint) const {
+void SkDraw::drawText(const char text[], size_t byteLength, SkScalar x, SkScalar y,
+ const SkPaint& paint, const SkSurfaceProps* props) const {
SkASSERT(byteLength == 0 || text != nullptr);
SkDEBUGCODE(this->validate();)
@@ -1584,7 +1579,7 @@ void SkDraw::drawText(const char text[], size_t byteLength,
return;
}
- SkAutoGlyphCache cache(paint, &fDevice->surfaceProps(), this->scalerContextFlags(), fMatrix);
+ SkAutoGlyphCache cache(paint, props, this->scalerContextFlags(), fMatrix);
// The Blitter Choose needs to be live while using the blitter below.
SkAutoBlitterChoose blitterChooser(fDst, *fMatrix, paint);
@@ -1598,9 +1593,9 @@ void SkDraw::drawText(const char text[], size_t byteLength,
//////////////////////////////////////////////////////////////////////////////
-void SkDraw::drawPosText_asPaths(const char text[], size_t byteLength,
- const SkScalar pos[], int scalarsPerPosition,
- const SkPoint& offset, const SkPaint& origPaint) const {
+void SkDraw::drawPosText_asPaths(const char text[], size_t byteLength, const SkScalar pos[],
+ int scalarsPerPosition, const SkPoint& offset,
+ const SkPaint& origPaint, const SkSurfaceProps* props) const {
// setup our std paint, in hopes of getting hits in the cache
SkPaint paint(origPaint);
SkScalar matrixScale = paint.setupForAsPaths();
@@ -1615,7 +1610,7 @@ void SkDraw::drawPosText_asPaths(const char text[], size_t byteLength,
SkPaint::GlyphCacheProc glyphCacheProc = SkPaint::GetGlyphCacheProc(paint.getTextEncoding(),
paint.isDevKernText(),
true);
- SkAutoGlyphCache cache(paint, &fDevice->surfaceProps(), this->scalerContextFlags(), nullptr);
+ SkAutoGlyphCache cache(paint, props, this->scalerContextFlags(), nullptr);
const char* stop = text + byteLength;
SkTextAlignProc alignProc(paint.getTextAlign());
@@ -1637,20 +1632,16 @@ void SkDraw::drawPosText_asPaths(const char text[], size_t byteLength,
matrix[SkMatrix::kMTransX] = loc.fX;
matrix[SkMatrix::kMTransY] = loc.fY;
- if (fDevice) {
- fDevice->drawPath(*this, *path, paint, &matrix, false);
- } else {
- this->drawPath(*path, paint, &matrix, false);
- }
+ this->drawPath(*path, paint, &matrix, false);
}
}
pos += scalarsPerPosition;
}
}
-void SkDraw::drawPosText(const char text[], size_t byteLength,
- const SkScalar pos[], int scalarsPerPosition,
- const SkPoint& offset, const SkPaint& paint) const {
+void SkDraw::drawPosText(const char text[], size_t byteLength, const SkScalar pos[],
+ int scalarsPerPosition, const SkPoint& offset, const SkPaint& paint,
+ const SkSurfaceProps* props) const {
SkASSERT(byteLength == 0 || text != nullptr);
SkASSERT(1 == scalarsPerPosition || 2 == scalarsPerPosition);
@@ -1662,11 +1653,11 @@ void SkDraw::drawPosText(const char text[], size_t byteLength,
}
if (ShouldDrawTextAsPaths(paint, *fMatrix)) {
- this->drawPosText_asPaths(text, byteLength, pos, scalarsPerPosition, offset, paint);
+ this->drawPosText_asPaths(text, byteLength, pos, scalarsPerPosition, offset, paint, props);
return;
}
- SkAutoGlyphCache cache(paint, &fDevice->surfaceProps(), this->scalerContextFlags(), fMatrix);
+ SkAutoGlyphCache cache(paint, props, this->scalerContextFlags(), fMatrix);
// The Blitter Choose needs to be live while using the blitter below.
SkAutoBlitterChoose blitterChooser(fDst, *fMatrix, paint);
diff --git a/src/core/SkDraw.h b/src/core/SkDraw.h
index 8a2c2d44fe..534333984b 100644
--- a/src/core/SkDraw.h
+++ b/src/core/SkDraw.h
@@ -33,7 +33,7 @@ public:
void drawPaint(const SkPaint&) const;
void drawPoints(SkCanvas::PointMode, size_t count, const SkPoint[],
- const SkPaint&, bool forceUseDevice = false) const;
+ const SkPaint&, SkBaseDevice*) const;
void drawRect(const SkRect& prePaintRect, const SkPaint&, const SkMatrix* paintMatrix,
const SkRect* postPaintRect) const;
void drawRect(const SkRect& rect, const SkPaint& paint) const {
@@ -64,10 +64,10 @@ public:
const SkPaint&) const;
void drawSprite(const SkBitmap&, int x, int y, const SkPaint&) const;
void drawText(const char text[], size_t byteLength, SkScalar x,
- SkScalar y, const SkPaint& paint) const;
+ SkScalar y, const SkPaint& paint, const SkSurfaceProps*) const;
void drawPosText(const char text[], size_t byteLength,
const SkScalar pos[], int scalarsPerPosition,
- const SkPoint& offset, const SkPaint& paint) const;
+ const SkPoint& offset, const SkPaint&, const SkSurfaceProps*) const;
void drawVertices(SkCanvas::VertexMode mode, int count,
const SkPoint vertices[], const SkPoint textures[],
const SkColor colors[], SkBlendMode bmode,
@@ -114,11 +114,11 @@ public:
SkPoint* strokeSize);
static bool ShouldDrawTextAsPaths(const SkPaint&, const SkMatrix&);
- void drawText_asPaths(const char text[], size_t byteLength,
- SkScalar x, SkScalar y, const SkPaint&) const;
- void drawPosText_asPaths(const char text[], size_t byteLength,
- const SkScalar pos[], int scalarsPerPosition,
- const SkPoint& offset, const SkPaint&) const;
+ void drawText_asPaths(const char text[], size_t byteLength, SkScalar x, SkScalar y,
+ const SkPaint&) const;
+ void drawPosText_asPaths(const char text[], size_t byteLength, const SkScalar pos[],
+ int scalarsPerPosition, const SkPoint& offset,
+ const SkPaint&, const SkSurfaceProps*) const;
static SkScalar ComputeResScaleForStroking(const SkMatrix& );
private:
void drawDevMask(const SkMask& mask, const SkPaint&) const;
@@ -149,9 +149,7 @@ public:
SkPixmap fDst;
const SkMatrix* fMatrix; // required
const SkRasterClip* fRC; // required
-
const SkClipStack* fClipStack; // optional, may be null
- SkBaseDevice* fDevice; // optional, may be null
#ifdef SK_DEBUG
void validate() const;
diff --git a/src/gpu/SkGpuDevice.cpp b/src/gpu/SkGpuDevice.cpp
index f1cbda7cb7..aedfc0b258 100644
--- a/src/gpu/SkGpuDevice.cpp
+++ b/src/gpu/SkGpuDevice.cpp
@@ -368,7 +368,7 @@ void SkGpuDevice::drawPoints(const SkDraw& draw, SkCanvas::PointMode mode,
// else we let the SkDraw call our drawPath()
if (!isHairline || paint.getPathEffect() || paint.getMaskFilter() ||
(paint.isAntiAlias() && needs_antialiasing(mode, count, pts, *draw.fMatrix))) {
- draw.drawPoints(mode, count, pts, paint, true);
+ draw.drawPoints(mode, count, pts, paint, this);
return;
}
diff --git a/src/pdf/SkPDFDevice.cpp b/src/pdf/SkPDFDevice.cpp
index b2c54fecce..8f3146b2ad 100644
--- a/src/pdf/SkPDFDevice.cpp
+++ b/src/pdf/SkPDFDevice.cpp
@@ -568,9 +568,7 @@ void SkPDFDevice::drawPoints(const SkDraw& d,
if (d.fClipStack->isEmpty(this->getGlobalBounds())) {
return;
}
- SkDraw pointDraw(d);
- pointDraw.fDevice = this;
- pointDraw.drawPoints(mode, count, points, passedPaint, true);
+ d.drawPoints(mode, count, points, passedPaint, this);
return;
}
diff --git a/src/xps/SkXPSDevice.cpp b/src/xps/SkXPSDevice.cpp
index 302f79eebb..bf93302d51 100644
--- a/src/xps/SkXPSDevice.cpp
+++ b/src/xps/SkXPSDevice.cpp
@@ -1143,7 +1143,7 @@ void SkXPSDevice::drawPoints(const SkDraw& d, SkCanvas::PointMode mode,
size_t count, const SkPoint points[],
const SkPaint& paint) {
//This will call back into the device to do the drawing.
- d.drawPoints(mode, count, points, paint, true);
+ d.drawPoints(mode, count, points, paint, this);
}
void SkXPSDevice::drawVertices(const SkDraw&, SkCanvas::VertexMode,