40inline bool use_shader(
bool textureIsAlphaOnly,
const SkPaint&
paint) {
41 return textureIsAlphaOnly &&
paint.getShader();
47static const SkScalar kColorBleedTolerance = 0.001f;
49bool has_aligned_samples(
const SkRect& srcRect,
const SkRect& transformedRect) {
60bool may_color_bleed(
const SkRect& srcRect,
61 const SkRect& transformedRect,
66 SkASSERT(!has_aligned_samples(srcRect, transformedRect));
67 SkRect innerSrcRect(srcRect), innerTransformedRect, outerTransformedRect(transformedRect);
73 m.mapRect(&innerTransformedRect, innerSrcRect);
79 outerTransformedRect.inset(kColorBleedTolerance, kColorBleedTolerance);
80 innerTransformedRect.
outset(kColorBleedTolerance, kColorBleedTolerance);
82 outerTransformedRect.round(&outer);
83 innerTransformedRect.
round(&inner);
86 return inner != outer;
89bool can_ignore_linear_filtering_subset(
const SkRect& srcSubset,
90 const SkMatrix& srcRectToDeviceSpace,
95 srcRectToDeviceSpace.
mapRect(&transformedRect, srcSubset);
97 if (has_aligned_samples(srcSubset, transformedRect) ||
98 !may_color_bleed(srcSubset, transformedRect, srcRectToDeviceSpace, numSamples)) {
113 return (!
paint.getColorFilter() && !
paint.getShader() && !
paint.getMaskFilter() &&
120 paintColor.fA *= entryAlpha;
124 float paintAlpha =
SkTPin(paintColor.fA, 0.f, 1.f);
125 return { paintAlpha, paintAlpha, paintAlpha, paintAlpha };
157 if (!safeBounds.
contains(srcRect)) {
181 std::move(textureXform));
195 std::move(textureXform));
228 const GrClip* clip = this->clip();
285 if (can_ignore_linear_filtering_subset(
src, combinedMatrix, sdc->
numSamples())) {
286 restrictToSubset =
false;
291 if (canUseTextureCoordsAsLocalCoords) {
294 if (!srcToDst.
invert(&textureMatrix)) {
298 const SkRect* subset = restrictToSubset ? &
src :
nullptr;
299 const SkRect* domain = coordsAllInsideSrcRect ? &
src :
nullptr;
302 rContext,
image,
sampling, tileModes, textureMatrix, subset, domain);
306 if (
const auto* shader =
as_SB(
paint.getShader())) {
316 fp = GrBlendFragmentProcessor::Make<SkBlendMode::kDstIn>(std::move(
fp),
317 std::move(shaderFP));
340 if (canUseTextureCoordsAsLocalCoords) {
343 srcClip = srcClipPoints;
350 canUseTextureCoordsAsLocalCoords ? &
src :
nullptr);
360 path.addPoly(dstClip, 4,
true);
367 rContext, sdc, clip, shape, std::move(grPaint),
localToDevice, mf);
384 GrAA aa = fSurfaceDrawContext->chooseAA(
paint);
437 srcRect, dstRect, dstClip,
482 int dstClipIndex = 0;
489 if (
set[
i].fAlpha != 1.f) {
490 auto paintAlpha =
paint.getAlphaf();
491 entryPaint.
writable()->setAlphaf(paintAlpha *
set[
i].fAlpha);
493 this->drawImageQuadDirect(
499 dstClipIndex += 4 *
set[
i].fHasClip;
513 int base = 0, n = 0,
p = 0;
514 auto draw = [&](
int nextBase) {
517 fSurfaceDrawContext->colorInfo());
518 fSurfaceDrawContext->drawTextureSet(this->clip(),
526 this->localToDevice(),
527 std::move(textureXform));
533 int dstClipIndex = 0;
541 dstClipIndex += 4 *
set[
i].fHasClip;
545 if (!
set[
i].fSrcRect.isSorted()) {
554 if (!
image->isYUVA()) {
555 std::tie(view, std::ignore) =
569 if (
set[
i].fAlpha != 1.f) {
570 auto paintAlpha =
paint.getAlphaf();
571 entryPaint.
writable()->setAlphaf(paintAlpha *
set[
i].fAlpha);
573 this->drawImageQuadDirect(
581 textures[
i].fProxyView = std::move(view);
583 textures[
i].fSrcRect =
set[
i].fSrcRect;
584 textures[
i].fDstRect =
set[
i].fDstRect;
585 textures[
i].fDstClipQuad = clip;
586 textures[
i].fPreViewMatrix =
588 textures[
i].fColor = texture_color(
paint.getColor4f(),
set[
i].fAlpha,
590 fSurfaceDrawContext->colorInfo());
595 textures[
i].fProxyView.proxy(),
596 textures[
base].fProxyView.proxy()) ||
597 textures[
i].fProxyView.swizzle() != textures[
base].fProxyView.swizzle() ||
598 set[
i].fImage->alphaType() !=
set[
base].fImage->alphaType() ||
605 if (n == 1 || textures[
i - 1].fProxyView.proxy() != textures[
i].fProxyView.proxy()) {
static void info(const char *fmt,...) SK_PRINTF_LIKE(1
static void GrMapRectPoints(const SkRect &inRect, const SkRect &outRect, const SkPoint inPts[], SkPoint outPts[], int ptCount)
static GrQuadAAFlags SkToGrQuadAAFlags(unsigned flags)
static constexpr bool GrColorTypeIsAlphaOnly(GrColorType ct)
static constexpr GrColorType SkColorTypeToGrColorType(SkColorType ct)
@ kSrcOver
r = s + (1-sa)*d
bool SkPaintToGrPaintReplaceShader(GrRecordingContext *context, const GrColorInfo &dstColorInfo, const SkPaint &skPaint, const SkMatrix &ctm, std::unique_ptr< GrFragmentProcessor > shaderFP, const SkSurfaceProps &surfaceProps, GrPaint *grPaint)
SkColor4f SkColor4fPrepForDst(SkColor4f color, const GrColorInfo &colorInfo)
static SkImage_Base * as_IB(SkImage *image)
static SkPath clip(const SkPath &path, const SkHalfPlane &plane)
sk_sp< T > sk_ref_sp(T *obj)
#define SkScalarRoundToScalar(x)
SkShaderBase * as_SB(SkShader *shader)
static constexpr const T & SkTPin(const T &x, const T &lo, const T &hi)
static void draw(SkCanvas *canvas, SkRect &target, int x, int y)
GrColorType colorType() const
SkAlphaType alphaType() const
static std::unique_ptr< GrFragmentProcessor > MulInputByChildAlpha(std::unique_ptr< GrFragmentProcessor > child)
skgpu::Swizzle swizzle() const
void concatSwizzle(skgpu::Swizzle swizzle)
sk_sp< GrSurfaceProxy > detachProxy()
GrSurfaceOrigin origin() const
GrSurfaceProxy * proxy() const
GrSurfaceProxyPriv priv()
SkRect getBoundsRect() const
bool isFunctionallyExact() const
static constexpr float kLinearInset
static bool ProxiesAreCompatibleAsDynamicState(const GrSurfaceProxy *first, const GrSurfaceProxy *second)
@ kStrict_SrcRectConstraint
sample only inside bounds; slower
@ kFast_SrcRectConstraint
sample outside bounds; faster
static bool Equals(const SkColorSpace *, const SkColorSpace *)
const SkMatrix & localToDevice() const
const SkImageInfo & imageInfo() const
SkAlphaType alphaType() const
SkColorType colorType() const
static SkMatrix RectToRect(const SkRect &src, const SkRect &dst, ScaleToFit mode=kFill_ScaleToFit)
bool invert(SkMatrix *inverse) const
bool rectStaysRect() const
static const SkMatrix & I()
SkMatrix & preConcat(const SkMatrix &other)
bool mapRect(SkRect *dst, const SkRect &src, SkApplyPerspectiveClip pc=SkApplyPerspectiveClip::kYes) const
SkMatrix & setConcat(const SkMatrix &a, const SkMatrix &b)
virtual GrRecordingContext * getContext() const
virtual bool isGaneshBacked() const
uint32_t uniqueID() const
const SkIRect & subset() const
const SkColorInfo & colorInfo() const
static constexpr Swizzle Concat(const Swizzle &a, const Swizzle &b)
static ImageDrawMode OptimizeSampleArea(const SkISize &imageSize, const SkRect &origSrcRect, const SkRect &origDstRect, const SkPoint dstClip[4], SkRect *outSrcRect, SkRect *outDstRect, SkMatrix *outSrcToDst)
static bool CanDisableMipmap(const SkMatrix &viewM, const SkMatrix &localM)
void drawEdgeAAImageSet(const SkCanvas::ImageSetEntry[], int count, const SkPoint dstClips[], const SkMatrix preViewMatrices[], const SkSamplingOptions &, const SkPaint &, SkCanvas::SrcRectConstraint) override
void drawSpecial(SkSpecialImage *, const SkMatrix &localToDevice, const SkSamplingOptions &, const SkPaint &, SkCanvas::SrcRectConstraint) override
void drawEdgeAAImage(const SkImage *, const SkRect &src, const SkRect &dst, const SkPoint dstClip[4], SkCanvas::QuadAAFlags, const SkMatrix &localToDevice, const SkSamplingOptions &, const SkPaint &, SkCanvas::SrcRectConstraint, const SkMatrix &srcToDst, SkTileMode)
GrRecordingContext * recordingContext() const override
const GrColorInfo & colorInfo() const
void fillQuadWithEdgeAA(const GrClip *clip, GrPaint &&paint, GrQuadAAFlags edgeAA, const SkMatrix &viewMatrix, const SkPoint points[4], const SkPoint optionalLocalPoints[4])
void fillRectWithEdgeAA(const GrClip *clip, GrPaint &&paint, GrQuadAAFlags edgeAA, const SkMatrix &viewMatrix, const SkRect &rect, const SkRect *optionalLocalRect=nullptr)
void drawTextureQuad(const GrClip *clip, GrSurfaceProxyView view, GrColorType srcColorType, SkAlphaType srcAlphaType, GrSamplerState::Filter filter, GrSamplerState::MipmapMode mm, SkBlendMode mode, const SkPMColor4f &color, const SkPoint srcQuad[4], const SkPoint dstQuad[4], GrQuadAAFlags edgeAA, const SkRect *subset, const SkMatrix &viewMatrix, sk_sp< GrColorSpaceXform > texXform)
const SkSurfaceProps & surfaceProps() const
void drawTexture(const GrClip *, GrSurfaceProxyView, SkAlphaType, GrSamplerState::Filter, GrSamplerState::MipmapMode, SkBlendMode, const SkPMColor4f &, const SkRect &srcRect, const SkRect &dstRect, GrQuadAAFlags, SkCanvas::SrcRectConstraint, const SkMatrix &, sk_sp< GrColorSpaceXform >)
static void draw_texture(const GrCaps *caps, skgpu::ganesh::SurfaceDrawContext *sdc, const GrSurfaceProxyView &src, const SkIRect &srcRect, const SkIRect &drawRect, const SkMatrix &mat, GrSamplerState::WrapMode xTileMode, GrSamplerState::WrapMode yTileMode)
void DrawShapeWithMaskFilter(GrRecordingContext *rContext, skgpu::ganesh::SurfaceDrawContext *sdc, const GrClip *clip, const GrStyledShape &shape, GrPaint &&paint, const SkMatrix &viewMatrix, const SkMaskFilter *mf)
std::unique_ptr< GrFragmentProcessor > Make(const SkMaskFilter *maskfilter, const GrFPArgs &args, const SkMatrix &ctm)
bool IsSupported(const SkMaskFilter *maskfilter)
PODArray< SkPoint > dstClips
sk_sp< const SkImage > image
PODArray< SkMatrix > preViewMatrices
SkSamplingOptions sampling
GrSurfaceProxyView AsView(GrRecordingContext *context, const SkSpecialImage *img)
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
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
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
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
std::unique_ptr< GrFragmentProcessor > AsFragmentProcessor(GrRecordingContext *rContext, const SkImage *img, SkSamplingOptions sampling, const SkTileMode tileModes[2], const SkMatrix &m, const SkRect *subset, const SkRect *domain)
std::tuple< GrSurfaceProxyView, GrColorType > AsView(GrRecordingContext *rContext, const SkImage *img, skgpu::Mipmapped mipmapped, GrImageTexGenPolicy policy)
SkSamplingOptions(SkFilterMode::kLinear))
static constexpr SkISize Make(int32_t w, int32_t h)
const SkColorInfo & colorInfo() const
static SkRect Make(const SkISize &size)
constexpr float left() const
void inset(float dx, float dy)
constexpr float top() const
void outset(float dx, float dy)
bool contains(SkScalar x, SkScalar y) const
void round(SkIRect *dst) const
constexpr float height() const
constexpr float width() const
static constexpr SkRect MakeWH(float w, float h)
const SkFilterMode filter
const SkMipmapMode mipmap