Remove coverage-as-alpha flag from GrAlphaThresholdFP
Don't sort thresholds and allow full 0..1 range Change-Id: I228be036bb259bea53ac9885e758c9e46ced1d62 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/296717 Commit-Queue: Brian Salomon <bsalomon@google.com> Auto-Submit: Brian Salomon <bsalomon@google.com> Reviewed-by: Brian Osman <brianosman@google.com> Reviewed-by: John Stiles <johnstiles@google.com>
This commit is contained in:
parent
ca72cad601
commit
4569f66309
@ -12,8 +12,7 @@ in uniform half outerThreshold;
|
|||||||
|
|
||||||
@optimizationFlags {
|
@optimizationFlags {
|
||||||
(inputFP ? ProcessorOptimizationFlags(inputFP.get()) : kAll_OptimizationFlags) &
|
(inputFP ? ProcessorOptimizationFlags(inputFP.get()) : kAll_OptimizationFlags) &
|
||||||
(kCompatibleWithCoverageAsAlpha_OptimizationFlag |
|
((outerThreshold >= 1.0) ? kPreservesOpaqueInput_OptimizationFlag : kNone_OptimizationFlags)
|
||||||
((outerThreshold >= 1.0) ? kPreservesOpaqueInput_OptimizationFlag : kNone_OptimizationFlags))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
@ -34,10 +33,9 @@ void main() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@test(testData) {
|
@test(testData) {
|
||||||
auto [maskView, ct, at] = testData->randomAlphaOnlyView();
|
// Make the inner and outer thresholds be in [0, 1].
|
||||||
// Make the inner and outer thresholds be in (0, 1) exclusive and be sorted correctly.
|
float outerThresh = testData->fRandom->nextUScalar1();
|
||||||
float innerThresh = testData->fRandom->nextUScalar1() * .99f + 0.005f;
|
float innerThresh = testData->fRandom->nextUScalar1();
|
||||||
float outerThresh = testData->fRandom->nextUScalar1() * .99f + 0.005f;
|
|
||||||
std::unique_ptr<GrFragmentProcessor> inputChild, maskChild;
|
std::unique_ptr<GrFragmentProcessor> inputChild, maskChild;
|
||||||
if (testData->fRandom->nextBool()) {
|
if (testData->fRandom->nextBool()) {
|
||||||
inputChild = GrProcessorUnitTest::MakeChildFP(testData);
|
inputChild = GrProcessorUnitTest::MakeChildFP(testData);
|
||||||
|
@ -32,23 +32,23 @@ public:
|
|||||||
kHalf_GrSLType, "innerThreshold");
|
kHalf_GrSLType, "innerThreshold");
|
||||||
outerThresholdVar = args.fUniformHandler->addUniform(&_outer, kFragment_GrShaderFlag,
|
outerThresholdVar = args.fUniformHandler->addUniform(&_outer, kFragment_GrShaderFlag,
|
||||||
kHalf_GrSLType, "outerThreshold");
|
kHalf_GrSLType, "outerThreshold");
|
||||||
SkString _input572 = SkStringPrintf("%s", args.fInputColor);
|
SkString _input515 = SkStringPrintf("%s", args.fInputColor);
|
||||||
SkString _sample572;
|
SkString _sample515;
|
||||||
if (_outer.inputFP_index >= 0) {
|
if (_outer.inputFP_index >= 0) {
|
||||||
_sample572 = this->invokeChild(_outer.inputFP_index, _input572.c_str(), args);
|
_sample515 = this->invokeChild(_outer.inputFP_index, _input515.c_str(), args);
|
||||||
} else {
|
} else {
|
||||||
_sample572 = _input572;
|
_sample515 = _input515;
|
||||||
}
|
}
|
||||||
fragBuilder->codeAppendf("half4 color = %s;", _sample572.c_str());
|
fragBuilder->codeAppendf("half4 color = %s;", _sample515.c_str());
|
||||||
SkString _sample624;
|
SkString _sample567;
|
||||||
_sample624 = this->invokeChild(_outer.maskFP_index, args);
|
_sample567 = this->invokeChild(_outer.maskFP_index, args);
|
||||||
fragBuilder->codeAppendf(
|
fragBuilder->codeAppendf(
|
||||||
"\nhalf4 mask_color = %s;\nif (mask_color.w < 0.5) {\n if (color.w > %s) {\n "
|
"\nhalf4 mask_color = %s;\nif (mask_color.w < 0.5) {\n if (color.w > %s) {\n "
|
||||||
" half scale = %s / color.w;\n color.xyz *= scale;\n color.w = "
|
" half scale = %s / color.w;\n color.xyz *= scale;\n color.w = "
|
||||||
"%s;\n }\n} else if (color.w < %s) {\n half scale = %s / "
|
"%s;\n }\n} else if (color.w < %s) {\n half scale = %s / "
|
||||||
"max(0.0010000000474974513, color.w);\n color.xyz *= scale;\n color.w = "
|
"max(0.0010000000474974513, color.w);\n color.xyz *= scale;\n color.w = "
|
||||||
"%s;\n}\n%s = color;\n",
|
"%s;\n}\n%s = color;\n",
|
||||||
_sample624.c_str(), args.fUniformHandler->getUniformCStr(outerThresholdVar),
|
_sample567.c_str(), args.fUniformHandler->getUniformCStr(outerThresholdVar),
|
||||||
args.fUniformHandler->getUniformCStr(outerThresholdVar),
|
args.fUniformHandler->getUniformCStr(outerThresholdVar),
|
||||||
args.fUniformHandler->getUniformCStr(outerThresholdVar),
|
args.fUniformHandler->getUniformCStr(outerThresholdVar),
|
||||||
args.fUniformHandler->getUniformCStr(innerThresholdVar),
|
args.fUniformHandler->getUniformCStr(innerThresholdVar),
|
||||||
@ -98,10 +98,9 @@ GR_DEFINE_FRAGMENT_PROCESSOR_TEST(GrAlphaThresholdFragmentProcessor);
|
|||||||
#if GR_TEST_UTILS
|
#if GR_TEST_UTILS
|
||||||
std::unique_ptr<GrFragmentProcessor> GrAlphaThresholdFragmentProcessor::TestCreate(
|
std::unique_ptr<GrFragmentProcessor> GrAlphaThresholdFragmentProcessor::TestCreate(
|
||||||
GrProcessorTestData* testData) {
|
GrProcessorTestData* testData) {
|
||||||
auto[maskView, ct, at] = testData->randomAlphaOnlyView();
|
// Make the inner and outer thresholds be in [0, 1].
|
||||||
// Make the inner and outer thresholds be in (0, 1) exclusive and be sorted correctly.
|
float outerThresh = testData->fRandom->nextUScalar1();
|
||||||
float innerThresh = testData->fRandom->nextUScalar1() * .99f + 0.005f;
|
float innerThresh = testData->fRandom->nextUScalar1();
|
||||||
float outerThresh = testData->fRandom->nextUScalar1() * .99f + 0.005f;
|
|
||||||
std::unique_ptr<GrFragmentProcessor> inputChild, maskChild;
|
std::unique_ptr<GrFragmentProcessor> inputChild, maskChild;
|
||||||
if (testData->fRandom->nextBool()) {
|
if (testData->fRandom->nextBool()) {
|
||||||
inputChild = GrProcessorUnitTest::MakeChildFP(testData);
|
inputChild = GrProcessorUnitTest::MakeChildFP(testData);
|
||||||
|
@ -42,9 +42,8 @@ private:
|
|||||||
: INHERITED(kGrAlphaThresholdFragmentProcessor_ClassID,
|
: INHERITED(kGrAlphaThresholdFragmentProcessor_ClassID,
|
||||||
(OptimizationFlags)(inputFP ? ProcessorOptimizationFlags(inputFP.get())
|
(OptimizationFlags)(inputFP ? ProcessorOptimizationFlags(inputFP.get())
|
||||||
: kAll_OptimizationFlags) &
|
: kAll_OptimizationFlags) &
|
||||||
(kCompatibleWithCoverageAsAlpha_OptimizationFlag |
|
|
||||||
((outerThreshold >= 1.0) ? kPreservesOpaqueInput_OptimizationFlag
|
((outerThreshold >= 1.0) ? kPreservesOpaqueInput_OptimizationFlag
|
||||||
: kNone_OptimizationFlags)))
|
: kNone_OptimizationFlags))
|
||||||
, innerThreshold(innerThreshold)
|
, innerThreshold(innerThreshold)
|
||||||
, outerThreshold(outerThreshold) {
|
, outerThreshold(outerThreshold) {
|
||||||
if (inputFP) {
|
if (inputFP) {
|
||||||
|
Loading…
Reference in New Issue
Block a user