diff --git a/src/gpu/GrRenderTargetContext.cpp b/src/gpu/GrRenderTargetContext.cpp index 60a3b030ab..3da23c2950 100644 --- a/src/gpu/GrRenderTargetContext.cpp +++ b/src/gpu/GrRenderTargetContext.cpp @@ -830,7 +830,7 @@ void GrRenderTargetContext::drawTexture(const GrClip& clip, sk_sp texXform) { ASSERT_SINGLE_OWNER @@ -838,7 +838,7 @@ void GrRenderTargetContext::drawTextureSet(const GrClip& clip, const TextureSetE SkDEBUGCODE(this->validate();) GR_CREATE_TRACE_MARKER_CONTEXT("GrRenderTargetContext", "drawTextureSet", fContext); GrAAType aaType = this->chooseAAType(GrAA::kYes, GrAllowMixedSamples::kNo); - auto op = GrTextureOp::Make(fContext, set, cnt, filter, color, aaType, viewMatrix, + auto op = GrTextureOp::Make(fContext, set, cnt, filter, alpha, aaType, viewMatrix, std::move(texXform)); this->addDrawOp(clip, std::move(op)); } diff --git a/src/gpu/GrRenderTargetContext.h b/src/gpu/GrRenderTargetContext.h index da34c124bc..df2ea2986e 100644 --- a/src/gpu/GrRenderTargetContext.h +++ b/src/gpu/GrRenderTargetContext.h @@ -150,8 +150,7 @@ public: * texture color xform. The textures must all have the same GrTextureType and GrConfig. */ void drawTextureSet(const GrClip&, const TextureSetEntry[], int cnt, GrSamplerState::Filter, - const SkPMColor4f&, const SkMatrix& viewMatrix, - sk_sp texXform); + float alpha, const SkMatrix& viewMatrix, sk_sp texXform); /** * Draw a roundrect using a paint. diff --git a/src/gpu/SkGpuDevice.cpp b/src/gpu/SkGpuDevice.cpp index 8e88dfd4e3..e36b0ce449 100644 --- a/src/gpu/SkGpuDevice.cpp +++ b/src/gpu/SkGpuDevice.cpp @@ -1466,7 +1466,6 @@ void SkGpuDevice::drawImageSet(const SkCanvas::ImageSetEntry set[], int count, f sampler.setFilterMode(kNone_SkFilterQuality == filterQuality ? GrSamplerState::Filter::kNearest : GrSamplerState::Filter::kBilerp); SkAutoTArray textures(count); - SkPMColor4f color = { alpha, alpha, alpha, alpha }; // We accumulate compatible proxies until we find an an incompatible one or reach the end and // issue the accumulated 'n' draws starting at 'base'. int base = 0, n = 0; @@ -1476,7 +1475,7 @@ void SkGpuDevice::drawImageSet(const SkCanvas::ImageSetEntry set[], int count, f set[base].fImage->colorSpace(), set[base].fImage->alphaType(), fRenderTargetContext->colorSpaceInfo().colorSpace(), kPremul_SkAlphaType); fRenderTargetContext->drawTextureSet(this->clip(), textures.get() + base, n, - sampler.filter(), color, this->ctm(), + sampler.filter(), alpha, this->ctm(), std::move(textureXform)); } }; diff --git a/src/gpu/ops/GrTextureOp.cpp b/src/gpu/ops/GrTextureOp.cpp index 4255d2cf26..953b9bf963 100644 --- a/src/gpu/ops/GrTextureOp.cpp +++ b/src/gpu/ops/GrTextureOp.cpp @@ -215,15 +215,14 @@ public: } static std::unique_ptr Make(GrContext* context, const GrRenderTargetContext::TextureSetEntry set[], - int cnt, GrSamplerState::Filter filter, - const SkPMColor4f& color, GrAAType aaType, - const SkMatrix& viewMatrix, + int cnt, GrSamplerState::Filter filter, float alpha, + GrAAType aaType, const SkMatrix& viewMatrix, sk_sp textureColorSpaceXform) { size_t size = sizeof(TextureOp) + sizeof(Proxy) * (cnt - 1); GrOpMemoryPool* pool = context->contextPriv().opMemoryPool(); void* mem = pool->allocate(size); return std::unique_ptr(new (mem) TextureOp( - set, cnt, filter, color, aaType, viewMatrix, std::move(textureColorSpaceXform))); + set, cnt, filter, alpha, aaType, viewMatrix, std::move(textureColorSpaceXform))); } ~TextureOp() override { @@ -339,12 +338,13 @@ private: static_cast(fProxies[0].fProxy->canSkipResourceAllocator()); } TextureOp(const GrRenderTargetContext::TextureSetEntry set[], int cnt, - GrSamplerState::Filter filter, const SkPMColor4f& color, GrAAType aaType, + GrSamplerState::Filter filter, float alpha, GrAAType aaType, const SkMatrix& viewMatrix, sk_sp textureColorSpaceXform) : INHERITED(ClassID()) , fTextureColorSpaceXform(std::move(textureColorSpaceXform)) , fFilter(static_cast(filter)) , fFinalized(0) { + alpha = SkTPin(alpha, 0.f, 1.f); fQuads.reserve(cnt); fProxyCnt = SkToUInt(cnt); SkRect bounds = SkRectPriv::MakeLargestInverted(); @@ -376,6 +376,7 @@ private: mustFilter = quadType != GrQuadType::kRect || filter_has_effect_for_rect_stays_rect(quad, set[p].fSrcRect); } + SkPMColor4f color{alpha, alpha, alpha, alpha}; fQuads.emplace_back(set[p].fSrcRect, quad, aaFlags, SkCanvas::kFast_SrcRectConstraint, color); } @@ -386,11 +387,11 @@ private: this->setBounds(bounds, HasAABloat(this->aaType() == GrAAType::kCoverage), IsZeroArea::kNo); fPerspective = static_cast(viewMatrix.hasPerspective()); fDomain = static_cast(false); - fWideColor = !SkPMColor4fFitsInBytes(color); + fWideColor = static_cast(false); } - void tess(void* v, const VertexSpec& spec, const GrTextureProxy* proxy, - int start, int cnt) const { + void tess(void* v, const VertexSpec& spec, const GrTextureProxy* proxy, int start, + int cnt) const { TRACE_EVENT0("skia", TRACE_FUNC); auto origin = proxy->origin(); const auto* texture = proxy->peekTexture(); @@ -642,11 +643,11 @@ std::unique_ptr Make(GrContext* context, const GrRenderTargetContext::TextureSetEntry set[], int cnt, GrSamplerState::Filter filter, - const SkPMColor4f& color, + float alpha, GrAAType aaType, const SkMatrix& viewMatrix, sk_sp textureColorSpaceXform) { - return TextureOp::Make(context, set, cnt, filter, color, aaType, viewMatrix, + return TextureOp::Make(context, set, cnt, filter, alpha, aaType, viewMatrix, std::move(textureColorSpaceXform)); } diff --git a/src/gpu/ops/GrTextureOp.h b/src/gpu/ops/GrTextureOp.h index 69cb2a7e09..50192c1abc 100644 --- a/src/gpu/ops/GrTextureOp.h +++ b/src/gpu/ops/GrTextureOp.h @@ -43,7 +43,7 @@ std::unique_ptr Make(GrContext*, const GrRenderTargetContext::TextureSetEntry[], int cnt, GrSamplerState::Filter, - const SkPMColor4f&, + float alpha, GrAAType, const SkMatrix& viewMatrix, sk_sp textureXform);