32bool should_dither(
const PaintParams&
p,
SkColorType dstCT) {
58 : fColor(
paint.getColor4f())
59 , fFinalBlender(
paint.refBlender())
60 , fShader(
paint.refShader())
61 , fColorFilter(
paint.refColorFilter())
62 , fPrimitiveBlender(
std::move(primitiveBlender))
63 , fClipShader(
std::move(clipShader))
64 , fDstReadReq(dstReadReq)
65 , fSkipColorXform(skipColorXform)
66 , fDither(
paint.isDither()) {}
132 static_cast<int>(bm));
176 if (keyContext.
recorder() && !proxy) {
177 SKGPU_LOG_W(
"Couldn't create dither shader's LUT");
187void PaintParams::addPaintColorToKey(
const KeyContext& keyContext,
188 PaintParamsKeyBuilder* keyBuilder,
189 PipelineDataGatherer* gatherer)
const {
191 AddToKey(keyContext, keyBuilder, gatherer, fShader.
get());
202void PaintParams::handlePrimitiveColor(
const KeyContext& keyContext,
203 PaintParamsKeyBuilder* keyBuilder,
204 PipelineDataGatherer* gatherer)
const {
205 if (fPrimitiveBlender) {
206 Blend(keyContext, keyBuilder, gatherer,
208 AddToKey(keyContext, keyBuilder, gatherer, fPrimitiveBlender.
get());
211 this->addPaintColorToKey(keyContext, keyBuilder, gatherer);
217 this->addPaintColorToKey(keyContext, keyBuilder, gatherer);
222void PaintParams::handlePaintAlpha(
const KeyContext& keyContext,
223 PaintParamsKeyBuilder* keyBuilder,
224 PipelineDataGatherer* gatherer)
const {
226 if (!fShader && !fPrimitiveBlender) {
230 keyContext.dstColorInfo()).premul();
235 if (fColor.fA != 1.0f) {
236 Blend(keyContext, keyBuilder, gatherer,
241 this->handlePrimitiveColor(keyContext, keyBuilder, gatherer);
247 this->handlePrimitiveColor(keyContext, keyBuilder, gatherer);
251void PaintParams::handleColorFilter(
const KeyContext& keyContext,
252 PaintParamsKeyBuilder*
builder,
253 PipelineDataGatherer* gatherer)
const {
257 this->handlePaintAlpha(keyContext,
builder, gatherer);
263 this->handlePaintAlpha(keyContext,
builder, gatherer);
267void PaintParams::handleDithering(
const KeyContext& keyContext,
268 PaintParamsKeyBuilder*
builder,
269 PipelineDataGatherer* gatherer)
const {
271#ifndef SK_IGNORE_GPU_DITHER
272 SkColorType ct = keyContext.dstColorInfo().colorType();
273 if (should_dither(*
this, ct)) {
276 this->handleColorFilter(keyContext,
builder, gatherer);
284 this->handleColorFilter(keyContext,
builder, gatherer);
288void PaintParams::handleDstRead(
const KeyContext& keyContext,
289 PaintParamsKeyBuilder*
builder,
290 PipelineDataGatherer* gatherer)
const {
301 this->handleDithering(keyContext,
builder, gatherer);
307 this->handleDithering(keyContext,
builder, gatherer);
314 this->handleDstRead(keyContext,
builder, gatherer);
335 builder->addBlock(fixedFuncBlendModeID);
344 if (fPrimitiveBlender) {
#define SKGPU_LOG_W(fmt,...)
@ kLastCoeffMode
last porter duff blend mode
@ kSrcOver
r = s + (1-sa)*d
SkBlenderBase * as_BB(SkBlender *blend)
SkColorSpace * sk_srgb_singleton()
@ kARGB_4444_SkColorType
pixel with 4 bits for alpha, red, green, blue; in 16-bit word
@ kRGB_565_SkColorType
pixel with 5 bits red, 6 bits green, 5 bits blue, in 16-bit word
@ kUnknown_SkColorType
uninitialized
SkShaderBase * as_SB(SkShader *shader)
virtual std::optional< SkBlendMode > asBlendMode() const
SkColorSpace * colorSpace() const
virtual bool isConstant() const
SkIPoint dstOffset() const
Recorder * recorder() const
sk_sp< TextureProxy > dstTexture() const
PaintParams & operator=(const PaintParams &)
sk_sp< SkBlender > refFinalBlender() const
sk_sp< SkBlender > refPrimitiveBlender() const
void toKey(const KeyContext &, PaintParamsKeyBuilder *, PipelineDataGatherer *) const
PaintParams(const SkPaint &, sk_sp< SkBlender > primitiveBlender, sk_sp< SkShader > clipShader, DstReadRequirement dstReadReq, bool skipColorXform)
std::optional< SkBlendMode > asFinalBlendMode() const
static SkColor4f Color4fPrepForDst(SkColor4f srgb, const SkColorInfo &dstColorInfo)
sk_sp< SkColorFilter > refColorFilter() const
void notifyImagesInUse(Recorder *, DrawContext *) const
sk_sp< SkShader > refShader() const
static sk_sp< TextureProxy > CreateCachedProxy(Recorder *, const SkBitmap &, std::string_view label)
static constexpr int kFixedFunctionBlendModeIDOffset
void AddToKey(const KeyContext &keyContext, PaintParamsKeyBuilder *builder, PipelineDataGatherer *gatherer, const SkBlender *blender)
std::function< void()> AddToKeyFn
void AddKnownModeBlend(const KeyContext &keyContext, PaintParamsKeyBuilder *builder, PipelineDataGatherer *gatherer, SkBlendMode bm)
void Compose(const KeyContext &keyContext, PaintParamsKeyBuilder *keyBuilder, PipelineDataGatherer *gatherer, AddToKeyFn addInnerToKey, AddToKeyFn addOuterToKey)
void AddDitherBlock(const KeyContext &keyContext, PaintParamsKeyBuilder *builder, PipelineDataGatherer *gatherer, SkColorType ct)
void AddDstReadBlock(const KeyContext &keyContext, PaintParamsKeyBuilder *builder, PipelineDataGatherer *gatherer, DstReadRequirement dstReadReq)
void Blend(const KeyContext &keyContext, PaintParamsKeyBuilder *keyBuilder, PipelineDataGatherer *gatherer, AddToKeyFn addBlendToKey, AddToKeyFn addSrcToKey, AddToKeyFn addDstToKey)
void AddModeBlend(const KeyContext &keyContext, PaintParamsKeyBuilder *builder, PipelineDataGatherer *gatherer, SkBlendMode bm)
void NotifyImagesInUse(Recorder *recorder, DrawContext *drawContext, const SkBlender *blender)
float DitherRangeForConfig(SkColorType dstColorType)
SkSpan< const float > GetPorterDuffBlendConstants(SkBlendMode mode)
static void AddBlock(const KeyContext &, PaintParamsKeyBuilder *, PipelineDataGatherer *)
static void AddBlock(const KeyContext &, PaintParamsKeyBuilder *, PipelineDataGatherer *, SkBlendMode)
static void BeginBlock(const KeyContext &, PaintParamsKeyBuilder *, PipelineDataGatherer *)
static void BeginBlock(const KeyContext &, PaintParamsKeyBuilder *, PipelineDataGatherer *)
static void AddBlock(const KeyContext &, PaintParamsKeyBuilder *, PipelineDataGatherer *, SkSpan< const float > coeffs)
static void BeginBlock(const KeyContext &, PaintParamsKeyBuilder *, PipelineDataGatherer *)
static void AddBlock(const KeyContext &, PaintParamsKeyBuilder *, PipelineDataGatherer *, const DitherData &)
static void AddBlock(const KeyContext &, PaintParamsKeyBuilder *, PipelineDataGatherer *, sk_sp< TextureProxy > dst, SkIPoint dstOffset)
static void AddBlock(const KeyContext &, PaintParamsKeyBuilder *, PipelineDataGatherer *)
static void AddBlock(const KeyContext &, PaintParamsKeyBuilder *, PipelineDataGatherer *, const SkPMColor4f &)
std::shared_ptr< const fml::Mapping > data