Pass alpha rather than full colors to TextureOps made from image sets.

Bug: skia:8563

Change-Id: Iff1a5544df7f5dfeca3bfa14723ce39e653007eb
Reviewed-on: https://skia-review.googlesource.com/c/171903
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Brian Salomon <bsalomon@google.com>
This commit is contained in:
Brian Salomon 2018-11-19 16:57:25 -05:00 committed by Skia Commit-Bot
parent 8be4196e48
commit 574d6165e2
5 changed files with 16 additions and 17 deletions

View File

@ -830,7 +830,7 @@ void GrRenderTargetContext::drawTexture(const GrClip& clip, sk_sp<GrTextureProxy
}
void GrRenderTargetContext::drawTextureSet(const GrClip& clip, const TextureSetEntry set[], int cnt,
GrSamplerState::Filter filter, const SkPMColor4f& color,
GrSamplerState::Filter filter, float alpha,
const SkMatrix& viewMatrix,
sk_sp<GrColorSpaceXform> 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));
}

View File

@ -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<GrColorSpaceXform> texXform);
float alpha, const SkMatrix& viewMatrix, sk_sp<GrColorSpaceXform> texXform);
/**
* Draw a roundrect using a paint.

View File

@ -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<GrRenderTargetContext::TextureSetEntry> 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));
}
};

View File

@ -215,15 +215,14 @@ public:
}
static std::unique_ptr<GrDrawOp> 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<GrColorSpaceXform> textureColorSpaceXform) {
size_t size = sizeof(TextureOp) + sizeof(Proxy) * (cnt - 1);
GrOpMemoryPool* pool = context->contextPriv().opMemoryPool();
void* mem = pool->allocate(size);
return std::unique_ptr<GrDrawOp>(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<unsigned>(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<GrColorSpaceXform> textureColorSpaceXform)
: INHERITED(ClassID())
, fTextureColorSpaceXform(std::move(textureColorSpaceXform))
, fFilter(static_cast<unsigned>(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<unsigned>(viewMatrix.hasPerspective());
fDomain = static_cast<unsigned>(false);
fWideColor = !SkPMColor4fFitsInBytes(color);
fWideColor = static_cast<unsigned>(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<GrDrawOp> Make(GrContext* context,
const GrRenderTargetContext::TextureSetEntry set[],
int cnt,
GrSamplerState::Filter filter,
const SkPMColor4f& color,
float alpha,
GrAAType aaType,
const SkMatrix& viewMatrix,
sk_sp<GrColorSpaceXform> textureColorSpaceXform) {
return TextureOp::Make(context, set, cnt, filter, color, aaType, viewMatrix,
return TextureOp::Make(context, set, cnt, filter, alpha, aaType, viewMatrix,
std::move(textureColorSpaceXform));
}

View File

@ -43,7 +43,7 @@ std::unique_ptr<GrDrawOp> Make(GrContext*,
const GrRenderTargetContext::TextureSetEntry[],
int cnt,
GrSamplerState::Filter,
const SkPMColor4f&,
float alpha,
GrAAType,
const SkMatrix& viewMatrix,
sk_sp<GrColorSpaceXform> textureXform);