Flutter Engine
The Flutter Engine
Public Types | Public Member Functions | Static Public Member Functions | Static Public Attributes | List of all members
DrawCommand Class Referenceabstract

#include <DrawCommand.h>

Inheritance diagram for DrawCommand:
BeginDrawPictureCommand ClearCommand ClipPathCommand ClipRRectCommand ClipRectCommand ClipRegionCommand ClipShaderCommand Concat44Command ConcatCommand DrawAnnotationCommand DrawArcCommand DrawAtlasCommand DrawBehindCommand DrawDRRectCommand DrawDrawableCommand DrawEdgeAAImageSetCommand DrawEdgeAAQuadCommand DrawImageCommand DrawImageLatticeCommand DrawImageRectCommand DrawImageRectLayerCommand DrawOvalCommand DrawPaintCommand DrawPatchCommand DrawPathCommand DrawPointsCommand DrawRRectCommand DrawRectCommand DrawRegionCommand DrawShadowCommand DrawTextBlobCommand DrawVerticesCommand EndDrawPictureCommand ResetClipCommand RestoreCommand SaveCommand SaveLayerCommand SetM44Command SetMatrixCommand

Public Types

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
}
 

Public Member Functions

 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
 

Static Public Member Functions

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

static const int kOpTypeCount = kLast_OpType + 1
 

Detailed Description

Definition at line 53 of file DrawCommand.h.

Member Enumeration Documentation

◆ OpType

Enumerator
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 

Definition at line 55 of file DrawCommand.h.

55 {
73 kDrawImageRectLayer_OpType, // unique to DebugCanvas
96
98 };
@ kDrawBitmapRect_OpType
Definition: DrawCommand.h:68
@ kDrawTextBlob_OpType
Definition: DrawCommand.h:84
@ kDrawPoints_OpType
Definition: DrawCommand.h:79
@ kDrawImageLattice_OpType
Definition: DrawCommand.h:71
@ kSaveLayer_OpType
Definition: DrawCommand.h:93
@ kDrawEdgeAAImageSet_OpType
Definition: DrawCommand.h:89
@ kDrawPath_OpType
Definition: DrawCommand.h:78
@ kDrawEdgeAAQuad_OpType
Definition: DrawCommand.h:88
@ kClipPath_OpType
Definition: DrawCommand.h:58
@ kClipShader_OpType
Definition: DrawCommand.h:62
@ kDrawPaint_OpType
Definition: DrawCommand.h:76
@ kClipRegion_OpType
Definition: DrawCommand.h:59
@ kClipRRect_OpType
Definition: DrawCommand.h:61
@ kDrawImageRectLayer_OpType
Definition: DrawCommand.h:73
@ kDrawAnnotation_OpType
Definition: DrawCommand.h:66
@ kDrawRect_OpType
Definition: DrawCommand.h:80
@ kDrawRRect_OpType
Definition: DrawCommand.h:81
@ kDrawVertices_OpType
Definition: DrawCommand.h:85
@ kEndDrawPicture_OpType
Definition: DrawCommand.h:90
@ kSetMatrix_OpType
Definition: DrawCommand.h:94
@ kDrawOval_OpType
Definition: DrawCommand.h:74
@ kBeginDrawPicture_OpType
Definition: DrawCommand.h:56
@ kDrawImage_OpType
Definition: DrawCommand.h:70
@ kDrawImageRect_OpType
Definition: DrawCommand.h:72
@ kDrawPatch_OpType
Definition: DrawCommand.h:77
@ kResetClip_OpType
Definition: DrawCommand.h:63
@ kDrawBitmap_OpType
Definition: DrawCommand.h:67
@ kDrawAtlas_OpType
Definition: DrawCommand.h:86
@ kConcat44_OpType
Definition: DrawCommand.h:65
@ kDrawDRRect_OpType
Definition: DrawCommand.h:69
@ kDrawShadow_OpType
Definition: DrawCommand.h:83
@ kDrawDrawable_OpType
Definition: DrawCommand.h:87
@ kClipRect_OpType
Definition: DrawCommand.h:60
@ kDrawRegion_OpType
Definition: DrawCommand.h:82

Constructor & Destructor Documentation

◆ DrawCommand()

DrawCommand::DrawCommand ( OpType  opType)

Definition at line 232 of file DrawCommand.cpp.

232: fOpType(type), fVisible(true) {}
GLenum type

◆ ~DrawCommand()

virtual DrawCommand::~DrawCommand ( )
inlinevirtual

Definition at line 106 of file DrawCommand.h.

106{}

Member Function Documentation

◆ execute()

virtual void DrawCommand::execute ( SkCanvas ) const
pure virtual

◆ flatten() [1/3]

bool DrawCommand::flatten ( const SkBitmap bitmap,
SkJSONWriter writer,
UrlDataManager urlDataManager 
)
static

Definition at line 732 of file DrawCommand.cpp.

734 {
735 sk_sp<SkImage> image(bitmap.asImage());
738 // Image will appear to have no uses, TODO(nifong): provide the user with a useful explanation
739 bool success = flatten(*image, writer, urlDataManager);
740 return success;
741}
#define DEBUGCANVAS_ATTRIBUTE_ALPHA
static const char * color_type_name(SkColorType colorType)
#define DEBUGCANVAS_ATTRIBUTE_COLOR
Definition: DrawCommand.cpp:81
static const char * alpha_type_name(SkAlphaType alphaType)
static void flatten(const SkFlattenable *flattenable, SkJSONWriter &writer, UrlDataManager &urlDataManager)
void appendCString(const char *value)
Definition: SkJSONWriter.h:224
sk_sp< const SkImage > image
Definition: SkRecords.h:269
Definition: bitmap.py:1

◆ flatten() [2/3]

void DrawCommand::flatten ( const SkFlattenable flattenable,
SkJSONWriter writer,
UrlDataManager urlDataManager 
)
static

Definition at line 630 of file DrawCommand.cpp.

632 {
633 SkBinaryWriteBuffer buffer({}); // TODO(kjlubick, bungeman) feed SkSerialProcs through API
634 flattenable->flatten(buffer);
635 void* data = sk_malloc_throw(buffer.bytesWritten());
636 buffer.writeToMemory(data);
637 SkString url =
638 encode_data(data, buffer.bytesWritten(), "application/octet-stream", urlDataManager);
641
643 JsonWriteBuffer jsonBuffer(&writer, &urlDataManager);
644 flattenable->flatten(jsonBuffer);
645 writer.endObject(); // values
646
647 sk_free(data);
648}
#define DEBUGCANVAS_ATTRIBUTE_DATA
#define DEBUGCANVAS_ATTRIBUTE_VALUES
#define DEBUGCANVAS_ATTRIBUTE_NAME
static SkString encode_data(const void *bytes, size_t count, const char *contentType, UrlDataManager &urlDataManager)
SK_API void sk_free(void *)
static void * sk_malloc_throw(size_t size)
Definition: SkMalloc.h:67
virtual void flatten(SkWriteBuffer &) const
Definition: SkFlattenable.h:67
virtual const char * getTypeName() const =0
void beginObject(const char *name=nullptr, bool multiline=true)
Definition: SkJSONWriter.h:114
void endObject()
Definition: SkJSONWriter.h:126
void appendString(const char *value, size_t size)
Definition: SkJSONWriter.h:176
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 to the cache directory This is different from the persistent_cache_path in embedder which is used for Skia shader cache icu native lib Path to the library file that exports the ICU data vm service The hostname IP address on which the Dart VM Service should be served If not defaults to or::depending on whether ipv6 is specified vm service A custom Dart VM Service port The default is to pick a randomly available open port disable vm Disable the Dart VM Service The Dart VM Service is never available in release mode disable vm service Disable mDNS Dart VM Service publication Bind to the IPv6 localhost address for the Dart VM Service Ignored if vm service host is set endless trace buffer
Definition: switches.h:126
std::shared_ptr< const fml::Mapping > data
Definition: texture_gles.cc:63

◆ flatten() [3/3]

bool DrawCommand::flatten ( const SkImage image,
SkJSONWriter writer,
UrlDataManager urlDataManager 
)
static

Definition at line 661 of file DrawCommand.cpp.

663 {
664 // For MSKP files, there is no need to encode the image,
665 // just report its id.
666 if (urlDataManager.hasImageIndex()) {
668 writer.appendU64(urlDataManager.lookupImage(&image));
669 return true;
670 }
671
673 size_t rowBytes = 4 * image.width();
674 SkAutoMalloc buffer(rowBytes * image.height());
675 SkImageInfo dstInfo =
676 SkImageInfo::Make(image.dimensions(), kN32_SkColorType, kPremul_SkAlphaType);
677 // "cheat" for this debug tool and use image's context
678 GrDirectContext* dContext = nullptr;
679#if defined(SK_GANESH)
680 dContext = GrAsDirectContext(as_IB(&image)->context());
681#endif
682 if (!image.readPixels(dContext, dstInfo, buffer.get(), rowBytes, 0, 0)) {
683 SkDebugf("DrawCommand::flatten SkImage: readPixels failed\n");
684 writer.endObject();
685 return false;
686 }
687
688 SkBitmap bm;
689 bm.installPixels(dstInfo, buffer.get(), rowBytes);
690
693 sk_sp<SkData> encoded = out.detachAsData();
694 if (encoded == nullptr) {
695 SkDebugf("DrawCommand::flatten SkImage: could not encode image as PNG\n");
696 writer.endObject();
697 return false;
698 }
699 auto dataPtr = encoded->data();
700 if (!dataPtr) {
701 SkDebugf("DrawCommand::flatten SkImage: encoding as PNG produced zero length data\n");
702 writer.endObject();
703 return false;
704 }
705 SkString url = encode_data(encoded->data(), encoded->size(), "image/png", urlDataManager);
707 writer.endObject();
708 return true;
709}
#define DEBUGCANVAS_ATTRIBUTE_IMAGE_INDEX
#define DEBUGCANVAS_ATTRIBUTE_IMAGE
static GrDirectContext * GrAsDirectContext(GrContext_Base *base)
@ kPremul_SkAlphaType
pixel components are premultiplied by alpha
Definition: SkAlphaType.h:29
void SK_SPI SkDebugf(const char format[],...) SK_PRINTF_LIKE(1
static SkImage_Base * as_IB(SkImage *image)
Definition: SkImage_Base.h:201
static void WritePNG(const SkBitmap &bitmap, SkWStream &out)
bool installPixels(const SkImageInfo &info, void *pixels, size_t rowBytes, void(*releaseProc)(void *addr, void *context), void *context)
Definition: SkBitmap.cpp:323
const void * data() const
Definition: SkData.h:37
size_t size() const
Definition: SkData.h:30
void appendU64(uint64_t value)
void appendName(const char *name)
Definition: SkJSONWriter.h:90
bool hasImageIndex()
int lookupImage(const SkImage *)
static SkImageInfo Make(int width, int height, SkColorType ct, SkAlphaType at)

◆ GetCommandString()

const char * DrawCommand::GetCommandString ( OpType  type)
static

Definition at line 234 of file DrawCommand.cpp.

234 {
235 switch (type) {
236 case kBeginDrawPicture_OpType: return "BeginDrawPicture";
237 case kClear_OpType: return "DrawClear";
238 case kClipPath_OpType: return "ClipPath";
239 case kClipRegion_OpType: return "ClipRegion";
240 case kClipRect_OpType: return "ClipRect";
241 case kClipRRect_OpType: return "ClipRRect";
242 case kResetClip_OpType: return "ResetClip";
243 case kConcat_OpType: return "Concat";
244 case kConcat44_OpType: return "Concat44";
245 case kDrawAnnotation_OpType: return "DrawAnnotation";
246 case kDrawBitmap_OpType: return "DrawBitmap";
247 case kDrawBitmapRect_OpType: return "DrawBitmapRect";
248 case kDrawDRRect_OpType: return "DrawDRRect";
249 case kDrawImage_OpType: return "DrawImage";
250 case kDrawImageLattice_OpType: return "DrawImageLattice";
251 case kDrawImageRect_OpType: return "DrawImageRect";
252 case kDrawImageRectLayer_OpType: return "DrawImageRectLayer";
253 case kDrawOval_OpType: return "DrawOval";
254 case kDrawPaint_OpType: return "DrawPaint";
255 case kDrawPatch_OpType: return "DrawPatch";
256 case kDrawPath_OpType: return "DrawPath";
257 case kDrawArc_OpType: return "DrawArc";
258 case kDrawPoints_OpType: return "DrawPoints";
259 case kDrawRect_OpType: return "DrawRect";
260 case kDrawRRect_OpType: return "DrawRRect";
261 case kDrawRegion_OpType: return "DrawRegion";
262 case kDrawShadow_OpType: return "DrawShadow";
263 case kDrawTextBlob_OpType: return "DrawTextBlob";
264 case kDrawVertices_OpType: return "DrawVertices";
265 case kDrawAtlas_OpType: return "DrawAtlas";
266 case kDrawDrawable_OpType: return "DrawDrawable";
267 case kDrawEdgeAAQuad_OpType: return "DrawEdgeAAQuad";
268 case kDrawEdgeAAImageSet_OpType: return "DrawEdgeAAImageSet";
269 case kEndDrawPicture_OpType: return "EndDrawPicture";
270 case kRestore_OpType: return "Restore";
271 case kSave_OpType: return "Save";
272 case kSaveLayer_OpType: return "SaveLayer";
273 case kSetMatrix_OpType: return "SetMatrix";
274 case kSetM44_OpType: return "SetM44";
275 default:
276 SkDebugf("OpType error 0x%08x\n", type);
277 SkASSERT(0);
278 break;
279 }
280 SkDEBUGFAIL("DrawType UNUSED\n");
281 return nullptr;
282}
#define SkDEBUGFAIL(message)
Definition: SkAssert.h:118
#define SkASSERT(cond)
Definition: SkAssert.h:116

◆ getOpType()

OpType DrawCommand::getOpType ( ) const
inline

Definition at line 143 of file DrawCommand.h.

143{ return fOpType; }

◆ isVisible()

bool DrawCommand::isVisible ( ) const
inline

Definition at line 108 of file DrawCommand.h.

108{ return fVisible; }

◆ MakeJsonColor()

void DrawCommand::MakeJsonColor ( SkJSONWriter writer,
const SkColor  color 
)
static

Definition at line 400 of file DrawCommand.cpp.

400 {
401 writer.beginArray(nullptr, false);
402 writer.appendS32(SkColorGetA(color));
403 writer.appendS32(SkColorGetR(color));
404 writer.appendS32(SkColorGetG(color));
405 writer.appendS32(SkColorGetB(color));
406 writer.endArray();
407}
#define SkColorGetR(color)
Definition: SkColor.h:65
#define SkColorGetG(color)
Definition: SkColor.h:69
#define SkColorGetA(color)
Definition: SkColor.h:61
#define SkColorGetB(color)
Definition: SkColor.h:73
void appendS32(int32_t value)
Definition: SkJSONWriter.h:237
void beginArray(const char *name=nullptr, bool multiline=true)
Definition: SkJSONWriter.h:146
void endArray()
Definition: SkJSONWriter.h:158
DlColor color

◆ MakeJsonColor4f()

void DrawCommand::MakeJsonColor4f ( SkJSONWriter writer,
const SkColor4f color 
)
static

Definition at line 409 of file DrawCommand.cpp.

409 {
410 writer.beginArray(nullptr, false);
411 writer.appendFloat(color.fA);
412 writer.appendFloat(color.fR);
413 writer.appendFloat(color.fG);
414 writer.appendFloat(color.fB);
415 writer.endArray();
416}
void appendFloat(float value)
Definition: SkJSONWriter.h:241

◆ MakeJsonIRect()

void DrawCommand::MakeJsonIRect ( SkJSONWriter writer,
const SkIRect rect 
)
static

Definition at line 449 of file DrawCommand.cpp.

449 {
450 writer.beginArray(nullptr, false);
451 writer.appendS32(rect.left());
452 writer.appendS32(rect.top());
453 writer.appendS32(rect.right());
454 writer.appendS32(rect.bottom());
455 writer.endArray();
456}
sk_sp< SkBlender > blender SkRect rect
Definition: SkRecords.h:350

◆ MakeJsonLattice()

void DrawCommand::MakeJsonLattice ( SkJSONWriter writer,
const SkCanvas::Lattice lattice 
)
static

Definition at line 972 of file DrawCommand.cpp.

972 {
973 writer.beginObject();
976 if (nullptr != lattice.fBounds) {
978 MakeJsonIRect(writer, *lattice.fBounds);
979 }
981 for (int i = 0; i < lattice.fXCount; i++) {
982 writer.appendS32(lattice.fXDivs[i]);
983 }
984 writer.endArray(); // xdivs
986 for (int i = 0; i < lattice.fYCount; i++) {
987 writer.appendS32(lattice.fYDivs[i]);
988 }
989 writer.endArray(); // ydivs
990 if (nullptr != lattice.fRectTypes) {
992 int flagCount = 0;
993 for (int row = 0; row < lattice.fYCount + 1; row++) {
994 writer.beginArray();
995 for (int column = 0; column < lattice.fXCount + 1; column++) {
996 writer.appendS32(lattice.fRectTypes[flagCount++]);
997 }
998 writer.endArray(); // row
999 }
1000 writer.endArray();
1001 }
1002 writer.endObject();
1003}
#define DEBUGCANVAS_ATTRIBUTE_LATTICEFLAGS
#define DEBUGCANVAS_ATTRIBUTE_BOUNDS
Definition: DrawCommand.cpp:72
#define DEBUGCANVAS_ATTRIBUTE_LATTICEXDIVS
#define DEBUGCANVAS_ATTRIBUTE_LATTICEYDIVS
#define DEBUGCANVAS_ATTRIBUTE_LATTICEYCOUNT
#define DEBUGCANVAS_ATTRIBUTE_LATTICEXCOUNT
static void MakeJsonIRect(SkJSONWriter &, const SkIRect &)
int flagCount
Definition: SkRecords.h:274
int fYCount
number of y-coordinates
Definition: SkCanvas.h:1617
const SkIRect * fBounds
source bounds to draw from
Definition: SkCanvas.h:1618
const int * fYDivs
y-axis values dividing bitmap
Definition: SkCanvas.h:1614
int fXCount
number of x-coordinates
Definition: SkCanvas.h:1616
const RectType * fRectTypes
array of fill types
Definition: SkCanvas.h:1615
const int * fXDivs
x-axis values dividing bitmap
Definition: SkCanvas.h:1613

◆ MakeJsonMatrix()

void DrawCommand::MakeJsonMatrix ( SkJSONWriter writer,
const SkMatrix matrix 
)
static

Definition at line 468 of file DrawCommand.cpp.

468 {
469 writer.beginArray();
470 for (int r = 0; r < 3; ++r) {
471 writer.beginArray(nullptr, false);
472 for (int c = 0; c < 3; ++c) {
473 writer.appendFloat(matrix[r * 3 + c]);
474 }
475 writer.endArray();
476 }
477 writer.endArray();
478}
unsigned useCenter Optional< SkMatrix > matrix
Definition: SkRecords.h:258

◆ MakeJsonMatrix44()

void DrawCommand::MakeJsonMatrix44 ( SkJSONWriter writer,
const SkM44 matrix 
)
static

Definition at line 480 of file DrawCommand.cpp.

480 {
481 writer.beginArray();
482 for (int r = 0; r < 4; ++r) {
483 writer.beginArray(nullptr, false);
484 for (int c = 0; c < 4; ++c) {
485 writer.appendFloat(matrix.rc(r, c));
486 }
487 writer.endArray();
488 }
489 writer.endArray();
490}

◆ MakeJsonPaint()

void DrawCommand::MakeJsonPaint ( SkJSONWriter writer,
const SkPaint paint,
UrlDataManager urlDataManager 
)
static

Definition at line 928 of file DrawCommand.cpp.

930 {
931 writer.beginObject();
932 store_scalar(writer, DEBUGCANVAS_ATTRIBUTE_STROKEWIDTH, paint.getStrokeWidth(), 0.0f);
933 store_scalar(writer,
935 paint.getStrokeMiter(),
937 store_bool(writer, DEBUGCANVAS_ATTRIBUTE_ANTIALIAS, paint.isAntiAlias(), false);
938 store_bool(writer, DEBUGCANVAS_ATTRIBUTE_DITHER, paint.isDither(), false);
939
940 apply_paint_color(paint, writer);
941 apply_paint_style(paint, writer);
942 apply_paint_blend_mode(paint, writer);
943 apply_paint_cap(paint, writer);
944 apply_paint_join(paint, writer);
945 apply_paint_patheffect(paint, writer, urlDataManager);
946 apply_paint_maskfilter(paint, writer, urlDataManager);
947 apply_flattenable(DEBUGCANVAS_ATTRIBUTE_SHADER, paint.getShader(), writer, urlDataManager);
949 DEBUGCANVAS_ATTRIBUTE_IMAGEFILTER, paint.getImageFilter(), writer, urlDataManager);
951 DEBUGCANVAS_ATTRIBUTE_COLORFILTER, paint.getColorFilter(), writer, urlDataManager);
952 writer.endObject(); // paint
953}
static void apply_paint_patheffect(const SkPaint &paint, SkJSONWriter &writer, UrlDataManager &urlDataManager)
#define DEBUGCANVAS_ATTRIBUTE_IMAGEFILTER
#define DEBUGCANVAS_ATTRIBUTE_SHADER
static void store_bool(SkJSONWriter &writer, const char *key, bool value, bool defaultValue)
static void apply_paint_maskfilter(const SkPaint &paint, SkJSONWriter &writer, UrlDataManager &urlDataManager)
#define DEBUGCANVAS_ATTRIBUTE_ANTIALIAS
Definition: DrawCommand.cpp:90
static void apply_paint_join(const SkPaint &paint, SkJSONWriter &writer)
static void store_scalar(SkJSONWriter &writer, const char *key, SkScalar value, SkScalar defaultValue)
#define DEBUGCANVAS_ATTRIBUTE_COLORFILTER
#define DEBUGCANVAS_ATTRIBUTE_STROKEMITER
Definition: DrawCommand.cpp:87
static void apply_paint_style(const SkPaint &paint, SkJSONWriter &writer)
#define DEBUGCANVAS_ATTRIBUTE_STROKEWIDTH
Definition: DrawCommand.cpp:86
static void apply_paint_cap(const SkPaint &paint, SkJSONWriter &writer)
#define DEBUGCANVAS_ATTRIBUTE_DITHER
Definition: DrawCommand.cpp:91
static void apply_flattenable(const char *key, SkFlattenable *flattenable, SkJSONWriter &writer, UrlDataManager &urlDataManager)
static void apply_paint_color(const SkPaint &paint, SkJSONWriter &writer)
#define SkPaintDefaults_MiterLimit
const Paint & paint
Definition: color_source.cc:38

◆ MakeJsonPath()

void DrawCommand::MakeJsonPath ( SkJSONWriter writer,
const SkPath path 
)
static

Definition at line 492 of file DrawCommand.cpp.

492 {
493 writer.beginObject();
494
496 path.dump(&wstream, false);
497 auto data = wstream.detachAsData();
499 static_cast<const char*>(data->data()), data->size());
500
501 switch (path.getFillType()) {
504 break;
507 break;
511 break;
515 break;
516 }
518 SkPath::Iter iter(path, false);
519 SkPoint pts[4];
520 SkPath::Verb verb;
521 while ((verb = iter.next(pts)) != SkPath::kDone_Verb) {
522 if (verb == SkPath::kClose_Verb) {
524 continue;
525 }
526 writer.beginObject(); // verb
527 switch (verb) {
528 case SkPath::kLine_Verb: {
530 MakeJsonPoint(writer, pts[1]);
531 break;
532 }
533 case SkPath::kQuad_Verb: {
535 MakeJsonPoint(writer, pts[1]);
536 MakeJsonPoint(writer, pts[2]);
537 writer.endArray(); // quad coords
538 break;
539 }
540 case SkPath::kCubic_Verb: {
542 MakeJsonPoint(writer, pts[1]);
543 MakeJsonPoint(writer, pts[2]);
544 MakeJsonPoint(writer, pts[3]);
545 writer.endArray(); // cubic coords
546 break;
547 }
548 case SkPath::kConic_Verb: {
550 MakeJsonPoint(writer, pts[1]);
551 MakeJsonPoint(writer, pts[2]);
552 writer.appendFloat(iter.conicWeight());
553 writer.endArray(); // conic coords
554 break;
555 }
556 case SkPath::kMove_Verb: {
558 MakeJsonPoint(writer, pts[0]);
559 break;
560 }
563 // Unreachable
564 break;
565 }
566 writer.endObject(); // verb
567 }
568 writer.endArray(); // verbs
569 writer.endObject(); // path
570}
#define DEBUGCANVAS_VERB_CUBIC
#define DEBUGCANVAS_FILLTYPE_EVENODD
#define DEBUGCANVAS_VERB_QUAD
#define DEBUGCANVAS_FILLTYPE_INVERSEWINDING
#define DEBUGCANVAS_FILLTYPE_INVERSEEVENODD
#define DEBUGCANVAS_VERB_CONIC
#define DEBUGCANVAS_ATTRIBUTE_DUMP
Definition: DrawCommand.cpp:64
#define DEBUGCANVAS_VERB_MOVE
#define DEBUGCANVAS_VERB_CLOSE
#define DEBUGCANVAS_FILLTYPE_WINDING
#define DEBUGCANVAS_ATTRIBUTE_VERBS
#define DEBUGCANVAS_ATTRIBUTE_FILLTYPE
#define DEBUGCANVAS_VERB_LINE
static void MakeJsonPoint(SkJSONWriter &, const SkPoint &point)
sk_sp< SkData > detachAsData()
Definition: SkStream.cpp:707
void appendNString(char const (&value)[N])
Definition: SkJSONWriter.h:220
@ kClose_Verb
Definition: SkPath.h:1471
@ kMove_Verb
Definition: SkPath.h:1466
@ kConic_Verb
Definition: SkPath.h:1469
@ kDone_Verb
Definition: SkPath.h:1472
@ kCubic_Verb
Definition: SkPath.h:1470
@ kQuad_Verb
Definition: SkPath.h:1468
@ kLine_Verb
Definition: SkPath.h:1467
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

◆ MakeJsonPoint() [1/2]

void DrawCommand::MakeJsonPoint ( SkJSONWriter writer,
const SkPoint point 
)
static

Definition at line 418 of file DrawCommand.cpp.

418 {
419 writer.beginArray(nullptr, false);
420 writer.appendFloat(point.x());
421 writer.appendFloat(point.y());
422 writer.endArray();
423}
constexpr float y() const
Definition: SkPoint_impl.h:187
constexpr float x() const
Definition: SkPoint_impl.h:181

◆ MakeJsonPoint() [2/2]

void DrawCommand::MakeJsonPoint ( SkJSONWriter writer,
SkScalar  x,
SkScalar  y 
)
static

Definition at line 425 of file DrawCommand.cpp.

425 {
426 writer.beginArray(nullptr, false);
427 writer.appendFloat(x);
428 writer.appendFloat(y);
429 writer.endArray();
430}
double y
double x

◆ MakeJsonPoint3()

void DrawCommand::MakeJsonPoint3 ( SkJSONWriter writer,
const SkPoint3 point 
)
static

Definition at line 432 of file DrawCommand.cpp.

432 {
433 writer.beginArray(nullptr, false);
434 writer.appendFloat(point.x());
435 writer.appendFloat(point.y());
436 writer.appendFloat(point.z());
437 writer.endArray();
438}
SkScalar x() const
Definition: SkPoint3.h:24
SkScalar y() const
Definition: SkPoint3.h:25
SkScalar z() const
Definition: SkPoint3.h:26

◆ MakeJsonRect()

void DrawCommand::MakeJsonRect ( SkJSONWriter writer,
const SkRect rect 
)
static

Definition at line 440 of file DrawCommand.cpp.

440 {
441 writer.beginArray(nullptr, false);
442 writer.appendFloat(rect.left());
443 writer.appendFloat(rect.top());
444 writer.appendFloat(rect.right());
445 writer.appendFloat(rect.bottom());
446 writer.endArray();
447}

◆ MakeJsonRegion()

void DrawCommand::MakeJsonRegion ( SkJSONWriter writer,
const SkRegion region 
)
static

Definition at line 572 of file DrawCommand.cpp.

572 {
573 // TODO: Actually serialize the rectangles, rather than just devolving to path
574 SkPath path;
576 MakeJsonPath(writer, path);
577}
static void MakeJsonPath(SkJSONWriter &, const SkPath &path)
Definition: SkPath.h:59
bool getBoundaryPath(SkPath *path) const
ClipOpAndAA opAA SkRegion region
Definition: SkRecords.h:238

◆ MakeJsonSampling()

void DrawCommand::MakeJsonSampling ( SkJSONWriter writer,
const SkSamplingOptions sampling 
)
static

Definition at line 579 of file DrawCommand.cpp.

579 {
580 writer.beginObject();
581 writer.appendS32("maxAniso", sampling.maxAniso);
582 writer.appendBool("useCubic", sampling.useCubic);
583 writer.appendS32("filter", (int)sampling.filter);
584 writer.appendS32("mipmap", (int)sampling.mipmap);
585 writer.appendFloat("cubic.B", sampling.cubic.B);
586 writer.appendFloat("cubic.C", sampling.cubic.C);
587 writer.endObject();
588}
void appendBool(bool value)
Definition: SkJSONWriter.h:229
SkSamplingOptions sampling
Definition: SkRecords.h:337
const SkCubicResampler cubic
const SkFilterMode filter
const SkMipmapMode mipmap

◆ render()

virtual bool DrawCommand::render ( SkCanvas canvas) const
inlinevirtual

◆ setVisible()

void DrawCommand::setVisible ( bool  toggle)
inline

Definition at line 110 of file DrawCommand.h.

110{ fVisible = toggle; }

◆ toJSON()

void DrawCommand::toJSON ( SkJSONWriter writer,
UrlDataManager urlDataManager 
) const
virtual

◆ WritePNG()

void DrawCommand::WritePNG ( const SkBitmap bitmap,
SkWStream out 
)
static

Definition at line 650 of file DrawCommand.cpp.

650 {
651 SkPixmap pm;
652 SkAssertResult(bitmap.peekPixels(&pm));
653
655 options.fZLibLevel = 1;
658}
const char * options
SkAssertResult(font.textToGlyphs("Hello", 5, SkTextEncoding::kUTF8, glyphs, std::size(glyphs))==count)
SK_API bool Encode(SkWStream *dst, const SkPixmap &src, const Options &options)

Member Data Documentation

◆ kOpTypeCount

const int DrawCommand::kOpTypeCount = kLast_OpType + 1
static

Definition at line 100 of file DrawCommand.h.


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