diff options
author | 2018-03-15 17:34:40 -0400 | |
---|---|---|
committer | 2018-03-16 20:28:36 +0000 | |
commit | 76d69b44bbba118a6769b5fb267588ccac41a815 (patch) | |
tree | 2fdb871fb4f7ae9b00721661cd3fa361ba4cbfbd /src | |
parent | 7278d68cac9e39970144909df449113d43fff480 (diff) |
Apply filterTextFlags so the fonts are the same.
In order to apply filterTextFlags correctly, teach
TrackLayerDevice how to process save and restore layers.
At this point, I don't see any other traffic than the
cache warming traffic.
This code has a performance between 82% and 105% of just
drawing the picture.
BUG=skia:7515
Change-Id: I44736be46884f18b6d120d4b5ca582f34dbdff0f
Reviewed-on: https://skia-review.googlesource.com/114641
Reviewed-by: Herb Derby <herb@google.com>
Commit-Queue: Herb Derby <herb@google.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/core/SkCanvas.cpp | 56 | ||||
-rw-r--r-- | src/core/SkDevice.h | 66 |
2 files changed, 62 insertions, 60 deletions
diff --git a/src/core/SkCanvas.cpp b/src/core/SkCanvas.cpp index 2f31335286..24a6d4ab26 100644 --- a/src/core/SkCanvas.cpp +++ b/src/core/SkCanvas.cpp @@ -52,58 +52,6 @@ #define RETURN_ON_NULL(ptr) do { if (nullptr == (ptr)) return; } while (0) #define RETURN_ON_FALSE(pred) do { if (!(pred)) return; } while (0) -class SkNoPixelsDevice : public SkBaseDevice { -public: - SkNoPixelsDevice(const SkIRect& bounds, const SkSurfaceProps& props) - : SkBaseDevice(SkImageInfo::MakeUnknown(bounds.width(), bounds.height()), props) - { - // this fails if we enable this assert: DiscardableImageMapTest.GetDiscardableImagesInRectMaxImage - //SkASSERT(bounds.width() >= 0 && bounds.height() >= 0); - } - - void resetForNextPicture(const SkIRect& bounds) { - //SkASSERT(bounds.width() >= 0 && bounds.height() >= 0); - this->privateResize(bounds.width(), bounds.height()); - } - -protected: - // We don't track the clip at all (for performance), but we have to respond to some queries. - // We pretend to be wide-open. We could pretend to always be empty, but that *seems* worse. - void onSave() override {} - void onRestore() override {} - void onClipRect(const SkRect& rect, SkClipOp, bool aa) override {} - void onClipRRect(const SkRRect& rrect, SkClipOp, bool aa) override {} - void onClipPath(const SkPath& path, SkClipOp, bool aa) override {} - void onClipRegion(const SkRegion& deviceRgn, SkClipOp) override {} - void onSetDeviceClipRestriction(SkIRect* mutableClipRestriction) override {} - bool onClipIsAA() const override { return false; } - void onAsRgnClip(SkRegion* rgn) const override { - rgn->setRect(SkIRect::MakeWH(this->width(), this->height())); - } - ClipType onGetClipType() const override { - return kRect_ClipType; - } - - void drawPaint(const SkPaint& paint) override {} - void drawPoints(SkCanvas::PointMode, size_t, const SkPoint[], const SkPaint&) override {} - 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 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&, - SkCanvas::SrcRectConstraint) override {} - void drawText(const void*, size_t, SkScalar, SkScalar, const SkPaint&) override {} - void drawPosText(const void*, size_t, const SkScalar[], int, const SkPoint&, - const SkPaint&) override {} - void drawDevice(SkBaseDevice*, int, int, const SkPaint&) override {} - void drawVertices(const SkVertices*, SkBlendMode, const SkPaint&) override {} - -private: - typedef SkBaseDevice INHERITED; -}; - /////////////////////////////////////////////////////////////////////////////////////////////////// /* @@ -974,7 +922,6 @@ bool SkCanvas::clipRectBounds(const SkRect* bounds, SaveLayerFlags saveLayerFlag return true; } - int SkCanvas::saveLayer(const SkRect* bounds, const SkPaint* paint) { return this->saveLayer(SaveLayerRec(bounds, paint, 0)); } @@ -2907,6 +2854,9 @@ SkNoDrawCanvas::SkNoDrawCanvas(int width, int height) SkNoDrawCanvas::SkNoDrawCanvas(const SkIRect& bounds) : INHERITED(bounds, kConservativeRasterClip_InitFlag) {} +SkNoDrawCanvas::SkNoDrawCanvas(SkBaseDevice *device) + : INHERITED(device) {} + SkCanvas::SaveLayerStrategy SkNoDrawCanvas::getSaveLayerStrategy(const SaveLayerRec& rec) { (void)this->INHERITED::getSaveLayerStrategy(rec); return kNoLayer_SaveLayerStrategy; diff --git a/src/core/SkDevice.h b/src/core/SkDevice.h index c7b993cf22..6739230115 100644 --- a/src/core/SkDevice.h +++ b/src/core/SkDevice.h @@ -11,6 +11,7 @@ #include "SkRefCnt.h" #include "SkCanvas.h" #include "SkColor.h" +#include "SkRegion.h" #include "SkSurfaceProps.h" class SkBitmap; @@ -20,7 +21,6 @@ class SkImageFilterCache; struct SkIRect; class SkMatrix; class SkRasterHandleAllocator; -class SkRegion; class SkSpecialImage; class SkBaseDevice : public SkRefCnt { @@ -125,6 +125,12 @@ public: void setGlobalCTM(const SkMatrix& ctm); virtual void validateDevBounds(const SkIRect&) {} + /** + * Returns the text-related flags, possibly modified based on the state of the + * device (e.g. support for LCD). + */ + uint32_t filterTextFlags(const SkPaint&) const; + protected: enum TileUsage { kPossible_TileUsage, //!< the created device may be drawn tiled @@ -135,12 +141,6 @@ protected: uint32_t fFlags; // SkPaint::getFlags() }; - /** - * Returns the text-related flags, possibly modified based on the state of the - * device (e.g. support for LCD). - */ - uint32_t filterTextFlags(const SkPaint&) const; - virtual bool onShouldDisableLCD(const SkPaint&) const { return false; } virtual void onSave() {} @@ -390,6 +390,58 @@ private: typedef SkRefCnt INHERITED; }; +class SkNoPixelsDevice : public SkBaseDevice { +public: + SkNoPixelsDevice(const SkIRect& bounds, const SkSurfaceProps& props) + : SkBaseDevice(SkImageInfo::MakeUnknown(bounds.width(), bounds.height()), props) + { + // this fails if we enable this assert: DiscardableImageMapTest.GetDiscardableImagesInRectMaxImage + //SkASSERT(bounds.width() >= 0 && bounds.height() >= 0); + } + + void resetForNextPicture(const SkIRect& bounds) { + //SkASSERT(bounds.width() >= 0 && bounds.height() >= 0); + this->privateResize(bounds.width(), bounds.height()); + } + +protected: + // We don't track the clip at all (for performance), but we have to respond to some queries. + // We pretend to be wide-open. We could pretend to always be empty, but that *seems* worse. + void onSave() override {} + void onRestore() override {} + void onClipRect(const SkRect& rect, SkClipOp, bool aa) override {} + void onClipRRect(const SkRRect& rrect, SkClipOp, bool aa) override {} + void onClipPath(const SkPath& path, SkClipOp, bool aa) override {} + void onClipRegion(const SkRegion& deviceRgn, SkClipOp) override {} + void onSetDeviceClipRestriction(SkIRect* mutableClipRestriction) override {} + bool onClipIsAA() const override { return false; } + void onAsRgnClip(SkRegion* rgn) const override { + rgn->setRect(SkIRect::MakeWH(this->width(), this->height())); + } + ClipType onGetClipType() const override { + return kRect_ClipType; + } + + void drawPaint(const SkPaint& paint) override {} + void drawPoints(SkCanvas::PointMode, size_t, const SkPoint[], const SkPaint&) override {} + 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 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&, + SkCanvas::SrcRectConstraint) override {} + void drawText(const void*, size_t, SkScalar, SkScalar, const SkPaint&) override {} + void drawPosText(const void*, size_t, const SkScalar[], int, const SkPoint&, + const SkPaint&) override {} + void drawDevice(SkBaseDevice*, int, int, const SkPaint&) override {} + void drawVertices(const SkVertices*, SkBlendMode, const SkPaint&) override {} + +private: + typedef SkBaseDevice INHERITED; +}; + class SkAutoDeviceCTMRestore : SkNoncopyable { public: SkAutoDeviceCTMRestore(SkBaseDevice* device, const SkMatrix& ctm) |