Rebase non-drawing SkCanvas subclasses to SkNoDrawCanvas
authorFlorin Malita <fmalita@chromium.org>
Fri, 2 Dec 2016 17:05:41 +0000 (12:05 -0500)
committerSkia Commit-Bot <skia-commit-bot@chromium.org>
Fri, 2 Dec 2016 18:25:49 +0000 (18:25 +0000)
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>

13 files changed:
include/core/SkCanvas.h
include/utils/SkNWayCanvas.h
include/utils/SkNoDrawCanvas.h
src/core/SkCanvas.cpp
src/core/SkLiteRecorder.cpp
src/core/SkLiteRecorder.h
src/core/SkRecorder.cpp
src/core/SkRecorder.h
src/pipe/SkPipeCanvas.cpp
src/pipe/SkPipeCanvas.h
src/utils/SkDeferredCanvas.cpp
src/utils/SkDeferredCanvas.h
src/utils/SkNWayCanvas.cpp

index 9887211057ec42b5dfb7502435a564bfff6190ad..0804ae4d966396929a6745c49bcfe39c103720d5 100644 (file)
@@ -1620,14 +1620,12 @@ private:
     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;
 
index e8b88ab157bc3a87f8132fc34bfb7daa6405930e..d8856dad0bdd9019a8063f68e2c0bfa83d068611 100644 (file)
@@ -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 @@ protected:
     class Iter;
 
 private:
-    typedef SkCanvas INHERITED;
+    typedef SkNoDrawCanvas INHERITED;
 };
 
 
index 0330251ede013e430a481b296b0986b625f93b3e..e8c5d7e5caba9f30e522e68302087ea087847542 100644 (file)
@@ -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 @@ class SK_API SkNoDrawCanvas : public SkCanvas {
 public:
     SkNoDrawCanvas(int width, int height);
 
+    // TODO: investigate the users of this ctor.
+    SkNoDrawCanvas(const SkIRect&);
+
 protected:
     SaveLayerStrategy getSaveLayerStrategy(const SaveLayerRec& rec) override;
 
index 25f83deb099e8ec912e85d80cbe456acf6b88e2c..2dff8e9f89a5274c1a86be1a9c2322867364ea58 100644 (file)
@@ -3373,6 +3373,9 @@ SkAutoCanvasMatrixPaint::~SkAutoCanvasMatrixPaint() {
 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;
index 866ebd0f59e872490d97abc51fe9ff20c242761f..b26547a4620f27cb20eaafe1277558d8319d3c97 100644 (file)
@@ -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 @@ sk_sp<SkSurface> SkLiteRecorder::onNewSurface(const SkImageInfo&, const SkSurfac
 #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::didTranslate(SkScalar dx, SkScalar dy) { fDL->translate(dx,
 
 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) {
index 4ae24564fec14ca07556d88857bdee55b4577281..4ffd132862e1d4cc7f13abe139f9412024f14b1b 100644 (file)
@@ -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 @@ public:
 #endif
 
 private:
+    typedef SkNoDrawCanvas INHERITED;
+
     SkLiteDL* fDL;
 };
 
index 91236c6a1f9dfe37f740454323d145beca9c68af..4c56d99f45ee04d6667a30952739c95f8aa03094 100644 (file)
@@ -37,14 +37,14 @@ void SkDrawableList::append(SkDrawable* drawable) {
 ///////////////////////////////////////////////////////////////////////////////////////////////
 
 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 @@ void SkRecorder::forgetRecord() {
 #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.)
index 0f157b51d8b098461967832ec4b63c6a80154052..c93ee63430b37abb8fbda0ab1e11b794d8a6b398 100644 (file)
@@ -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 @@ private:
 
 // 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
index 43235c3e68d057009bb5e5bc88ae23084d8b25c3..1614bbd6b8873a236545580cec056b02a32c7d8e 100644 (file)
@@ -208,7 +208,7 @@ public:
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 
 SkPipeCanvas::SkPipeCanvas(const SkRect& cull, SkPipeDeduper* deduper, SkWStream* stream)
-    : INHERITED(cull.roundOut(), SkCanvas::kConservativeRasterClip_InitFlag)
+    : INHERITED(cull.roundOut())
     , fDeduper(deduper)
     , fStream(stream)
 {}
index 508c2a1ba562a7bfb826e738d06393414f6c5bf9..e7b99bdd9397ad52ef464e994a2d8e7f78fb5c21 100644 (file)
@@ -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 @@ private:
 };
 
 
-class SkPipeCanvas : public SkCanvas {
+class SkPipeCanvas : public SkNoDrawCanvas {
 public:
     SkPipeCanvas(const SkRect& cull, SkPipeDeduper*, SkWStream*);
     ~SkPipeCanvas() override;
@@ -165,7 +165,7 @@ private:
 
     friend class SkPipeWriter;
 
-    typedef SkCanvas INHERITED;
+    typedef SkNoDrawCanvas INHERITED;
 };
 
 
index 19cfc97d410e959b0b5fb0af934096e3067032e3..aad8199864d55948de9e4d47b22149f0c9941411 100644 (file)
@@ -45,7 +45,7 @@ void SkDeferredCanvas::Rec::setConcat(const SkMatrix& m) {
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 
 SkDeferredCanvas::SkDeferredCanvas(SkCanvas* canvas)
-    : SkCanvas({0,0,1,1}, SkCanvas::kConservativeRasterClip_InitFlag) {
+    : INHERITED(1, 1) {
     this->reset(canvas);
 }
 
index 38ee0cbccf17e60625b46868629ed8113e436478..2549540943dfb77569b8b184e9bdaeda8fa5bc08 100644 (file)
@@ -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 @@ private:
 
     void internal_flush_translate(SkScalar* x, SkScalar* y, const SkRect* boundsOrNull);
 
-    typedef SkCanvas INHERITED;
+    typedef SkNoDrawCanvas INHERITED;
 };
 
 
index d81a8efbea0f590f89c8791fef02b84b11ac805c..3e814d4944800fbb550daacd0a9a2510f9b4cf98 100644 (file)
@@ -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();