simplify GrFPArgs, isolating localmatrix

Bug: skia:
Change-Id: Icee24e0a355a7d1bae29b7721b4d95db8023ca77
Reviewed-on: https://skia-review.googlesource.com/97063
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Mike Reed <reed@google.com>
This commit is contained in:
Mike Reed 2018-01-19 15:42:28 -05:00 committed by Skia Commit-Bot
parent ad6660a639
commit b76c717025
6 changed files with 21 additions and 15 deletions

View File

@ -303,6 +303,7 @@ SkMaskFilter::filterRectsToNine(const SkRect[], int count, const SkMatrix&,
#if SK_SUPPORT_GPU
std::unique_ptr<GrFragmentProcessor> SkMaskFilter::asFragmentProcessor(const GrFPArgs& args) const {
SkASSERT(args.fLocalMatrix == nullptr);
auto fp = this->onAsFragmentProcessor(args);
if (fp) {
SkASSERT(this->hasFragmentProcessor());

View File

@ -15,7 +15,6 @@ class GrContext;
class GrColorSpaceInfo;
struct GrFPArgs {
GrFPArgs() {}
GrFPArgs(GrContext* context,
const SkMatrix* viewMatrix,
const SkMatrix* localMatrix,
@ -27,6 +26,16 @@ struct GrFPArgs {
, fFilterQuality(filterQuality)
, fDstColorSpaceInfo(dstColorSpaceInfo) {}
GrFPArgs(GrContext* context,
const SkMatrix* viewMatrix,
SkFilterQuality filterQuality,
const GrColorSpaceInfo* dstColorSpaceInfo)
: fContext(context)
, fViewMatrix(viewMatrix)
, fLocalMatrix(nullptr)
, fFilterQuality(filterQuality)
, fDstColorSpaceInfo(dstColorSpaceInfo) {}
GrContext* fContext;
const SkMatrix* fViewMatrix;
const SkMatrix* fLocalMatrix;

View File

@ -334,17 +334,13 @@ sk_sp<GrColorSpaceXform> TestColorXform(SkRandom* random) {
return gXforms[random->nextULessThan(static_cast<uint32_t>(SK_ARRAY_COUNT(gXforms)))];
}
TestAsFPArgs::TestAsFPArgs(GrProcessorTestData* d) {
fViewMatrixStorage = TestMatrix(d->fRandom);
fColorSpaceInfoStorage = skstd::make_unique<GrColorSpaceInfo>(TestColorSpace(d->fRandom),
kRGBA_8888_GrPixelConfig);
fArgs.fContext = d->context();
fArgs.fViewMatrix = &fViewMatrixStorage;
fArgs.fLocalMatrix = nullptr;
fArgs.fFilterQuality = kNone_SkFilterQuality;
fArgs.fDstColorSpaceInfo = fColorSpaceInfoStorage.get();
}
TestAsFPArgs::TestAsFPArgs(GrProcessorTestData* d)
: fViewMatrixStorage(TestMatrix(d->fRandom))
, fColorSpaceInfoStorage(skstd::make_unique<GrColorSpaceInfo>(TestColorSpace(d->fRandom),
kRGBA_8888_GrPixelConfig))
, fArgs(d->context(), &fViewMatrixStorage, nullptr, kNone_SkFilterQuality,
fColorSpaceInfoStorage.get())
{}
TestAsFPArgs::~TestAsFPArgs() {}

View File

@ -58,9 +58,9 @@ public:
const GrFPArgs& args() const { return fArgs; }
private:
GrFPArgs fArgs;
SkMatrix fViewMatrixStorage;
std::unique_ptr<GrColorSpaceInfo> fColorSpaceInfoStorage;
GrFPArgs fArgs;
};
// We have a simplified dash path effect here to avoid relying on SkDashPathEffect which

View File

@ -375,7 +375,7 @@ static inline bool skpaint_to_grpaint_impl(GrContext* context,
// Convert SkPaint color to 4f format, including optional linearizing and gamut conversion.
GrColor4f origColor = SkColorToUnpremulGrColor4f(skPaint.getColor(), colorSpaceInfo);
const GrFPArgs fpArgs(context, &viewM, nullptr, skPaint.getFilterQuality(), &colorSpaceInfo);
const GrFPArgs fpArgs(context, &viewM, skPaint.getFilterQuality(), &colorSpaceInfo);
// Setup the initial color considering the shader, the SkPaint color, and the presence or not
// of per-vertex colors.

View File

@ -369,7 +369,7 @@ std::unique_ptr<GrFragmentProcessor> SkPictureShader::asFragmentProcessor(
return nullptr;
}
return as_SB(bitmapShader)
->asFragmentProcessor(GrFPArgs(args.fContext, args.fViewMatrix, nullptr,
->asFragmentProcessor(GrFPArgs(args.fContext, args.fViewMatrix,
args.fFilterQuality, args.fDstColorSpaceInfo));
}
#endif