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

#include <SkCanvasPriv.h>

Static Public Member Functions

static bool ReadLattice (SkReadBuffer &, SkCanvas::Lattice *)
 
static void WriteLattice (SkWriteBuffer &, const SkCanvas::Lattice &)
 
static size_t WriteLattice (void *storage, const SkCanvas::Lattice &)
 
static int SaveBehind (SkCanvas *canvas, const SkRect *subset)
 
static void DrawBehind (SkCanvas *canvas, const SkPaint &paint)
 
static void ResetClip (SkCanvas *canvas)
 
static SkDeviceTopDevice (const SkCanvas *canvas)
 
static void GetDstClipAndMatrixCounts (const SkCanvas::ImageSetEntry set[], int count, int *totalDstClipCount, int *totalMatrixCount)
 
static SkCanvas::SaveLayerRec ScaledBackdropLayer (const SkRect *bounds, const SkPaint *paint, const SkImageFilter *backdrop, SkScalar backdropScale, SkCanvas::SaveLayerFlags saveLayerFlags, SkCanvas::FilterSpan filters={})
 
static SkScalar GetBackdropScaleFactor (const SkCanvas::SaveLayerRec &rec)
 
static void SetBackdropScaleFactor (SkCanvas::SaveLayerRec *rec, SkScalar scale)
 
static bool ImageToColorFilter (SkPaint *)
 

Detailed Description

Definition at line 42 of file SkCanvasPriv.h.

Member Function Documentation

◆ DrawBehind()

static void SkCanvasPriv::DrawBehind ( SkCanvas canvas,
const SkPaint paint 
)
inlinestatic

Definition at line 56 of file SkCanvasPriv.h.

56 {
57 canvas->drawClippedToSaveBehind(paint);
58 }
const Paint & paint
Definition: color_source.cc:38

◆ GetBackdropScaleFactor()

static SkScalar SkCanvasPriv::GetBackdropScaleFactor ( const SkCanvas::SaveLayerRec rec)
inlinestatic

Definition at line 85 of file SkCanvasPriv.h.

85 {
86 return rec.fExperimentalBackdropScale;
87 }

◆ GetDstClipAndMatrixCounts()

void SkCanvasPriv::GetDstClipAndMatrixCounts ( const SkCanvas::ImageSetEntry  set[],
int  count,
int totalDstClipCount,
int totalMatrixCount 
)
static

Definition at line 103 of file SkCanvasPriv.cpp.

104 {
105 int dstClipCount = 0;
106 int maxMatrixIndex = -1;
107 for (int i = 0; i < count; ++i) {
108 dstClipCount += 4 * set[i].fHasClip;
109 if (set[i].fMatrixIndex > maxMatrixIndex) {
110 maxMatrixIndex = set[i].fMatrixIndex;
111 }
112 }
113
114 *totalDstClipCount = dstClipCount;
115 *totalMatrixCount = maxMatrixIndex + 1;
116}
int count
Definition: FontMgrTest.cpp:50
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 set
Definition: switches.h:76

◆ ImageToColorFilter()

bool SkCanvasPriv::ImageToColorFilter ( SkPaint paint)
static

Definition at line 121 of file SkCanvasPriv.cpp.

121 {
122 SkASSERT(SkToBool(paint) && paint->getImageFilter());
123
124 // An image filter logically runs after any mask filter and the src-over blending against the
125 // layer's transparent black initial content. Moving the image filter (as a color filter) into
126 // the color filter slot causes it to run before the mask filter or blending.
127 //
128 // Src-over blending against transparent black is a no-op, so skipping the layer and drawing the
129 // output of the color filter-image filter with the original blender is valid.
130 //
131 // If there's also a mask filter on the paint, it will operate on an alpha-only layer that's
132 // then shaded with the paint's effects. Moving the CF-IF into the paint's color filter slot
133 // will mean that the CF-IF operates on the output of the original CF *before* it's combined
134 // with the coverage value. Under normal circumstances the CF-IF evaluates the color after
135 // coverage has been multiplied into the alpha channel.
136 //
137 // Some color filters may behave the same, e.g. cf(color)*coverage == cf(color*coverage), but
138 // that's hard to detect so we disable the optimization when both image filters and mask filters
139 // are present.
140 if (paint->getMaskFilter()) {
141 return false;
142 }
143
144 SkColorFilter* imgCFPtr;
145 if (!paint->getImageFilter()->asAColorFilter(&imgCFPtr)) {
146 return false;
147 }
148 sk_sp<SkColorFilter> imgCF(imgCFPtr);
149
150 SkColorFilter* paintCF = paint->getColorFilter();
151 if (paintCF) {
152 // The paint has both a colorfilter(paintCF) and an imagefilter-that-is-a-colorfilter(imgCF)
153 // and we need to combine them into a single colorfilter.
154 imgCF = imgCF->makeComposed(sk_ref_sp(paintCF));
155 }
156
157 paint->setColorFilter(std::move(imgCF));
158 paint->setImageFilter(nullptr);
159 return true;
160}
#define SkASSERT(cond)
Definition: SkAssert.h:116
sk_sp< T > sk_ref_sp(T *obj)
Definition: SkRefCnt.h:381
static constexpr bool SkToBool(const T &x)
Definition: SkTo.h:35

◆ ReadLattice()

bool SkCanvasPriv::ReadLattice ( SkReadBuffer buffer,
SkCanvas::Lattice lattice 
)
static

Definition at line 56 of file SkCanvasPriv.cpp.

56 {
57 lattice->fXCount = buffer.readInt();
58 lattice->fXDivs = buffer.skipT<int32_t>(lattice->fXCount);
59 lattice->fYCount = buffer.readInt();
60 lattice->fYDivs = buffer.skipT<int32_t>(lattice->fYCount);
61 int flagCount = buffer.readInt();
62 lattice->fRectTypes = nullptr;
63 lattice->fColors = nullptr;
64 if (flagCount) {
66 lattice->fColors = buffer.skipT<SkColor>(flagCount);
67 }
68 lattice->fBounds = buffer.skipT<SkIRect>();
69 return buffer.isValid();
70}
uint32_t SkColor
Definition: SkColor.h:37
int flagCount
Definition: SkRecords.h:274
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
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 SkColor * fColors
array of colors
Definition: SkCanvas.h:1619
const int * fXDivs
x-axis values dividing bitmap
Definition: SkCanvas.h:1613
Definition: SkRect.h:32

◆ ResetClip()

static void SkCanvasPriv::ResetClip ( SkCanvas canvas)
inlinestatic

Definition at line 61 of file SkCanvasPriv.h.

61 {
62 canvas->internal_private_resetClip();
63 }

◆ SaveBehind()

static int SkCanvasPriv::SaveBehind ( SkCanvas canvas,
const SkRect subset 
)
inlinestatic

Definition at line 53 of file SkCanvasPriv.h.

53 {
54 return canvas->only_axis_aligned_saveBehind(subset);
55 }

◆ ScaledBackdropLayer()

static SkCanvas::SaveLayerRec SkCanvasPriv::ScaledBackdropLayer ( const SkRect bounds,
const SkPaint paint,
const SkImageFilter backdrop,
SkScalar  backdropScale,
SkCanvas::SaveLayerFlags  saveLayerFlags,
SkCanvas::FilterSpan  filters = {} 
)
inlinestatic

Definition at line 75 of file SkCanvasPriv.h.

80 {}) {
82 bounds, paint, backdrop, nullptr, backdropScale, saveLayerFlags, filters);
83 }
SkCanvas::SaveLayerFlags saveLayerFlags
Definition: SkRecords.h:192
Optional< SkRect > bounds
Definition: SkRecords.h:189
SkScalar backdropScale
Definition: SkRecords.h:193
sk_sp< const SkImageFilter > backdrop
Definition: SkRecords.h:191

◆ SetBackdropScaleFactor()

static void SkCanvasPriv::SetBackdropScaleFactor ( SkCanvas::SaveLayerRec rec,
SkScalar  scale 
)
inlinestatic

Definition at line 89 of file SkCanvasPriv.h.

89 {
90 rec->fExperimentalBackdropScale = scale;
91 }
const Scalar scale

◆ TopDevice()

static SkDevice * SkCanvasPriv::TopDevice ( const SkCanvas canvas)
inlinestatic

Definition at line 65 of file SkCanvasPriv.h.

65 {
66 return canvas->topDevice();
67 }

◆ WriteLattice() [1/2]

void SkCanvasPriv::WriteLattice ( SkWriteBuffer buffer,
const SkCanvas::Lattice lattice 
)
static

Definition at line 96 of file SkCanvasPriv.cpp.

96 {
97 const size_t size = WriteLattice(nullptr, lattice);
99 WriteLattice(storage.get(), lattice);
100 buffer.writePad32(storage.get(), size);
101}
static void WriteLattice(SkWriteBuffer &, const SkCanvas::Lattice &)
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 keep the shell running after the Dart script has completed enable serial On low power devices with low core running concurrent GC tasks on threads can cause them to contend with the UI thread which could potentially lead to jank This option turns off all concurrent GC activities domain network JSON encoded network policy per domain This overrides the DisallowInsecureConnections switch Embedder can specify whether to allow or disallow insecure connections at a domain level old gen heap size
Definition: switches.h:259

◆ WriteLattice() [2/2]

size_t SkCanvasPriv::WriteLattice ( void *  storage,
const SkCanvas::Lattice lattice 
)
static

Definition at line 72 of file SkCanvasPriv.cpp.

72 {
73 int flagCount = lattice.fRectTypes ? (lattice.fXCount + 1) * (lattice.fYCount + 1) : 0;
74
75 const size_t size = (1 + lattice.fXCount + 1 + lattice.fYCount + 1) * sizeof(int32_t) +
77 SkAlign4(flagCount * sizeof(SkColor)) +
78 sizeof(SkIRect);
79
80 if (buffer) {
81 SkWriter32 writer(buffer, size);
82 writer.write32(lattice.fXCount);
83 writer.write(lattice.fXDivs, lattice.fXCount * sizeof(uint32_t));
84 writer.write32(lattice.fYCount);
85 writer.write(lattice.fYDivs, lattice.fYCount * sizeof(uint32_t));
86 writer.write32(flagCount);
87 writer.writePad(lattice.fRectTypes, flagCount * sizeof(uint8_t));
88 writer.write(lattice.fColors, flagCount * sizeof(SkColor));
89 SkASSERT(lattice.fBounds);
90 writer.write(lattice.fBounds, sizeof(SkIRect));
91 SkASSERT(writer.bytesWritten() == size);
92 }
93 return size;
94}
static constexpr T SkAlign4(T x)
Definition: SkAlign.h:16

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