From 0ec59b90ab943360c7699d516c81988a4c4a5b58 Mon Sep 17 00:00:00 2001 From: Herb Derby Date: Tue, 15 Feb 2022 13:33:50 -0500 Subject: [PATCH] add SubRunType for each SubRun to facilitate deserialization Change-Id: I058eb13d4efc20197d81f15d2261906950d6e92e Reviewed-on: https://skia-review.googlesource.com/c/skia/+/509397 Reviewed-by: Robert Phillips Commit-Queue: Herb Derby --- src/gpu/text/GrTextBlob.cpp | 29 +++++++++++++++++++++++++++++ src/gpu/text/GrTextBlob.h | 7 +++++-- 2 files changed, 34 insertions(+), 2 deletions(-) diff --git a/src/gpu/text/GrTextBlob.cpp b/src/gpu/text/GrTextBlob.cpp index 952f880bad..2c94b23b4f 100644 --- a/src/gpu/text/GrTextBlob.cpp +++ b/src/gpu/text/GrTextBlob.cpp @@ -50,6 +50,16 @@ using AtlasTextOp = skgpu::v1::AtlasTextOp; // Note: // In order to use GrSlugs, you need to set the fSupportBilerpFromGlyphAtlas on GrContextOptions. +enum GrSubRun::SubRunType : int { + kBad = 0, // Make this 0 to line up with errors from readInt. + kDirectMask, + kSDFT, + kTransformMask, + kPath, + kDrawable, + kSubRunTypeCount, +}; + // -- GrBlobSubRun --------------------------------------------------------------------------------- class GrBlobSubRun { public: @@ -509,6 +519,9 @@ public: } const GrAtlasSubRun* testingOnly_atlasSubRun() const override { return nullptr; } +protected: + SubRunType subRunType() const override { return kPath; } + private: PathOpSubmitter fPathDrawing; }; @@ -636,6 +649,9 @@ public: int unflattenSize() const override { return 0; } +protected: + SubRunType subRunType() const override { return kDrawable; } + private: DrawableOpSubmitter fDrawingDrawing; }; @@ -707,6 +723,10 @@ public: GrColor color, const SkMatrix& drawMatrix, SkPoint drawOrigin, SkIRect clip) const override; + +protected: + SubRunType subRunType() const override { return kDirectMask; } + private: // The rectangle that surrounds all the glyph bounding boxes in device space. SkRect deviceRect(const SkMatrix& drawMatrix, SkPoint drawOrigin) const; @@ -1113,6 +1133,9 @@ public: size_t vertexStride(const SkMatrix& drawMatrix) const override; int glyphCount() const override; +protected: + SubRunType subRunType() const override { return kTransformMask; } + private: // The rectangle that surrounds all the glyph bounding boxes in device space. SkRect deviceRect(const SkMatrix& drawMatrix, SkPoint drawOrigin) const; @@ -1324,6 +1347,9 @@ public: size_t vertexStride(const SkMatrix& drawMatrix) const override; int glyphCount() const override; +protected: + SubRunType subRunType() const override { return kSDFT; } + private: // The rectangle that surrounds all the glyph bounding boxes in device space. SkRect deviceRect(const SkMatrix& drawMatrix, SkPoint drawOrigin) const; @@ -2725,6 +2751,9 @@ public: const SkMatrix& drawMatrix, SkPoint drawOrigin, SkIRect clip) const override; +protected: + SubRunType subRunType() const override { return kDirectMask; } + private: // Return true if the positionMatrix represents an integer translation. Return the device // bounding box of all the glyphs. If the bounding box is empty, then something went singular diff --git a/src/gpu/text/GrTextBlob.h b/src/gpu/text/GrTextBlob.h index 33fd143230..0f3850584d 100644 --- a/src/gpu/text/GrTextBlob.h +++ b/src/gpu/text/GrTextBlob.h @@ -38,7 +38,7 @@ class SkSurfaceProps; class SkTextBlob; class SkTextBlobRunIterator; -namespace skgpu { namespace v1 { class SurfaceDrawContext; }} +namespace skgpu::v1 { class SurfaceDrawContext; } // -- GrAtlasSubRun -------------------------------------------------------------------------------- // GrAtlasSubRun is the API that AtlasTextOp uses to generate vertex data for drawing. @@ -110,6 +110,10 @@ public: // of the slug. If it's off then there may be more allocations needed to unflatten. virtual int unflattenSize() const = 0; +protected: + enum SubRunType : int; + virtual SubRunType subRunType() const = 0; + private: friend class GrSubRunList; GrSubRunOwner fNext; @@ -172,7 +176,6 @@ private: // class GrTextBlob final : public GrTextReferenceFrame, public SkGlyphRunPainterInterface { public: - // Key is not used as part of a hash map, so the hash is never taken. It's only used in a // list search using operator =(). struct Key {