20#ifdef SK_ENABLE_VELLO_SHADERS
28constexpr uint16_t kComputeAtlasDim = 4096;
33 :
PathAtlas(recorder, kComputeAtlasDim, kComputeAtlasDim)
36bool ComputePathAtlas::initializeTextureIfNeeded() {
46 return fTexture !=
nullptr;
70 return (width *
height) <= (1024 * 512);
75 if (!this->initializeTextureIfNeeded()) {
76 SKGPU_LOG_E(
"Failed to instantiate an atlas texture");
85 return fTexture.get();
92 return fTexture.get();
101#ifdef SK_ENABLE_VELLO_SHADERS
110 std::unique_ptr<DispatchGroup> recordDispatches(
Recorder* recorder)
const override;
113 const TextureProxy* onAddShape(
const Shape&,
118 void onReset()
override {
120 fOccuppiedWidth = fOccuppiedHeight = 0;
127 uint32_t fOccuppiedWidth = 0;
128 uint32_t fOccuppiedHeight = 0;
131std::unique_ptr<DispatchGroup> VelloComputePathAtlas::recordDispatches(
Recorder* recorder)
const {
136 SkASSERT(recorder && recorder == fRecorder);
139#if defined(GRAPHITE_TEST_UTILS)
154const TextureProxy* VelloComputePathAtlas::onAddShape(
161 const TextureProxy* texProxy = this->addRect(maskSize, &iPos);
169 if (!
all(maskSize)) {
180 fOccuppiedWidth = std::max(fOccuppiedWidth, (uint32_t)atlasBounds.right() + kEntryPadding);
181 fOccuppiedHeight = std::max(fOccuppiedHeight, (uint32_t)atlasBounds.bot() + kEntryPadding);
202 SkPath devicePath = shape.asPath();
215 float deviceWidth =
width * atlasTransform.maxScaleFactor();
224 float transformedWidth = 1.0f / atlasTransform.maxScaleFactor();
226 adjustedStyle.setStrokeStyle(transformedWidth);
227 fScene.solidStroke(devicePath,
color, adjustedStyle, atlasTransform);
229 fScene.solidStroke(devicePath,
SkColors::kRed, style, atlasTransform);
233 fScene.solidFill(devicePath,
SkColors::kRed, shape.fillType(), atlasTransform);
236 fScene.popClipLayer();
244#ifdef SK_ENABLE_VELLO_SHADERS
245 return std::make_unique<VelloComputePathAtlas>(recorder);
#define SKGPU_LOG_E(fmt,...)
sk_sp< T > sk_ref_sp(T *obj)
static SkPath Rect(const SkRect &, SkPathDirection=SkPathDirection::kCW, unsigned startIndex=0)
bool isHairlineStyle() const
SkScalar getWidth() const
bool addPaddedRect(int width, int height, int16_t padding, SkIPoint16 *loc)
sk_sp< TextureProxy > getAtlasTexture(Recorder *, uint16_t width, uint16_t height, SkColorType, uint16_t identifier, bool requireStorageUsage)
bool isSuitableForAtlasing(const Rect &transformedShapeBounds) const override
ComputePathAtlas(Recorder *)
static std::unique_ptr< ComputePathAtlas > CreateDefault(Recorder *)
const TextureProxy * addRect(skvx::half2 maskSize, SkIPoint16 *outPos)
static constexpr int kEntryPadding
AtlasProvider * atlasProvider()
const Caps * caps() const
const RendererProvider * rendererProvider() const
static AI Rect XYWH(float x, float y, float w, float h)
AI Rect makeRoundOut() const
constexpr SkColor4f kBlack
clipRect(r.rect, r.opAA.op(), r.opAA.aa())) template<> void Draw
SkColorType ComputeShaderCoverageMaskTargetFormat(const Caps *caps)
skgpu::graphite::Transform Transform
SIT bool all(const Vec< 1, T > &x)
static SkColor4f transform(SkColor4f c, SkColorSpace *src, SkColorSpace *dst)