Flutter Engine
The Flutter Engine
Public Member Functions | List of all members
DrawTextBlobCommand Class Reference

#include <DrawCommand.h>

Inheritance diagram for DrawTextBlobCommand:
DrawCommand

Public Member Functions

 DrawTextBlobCommand (sk_sp< SkTextBlob > blob, SkScalar x, SkScalar y, const SkPaint &paint)
 
void execute (SkCanvas *canvas) const override
 
bool render (SkCanvas *canvas) const override
 
void toJSON (SkJSONWriter &writer, UrlDataManager &urlDataManager) const override
 
- Public Member Functions inherited from DrawCommand
 DrawCommand (OpType opType)
 
virtual ~DrawCommand ()
 
bool isVisible () const
 
void setVisible (bool toggle)
 
virtual void execute (SkCanvas *) const =0
 
virtual bool render (SkCanvas *canvas) const
 
virtual void toJSON (SkJSONWriter &writer, UrlDataManager &urlDataManager) const
 
OpType getOpType () const
 

Additional Inherited Members

- Public Types inherited from DrawCommand
enum  OpType {
  kBeginDrawPicture_OpType , kClear_OpType , kClipPath_OpType , kClipRegion_OpType ,
  kClipRect_OpType , kClipRRect_OpType , kClipShader_OpType , kResetClip_OpType ,
  kConcat_OpType , kConcat44_OpType , kDrawAnnotation_OpType , kDrawBitmap_OpType ,
  kDrawBitmapRect_OpType , kDrawDRRect_OpType , kDrawImage_OpType , kDrawImageLattice_OpType ,
  kDrawImageRect_OpType , kDrawImageRectLayer_OpType , kDrawOval_OpType , kDrawArc_OpType ,
  kDrawPaint_OpType , kDrawPatch_OpType , kDrawPath_OpType , kDrawPoints_OpType ,
  kDrawRect_OpType , kDrawRRect_OpType , kDrawRegion_OpType , kDrawShadow_OpType ,
  kDrawTextBlob_OpType , kDrawVertices_OpType , kDrawAtlas_OpType , kDrawDrawable_OpType ,
  kDrawEdgeAAQuad_OpType , kDrawEdgeAAImageSet_OpType , kEndDrawPicture_OpType , kRestore_OpType ,
  kSave_OpType , kSaveLayer_OpType , kSetMatrix_OpType , kSetM44_OpType ,
  kLast_OpType = kSetM44_OpType
}
 
- Static Public Member Functions inherited from DrawCommand
static void WritePNG (const SkBitmap &bitmap, SkWStream &out)
 
static const char * GetCommandString (OpType type)
 
static void MakeJsonColor (SkJSONWriter &, const SkColor color)
 
static void MakeJsonColor4f (SkJSONWriter &, const SkColor4f &color)
 
static void MakeJsonPoint (SkJSONWriter &, const SkPoint &point)
 
static void MakeJsonPoint (SkJSONWriter &, SkScalar x, SkScalar y)
 
static void MakeJsonPoint3 (SkJSONWriter &, const SkPoint3 &point)
 
static void MakeJsonRect (SkJSONWriter &, const SkRect &rect)
 
static void MakeJsonIRect (SkJSONWriter &, const SkIRect &)
 
static void MakeJsonMatrix (SkJSONWriter &, const SkMatrix &)
 
static void MakeJsonMatrix44 (SkJSONWriter &, const SkM44 &)
 
static void MakeJsonPath (SkJSONWriter &, const SkPath &path)
 
static void MakeJsonRegion (SkJSONWriter &, const SkRegion &region)
 
static void MakeJsonSampling (SkJSONWriter &, const SkSamplingOptions &sampling)
 
static void MakeJsonPaint (SkJSONWriter &, const SkPaint &paint, UrlDataManager &urlDataManager)
 
static void MakeJsonLattice (SkJSONWriter &, const SkCanvas::Lattice &lattice)
 
static void flatten (const SkFlattenable *flattenable, SkJSONWriter &writer, UrlDataManager &urlDataManager)
 
static bool flatten (const SkImage &image, SkJSONWriter &writer, UrlDataManager &urlDataManager)
 
static bool flatten (const SkBitmap &bitmap, SkJSONWriter &writer, UrlDataManager &urlDataManager)
 
- Static Public Attributes inherited from DrawCommand
static const int kOpTypeCount = kLast_OpType + 1
 

Detailed Description

Definition at line 518 of file DrawCommand.h.

Constructor & Destructor Documentation

◆ DrawTextBlobCommand()

DrawTextBlobCommand::DrawTextBlobCommand ( sk_sp< SkTextBlob blob,
SkScalar  x,
SkScalar  y,
const SkPaint paint 
)

Definition at line 1664 of file DrawCommand.cpp.

1668 : INHERITED(kDrawTextBlob_OpType)
1669 , fBlob(std::move(blob))
1670 , fXPos(x)
1671 , fYPos(y)
1672 , fPaint(paint) {}
@ kDrawTextBlob_OpType
Definition: DrawCommand.h:84
const Paint & paint
Definition: color_source.cc:38
double y
double x

Member Function Documentation

◆ execute()

void DrawTextBlobCommand::execute ( SkCanvas canvas) const
overridevirtual

Implements DrawCommand.

Definition at line 1674 of file DrawCommand.cpp.

1674 {
1675 canvas->drawTextBlob(fBlob, fXPos, fYPos, fPaint);
1676}
void drawTextBlob(const SkTextBlob *blob, SkScalar x, SkScalar y, const SkPaint &paint)
Definition: SkCanvas.cpp:2484

◆ render()

bool DrawTextBlobCommand::render ( SkCanvas canvas) const
overridevirtual

Reimplemented from DrawCommand.

Definition at line 1678 of file DrawCommand.cpp.

1678 {
1679 canvas->clear(SK_ColorWHITE);
1680 canvas->save();
1681
1682 SkRect bounds = fBlob->bounds().makeOffset(fXPos, fYPos);
1683 xlate_and_scale_to_bounds(canvas, bounds);
1684
1685 canvas->drawTextBlob(fBlob, fXPos, fYPos, fPaint);
1686
1687 canvas->restore();
1688
1689 return true;
1690}
constexpr SkColor SK_ColorWHITE
Definition: SkColor.h:122
void restore()
Definition: SkCanvas.cpp:461
void clear(SkColor color)
Definition: SkCanvas.h:1199
int save()
Definition: SkCanvas.cpp:447
const SkRect & bounds() const
Definition: SkTextBlob.h:53
Optional< SkRect > bounds
Definition: SkRecords.h:189
constexpr SkRect makeOffset(float dx, float dy) const
Definition: SkRect.h:965

◆ toJSON()

void DrawTextBlobCommand::toJSON ( SkJSONWriter writer,
UrlDataManager urlDataManager 
) const
overridevirtual

Reimplemented from DrawCommand.

Definition at line 1692 of file DrawCommand.cpp.

1692 {
1693 INHERITED::toJSON(writer, urlDataManager);
1694 writer.appendFloat(DEBUGCANVAS_ATTRIBUTE_X, fXPos);
1695 writer.appendFloat(DEBUGCANVAS_ATTRIBUTE_Y, fYPos);
1696 SkRect bounds = fBlob->bounds();
1698 MakeJsonRect(writer, bounds);
1700 MakeJsonPaint(writer, fPaint, urlDataManager);
1701
1703 SkTextBlobRunIterator iter(fBlob.get());
1704 while (!iter.done()) {
1705 writer.beginObject(); // run
1706 if (iter.textSize()) {
1707 writer.appendString(DEBUGCANVAS_ATTRIBUTE_TEXT, iter.text(), iter.textSize());
1708 }
1710 MakeJsonFont(iter.font(), writer, urlDataManager);
1712 MakeJsonPoint(writer, iter.offset());
1714 for (uint32_t i = 0; i < iter.glyphCount(); i++) {
1715 writer.appendU32(iter.glyphs()[i]);
1716 }
1717 writer.endArray(); // glyphs
1718 if (iter.positioning() != SkTextBlobRunIterator::kDefault_Positioning) {
1720 const SkScalar* iterPositions = iter.pos();
1721 for (uint32_t i = 0; i < iter.glyphCount(); i++) {
1722 switch (iter.positioning()) {
1724 MakeJsonPoint(writer, iterPositions[i * 2], iterPositions[i * 2 + 1]);
1725 break;
1727 writer.appendFloat(iterPositions[i]);
1728 break;
1731 // TODO_RSXFORM_BLOB
1732 break;
1733 }
1734 }
1735 writer.endArray(); // positions
1736 }
1737 if (iter.clusters()) {
1739 for (uint32_t i = 0; i < iter.glyphCount(); i++) {
1740 writer.appendU32(iter.clusters()[i]);
1741 }
1742 writer.endArray(); // clusters
1743 }
1744 writer.endObject(); // run
1745 iter.next();
1746 }
1747 writer.endArray(); // runs
1748
1749 SkString desc;
1750 // make the bounds local by applying the x,y
1751 bounds.offset(fXPos, fYPos);
1753}
#define DEBUGCANVAS_ATTRIBUTE_FONT
#define DEBUGCANVAS_ATTRIBUTE_BOUNDS
Definition: DrawCommand.cpp:72
#define DEBUGCANVAS_ATTRIBUTE_SHORTDESC
#define DEBUGCANVAS_ATTRIBUTE_CLUSTERS
Definition: DrawCommand.cpp:79
#define DEBUGCANVAS_ATTRIBUTE_POSITIONS
#define DEBUGCANVAS_ATTRIBUTE_PAINT
Definition: DrawCommand.cpp:73
static void MakeJsonFont(const SkFont &font, SkJSONWriter &writer, UrlDataManager &urlDataManager)
#define DEBUGCANVAS_ATTRIBUTE_X
static SkString * str_append(SkString *str, const SkRect &r)
#define DEBUGCANVAS_ATTRIBUTE_TEXT
Definition: DrawCommand.cpp:80
#define DEBUGCANVAS_ATTRIBUTE_GLYPHS
#define DEBUGCANVAS_ATTRIBUTE_Y
#define DEBUGCANVAS_ATTRIBUTE_COORDS
Definition: DrawCommand.cpp:69
#define DEBUGCANVAS_ATTRIBUTE_RUNS
static void MakeJsonPoint(SkJSONWriter &, const SkPoint &point)
static void MakeJsonPaint(SkJSONWriter &, const SkPaint &paint, UrlDataManager &urlDataManager)
virtual void toJSON(SkJSONWriter &writer, UrlDataManager &urlDataManager) const
static void MakeJsonRect(SkJSONWriter &, const SkRect &rect)
void beginArray(const char *name=nullptr, bool multiline=true)
Definition: SkJSONWriter.h:146
void appendU32(uint32_t value)
Definition: SkJSONWriter.h:239
void beginObject(const char *name=nullptr, bool multiline=true)
Definition: SkJSONWriter.h:114
void appendFloat(float value)
Definition: SkJSONWriter.h:241
void endObject()
Definition: SkJSONWriter.h:126
void appendName(const char *name)
Definition: SkJSONWriter.h:90
void endArray()
Definition: SkJSONWriter.h:158
void appendString(const char *value, size_t size)
Definition: SkJSONWriter.h:176
T * get() const
Definition: SkRefCnt.h:303
float SkScalar
Definition: extension.cpp:12

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