40class SoftwarePathData {
44 : fMaskBounds(maskBounds)
49 const SkIRect& getMaskBounds()
const {
return fMaskBounds; }
52 GrAA getAA()
const {
return fAA; }
68 matrix.mapRect(&shapeDevBounds, shapeBounds);
73 static constexpr int32_t
kMaxInt = 2147483520;
105 "MakeDeferredMaskTextureView");
118 if (!
args.fShape->style().applies() &&
SkToBool(fProxyProvider) &&
134 SkIRect* unclippedDevShapeBounds,
135 SkIRect* clippedDevShapeBounds,
138 *devClipBounds =
clip ?
clip->getConservativeBounds()
146 if (!clippedDevShapeBounds->
intersect(*devClipBounds, *unclippedDevShapeBounds)) {
163 viewMatrix,
rect, &localMatrix);
172 const SkIRect& devPathBounds) {
179 if (devClipBounds.
fTop < devPathBounds.
fTop) {
185 if (devClipBounds.
fLeft < devPathBounds.
fLeft) {
200 DrawNonAARect(sdc, std::move(
paint), userStencilSettings,
clip,
205void SoftwarePathRenderer::DrawToTargetWithShapeMask(
212 const SkIPoint& textureOriginInDeviceSpace,
213 const SkIRect& deviceSpaceRectToDraw) {
238bool SoftwarePathRenderer::onDrawPath(
const DrawPathArgs&
args) {
240 "SoftwarePathRenderer::onDrawPath");
242 if (!fProxyProvider) {
249 bool inverseFilled =
args.fShape->inverseFilled() &&
251 *
args.fViewMatrix,
nullptr);
253 SkIRect unclippedDevShapeBounds, clippedDevShapeBounds, devClipBounds;
256 bool useCache = fAllowCaching && !inverseFilled &&
args.fViewMatrix->preservesAxisAlignment() &&
261 *
args.fViewMatrix, &unclippedDevShapeBounds,
262 &clippedDevShapeBounds,
265 DrawAroundInvPath(
args.fSurfaceDrawContext, std::move(
args.fPaint),
266 *
args.fUserStencilSettings,
args.fClip, *
args.fViewMatrix,
267 devClipBounds, unclippedDevShapeBounds);
272 const SkIRect* boundsForMask = &clippedDevShapeBounds;
275 int unclippedWidth = unclippedDevShapeBounds.
width();
276 int unclippedHeight = unclippedDevShapeBounds.
height();
277 int64_t unclippedArea =
sk_64_mul(unclippedWidth, unclippedHeight);
279 clippedDevShapeBounds.
height());
280 int maxTextureSize =
args.fSurfaceDrawContext->caps()->maxTextureSize();
281 if (unclippedArea > 2 * clippedArea || unclippedWidth > maxTextureSize ||
282 unclippedHeight > maxTextureSize) {
285 boundsForMask = &unclippedDevShapeBounds;
302#ifdef SK_BUILD_FOR_ANDROID_FRAMEWORK
323 uint32_t styleBits =
args.fShape->style().isSimpleHairline() ?
324 ((
args.fShape->style().strokeRec().getCap() << 1) | 1) : 0;
325 builder[6] = fracX | (fracY >> 8) | (styleBits << 16);
336 args.fContext->priv().stats()->incNumPathMasksCacheHits();
344 if (
auto direct =
args.fContext->asDirectContext()) {
345 taskGroup = direct->priv().getTaskGroup();
349 view = make_deferred_mask_texture_view(
args.fContext, fit, boundsForMask->
size());
354 auto uploader = std::make_unique<GrTDeferredProxyUploader<SoftwarePathData>>(
355 *boundsForMask, *
args.fViewMatrix, *
args.fShape, aa);
358 auto drawAndUploadMask = [uploaderRaw] {
361 if (helper.init(uploaderRaw->data().getMaskBounds())) {
362 helper.drawShape(uploaderRaw->data().getShape(),
363 *uploaderRaw->data().getViewMatrix(),
364 uploaderRaw->data().getAA(), 0xFF);
368 uploaderRaw->signalAndFreeData();
370 taskGroup->
add(std::move(drawAndUploadMask));
374 if (!helper.
init(*boundsForMask)) {
390 args.fContext->priv().contextID());
392 args.fShape->addGenIDChangeListener(std::move(listener));
395 args.fContext->priv().stats()->incNumPathMasksGenerated();
400 *
args.fUserStencilSettings,
args.fClip, *
args.fViewMatrix, devClipBounds,
401 unclippedDevShapeBounds);
403 DrawToTargetWithShapeMask(std::move(view),
args.fSurfaceDrawContext, std::move(
args.fPaint),
404 *
args.fUserStencilSettings,
args.fClip, *
args.fViewMatrix,
405 SkIPoint{boundsForMask->fLeft, boundsForMask->fTop}, *boundsForMask);
#define GR_AUDIT_TRAIL_AUTO_FRAME(audit_trail, framename)
@ kTopLeft_GrSurfaceOrigin
bool GrIsStrokeHairlineOrEquivalent(const GrStyle &style, const SkMatrix &matrix, SkScalar *outCoverage)
@ kPremul_SkAlphaType
pixel components are premultiplied by alpha
#define SkDEBUGFAIL(message)
#define SkScalarToFixed(x)
static uint32_t SkFloat2Bits(float value)
sk_sp< SkIDChangeListener > GrMakeUniqueKeyInvalidationListener(skgpu::UniqueKey *key, uint32_t contextID)
static int64_t sk_64_mul(int64_t a, int64_t b)
static SkPath clip(const SkPath &path, const SkHalfPlane &plane)
#define SkScalarRoundToInt(x)
static SkScalar SkScalarFraction(SkScalar x)
static constexpr bool SkToBool(const T &x)
const GrCaps * caps() const
GrBackendFormat getDefaultBackendFormat(GrColorType, GrRenderable) const
skgpu::Swizzle getReadSwizzle(const GrBackendFormat &format, GrColorType colorType) const
static GrPaint Clone(const GrPaint &src)
sk_sp< GrTextureProxy > createProxy(const GrBackendFormat &, SkISize dimensions, GrRenderable, int renderTargetSampleCnt, skgpu::Mipmapped, SkBackingFit, skgpu::Budgeted, GrProtected, std::string_view label, GrInternalSurfaceFlags=GrInternalSurfaceFlags::kNone, UseAllocator useAllocator=UseAllocator::kYes)
bool assignUniqueKeyToProxy(const skgpu::UniqueKey &, GrTextureProxy *)
sk_sp< GrTextureProxy > findOrCreateProxyByUniqueKey(const skgpu::UniqueKey &, UseAllocator=UseAllocator::kYes)
GrProxyProvider * proxyProvider()
GrRecordingContextPriv priv()
void drawShape(const GrStyledShape &, const SkMatrix &matrix, GrAA, uint8_t alpha)
bool init(const SkIRect &resultBounds)
GrSurfaceProxyView toTextureView(GrRecordingContext *, SkBackingFit fit)
SkRect styledBounds() const
void concatSwizzle(skgpu::Swizzle swizzle)
GrTextureProxy * asTextureProxy() const
GrSurfaceOrigin origin() const
const GrBackendFormat & backendFormat() const
static std::unique_ptr< GrFragmentProcessor > Make(GrSurfaceProxyView, SkAlphaType, const SkMatrix &=SkMatrix::I(), GrSamplerState::Filter=GrSamplerState::Filter::kNearest, GrSamplerState::MipmapMode mipmapMode=GrSamplerState::MipmapMode::kNone)
void setDeferredUploader(std::unique_ptr< GrDeferredProxyUploader >)
GrTextureProxyPriv texPriv()
static constexpr int kMScaleX
horizontal scale factor
static constexpr int kMTransY
vertical translation
static SkMatrix Translate(SkScalar dx, SkScalar dy)
bool invert(SkMatrix *inverse) const
static const SkMatrix & I()
SkMatrix & preConcat(const SkMatrix &other)
static constexpr int kMTransX
horizontal translation
static constexpr int kMSkewY
vertical skew factor
static constexpr int kMScaleY
vertical scale factor
static constexpr int kMSkewX
horizontal skew factor
void add(std::function< void(void)> fn)
static Domain GenerateDomain()
static bool GetShapeAndClipBounds(SurfaceDrawContext *, const GrClip *, const GrStyledShape &, const SkMatrix &viewMatrix, SkIRect *unclippedDevShapeBounds, SkIRect *clippedDevShapeBounds, SkIRect *devClipBounds)
void stencilRect(const GrClip *clip, const GrUserStencilSettings *ss, GrPaint &&paint, GrAA doStencilMSAA, const SkMatrix &viewMatrix, const SkRect &rect, const SkMatrix *localMatrix=nullptr)
G_BEGIN_DECLS G_MODULE_EXPORT FlValue * args
uint32_t uint32_t * format
static bool get_unclipped_shape_dev_bounds(const GrStyledShape &shape, const SkMatrix &matrix, SkIRect *devBounds)
unsigned useCenter Optional< SkMatrix > matrix
sk_sp< SkBlender > blender SkRect rect
bool intersect(const SkIRect &r)
int32_t fBottom
larger y-axis bounds
constexpr SkISize size() const
constexpr int32_t height() const
int32_t fTop
smaller y-axis bounds
static constexpr SkIRect MakeEmpty()
constexpr int32_t width() const
static constexpr SkIRect MakeWH(int32_t w, int32_t h)
int32_t fLeft
smaller x-axis bounds
int32_t fRight
larger x-axis bounds
static SkRect Make(const SkISize &size)
bool intersect(const SkRect &r)
void roundOut(SkIRect *dst) const
constexpr float height() const
constexpr float width() const
static constexpr SkRect MakeLTRB(float l, float t, float r, float b)
#define TRACE_EVENT0(category_group, name)