Flutter Engine
The Flutter Engine
Classes | Public Member Functions | Static Public Member Functions | List of all members
SkSVGDevice Class Referencefinal

#include <SkSVGDevice.h>

Inheritance diagram for SkSVGDevice:
SkClipStackDevice SkDevice SkRefCnt SkRefCntBase

Classes

class  AutoElement
 
struct  MxCp
 
class  ResourceBucket
 

Public Member Functions

void drawPaint (const SkPaint &paint) override
 
void drawAnnotation (const SkRect &rect, const char key[], SkData *value) override
 
void drawPoints (SkCanvas::PointMode mode, size_t count, const SkPoint[], const SkPaint &paint) override
 
void drawImageRect (const SkImage *image, const SkRect *src, const SkRect &dst, const SkSamplingOptions &, const SkPaint &paint, SkCanvas::SrcRectConstraint constraint) override
 
void drawRect (const SkRect &r, const SkPaint &paint) override
 
void drawOval (const SkRect &oval, const SkPaint &paint) override
 
void drawRRect (const SkRRect &rr, const SkPaint &paint) override
 
void drawPath (const SkPath &path, const SkPaint &paint, bool pathIsMutable=false) override
 
void drawVertices (const SkVertices *, sk_sp< SkBlender >, const SkPaint &, bool) override
 
void drawMesh (const SkMesh &, sk_sp< SkBlender >, const SkPaint &) override
 
- Public Member Functions inherited from SkClipStackDevice
 SkClipStackDevice (const SkImageInfo &info, const SkSurfaceProps &props)
 
SkClipStackcs ()
 
const SkClipStackcs () const
 
void pushClipStack () override
 
void popClipStack () override
 
void clipRect (const SkRect &rect, SkClipOp, bool aa) override
 
void clipRRect (const SkRRect &rrect, SkClipOp, bool aa) override
 
void clipPath (const SkPath &path, SkClipOp, bool aa) override
 
void clipRegion (const SkRegion &deviceRgn, SkClipOp) override
 
void replaceClip (const SkIRect &rect) override
 
bool isClipAntiAliased () const override
 
bool isClipWideOpen () const override
 
bool isClipEmpty () const override
 
bool isClipRect () const override
 
void android_utils_clipAsRgn (SkRegion *) const override
 
SkIRect devClipBounds () const override
 
- Public Member Functions inherited from SkDevice
 SkDevice (const SkImageInfo &, const SkSurfaceProps &)
 
const SkImageInfoimageInfo () const
 
int width () const
 
int height () const
 
bool isOpaque () const
 
SkIRect bounds () const
 
SkISize size () const
 
const SkSurfacePropssurfaceProps () const
 
SkScalerContextFlags scalerContextFlags () const
 
virtual SkStrikeDeviceInfo strikeDeviceInfo () const
 
bool writePixels (const SkPixmap &src, int x, int y)
 
bool readPixels (const SkPixmap &dst, int x, int y)
 
bool accessPixels (SkPixmap *pmap)
 
bool peekPixels (SkPixmap *)
 
const SkM44localToDevice44 () const
 
const SkMatrixlocalToDevice () const
 
const SkM44deviceToGlobal () const
 
const SkM44globalToDevice () const
 
SkIPoint getOrigin () const
 
bool isPixelAlignedToGlobal () const
 
SkMatrix getRelativeTransform (const SkDevice &) const
 
void setLocalToDevice (const SkM44 &localToDevice)
 
void setGlobalCTM (const SkM44 &ctm)
 
void getGlobalBounds (SkIRect *bounds) const
 
SkIRect getGlobalBounds () const
 
virtual SkIRect devClipBounds () const =0
 
virtual void pushClipStack ()=0
 
virtual void popClipStack ()=0
 
virtual void clipRect (const SkRect &rect, SkClipOp op, bool aa)=0
 
virtual void clipRRect (const SkRRect &rrect, SkClipOp op, bool aa)=0
 
virtual void clipPath (const SkPath &path, SkClipOp op, bool aa)=0
 
virtual void clipRegion (const SkRegion &region, SkClipOp op)=0
 
void clipShader (sk_sp< SkShader > sh, SkClipOp op)
 
virtual void replaceClip (const SkIRect &rect)=0
 
virtual bool isClipAntiAliased () const =0
 
virtual bool isClipEmpty () const =0
 
virtual bool isClipRect () const =0
 
virtual bool isClipWideOpen () const =0
 
virtual void android_utils_clipAsRgn (SkRegion *) const =0
 
virtual bool android_utils_clipWithStencil ()
 
virtual bool useDrawCoverageMaskForMaskFilters () const
 
virtual bool isNoPixelsDevice () const
 
virtual void * getRasterHandle () const
 
virtual GrRecordingContextrecordingContext () const
 
virtual skgpu::graphite::Recorderrecorder () const
 
virtual skgpu::ganesh::DeviceasGaneshDevice ()
 
virtual skgpu::graphite::DeviceasGraphiteDevice ()
 
virtual void setImmutable ()
 
virtual sk_sp< SkSurfacemakeSurface (const SkImageInfo &, const SkSurfaceProps &)
 
virtual sk_sp< SkDevicecreateDevice (const CreateInfo &, const SkPaint *)
 
void drawGlyphRunList (SkCanvas *, const sktext::GlyphRunList &glyphRunList, const SkPaint &paint)
 
virtual sk_sp< sktext::gpu::SlugconvertGlyphRunListToSlug (const sktext::GlyphRunList &glyphRunList, const SkPaint &paint)
 
virtual void drawSlug (SkCanvas *, const sktext::gpu::Slug *slug, const SkPaint &paint)
 
virtual void drawPaint (const SkPaint &paint)=0
 
virtual void drawPoints (SkCanvas::PointMode mode, size_t count, const SkPoint[], const SkPaint &paint)=0
 
virtual void drawRect (const SkRect &r, const SkPaint &paint)=0
 
virtual void drawRegion (const SkRegion &r, const SkPaint &paint)
 
virtual void drawOval (const SkRect &oval, const SkPaint &paint)=0
 
virtual void drawArc (const SkArc &arc, const SkPaint &paint)
 
virtual void drawRRect (const SkRRect &rr, const SkPaint &paint)=0
 
virtual void drawDRRect (const SkRRect &outer, const SkRRect &inner, const SkPaint &)
 
virtual void drawPath (const SkPath &path, const SkPaint &paint, bool pathIsMutable=false)=0
 
virtual void drawImageRect (const SkImage *, const SkRect *src, const SkRect &dst, const SkSamplingOptions &, const SkPaint &, SkCanvas::SrcRectConstraint)=0
 
virtual bool shouldDrawAsTiledImageRect () const
 
virtual bool drawAsTiledImageRect (SkCanvas *, const SkImage *, const SkRect *src, const SkRect &dst, const SkSamplingOptions &, const SkPaint &, SkCanvas::SrcRectConstraint)
 
virtual void drawImageLattice (const SkImage *, const SkCanvas::Lattice &, const SkRect &dst, SkFilterMode, const SkPaint &)
 
virtual void drawVertices (const SkVertices *, sk_sp< SkBlender >, const SkPaint &, bool skipColorXform=false)=0
 
virtual void drawMesh (const SkMesh &mesh, sk_sp< SkBlender >, const SkPaint &)=0
 
virtual void drawShadow (const SkPath &, const SkDrawShadowRec &)
 
virtual void drawPatch (const SkPoint cubics[12], const SkColor colors[4], const SkPoint texCoords[4], sk_sp< SkBlender >, const SkPaint &paint)
 
virtual void drawAtlas (const SkRSXform[], const SkRect[], const SkColor[], int count, sk_sp< SkBlender >, const SkPaint &)
 
virtual void drawAnnotation (const SkRect &, const char[], SkData *)
 
virtual void drawEdgeAAQuad (const SkRect &rect, const SkPoint clip[4], SkCanvas::QuadAAFlags aaFlags, const SkColor4f &color, SkBlendMode mode)
 
virtual void drawEdgeAAImageSet (const SkCanvas::ImageSetEntry[], int count, const SkPoint dstClips[], const SkMatrix preViewMatrices[], const SkSamplingOptions &, const SkPaint &, SkCanvas::SrcRectConstraint)
 
virtual void drawDrawable (SkCanvas *, SkDrawable *, const SkMatrix *)
 
virtual sk_sp< SkSpecialImagesnapSpecial (const SkIRect &subset, bool forceCopy=false)
 
virtual sk_sp< SkSpecialImagesnapSpecialScaled (const SkIRect &subset, const SkISize &dstDims)
 
sk_sp< SkSpecialImagesnapSpecial ()
 
virtual void drawDevice (SkDevice *, const SkSamplingOptions &, const SkPaint &)
 
virtual void drawSpecial (SkSpecialImage *, const SkMatrix &localToDevice, const SkSamplingOptions &, const SkPaint &, SkCanvas::SrcRectConstraint constraint=SkCanvas::kStrict_SrcRectConstraint)
 
virtual void drawCoverageMask (const SkSpecialImage *, const SkMatrix &maskToDevice, const SkSamplingOptions &, const SkPaint &)
 
virtual bool drawBlurredRRect (const SkRRect &, const SkPaint &, float deviceSigma)
 
void drawFilteredImage (const skif::Mapping &mapping, SkSpecialImage *src, SkColorType ct, const SkImageFilter *, const SkSamplingOptions &, const SkPaint &)
 
- Public Member Functions inherited from SkRefCntBase
 SkRefCntBase ()
 
virtual ~SkRefCntBase ()
 
bool unique () const
 
void ref () const
 
void unref () const
 

Static Public Member Functions

static sk_sp< SkDeviceMake (const SkISize &size, std::unique_ptr< SkXMLWriter >, uint32_t flags)
 

Additional Inherited Members

- Protected Member Functions inherited from SkDevice
virtual sk_sp< SkSpecialImagemakeSpecial (const SkBitmap &)
 
virtual sk_sp< SkSpecialImagemakeSpecial (const SkImage *)
 
void setDeviceCoordinateSystem (const SkM44 &deviceToGlobal, const SkM44 &globalToDevice, const SkM44 &localToDevice, int bufferOriginX, int bufferOriginY)
 
void setOrigin (const SkM44 &globalCTM, int x, int y)
 
bool checkLocalToDeviceDirty ()
 

Detailed Description

Definition at line 45 of file SkSVGDevice.h.

Member Function Documentation

◆ drawAnnotation()

void SkSVGDevice::drawAnnotation ( const SkRect rect,
const char  key[],
SkData value 
)
overridevirtual

Reimplemented from SkDevice.

Definition at line 851 of file SkSVGDevice.cpp.

851 {
852 if (!value) {
853 return;
854 }
855
856 if (!strcmp(SkAnnotationKeys::URL_Key(), key) ||
858 this->cs().save();
859 this->cs().clipRect(rect, this->localToDevice(), SkClipOp::kIntersect, true);
860 SkRect transformedRect = this->cs().bounds(this->getGlobalBounds());
861 this->cs().restore();
862 if (transformedRect.isEmpty()) {
863 return;
864 }
865
866 SkString url(static_cast<const char*>(value->data()), value->size() - 1);
867 AutoElement a("a", fWriter);
868 a.addAttribute("xlink:href", url.c_str());
869 {
870 AutoElement r("rect", fWriter);
871 r.addAttribute("fill-opacity", "0.0");
872 r.addRectAttributes(transformedRect);
873 }
874 }
875}
static const char * Link_Named_Dest_Key()
static const char * URL_Key()
SkClipStack & cs()
void clipRect(const SkRect &, const SkMatrix &matrix, SkClipOp, bool doAA)
void restore()
SkRect bounds(const SkIRect &deviceBounds) const
const SkMatrix & localToDevice() const
Definition: SkDevice.h:179
SkIRect getGlobalBounds() const
Definition: SkDevice.h:230
struct MyStruct a[10]
uint8_t value
bool isEmpty() const
Definition: SkRect.h:693

◆ drawImageRect()

void SkSVGDevice::drawImageRect ( const SkImage image,
const SkRect src,
const SkRect dst,
const SkSamplingOptions sampling,
const SkPaint paint,
SkCanvas::SrcRectConstraint  constraint 
)
overridevirtual

Implements SkDevice.

Definition at line 1024 of file SkSVGDevice.cpp.

1026 {
1027 SkBitmap bm;
1028 // TODO: support gpu images
1029 if (!as_IB(image)->getROPixels(nullptr, &bm)) {
1030 return;
1031 }
1032
1033 SkClipStack* cs = &this->cs();
1034 SkClipStack::AutoRestore ar(cs, false);
1035 if (src && *src != SkRect::Make(bm.bounds())) {
1036 cs->save();
1038 }
1039
1040 SkMatrix adjustedMatrix = this->localToDevice()
1041 * SkMatrix::RectToRect(src ? *src : SkRect::Make(bm.bounds()), dst);
1042
1043 drawBitmapCommon(MxCp(&adjustedMatrix, cs), bm, paint);
1044}
static SkImage_Base * as_IB(SkImage *image)
Definition: SkImage_Base.h:201
SkIRect bounds() const
Definition: SkBitmap.h:382
static SkMatrix RectToRect(const SkRect &src, const SkRect &dst, ScaleToFit mode=kFill_ScaleToFit)
Definition: SkMatrix.h:157
bool isAntiAlias() const
Definition: SkPaint.h:162
const Paint & paint
Definition: color_source.cc:38
sk_sp< const SkImage > image
Definition: SkRecords.h:269
dst
Definition: cp.py:12
static SkRect Make(const SkISize &size)
Definition: SkRect.h:669

◆ drawMesh()

void SkSVGDevice::drawMesh ( const SkMesh ,
sk_sp< SkBlender ,
const SkPaint  
)
overridevirtual

Implements SkDevice.

Definition at line 1170 of file SkSVGDevice.cpp.

1170 {
1171 // todo
1172}

◆ drawOval()

void SkSVGDevice::drawOval ( const SkRect oval,
const SkPaint paint 
)
overridevirtual

Implements SkDevice.

Definition at line 927 of file SkSVGDevice.cpp.

927 {
928 if (paint.getPathEffect()) {
929 this->drawPath(SkPath::Oval(oval), paint, true);
930 return;
931 }
932
933 AutoElement ellipse("ellipse", this, fResourceBucket.get(), MxCp(this), paint);
934 ellipse.addAttribute("cx", oval.centerX());
935 ellipse.addAttribute("cy", oval.centerY());
936 ellipse.addAttribute("rx", oval.width() / 2);
937 ellipse.addAttribute("ry", oval.height() / 2);
938}
static SkPath Oval(const SkRect &, SkPathDirection=SkPathDirection::kCW)
Definition: SkPath.cpp:3590
void drawPath(const SkPath &path, const SkPaint &paint, bool pathIsMutable=false) override
SkRect oval
Definition: SkRecords.h:249
constexpr float centerX() const
Definition: SkRect.h:776
constexpr float height() const
Definition: SkRect.h:769
constexpr float centerY() const
Definition: SkRect.h:785
constexpr float width() const
Definition: SkRect.h:762

◆ drawPaint()

void SkSVGDevice::drawPaint ( const SkPaint paint)
overridevirtual

Implements SkDevice.

Definition at line 845 of file SkSVGDevice.cpp.

845 {
846 AutoElement rect("rect", this, fResourceBucket.get(), MxCp(this), paint);
847 rect.addRectAttributes(SkRect::MakeWH(SkIntToScalar(this->width()),
848 SkIntToScalar(this->height())));
849}
#define SkIntToScalar(x)
Definition: SkScalar.h:57
int height() const
Definition: SkDevice.h:120
int width() const
Definition: SkDevice.h:119
sk_sp< SkBlender > blender SkRect rect
Definition: SkRecords.h:350
static constexpr SkRect MakeWH(float w, float h)
Definition: SkRect.h:609

◆ drawPath()

void SkSVGDevice::drawPath ( const SkPath path,
const SkPaint paint,
bool  pathIsMutable = false 
)
overridevirtual

If pathIsMutable, then the implementation is allowed to cast path to a non-const pointer and modify it in place (as an optimization). Canvas may do this to implement helpers such as drawOval, by placing a temp path on the stack to hold the representation of the oval.

Implements SkDevice.

Definition at line 950 of file SkSVGDevice.cpp.

950 {
951 if (path.isInverseFillType()) {
952 SkDebugf("Inverse path fill type not yet implemented.");
953 return;
954 }
955
956 SkPath pathStorage;
957 SkPath* pathPtr = const_cast<SkPath*>(&path);
959
960 // Apply path effect from paint to path.
961 if (path_paint->getPathEffect()) {
962 if (!pathIsMutable) {
963 pathPtr = &pathStorage;
964 }
965 bool fill = skpathutils::FillPathWithPaint(path, *path_paint, pathPtr);
966 if (fill) {
967 // Path should be filled.
968 path_paint.writable()->setStyle(SkPaint::kFill_Style);
969 } else {
970 // Path should be drawn with a hairline (width == 0).
971 path_paint.writable()->setStyle(SkPaint::kStroke_Style);
972 path_paint.writable()->setStrokeWidth(0);
973 }
974
975 path_paint.writable()->setPathEffect(nullptr); // path effect processed
976 }
977
978 // Create path element.
979 AutoElement elem("path", this, fResourceBucket.get(), MxCp(this), *path_paint);
980 elem.addPathAttributes(*pathPtr, this->pathEncoding());
981
982 // TODO: inverse fill types?
983 if (pathPtr->getFillType() == SkPathFillType::kEvenOdd) {
984 elem.addAttribute("fill-rule", "evenodd");
985 }
986}
void SK_SPI SkDebugf(const char format[],...) SK_PRINTF_LIKE(1
@ kStroke_Style
set to stroke geometry
Definition: SkPaint.h:194
@ kFill_Style
set to fill geometry
Definition: SkPaint.h:193
Definition: SkPath.h:59
SkPathFillType getFillType() const
Definition: SkPath.h:230
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
SK_API bool FillPathWithPaint(const SkPath &src, const SkPaint &paint, SkPath *dst, const SkRect *cullRect, SkScalar resScale=1)
Definition: SkPathUtils.cpp:23

◆ drawPoints()

void SkSVGDevice::drawPoints ( SkCanvas::PointMode  mode,
size_t  count,
const SkPoint  pts[],
const SkPaint paint 
)
overridevirtual

Implements SkDevice.

Definition at line 877 of file SkSVGDevice.cpp.

878 {
880
881 switch (mode) {
882 // todo
884 // TODO?
885 break;
887 count -= 1;
888 for (size_t i = 0; i < count; i += 2) {
889 path.moveTo(pts[i]);
890 path.lineTo(pts[i+1]);
891 }
892 break;
894 if (count > 1) {
895 path.addPolygon(pts, SkToInt(count), false);
896 }
897 break;
898 }
899
900 this->drawPath(path.detach(), paint, true);
901}
int count
Definition: FontMgrTest.cpp:50
constexpr int SkToInt(S x)
Definition: SkTo.h:29
@ kLines_PointMode
draw each pair of points as a line segment
Definition: SkCanvas.h:1242
@ kPolygon_PointMode
draw the array of points as a open polygon
Definition: SkCanvas.h:1243
@ kPoints_PointMode
draw each point separately
Definition: SkCanvas.h:1241
it will be possible to load the file into Perfetto s trace viewer disable asset Prevents usage of any non test fonts unless they were explicitly Loaded via prefetched default font Indicates whether the embedding started a prefetch of the default font manager before creating the engine run In non interactive mode
Definition: switches.h:228

◆ drawRect()

void SkSVGDevice::drawRect ( const SkRect r,
const SkPaint paint 
)
overridevirtual

Implements SkDevice.

Definition at line 903 of file SkSVGDevice.cpp.

903 {
904 if (paint.getPathEffect()) {
905 this->drawPath(SkPath::Rect(r), paint, true);
906 return;
907 }
908
909 std::unique_ptr<AutoElement> svg;
910 if (RequiresViewportReset(paint)) {
911 svg = std::make_unique<AutoElement>("svg", this, fResourceBucket.get(), MxCp(this), paint);
912 svg->addRectAttributes(r);
913 }
914
915 AutoElement rect("rect", this, fResourceBucket.get(), MxCp(this), paint);
916
917 if (svg) {
918 rect.addAttribute("x", 0);
919 rect.addAttribute("y", 0);
920 rect.addAttribute("width", "100%");
921 rect.addAttribute("height", "100%");
922 } else {
923 rect.addRectAttributes(r);
924 }
925}
static SkPath Rect(const SkRect &, SkPathDirection=SkPathDirection::kCW, unsigned startIndex=0)
Definition: SkPath.cpp:3586
const char * svg

◆ drawRRect()

void SkSVGDevice::drawRRect ( const SkRRect rr,
const SkPaint paint 
)
overridevirtual

Implements SkDevice.

Definition at line 940 of file SkSVGDevice.cpp.

940 {
941 if (paint.getPathEffect()) {
942 this->drawPath(SkPath::RRect(rr), paint, true);
943 return;
944 }
945
946 AutoElement elem("path", this, fResourceBucket.get(), MxCp(this), paint);
947 elem.addPathAttributes(SkPath::RRect(rr), this->pathEncoding());
948}
static SkPath RRect(const SkRRect &, SkPathDirection dir=SkPathDirection::kCW)
Definition: SkPath.cpp:3602

◆ drawVertices()

void SkSVGDevice::drawVertices ( const SkVertices ,
sk_sp< SkBlender ,
const SkPaint ,
bool  skipColorXform 
)
overridevirtual

If skipColorXform is true, then the implementation should assume that the provided vertex colors are already in the destination color space.

Implements SkDevice.

Definition at line 1166 of file SkSVGDevice.cpp.

1166 {
1167 // todo
1168}

◆ Make()

sk_sp< SkDevice > SkSVGDevice::Make ( const SkISize size,
std::unique_ptr< SkXMLWriter writer,
uint32_t  flags 
)
static

Definition at line 729 of file SkSVGDevice.cpp.

731 {
732 return writer ? sk_sp<SkDevice>(new SkSVGDevice(size, std::move(writer), flags))
733 : nullptr;
734}
SkISize size() const
Definition: SkDevice.h:126
FlutterSemanticsFlag flags

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