Rebase non-drawing SkCanvas subclasses to SkNoDrawCanvas
R=reed@google.com,mtklein@google.com
Change-Id: I7df84587821db561e262a915afa23108a4a78834
Reviewed-on: https://skia-review.googlesource.com/5508
Reviewed-by: Mike Reed <reed@google.com>
Commit-Queue: Florin Malita <fmalita@chromium.org>
diff --git a/include/core/SkCanvas.h b/include/core/SkCanvas.h
index 9887211..0804ae4 100644
--- a/include/core/SkCanvas.h
+++ b/include/core/SkCanvas.h
@@ -1620,14 +1620,12 @@
friend class SkLua; // needs top layer size and offset
friend class SkDebugCanvas; // needs experimental fAllowSimplifyClip
friend class SkSurface_Raster; // needs getDevice()
- friend class SkRecorder; // InitFlags
- friend class SkLiteRecorder; // InitFlags
- friend class SkNoDrawCanvas; // InitFlags
- friend class SkNWayCanvas; // InitFlags
+ friend class SkRecorder; // resetForNextPicture
+ friend class SkLiteRecorder; // resetForNextPicture
+ friend class SkNoDrawCanvas; // InitFlags
friend class SkPictureImageFilter; // SkCanvas(SkBaseDevice*, SkSurfaceProps*, InitFlags)
friend class SkPictureRecord; // predrawNotify (why does it need it? <reed>)
friend class SkPicturePlayback; // SaveFlagsToSaveLayerFlags
- friend class SkPipeCanvas; // InitFlags
friend class SkDeferredCanvas; // For use of resetForNextPicture
friend class SkOverdrawCanvas;
diff --git a/include/utils/SkNWayCanvas.h b/include/utils/SkNWayCanvas.h
index e8b88ab..d8856da 100644
--- a/include/utils/SkNWayCanvas.h
+++ b/include/utils/SkNWayCanvas.h
@@ -10,9 +10,9 @@
#define SkNWayCanvas_DEFINED
#include "../private/SkTDArray.h"
-#include "SkCanvas.h"
+#include "SkNoDrawCanvas.h"
-class SK_API SkNWayCanvas : public SkCanvas {
+class SK_API SkNWayCanvas : public SkNoDrawCanvas {
public:
SkNWayCanvas(int width, int height);
virtual ~SkNWayCanvas();
@@ -87,7 +87,7 @@
class Iter;
private:
- typedef SkCanvas INHERITED;
+ typedef SkNoDrawCanvas INHERITED;
};
diff --git a/include/utils/SkNoDrawCanvas.h b/include/utils/SkNoDrawCanvas.h
index 0330251..e8c5d7e 100644
--- a/include/utils/SkNoDrawCanvas.h
+++ b/include/utils/SkNoDrawCanvas.h
@@ -10,6 +10,8 @@
#include "SkCanvas.h"
+struct SkIRect;
+
// SkNoDrawCanvas is a helper for SkCanvas subclasses which do not need to
// actually rasterize (e.g., analysis of the draw calls).
//
@@ -22,6 +24,9 @@
public:
SkNoDrawCanvas(int width, int height);
+ // TODO: investigate the users of this ctor.
+ SkNoDrawCanvas(const SkIRect&);
+
protected:
SaveLayerStrategy getSaveLayerStrategy(const SaveLayerRec& rec) override;
diff --git a/src/core/SkCanvas.cpp b/src/core/SkCanvas.cpp
index 25f83de..2dff8e9 100644
--- a/src/core/SkCanvas.cpp
+++ b/src/core/SkCanvas.cpp
@@ -3373,6 +3373,9 @@
SkNoDrawCanvas::SkNoDrawCanvas(int width, int height)
: INHERITED(SkIRect::MakeWH(width, height), kConservativeRasterClip_InitFlag) {}
+SkNoDrawCanvas::SkNoDrawCanvas(const SkIRect& bounds)
+ : INHERITED(bounds, kConservativeRasterClip_InitFlag) {}
+
SkCanvas::SaveLayerStrategy SkNoDrawCanvas::getSaveLayerStrategy(const SaveLayerRec& rec) {
(void)this->INHERITED::getSaveLayerStrategy(rec);
return kNoLayer_SaveLayerStrategy;
diff --git a/src/core/SkLiteRecorder.cpp b/src/core/SkLiteRecorder.cpp
index 866ebd0..b26547a 100644
--- a/src/core/SkLiteRecorder.cpp
+++ b/src/core/SkLiteRecorder.cpp
@@ -10,7 +10,7 @@
#include "SkSurface.h"
SkLiteRecorder::SkLiteRecorder()
- : SkCanvas({0,0,1,1}, SkCanvas::kConservativeRasterClip_InitFlag)
+ : INHERITED(1, 1)
, fDL(nullptr) {}
void SkLiteRecorder::reset(SkLiteDL* dl) {
@@ -25,7 +25,7 @@
#ifdef SK_SUPPORT_LEGACY_DRAWFILTER
SkDrawFilter* SkLiteRecorder::setDrawFilter(SkDrawFilter* df) {
fDL->setDrawFilter(df);
- return SkCanvas::setDrawFilter(df);
+ return this->INHERITED::setDrawFilter(df);
}
#endif
@@ -42,19 +42,19 @@
void SkLiteRecorder::onClipRect(const SkRect& rect, ClipOp op, ClipEdgeStyle style) {
fDL->clipRect(rect, op, style==kSoft_ClipEdgeStyle);
- SkCanvas::onClipRect(rect, op, style);
+ this->INHERITED::onClipRect(rect, op, style);
}
void SkLiteRecorder::onClipRRect(const SkRRect& rrect, ClipOp op, ClipEdgeStyle style) {
fDL->clipRRect(rrect, op, style==kSoft_ClipEdgeStyle);
- SkCanvas::onClipRRect(rrect, op, style);
+ this->INHERITED::onClipRRect(rrect, op, style);
}
void SkLiteRecorder::onClipPath(const SkPath& path, ClipOp op, ClipEdgeStyle style) {
fDL->clipPath(path, op, style==kSoft_ClipEdgeStyle);
- SkCanvas::onClipPath(path, op, style);
+ this->INHERITED::onClipPath(path, op, style);
}
void SkLiteRecorder::onClipRegion(const SkRegion& region, ClipOp op) {
fDL->clipRegion(region, op);
- SkCanvas::onClipRegion(region, op);
+ this->INHERITED::onClipRegion(region, op);
}
void SkLiteRecorder::onDrawPaint(const SkPaint& paint) {
diff --git a/src/core/SkLiteRecorder.h b/src/core/SkLiteRecorder.h
index 4ae2456..4ffd132 100644
--- a/src/core/SkLiteRecorder.h
+++ b/src/core/SkLiteRecorder.h
@@ -8,11 +8,11 @@
#ifndef SkLiteRecorder_DEFINED
#define SkLiteRecorder_DEFINED
-#include "SkCanvas.h"
+#include "SkNoDrawCanvas.h"
class SkLiteDL;
-class SkLiteRecorder final : public SkCanvas {
+class SkLiteRecorder final : public SkNoDrawCanvas {
public:
SkLiteRecorder();
void reset(SkLiteDL*);
@@ -90,6 +90,8 @@
#endif
private:
+ typedef SkNoDrawCanvas INHERITED;
+
SkLiteDL* fDL;
};
diff --git a/src/core/SkRecorder.cpp b/src/core/SkRecorder.cpp
index 91236c6..4c56d99 100644
--- a/src/core/SkRecorder.cpp
+++ b/src/core/SkRecorder.cpp
@@ -37,14 +37,14 @@
///////////////////////////////////////////////////////////////////////////////////////////////
SkRecorder::SkRecorder(SkRecord* record, int width, int height, SkMiniRecorder* mr)
- : SkCanvas(SkIRect::MakeWH(width, height), SkCanvas::kConservativeRasterClip_InitFlag)
+ : SkNoDrawCanvas(width, height)
, fDrawPictureMode(Record_DrawPictureMode)
, fApproxBytesUsedBySubPictures(0)
, fRecord(record)
, fMiniRecorder(mr) {}
SkRecorder::SkRecorder(SkRecord* record, const SkRect& bounds, SkMiniRecorder* mr)
- : SkCanvas(bounds.roundOut(), SkCanvas::kConservativeRasterClip_InitFlag)
+ : SkNoDrawCanvas(bounds.roundOut())
, fDrawPictureMode(Record_DrawPictureMode)
, fApproxBytesUsedBySubPictures(0)
, fRecord(record)
@@ -75,8 +75,8 @@
#define TRY_MINIRECORDER(method, ...) \
if (fMiniRecorder && fMiniRecorder->method(__VA_ARGS__)) { return; }
-// For methods which must call back into SkCanvas.
-#define INHERITED(method, ...) this->SkCanvas::method(__VA_ARGS__)
+// For methods which must call back into SkNoDrawCanvas.
+#define INHERITED(method, ...) this->SkNoDrawCanvas::method(__VA_ARGS__)
// Use copy() only for optional arguments, to be copied if present or skipped if not.
// (For most types we just pass by value and let copy constructors do their thing.)
diff --git a/src/core/SkRecorder.h b/src/core/SkRecorder.h
index 0f157b5..c93ee63 100644
--- a/src/core/SkRecorder.h
+++ b/src/core/SkRecorder.h
@@ -9,8 +9,8 @@
#define SkRecorder_DEFINED
#include "SkBigPicture.h"
-#include "SkCanvas.h"
#include "SkMiniRecorder.h"
+#include "SkNoDrawCanvas.h"
#include "SkRecord.h"
#include "SkRecords.h"
#include "SkTDArray.h"
@@ -36,7 +36,7 @@
// SkRecorder provides an SkCanvas interface for recording into an SkRecord.
-class SkRecorder : public SkCanvas {
+class SkRecorder final : public SkNoDrawCanvas {
public:
// Does not take ownership of the SkRecord.
SkRecorder(SkRecord*, int width, int height, SkMiniRecorder* = nullptr); // legacy version
diff --git a/src/pipe/SkPipeCanvas.cpp b/src/pipe/SkPipeCanvas.cpp
index 43235c3..1614bbd 100644
--- a/src/pipe/SkPipeCanvas.cpp
+++ b/src/pipe/SkPipeCanvas.cpp
@@ -208,7 +208,7 @@
///////////////////////////////////////////////////////////////////////////////////////////////////
SkPipeCanvas::SkPipeCanvas(const SkRect& cull, SkPipeDeduper* deduper, SkWStream* stream)
- : INHERITED(cull.roundOut(), SkCanvas::kConservativeRasterClip_InitFlag)
+ : INHERITED(cull.roundOut())
, fDeduper(deduper)
, fStream(stream)
{}
diff --git a/src/pipe/SkPipeCanvas.h b/src/pipe/SkPipeCanvas.h
index 508c2a1..e7b99bd 100644
--- a/src/pipe/SkPipeCanvas.h
+++ b/src/pipe/SkPipeCanvas.h
@@ -8,9 +8,9 @@
#ifndef SkPipeCanvas_DEFINED
#define SkPipeCanvas_DEFINED
-#include "SkCanvas.h"
#include "SkDeduper.h"
#include "SkImage.h"
+#include "SkNoDrawCanvas.h"
#include "SkPipe.h"
#include "SkTypeface.h"
#include "SkWriteBuffer.h"
@@ -89,7 +89,7 @@
};
-class SkPipeCanvas : public SkCanvas {
+class SkPipeCanvas : public SkNoDrawCanvas {
public:
SkPipeCanvas(const SkRect& cull, SkPipeDeduper*, SkWStream*);
~SkPipeCanvas() override;
@@ -165,7 +165,7 @@
friend class SkPipeWriter;
- typedef SkCanvas INHERITED;
+ typedef SkNoDrawCanvas INHERITED;
};
diff --git a/src/utils/SkDeferredCanvas.cpp b/src/utils/SkDeferredCanvas.cpp
index 19cfc97..aad8199 100644
--- a/src/utils/SkDeferredCanvas.cpp
+++ b/src/utils/SkDeferredCanvas.cpp
@@ -45,7 +45,7 @@
///////////////////////////////////////////////////////////////////////////////////////////////////
SkDeferredCanvas::SkDeferredCanvas(SkCanvas* canvas)
- : SkCanvas({0,0,1,1}, SkCanvas::kConservativeRasterClip_InitFlag) {
+ : INHERITED(1, 1) {
this->reset(canvas);
}
diff --git a/src/utils/SkDeferredCanvas.h b/src/utils/SkDeferredCanvas.h
index 38ee0cb..2549540 100644
--- a/src/utils/SkDeferredCanvas.h
+++ b/src/utils/SkDeferredCanvas.h
@@ -10,9 +10,9 @@
#define SkDeferredCanvas_DEFINED
#include "../private/SkTDArray.h"
-#include "SkCanvas.h"
+#include "SkNoDrawCanvas.h"
-class SK_API SkDeferredCanvas : public SkCanvas {
+class SK_API SkDeferredCanvas : public SkNoDrawCanvas {
public:
SkDeferredCanvas(SkCanvas* = nullptr);
~SkDeferredCanvas() override;
@@ -149,7 +149,7 @@
void internal_flush_translate(SkScalar* x, SkScalar* y, const SkRect* boundsOrNull);
- typedef SkCanvas INHERITED;
+ typedef SkNoDrawCanvas INHERITED;
};
diff --git a/src/utils/SkNWayCanvas.cpp b/src/utils/SkNWayCanvas.cpp
index d81a8ef..3e814d4 100644
--- a/src/utils/SkNWayCanvas.cpp
+++ b/src/utils/SkNWayCanvas.cpp
@@ -6,8 +6,7 @@
*/
#include "SkNWayCanvas.h"
-SkNWayCanvas::SkNWayCanvas(int width, int height)
- : INHERITED(SkIRect::MakeWH(width, height), SkCanvas::kConservativeRasterClip_InitFlag) {}
+SkNWayCanvas::SkNWayCanvas(int width, int height) : INHERITED(width, height) {}
SkNWayCanvas::~SkNWayCanvas() {
this->removeAll();