Renamed DSL Ternary to Select

Change-Id: Idd0d49d3564dc3a24455db3c504ffa124f34dd05
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/371336
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
Commit-Queue: John Stiles <johnstiles@google.com>
Auto-Submit: Ethan Nicholas <ethannicholas@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
Reviewed-by: John Stiles <johnstiles@google.com>
This commit is contained in:
Ethan Nicholas 2021-02-17 12:13:20 -05:00 committed by Skia Commit-Bot
parent b41a1f9025
commit fa648a1be3
3 changed files with 21 additions and 21 deletions

View File

@ -155,7 +155,7 @@ public:
return DSLWriter::IRGenerator().convertSwizzle(base.release(), mask);
}
static DSLExpression Ternary(DSLExpression test, DSLExpression ifTrue, DSLExpression ifFalse) {
static DSLExpression Select(DSLExpression test, DSLExpression ifTrue, DSLExpression ifFalse) {
return DSLWriter::IRGenerator().convertTernaryExpression(test.release(), ifTrue.release(),
ifFalse.release());
}
@ -206,8 +206,8 @@ DSLStatement Return(DSLExpression expr) {
return DSLCore::Return(std::move(expr));
}
DSLExpression Ternary(DSLExpression test, DSLExpression ifTrue, DSLExpression ifFalse) {
return DSLCore::Ternary(std::move(test), std::move(ifTrue), std::move(ifFalse));
DSLExpression Select(DSLExpression test, DSLExpression ifTrue, DSLExpression ifFalse) {
return DSLCore::Select(std::move(test), std::move(ifTrue), std::move(ifFalse));
}
DSLStatement While(DSLExpression test, DSLStatement stmt) {

View File

@ -125,7 +125,7 @@ DSLStatement Switch(DSLExpression value, Cases... cases) {
/**
* test ? ifTrue : ifFalse
*/
DSLExpression Ternary(DSLExpression test, DSLExpression ifTrue, DSLExpression ifFalse);
DSLExpression Select(DSLExpression test, DSLExpression ifTrue, DSLExpression ifFalse);
/**
* while (test) stmt;

View File

@ -1091,6 +1091,23 @@ DEF_GPUTEST_FOR_MOCK_CONTEXT(DSLReturn, r, ctxInfo) {
REPORTER_ASSERT(r, whitespace_insensitive_compare(y, "return true;"));
}
DEF_GPUTEST_FOR_MOCK_CONTEXT(DSLSelect, r, ctxInfo) {
AutoDSLContext context(ctxInfo.directContext()->priv().getGpu());
Var a(kInt, "a");
Expression x = Select(a > 0, 1, -1);
REPORTER_ASSERT(r, x.release()->description() == "((a > 0) ? 1 : -1)");
{
ExpectError error(r, "error: expected 'bool', but found 'int'\n");
Select(a, 1, -1).release();
}
{
ExpectError error(r, "error: ternary operator result mismatch: 'float2', 'float3'\n");
Select(a > 0, Float2(1), Float3(1)).release();
}
}
DEF_GPUTEST_FOR_MOCK_CONTEXT(DSLSwitch, r, ctxInfo) {
AutoDSLContext context(ctxInfo.directContext()->priv().getGpu());
@ -1179,23 +1196,6 @@ DEF_GPUTEST_FOR_MOCK_CONTEXT(DSLSwizzle, r, ctxInfo) {
REPORTER_ASSERT(r, e13.release()->description() == "float4(a.xyz, float(1)).x");
}
DEF_GPUTEST_FOR_MOCK_CONTEXT(DSLTernary, r, ctxInfo) {
AutoDSLContext context(ctxInfo.directContext()->priv().getGpu());
Var a(kInt, "a");
Expression x = Ternary(a > 0, 1, -1);
REPORTER_ASSERT(r, x.release()->description() == "((a > 0) ? 1 : -1)");
{
ExpectError error(r, "error: expected 'bool', but found 'int'\n");
Ternary(a, 1, -1).release();
}
{
ExpectError error(r, "error: ternary operator result mismatch: 'float2', 'float3'\n");
Ternary(a > 0, Float2(1), Float3(1)).release();
}
}
DEF_GPUTEST_FOR_MOCK_CONTEXT(DSLWhile, r, ctxInfo) {
AutoDSLContext context(ctxInfo.directContext()->priv().getGpu());
Statement x = While(true, Block());