Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Static Public Member Functions | Private Member Functions | List of all members
SkSVGText Class Referencefinal

#include <SkSVGText.h>

Inheritance diagram for SkSVGText:
SkSVGTextContainer SkSVGTextFragment SkSVGTransformableNode SkSVGNode SkRefCnt SkRefCntBase

Static Public Member Functions

static sk_sp< SkSVGTextMake ()
 

Private Member Functions

void onRender (const SkSVGRenderContext &) const override
 
SkRect onObjectBoundingBox (const SkSVGRenderContext &) const override
 
SkPath onAsPath (const SkSVGRenderContext &) const override
 

Additional Inherited Members

- Public Member Functions inherited from SkSVGTextContainer
void appendChild (sk_sp< SkSVGNode >) final
 
- Public Member Functions inherited from SkSVGTextFragment
void renderText (const SkSVGRenderContext &, SkSVGTextContext *, SkSVGXmlSpace) const
 
- Public Member Functions inherited from SkSVGTransformableNode
void setTransform (const SkSVGTransformType &t)
 
- Public Member Functions inherited from SkSVGNode
 ~SkSVGNode () override
 
SkSVGTag tag () const
 
void render (const SkSVGRenderContext &) const
 
bool asPaint (const SkSVGRenderContext &, SkPaint *) const
 
SkPath asPath (const SkSVGRenderContext &) const
 
SkRect objectBoundingBox (const SkSVGRenderContext &) const
 
void setAttribute (SkSVGAttribute, const SkSVGValue &)
 
bool setAttribute (const char *attributeName, const char *attributeValue)
 
- Public Member Functions inherited from SkRefCntBase
 SkRefCntBase ()
 
virtual ~SkRefCntBase ()
 
bool unique () const
 
void ref () const
 
void unref () const
 
- Protected Member Functions inherited from SkSVGTextContainer
 SkSVGTextContainer (SkSVGTag t)
 
void onShapeText (const SkSVGRenderContext &, SkSVGTextContext *, SkSVGXmlSpace) const override
 
bool parseAndSetAttribute (const char *, const char *) override
 
- Protected Member Functions inherited from SkSVGTextFragment
 SkSVGTextFragment (SkSVGTag t)
 
void onRender (const SkSVGRenderContext &) const override
 
- Protected Member Functions inherited from SkSVGTransformableNode
 SkSVGTransformableNode (SkSVGTag)
 
bool onPrepareToRender (SkSVGRenderContext *) const override
 
void onSetAttribute (SkSVGAttribute, const SkSVGValue &) override
 
void mapToParent (SkPath *) const
 
void mapToParent (SkRect *) const
 
- Protected Member Functions inherited from SkSVGNode
 SkSVGNode (SkSVGTag)
 
virtual bool onAsPaint (const SkSVGRenderContext &, SkPaint *) const
 
virtual bool hasChildren () const
 
- Static Protected Member Functions inherited from SkSVGNode
static SkMatrix ComputeViewboxMatrix (const SkRect &, const SkRect &, SkSVGPreserveAspectRatio)
 

Detailed Description

Definition at line 63 of file SkSVGText.h.

Member Function Documentation

◆ Make()

static sk_sp< SkSVGText > SkSVGText::Make ( )
inlinestatic

Definition at line 65 of file SkSVGText.h.

65{ return sk_sp<SkSVGText>(new SkSVGText()); }

◆ onAsPath()

SkPath SkSVGText::onAsPath ( const SkSVGRenderContext ctx) const
overrideprivatevirtual

Implements SkSVGNode.

Definition at line 655 of file SkSVGText.cpp.

655 {
657
659 [&builder](const SkSVGRenderContext& ctx, const sk_sp<SkTextBlob>& blob, const SkPaint*,
660 const SkPaint*) {
661 if (!blob) {
662 return;
663 }
664
665 for (SkTextBlobRunIterator it(blob.get()); !it.done(); it.next()) {
666 struct GetPathsCtx {
668 const SkRSXform* xform;
669 } get_paths_ctx {builder, it.xforms()};
670
671 it.font().getPaths(it.glyphs(), it.glyphCount(), [](const SkPath* path,
672 const SkMatrix& matrix,
673 void* raw_ctx) {
674 auto* get_paths_ctx = static_cast<GetPathsCtx*>(raw_ctx);
675 const auto& glyph_rsx = *get_paths_ctx->xform++;
676
677 if (!path) {
678 return;
679 }
680
681 SkMatrix glyph_matrix;
682 glyph_matrix.setRSXform(glyph_rsx);
683 glyph_matrix.preConcat(matrix);
684
685 get_paths_ctx->builder.addPath(path->makeTransform(glyph_matrix));
686 }, &get_paths_ctx);
687 }
688 };
689
690 {
691 SkSVGTextContext tctx(ctx, as_path);
692 this->onShapeText(ctx, &tctx, this->getXmlSpace());
693 }
694
695 auto path = builder.detach();
696 this->mapToParent(&path);
697
698 return path;
699}
SkMatrix & setRSXform(const SkRSXform &rsxForm)
Definition SkMatrix.cpp:420
SkMatrix & preConcat(const SkMatrix &other)
Definition SkMatrix.cpp:674
void onShapeText(const SkSVGRenderContext &, SkSVGTextContext *, SkSVGXmlSpace) const override
std::function< void(const SkSVGRenderContext &, const sk_sp< SkTextBlob > &, const SkPaint *, const SkPaint *)> ShapedTextCallback
void mapToParent(SkPath *) const
unsigned useCenter Optional< SkMatrix > matrix
Definition SkRecords.h:258
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot The VM snapshot data that will be memory mapped as read only SnapshotAssetPath must be present isolate snapshot The isolate snapshot data that will be memory mapped as read only SnapshotAssetPath must be present cache dir path
Definition switches.h:57

◆ onObjectBoundingBox()

SkRect SkSVGText::onObjectBoundingBox ( const SkSVGRenderContext ctx) const
overrideprivatevirtual

Reimplemented from SkSVGNode.

Definition at line 622 of file SkSVGText.cpp.

622 {
624
625 const SkSVGTextContext::ShapedTextCallback compute_bounds =
626 [&bounds](const SkSVGRenderContext& ctx, const sk_sp<SkTextBlob>& blob, const SkPaint*,
627 const SkPaint*) {
628 if (!blob) {
629 return;
630 }
631
632 AutoSTArray<64, SkRect> glyphBounds;
633
634 for (SkTextBlobRunIterator it(blob.get()); !it.done(); it.next()) {
635 glyphBounds.reset(SkToInt(it.glyphCount()));
636 it.font().getBounds(it.glyphs(), it.glyphCount(), glyphBounds.get(), nullptr);
637
639 SkMatrix m;
640 for (uint32_t i = 0; i < it.glyphCount(); ++i) {
641 m.setRSXform(it.xforms()[i]);
642 bounds.join(m.mapRect(glyphBounds[i]));
643 }
644 }
645 };
646
647 {
648 SkSVGTextContext tctx(ctx, compute_bounds);
649 this->onShapeText(ctx, &tctx, this->getXmlSpace());
650 }
651
652 return bounds;
653}
#define SkASSERT(cond)
Definition SkAssert.h:116
constexpr int SkToInt(S x)
Definition SkTo.h:29
Optional< SkRect > bounds
Definition SkRecords.h:189
static constexpr SkRect MakeEmpty()
Definition SkRect.h:595

◆ onRender()

void SkSVGText::onRender ( const SkSVGRenderContext ctx) const
overrideprivatevirtual

Implements SkSVGNode.

Definition at line 603 of file SkSVGText.cpp.

603 {
604 const SkSVGTextContext::ShapedTextCallback render_text = [](const SkSVGRenderContext& ctx,
605 const sk_sp<SkTextBlob>& blob,
606 const SkPaint* fill,
607 const SkPaint* stroke) {
608 if (fill) {
609 ctx.canvas()->drawTextBlob(blob, 0, 0, *fill);
610 }
611 if (stroke) {
612 ctx.canvas()->drawTextBlob(blob, 0, 0, *stroke);
613 }
614 };
615
616 // Root <text> nodes establish a text layout context.
617 SkSVGTextContext tctx(ctx, render_text);
618
619 this->onShapeText(ctx, &tctx, this->getXmlSpace());
620}
void drawTextBlob(const SkTextBlob *blob, SkScalar x, SkScalar y, const SkPaint &paint)
SkCanvas * canvas() const

The documentation for this class was generated from the following files: