aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar Ethan Nicholas <ethannicholas@google.com>2017-03-30 18:42:48 +0000
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2017-03-30 18:42:59 +0000
commitbcf35f86d50b784b165de703b404998dd4299f6a (patch)
tree9fcd85326b1a5dbda864da9431a878bb62f65191
parent7833466da45bfa1e078427c4a6db94d41c5c1535 (diff)
Revert "skslc can now be compiled with no Skia dependencies, in preparation for"
This reverts commit 7833466da45bfa1e078427c4a6db94d41c5c1535. Reason for revert: Vulkan assertion failure Original change's description: > skslc can now be compiled with no Skia dependencies, in preparation for > its eventual role in Skia's build process. > > Bug: skia: > Change-Id: Iaa9933f4fc4a64bec60aa897c509a3513f457a78 > Reviewed-on: https://skia-review.googlesource.com/10282 > Commit-Queue: Ethan Nicholas <ethannicholas@google.com> > Reviewed-by: Ben Wagner <benjaminwagner@google.com> > TBR=egdaniel@google.com,benjaminwagner@google.com,ethannicholas@google.com,reviews@skia.org NOPRESUBMIT=true NOTREECHECKS=true NOTRY=true Change-Id: Ic64cac2395abb406116885ddd725f74a434c8c49 Reviewed-on: https://skia-review.googlesource.com/10758 Reviewed-by: Ethan Nicholas <ethannicholas@google.com> Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
-rw-r--r--BUILD.gn7
-rw-r--r--bench/GLBench.cpp2
-rw-r--r--fuzz/fuzz.cpp2
-rw-r--r--gn/sksl.gni1
-rw-r--r--src/gpu/gl/builders/GrGLShaderStringBuilder.cpp2
-rw-r--r--src/gpu/vk/GrVkUtil.cpp2
-rw-r--r--src/sksl/README8
-rw-r--r--src/sksl/SkSLCFGGenerator.cpp2
-rw-r--r--src/sksl/SkSLCFGGenerator.h2
-rw-r--r--src/sksl/SkSLCodeGenerator.h6
-rw-r--r--src/sksl/SkSLCompiler.cpp60
-rw-r--r--src/sksl/SkSLCompiler.h22
-rw-r--r--src/sksl/SkSLContext.h196
-rw-r--r--src/sksl/SkSLErrorReporter.h6
-rw-r--r--src/sksl/SkSLFileOutputStream.h75
-rw-r--r--src/sksl/SkSLGLSLCodeGenerator.cpp43
-rw-r--r--src/sksl/SkSLGLSLCodeGenerator.h13
-rw-r--r--src/sksl/SkSLIRGenerator.cpp34
-rw-r--r--src/sksl/SkSLIRGenerator.h8
-rw-r--r--src/sksl/SkSLMain.cpp20
-rw-r--r--src/sksl/SkSLMemoryLayout.h14
-rw-r--r--src/sksl/SkSLOutputStream.h36
-rw-r--r--src/sksl/SkSLParser.cpp36
-rw-r--r--src/sksl/SkSLParser.h18
-rw-r--r--src/sksl/SkSLPosition.h8
-rw-r--r--src/sksl/SkSLSPIRVCodeGenerator.cpp901
-rw-r--r--src/sksl/SkSLSPIRVCodeGenerator.h147
-rw-r--r--src/sksl/SkSLString.cpp173
-rw-r--r--src/sksl/SkSLString.h105
-rw-r--r--src/sksl/SkSLStringStream.h90
-rw-r--r--src/sksl/SkSLToken.h88
-rw-r--r--src/sksl/SkSLUtil.cpp107
-rw-r--r--src/sksl/SkSLUtil.h207
-rw-r--r--src/sksl/ast/SkSLASTBinaryExpression.h4
-rw-r--r--src/sksl/ast/SkSLASTBlock.h10
-rw-r--r--src/sksl/ast/SkSLASTBoolLiteral.h8
-rw-r--r--src/sksl/ast/SkSLASTBreakStatement.h8
-rw-r--r--src/sksl/ast/SkSLASTCallSuffix.h12
-rw-r--r--src/sksl/ast/SkSLASTContinueStatement.h8
-rw-r--r--src/sksl/ast/SkSLASTDeclaration.h4
-rw-r--r--src/sksl/ast/SkSLASTDiscardStatement.h8
-rw-r--r--src/sksl/ast/SkSLASTDoStatement.h6
-rw-r--r--src/sksl/ast/SkSLASTExpression.h4
-rw-r--r--src/sksl/ast/SkSLASTExpressionStatement.h6
-rw-r--r--src/sksl/ast/SkSLASTExtension.h12
-rw-r--r--src/sksl/ast/SkSLASTFieldSuffix.h8
-rw-r--r--src/sksl/ast/SkSLASTFloatLiteral.h6
-rw-r--r--src/sksl/ast/SkSLASTForStatement.h10
-rw-r--r--src/sksl/ast/SkSLASTFunction.h16
-rw-r--r--src/sksl/ast/SkSLASTIdentifier.h10
-rw-r--r--src/sksl/ast/SkSLASTIfStatement.h12
-rw-r--r--src/sksl/ast/SkSLASTIndexSuffix.h10
-rw-r--r--src/sksl/ast/SkSLASTIntLiteral.h4
-rw-r--r--src/sksl/ast/SkSLASTInterfaceBlock.h12
-rw-r--r--src/sksl/ast/SkSLASTModifiersDeclaration.h2
-rw-r--r--src/sksl/ast/SkSLASTNode.h8
-rw-r--r--src/sksl/ast/SkSLASTParameter.h8
-rw-r--r--src/sksl/ast/SkSLASTPositionNode.h2
-rw-r--r--src/sksl/ast/SkSLASTPrecision.h18
-rw-r--r--src/sksl/ast/SkSLASTPrefixExpression.h4
-rw-r--r--src/sksl/ast/SkSLASTReturnStatement.h8
-rw-r--r--src/sksl/ast/SkSLASTStatement.h2
-rw-r--r--src/sksl/ast/SkSLASTSuffix.h10
-rw-r--r--src/sksl/ast/SkSLASTSuffixExpression.h4
-rw-r--r--src/sksl/ast/SkSLASTSwitchCase.h4
-rw-r--r--src/sksl/ast/SkSLASTSwitchStatement.h4
-rw-r--r--src/sksl/ast/SkSLASTTernaryExpression.h6
-rw-r--r--src/sksl/ast/SkSLASTType.h8
-rw-r--r--src/sksl/ast/SkSLASTVarDeclaration.h14
-rw-r--r--src/sksl/ast/SkSLASTVarDeclarationStatement.h4
-rw-r--r--src/sksl/ast/SkSLASTWhileStatement.h6
-rw-r--r--src/sksl/ir/SkSLBinaryExpression.h2
-rw-r--r--src/sksl/ir/SkSLBlock.h4
-rw-r--r--src/sksl/ir/SkSLBoolLiteral.h6
-rw-r--r--src/sksl/ir/SkSLBreakStatement.h8
-rw-r--r--src/sksl/ir/SkSLConstructor.h6
-rw-r--r--src/sksl/ir/SkSLContinueStatement.h8
-rw-r--r--src/sksl/ir/SkSLDiscardStatement.h8
-rw-r--r--src/sksl/ir/SkSLDoStatement.h4
-rw-r--r--src/sksl/ir/SkSLExpressionStatement.h6
-rw-r--r--src/sksl/ir/SkSLExtension.h14
-rw-r--r--src/sksl/ir/SkSLField.h10
-rw-r--r--src/sksl/ir/SkSLFieldAccess.h6
-rw-r--r--src/sksl/ir/SkSLFloatLiteral.h4
-rw-r--r--src/sksl/ir/SkSLForStatement.h14
-rw-r--r--src/sksl/ir/SkSLFunctionCall.h8
-rw-r--r--src/sksl/ir/SkSLFunctionDeclaration.h12
-rw-r--r--src/sksl/ir/SkSLFunctionDefinition.h6
-rw-r--r--src/sksl/ir/SkSLFunctionReference.h10
-rw-r--r--src/sksl/ir/SkSLIRNode.h6
-rw-r--r--src/sksl/ir/SkSLIfStatement.h8
-rw-r--r--src/sksl/ir/SkSLIndexExpression.h6
-rw-r--r--src/sksl/ir/SkSLIntLiteral.h4
-rw-r--r--src/sksl/ir/SkSLInterfaceBlock.h12
-rw-r--r--src/sksl/ir/SkSLLayout.h11
-rw-r--r--src/sksl/ir/SkSLModifiers.h4
-rw-r--r--src/sksl/ir/SkSLModifiersDeclaration.h4
-rw-r--r--src/sksl/ir/SkSLPostfixExpression.h4
-rw-r--r--src/sksl/ir/SkSLPrefixExpression.h4
-rw-r--r--src/sksl/ir/SkSLProgram.h4
-rw-r--r--src/sksl/ir/SkSLProgramElement.h2
-rw-r--r--src/sksl/ir/SkSLReturnStatement.h8
-rw-r--r--src/sksl/ir/SkSLStatement.h2
-rw-r--r--src/sksl/ir/SkSLSwitchCase.h4
-rw-r--r--src/sksl/ir/SkSLSwitchStatement.h4
-rw-r--r--src/sksl/ir/SkSLSwizzle.h8
-rw-r--r--src/sksl/ir/SkSLSymbol.h6
-rw-r--r--src/sksl/ir/SkSLSymbolTable.cpp6
-rw-r--r--src/sksl/ir/SkSLSymbolTable.h10
-rw-r--r--src/sksl/ir/SkSLTernaryExpression.h6
-rw-r--r--src/sksl/ir/SkSLType.cpp4
-rw-r--r--src/sksl/ir/SkSLType.h28
-rw-r--r--src/sksl/ir/SkSLTypeReference.h6
-rw-r--r--src/sksl/ir/SkSLUnresolvedFunction.h4
-rw-r--r--src/sksl/ir/SkSLVarDeclarations.h20
-rw-r--r--src/sksl/ir/SkSLVarDeclarationsStatement.h4
-rw-r--r--src/sksl/ir/SkSLVariable.h6
-rw-r--r--src/sksl/ir/SkSLVariableReference.h4
-rw-r--r--src/sksl/ir/SkSLWhileStatement.h6
-rw-r--r--tests/SkSLErrorTest.cpp8
-rw-r--r--tests/SkSLGLSLTest.cpp4
121 files changed, 1293 insertions, 1791 deletions
diff --git a/BUILD.gn b/BUILD.gn
index 3a206f16f5..88ec34fb0c 100644
--- a/BUILD.gn
+++ b/BUILD.gn
@@ -1500,12 +1500,13 @@ if (skia_enable_tools) {
if (skia_enable_gpu) {
test_app("skslc") {
- defines = [ "SKSL_STANDALONE" ]
sources = [
"src/sksl/SkSLMain.cpp",
]
- sources += skia_sksl_sources
- include_dirs = [ "src/sksl" ]
+ deps = [
+ ":flags",
+ ":skia",
+ ]
}
}
}
diff --git a/bench/GLBench.cpp b/bench/GLBench.cpp
index f043c952f6..0fcd56f2a9 100644
--- a/bench/GLBench.cpp
+++ b/bench/GLBench.cpp
@@ -67,7 +67,7 @@ void GLBench::onDraw(int loops, SkCanvas* canvas) {
GrGLuint GLBench::CompileShader(const GrGLContext* context, const char* sksl, GrGLenum type) {
const GrGLInterface* gl = context->interface();
- SkSL::String glsl;
+ SkString glsl;
SkSL::Program::Settings settings;
settings.fCaps = context->caps()->shaderCaps();
std::unique_ptr<SkSL::Program> program = context->compiler()->convertProgram(
diff --git a/fuzz/fuzz.cpp b/fuzz/fuzz.cpp
index 8374f9518b..d156680718 100644
--- a/fuzz/fuzz.cpp
+++ b/fuzz/fuzz.cpp
@@ -558,7 +558,7 @@ static void fuzz_filter_fuzz(sk_sp<SkData> bytes) {
#if SK_SUPPORT_GPU
static void fuzz_sksl2glsl(sk_sp<SkData> bytes) {
SkSL::Compiler compiler;
- SkSL::String output;
+ SkString output;
SkSL::Program::Settings settings;
sk_sp<GrShaderCaps> caps = SkSL::ShaderCapsFactory::Default();
settings.fCaps = caps.get();
diff --git a/gn/sksl.gni b/gn/sksl.gni
index a1cab827ff..748466f6aa 100644
--- a/gn/sksl.gni
+++ b/gn/sksl.gni
@@ -13,7 +13,6 @@ skia_sksl_sources = [
"$_src/sksl/SkSLParser.cpp",
"$_src/sksl/SkSLGLSLCodeGenerator.cpp",
"$_src/sksl/SkSLSPIRVCodeGenerator.cpp",
- "$_src/sksl/SkSLString.cpp",
"$_src/sksl/SkSLUtil.cpp",
"$_src/sksl/lex.layout.cpp",
"$_src/sksl/ir/SkSLSymbolTable.cpp",
diff --git a/src/gpu/gl/builders/GrGLShaderStringBuilder.cpp b/src/gpu/gl/builders/GrGLShaderStringBuilder.cpp
index e3d2defdef..46530f2e30 100644
--- a/src/gpu/gl/builders/GrGLShaderStringBuilder.cpp
+++ b/src/gpu/gl/builders/GrGLShaderStringBuilder.cpp
@@ -48,7 +48,7 @@ GrGLuint GrGLCompileAndAttachShader(const GrGLContext& glCtx,
}
#endif
- SkSL::String glsl;
+ SkString glsl;
if (type == GR_GL_VERTEX_SHADER || type == GR_GL_FRAGMENT_SHADER) {
SkSL::Compiler& compiler = *glCtx.compiler();
std::unique_ptr<SkSL::Program> program;
diff --git a/src/gpu/vk/GrVkUtil.cpp b/src/gpu/vk/GrVkUtil.cpp
index 1fdf69cdd8..1a73f9a2c0 100644
--- a/src/gpu/vk/GrVkUtil.cpp
+++ b/src/gpu/vk/GrVkUtil.cpp
@@ -283,7 +283,7 @@ bool GrCompileVkShaderModule(const GrVkGpu* gpu,
SkASSERT(false);
}
*outInputs = program->fInputs;
- SkSL::String code;
+ SkString code;
if (!gpu->shaderCompiler()->toSPIRV(*program, &code)) {
SkDebugf("%s\n", gpu->shaderCompiler()->errorText().c_str());
return false;
diff --git a/src/sksl/README b/src/sksl/README
index 5e8e21b92f..25b07c18e1 100644
--- a/src/sksl/README
+++ b/src/sksl/README
@@ -1,7 +1,7 @@
Overview
========
-SkSL ("Skia Shading Language") is a variant of GLSL which is used as Skia's
+SkSL ("Skia Shading Language") is a variant of GLSL which is used as Skia's
internal shading language. SkSL is, at its heart, a single standardized version
of GLSL which avoids all of the various version and dialect differences found
in GLSL "in the wild", but it does bring a few of its own changes to the table.
@@ -15,7 +15,7 @@ Differences from GLSL
SkSL is based on GLSL 4.5. For the most part, write SkSL exactly as you would
desktop GLSL, and the SkSL compiler will take care of version and dialect
differences (for instance, you always use "in" and "out", and skslc will handle
-translating them to "varying" and "attribute" as appropriate). Be aware of the
+translating them to "varying" and "attribute" as appropriate). Be aware of the
following differences between SkSL and GLSL:
* GLSL caps can be referenced via the syntax 'sk_Caps.<name>', e.g.
@@ -36,11 +36,11 @@ following differences between SkSL and GLSL:
* use sk_VertexID instead of gl_VertexID
* the fragment coordinate is sk_FragCoord, and is always relative to the upper
left.
-* lowp, mediump, and highp are always permitted (but will only be respected if
+* lowp, mediump, and highp are always permitted (but will only be respected if
you run on a device which supports them)
* you do not need to include ".0" to make a number a float (meaning that
"vec2(x, y) * 4" is perfectly legal in SkSL, unlike GLSL where it would often
- have to be expressed "vec2(x, y) * 4.0". There is no performance penalty for
+ have to be expressed "vec2(x, y) * 4.0". There is no performance penalty for
this, as the number is converted to a float at compile time)
* type suffixes on numbers (1.0f, 0xFFu) are both unnecessary and unsupported
* creating a smaller vector from a larger vector (e.g. vec2(vec3(1))) is
diff --git a/src/sksl/SkSLCFGGenerator.cpp b/src/sksl/SkSLCFGGenerator.cpp
index e2c038075b..28533df557 100644
--- a/src/sksl/SkSLCFGGenerator.cpp
+++ b/src/sksl/SkSLCFGGenerator.cpp
@@ -4,7 +4,7 @@
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
-
+
#include "SkSLCFGGenerator.h"
#include "ir/SkSLConstructor.h"
diff --git a/src/sksl/SkSLCFGGenerator.h b/src/sksl/SkSLCFGGenerator.h
index 0a03d69fc6..337fdfac35 100644
--- a/src/sksl/SkSLCFGGenerator.h
+++ b/src/sksl/SkSLCFGGenerator.h
@@ -4,7 +4,7 @@
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
-
+
#ifndef SKSL_CFGGENERATOR
#define SKSL_CFGGENERATOR
diff --git a/src/sksl/SkSLCodeGenerator.h b/src/sksl/SkSLCodeGenerator.h
index f6f990503c..111e73a139 100644
--- a/src/sksl/SkSLCodeGenerator.h
+++ b/src/sksl/SkSLCodeGenerator.h
@@ -4,7 +4,7 @@
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
-
+
#ifndef SKSL_CODEGENERATOR
#define SKSL_CODEGENERATOR
@@ -18,7 +18,7 @@ namespace SkSL {
*/
class CodeGenerator {
public:
- CodeGenerator(const Program* program, ErrorReporter* errors, OutputStream* out)
+ CodeGenerator(const Program* program, ErrorReporter* errors, SkWStream* out)
: fProgram(*program)
, fErrors(*errors)
, fOut(out) {}
@@ -31,7 +31,7 @@ protected:
const Program& fProgram;
ErrorReporter& fErrors;
- OutputStream* fOut;
+ SkWStream* fOut;
};
} // namespace
diff --git a/src/sksl/SkSLCompiler.cpp b/src/sksl/SkSLCompiler.cpp
index a20369b32b..1cbc4410b5 100644
--- a/src/sksl/SkSLCompiler.cpp
+++ b/src/sksl/SkSLCompiler.cpp
@@ -19,6 +19,7 @@
#include "ir/SkSLSymbolTable.h"
#include "ir/SkSLUnresolvedFunction.h"
#include "ir/SkSLVarDeclarations.h"
+#include "SkMutex.h"
#ifdef SK_ENABLE_SPIRV_VALIDATION
#include "spirv-tools/libspirv.hpp"
@@ -76,17 +77,17 @@ Compiler::Compiler()
ADD_TYPE(BVec3);
ADD_TYPE(BVec4);
ADD_TYPE(Mat2x2);
- types->addWithoutOwnership(String("mat2x2"), fContext.fMat2x2_Type.get());
+ types->addWithoutOwnership(SkString("mat2x2"), fContext.fMat2x2_Type.get());
ADD_TYPE(Mat2x3);
ADD_TYPE(Mat2x4);
ADD_TYPE(Mat3x2);
ADD_TYPE(Mat3x3);
- types->addWithoutOwnership(String("mat3x3"), fContext.fMat3x3_Type.get());
+ types->addWithoutOwnership(SkString("mat3x3"), fContext.fMat3x3_Type.get());
ADD_TYPE(Mat3x4);
ADD_TYPE(Mat4x2);
ADD_TYPE(Mat4x3);
ADD_TYPE(Mat4x4);
- types->addWithoutOwnership(String("mat4x4"), fContext.fMat4x4_Type.get());
+ types->addWithoutOwnership(SkString("mat4x4"), fContext.fMat4x4_Type.get());
ADD_TYPE(GenType);
ADD_TYPE(GenDType);
ADD_TYPE(GenIType);
@@ -146,14 +147,14 @@ Compiler::Compiler()
ADD_TYPE(GSampler2DArrayShadow);
ADD_TYPE(GSamplerCubeArrayShadow);
- String skCapsName("sk_Caps");
- Variable* skCaps = new Variable(Position(), Modifiers(), skCapsName,
+ SkString skCapsName("sk_Caps");
+ Variable* skCaps = new Variable(Position(), Modifiers(), skCapsName,
*fContext.fSkCaps_Type, Variable::kGlobal_Storage);
fIRGenerator->fSymbolTable->add(skCapsName, std::unique_ptr<Symbol>(skCaps));
Modifiers::Flag ignored1;
std::vector<std::unique_ptr<ProgramElement>> ignored2;
- this->internalConvertProgram(String(SKSL_INCLUDE), &ignored1, &ignored2);
+ this->internalConvertProgram(SkString(SKSL_INCLUDE), &ignored1, &ignored2);
fIRGenerator->fSymbolTable->markAllFunctionsBuiltin();
ASSERT(!fErrorCount);
}
@@ -350,7 +351,7 @@ void Compiler::scanCFG(const FunctionDefinition& f) {
p = (*cfg.fBlocks[i].fNodes[0].fExpression)->fPosition;
break;
}
- this->error(p, String("unreachable"));
+ this->error(p, SkString("unreachable"));
}
}
if (fErrorCount) {
@@ -388,12 +389,12 @@ void Compiler::scanCFG(const FunctionDefinition& f) {
// check for missing return
if (f.fDeclaration.fReturnType != *fContext.fVoid_Type) {
if (cfg.fBlocks[cfg.fExit].fEntrances.size()) {
- this->error(f.fPosition, String("function can exit without returning a value"));
+ this->error(f.fPosition, SkString("function can exit without returning a value"));
}
}
}
-void Compiler::internalConvertProgram(String text,
+void Compiler::internalConvertProgram(SkString text,
Modifiers::Flag* defaultPrecision,
std::vector<std::unique_ptr<ProgramElement>>* result) {
Parser parser(text, *fTypes, *this);
@@ -456,7 +457,7 @@ void Compiler::internalConvertProgram(String text,
}
}
-std::unique_ptr<Program> Compiler::convertProgram(Program::Kind kind, String text,
+std::unique_ptr<Program> Compiler::convertProgram(Program::Kind kind, SkString text,
const Program::Settings& settings) {
fErrorText = "";
fErrorCount = 0;
@@ -465,13 +466,13 @@ std::unique_ptr<Program> Compiler::convertProgram(Program::Kind kind, String tex
Modifiers::Flag ignored;
switch (kind) {
case Program::kVertex_Kind:
- this->internalConvertProgram(String(SKSL_VERT_INCLUDE), &ignored, &elements);
+ this->internalConvertProgram(SkString(SKSL_VERT_INCLUDE), &ignored, &elements);
break;
case Program::kFragment_Kind:
- this->internalConvertProgram(String(SKSL_FRAG_INCLUDE), &ignored, &elements);
+ this->internalConvertProgram(SkString(SKSL_FRAG_INCLUDE), &ignored, &elements);
break;
case Program::kGeometry_Kind:
- this->internalConvertProgram(String(SKSL_GEOM_INCLUDE), &ignored, &elements);
+ this->internalConvertProgram(SkString(SKSL_GEOM_INCLUDE), &ignored, &elements);
break;
}
fIRGenerator->fSymbolTable->markAllFunctionsBuiltin();
@@ -489,22 +490,23 @@ std::unique_ptr<Program> Compiler::convertProgram(Program::Kind kind, String tex
return result;
}
-bool Compiler::toSPIRV(const Program& program, OutputStream& out) {
+bool Compiler::toSPIRV(const Program& program, SkWStream& out) {
#ifdef SK_ENABLE_SPIRV_VALIDATION
- StringStream buffer;
+ SkDynamicMemoryWStream buffer;
SPIRVCodeGenerator cg(&fContext, &program, this, &buffer);
bool result = cg.generateCode();
if (result) {
+ sk_sp<SkData> data(buffer.detachAsData());
spvtools::SpirvTools tools(SPV_ENV_VULKAN_1_0);
- ASSERT(0 == buffer.size() % 4);
+ SkASSERT(0 == data->size() % 4);
auto dumpmsg = [](spv_message_level_t, const char*, const spv_position_t&, const char* m) {
SkDebugf("SPIR-V validation error: %s\n", m);
};
tools.SetMessageConsumer(dumpmsg);
// Verify that the SPIR-V we produced is valid. If this assert fails, check the logs prior
// to the failure to see the validation errors.
- ASSERT_RESULT(tools.Validate((const uint32_t*) buffer.data(), buffer.size() / 4));
- out.write(buffer.data(), buffer.size());
+ SkAssertResult(tools.Validate((const uint32_t*) data->data(), data->size() / 4));
+ out.write(data->data(), data->size());
}
#else
SPIRVCodeGenerator cg(&fContext, &program, this, &out);
@@ -514,39 +516,41 @@ bool Compiler::toSPIRV(const Program& program, OutputStream& out) {
return result;
}
-bool Compiler::toSPIRV(const Program& program, String* out) {
- StringStream buffer;
+bool Compiler::toSPIRV(const Program& program, SkString* out) {
+ SkDynamicMemoryWStream buffer;
bool result = this->toSPIRV(program, buffer);
if (result) {
- *out = String(buffer.data(), buffer.size());
+ sk_sp<SkData> data(buffer.detachAsData());
+ *out = SkString((const char*) data->data(), data->size());
}
return result;
}
-bool Compiler::toGLSL(const Program& program, OutputStream& out) {
+bool Compiler::toGLSL(const Program& program, SkWStream& out) {
GLSLCodeGenerator cg(&fContext, &program, this, &out);
bool result = cg.generateCode();
this->writeErrorCount();
return result;
}
-bool Compiler::toGLSL(const Program& program, String* out) {
- StringStream buffer;
+bool Compiler::toGLSL(const Program& program, SkString* out) {
+ SkDynamicMemoryWStream buffer;
bool result = this->toGLSL(program, buffer);
if (result) {
- *out = String(buffer.data(), buffer.size());
+ sk_sp<SkData> data(buffer.detachAsData());
+ *out = SkString((const char*) data->data(), data->size());
}
return result;
}
-void Compiler::error(Position position, String msg) {
+void Compiler::error(Position position, SkString msg) {
fErrorCount++;
fErrorText += "error: " + position.description() + ": " + msg.c_str() + "\n";
}
-String Compiler::errorText() {
- String result = fErrorText;
+SkString Compiler::errorText() {
+ SkString result = fErrorText;
return result;
}
diff --git a/src/sksl/SkSLCompiler.h b/src/sksl/SkSLCompiler.h
index 7e3c83edff..ec02c5ac52 100644
--- a/src/sksl/SkSLCompiler.h
+++ b/src/sksl/SkSLCompiler.h
@@ -4,7 +4,7 @@
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
-
+
#ifndef SKSL_COMPILER
#define SKSL_COMPILER
@@ -42,20 +42,20 @@ public:
~Compiler() override;
- std::unique_ptr<Program> convertProgram(Program::Kind kind, String text,
+ std::unique_ptr<Program> convertProgram(Program::Kind kind, SkString text,
const Program::Settings& settings);
- bool toSPIRV(const Program& program, OutputStream& out);
+ bool toSPIRV(const Program& program, SkWStream& out);
- bool toSPIRV(const Program& program, String* out);
+ bool toSPIRV(const Program& program, SkString* out);
- bool toGLSL(const Program& program, OutputStream& out);
+ bool toGLSL(const Program& program, SkWStream& out);
- bool toGLSL(const Program& program, String* out);
+ bool toGLSL(const Program& program, SkString* out);
- void error(Position position, String msg) override;
+ void error(Position position, SkString msg) override;
- String errorText();
+ SkString errorText();
void writeErrorCount();
@@ -73,17 +73,17 @@ private:
void scanCFG(const FunctionDefinition& f);
- void internalConvertProgram(String text,
+ void internalConvertProgram(SkString text,
Modifiers::Flag* defaultPrecision,
std::vector<std::unique_ptr<ProgramElement>>* result);
std::shared_ptr<SymbolTable> fTypes;
IRGenerator* fIRGenerator;
- String fSkiaVertText; // FIXME store parsed version instead
+ SkString fSkiaVertText; // FIXME store parsed version instead
Context fContext;
int fErrorCount;
- String fErrorText;
+ SkString fErrorText;
};
} // namespace
diff --git a/src/sksl/SkSLContext.h b/src/sksl/SkSLContext.h
index 450baa5d77..df651bc8b3 100644
--- a/src/sksl/SkSLContext.h
+++ b/src/sksl/SkSLContext.h
@@ -4,7 +4,7 @@
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
-
+
#ifndef SKSL_CONTEXT
#define SKSL_CONTEXT
@@ -19,114 +19,114 @@ namespace SkSL {
class Context {
public:
Context()
- : fInvalid_Type(new Type(String("<INVALID>")))
- , fVoid_Type(new Type(String("void")))
- , fDouble_Type(new Type(String("double"), true))
- , fDVec2_Type(new Type(String("dvec2"), *fDouble_Type, 2))
- , fDVec3_Type(new Type(String("dvec3"), *fDouble_Type, 3))
- , fDVec4_Type(new Type(String("dvec4"), *fDouble_Type, 4))
- , fFloat_Type(new Type(String("float"), true, { fDouble_Type.get() }))
- , fVec2_Type(new Type(String("vec2"), *fFloat_Type, 2))
- , fVec3_Type(new Type(String("vec3"), *fFloat_Type, 3))
- , fVec4_Type(new Type(String("vec4"), *fFloat_Type, 4))
- , fUInt_Type(new Type(String("uint"), true, { fFloat_Type.get(), fDouble_Type.get() }))
- , fUVec2_Type(new Type(String("uvec2"), *fUInt_Type, 2))
- , fUVec3_Type(new Type(String("uvec3"), *fUInt_Type, 3))
- , fUVec4_Type(new Type(String("uvec4"), *fUInt_Type, 4))
- , fInt_Type(new Type(String("int"), true, { fUInt_Type.get(), fFloat_Type.get(),
+ : fInvalid_Type(new Type(SkString("<INVALID>")))
+ , fVoid_Type(new Type(SkString("void")))
+ , fDouble_Type(new Type(SkString("double"), true))
+ , fDVec2_Type(new Type(SkString("dvec2"), *fDouble_Type, 2))
+ , fDVec3_Type(new Type(SkString("dvec3"), *fDouble_Type, 3))
+ , fDVec4_Type(new Type(SkString("dvec4"), *fDouble_Type, 4))
+ , fFloat_Type(new Type(SkString("float"), true, { fDouble_Type.get() }))
+ , fVec2_Type(new Type(SkString("vec2"), *fFloat_Type, 2))
+ , fVec3_Type(new Type(SkString("vec3"), *fFloat_Type, 3))
+ , fVec4_Type(new Type(SkString("vec4"), *fFloat_Type, 4))
+ , fUInt_Type(new Type(SkString("uint"), true, { fFloat_Type.get(), fDouble_Type.get() }))
+ , fUVec2_Type(new Type(SkString("uvec2"), *fUInt_Type, 2))
+ , fUVec3_Type(new Type(SkString("uvec3"), *fUInt_Type, 3))
+ , fUVec4_Type(new Type(SkString("uvec4"), *fUInt_Type, 4))
+ , fInt_Type(new Type(SkString("int"), true, { fUInt_Type.get(), fFloat_Type.get(),
fDouble_Type.get() }))
- , fIVec2_Type(new Type(String("ivec2"), *fInt_Type, 2))
- , fIVec3_Type(new Type(String("ivec3"), *fInt_Type, 3))
- , fIVec4_Type(new Type(String("ivec4"), *fInt_Type, 4))
- , fBool_Type(new Type(String("bool"), false))
- , fBVec2_Type(new Type(String("bvec2"), *fBool_Type, 2))
- , fBVec3_Type(new Type(String("bvec3"), *fBool_Type, 3))
- , fBVec4_Type(new Type(String("bvec4"), *fBool_Type, 4))
- , fMat2x2_Type(new Type(String("mat2"), *fFloat_Type, 2, 2))
- , fMat2x3_Type(new Type(String("mat2x3"), *fFloat_Type, 2, 3))
- , fMat2x4_Type(new Type(String("mat2x4"), *fFloat_Type, 2, 4))
- , fMat3x2_Type(new Type(String("mat3x2"), *fFloat_Type, 3, 2))
- , fMat3x3_Type(new Type(String("mat3"), *fFloat_Type, 3, 3))
- , fMat3x4_Type(new Type(String("mat3x4"), *fFloat_Type, 3, 4))
- , fMat4x2_Type(new Type(String("mat4x2"), *fFloat_Type, 4, 2))
- , fMat4x3_Type(new Type(String("mat4x3"), *fFloat_Type, 4, 3))
- , fMat4x4_Type(new Type(String("mat4"), *fFloat_Type, 4, 4))
- , fDMat2x2_Type(new Type(String("dmat2"), *fFloat_Type, 2, 2))
- , fDMat2x3_Type(new Type(String("dmat2x3"), *fFloat_Type, 2, 3))
- , fDMat2x4_Type(new Type(String("dmat2x4"), *fFloat_Type, 2, 4))
- , fDMat3x2_Type(new Type(String("dmat3x2"), *fFloat_Type, 3, 2))
- , fDMat3x3_Type(new Type(String("dmat3"), *fFloat_Type, 3, 3))
- , fDMat3x4_Type(new Type(String("dmat3x4"), *fFloat_Type, 3, 4))
- , fDMat4x2_Type(new Type(String("dmat4x2"), *fFloat_Type, 4, 2))
- , fDMat4x3_Type(new Type(String("dmat4x3"), *fFloat_Type, 4, 3))
- , fDMat4x4_Type(new Type(String("dmat4"), *fFloat_Type, 4, 4))
- , fSampler1D_Type(new Type(String("sampler1D"), SpvDim1D, false, false, false, true))
- , fSampler2D_Type(new Type(String("sampler2D"), SpvDim2D, false, false, false, true))
- , fSampler3D_Type(new Type(String("sampler3D"), SpvDim3D, false, false, false, true))
- , fSamplerExternalOES_Type(new Type(String("samplerExternalOES"), SpvDim2D, false, false,
+ , fIVec2_Type(new Type(SkString("ivec2"), *fInt_Type, 2))
+ , fIVec3_Type(new Type(SkString("ivec3"), *fInt_Type, 3))
+ , fIVec4_Type(new Type(SkString("ivec4"), *fInt_Type, 4))
+ , fBool_Type(new Type(SkString("bool"), false))
+ , fBVec2_Type(new Type(SkString("bvec2"), *fBool_Type, 2))
+ , fBVec3_Type(new Type(SkString("bvec3"), *fBool_Type, 3))
+ , fBVec4_Type(new Type(SkString("bvec4"), *fBool_Type, 4))
+ , fMat2x2_Type(new Type(SkString("mat2"), *fFloat_Type, 2, 2))
+ , fMat2x3_Type(new Type(SkString("mat2x3"), *fFloat_Type, 2, 3))
+ , fMat2x4_Type(new Type(SkString("mat2x4"), *fFloat_Type, 2, 4))
+ , fMat3x2_Type(new Type(SkString("mat3x2"), *fFloat_Type, 3, 2))
+ , fMat3x3_Type(new Type(SkString("mat3"), *fFloat_Type, 3, 3))
+ , fMat3x4_Type(new Type(SkString("mat3x4"), *fFloat_Type, 3, 4))
+ , fMat4x2_Type(new Type(SkString("mat4x2"), *fFloat_Type, 4, 2))
+ , fMat4x3_Type(new Type(SkString("mat4x3"), *fFloat_Type, 4, 3))
+ , fMat4x4_Type(new Type(SkString("mat4"), *fFloat_Type, 4, 4))
+ , fDMat2x2_Type(new Type(SkString("dmat2"), *fFloat_Type, 2, 2))
+ , fDMat2x3_Type(new Type(SkString("dmat2x3"), *fFloat_Type, 2, 3))
+ , fDMat2x4_Type(new Type(SkString("dmat2x4"), *fFloat_Type, 2, 4))
+ , fDMat3x2_Type(new Type(SkString("dmat3x2"), *fFloat_Type, 3, 2))
+ , fDMat3x3_Type(new Type(SkString("dmat3"), *fFloat_Type, 3, 3))
+ , fDMat3x4_Type(new Type(SkString("dmat3x4"), *fFloat_Type, 3, 4))
+ , fDMat4x2_Type(new Type(SkString("dmat4x2"), *fFloat_Type, 4, 2))
+ , fDMat4x3_Type(new Type(SkString("dmat4x3"), *fFloat_Type, 4, 3))
+ , fDMat4x4_Type(new Type(SkString("dmat4"), *fFloat_Type, 4, 4))
+ , fSampler1D_Type(new Type(SkString("sampler1D"), SpvDim1D, false, false, false, true))
+ , fSampler2D_Type(new Type(SkString("sampler2D"), SpvDim2D, false, false, false, true))
+ , fSampler3D_Type(new Type(SkString("sampler3D"), SpvDim3D, false, false, false, true))
+ , fSamplerExternalOES_Type(new Type(SkString("samplerExternalOES"), SpvDim2D, false, false,
false, true))
- , fSamplerCube_Type(new Type(String("samplerCube"), SpvDimCube, false, false, false, true))
- , fSampler2DRect_Type(new Type(String("sampler2DRect"), SpvDimRect, false, false, false,
+ , fSamplerCube_Type(new Type(SkString("samplerCube"), SpvDimCube, false, false, false, true))
+ , fSampler2DRect_Type(new Type(SkString("sampler2DRect"), SpvDimRect, false, false, false,
true))
- , fSampler1DArray_Type(new Type(String("sampler1DArray")))
- , fSampler2DArray_Type(new Type(String("sampler2DArray")))
- , fSamplerCubeArray_Type(new Type(String("samplerCubeArray")))
- , fSamplerBuffer_Type(new Type(String("samplerBuffer")))
- , fSampler2DMS_Type(new Type(String("sampler2DMS")))
- , fSampler2DMSArray_Type(new Type(String("sampler2DMSArray")))
- , fSampler1DShadow_Type(new Type(String("sampler1DShadow")))
- , fSampler2DShadow_Type(new Type(String("sampler2DShadow")))
- , fSamplerCubeShadow_Type(new Type(String("samplerCubeShadow")))
- , fSampler2DRectShadow_Type(new Type(String("sampler2DRectShadow")))
- , fSampler1DArrayShadow_Type(new Type(String("sampler1DArrayShadow")))
- , fSampler2DArrayShadow_Type(new Type(String("sampler2DArrayShadow")))
- , fSamplerCubeArrayShadow_Type(new Type(String("samplerCubeArrayShadow")))
+ , fSampler1DArray_Type(new Type(SkString("sampler1DArray")))
+ , fSampler2DArray_Type(new Type(SkString("sampler2DArray")))
+ , fSamplerCubeArray_Type(new Type(SkString("samplerCubeArray")))
+ , fSamplerBuffer_Type(new Type(SkString("samplerBuffer")))
+ , fSampler2DMS_Type(new Type(SkString("sampler2DMS")))
+ , fSampler2DMSArray_Type(new Type(SkString("sampler2DMSArray")))
+ , fSampler1DShadow_Type(new Type(SkString("sampler1DShadow")))
+ , fSampler2DShadow_Type(new Type(SkString("sampler2DShadow")))
+ , fSamplerCubeShadow_Type(new Type(SkString("samplerCubeShadow")))
+ , fSampler2DRectShadow_Type(new Type(SkString("sampler2DRectShadow")))
+ , fSampler1DArrayShadow_Type(new Type(SkString("sampler1DArrayShadow")))
+ , fSampler2DArrayShadow_Type(new Type(SkString("sampler2DArrayShadow")))
+ , fSamplerCubeArrayShadow_Type(new Type(SkString("samplerCubeArrayShadow")))
// Related to below FIXME, gsampler*s don't currently expand to cover integer case.
- , fISampler2D_Type(new Type(String("isampler2D"), SpvDim2D, false, false, false, true))
+ , fISampler2D_Type(new Type(SkString("isampler2D"), SpvDim2D, false, false, false, true))
// FIXME express these as "gimage2D" that expand to image2D, iimage2D, and uimage2D.
- , fImage2D_Type(new Type(String("image2D"), SpvDim2D, false, false, false, true))
- , fIImage2D_Type(new Type(String("iimage2D"), SpvDim2D, false, false, false, true))
+ , fImage2D_Type(new Type(SkString("image2D"), SpvDim2D, false, false, false, true))
+ , fIImage2D_Type(new Type(SkString("iimage2D"), SpvDim2D, false, false, false, true))
// FIXME express these as "gsubpassInput" that expand to subpassInput, isubpassInput,
// and usubpassInput.
- , fSubpassInput_Type(new Type(String("subpassInput"), SpvDimSubpassData, false, false,
+ , fSubpassInput_Type(new Type(SkString("subpassInput"), SpvDimSubpassData, false, false,
false, false))
- , fSubpassInputMS_Type(new Type(String("subpassInputMS"), SpvDimSubpassData, false, false,
+ , fSubpassInputMS_Type(new Type(SkString("subpassInputMS"), SpvDimSubpassData, false, false,
true, false))
// FIXME figure out what we're supposed to do with the gsampler et al. types)
- , fGSampler1D_Type(new Type(String("$gsampler1D"), static_type(*fSampler1D_Type)))
- , fGSampler2D_Type(new Type(String("$gsampler2D"), static_type(*fSampler2D_Type)))
- , fGSampler3D_Type(new Type(String("$gsampler3D"), static_type(*fSampler3D_Type)))
- , fGSamplerCube_Type(new Type(String("$gsamplerCube"), static_type(*fSamplerCube_Type)))
- , fGSampler2DRect_Type(new Type(String("$gsampler2DRect"), static_type(*fSampler2DRect_Type)))
- , fGSampler1DArray_Type(new Type(String("$gsampler1DArray"),
+ , fGSampler1D_Type(new Type(SkString("$gsampler1D"), static_type(*fSampler1D_Type)))
+ , fGSampler2D_Type(new Type(SkString("$gsampler2D"), static_type(*fSampler2D_Type)))
+ , fGSampler3D_Type(new Type(SkString("$gsampler3D"), static_type(*fSampler3D_Type)))
+ , fGSamplerCube_Type(new Type(SkString("$gsamplerCube"), static_type(*fSamplerCube_Type)))
+ , fGSampler2DRect_Type(new Type(SkString("$gsampler2DRect"), static_type(*fSampler2DRect_Type)))
+ , fGSampler1DArray_Type(new Type(SkString("$gsampler1DArray"),
static_type(*fSampler1DArray_Type)))
- , fGSampler2DArray_Type(new Type(String("$gsampler2DArray"),
+ , fGSampler2DArray_Type(new Type(SkString("$gsampler2DArray"),
static_type(*fSampler2DArray_Type)))
- , fGSamplerCubeArray_Type(new Type(String("$gsamplerCubeArray"),
+ , fGSamplerCubeArray_Type(new Type(SkString("$gsamplerCubeArray"),
static_type(*fSamplerCubeArray_Type)))
- , fGSamplerBuffer_Type(new Type(String("$gsamplerBuffer"), static_type(*fSamplerBuffer_Type)))
- , fGSampler2DMS_Type(new Type(String("$gsampler2DMS"), static_type(*fSampler2DMS_Type)))
- , fGSampler2DMSArray_Type(new Type(String("$gsampler2DMSArray"),
+ , fGSamplerBuffer_Type(new Type(SkString("$gsamplerBuffer"), static_type(*fSamplerBuffer_Type)))
+ , fGSampler2DMS_Type(new Type(SkString("$gsampler2DMS"), static_type(*fSampler2DMS_Type)))
+ , fGSampler2DMSArray_Type(new Type(SkString("$gsampler2DMSArray"),
static_type(*fSampler2DMSArray_Type)))
- , fGSampler2DArrayShadow_Type(new Type(String("$gsampler2DArrayShadow"),
+ , fGSampler2DArrayShadow_Type(new Type(SkString("$gsampler2DArrayShadow"),
static_type(*fSampler2DArrayShadow_Type)))
- , fGSamplerCubeArrayShadow_Type(new Type(String("$gsamplerCubeArrayShadow"),
+ , fGSamplerCubeArrayShadow_Type(new Type(SkString("$gsamplerCubeArrayShadow"),
static_type(*fSamplerCubeArrayShadow_Type)))
- , fGenType_Type(new Type(String("$genType"), { fFloat_Type.get(), fVec2_Type.get(),
+ , fGenType_Type(new Type(SkString("$genType"), { fFloat_Type.get(), fVec2_Type.get(),
fVec3_Type.get(), fVec4_Type.get() }))
- , fGenDType_Type(new Type(String("$genDType"), { fDouble_Type.get(), fDVec2_Type.get(),
+ , fGenDType_Type(new Type(SkString("$genDType"), { fDouble_Type.get(), fDVec2_Type.get(),
fDVec3_Type.get(), fDVec4_Type.get() }))
- , fGenIType_Type(new Type(String("$genIType"), { fInt_Type.get(), fIVec2_Type.get(),
+ , fGenIType_Type(new Type(SkString("$genIType"), { fInt_Type.get(), fIVec2_Type.get(),
fIVec3_Type.get(), fIVec4_Type.get() }))
- , fGenUType_Type(new Type(String("$genUType"), { fUInt_Type.get(), fUVec2_Type.get(),
+ , fGenUType_Type(new Type(SkString("$genUType"), { fUInt_Type.get(), fUVec2_Type.get(),
fUVec3_Type.get(), fUVec4_Type.get() }))
- , fGenBType_Type(new Type(String("$genBType"), { fBool_Type.get(), fBVec2_Type.get(),
+ , fGenBType_Type(new Type(SkString("$genBType"), { fBool_Type.get(), fBVec2_Type.get(),
fBVec3_Type.get(), fBVec4_Type.get() }))
- , fMat_Type(new Type(String("$mat"), { fMat2x2_Type.get(), fMat2x3_Type.get(),
+ , fMat_Type(new Type(SkString("$mat"), { fMat2x2_Type.get(), fMat2x3_Type.get(),
fMat2x4_Type.get(), fMat3x2_Type.get(),
fMat3x3_Type.get(), fMat3x4_Type.get(),
fMat4x2_Type.get(), fMat4x3_Type.get(),
@@ -135,21 +135,21 @@ public:
fDMat3x2_Type.get(), fDMat3x3_Type.get(),
fDMat3x4_Type.get(), fDMat4x2_Type.get(),
fDMat4x3_Type.get(), fDMat4x4_Type.get() }))
- , fVec_Type(new Type(String("$vec"), { fInvalid_Type.get(), fVec2_Type.get(),
+ , fVec_Type(new Type(SkString("$vec"), { fInvalid_Type.get(), fVec2_Type.get(),
fVec3_Type.get(), fVec4_Type.get() }))
- , fGVec_Type(new Type(String("$gvec")))
- , fGVec2_Type(new Type(String("$gvec2")))
- , fGVec3_Type(new Type(String("$gvec3")))
- , fGVec4_Type(new Type(String("$gvec4"), static_type(*fVec4_Type)))
- , fDVec_Type(new Type(String("$dvec"), { fInvalid_Type.get(), fDVec2_Type.get(),
+ , fGVec_Type(new Type(SkString("$gvec")))
+ , fGVec2_Type(new Type(SkString("$gvec2")))
+ , fGVec3_Type(new Type(SkString("$gvec3")))
+ , fGVec4_Type(new Type(SkString("$gvec4"), static_type(*fVec4_Type)))
+ , fDVec_Type(new Type(SkString("$dvec"), { fInvalid_Type.get(), fDVec2_Type.get(),
fDVec3_Type.get(), fDVec4_Type.get() }))
- , fIVec_Type(new Type(String("$ivec"), { fInvalid_Type.get(), fIVec2_Type.get(),
+ , fIVec_Type(new Type(SkString("$ivec"), { fInvalid_Type.get(), fIVec2_Type.get(),
fIVec3_Type.get(), fIVec4_Type.get() }))
- , fUVec_Type(new Type(String("$uvec"), { fInvalid_Type.get(), fUVec2_Type.get(),
+ , fUVec_Type(new Type(SkString("$uvec"), { fInvalid_Type.get(), fUVec2_Type.get(),
fUVec3_Type.get(), fUVec4_Type.get() }))
- , fBVec_Type(new Type(String("$bvec"), { fInvalid_Type.get(), fBVec2_Type.get(),
+ , fBVec_Type(new Type(SkString("$bvec"), { fInvalid_Type.get(), fBVec2_Type.get(),
fBVec3_Type.get(), fBVec4_Type.get() }))
- , fSkCaps_Type(new Type(String("$sk_Caps")))
+ , fSkCaps_Type(new Type(SkString("$sk_Caps")))
, fDefined_Expression(new Defined(*fInvalid_Type)) {}
static std::vector<const Type*> static_type(const Type& t) {
@@ -269,19 +269,19 @@ public:
const std::unique_ptr<Type> fSkCaps_Type;
- // dummy expression used to mark that a variable has a value during dataflow analysis (when it
+ // dummy expression used to mark that a variable has a value during dataflow analysis (when it
// could have several different values, or the analyzer is otherwise unable to assign it a
// specific expression)
const std::unique_ptr<Expression> fDefined_Expression;
-private:
+private:
class Defined : public Expression {
public:
Defined(const Type& type)
: INHERITED(Position(), kDefined_Kind, type) {}
- virtual String description() const override {
- return String("<defined>");
+ virtual SkString description() const override {
+ return SkString("<defined>");
}
typedef Expression INHERITED;
diff --git a/src/sksl/SkSLErrorReporter.h b/src/sksl/SkSLErrorReporter.h
index 172e4888d8..85d386d49c 100644
--- a/src/sksl/SkSLErrorReporter.h
+++ b/src/sksl/SkSLErrorReporter.h
@@ -4,7 +4,7 @@
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
-
+
#ifndef SKSL_ERRORREPORTER
#define SKSL_ERRORREPORTER
@@ -20,10 +20,10 @@ public:
virtual ~ErrorReporter() {}
void error(Position position, const char* msg) {
- this->error(position, String(msg));
+ this->error(position, SkString(msg));
}
- virtual void error(Position position, String msg) = 0;
+ virtual void error(Position position, SkString msg) = 0;
virtual int errorCount() = 0;
};
diff --git a/src/sksl/SkSLFileOutputStream.h b/src/sksl/SkSLFileOutputStream.h
deleted file mode 100644
index f4739306c9..0000000000
--- a/src/sksl/SkSLFileOutputStream.h
+++ /dev/null
@@ -1,75 +0,0 @@
-/*
- * Copyright 2017 Google Inc.
- *
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#ifndef SKSL_FILEOUTPUTSTREAM
-#define SKSL_FILEOUTPUTSTREAM
-
-#include "SkSLOutputStream.h"
-#include <stdio.h>
-
-namespace SkSL {
-
-class FileOutputStream : public OutputStream {
-public:
- FileOutputStream(const char* name) {
- fFile = fopen(name, "w");
- }
-
- ~FileOutputStream() {
- ASSERT(!fOpen);
- }
-
- bool isValid() const override {
- return nullptr != fFile;
- }
-
- void write8(uint8_t b) override {
- ASSERT(fOpen);
- if (isValid()) {
- if (EOF == fputc(b, fFile)) {
- fFile = nullptr;
- }
- }
- }
-
- void writeText(const char* s) override {
- ASSERT(fOpen);
- if (isValid()) {
- if (EOF == fputs(s, fFile)) {
- fFile = nullptr;
- }
- }
- }
-
- void write(const void* s, size_t size) override {
- if (isValid()) {
- size_t written = fwrite(s, 1, size, fFile);
- if (written != size) {
- fFile = nullptr;
- }
- }
- }
-
- bool close() {
- fOpen = false;
- if (isValid() && fclose(fFile)) {
- fFile = nullptr;
- return false;
- }
- return true;
- }
-
-private:
- bool fOpen = true;
- FILE *fFile;
-
- typedef OutputStream INHERITED;
-};
-
-} // namespace
-
-#endif
diff --git a/src/sksl/SkSLGLSLCodeGenerator.cpp b/src/sksl/SkSLGLSLCodeGenerator.cpp
index ab64e66f7c..a19de8f844 100644
--- a/src/sksl/SkSLGLSLCodeGenerator.cpp
+++ b/src/sksl/SkSLGLSLCodeGenerator.cpp
@@ -7,6 +7,8 @@
#include "SkSLGLSLCodeGenerator.h"
+#include "string.h"
+
#include "GLSL.std.450.h"
#include "SkSLCompiler.h"
@@ -33,15 +35,15 @@ void GLSLCodeGenerator::write(const char* s) {
void GLSLCodeGenerator::writeLine(const char* s) {
this->write(s);
- fOut->write8('\n');
+ fOut->writeText("\n");
fAtLineStart = true;
}
-void GLSLCodeGenerator::write(const String& s) {
+void GLSLCodeGenerator::write(const SkString& s) {
this->write(s.c_str());
}
-void GLSLCodeGenerator::writeLine(const String& s) {
+void GLSLCodeGenerator::writeLine(const SkString& s) {
this->writeLine(s.c_str());
}
@@ -135,8 +137,8 @@ static bool is_abs(Expression& expr) {
// Tegra3 compiler bug.
void GLSLCodeGenerator::writeMinAbsHack(Expression& absExpr, Expression& otherExpr) {
ASSERT(!fProgram.fSettings.fCaps->canUseMinAndAbsTogether());
- String tmpVar1 = "minAbsHackVar" + to_string(fVarCount++);
- String tmpVar2 = "minAbsHackVar" + to_string(fVarCount++);
+ SkString tmpVar1 = "minAbsHackVar" + to_string(fVarCount++);
+ SkString tmpVar2 = "minAbsHackVar" + to_string(fVarCount++);
this->fFunctionHeader += " " + absExpr.fType.name() + " " + tmpVar1 + ";\n";
this->fFunctionHeader += " " + otherExpr.fType.name() + " " + tmpVar2 + ";\n";
this->write("((" + tmpVar1 + " = ");
@@ -409,7 +411,7 @@ static GLSLCodeGenerator::Precedence get_binary_precedence(Token::Kind op) {
}
}
-void GLSLCodeGenerator::writeBinaryExpression(const BinaryExpression& b,
+void GLSLCodeGenerator::writeBinaryExpression(const BinaryExpression& b,
Precedence parentPrecedence) {
Precedence precedence = get_binary_precedence(b.fOperator);
if (precedence >= parentPrecedence) {
@@ -423,7 +425,7 @@ void GLSLCodeGenerator::writeBinaryExpression(const BinaryExpression& b,
}
}
-void GLSLCodeGenerator::writeTernaryExpression(const TernaryExpression& t,
+void GLSLCodeGenerator::writeTernaryExpression(const TernaryExpression& t,
Precedence parentPrecedence) {
if (kTernary_Precedence >= parentPrecedence) {
this->write("(");
@@ -438,7 +440,7 @@ void GLSLCodeGenerator::writeTernaryExpression(const TernaryExpression& t,
}
}
-void GLSLCodeGenerator::writePrefixExpression(const PrefixExpression& p,
+void GLSLCodeGenerator::writePrefixExpression(const PrefixExpression& p,
Precedence parentPrecedence) {
if (kPrefix_Precedence >= parentPrecedence) {
this->write("(");
@@ -450,7 +452,7 @@ void GLSLCodeGenerator::writePrefixExpression(const PrefixExpression& p,
}
}
-void GLSLCodeGenerator::writePostfixExpression(const PostfixExpression& p,
+void GLSLCodeGenerator::writePostfixExpression(const PostfixExpression& p,
Precedence parentPrecedence) {
if (kPostfix_Precedence >= parentPrecedence) {
this->write("(");
@@ -505,8 +507,8 @@ void GLSLCodeGenerator::writeFunction(const FunctionDefinition& f) {
this->writeLine(") {");
fFunctionHeader = "";
- OutputStream* oldOut = fOut;
- StringStream buffer;
+ SkWStream* oldOut = fOut;
+ SkDynamicMemoryWStream buffer;
fOut = &buffer;
fIndentation++;
for (const auto& s : f.fBody->fStatements) {
@@ -518,7 +520,8 @@ void GLSLCodeGenerator::writeFunction(const FunctionDefinition& f) {
fOut = oldOut;
this->write(fFunctionHeader);
- this->write(String(buffer.data(), buffer.size()));
+ sk_sp<SkData> data(buffer.detachAsData());
+ this->write(SkString((const char*) data->data(), data->size()));
}
void GLSLCodeGenerator::writeModifiers(const Modifiers& modifiers,
@@ -529,7 +532,7 @@ void GLSLCodeGenerator::writeModifiers(const Modifiers& modifiers,
if (modifiers.fFlags & Modifiers::kNoPerspective_Flag) {
this->write("noperspective ");
}
- String layout = modifiers.fLayout.description();
+ SkString layout = modifiers.fLayout.description();
if (layout.size()) {
this->write(layout + " ");
}
@@ -622,11 +625,11 @@ void GLSLCodeGenerator::writeVarDeclarations(const VarDeclarations& decl, bool g
ASSERT(decl.fVars.size() > 0);
this->writeModifiers(decl.fVars[0].fVar->fModifiers, global);
this->writeType(decl.fBaseType);
- String separator(" ");
+ SkString separator(" ");
for (const auto& var : decl.fVars) {
ASSERT(var.fVar->fModifiers == decl.fVars[0].fVar->fModifiers);
this->write(separator);
- separator = String(", ");
+ separator = SkString(", ");
this->write(var.fVar->fName);
for (const auto& size : var.fSizes) {
this->write("[");
@@ -660,7 +663,7 @@ void GLSLCodeGenerator::writeStatement(const Statement& s) {
this->writeExpression(*((ExpressionStatement&) s).fExpression, kTopLevel_Precedence);
this->write(";");
break;
- case Statement::kReturn_Kind:
+ case Statement::kReturn_Kind:
this->writeReturnStatement((ReturnStatement&) s);
break;
case Statement::kVarDeclarations_Kind:
@@ -784,7 +787,7 @@ void GLSLCodeGenerator::writeReturnStatement(const ReturnStatement& r) {
}
bool GLSLCodeGenerator::generateCode() {
- OutputStream* rawOut = fOut;
+ SkWStream* rawOut = fOut;
fOut = &fHeader;
fProgramKind = fProgram.fKind;
this->write(fProgram.fSettings.fCaps->versionDeclString());
@@ -794,7 +797,7 @@ bool GLSLCodeGenerator::generateCode() {
this->writeExtension((Extension&) *e);
}
}
- StringStream body;
+ SkDynamicMemoryWStream body;
fOut = &body;
if (fProgram.fSettings.fCaps->usesPrecisionModifiers()) {
this->write("precision ");
@@ -854,8 +857,8 @@ bool GLSLCodeGenerator::generateCode() {
}
fOut = nullptr;
- write_stringstream(fHeader, *rawOut);
- write_stringstream(body, *rawOut);
+ write_data(*fHeader.detachAsData(), *rawOut);
+ write_data(*body.detachAsData(), *rawOut);
return true;
}
diff --git a/src/sksl/SkSLGLSLCodeGenerator.h b/src/sksl/SkSLGLSLCodeGenerator.h
index ab88d50881..907c3053c6 100644
--- a/src/sksl/SkSLGLSLCodeGenerator.h
+++ b/src/sksl/SkSLGLSLCodeGenerator.h
@@ -12,6 +12,7 @@
#include <tuple>
#include <unordered_map>
+#include "SkStream.h"
#include "SkSLCodeGenerator.h"
#include "ir/SkSLBinaryExpression.h"
#include "ir/SkSLBoolLiteral.h"
@@ -72,7 +73,7 @@ public:
};
GLSLCodeGenerator(const Context* context, const Program* program, ErrorReporter* errors,
- OutputStream* out)
+ SkWStream* out)
: INHERITED(program, errors, out)
, fContext(*context) {}
@@ -85,9 +86,9 @@ private:
void writeLine(const char* s);
- void write(const String& s);
+ void write(const SkString& s);
- void writeLine(const String& s);
+ void writeLine(const SkString& s);
void writeType(const Type& type);
@@ -96,7 +97,7 @@ private:
void writeInterfaceBlock(const InterfaceBlock& intf);
void writeFunctionStart(const FunctionDeclaration& f);
-
+
void writeFunctionDeclaration(const FunctionDeclaration& f);
void writeFunction(const FunctionDefinition& f);
@@ -160,8 +161,8 @@ private:
void writeReturnStatement(const ReturnStatement& r);
const Context& fContext;
- StringStream fHeader;
- String fFunctionHeader;
+ SkDynamicMemoryWStream fHeader;
+ SkString fFunctionHeader;
Program::Kind fProgramKind;
int fVarCount = 0;
int fIndentation = 0;
diff --git a/src/sksl/SkSLIRGenerator.cpp b/src/sksl/SkSLIRGenerator.cpp
index 368aa22388..ae2a90f899 100644
--- a/src/sksl/SkSLIRGenerator.cpp
+++ b/src/sksl/SkSLIRGenerator.cpp
@@ -115,8 +115,8 @@ void IRGenerator::popSymbolTable() {
fSymbolTable = fSymbolTable->fParent;
}
-static void fill_caps(const SKSL_CAPS_CLASS& caps, std::unordered_map<String, CapValue>* capsMap) {
-#define CAP(name) capsMap->insert(std::make_pair(String(#name), CapValue(caps.name())));
+static void fill_caps(const GrShaderCaps& caps, std::unordered_map<SkString, CapValue>* capsMap) {
+#define CAP(name) capsMap->insert(std::make_pair(SkString(#name), CapValue(caps.name())));
CAP(fbFetchSupport);
CAP(fbFetchNeedsCustomOutput);
CAP(bindlessTextureSupport);
@@ -224,7 +224,7 @@ std::unique_ptr<VarDeclarations> IRGenerator::convertVarDeclarations(const ASTVa
if (!size) {
return nullptr;
}
- String name = type->fName;
+ SkString name = type->fName;
int64_t count;
if (size->fKind == Expression::kIntLiteral_Kind) {
count = ((IntLiteral&) *size).fValue;
@@ -255,7 +255,7 @@ std::unique_ptr<VarDeclarations> IRGenerator::convertVarDeclarations(const ASTVa
}
value = this->coerce(std::move(value), *type);
}
- if (storage == Variable::kGlobal_Storage && varDecl.fName == String("sk_FragColor") &&
+ if (storage == Variable::kGlobal_Storage && varDecl.fName == SkString("sk_FragColor") &&
(*fSymbolTable)[varDecl.fName]) {
// already defined, ignore
} else if (storage == Variable::kGlobal_Storage && (*fSymbolTable)[varDecl.fName] &&
@@ -501,12 +501,12 @@ std::unique_ptr<FunctionDefinition> IRGenerator::convertFunction(const ASTFuncti
}
for (int j = (int) param->fSizes.size() - 1; j >= 0; j--) {
int size = param->fSizes[j];
- String name = type->name() + "[" + to_string(size) + "]";
+ SkString name = type->name() + "[" + to_string(size) + "]";
Type* newType = new Type(std::move(name), Type::kArray_Kind, *type, size);
fSymbolTable->takeOwnership(newType);
type = newType;
}
- String name = param->fName;
+ SkString name = param->fName;
Position pos = param->fPosition;
Variable* var = new Variable(pos, param->fModifiers, std::move(name), *type,
Variable::kParameter_Storage);
@@ -632,7 +632,7 @@ std::unique_ptr<InterfaceBlock> IRGenerator::convertInterfaceBlock(const ASTInte
if (!converted) {
return nullptr;
}
- String name = type->fName;
+ SkString name = type->fName;
int64_t count;
if (converted->fKind == Expression::kIntLiteral_Kind) {
count = ((IntLiteral&) *converted).fValue;
@@ -676,7 +676,7 @@ const Type* IRGenerator::convertType(const ASTType& type) {
const Symbol* result = (*fSymbolTable)[type.fName];
if (result && result->fKind == Symbol::kType_Kind) {
for (int size : type.fSizes) {
- String name = result->fName + "[";
+ SkString name = result->fName + "[";
if (size != -1) {
name += to_string(size);
}
@@ -1115,7 +1115,7 @@ std::unique_ptr<Expression> IRGenerator::call(Position position,
const FunctionDeclaration& function,
std::vector<std::unique_ptr<Expression>> arguments) {
if (function.fParameters.size() != arguments.size()) {
- String msg = "call to '" + function.fName + "' expected " +
+ SkString msg = "call to '" + function.fName + "' expected " +
to_string((uint64_t) function.fParameters.size()) +
" argument";
if (function.fParameters.size() != 1) {
@@ -1128,8 +1128,8 @@ std::unique_ptr<Expression> IRGenerator::call(Position position,
std::vector<const Type*> types;
const Type* returnType;
if (!function.determineFinalTypes(arguments, &types, &returnType)) {
- String msg = "no match for " + function.fName + "(";
- String separator;
+ SkString msg = "no match for " + function.fName + "(";
+ SkString separator;
for (size_t i = 0; i < arguments.size(); i++) {
msg += separator;
separator = ", ";
@@ -1207,8 +1207,8 @@ std::unique_ptr<Expression> IRGenerator::call(Position position,
if (best) {
return this->call(position, *best, std::move(arguments));
}
- String msg = "no match for " + ref->fFunctions[0]->fName + "(";
- String separator;
+ SkString msg = "no match for " + ref->fFunctions[0]->fName + "(";
+ SkString separator;
for (size_t i = 0; i < arguments.size(); i++) {
msg += separator;
separator = ", ";
@@ -1465,7 +1465,7 @@ std::unique_ptr<Expression> IRGenerator::convertIndex(std::unique_ptr<Expression
}
std::unique_ptr<Expression> IRGenerator::convertField(std::unique_ptr<Expression> base,
- const String& field) {
+ const SkString& field) {
auto fields = base->fType.fields();
for (size_t i = 0; i < fields.size(); i++) {
if (fields[i].fName == field) {
@@ -1478,7 +1478,7 @@ std::unique_ptr<Expression> IRGenerator::convertField(std::unique_ptr<Expression
}
std::unique_ptr<Expression> IRGenerator::convertSwizzle(std::unique_ptr<Expression> base,
- const String& fields) {
+ const SkString& fields) {
if (base->fType.kind() != Type::kVector_Kind) {
fErrors.error(base->fPosition, "cannot swizzle type '" + base->fType.description() + "'");
return nullptr;
@@ -1516,7 +1516,7 @@ std::unique_ptr<Expression> IRGenerator::convertSwizzle(std::unique_ptr<Expressi
}
// fall through
default:
- fErrors.error(base->fPosition, String::printf("invalid swizzle component '%c'",
+ fErrors.error(base->fPosition, SkStringPrintf("invalid swizzle component '%c'",
fields[i]));
return nullptr;
}
@@ -1529,7 +1529,7 @@ std::unique_ptr<Expression> IRGenerator::convertSwizzle(std::unique_ptr<Expressi
return std::unique_ptr<Expression>(new Swizzle(fContext, std::move(base), swizzleComponents));
}
-std::unique_ptr<Expression> IRGenerator::getCap(Position position, String name) {
+std::unique_ptr<Expression> IRGenerator::getCap(Position position, SkString name) {
auto found = fCapsMap.find(name);
if (found == fCapsMap.end()) {
fErrors.error(position, "unknown capability flag '" + name + "'");
diff --git a/src/sksl/SkSLIRGenerator.h b/src/sksl/SkSLIRGenerator.h
index b0a449acea..fb79cda9b5 100644
--- a/src/sksl/SkSLIRGenerator.h
+++ b/src/sksl/SkSLIRGenerator.h
@@ -154,12 +154,12 @@ private:
Modifiers convertModifiers(const Modifiers& m);
std::unique_ptr<Expression> convertPrefixExpression(const ASTPrefixExpression& expression);
std::unique_ptr<Statement> convertReturn(const ASTReturnStatement& r);
- std::unique_ptr<Expression> getCap(Position position, String name);
+ std::unique_ptr<Expression> getCap(Position position, SkString name);
std::unique_ptr<Expression> convertSuffixExpression(const ASTSuffixExpression& expression);
std::unique_ptr<Expression> convertField(std::unique_ptr<Expression> base,
- const String& field);
+ const SkString& field);
std::unique_ptr<Expression> convertSwizzle(std::unique_ptr<Expression> base,
- const String& fields);
+ const SkString& fields);
std::unique_ptr<Expression> convertTernaryExpression(const ASTTernaryExpression& expression);
std::unique_ptr<Statement> convertVarDeclarationStatement(const ASTVarDeclarationStatement& s);
std::unique_ptr<Statement> convertWhile(const ASTWhileStatement& w);
@@ -169,7 +169,7 @@ private:
const FunctionDeclaration* fCurrentFunction;
const Program::Settings* fSettings;
- std::unordered_map<String, CapValue> fCapsMap;
+ std::unordered_map<SkString, CapValue> fCapsMap;
std::shared_ptr<SymbolTable> fSymbolTable;
int fLoopLevel;
int fSwitchLevel;
diff --git a/src/sksl/SkSLMain.cpp b/src/sksl/SkSLMain.cpp
index 1461bf9aae..46e9c18757 100644
--- a/src/sksl/SkSLMain.cpp
+++ b/src/sksl/SkSLMain.cpp
@@ -8,7 +8,7 @@
#include "stdio.h"
#include <fstream>
#include "SkSLCompiler.h"
-#include "SkSLFileOutputStream.h"
+#include "GrContextOptions.h"
/**
* Very simple standalone executable to facilitate testing.
@@ -34,15 +34,17 @@ int main(int argc, const char** argv) {
std::ifstream in(argv[1]);
std::string stdText((std::istreambuf_iterator<char>(in)),
std::istreambuf_iterator<char>());
- SkSL::String text(stdText.c_str());
+ SkString text(stdText.c_str());
if (in.rdstate()) {
printf("error reading '%s'\n", argv[1]);
exit(2);
}
SkSL::Program::Settings settings;
- SkSL::String name(argv[2]);
+ sk_sp<GrShaderCaps> caps = SkSL::ShaderCapsFactory::Default();
+ settings.fCaps = caps.get();
+ SkString name(argv[2]);
if (name.endsWith(".spirv")) {
- SkSL::FileOutputStream out(argv[2]);
+ SkFILEWStream out(argv[2]);
SkSL::Compiler compiler;
if (!out.isValid()) {
printf("error writing '%s'\n", argv[2]);
@@ -53,12 +55,8 @@ int main(int argc, const char** argv) {
printf("%s", compiler.errorText().c_str());
exit(3);
}
- if (!out.close()) {
- printf("error writing '%s'\n", argv[2]);
- exit(4);
- }
} else if (name.endsWith(".glsl")) {
- SkSL::FileOutputStream out(argv[2]);
+ SkFILEWStream out(argv[2]);
SkSL::Compiler compiler;
if (!out.isValid()) {
printf("error writing '%s'\n", argv[2]);
@@ -69,10 +67,6 @@ int main(int argc, const char** argv) {
printf("%s", compiler.errorText().c_str());
exit(3);
}
- if (!out.close()) {
- printf("error writing '%s'\n", argv[2]);
- exit(4);
- }
} else {
printf("expected output filename to end with '.spirv' or '.glsl'");
}
diff --git a/src/sksl/SkSLMemoryLayout.h b/src/sksl/SkSLMemoryLayout.h
index 61712eccff..95a292f9d9 100644
--- a/src/sksl/SkSLMemoryLayout.h
+++ b/src/sksl/SkSLMemoryLayout.h
@@ -4,7 +4,7 @@
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
-
+
#ifndef SKIASL_MEMORYLAYOUT
#define SKIASL_MEMORYLAYOUT
@@ -19,14 +19,14 @@ public:
k430_Standard
};
- MemoryLayout(Standard std)
+ MemoryLayout(Standard std)
: fStd(std) {}
static size_t vector_alignment(size_t componentSize, int columns) {
return componentSize * (columns + columns % 2);
}
- /**
+ /**
* Rounds up to the nearest multiple of 16 if in std140, otherwise returns the parameter
* unchanged (std140 requires various things to be rounded up to the nearest multiple of 16,
* std430 does not).
@@ -50,7 +50,7 @@ public:
case Type::kVector_Kind:
return vector_alignment(this->size(type.componentType()), type.columns());
case Type::kMatrix_Kind:
- return this->roundUpIfNeeded(vector_alignment(this->size(type.componentType()),
+ return this->roundUpIfNeeded(vector_alignment(this->size(type.componentType()),
type.rows()));
case Type::kArray_Kind:
return this->roundUpIfNeeded(this->alignment(type.componentType()));
@@ -65,7 +65,7 @@ public:
return this->roundUpIfNeeded(result);
}
default:
- ABORT("cannot determine size of type %s", type.name().c_str());
+ ABORT(("cannot determine size of type " + type.name()).c_str());
}
}
@@ -111,12 +111,12 @@ public:
total += this->size(*f.fType);
}
size_t alignment = this->alignment(type);
- ASSERT(!type.fields().size() ||
+ ASSERT(!type.fields().size() ||
(0 == alignment % this->alignment(*type.fields()[0].fType)));
return (total + alignment - 1) & ~(alignment - 1);
}
default:
- ABORT("cannot determine size of type %s", type.name().c_str());
+ ABORT(("cannot determine size of type " + type.name()).c_str());
}
}
diff --git a/src/sksl/SkSLOutputStream.h b/src/sksl/SkSLOutputStream.h
deleted file mode 100644
index 62be61e753..0000000000
--- a/src/sksl/SkSLOutputStream.h
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * Copyright 2017 Google Inc.
- *
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#ifndef SKSL_OUTPUTSTREAM
-#define SKSL_OUTPUTSTREAM
-
-#include "SkSLString.h"
-
-namespace SkSL {
-
-class OutputStream {
-public:
- virtual bool isValid() const {
- return true;
- }
-
- virtual void write8(uint8_t b) = 0;
-
- virtual void writeText(const char* s) = 0;
-
- virtual void write(const void* s, size_t size) = 0;
-
- void writeString(String s) {
- this->write(s.c_str(), s.size());
- }
-
- virtual ~OutputStream() {}
-};
-
-} // namespace
-
-#endif
diff --git a/src/sksl/SkSLParser.cpp b/src/sksl/SkSLParser.cpp
index 1004de85b1..e24685a51d 100644
--- a/src/sksl/SkSLParser.cpp
+++ b/src/sksl/SkSLParser.cpp
@@ -79,7 +79,7 @@ public:
bool checkValid() {
if (fParser->fDepth > MAX_PARSE_DEPTH) {
- fParser->error(fParser->peek().fPosition, String("exceeded max parse depth"));
+ fParser->error(fParser->peek().fPosition, SkString("exceeded max parse depth"));
return false;
}
return true;
@@ -89,8 +89,8 @@ private:
Parser* fParser;
};
-Parser::Parser(String text, SymbolTable& types, ErrorReporter& errors)
-: fPushback(Position(-1, -1), Token::INVALID_TOKEN, String())
+Parser::Parser(SkString text, SymbolTable& types, ErrorReporter& errors)
+: fPushback(Position(-1, -1), Token::INVALID_TOKEN, SkString())
, fTypes(types)
, fErrors(errors) {
sksllex_init(&fScanner);
@@ -150,17 +150,17 @@ Token Parser::nextToken() {
return result;
}
int token = sksllex(fScanner);
- String text;
+ SkString text;
switch ((Token::Kind) token) {
case Token::IDENTIFIER: // fall through
case Token::INT_LITERAL: // fall through
case Token::FLOAT_LITERAL: // fall through
case Token::DIRECTIVE:
- text = String(skslget_text(fScanner));
+ text = SkString(skslget_text(fScanner));
break;
default:
#ifdef SK_DEBUG
- text = String(skslget_text(fScanner));
+ text = SkString(skslget_text(fScanner));
#endif
break;
}
@@ -179,10 +179,10 @@ Token Parser::peek() {
bool Parser::expect(Token::Kind kind, const char* expected, Token* result) {
- return this->expect(kind, String(expected), result);
+ return this->expect(kind, SkString(expected), result);
}
-bool Parser::expect(Token::Kind kind, String expected, Token* result) {
+bool Parser::expect(Token::Kind kind, SkString expected, Token* result) {
Token next = this->nextToken();
if (next.fKind == kind) {
if (result) {
@@ -201,14 +201,14 @@ bool Parser::expect(Token::Kind kind, String expected, Token* result) {
}
void Parser::error(Position p, const char* msg) {
- this->error(p, String(msg));
+ this->error(p, SkString(msg));
}
-void Parser::error(Position p, String msg) {
+void Parser::error(Position p, SkString msg) {
fErrors.error(p, msg);
}
-bool Parser::isType(String name) {
+bool Parser::isType(SkString name) {
return nullptr != fTypes[name];
}
@@ -380,7 +380,7 @@ std::unique_ptr<ASTType> Parser::structDeclaration() {
return nullptr;
}
uint64_t columns = ((ASTIntLiteral&) *var.fSizes[i]).fValue;
- String name = type->name() + "[" + to_string(columns) + "]";
+ SkString name = type->name() + "[" + to_string(columns) + "]";
type = new Type(name, Type::kArray_Kind, *type, (int) columns);
fTypes.takeOwnership((Type*) type);
}
@@ -427,7 +427,7 @@ std::unique_ptr<ASTVarDeclarations> Parser::structVarDeclaration(Modifiers modif
(LBRACKET expression? RBRACKET)* (EQ expression)?)* SEMICOLON */
std::unique_ptr<ASTVarDeclarations> Parser::varDeclarationEnd(Modifiers mods,
std::unique_ptr<ASTType> type,
- String name) {
+ SkString name) {
std::vector<ASTVarDeclaration> vars;
std::vector<std::unique_ptr<ASTExpression>> currentVarSizes;
while (this->peek().fKind == Token::LBRACKET) {
@@ -837,7 +837,7 @@ std::unique_ptr<ASTDeclaration> Parser::interfaceBlock(Modifiers mods) {
decls.push_back(std::move(decl));
}
this->nextToken();
- String instanceName;
+ SkString instanceName;
std::vector<std::unique_ptr<ASTExpression>> sizes;
if (this->peek().fKind == Token::IDENTIFIER) {
instanceName = this->nextToken().fText;
@@ -1008,7 +1008,7 @@ std::unique_ptr<ASTStatement> Parser::switchStatement() {
// parts of the compiler may rely upon this assumption.
if (this->peek().fKind == Token::DEFAULT) {
Token defaultStart;
- ASSERT_RESULT(this->expect(Token::DEFAULT, "'default'", &defaultStart));
+ SkAssertResult(this->expect(Token::DEFAULT, "'default'", &defaultStart));
if (!this->expect(Token::COLON, "':'")) {
return nullptr;
}
@@ -1562,7 +1562,7 @@ std::unique_ptr<ASTSuffix> Parser::suffix() {
}
case Token::DOT: {
Position pos = this->peek().fPosition;
- String text;
+ SkString text;
if (this->identifier(&text)) {
return std::unique_ptr<ASTSuffix>(new ASTFieldSuffix(pos, std::move(text)));
}
@@ -1607,7 +1607,7 @@ std::unique_ptr<ASTExpression> Parser::term() {
Token t = this->peek();
switch (t.fKind) {
case Token::IDENTIFIER: {
- String text;
+ SkString text;
if (this->identifier(&text)) {
result.reset(new ASTIdentifier(t.fPosition, std::move(text)));
}
@@ -1688,7 +1688,7 @@ bool Parser::boolLiteral(bool* dest) {
}
/* IDENTIFIER */
-bool Parser::identifier(String* dest) {
+bool Parser::identifier(SkString* dest) {
Token t;
if (this->expect(Token::IDENTIFIER, "identifier", &t)) {
*dest = t.fText;
diff --git a/src/sksl/SkSLParser.h b/src/sksl/SkSLParser.h
index 0fa00cb882..9be017ce62 100644
--- a/src/sksl/SkSLParser.h
+++ b/src/sksl/SkSLParser.h
@@ -51,7 +51,7 @@ class SymbolTable;
*/
class Parser {
public:
- Parser(String text, SymbolTable& types, ErrorReporter& errors);
+ Parser(SkString text, SymbolTable& types, ErrorReporter& errors);
~Parser();
@@ -90,16 +90,16 @@ private:
* Returns true if the read token was as expected, false otherwise.
*/
bool expect(Token::Kind kind, const char* expected, Token* result = nullptr);
- bool expect(Token::Kind kind, String expected, Token* result = nullptr);
+ bool expect(Token::Kind kind, SkString expected, Token* result = nullptr);
void error(Position p, const char* msg);
- void error(Position p, String msg);
-
+ void error(Position p, SkString msg);
+
/**
* Returns true if the 'name' identifier refers to a type name. For instance, isType("int") will
* always return true.
*/
- bool isType(String name);
+ bool isType(SkString name);
// these functions parse individual grammar rules from the current parse position; you probably
// don't need to call any of these outside of the parser. The function declarations in the .cpp
@@ -119,12 +119,12 @@ private:
std::unique_ptr<ASTVarDeclarations> varDeclarationEnd(Modifiers modifiers,
std::unique_ptr<ASTType> type,
- String name);
+ SkString name);
std::unique_ptr<ASTParameter> parameter();
int layoutInt();
-
+
Layout layout();
Modifiers modifiers();
@@ -164,7 +164,7 @@ private:
std::unique_ptr<ASTExpression> expression();
std::unique_ptr<ASTExpression> assignmentExpression();
-
+
std::unique_ptr<ASTExpression> ternaryExpression();
std::unique_ptr<ASTExpression> logicalOrExpression();
@@ -203,7 +203,7 @@ private:
bool boolLiteral(bool* dest);
- bool identifier(String* dest);
+ bool identifier(SkString* dest);
void* fScanner;
void* fLayoutScanner;
diff --git a/src/sksl/SkSLPosition.h b/src/sksl/SkSLPosition.h
index 83cfe82542..b1841c5a59 100644
--- a/src/sksl/SkSLPosition.h
+++ b/src/sksl/SkSLPosition.h
@@ -4,7 +4,7 @@
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
-
+
#ifndef SKSL_POSITION
#define SKSL_POSITION
@@ -17,15 +17,15 @@ namespace SkSL {
* ignored.
*/
struct Position {
- Position()
+ Position()
: fLine(-1)
, fColumn(-1) {}
-
+
Position(int line, int column)
: fLine(line)
, fColumn(column) {}
- String description() const {
+ SkString description() const {
return to_string(fLine);
}
diff --git a/src/sksl/SkSLSPIRVCodeGenerator.cpp b/src/sksl/SkSLSPIRVCodeGenerator.cpp
index 4c0194feca..93ec4ce9b2 100644
--- a/src/sksl/SkSLSPIRVCodeGenerator.cpp
+++ b/src/sksl/SkSLSPIRVCodeGenerator.cpp
@@ -4,9 +4,11 @@
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
-
+
#include "SkSLSPIRVCodeGenerator.h"
+#include "string.h"
+
#include "GLSL.std.450.h"
#include "ir/SkSLExpressionStatement.h"
@@ -32,103 +34,103 @@ void SPIRVCodeGenerator::setupIntrinsics() {
#define SPECIAL(x) std::make_tuple(kSpecial_IntrinsicKind, k ## x ## _SpecialIntrinsic, \
k ## x ## _SpecialIntrinsic, k ## x ## _SpecialIntrinsic, \
k ## x ## _SpecialIntrinsic)
- fIntrinsicMap[String("round")] = ALL_GLSL(Round);
- fIntrinsicMap[String("roundEven")] = ALL_GLSL(RoundEven);
- fIntrinsicMap[String("trunc")] = ALL_GLSL(Trunc);
- fIntrinsicMap[String("abs")] = BY_TYPE_GLSL(FAbs, SAbs, SAbs);
- fIntrinsicMap[String("sign")] = BY_TYPE_GLSL(FSign, SSign, SSign);
- fIntrinsicMap[String("floor")] = ALL_GLSL(Floor);
- fIntrinsicMap[String("ceil")] = ALL_GLSL(Ceil);
- fIntrinsicMap[String("fract")] = ALL_GLSL(Fract);
- fIntrinsicMap[String("radians")] = ALL_GLSL(Radians);
- fIntrinsicMap[String("degrees")] = ALL_GLSL(Degrees);
- fIntrinsicMap[String("sin")] = ALL_GLSL(Sin);
- fIntrinsicMap[String("cos")] = ALL_GLSL(Cos);
- fIntrinsicMap[String("tan")] = ALL_GLSL(Tan);
- fIntrinsicMap[String("asin")] = ALL_GLSL(Asin);
- fIntrinsicMap[String("acos")] = ALL_GLSL(Acos);
- fIntrinsicMap[String("atan")] = SPECIAL(Atan);
- fIntrinsicMap[String("sinh")] = ALL_GLSL(Sinh);
- fIntrinsicMap[String("cosh")] = ALL_GLSL(Cosh);
- fIntrinsicMap[String("tanh")] = ALL_GLSL(Tanh);
- fIntrinsicMap[String("asinh")] = ALL_GLSL(Asinh);
- fIntrinsicMap[String("acosh")] = ALL_GLSL(Acosh);
- fIntrinsicMap[String("atanh")] = ALL_GLSL(Atanh);
- fIntrinsicMap[String("pow")] = ALL_GLSL(Pow);
- fIntrinsicMap[String("exp")] = ALL_GLSL(Exp);
- fIntrinsicMap[String("log")] = ALL_GLSL(Log);
- fIntrinsicMap[String("exp2")] = ALL_GLSL(Exp2);
- fIntrinsicMap[String("log2")] = ALL_GLSL(Log2);
- fIntrinsicMap[String("sqrt")] = ALL_GLSL(Sqrt);
- fIntrinsicMap[String("inversesqrt")] = ALL_GLSL(InverseSqrt);
- fIntrinsicMap[String("determinant")] = ALL_GLSL(Determinant);
- fIntrinsicMap[String("matrixInverse")] = ALL_GLSL(MatrixInverse);
- fIntrinsicMap[String("mod")] = std::make_tuple(kSPIRV_IntrinsicKind, SpvOpFMod,
+ fIntrinsicMap[SkString("round")] = ALL_GLSL(Round);
+ fIntrinsicMap[SkString("roundEven")] = ALL_GLSL(RoundEven);
+ fIntrinsicMap[SkString("trunc")] = ALL_GLSL(Trunc);
+ fIntrinsicMap[SkString("abs")] = BY_TYPE_GLSL(FAbs, SAbs, SAbs);
+ fIntrinsicMap[SkString("sign")] = BY_TYPE_GLSL(FSign, SSign, SSign);
+ fIntrinsicMap[SkString("floor")] = ALL_GLSL(Floor);
+ fIntrinsicMap[SkString("ceil")] = ALL_GLSL(Ceil);
+ fIntrinsicMap[SkString("fract")] = ALL_GLSL(Fract);
+ fIntrinsicMap[SkString("radians")] = ALL_GLSL(Radians);
+ fIntrinsicMap[SkString("degrees")] = ALL_GLSL(Degrees);
+ fIntrinsicMap[SkString("sin")] = ALL_GLSL(Sin);
+ fIntrinsicMap[SkString("cos")] = ALL_GLSL(Cos);
+ fIntrinsicMap[SkString("tan")] = ALL_GLSL(Tan);
+ fIntrinsicMap[SkString("asin")] = ALL_GLSL(Asin);
+ fIntrinsicMap[SkString("acos")] = ALL_GLSL(Acos);
+ fIntrinsicMap[SkString("atan")] = SPECIAL(Atan);
+ fIntrinsicMap[SkString("sinh")] = ALL_GLSL(Sinh);
+ fIntrinsicMap[SkString("cosh")] = ALL_GLSL(Cosh);
+ fIntrinsicMap[SkString("tanh")] = ALL_GLSL(Tanh);
+ fIntrinsicMap[SkString("asinh")] = ALL_GLSL(Asinh);
+ fIntrinsicMap[SkString("acosh")] = ALL_GLSL(Acosh);
+ fIntrinsicMap[SkString("atanh")] = ALL_GLSL(Atanh);
+ fIntrinsicMap[SkString("pow")] = ALL_GLSL(Pow);
+ fIntrinsicMap[SkString("exp")] = ALL_GLSL(Exp);
+ fIntrinsicMap[SkString("log")] = ALL_GLSL(Log);
+ fIntrinsicMap[SkString("exp2")] = ALL_GLSL(Exp2);
+ fIntrinsicMap[SkString("log2")] = ALL_GLSL(Log2);
+ fIntrinsicMap[SkString("sqrt")] = ALL_GLSL(Sqrt);
+ fIntrinsicMap[SkString("inversesqrt")] = ALL_GLSL(InverseSqrt);
+ fIntrinsicMap[SkString("determinant")] = ALL_GLSL(Determinant);
+ fIntrinsicMap[SkString("matrixInverse")] = ALL_GLSL(MatrixInverse);
+ fIntrinsicMap[SkString("mod")] = std::make_tuple(kSPIRV_IntrinsicKind, SpvOpFMod,
SpvOpSMod, SpvOpUMod, SpvOpUndef);
- fIntrinsicMap[String("min")] = BY_TYPE_GLSL(FMin, SMin, UMin);
- fIntrinsicMap[String("max")] = BY_TYPE_GLSL(FMax, SMax, UMax);
- fIntrinsicMap[String("clamp")] = BY_TYPE_GLSL(FClamp, SClamp, UClamp);
- fIntrinsicMap[String("dot")] = std::make_tuple(kSPIRV_IntrinsicKind, SpvOpDot,
+ fIntrinsicMap[SkString("min")] = BY_TYPE_GLSL(FMin, SMin, UMin);
+ fIntrinsicMap[SkString("max")] = BY_TYPE_GLSL(FMax, SMax, UMax);
+ fIntrinsicMap[SkString("clamp")] = BY_TYPE_GLSL(FClamp, SClamp, UClamp);
+ fIntrinsicMap[SkString("dot")] = std::make_tuple(kSPIRV_IntrinsicKind, SpvOpDot,
SpvOpUndef, SpvOpUndef, SpvOpUndef);
- fIntrinsicMap[String("mix")] = ALL_GLSL(FMix);
- fIntrinsicMap[String("step")] = ALL_GLSL(Step);
- fIntrinsicMap[String("smoothstep")] = ALL_GLSL(SmoothStep);
- fIntrinsicMap[String("fma")] = ALL_GLSL(Fma);
- fIntrinsicMap[String("frexp")] = ALL_GLSL(Frexp);
- fIntrinsicMap[String("ldexp")] = ALL_GLSL(Ldexp);
-
-#define PACK(type) fIntrinsicMap[String("pack" #type)] = ALL_GLSL(Pack ## type); \
- fIntrinsicMap[String("unpack" #type)] = ALL_GLSL(Unpack ## type)
+ fIntrinsicMap[SkString("mix")] = ALL_GLSL(FMix);
+ fIntrinsicMap[SkString("step")] = ALL_GLSL(Step);
+ fIntrinsicMap[SkString("smoothstep")] = ALL_GLSL(SmoothStep);
+ fIntrinsicMap[SkString("fma")] = ALL_GLSL(Fma);
+ fIntrinsicMap[SkString("frexp")] = ALL_GLSL(Frexp);
+ fIntrinsicMap[SkString("ldexp")] = ALL_GLSL(Ldexp);
+
+#define PACK(type) fIntrinsicMap[SkString("pack" #type)] = ALL_GLSL(Pack ## type); \
+ fIntrinsicMap[SkString("unpack" #type)] = ALL_GLSL(Unpack ## type)
PACK(Snorm4x8);
PACK(Unorm4x8);
PACK(Snorm2x16);
PACK(Unorm2x16);
PACK(Half2x16);
PACK(Double2x32);
- fIntrinsicMap[String("length")] = ALL_GLSL(Length);
- fIntrinsicMap[String("distance")] = ALL_GLSL(Distance);
- fIntrinsicMap[String("cross")] = ALL_GLSL(Cross);
- fIntrinsicMap[String("normalize")] = ALL_GLSL(Normalize);
- fIntrinsicMap[String("faceForward")] = ALL_GLSL(FaceForward);
- fIntrinsicMap[String("reflect")] = ALL_GLSL(Reflect);
- fIntrinsicMap[String("refract")] = ALL_GLSL(Refract);
- fIntrinsicMap[String("findLSB")] = ALL_GLSL(FindILsb);
- fIntrinsicMap[String("findMSB")] = BY_TYPE_GLSL(FindSMsb, FindSMsb, FindUMsb);
- fIntrinsicMap[String("dFdx")] = std::make_tuple(kSPIRV_IntrinsicKind, SpvOpDPdx,
+ fIntrinsicMap[SkString("length")] = ALL_GLSL(Length);
+ fIntrinsicMap[SkString("distance")] = ALL_GLSL(Distance);
+ fIntrinsicMap[SkString("cross")] = ALL_GLSL(Cross);
+ fIntrinsicMap[SkString("normalize")] = ALL_GLSL(Normalize);
+ fIntrinsicMap[SkString("faceForward")] = ALL_GLSL(FaceForward);
+ fIntrinsicMap[SkString("reflect")] = ALL_GLSL(Reflect);
+ fIntrinsicMap[SkString("refract")] = ALL_GLSL(Refract);
+ fIntrinsicMap[SkString("findLSB")] = ALL_GLSL(FindILsb);
+ fIntrinsicMap[SkString("findMSB")] = BY_TYPE_GLSL(FindSMsb, FindSMsb, FindUMsb);
+ fIntrinsicMap[SkString("dFdx")] = std::make_tuple(kSPIRV_IntrinsicKind, SpvOpDPdx,
SpvOpUndef, SpvOpUndef, SpvOpUndef);
- fIntrinsicMap[String("dFdy")] = std::make_tuple(kSPIRV_IntrinsicKind, SpvOpDPdy,
+ fIntrinsicMap[SkString("dFdy")] = std::make_tuple(kSPIRV_IntrinsicKind, SpvOpDPdy,
SpvOpUndef, SpvOpUndef, SpvOpUndef);
- fIntrinsicMap[String("dFdy")] = std::make_tuple(kSPIRV_IntrinsicKind, SpvOpDPdy,
+ fIntrinsicMap[SkString("dFdy")] = std::make_tuple(kSPIRV_IntrinsicKind, SpvOpDPdy,
SpvOpUndef, SpvOpUndef, SpvOpUndef);
- fIntrinsicMap[String("texture")] = SPECIAL(Texture);
+ fIntrinsicMap[SkString("texture")] = SPECIAL(Texture);
- fIntrinsicMap[String("subpassLoad")] = SPECIAL(SubpassLoad);
+ fIntrinsicMap[SkString("subpassLoad")] = SPECIAL(SubpassLoad);
- fIntrinsicMap[String("any")] = std::make_tuple(kSPIRV_IntrinsicKind, SpvOpUndef,
+ fIntrinsicMap[SkString("any")] = std::make_tuple(kSPIRV_IntrinsicKind, SpvOpUndef,
SpvOpUndef, SpvOpUndef, SpvOpAny);
- fIntrinsicMap[String("all")] = std::make_tuple(kSPIRV_IntrinsicKind, SpvOpUndef,
+ fIntrinsicMap[SkString("all")] = std::make_tuple(kSPIRV_IntrinsicKind, SpvOpUndef,
SpvOpUndef, SpvOpUndef, SpvOpAll);
- fIntrinsicMap[String("equal")] = std::make_tuple(kSPIRV_IntrinsicKind,
+ fIntrinsicMap[SkString("equal")] = std::make_tuple(kSPIRV_IntrinsicKind,
SpvOpFOrdEqual, SpvOpIEqual,
SpvOpIEqual, SpvOpLogicalEqual);
- fIntrinsicMap[String("notEqual")] = std::make_tuple(kSPIRV_IntrinsicKind,
+ fIntrinsicMap[SkString("notEqual")] = std::make_tuple(kSPIRV_IntrinsicKind,
SpvOpFOrdNotEqual, SpvOpINotEqual,
SpvOpINotEqual,
SpvOpLogicalNotEqual);
- fIntrinsicMap[String("lessThan")] = std::make_tuple(kSPIRV_IntrinsicKind,
+ fIntrinsicMap[SkString("lessThan")] = std::make_tuple(kSPIRV_IntrinsicKind,
SpvOpSLessThan, SpvOpULessThan,
SpvOpFOrdLessThan, SpvOpUndef);
- fIntrinsicMap[String("lessThanEqual")] = std::make_tuple(kSPIRV_IntrinsicKind,
+ fIntrinsicMap[SkString("lessThanEqual")] = std::make_tuple(kSPIRV_IntrinsicKind,
SpvOpSLessThanEqual,
SpvOpULessThanEqual,
SpvOpFOrdLessThanEqual,
SpvOpUndef);
- fIntrinsicMap[String("greaterThan")] = std::make_tuple(kSPIRV_IntrinsicKind,
+ fIntrinsicMap[SkString("greaterThan")] = std::make_tuple(kSPIRV_IntrinsicKind,
SpvOpSGreaterThan,
SpvOpUGreaterThan,
SpvOpFOrdGreaterThan,
SpvOpUndef);
- fIntrinsicMap[String("greaterThanEqual")] = std::make_tuple(kSPIRV_IntrinsicKind,
+ fIntrinsicMap[SkString("greaterThanEqual")] = std::make_tuple(kSPIRV_IntrinsicKind,
SpvOpSGreaterThanEqual,
SpvOpUGreaterThanEqual,
SpvOpFOrdGreaterThanEqual,
@@ -137,7 +139,7 @@ void SPIRVCodeGenerator::setupIntrinsics() {
// interpolateAt* not yet supported...
}
-void SPIRVCodeGenerator::writeWord(int32_t word, OutputStream& out) {
+void SPIRVCodeGenerator::writeWord(int32_t word, SkWStream& out) {
#if SPIRV_DEBUG
out << "(" << word << ") ";
#else
@@ -178,603 +180,603 @@ static bool is_out(const Variable& var) {
}
#if SPIRV_DEBUG
-static String opcode_text(SpvOp_ opCode) {
+static SkString opcode_text(SpvOp_ opCode) {
switch (opCode) {
case SpvOpNop:
- return String("Nop");
+ return SkString("Nop");
case SpvOpUndef:
- return String("Undef");
+ return SkString("Undef");
case SpvOpSourceContinued:
- return String("SourceContinued");
+ return SkString("SourceContinued");
case SpvOpSource:
- return String("Source");
+ return SkString("Source");
case SpvOpSourceExtension:
- return String("SourceExtension");
+ return SkString("SourceExtension");
case SpvOpName:
- return String("Name");
+ return SkString("Name");
case SpvOpMemberName:
- return String("MemberName");
+ return SkString("MemberName");
case SpvOpString:
- return String("String");
+ return SkString("String");
case SpvOpLine:
- return String("Line");
+ return SkString("Line");
case SpvOpExtension:
- return String("Extension");
+ return SkString("Extension");
case SpvOpExtInstImport:
- return String("ExtInstImport");
+ return SkString("ExtInstImport");
case SpvOpExtInst:
- return String("ExtInst");
+ return SkString("ExtInst");
case SpvOpMemoryModel:
- return String("MemoryModel");
+ return SkString("MemoryModel");
case SpvOpEntryPoint:
- return String("EntryPoint");
+ return SkString("EntryPoint");
case SpvOpExecutionMode:
- return String("ExecutionMode");
+ return SkString("ExecutionMode");
case SpvOpCapability:
- return String("Capability");
+ return SkString("Capability");
case SpvOpTypeVoid:
- return String("TypeVoid");
+ return SkString("TypeVoid");
case SpvOpTypeBool:
- return String("TypeBool");
+ return SkString("TypeBool");
case SpvOpTypeInt:
- return String("TypeInt");
+ return SkString("TypeInt");
case SpvOpTypeFloat:
- return String("TypeFloat");
+ return SkString("TypeFloat");
case SpvOpTypeVector:
- return String("TypeVector");
+ return SkString("TypeVector");
case SpvOpTypeMatrix:
- return String("TypeMatrix");
+ return SkString("TypeMatrix");
case SpvOpTypeImage:
- return String("TypeImage");
+ return SkString("TypeImage");
case SpvOpTypeSampler:
- return String("TypeSampler");
+ return SkString("TypeSampler");
case SpvOpTypeSampledImage:
- return String("TypeSampledImage");
+ return SkString("TypeSampledImage");
case SpvOpTypeArray:
- return String("TypeArray");
+ return SkString("TypeArray");
case SpvOpTypeRuntimeArray:
- return String("TypeRuntimeArray");
+ return SkString("TypeRuntimeArray");
case SpvOpTypeStruct:
- return String("TypeStruct");
+ return SkString("TypeStruct");
case SpvOpTypeOpaque:
- return String("TypeOpaque");
+ return SkString("TypeOpaque");
case SpvOpTypePointer:
- return String("TypePointer");
+ return SkString("TypePointer");
case SpvOpTypeFunction:
- return String("TypeFunction");
+ return SkString("TypeFunction");
case SpvOpTypeEvent:
- return String("TypeEvent");
+ return SkString("TypeEvent");
case SpvOpTypeDeviceEvent:
- return String("TypeDeviceEvent");
+ return SkString("TypeDeviceEvent");
case SpvOpTypeReserveId:
- return String("TypeReserveId");
+ return SkString("TypeReserveId");
case SpvOpTypeQueue:
- return String("TypeQueue");
+ return SkString("TypeQueue");
case SpvOpTypePipe:
- return String("TypePipe");
+ return SkString("TypePipe");
case SpvOpTypeForwardPointer:
- return String("TypeForwardPointer");
+ return SkString("TypeForwardPointer");
case SpvOpConstantTrue:
- return String("ConstantTrue");
+ return SkString("ConstantTrue");
case SpvOpConstantFalse:
- return String("ConstantFalse");
+ return SkString("ConstantFalse");
case SpvOpConstant:
- return String("Constant");
+ return SkString("Constant");
case SpvOpConstantComposite:
- return String("ConstantComposite");
+ return SkString("ConstantComposite");
case SpvOpConstantSampler:
- return String("ConstantSampler");
+ return SkString("ConstantSampler");
case SpvOpConstantNull:
- return String("ConstantNull");
+ return SkString("ConstantNull");
case SpvOpSpecConstantTrue:
- return String("SpecConstantTrue");
+ return SkString("SpecConstantTrue");
case SpvOpSpecConstantFalse:
- return String("SpecConstantFalse");
+ return SkString("SpecConstantFalse");
case SpvOpSpecConstant:
- return String("SpecConstant");
+ return SkString("SpecConstant");
case SpvOpSpecConstantComposite:
- return String("SpecConstantComposite");
+ return SkString("SpecConstantComposite");
case SpvOpSpecConstantOp:
- return String("SpecConstantOp");
+ return SkString("SpecConstantOp");
case SpvOpFunction:
- return String("Function");
+ return SkString("Function");
case SpvOpFunctionParameter:
- return String("FunctionParameter");
+ return SkString("FunctionParameter");
case SpvOpFunctionEnd:
- return String("FunctionEnd");
+ return SkString("FunctionEnd");
case SpvOpFunctionCall:
- return String("FunctionCall");
+ return SkString("FunctionCall");
case SpvOpVariable:
- return String("Variable");
+ return SkString("Variable");
case SpvOpImageTexelPointer:
- return String("ImageTexelPointer");
+ return SkString("ImageTexelPointer");
case SpvOpLoad:
- return String("Load");
+ return SkString("Load");
case SpvOpStore:
- return String("Store");
+ return SkString("Store");
case SpvOpCopyMemory:
- return String("CopyMemory");
+ return SkString("CopyMemory");
case SpvOpCopyMemorySized:
- return String("CopyMemorySized");
+ return SkString("CopyMemorySized");
case SpvOpAccessChain:
- return String("AccessChain");
+ return SkString("AccessChain");
case SpvOpInBoundsAccessChain:
- return String("InBoundsAccessChain");
+ return SkString("InBoundsAccessChain");
case SpvOpPtrAccessChain:
- return String("PtrAccessChain");
+ return SkString("PtrAccessChain");
case SpvOpArrayLength:
- return String("ArrayLength");
+ return SkString("ArrayLength");
case SpvOpGenericPtrMemSemantics:
- return String("GenericPtrMemSemantics");
+ return SkString("GenericPtrMemSemantics");
case SpvOpInBoundsPtrAccessChain:
- return String("InBoundsPtrAccessChain");
+ return SkString("InBoundsPtrAccessChain");
case SpvOpDecorate:
- return String("Decorate");
+ return SkString("Decorate");
case SpvOpMemberDecorate:
- return String("MemberDecorate");
+ return SkString("MemberDecorate");
case SpvOpDecorationGroup:
- return String("DecorationGroup");
+ return SkString("DecorationGroup");
case SpvOpGroupDecorate:
- return String("GroupDecorate");
+ return SkString("GroupDecorate");
case SpvOpGroupMemberDecorate:
- return String("GroupMemberDecorate");
+ return SkString("GroupMemberDecorate");
case SpvOpVectorExtractDynamic:
- return String("VectorExtractDynamic");
+ return SkString("VectorExtractDynamic");
case SpvOpVectorInsertDynamic:
- return String("VectorInsertDynamic");
+ return SkString("VectorInsertDynamic");
case SpvOpVectorShuffle:
- return String("VectorShuffle");
+ return SkString("VectorShuffle");
case SpvOpCompositeConstruct:
- return String("CompositeConstruct");
+ return SkString("CompositeConstruct");
case SpvOpCompositeExtract:
- return String("CompositeExtract");
+ return SkString("CompositeExtract");
case SpvOpCompositeInsert:
- return String("CompositeInsert");
+ return SkString("CompositeInsert");
case SpvOpCopyObject:
- return String("CopyObject");
+ return SkString("CopyObject");
case SpvOpTranspose:
- return String("Transpose");
+ return SkString("Transpose");
case SpvOpSampledImage:
- return String("SampledImage");
+ return SkString("SampledImage");
case SpvOpImageSampleImplicitLod:
- return String("ImageSampleImplicitLod");
+ return SkString("ImageSampleImplicitLod");
case SpvOpImageSampleExplicitLod:
- return String("ImageSampleExplicitLod");
+ return SkString("ImageSampleExplicitLod");
case SpvOpImageSampleDrefImplicitLod:
- return String("ImageSampleDrefImplicitLod");
+ return SkString("ImageSampleDrefImplicitLod");
case SpvOpImageSampleDrefExplicitLod:
- return String("ImageSampleDrefExplicitLod");
+ return SkString("ImageSampleDrefExplicitLod");
case SpvOpImageSampleProjImplicitLod:
- return String("ImageSampleProjImplicitLod");
+ return SkString("ImageSampleProjImplicitLod");
case SpvOpImageSampleProjExplicitLod:
- return String("ImageSampleProjExplicitLod");
+ return SkString("ImageSampleProjExplicitLod");
case SpvOpImageSampleProjDrefImplicitLod:
- return String("ImageSampleProjDrefImplicitLod");
+ return SkString("ImageSampleProjDrefImplicitLod");
case SpvOpImageSampleProjDrefExplicitLod:
- return String("ImageSampleProjDrefExplicitLod");
+ return SkString("ImageSampleProjDrefExplicitLod");
case SpvOpImageFetch:
- return String("ImageFetch");
+ return SkString("ImageFetch");
case SpvOpImageGather:
- return String("ImageGather");
+ return SkString("ImageGather");
case SpvOpImageDrefGather:
- return String("ImageDrefGather");
+ return SkString("ImageDrefGather");
case SpvOpImageRead:
- return String("ImageRead");
+ return SkString("ImageRead");
case SpvOpImageWrite:
- return String("ImageWrite");
+ return SkString("ImageWrite");
case SpvOpImage:
- return String("Image");
+ return SkString("Image");
case SpvOpImageQueryFormat:
- return String("ImageQueryFormat");
+ return SkString("ImageQueryFormat");
case SpvOpImageQueryOrder:
- return String("ImageQueryOrder");
+ return SkString("ImageQueryOrder");
case SpvOpImageQuerySizeLod:
- return String("ImageQuerySizeLod");
+ return SkString("ImageQuerySizeLod");
case SpvOpImageQuerySize:
- return String("ImageQuerySize");
+ return SkString("ImageQuerySize");
case SpvOpImageQueryLod:
- return String("ImageQueryLod");
+ return SkString("ImageQueryLod");
case SpvOpImageQueryLevels:
- return String("ImageQueryLevels");
+ return SkString("ImageQueryLevels");
case SpvOpImageQuerySamples:
- return String("ImageQuerySamples");
+ return SkString("ImageQuerySamples");
case SpvOpConvertFToU:
- return String("ConvertFToU");
+ return SkString("ConvertFToU");
case SpvOpConvertFToS:
- return String("ConvertFToS");
+ return SkString("ConvertFToS");
case SpvOpConvertSToF:
- return String("ConvertSToF");
+ return SkString("ConvertSToF");
case SpvOpConvertUToF:
- return String("ConvertUToF");
+ return SkString("ConvertUToF");
case SpvOpUConvert:
- return String("UConvert");
+ return SkString("UConvert");
case SpvOpSConvert:
- return String("SConvert");
+ return SkString("SConvert");
case SpvOpFConvert:
- return String("FConvert");
+ return SkString("FConvert");
case SpvOpQuantizeToF16:
- return String("QuantizeToF16");
+ return SkString("QuantizeToF16");
case SpvOpConvertPtrToU:
- return String("ConvertPtrToU");
+ return SkString("ConvertPtrToU");
case SpvOpSatConvertSToU:
- return String("SatConvertSToU");
+ return SkString("SatConvertSToU");
case SpvOpSatConvertUToS:
- return String("SatConvertUToS");
+ return SkString("SatConvertUToS");
case SpvOpConvertUToPtr:
- return String("ConvertUToPtr");
+ return SkString("ConvertUToPtr");
case SpvOpPtrCastToGeneric:
- return String("PtrCastToGeneric");
+ return SkString("PtrCastToGeneric");
case SpvOpGenericCastToPtr:
- return String("GenericCastToPtr");
+ return SkString("GenericCastToPtr");
case SpvOpGenericCastToPtrExplicit:
- return String("GenericCastToPtrExplicit");
+ return SkString("GenericCastToPtrExplicit");
case SpvOpBitcast:
- return String("Bitcast");
+ return SkString("Bitcast");
case SpvOpSNegate:
- return String("SNegate");
+ return SkString("SNegate");
case SpvOpFNegate:
- return String("FNegate");
+ return SkString("FNegate");
case SpvOpIAdd:
- return String("IAdd");
+ return SkString("IAdd");
case SpvOpFAdd:
- return String("FAdd");
+ return SkString("FAdd");
case SpvOpISub:
- return String("ISub");
+ return SkString("ISub");
case SpvOpFSub:
- return String("FSub");
+ return SkString("FSub");
case SpvOpIMul:
- return String("IMul");
+ return SkString("IMul");
case SpvOpFMul:
- return String("FMul");
+ return SkString("FMul");
case SpvOpUDiv:
- return String("UDiv");
+ return SkString("UDiv");
case SpvOpSDiv:
- return String("SDiv");
+ return SkString("SDiv");
case SpvOpFDiv:
- return String("FDiv");
+ return SkString("FDiv");
case SpvOpUMod:
- return String("UMod");
+ return SkString("UMod");
case SpvOpSRem:
- return String("SRem");
+ return SkString("SRem");
case SpvOpSMod:
- return String("SMod");
+ return SkString("SMod");
case SpvOpFRem:
- return String("FRem");
+ return SkString("FRem");
case SpvOpFMod:
- return String("FMod");
+ return SkString("FMod");
case SpvOpVectorTimesScalar:
- return String("VectorTimesScalar");
+ return SkString("VectorTimesScalar");
case SpvOpMatrixTimesScalar:
- return String("MatrixTimesScalar");
+ return SkString("MatrixTimesScalar");
case SpvOpVectorTimesMatrix:
- return String("VectorTimesMatrix");
+ return SkString("VectorTimesMatrix");
case SpvOpMatrixTimesVector:
- return String("MatrixTimesVector");
+ return SkString("MatrixTimesVector");
case SpvOpMatrixTimesMatrix:
- return String("MatrixTimesMatrix");
+ return SkString("MatrixTimesMatrix");
case SpvOpOuterProduct:
- return String("OuterProduct");
+ return SkString("OuterProduct");
case SpvOpDot:
- return String("Dot");
+ return SkString("Dot");
case SpvOpIAddCarry:
- return String("IAddCarry");
+ return SkString("IAddCarry");
case SpvOpISubBorrow:
- return String("ISubBorrow");
+ return SkString("ISubBorrow");
case SpvOpUMulExtended:
- return String("UMulExtended");
+ return SkString("UMulExtended");
case SpvOpSMulExtended:
- return String("SMulExtended");
+ return SkString("SMulExtended");
case SpvOpAny:
- return String("Any");
+ return SkString("Any");
case SpvOpAll:
- return String("All");
+ return SkString("All");
case SpvOpIsNan:
- return String("IsNan");
+ return SkString("IsNan");
case SpvOpIsInf:
- return String("IsInf");
+ return SkString("IsInf");
case SpvOpIsFinite:
- return String("IsFinite");
+ return SkString("IsFinite");
case SpvOpIsNormal:
- return String("IsNormal");
+ return SkString("IsNormal");
case SpvOpSignBitSet:
- return String("SignBitSet");
+ return SkString("SignBitSet");
case SpvOpLessOrGreater:
- return String("LessOrGreater");
+ return SkString("LessOrGreater");
case SpvOpOrdered:
- return String("Ordered");
+ return SkString("Ordered");
case SpvOpUnordered:
- return String("Unordered");
+ return SkString("Unordered");
case SpvOpLogicalEqual:
- return String("LogicalEqual");
+ return SkString("LogicalEqual");
case SpvOpLogicalNotEqual:
- return String("LogicalNotEqual");
+ return SkString("LogicalNotEqual");
case SpvOpLogicalOr:
- return String("LogicalOr");
+ return SkString("LogicalOr");
case SpvOpLogicalAnd:
- return String("LogicalAnd");
+ return SkString("LogicalAnd");
case SpvOpLogicalNot:
- return String("LogicalNot");
+ return SkString("LogicalNot");
case SpvOpSelect:
- return String("Select");
+ return SkString("Select");
case SpvOpIEqual:
- return String("IEqual");
+ return SkString("IEqual");
case SpvOpINotEqual:
- return String("INotEqual");
+ return SkString("INotEqual");
case SpvOpUGreaterThan:
- return String("UGreaterThan");
+ return SkString("UGreaterThan");
case SpvOpSGreaterThan:
- return String("SGreaterThan");
+ return SkString("SGreaterThan");
case SpvOpUGreaterThanEqual:
- return String("UGreaterThanEqual");
+ return SkString("UGreaterThanEqual");
case SpvOpSGreaterThanEqual:
- return String("SGreaterThanEqual");
+ return SkString("SGreaterThanEqual");
case SpvOpULessThan:
- return String("ULessThan");
+ return SkString("ULessThan");
case SpvOpSLessThan:
- return String("SLessThan");
+ return SkString("SLessThan");
case SpvOpULessThanEqual:
- return String("ULessThanEqual");
+ return SkString("ULessThanEqual");
case SpvOpSLessThanEqual:
- return String("SLessThanEqual");
+ return SkString("SLessThanEqual");
case SpvOpFOrdEqual:
- return String("FOrdEqual");
+ return SkString("FOrdEqual");
case SpvOpFUnordEqual:
- return String("FUnordEqual");
+ return SkString("FUnordEqual");
case SpvOpFOrdNotEqual:
- return String("FOrdNotEqual");
+ return SkString("FOrdNotEqual");
case SpvOpFUnordNotEqual:
- return String("FUnordNotEqual");
+ return SkString("FUnordNotEqual");
case SpvOpFOrdLessThan:
- return String("FOrdLessThan");
+ return SkString("FOrdLessThan");
case SpvOpFUnordLessThan:
- return String("FUnordLessThan");
+ return SkString("FUnordLessThan");
case SpvOpFOrdGreaterThan:
- return String("FOrdGreaterThan");
+ return SkString("FOrdGreaterThan");
case SpvOpFUnordGreaterThan:
- return String("FUnordGreaterThan");
+ return SkString("FUnordGreaterThan");
case SpvOpFOrdLessThanEqual:
- return String("FOrdLessThanEqual");
+ return SkString("FOrdLessThanEqual");
case SpvOpFUnordLessThanEqual:
- return String("FUnordLessThanEqual");
+ return SkString("FUnordLessThanEqual");
case SpvOpFOrdGreaterThanEqual:
- return String("FOrdGreaterThanEqual");
+ return SkString("FOrdGreaterThanEqual");
case SpvOpFUnordGreaterThanEqual:
- return String("FUnordGreaterThanEqual");
+ return SkString("FUnordGreaterThanEqual");
case SpvOpShiftRightLogical:
- return String("ShiftRightLogical");
+ return SkString("ShiftRightLogical");
case SpvOpShiftRightArithmetic:
- return String("ShiftRightArithmetic");
+ return SkString("ShiftRightArithmetic");
case SpvOpShiftLeftLogical:
- return String("ShiftLeftLogical");
+ return SkString("ShiftLeftLogical");
case SpvOpBitwiseOr:
- return String("BitwiseOr");
+ return SkString("BitwiseOr");
case SpvOpBitwiseXor:
- return String("BitwiseXor");
+ return SkString("BitwiseXor");
case SpvOpBitwiseAnd:
- return String("BitwiseAnd");
+ return SkString("BitwiseAnd");
case SpvOpNot:
- return String("Not");
+ return SkString("Not");
case SpvOpBitFieldInsert:
- return String("BitFieldInsert");
+ return SkString("BitFieldInsert");
case SpvOpBitFieldSExtract:
- return String("BitFieldSExtract");
+ return SkString("BitFieldSExtract");
case SpvOpBitFieldUExtract:
- return String("BitFieldUExtract");
+ return SkString("BitFieldUExtract");
case SpvOpBitReverse:
- return String("BitReverse");
+ return SkString("BitReverse");
case SpvOpBitCount:
- return String("BitCount");
+ return SkString("BitCount");
case SpvOpDPdx:
- return String("DPdx");
+ return SkString("DPdx");
case SpvOpDPdy:
- return String("DPdy");
+ return SkString("DPdy");
case SpvOpFwidth:
- return String("Fwidth");
+ return SkString("Fwidth");
case SpvOpDPdxFine:
- return String("DPdxFine");
+ return SkString("DPdxFine");
case SpvOpDPdyFine:
- return String("DPdyFine");
+ return SkString("DPdyFine");
case SpvOpFwidthFine:
- return String("FwidthFine");
+ return SkString("FwidthFine");
case SpvOpDPdxCoarse:
- return String("DPdxCoarse");
+ return SkString("DPdxCoarse");
case SpvOpDPdyCoarse:
- return String("DPdyCoarse");
+ return SkString("DPdyCoarse");
case SpvOpFwidthCoarse:
- return String("FwidthCoarse");
+ return SkString("FwidthCoarse");
case SpvOpEmitVertex:
- return String("EmitVertex");
+ return SkString("EmitVertex");
case SpvOpEndPrimitive:
- return String("EndPrimitive");
+ return SkString("EndPrimitive");
case SpvOpEmitStreamVertex:
- return String("EmitStreamVertex");
+ return SkString("EmitStreamVertex");
case SpvOpEndStreamPrimitive:
- return String("EndStreamPrimitive");
+ return SkString("EndStreamPrimitive");
case SpvOpControlBarrier:
- return String("ControlBarrier");
+ return SkString("ControlBarrier");
case SpvOpMemoryBarrier:
- return String("MemoryBarrier");
+ return SkString("MemoryBarrier");
case SpvOpAtomicLoad:
- return String("AtomicLoad");
+ return SkString("AtomicLoad");
case SpvOpAtomicStore:
- return String("AtomicStore");
+ return SkString("AtomicStore");
case SpvOpAtomicExchange:
- return String("AtomicExchange");
+ return SkString("AtomicExchange");
case SpvOpAtomicCompareExchange:
- return String("AtomicCompareExchange");
+ return SkString("AtomicCompareExchange");
case SpvOpAtomicCompareExchangeWeak:
- return String("AtomicCompareExchangeWeak");
+ return SkString("AtomicCompareExchangeWeak");
case SpvOpAtomicIIncrement:
- return String("AtomicIIncrement");
+ return SkString("AtomicIIncrement");
case SpvOpAtomicIDecrement:
- return String("AtomicIDecrement");
+ return SkString("AtomicIDecrement");
case SpvOpAtomicIAdd:
- return String("AtomicIAdd");
+ return SkString("AtomicIAdd");
case SpvOpAtomicISub:
- return String("AtomicISub");
+ return SkString("AtomicISub");
case SpvOpAtomicSMin:
- return String("AtomicSMin");
+ return SkString("AtomicSMin");
case SpvOpAtomicUMin:
- return String("AtomicUMin");
+ return SkString("AtomicUMin");
case SpvOpAtomicSMax:
- return String("AtomicSMax");
+ return SkString("AtomicSMax");
case SpvOpAtomicUMax:
- return String("AtomicUMax");
+ return SkString("AtomicUMax");
case SpvOpAtomicAnd:
- return String("AtomicAnd");
+ return SkString("AtomicAnd");
case SpvOpAtomicOr:
- return String("AtomicOr");
+ return SkString("AtomicOr");
case SpvOpAtomicXor:
- return String("AtomicXor");
+ return SkString("AtomicXor");
case SpvOpPhi:
- return String("Phi");
+ return SkString("Phi");
case SpvOpLoopMerge:
- return String("LoopMerge");
+ return SkString("LoopMerge");
case SpvOpSelectionMerge:
- return String("SelectionMerge");
+ return SkString("SelectionMerge");
case SpvOpLabel:
- return String("Label");
+ return SkString("Label");
case SpvOpBranch:
- return String("Branch");
+ return SkString("Branch");
case SpvOpBranchConditional:
- return String("BranchConditional");
+ return SkString("BranchConditional");
case SpvOpSwitch:
- return String("Switch");
+ return SkString("Switch");
case SpvOpKill:
- return String("Kill");
+ return SkString("Kill");
case SpvOpReturn:
- return String("Return");
+ return SkString("Return");
case SpvOpReturnValue:
- return String("ReturnValue");
+ return SkString("ReturnValue");
case SpvOpUnreachable:
- return String("Unreachable");
+ return SkString("Unreachable");
case SpvOpLifetimeStart:
- return String("LifetimeStart");
+ return SkString("LifetimeStart");
case SpvOpLifetimeStop:
- return String("LifetimeStop");
+ return SkString("LifetimeStop");
case SpvOpGroupAsyncCopy:
- return String("GroupAsyncCopy");
+ return SkString("GroupAsyncCopy");
case SpvOpGroupWaitEvents:
- return String("GroupWaitEvents");
+ return SkString("GroupWaitEvents");
case SpvOpGroupAll:
- return String("GroupAll");
+ return SkString("GroupAll");
case SpvOpGroupAny:
- return String("GroupAny");
+ return SkString("GroupAny");
case SpvOpGroupBroadcast:
- return String("GroupBroadcast");
+ return SkString("GroupBroadcast");
case SpvOpGroupIAdd:
- return String("GroupIAdd");
+ return SkString("GroupIAdd");
case SpvOpGroupFAdd:
- return String("GroupFAdd");
+ return SkString("GroupFAdd");
case SpvOpGroupFMin:
- return String("GroupFMin");
+ return SkString("GroupFMin");
case SpvOpGroupUMin:
- return String("GroupUMin");
+ return SkString("GroupUMin");
case SpvOpGroupSMin:
- return String("GroupSMin");
+ return SkString("GroupSMin");
case SpvOpGroupFMax:
- return String("GroupFMax");
+ return SkString("GroupFMax");
case SpvOpGroupUMax:
- return String("GroupUMax");
+ return SkString("GroupUMax");
case SpvOpGroupSMax:
- return String("GroupSMax");
+ return SkString("GroupSMax");
case SpvOpReadPipe:
- return String("ReadPipe");
+ return SkString("ReadPipe");
case SpvOpWritePipe:
- return String("WritePipe");
+ return SkString("WritePipe");
case SpvOpReservedReadPipe:
- return String("ReservedReadPipe");
+ return SkString("ReservedReadPipe");
case SpvOpReservedWritePipe:
- return String("ReservedWritePipe");
+ return SkString("ReservedWritePipe");
case SpvOpReserveReadPipePackets:
- return String("ReserveReadPipePackets");
+ return SkString("ReserveReadPipePackets");
case SpvOpReserveWritePipePackets:
- return String("ReserveWritePipePackets");
+ return SkString("ReserveWritePipePackets");
case SpvOpCommitReadPipe:
- return String("CommitReadPipe");
+ return SkString("CommitReadPipe");
case SpvOpCommitWritePipe:
- return String("CommitWritePipe");
+ return SkString("CommitWritePipe");
case SpvOpIsValidReserveId:
- return String("IsValidReserveId");
+ return SkString("IsValidReserveId");
case SpvOpGetNumPipePackets:
- return String("GetNumPipePackets");
+ return SkString("GetNumPipePackets");
case SpvOpGetMaxPipePackets:
- return String("GetMaxPipePackets");
+ return SkString("GetMaxPipePackets");
case SpvOpGroupReserveReadPipePackets:
- return String("GroupReserveReadPipePackets");
+ return SkString("GroupReserveReadPipePackets");
case SpvOpGroupReserveWritePipePackets:
- return String("GroupReserveWritePipePackets");
+ return SkString("GroupReserveWritePipePackets");
case SpvOpGroupCommitReadPipe:
- return String("GroupCommitReadPipe");
+ return SkString("GroupCommitReadPipe");
case SpvOpGroupCommitWritePipe:
- return String("GroupCommitWritePipe");
+ return SkString("GroupCommitWritePipe");
case SpvOpEnqueueMarker:
- return String("EnqueueMarker");
+ return SkString("EnqueueMarker");
case SpvOpEnqueueKernel:
- return String("EnqueueKernel");
+ return SkString("EnqueueKernel");
case SpvOpGetKernelNDrangeSubGroupCount:
- return String("GetKernelNDrangeSubGroupCount");
+ return SkString("GetKernelNDrangeSubGroupCount");
case SpvOpGetKernelNDrangeMaxSubGroupSize:
- return String("GetKernelNDrangeMaxSubGroupSize");
+ return SkString("GetKernelNDrangeMaxSubGroupSize");
case SpvOpGetKernelWorkGroupSize:
- return String("GetKernelWorkGroupSize");
+ return SkString("GetKernelWorkGroupSize");
case SpvOpGetKernelPreferredWorkGroupSizeMultiple:
- return String("GetKernelPreferredWorkGroupSizeMultiple");
+ return SkString("GetKernelPreferredWorkGroupSizeMultiple");
case SpvOpRetainEvent:
- return String("RetainEvent");
+ return SkString("RetainEvent");
case SpvOpReleaseEvent:
- return String("ReleaseEvent");
+ return SkString("ReleaseEvent");
case SpvOpCreateUserEvent:
- return String("CreateUserEvent");
+ return SkString("CreateUserEvent");
case SpvOpIsValidEvent:
- return String("IsValidEvent");
+ return SkString("IsValidEvent");
case SpvOpSetUserEventStatus:
- return String("SetUserEventStatus");
+ return SkString("SetUserEventStatus");
case SpvOpCaptureEventProfilingInfo:
- return String("CaptureEventProfilingInfo");
+ return SkString("CaptureEventProfilingInfo");
case SpvOpGetDefaultQueue:
- return String("GetDefaultQueue");
+ return SkString("GetDefaultQueue");
case SpvOpBuildNDRange:
- return String("BuildNDRange");
+ return SkString("BuildNDRange");
case SpvOpImageSparseSampleImplicitLod:
- return String("ImageSparseSampleImplicitLod");
+ return SkString("ImageSparseSampleImplicitLod");
case SpvOpImageSparseSampleExplicitLod:
- return String("ImageSparseSampleExplicitLod");
+ return SkString("ImageSparseSampleExplicitLod");
case SpvOpImageSparseSampleDrefImplicitLod:
- return String("ImageSparseSampleDrefImplicitLod");
+ return SkString("ImageSparseSampleDrefImplicitLod");
case SpvOpImageSparseSampleDrefExplicitLod:
- return String("ImageSparseSampleDrefExplicitLod");
+ return SkString("ImageSparseSampleDrefExplicitLod");
case SpvOpImageSparseSampleProjImplicitLod:
- return String("ImageSparseSampleProjImplicitLod");
+ return SkString("ImageSparseSampleProjImplicitLod");
case SpvOpImageSparseSampleProjExplicitLod:
- return String("ImageSparseSampleProjExplicitLod");
+ return SkString("ImageSparseSampleProjExplicitLod");
case SpvOpImageSparseSampleProjDrefImplicitLod:
- return String("ImageSparseSampleProjDrefImplicitLod");
+ return SkString("ImageSparseSampleProjDrefImplicitLod");
case SpvOpImageSparseSampleProjDrefExplicitLod:
- return String("ImageSparseSampleProjDrefExplicitLod");
+ return SkString("ImageSparseSampleProjDrefExplicitLod");
case SpvOpImageSparseFetch:
- return String("ImageSparseFetch");
+ return SkString("ImageSparseFetch");
case SpvOpImageSparseGather:
- return String("ImageSparseGather");
+ return SkString("ImageSparseGather");
case SpvOpImageSparseDrefGather:
- return String("ImageSparseDrefGather");
+ return SkString("ImageSparseDrefGather");
case SpvOpImageSparseTexelsResident:
- return String("ImageSparseTexelsResident");
+ return SkString("ImageSparseTexelsResident");
case SpvOpNoLine:
- return String("NoLine");
+ return SkString("NoLine");
case SpvOpAtomicFlagTestAndSet:
- return String("AtomicFlagTestAndSet");
+ return SkString("AtomicFlagTestAndSet");
case SpvOpAtomicFlagClear:
- return String("AtomicFlagClear");
+ return SkString("AtomicFlagClear");
case SpvOpImageSparseRead:
- return String("ImageSparseRead");
+ return SkString("ImageSparseRead");
default:
- ABORT("unsupported SPIR-V op");
+ ABORT("unsupported SPIR-V op");
}
}
#endif
-void SPIRVCodeGenerator::writeOpCode(SpvOp_ opCode, int length, OutputStream& out) {
+void SPIRVCodeGenerator::writeOpCode(SpvOp_ opCode, int length, SkWStream& out) {
ASSERT(opCode != SpvOpUndef);
switch (opCode) {
case SpvOpReturn: // fall through
@@ -828,23 +830,23 @@ void SPIRVCodeGenerator::writeOpCode(SpvOp_ opCode, int length, OutputStream& ou
#endif
}
-void SPIRVCodeGenerator::writeLabel(SpvId label, OutputStream& out) {
+void SPIRVCodeGenerator::writeLabel(SpvId label, SkWStream& out) {
fCurrentBlock = label;
this->writeInstruction(SpvOpLabel, label, out);
}
-void SPIRVCodeGenerator::writeInstruction(SpvOp_ opCode, OutputStream& out) {
+void SPIRVCodeGenerator::writeInstruction(SpvOp_ opCode, SkWStream& out) {
this->writeOpCode(opCode, 1, out);
}
-void SPIRVCodeGenerator::writeInstruction(SpvOp_ opCode, int32_t word1, OutputStream& out) {
+void SPIRVCodeGenerator::writeInstruction(SpvOp_ opCode, int32_t word1, SkWStream& out) {
this->writeOpCode(opCode, 2, out);
this->writeWord(word1, out);
}
-void SPIRVCodeGenerator::writeString(const char* string, OutputStream& out) {
+void SPIRVCodeGenerator::writeString(const char* string, SkWStream& out) {
size_t length = strlen(string);
- out.write(string, length);
+ out.writeText(string);
switch (length % 4) {
case 1:
out.write8(0);
@@ -860,7 +862,7 @@ void SPIRVCodeGenerator::writeString(const char* string, OutputStream& out) {
}
}
-void SPIRVCodeGenerator::writeInstruction(SpvOp_ opCode, const char* string, OutputStream& out) {
+void SPIRVCodeGenerator::writeInstruction(SpvOp_ opCode, const char* string, SkWStream& out) {
int32_t length = (int32_t) strlen(string);
this->writeOpCode(opCode, 1 + (length + 4) / 4, out);
this->writeString(string, out);
@@ -868,7 +870,7 @@ void SPIRVCodeGenerator::writeInstruction(SpvOp_ opCode, const char* string, Out
void SPIRVCodeGenerator::writeInstruction(SpvOp_ opCode, int32_t word1, const char* string,
- OutputStream& out) {
+ SkWStream& out) {
int32_t length = (int32_t) strlen(string);
this->writeOpCode(opCode, 2 + (length + 4) / 4, out);
this->writeWord(word1, out);
@@ -876,7 +878,7 @@ void SPIRVCodeGenerator::writeInstruction(SpvOp_ opCode, int32_t word1, const ch
}
void SPIRVCodeGenerator::writeInstruction(SpvOp_ opCode, int32_t word1, int32_t word2,
- const char* string, OutputStream& out) {
+ const char* string, SkWStream& out) {
int32_t length = (int32_t) strlen(string);
this->writeOpCode(opCode, 3 + (length + 4) / 4, out);
this->writeWord(word1, out);
@@ -885,14 +887,14 @@ void SPIRVCodeGenerator::writeInstruction(SpvOp_ opCode, int32_t word1, int32_t
}
void SPIRVCodeGenerator::writeInstruction(SpvOp_ opCode, int32_t word1, int32_t word2,
- OutputStream& out) {
+ SkWStream& out) {
this->writeOpCode(opCode, 3, out);
this->writeWord(word1, out);
this->writeWord(word2, out);
}
void SPIRVCodeGenerator::writeInstruction(SpvOp_ opCode, int32_t word1, int32_t word2,
- int32_t word3, OutputStream& out) {
+ int32_t word3, SkWStream& out) {
this->writeOpCode(opCode, 4, out);
this->writeWord(word1, out);
this->writeWord(word2, out);
@@ -900,7 +902,7 @@ void SPIRVCodeGenerator::writeInstruction(SpvOp_ opCode, int32_t word1, int32_t
}
void SPIRVCodeGenerator::writeInstruction(SpvOp_ opCode, int32_t word1, int32_t word2,
- int32_t word3, int32_t word4, OutputStream& out) {
+ int32_t word3, int32_t word4, SkWStream& out) {
this->writeOpCode(opCode, 5, out);
this->writeWord(word1, out);
this->writeWord(word2, out);
@@ -910,7 +912,7 @@ void SPIRVCodeGenerator::writeInstruction(SpvOp_ opCode, int32_t word1, int32_t
void SPIRVCodeGenerator::writeInstruction(SpvOp_ opCode, int32_t word1, int32_t word2,
int32_t word3, int32_t word4, int32_t word5,
- OutputStream& out) {
+ SkWStream& out) {
this->writeOpCode(opCode, 6, out);
this->writeWord(word1, out);
this->writeWord(word2, out);
@@ -921,7 +923,7 @@ void SPIRVCodeGenerator::writeInstruction(SpvOp_ opCode, int32_t word1, int32_t
void SPIRVCodeGenerator::writeInstruction(SpvOp_ opCode, int32_t word1, int32_t word2,
int32_t word3, int32_t word4, int32_t word5,
- int32_t word6, OutputStream& out) {
+ int32_t word6, SkWStream& out) {
this->writeOpCode(opCode, 7, out);
this->writeWord(word1, out);
this->writeWord(word2, out);
@@ -933,7 +935,7 @@ void SPIRVCodeGenerator::writeInstruction(SpvOp_ opCode, int32_t word1, int32_t
void SPIRVCodeGenerator::writeInstruction(SpvOp_ opCode, int32_t word1, int32_t word2,
int32_t word3, int32_t word4, int32_t word5,
- int32_t word6, int32_t word7, OutputStream& out) {
+ int32_t word6, int32_t word7, SkWStream& out) {
this->writeOpCode(opCode, 8, out);
this->writeWord(word1, out);
this->writeWord(word2, out);
@@ -947,7 +949,7 @@ void SPIRVCodeGenerator::writeInstruction(SpvOp_ opCode, int32_t word1, int32_t
void SPIRVCodeGenerator::writeInstruction(SpvOp_ opCode, int32_t word1, int32_t word2,
int32_t word3, int32_t word4, int32_t word5,
int32_t word6, int32_t word7, int32_t word8,
- OutputStream& out) {
+ SkWStream& out) {
this->writeOpCode(opCode, 9, out);
this->writeWord(word1, out);
this->writeWord(word2, out);
@@ -959,7 +961,7 @@ void SPIRVCodeGenerator::writeInstruction(SpvOp_ opCode, int32_t word1, int32_t
this->writeWord(word8, out);
}
-void SPIRVCodeGenerator::writeCapabilities(OutputStream& out) {
+void SPIRVCodeGenerator::writeCapabilities(SkWStream& out) {
for (uint64_t i = 0, bit = 1; i <= kLast_Capability; i++, bit <<= 1) {
if (fCapabilities & bit) {
this->writeInstruction(SpvOpCapability, (SpvId) i, out);
@@ -1035,7 +1037,7 @@ SpvId SPIRVCodeGenerator::getType(const Type& type) {
}
SpvId SPIRVCodeGenerator::getType(const Type& type, const MemoryLayout& layout) {
- String key = type.name() + to_string((int) layout.fStd);
+ SkString key = type.name() + to_string((int) layout.fStd);
auto entry = fTypeMap.find(key);
if (entry == fTypeMap.end()) {
SpvId result = this->nextId();
@@ -1075,7 +1077,7 @@ SpvId SPIRVCodeGenerator::getType(const Type& type, const MemoryLayout& layout)
this->getType(type.componentType(), layout),
this->writeIntLiteral(count), fConstantBuffer);
this->writeInstruction(SpvOpDecorate, result, SpvDecorationArrayStride,
- (int32_t) layout.stride(type),
+ (int32_t) layout.stride(type),
fDecorationBuffer);
} else {
ABORT("runtime-sized arrays are not yet supported");
@@ -1114,8 +1116,8 @@ SpvId SPIRVCodeGenerator::getType(const Type& type, const MemoryLayout& layout)
}
SpvId SPIRVCodeGenerator::getFunctionType(const FunctionDeclaration& function) {
- String key = function.fReturnType.description() + "(";
- String separator;
+ SkString key = function.fReturnType.description() + "(";
+ SkString separator;
for (size_t i = 0; i < function.fParameters.size(); i++) {
key += separator;
separator = ", ";
@@ -1176,7 +1178,7 @@ SpvId SPIRVCodeGenerator::getPointerType(const Type& type, SpvStorageClass_ stor
SpvId SPIRVCodeGenerator::getPointerType(const Type& type, const MemoryLayout& layout,
SpvStorageClass_ storageClass) {
- String key = type.description() + "*" + to_string(layout.fStd) + to_string(storageClass);
+ SkString key = type.description() + "*" + to_string(layout.fStd) + to_string(storageClass);
auto entry = fTypeMap.find(key);
if (entry == fTypeMap.end()) {
SpvId result = this->nextId();
@@ -1188,7 +1190,7 @@ SpvId SPIRVCodeGenerator::getPointerType(const Type& type, const MemoryLayout& l
return entry->second;
}
-SpvId SPIRVCodeGenerator::writeExpression(const Expression& expr, OutputStream& out) {
+SpvId SPIRVCodeGenerator::writeExpression(const Expression& expr, SkWStream& out) {
switch (expr.fKind) {
case Expression::kBinary_Kind:
return this->writeBinaryExpression((BinaryExpression&) expr, out);
@@ -1222,7 +1224,7 @@ SpvId SPIRVCodeGenerator::writeExpression(const Expression& expr, OutputStream&
return -1;
}
-SpvId SPIRVCodeGenerator::writeIntrinsicCall(const FunctionCall& c, OutputStream& out) {
+SpvId SPIRVCodeGenerator::writeIntrinsicCall(const FunctionCall& c, SkWStream& out) {
auto intrinsic = fIntrinsicMap.find(c.fFunction.fName);
ASSERT(intrinsic != fIntrinsicMap.end());
const Type& type = c.fArguments[0]->fType;
@@ -1278,7 +1280,7 @@ SpvId SPIRVCodeGenerator::writeIntrinsicCall(const FunctionCall& c, OutputStream
}
SpvId SPIRVCodeGenerator::writeSpecialIntrinsic(const FunctionCall& c, SpecialIntrinsic kind,
- OutputStream& out) {
+ SkWStream& out) {
SpvId result = this->nextId();
switch (kind) {
case kAtan_SpecialIntrinsic: {
@@ -1356,7 +1358,7 @@ SpvId SPIRVCodeGenerator::writeSpecialIntrinsic(const FunctionCall& c, SpecialIn
coords,
out);
} else {
- ASSERT(2 == c.fArguments.size());
+ SkASSERT(2 == c.fArguments.size());
SpvId sample = this->writeExpression(*c.fArguments[1], out);
this->writeInstruction(SpvOpImageRead,
this->getType(c.fType),
@@ -1373,7 +1375,7 @@ SpvId SPIRVCodeGenerator::writeSpecialIntrinsic(const FunctionCall& c, SpecialIn
return result;
}
-SpvId SPIRVCodeGenerator::writeFunctionCall(const FunctionCall& c, OutputStream& out) {
+SpvId SPIRVCodeGenerator::writeFunctionCall(const FunctionCall& c, SkWStream& out) {
const auto& entry = fFunctionMap.find(&c.fFunction);
if (entry == fFunctionMap.end()) {
return this->writeIntrinsicCall(c, out);
@@ -1462,7 +1464,7 @@ SpvId SPIRVCodeGenerator::writeConstantVector(const Constructor& c) {
return result;
}
-SpvId SPIRVCodeGenerator::writeFloatConstructor(const Constructor& c, OutputStream& out) {
+SpvId SPIRVCodeGenerator::writeFloatConstructor(const Constructor& c, SkWStream& out) {
ASSERT(c.fType == *fContext.fFloat_Type);
ASSERT(c.fArguments.size() == 1);
ASSERT(c.fArguments[0]->fType.isNumber());
@@ -1480,7 +1482,7 @@ SpvId SPIRVCodeGenerator::writeFloatConstructor(const Constructor& c, OutputStre
return result;
}
-SpvId SPIRVCodeGenerator::writeIntConstructor(const Constructor& c, OutputStream& out) {
+SpvId SPIRVCodeGenerator::writeIntConstructor(const Constructor& c, SkWStream& out) {
ASSERT(c.fType == *fContext.fInt_Type);
ASSERT(c.fArguments.size() == 1);
ASSERT(c.fArguments[0]->fType.isNumber());
@@ -1499,7 +1501,7 @@ SpvId SPIRVCodeGenerator::writeIntConstructor(const Constructor& c, OutputStream
}
void SPIRVCodeGenerator::writeUniformScaleMatrix(SpvId id, SpvId diagonal, const Type& type,
- OutputStream& out) {
+ SkWStream& out) {
FloatLiteral zero(fContext, Position(), 0);
SpvId zeroId = this->writeFloatLiteral(zero);
std::vector<SpvId> columnIds;
@@ -1525,11 +1527,11 @@ void SPIRVCodeGenerator::writeUniformScaleMatrix(SpvId id, SpvId diagonal, const
}
void SPIRVCodeGenerator::writeMatrixCopy(SpvId id, SpvId src, const Type& srcType,
- const Type& dstType, OutputStream& out) {
+ const Type& dstType, SkWStream& out) {
ABORT("unimplemented");
}
-SpvId SPIRVCodeGenerator::writeMatrixConstructor(const Constructor& c, OutputStream& out) {
+SpvId SPIRVCodeGenerator::writeMatrixConstructor(const Constructor& c, SkWStream& out) {
ASSERT(c.fType.kind() == Type::kMatrix_Kind);
// go ahead and write the arguments so we don't try to write new instructions in the middle of
// an instruction
@@ -1578,7 +1580,7 @@ SpvId SPIRVCodeGenerator::writeMatrixConstructor(const Constructor& c, OutputStr
return result;
}
-SpvId SPIRVCodeGenerator::writeVectorConstructor(const Constructor& c, OutputStream& out) {
+SpvId SPIRVCodeGenerator::writeVectorConstructor(const Constructor& c, SkWStream& out) {
ASSERT(c.fType.kind() == Type::kVector_Kind);
if (c.isConstant()) {
return this->writeConstantVector(c);
@@ -1608,7 +1610,7 @@ SpvId SPIRVCodeGenerator::writeVectorConstructor(const Constructor& c, OutputStr
return result;
}
-SpvId SPIRVCodeGenerator::writeConstructor(const Constructor& c, OutputStream& out) {
+SpvId SPIRVCodeGenerator::writeConstructor(const Constructor& c, SkWStream& out) {
if (c.fType == *fContext.fFloat_Type) {
return this->writeFloatConstructor(c, out);
} else if (c.fType == *fContext.fInt_Type) {
@@ -1654,7 +1656,7 @@ SpvStorageClass_ get_storage_class(const Expression& expr) {
}
}
-std::vector<SpvId> SPIRVCodeGenerator::getAccessChain(const Expression& expr, OutputStream& out) {
+std::vector<SpvId> SPIRVCodeGenerator::getAccessChain(const Expression& expr, SkWStream& out) {
std::vector<SpvId> chain;
switch (expr.fKind) {
case Expression::kIndex_Kind: {
@@ -1687,13 +1689,13 @@ public:
return fPointer;
}
- virtual SpvId load(OutputStream& out) override {
+ virtual SpvId load(SkWStream& out) override {
SpvId result = fGen.nextId();
fGen.writeInstruction(SpvOpLoad, fType, result, fPointer, out);
return result;
}
- virtual void store(SpvId value, OutputStream& out) override {
+ virtual void store(SpvId value, SkWStream& out) override {
fGen.writeInstruction(SpvOpStore, fPointer, value, out);
}
@@ -1717,7 +1719,7 @@ public:
return 0;
}
- virtual SpvId load(OutputStream& out) override {
+ virtual SpvId load(SkWStream& out) override {
SpvId base = fGen.nextId();
fGen.writeInstruction(SpvOpLoad, fGen.getType(fBaseType), base, fVecPointer, out);
SpvId result = fGen.nextId();
@@ -1732,7 +1734,7 @@ public:
return result;
}
- virtual void store(SpvId value, OutputStream& out) override {
+ virtual void store(SpvId value, SkWStream& out) override {
// use OpVectorShuffle to mix and match the vector components. We effectively create
// a virtual vector out of the concatenation of the left and right vectors, and then
// select components from this virtual vector to make the result vector. For
@@ -1779,7 +1781,7 @@ private:
};
std::unique_ptr<SPIRVCodeGenerator::LValue> SPIRVCodeGenerator::getLValue(const Expression& expr,
- OutputStream& out) {
+ SkWStream& out) {
switch (expr.fKind) {
case Expression::kVariableReference_Kind: {
const Variable& var = ((VariableReference&) expr).fVariable;
@@ -1852,7 +1854,7 @@ std::unique_ptr<SPIRVCodeGenerator::LValue> SPIRVCodeGenerator::getLValue(const
}
}
-SpvId SPIRVCodeGenerator::writeVariableReference(const VariableReference& ref, OutputStream& out) {
+SpvId SPIRVCodeGenerator::writeVariableReference(const VariableReference& ref, SkWStream& out) {
SpvId result = this->nextId();
auto entry = fVariableMap.find(&ref.fVariable);
ASSERT(entry != fVariableMap.end());
@@ -1866,16 +1868,15 @@ SpvId SPIRVCodeGenerator::writeVariableReference(const VariableReference& ref, O
std::shared_ptr<SymbolTable> st(new SymbolTable(fErrors));
ASSERT(fRTHeightFieldIndex == (SpvId) -1);
std::vector<Type::Field> fields;
- fields.emplace_back(Modifiers(), String(SKSL_RTHEIGHT_NAME),
+ fields.emplace_back(Modifiers(), SkString(SKSL_RTHEIGHT_NAME),
fContext.fFloat_Type.get());
- String name("sksl_synthetic_uniforms");
+ SkString name("sksl_synthetic_uniforms");
Type intfStruct(Position(), name, fields);
- Layout layout(-1, -1, 1, -1, -1, -1, -1, false, false, false,
- Layout::Format::kUnspecified, false, Layout::kUnspecified_Primitive, -1,
- -1);
+ Layout layout(-1, -1, 1, -1, -1, -1, -1, false, false, false, Layout::Format::kUnspecified,
+ false, Layout::kUnspecified_Primitive, -1, -1);
Variable intfVar(Position(), Modifiers(layout, Modifiers::kUniform_Flag), name,
intfStruct, Variable::kGlobal_Storage);
- InterfaceBlock intf(Position(), intfVar, name, String(""),
+ InterfaceBlock intf(Position(), intfVar, name, SkString(""),
std::vector<std::unique_ptr<Expression>>(), st);
fRTHeightStructId = this->writeInterfaceBlock(intf);
fRTHeightFieldIndex = 0;
@@ -1919,15 +1920,15 @@ SpvId SPIRVCodeGenerator::writeVariableReference(const VariableReference& ref, O
return result;
}
-SpvId SPIRVCodeGenerator::writeIndexExpression(const IndexExpression& expr, OutputStream& out) {
+SpvId SPIRVCodeGenerator::writeIndexExpression(const IndexExpression& expr, SkWStream& out) {
return getLValue(expr, out)->load(out);
}
-SpvId SPIRVCodeGenerator::writeFieldAccess(const FieldAccess& f, OutputStream& out) {
+SpvId SPIRVCodeGenerator::writeFieldAccess(const FieldAccess& f, SkWStream& out) {
return getLValue(f, out)->load(out);
}
-SpvId SPIRVCodeGenerator::writeSwizzle(const Swizzle& swizzle, OutputStream& out) {
+SpvId SPIRVCodeGenerator::writeSwizzle(const Swizzle& swizzle, SkWStream& out) {
SpvId base = this->writeExpression(*swizzle.fBase, out);
SpvId result = this->nextId();
size_t count = swizzle.fComponents.size();
@@ -1950,7 +1951,7 @@ SpvId SPIRVCodeGenerator::writeSwizzle(const Swizzle& swizzle, OutputStream& out
SpvId SPIRVCodeGenerator::writeBinaryOperation(const Type& resultType,
const Type& operandType, SpvId lhs,
SpvId rhs, SpvOp_ ifFloat, SpvOp_ ifInt,
- SpvOp_ ifUInt, SpvOp_ ifBool, OutputStream& out) {
+ SpvOp_ ifUInt, SpvOp_ ifBool, SkWStream& out) {
SpvId result = this->nextId();
if (is_float(fContext, operandType)) {
this->writeInstruction(ifFloat, this->getType(resultType), result, lhs, rhs, out);
@@ -1988,7 +1989,7 @@ bool is_assignment(Token::Kind op) {
}
}
-SpvId SPIRVCodeGenerator::foldToBool(SpvId id, const Type& operandType, OutputStream& out) {
+SpvId SPIRVCodeGenerator::foldToBool(SpvId id, const Type& operandType, SkWStream& out) {
if (operandType.kind() == Type::kVector_Kind) {
SpvId result = this->nextId();
this->writeInstruction(SpvOpAll, this->getType(*fContext.fBool_Type), result, id, out);
@@ -1997,7 +1998,7 @@ SpvId SPIRVCodeGenerator::foldToBool(SpvId id, const Type& operandType, OutputSt
return id;
}
-SpvId SPIRVCodeGenerator::writeBinaryExpression(const BinaryExpression& b, OutputStream& out) {
+SpvId SPIRVCodeGenerator::writeBinaryExpression(const BinaryExpression& b, SkWStream& out) {
// handle cases where we don't necessarily evaluate both LHS and RHS
switch (b.fOperator) {
case Token::EQ: {
@@ -2194,7 +2195,7 @@ SpvId SPIRVCodeGenerator::writeBinaryExpression(const BinaryExpression& b, Outpu
}
}
-SpvId SPIRVCodeGenerator::writeLogicalAnd(const BinaryExpression& a, OutputStream& out) {
+SpvId SPIRVCodeGenerator::writeLogicalAnd(const BinaryExpression& a, SkWStream& out) {
ASSERT(a.fOperator == Token::LOGICALAND);
BoolLiteral falseLiteral(fContext, Position(), false);
SpvId falseConstant = this->writeBoolLiteral(falseLiteral);
@@ -2215,7 +2216,7 @@ SpvId SPIRVCodeGenerator::writeLogicalAnd(const BinaryExpression& a, OutputStrea
return result;
}
-SpvId SPIRVCodeGenerator::writeLogicalOr(const BinaryExpression& o, OutputStream& out) {
+SpvId SPIRVCodeGenerator::writeLogicalOr(const BinaryExpression& o, SkWStream& out) {
ASSERT(o.fOperator == Token::LOGICALOR);
BoolLiteral trueLiteral(fContext, Position(), true);
SpvId trueConstant = this->writeBoolLiteral(trueLiteral);
@@ -2236,7 +2237,7 @@ SpvId SPIRVCodeGenerator::writeLogicalOr(const BinaryExpression& o, OutputStream
return result;
}
-SpvId SPIRVCodeGenerator::writeTernaryExpression(const TernaryExpression& t, OutputStream& out) {
+SpvId SPIRVCodeGenerator::writeTernaryExpression(const TernaryExpression& t, SkWStream& out) {
SpvId test = this->writeExpression(*t.fTest, out);
if (t.fIfTrue->isConstant() && t.fIfFalse->isConstant()) {
// both true and false are constants, can just use OpSelect
@@ -2276,11 +2277,11 @@ std::unique_ptr<Expression> create_literal_1(const Context& context, const Type&
else if (type == *context.fFloat_Type) {
return std::unique_ptr<Expression>(new FloatLiteral(context, Position(), 1.0));
} else {
- ABORT("math is unsupported on type '%s'", type.name().c_str());
+ ABORT("math is unsupported on type '%s'")
}
}
-SpvId SPIRVCodeGenerator::writePrefixExpression(const PrefixExpression& p, OutputStream& out) {
+SpvId SPIRVCodeGenerator::writePrefixExpression(const PrefixExpression& p, SkWStream& out) {
if (p.fOperator == Token::MINUS) {
SpvId result = this->nextId();
SpvId typeId = this->getType(p.fType);
@@ -2333,7 +2334,7 @@ SpvId SPIRVCodeGenerator::writePrefixExpression(const PrefixExpression& p, Outpu
}
}
-SpvId SPIRVCodeGenerator::writePostfixExpression(const PostfixExpression& p, OutputStream& out) {
+SpvId SPIRVCodeGenerator::writePostfixExpression(const PostfixExpression& p, SkWStream& out) {
std::unique_ptr<LValue> lv = this->getLValue(*p.fOperand, out);
SpvId result = lv->load(out);
SpvId one = this->writeExpression(*create_literal_1(fContext, p.fType), out);
@@ -2430,7 +2431,7 @@ SpvId SPIRVCodeGenerator::writeFloatLiteral(const FloatLiteral& f) {
}
}
-SpvId SPIRVCodeGenerator::writeFunctionStart(const FunctionDeclaration& f, OutputStream& out) {
+SpvId SPIRVCodeGenerator::writeFunctionStart(const FunctionDeclaration& f, SkWStream& out) {
SpvId result = fFunctionMap[&f];
this->writeInstruction(SpvOpFunction, this->getType(f.fReturnType), result,
SpvFunctionControlMaskNone, this->getFunctionType(f), out);
@@ -2445,16 +2446,16 @@ SpvId SPIRVCodeGenerator::writeFunctionStart(const FunctionDeclaration& f, Outpu
return result;
}
-SpvId SPIRVCodeGenerator::writeFunction(const FunctionDefinition& f, OutputStream& out) {
+SpvId SPIRVCodeGenerator::writeFunction(const FunctionDefinition& f, SkWStream& out) {
SpvId result = this->writeFunctionStart(f.fDeclaration, out);
this->writeLabel(this->nextId(), out);
if (f.fDeclaration.fName == "main") {
- write_stringstream(fGlobalInitializersBuffer, out);
+ write_data(*fGlobalInitializersBuffer.detachAsData(), out);
}
- StringStream bodyBuffer;
+ SkDynamicMemoryWStream bodyBuffer;
this->writeBlock(*f.fBody, bodyBuffer);
- write_stringstream(fVariableBuffer, out);
- write_stringstream(bodyBuffer, out);
+ write_data(*fVariableBuffer.detachAsData(), out);
+ write_data(*bodyBuffer.detachAsData(), out);
if (fCurrentBlock) {
this->writeInstruction(SpvOpReturn, out);
}
@@ -2528,7 +2529,7 @@ SpvId SPIRVCodeGenerator::writeInterfaceBlock(const InterfaceBlock& intf) {
std::vector<Type::Field> fields = type->fields();
fRTHeightStructId = result;
fRTHeightFieldIndex = fields.size();
- fields.emplace_back(Modifiers(), String(SKSL_RTHEIGHT_NAME), fContext.fFloat_Type.get());
+ fields.emplace_back(Modifiers(), SkString(SKSL_RTHEIGHT_NAME), fContext.fFloat_Type.get());
type = new Type(type->fPosition, type->name(), fields);
}
SpvId typeId = this->getType(*type, layout);
@@ -2547,7 +2548,7 @@ SpvId SPIRVCodeGenerator::writeInterfaceBlock(const InterfaceBlock& intf) {
#define BUILTIN_IGNORE 9999
void SPIRVCodeGenerator::writeGlobalVars(Program::Kind kind, const VarDeclarations& decl,
- OutputStream& out) {
+ SkWStream& out) {
for (size_t i = 0; i < decl.fVars.size(); i++) {
const VarDeclaration& varDecl = decl.fVars[i];
const Variable* var = varDecl.fVar;
@@ -2609,7 +2610,7 @@ void SPIRVCodeGenerator::writeGlobalVars(Program::Kind kind, const VarDeclaratio
}
}
-void SPIRVCodeGenerator::writeVarDeclarations(const VarDeclarations& decl, OutputStream& out) {
+void SPIRVCodeGenerator::writeVarDeclarations(const VarDeclarations& decl, SkWStream& out) {
for (const auto& varDecl : decl.fVars) {
const Variable* var = varDecl.fVar;
// These haven't been implemented in our SPIR-V generator yet and we only currently use them
@@ -2631,7 +2632,7 @@ void SPIRVCodeGenerator::writeVarDeclarations(const VarDeclarations& decl, Outpu
}
}
-void SPIRVCodeGenerator::writeStatement(const Statement& s, OutputStream& out) {
+void SPIRVCodeGenerator::writeStatement(const Statement& s, SkWStream& out) {
switch (s.fKind) {
case Statement::kBlock_Kind:
this->writeBlock((Block&) s, out);
@@ -2671,13 +2672,13 @@ void SPIRVCodeGenerator::writeStatement(const Statement& s, OutputStream& out) {
}
}
-void SPIRVCodeGenerator::writeBlock(const Block& b, OutputStream& out) {
+void SPIRVCodeGenerator::writeBlock(const Block& b, SkWStream& out) {
for (size_t i = 0; i < b.fStatements.size(); i++) {
this->writeStatement(*b.fStatements[i], out);
}
}
-void SPIRVCodeGenerator::writeIfStatement(const IfStatement& stmt, OutputStream& out) {
+void SPIRVCodeGenerator::writeIfStatement(const IfStatement& stmt, SkWStream& out) {
SpvId test = this->writeExpression(*stmt.fTest, out);
SpvId ifTrue = this->nextId();
SpvId ifFalse = this->nextId();
@@ -2708,7 +2709,7 @@ void SPIRVCodeGenerator::writeIfStatement(const IfStatement& stmt, OutputStream&
}
}
-void SPIRVCodeGenerator::writeForStatement(const ForStatement& f, OutputStream& out) {
+void SPIRVCodeGenerator::writeForStatement(const ForStatement& f, SkWStream& out) {
if (f.fInitializer) {
this->writeStatement(*f.fInitializer, out);
}
@@ -2743,7 +2744,7 @@ void SPIRVCodeGenerator::writeForStatement(const ForStatement& f, OutputStream&
fContinueTarget.pop();
}
-void SPIRVCodeGenerator::writeWhileStatement(const WhileStatement& w, OutputStream& out) {
+void SPIRVCodeGenerator::writeWhileStatement(const WhileStatement& w, SkWStream& out) {
// We believe the while loop code below will work, but Skia doesn't actually use them and
// adequately testing this code in the absence of Skia exercising it isn't straightforward. For
// the time being, we just fail with an error due to the lack of testing. If you encounter this
@@ -2775,7 +2776,7 @@ void SPIRVCodeGenerator::writeWhileStatement(const WhileStatement& w, OutputStre
fContinueTarget.pop();
}
-void SPIRVCodeGenerator::writeDoStatement(const DoStatement& d, OutputStream& out) {
+void SPIRVCodeGenerator::writeDoStatement(const DoStatement& d, SkWStream& out) {
// We believe the do loop code below will work, but Skia doesn't actually use them and
// adequately testing this code in the absence of Skia exercising it isn't straightforward. For
// the time being, we just fail with an error due to the lack of testing. If you encounter this
@@ -2807,7 +2808,7 @@ void SPIRVCodeGenerator::writeDoStatement(const DoStatement& d, OutputStream& ou
fContinueTarget.pop();
}
-void SPIRVCodeGenerator::writeReturnStatement(const ReturnStatement& r, OutputStream& out) {
+void SPIRVCodeGenerator::writeReturnStatement(const ReturnStatement& r, SkWStream& out) {
if (r.fExpression) {
this->writeInstruction(SpvOpReturnValue, this->writeExpression(*r.fExpression, out),
out);
@@ -2816,9 +2817,9 @@ void SPIRVCodeGenerator::writeReturnStatement(const ReturnStatement& r, OutputSt
}
}
-void SPIRVCodeGenerator::writeInstructions(const Program& program, OutputStream& out) {
+void SPIRVCodeGenerator::writeInstructions(const Program& program, SkWStream& out) {
fGLSLExtendedInstructions = this->nextId();
- StringStream body;
+ SkDynamicMemoryWStream body;
std::set<SpvId> interfaceVars;
// assign IDs to functions
for (size_t i = 0; i < program.fElements.size(); i++) {
@@ -2898,12 +2899,12 @@ void SPIRVCodeGenerator::writeInstructions(const Program& program, OutputStream&
}
}
- write_stringstream(fExtraGlobalsBuffer, out);
- write_stringstream(fNameBuffer, out);
- write_stringstream(fDecorationBuffer, out);
- write_stringstream(fConstantBuffer, out);
- write_stringstream(fExternalFunctionsBuffer, out);
- write_stringstream(body, out);
+ write_data(*fExtraGlobalsBuffer.detachAsData(), out);
+ write_data(*fNameBuffer.detachAsData(), out);
+ write_data(*fDecorationBuffer.detachAsData(), out);
+ write_data(*fConstantBuffer.detachAsData(), out);
+ write_data(*fExternalFunctionsBuffer.detachAsData(), out);
+ write_data(*body.detachAsData(), out);
}
bool SPIRVCodeGenerator::generateCode() {
@@ -2911,11 +2912,11 @@ bool SPIRVCodeGenerator::generateCode() {
this->writeWord(SpvMagicNumber, *fOut);
this->writeWord(SpvVersion, *fOut);
this->writeWord(SKSL_MAGIC, *fOut);
- StringStream buffer;
+ SkDynamicMemoryWStream buffer;
this->writeInstructions(fProgram, buffer);
this->writeWord(fIdCount, *fOut);
this->writeWord(0, *fOut); // reserved, always zero
- write_stringstream(buffer, *fOut);
+ write_data(*buffer.detachAsData(), *fOut);
return 0 == fErrors.errorCount();
}
diff --git a/src/sksl/SkSLSPIRVCodeGenerator.h b/src/sksl/SkSLSPIRVCodeGenerator.h
index 656fb99e40..1cdc653c85 100644
--- a/src/sksl/SkSLSPIRVCodeGenerator.h
+++ b/src/sksl/SkSLSPIRVCodeGenerator.h
@@ -4,7 +4,7 @@
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
-
+
#ifndef SKSL_SPIRVCODEGENERATOR
#define SKSL_SPIRVCODEGENERATOR
@@ -12,6 +12,7 @@
#include <tuple>
#include <unordered_map>
+#include "SkStream.h"
#include "SkSLCodeGenerator.h"
#include "SkSLMemoryLayout.h"
#include "ir/SkSLBinaryExpression.h"
@@ -58,13 +59,13 @@ public:
// by a pointer (e.g. vector swizzles), returns 0.
virtual SpvId getPointer() = 0;
- virtual SpvId load(OutputStream& out) = 0;
+ virtual SpvId load(SkWStream& out) = 0;
- virtual void store(SpvId value, OutputStream& out) = 0;
+ virtual void store(SpvId value, SkWStream& out) = 0;
};
SPIRVCodeGenerator(const Context* context, const Program* program, ErrorReporter* errors,
- OutputStream* out)
+ SkWStream* out)
: INHERITED(program, errors, out)
, fContext(*context)
, fDefaultLayout(MemoryLayout::k140_Standard)
@@ -107,7 +108,7 @@ private:
SpvId getPointerType(const Type& type, const MemoryLayout& layout,
SpvStorageClass_ storageClass);
- std::vector<SpvId> getAccessChain(const Expression& expr, OutputStream& out);
+ std::vector<SpvId> getAccessChain(const Expression& expr, SkWStream& out);
void writeLayout(const Layout& layout, SpvId target);
@@ -115,43 +116,43 @@ private:
void writeStruct(const Type& type, const MemoryLayout& layout, SpvId resultId);
- void writeProgramElement(const ProgramElement& pe, OutputStream& out);
+ void writeProgramElement(const ProgramElement& pe, SkWStream& out);
SpvId writeInterfaceBlock(const InterfaceBlock& intf);
- SpvId writeFunctionStart(const FunctionDeclaration& f, OutputStream& out);
-
- SpvId writeFunctionDeclaration(const FunctionDeclaration& f, OutputStream& out);
-
- SpvId writeFunction(const FunctionDefinition& f, OutputStream& out);
+ SpvId writeFunctionStart(const FunctionDeclaration& f, SkWStream& out);
+
+ SpvId writeFunctionDeclaration(const FunctionDeclaration& f, SkWStream& out);
- void writeGlobalVars(Program::Kind kind, const VarDeclarations& v, OutputStream& out);
+ SpvId writeFunction(const FunctionDefinition& f, SkWStream& out);
- void writeVarDeclarations(const VarDeclarations& decl, OutputStream& out);
+ void writeGlobalVars(Program::Kind kind, const VarDeclarations& v, SkWStream& out);
- SpvId writeVariableReference(const VariableReference& ref, OutputStream& out);
+ void writeVarDeclarations(const VarDeclarations& decl, SkWStream& out);
- std::unique_ptr<LValue> getLValue(const Expression& value, OutputStream& out);
+ SpvId writeVariableReference(const VariableReference& ref, SkWStream& out);
- SpvId writeExpression(const Expression& expr, OutputStream& out);
+ std::unique_ptr<LValue> getLValue(const Expression& value, SkWStream& out);
- SpvId writeIntrinsicCall(const FunctionCall& c, OutputStream& out);
+ SpvId writeExpression(const Expression& expr, SkWStream& out);
+
+ SpvId writeIntrinsicCall(const FunctionCall& c, SkWStream& out);
- SpvId writeFunctionCall(const FunctionCall& c, OutputStream& out);
+ SpvId writeFunctionCall(const FunctionCall& c, SkWStream& out);
- SpvId writeSpecialIntrinsic(const FunctionCall& c, SpecialIntrinsic kind, OutputStream& out);
+ SpvId writeSpecialIntrinsic(const FunctionCall& c, SpecialIntrinsic kind, SkWStream& out);
SpvId writeConstantVector(const Constructor& c);
- SpvId writeFloatConstructor(const Constructor& c, OutputStream& out);
+ SpvId writeFloatConstructor(const Constructor& c, SkWStream& out);
- SpvId writeIntConstructor(const Constructor& c, OutputStream& out);
+ SpvId writeIntConstructor(const Constructor& c, SkWStream& out);
/**
* Writes a matrix with the diagonal entries all equal to the provided expression, and all other
* entries equal to zero.
*/
- void writeUniformScaleMatrix(SpvId id, SpvId diagonal, const Type& type, OutputStream& out);
+ void writeUniformScaleMatrix(SpvId id, SpvId diagonal, const Type& type, SkWStream& out);
/**
* Writes a potentially-different-sized copy of a matrix. Entries which do not exist in the
@@ -159,17 +160,17 @@ private:
* ignored.
*/
void writeMatrixCopy(SpvId id, SpvId src, const Type& srcType, const Type& dstType,
- OutputStream& out);
+ SkWStream& out);
- SpvId writeMatrixConstructor(const Constructor& c, OutputStream& out);
+ SpvId writeMatrixConstructor(const Constructor& c, SkWStream& out);
- SpvId writeVectorConstructor(const Constructor& c, OutputStream& out);
+ SpvId writeVectorConstructor(const Constructor& c, SkWStream& out);
- SpvId writeConstructor(const Constructor& c, OutputStream& out);
+ SpvId writeConstructor(const Constructor& c, SkWStream& out);
- SpvId writeFieldAccess(const FieldAccess& f, OutputStream& out);
+ SpvId writeFieldAccess(const FieldAccess& f, SkWStream& out);
- SpvId writeSwizzle(const Swizzle& swizzle, OutputStream& out);
+ SpvId writeSwizzle(const Swizzle& swizzle, SkWStream& out);
/**
* Folds the potentially-vector result of a logical operation down to a single bool. If
@@ -177,28 +178,28 @@ private:
* same dimensions, and applys all() to it to fold it down to a single bool value. Otherwise,
* returns the original id value.
*/
- SpvId foldToBool(SpvId id, const Type& operandType, OutputStream& out);
+ SpvId foldToBool(SpvId id, const Type& operandType, SkWStream& out);
SpvId writeBinaryOperation(const Type& resultType, const Type& operandType, SpvId lhs,
SpvId rhs, SpvOp_ ifFloat, SpvOp_ ifInt, SpvOp_ ifUInt,
- SpvOp_ ifBool, OutputStream& out);
+ SpvOp_ ifBool, SkWStream& out);
SpvId writeBinaryOperation(const BinaryExpression& expr, SpvOp_ ifFloat, SpvOp_ ifInt,
- SpvOp_ ifUInt, OutputStream& out);
+ SpvOp_ ifUInt, SkWStream& out);
- SpvId writeBinaryExpression(const BinaryExpression& b, OutputStream& out);
+ SpvId writeBinaryExpression(const BinaryExpression& b, SkWStream& out);
- SpvId writeTernaryExpression(const TernaryExpression& t, OutputStream& out);
+ SpvId writeTernaryExpression(const TernaryExpression& t, SkWStream& out);
- SpvId writeIndexExpression(const IndexExpression& expr, OutputStream& out);
+ SpvId writeIndexExpression(const IndexExpression& expr, SkWStream& out);
- SpvId writeLogicalAnd(const BinaryExpression& b, OutputStream& out);
+ SpvId writeLogicalAnd(const BinaryExpression& b, SkWStream& out);
- SpvId writeLogicalOr(const BinaryExpression& o, OutputStream& out);
+ SpvId writeLogicalOr(const BinaryExpression& o, SkWStream& out);
- SpvId writePrefixExpression(const PrefixExpression& p, OutputStream& out);
+ SpvId writePrefixExpression(const PrefixExpression& p, SkWStream& out);
- SpvId writePostfixExpression(const PostfixExpression& p, OutputStream& out);
+ SpvId writePostfixExpression(const PostfixExpression& p, SkWStream& out);
SpvId writeBoolLiteral(const BoolLiteral& b);
@@ -206,63 +207,63 @@ private:
SpvId writeFloatLiteral(const FloatLiteral& f);
- void writeStatement(const Statement& s, OutputStream& out);
+ void writeStatement(const Statement& s, SkWStream& out);
- void writeBlock(const Block& b, OutputStream& out);
+ void writeBlock(const Block& b, SkWStream& out);
- void writeIfStatement(const IfStatement& stmt, OutputStream& out);
+ void writeIfStatement(const IfStatement& stmt, SkWStream& out);
- void writeForStatement(const ForStatement& f, OutputStream& out);
+ void writeForStatement(const ForStatement& f, SkWStream& out);
- void writeWhileStatement(const WhileStatement& w, OutputStream& out);
+ void writeWhileStatement(const WhileStatement& w, SkWStream& out);
- void writeDoStatement(const DoStatement& d, OutputStream& out);
+ void writeDoStatement(const DoStatement& d, SkWStream& out);
- void writeReturnStatement(const ReturnStatement& r, OutputStream& out);
+ void writeReturnStatement(const ReturnStatement& r, SkWStream& out);
- void writeCapabilities(OutputStream& out);
+ void writeCapabilities(SkWStream& out);
- void writeInstructions(const Program& program, OutputStream& out);
+ void writeInstructions(const Program& program, SkWStream& out);
- void writeOpCode(SpvOp_ opCode, int length, OutputStream& out);
+ void writeOpCode(SpvOp_ opCode, int length, SkWStream& out);
- void writeWord(int32_t word, OutputStream& out);
+ void writeWord(int32_t word, SkWStream& out);
- void writeString(const char* string, OutputStream& out);
+ void writeString(const char* string, SkWStream& out);
- void writeLabel(SpvId id, OutputStream& out);
+ void writeLabel(SpvId id, SkWStream& out);
- void writeInstruction(SpvOp_ opCode, OutputStream& out);
+ void writeInstruction(SpvOp_ opCode, SkWStream& out);
- void writeInstruction(SpvOp_ opCode, const char* string, OutputStream& out);
+ void writeInstruction(SpvOp_ opCode, const char* string, SkWStream& out);
- void writeInstruction(SpvOp_ opCode, int32_t word1, OutputStream& out);
+ void writeInstruction(SpvOp_ opCode, int32_t word1, SkWStream& out);
- void writeInstruction(SpvOp_ opCode, int32_t word1, const char* string, OutputStream& out);
+ void writeInstruction(SpvOp_ opCode, int32_t word1, const char* string, SkWStream& out);
void writeInstruction(SpvOp_ opCode, int32_t word1, int32_t word2, const char* string,
- OutputStream& out);
+ SkWStream& out);
- void writeInstruction(SpvOp_ opCode, int32_t word1, int32_t word2, OutputStream& out);
+ void writeInstruction(SpvOp_ opCode, int32_t word1, int32_t word2, SkWStream& out);
void writeInstruction(SpvOp_ opCode, int32_t word1, int32_t word2, int32_t word3,
- OutputStream& out);
+ SkWStream& out);
void writeInstruction(SpvOp_ opCode, int32_t word1, int32_t word2, int32_t word3, int32_t word4,
- OutputStream& out);
+ SkWStream& out);
void writeInstruction(SpvOp_ opCode, int32_t word1, int32_t word2, int32_t word3, int32_t word4,
- int32_t word5, OutputStream& out);
+ int32_t word5, SkWStream& out);
void writeInstruction(SpvOp_ opCode, int32_t word1, int32_t word2, int32_t word3, int32_t word4,
- int32_t word5, int32_t word6, OutputStream& out);
+ int32_t word5, int32_t word6, SkWStream& out);
void writeInstruction(SpvOp_ opCode, int32_t word1, int32_t word2, int32_t word3, int32_t word4,
- int32_t word5, int32_t word6, int32_t word7, OutputStream& out);
+ int32_t word5, int32_t word6, int32_t word7, SkWStream& out);
void writeInstruction(SpvOp_ opCode, int32_t word1, int32_t word2, int32_t word3, int32_t word4,
int32_t word5, int32_t word6, int32_t word7, int32_t word8,
- OutputStream& out);
+ SkWStream& out);
const Context& fContext;
const MemoryLayout fDefaultLayout;
@@ -271,19 +272,19 @@ private:
SpvId fIdCount;
SpvId fGLSLExtendedInstructions;
typedef std::tuple<IntrinsicKind, int32_t, int32_t, int32_t, int32_t> Intrinsic;
- std::unordered_map<String, Intrinsic> fIntrinsicMap;
+ std::unordered_map<SkString, Intrinsic> fIntrinsicMap;
std::unordered_map<const FunctionDeclaration*, SpvId> fFunctionMap;
std::unordered_map<const Variable*, SpvId> fVariableMap;
std::unordered_map<const Variable*, int32_t> fInterfaceBlockMap;
- std::unordered_map<String, SpvId> fTypeMap;
- StringStream fCapabilitiesBuffer;
- StringStream fGlobalInitializersBuffer;
- StringStream fConstantBuffer;
- StringStream fExtraGlobalsBuffer;
- StringStream fExternalFunctionsBuffer;
- StringStream fVariableBuffer;
- StringStream fNameBuffer;
- StringStream fDecorationBuffer;
+ std::unordered_map<SkString, SpvId> fTypeMap;
+ SkDynamicMemoryWStream fCapabilitiesBuffer;
+ SkDynamicMemoryWStream fGlobalInitializersBuffer;
+ SkDynamicMemoryWStream fConstantBuffer;
+ SkDynamicMemoryWStream fExtraGlobalsBuffer;
+ SkDynamicMemoryWStream fExternalFunctionsBuffer;
+ SkDynamicMemoryWStream fVariableBuffer;
+ SkDynamicMemoryWStream fNameBuffer;
+ SkDynamicMemoryWStream fDecorationBuffer;
SpvId fBoolTrue;
SpvId fBoolFalse;
diff --git a/src/sksl/SkSLString.cpp b/src/sksl/SkSLString.cpp
deleted file mode 100644
index e98062efd0..0000000000
--- a/src/sksl/SkSLString.cpp
+++ /dev/null
@@ -1,173 +0,0 @@
-/*
- * Copyright 2017 Google Inc.
- *
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#include "SkSLString.h"
-
-#include "SkSLUtil.h"
-#include <cinttypes>
-#include <errno.h>
-#include <limits.h>
-#include <locale>
-#include <sstream>
-#include <string>
-
-namespace SkSL {
-
-String String::printf(const char* fmt, ...) {
- va_list args;
- va_start(args, fmt);
- String result;
- result.vappendf(fmt, args);
- return result;
-}
-
-#ifdef SKSL_STANDALONE
-void String::appendf(const char* fmt, ...) {
- va_list args;
- va_start(args, fmt);
- this->vappendf(fmt, args);
-}
-#endif
-
-void String::vappendf(const char* fmt, va_list args) {
-#ifdef SKSL_BUILD_FOR_WIN
- #define VSNPRINTF _vsnprintf
-#else
- #define VSNPRINTF vsnprintf
-#endif
- #define BUFFER_SIZE 256
- char buffer[BUFFER_SIZE];
- size_t size = VSNPRINTF(buffer, BUFFER_SIZE, fmt, args);
- if (BUFFER_SIZE >= size) {
- this->append(buffer, size);
- } else {
- auto newBuffer = std::unique_ptr<char[]>(new char[size]);
- VSNPRINTF(newBuffer.get(), size, fmt, args);
- this->append(newBuffer.get(), size);
- }
- va_end(args);
-}
-
-
-bool String::startsWith(const char* s) const {
- return strncmp(c_str(), s, strlen(s));
-}
-
-bool String::endsWith(const char* s) const {
- size_t len = strlen(s);
- if (size() < len) {
- return false;
- }
- return strncmp(c_str() + size() - len, s, len);
-}
-
-String String::operator+(const char* s) const {
- String result(*this);
- result.append(s);
- return result;
-}
-
-String String::operator+(const String& s) const {
- String result(*this);
- result.append(s);
- return result;
-}
-
-bool String::operator==(const String& s) const {
- return this->size() == s.size() && !memcmp(c_str(), s.c_str(), this->size());
-}
-
-bool String::operator!=(const String& s) const {
- return !(*this == s);
-}
-
-bool String::operator==(const char* s) const {
- return this->size() == strlen(s) && !memcmp(c_str(), s, this->size());
-}
-
-bool String::operator!=(const char* s) const {
- return !(*this == s);
-}
-
-String operator+(const char* s1, const String& s2) {
- String result(s1);
- result.append(s2);
- return result;
-}
-
-bool operator==(const char* s1, const String& s2) {
- return s2 == s1;
-}
-
-bool operator!=(const char* s1, const String& s2) {
- return s2 != s1;
-}
-
-String to_string(int32_t value) {
- return SkSL::String::printf("%d", value);
-}
-
-String to_string(uint32_t value) {
- return SkSL::String::printf("%u", value);
-}
-
-String to_string(int64_t value) {
- return SkSL::String::printf("%" PRId64, value);
-}
-
-String to_string(uint64_t value) {
- return SkSL::String::printf("%" PRIu64, value);
-}
-
-String to_string(double value) {
-#ifdef SKSL_BUILD_FOR_WIN
- #define SNPRINTF _snprintf
-#else
- #define SNPRINTF snprintf
-#endif
-#define MAX_DOUBLE_CHARS 25
- char buffer[MAX_DOUBLE_CHARS];
- SKSL_DEBUGCODE(int len = )SNPRINTF(buffer, sizeof(buffer), "%.17g", value);
- ASSERT(len < MAX_DOUBLE_CHARS);
- String result(buffer);
- if (!strchr(buffer, '.') && !strchr(buffer, 'e')) {
- result += ".0";
- }
- return result;
-#undef SNPRINTF
-#undef MAX_DOUBLE_CHARS
-}
-
-int stoi(String s) {
- char* p;
- SKSL_DEBUGCODE(errno = 0;)
- long result = strtol(s.c_str(), &p, 0);
- ASSERT(*p == 0);
- ASSERT(!errno && INT_MAX >= result && INT_MIN <= result);
- return (int) result;
-}
-
-double stod(String s) {
- double result;
- std::string str(s.c_str(), s.size());
- std::stringstream buffer(str);
- buffer.imbue(std::locale::classic());
- buffer >> result;
- ASSERT(!buffer.fail());
- return result;
-}
-
-long stol(String s) {
- char* p;
- SKSL_DEBUGCODE(errno = 0;)
- long result = strtol(s.c_str(), &p, 0);
- ASSERT(*p == 0);
- ASSERT(!errno);
- return result;
-}
-
-} // namespace
diff --git a/src/sksl/SkSLString.h b/src/sksl/SkSLString.h
deleted file mode 100644
index 73ba74643e..0000000000
--- a/src/sksl/SkSLString.h
+++ /dev/null
@@ -1,105 +0,0 @@
-/*
- * Copyright 2017 Google Inc.
- *
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#ifndef SKSL_STRING
-#define SKSL_STRING
-
-
-#ifdef SKSL_STANDALONE
- #define SKSL_STRING_BASE std::string
- #include <string>
-#else
- #define SKSL_STRING_BASE SkString
- #include "SkString.h"
-#endif
-
-namespace SkSL {
-
-class String : public SKSL_STRING_BASE {
-public:
- String() = default;
- String(const String&) = default;
- String(String&&) = default;
- String& operator=(const String&) = default;
- String& operator=(String&&) = default;
-
-#ifndef SKSL_STANDALONE
- String(const SkString& s)
- : INHERITED(s) {}
-#endif
-
- String(const char* s)
- : INHERITED(s) {}
-
- String(const char* s, size_t size)
- : INHERITED(s, size) {}
-
- static String printf(const char* fmt, ...);
-
-#ifdef SKSL_STANDALONE
- void appendf(const char* fmt, ...);
-#endif
- void vappendf(const char* fmt, va_list va);
-
- bool startsWith(const char* s) const;
- bool endsWith(const char* s) const;
-
- String operator+(const char* s) const;
- String operator+(const String& s) const;
- bool operator==(const char* s) const;
- bool operator!=(const char* s) const;
- bool operator==(const String& s) const;
- bool operator!=(const String& s) const;
- friend String operator+(const char* s1, const String& s2);
- friend bool operator==(const char* s1, const String& s2);
- friend bool operator!=(const char* s1, const String& s2);
-
-private:
- typedef SKSL_STRING_BASE INHERITED;
-};
-
-String operator+(const char* s1, const String& s2);
-bool operator!=(const char* s1, const String& s2);
-
-String to_string(double value);
-
-String to_string(int32_t value);
-
-String to_string(uint32_t value);
-
-String to_string(int64_t value);
-
-String to_string(uint64_t value);
-
-int stoi(String s);
-
-double stod(String s);
-
-long stol(String s);
-
-} // namespace
-
-#ifdef SKSL_STANDALONE
-namespace std {
- template<> struct hash<SkSL::String> {
- size_t operator()(const SkSL::String& s) const {
- return hash<std::string>{}(s);
- }
- };
-} // namespace
-#else
-#include "SkOpts.h"
-namespace std {
- template<> struct hash<SkSL::String> {
- size_t operator()(const SkSL::String& s) const {
- return SkOpts::hash_fn(s.c_str(), s.size(), 0);
- }
- };
-} // namespace
-#endif // SKIA_STANDALONE
-
-#endif
diff --git a/src/sksl/SkSLStringStream.h b/src/sksl/SkSLStringStream.h
deleted file mode 100644
index 9962955ce1..0000000000
--- a/src/sksl/SkSLStringStream.h
+++ /dev/null
@@ -1,90 +0,0 @@
-/*
- * Copyright 2017 Google Inc.
- *
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#ifndef SKSL_STRINGSTREAM
-#define SKSL_STRINGSTREAM
-
-#include "SkSLOutputStream.h"
-
-#ifdef SKSL_STANDALONE
-
-namespace SkSL {
-
-class StringStream : public OutputStream {
-public:
- void write8(uint8_t b) override {
- fBuffer += (char) b;
- }
-
- void writeText(const char* s) override {
- fBuffer += s;
- }
-
- void write(const void* s, size_t size) override {
- fBuffer.append((const char*) s, size);
- }
-
- const char* data() const {
- return fBuffer.c_str();
- }
-
- size_t size() const {
- return fBuffer.size();
- }
-
-private:
- String fBuffer;
-};
-
-#else
-
-#include "SkData.h"
-#include "SkStream.h"
-
-namespace SkSL {
-
-class StringStream : public OutputStream {
-public:
- void write8(uint8_t b) override {
- SkASSERT(!fData);
- fStream.write8(b);
- }
-
- void writeText(const char* s) override {
- SkASSERT(!fData);
- fStream.writeText(s);
- }
-
- void write(const void* s, size_t size) override {
- SkASSERT(!fData);
- fStream.write(s, size);
- }
-
- const char* data() const {
- if (!fData) {
- fData = fStream.detachAsData();
- }
- return (const char*) fData->data();
- }
-
- size_t size() const {
- if (!fData) {
- fData = fStream.detachAsData();
- }
- return fData->size();
- }
-
-private:
- mutable SkDynamicMemoryWStream fStream;
- mutable sk_sp<SkData> fData;
-};
-
-#endif // SKSL_STANDALONE
-
-} // namespace
-
-#endif
diff --git a/src/sksl/SkSLToken.h b/src/sksl/SkSLToken.h
index 8732e80c60..6bacb9015f 100644
--- a/src/sksl/SkSLToken.h
+++ b/src/sksl/SkSLToken.h
@@ -4,13 +4,13 @@
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
-
+
#ifndef SKSL_TOKEN
#define SKSL_TOKEN
#include "SkSLPosition.h"
#include "SkSLUtil.h"
-
+
namespace SkSL {
#undef IN
@@ -131,54 +131,54 @@ struct Token {
INVALID_TOKEN
};
- static String OperatorName(Kind kind) {
+ static SkString OperatorName(Kind kind) {
switch (kind) {
- case Token::PLUS: return String("+");
- case Token::MINUS: return String("-");
- case Token::STAR: return String("*");
- case Token::SLASH: return String("/");
- case Token::PERCENT: return String("%");
- case Token::SHL: return String("<<");
- case Token::SHR: return String(">>");
- case Token::LOGICALNOT: return String("!");
- case Token::LOGICALAND: return String("&&");
- case Token::LOGICALOR: return String("||");
- case Token::LOGICALXOR: return String("^^");
- case Token::BITWISENOT: return String("~");
- case Token::BITWISEAND: return String("&");
- case Token::BITWISEOR: return String("|");
- case Token::BITWISEXOR: return String("^");
- case Token::EQ: return String("=");
- case Token::EQEQ: return String("==");
- case Token::NEQ: return String("!=");
- case Token::LT: return String("<");
- case Token::GT: return String(">");
- case Token::LTEQ: return String("<=");
- case Token::GTEQ: return String(">=");
- case Token::PLUSEQ: return String("+=");
- case Token::MINUSEQ: return String("-=");
- case Token::STAREQ: return String("*=");
- case Token::SLASHEQ: return String("/=");
- case Token::PERCENTEQ: return String("%=");
- case Token::SHLEQ: return String("<<=");
- case Token::SHREQ: return String(">>=");
- case Token::LOGICALANDEQ: return String("&&=");
- case Token::LOGICALOREQ: return String("||=");
- case Token::LOGICALXOREQ: return String("^^=");
- case Token::BITWISEANDEQ: return String("&=");
- case Token::BITWISEOREQ: return String("|=");
- case Token::BITWISEXOREQ: return String("^=");
- case Token::PLUSPLUS: return String("++");
- case Token::MINUSMINUS: return String("--");
+ case Token::PLUS: return SkString("+");
+ case Token::MINUS: return SkString("-");
+ case Token::STAR: return SkString("*");
+ case Token::SLASH: return SkString("/");
+ case Token::PERCENT: return SkString("%");
+ case Token::SHL: return SkString("<<");
+ case Token::SHR: return SkString(">>");
+ case Token::LOGICALNOT: return SkString("!");
+ case Token::LOGICALAND: return SkString("&&");
+ case Token::LOGICALOR: return SkString("||");
+ case Token::LOGICALXOR: return SkString("^^");
+ case Token::BITWISENOT: return SkString("~");
+ case Token::BITWISEAND: return SkString("&");
+ case Token::BITWISEOR: return SkString("|");
+ case Token::BITWISEXOR: return SkString("^");
+ case Token::EQ: return SkString("=");
+ case Token::EQEQ: return SkString("==");
+ case Token::NEQ: return SkString("!=");
+ case Token::LT: return SkString("<");
+ case Token::GT: return SkString(">");
+ case Token::LTEQ: return SkString("<=");
+ case Token::GTEQ: return SkString(">=");
+ case Token::PLUSEQ: return SkString("+=");
+ case Token::MINUSEQ: return SkString("-=");
+ case Token::STAREQ: return SkString("*=");
+ case Token::SLASHEQ: return SkString("/=");
+ case Token::PERCENTEQ: return SkString("%=");
+ case Token::SHLEQ: return SkString("<<=");
+ case Token::SHREQ: return SkString(">>=");
+ case Token::LOGICALANDEQ: return SkString("&&=");
+ case Token::LOGICALOREQ: return SkString("||=");
+ case Token::LOGICALXOREQ: return SkString("^^=");
+ case Token::BITWISEANDEQ: return SkString("&=");
+ case Token::BITWISEOREQ: return SkString("|=");
+ case Token::BITWISEXOREQ: return SkString("^=");
+ case Token::PLUSPLUS: return SkString("++");
+ case Token::MINUSMINUS: return SkString("--");
default:
- ABORT("unsupported operator: %d\n", kind);
- }
+ ABORT("unsupported operator: %d\n", kind);
+ }
}
Token() {
}
- Token(Position position, Kind kind, String text)
+ Token(Position position, Kind kind, SkString text)
: fPosition(position)
, fKind(kind)
, fText(std::move(text)) {}
@@ -209,7 +209,7 @@ struct Token {
Kind fKind;
// will be the empty string unless the token has variable text content (identifiers, numeric
// literals, and directives)
- String fText;
+ SkString fText;
};
} // namespace
diff --git a/src/sksl/SkSLUtil.cpp b/src/sksl/SkSLUtil.cpp
index c715cf1d09..e93a953990 100644
--- a/src/sksl/SkSLUtil.cpp
+++ b/src/sksl/SkSLUtil.cpp
@@ -10,24 +10,117 @@
#ifndef __STDC_FORMAT_MACROS
#define __STDC_FORMAT_MACROS
#endif
+#include <cinttypes>
+#include <locale>
+#include <sstream>
+#include <string>
namespace SkSL {
-#ifdef SKSL_STANDALONE
-StandaloneShaderCaps standaloneCaps;
+SkString to_string(double value) {
+#ifdef SK_BUILD_FOR_WIN
+ #define SNPRINTF _snprintf
+#else
+ #define SNPRINTF snprintf
#endif
+#define MAX_DOUBLE_CHARS 25
+ char buffer[MAX_DOUBLE_CHARS];
+ SkDEBUGCODE(int len = )SNPRINTF(buffer, sizeof(buffer), "%.17g", value);
+ ASSERT(len < MAX_DOUBLE_CHARS);
+ SkString result(buffer);
+ if (!strchr(buffer, '.') && !strchr(buffer, 'e')) {
+ result += ".0";
+ }
+ return result;
+#undef SNPRINTF
+#undef MAX_DOUBLE_CHARS
+}
+
+SkString to_string(int32_t value) {
+ return SkStringPrintf("%d", value);
+}
+
+SkString to_string(uint32_t value) {
+ return SkStringPrintf("%u", value);
+}
+
+SkString to_string(int64_t value) {
+ return SkStringPrintf("%" PRId64, value);
+}
+
+SkString to_string(uint64_t value) {
+ return SkStringPrintf("%" PRIu64, value);
+}
+
+int stoi(SkString s) {
+ if (s.size() > 2 && s[0] == '0' && s[1] == 'x') {
+ char* p;
+ int result = strtoul(s.c_str() + 2, &p, 16);
+ ASSERT(*p == 0);
+ return result;
+ }
+ return atoi(s.c_str());
+}
+
+double stod(SkString s) {
+ double result;
+ std::string str(s.c_str(), s.size());
+ std::stringstream buffer(str);
+ buffer.imbue(std::locale::classic());
+ buffer >> result;
+ return result;
+}
+
+long stol(SkString s) {
+ if (s.size() > 2 && s[0] == '0' && s[1] == 'x') {
+ char* p;
+ long result = strtoul(s.c_str() + 2, &p, 16);
+ ASSERT(*p == 0);
+ return result;
+ }
+ return atol(s.c_str());
+}
void sksl_abort() {
-#ifdef SKSL_STANDALONE
- abort();
-#else
+#ifdef SKIA
sk_abort_no_print();
exit(1);
+#else
+ abort();
#endif
}
-void write_stringstream(const StringStream& s, OutputStream& out) {
- out.write(s.data(), s.size());
+void write_data(const SkData& data, SkWStream& out) {
+ out.write(data.data(), data.size());
+}
+
+SkString operator+(const SkString& s, const char* c) {
+ SkString result(s);
+ result += c;
+ return result;
+}
+
+SkString operator+(const char* c, const SkString& s) {
+ SkString result(c);
+ result += s;
+ return result;
}
+SkString operator+(const SkString& s1, const SkString& s2) {
+ SkString result(s1);
+ result += s2;
+ return result;
+}
+
+bool operator==(const SkString& s1, const char* s2) {
+ return !strcmp(s1.c_str(), s2);
+}
+
+bool operator!=(const SkString& s1, const char* s2) {
+ return strcmp(s1.c_str(), s2);
+}
+
+bool operator!=(const char* s1, const SkString& s2) {
+ return strcmp(s1, s2.c_str());
+}
} // namespace
diff --git a/src/sksl/SkSLUtil.h b/src/sksl/SkSLUtil.h
index d1af9bb3c7..678241d205 100644
--- a/src/sksl/SkSLUtil.h
+++ b/src/sksl/SkSLUtil.h
@@ -4,159 +4,22 @@
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
-
+
#ifndef SKSL_UTIL
#define SKSL_UTIL
-#include <cstdarg>
-#include <memory>
#include "stdlib.h"
-#include "string.h"
#include "assert.h"
-#include "SkSLString.h"
-#include "SkSLStringStream.h"
-
-#ifndef SKSL_STANDALONE
+#include "SkOpts.h"
+#include "SkRefCnt.h"
+#include "SkStream.h"
+#include "SkString.h"
+#include "SkTypes.h"
#include "GrContextOptions.h"
#include "GrShaderCaps.h"
-#endif
-
-#ifdef SKSL_STANDALONE
-#if defined(_WIN32) || defined(__SYMBIAN32__)
-#define SKSL_BUILD_FOR_WIN
-#endif
-#else
-#ifdef SK_BUILD_FOR_WIN
-#define SKSL_BUILD_FOR_WIN
-#endif // SK_BUILD_FOR_WIN
-#endif // SKSL_STANDALONE
namespace SkSL {
-#ifdef SKSL_STANDALONE
-
-// we're being compiled standalone, so we don't have access to caps...
-enum GrGLSLGeneration {
- k110_GrGLSLGeneration,
- k130_GrGLSLGeneration,
- k140_GrGLSLGeneration,
- k150_GrGLSLGeneration,
- k330_GrGLSLGeneration,
- k400_GrGLSLGeneration,
- k420_GrGLSLGeneration,
- k310es_GrGLSLGeneration,
- k320es_GrGLSLGeneration,
-};
-
-#define SKSL_CAPS_CLASS StandaloneShaderCaps
-class StandaloneShaderCaps {
-public:
- GrGLSLGeneration generation() const {
- return k400_GrGLSLGeneration;
- }
-
- bool canUseMinAndAbsTogether() const {
- return true;
- }
-
- bool mustForceNegatedAtanParamToFloat() const {
- return false;
- }
-
- bool shaderDerivativeSupport() const {
- return true;
- }
-
- bool usesPrecisionModifiers() const {
- return true;
- }
-
- bool mustDeclareFragmentShaderOutput() const {
- return true;
- }
-
- bool fbFetchSupport() const {
- return true;
- }
-
- bool fbFetchNeedsCustomOutput() const {
- return false;
- }
-
- bool bindlessTextureSupport() const {
- return false;
- }
-
- bool dropsTileOnZeroDivide() const {
- return false;
- }
-
- bool flatInterpolationSupport() const {
- return true;
- }
-
- bool noperspectiveInterpolationSupport() const {
- return true;
- }
-
- bool multisampleInterpolationSupport() const {
- return true;
- }
-
- bool sampleVariablesSupport() const {
- return true;
- }
-
- bool sampleMaskOverrideCoverageSupport() const {
- return true;
- }
-
- bool externalTextureSupport() const {
- return true;
- }
-
- bool texelFetchSupport() const {
- return true;
- }
-
- bool imageLoadStoreSupport() const {
- return true;
- }
-
- bool mustEnableAdvBlendEqs() const {
- return false;
- }
-
- bool mustEnableSpecificAdvBlendEqs() const {
- return false;
- }
-
- bool canUseAnyFunctionInShader() const {
- return false;
- }
-
- const char* shaderDerivativeExtensionString() const {
- return nullptr;
- }
-
- const char* fragCoordConventionsExtensionString() const {
- return nullptr;
- }
-
- const char* imageLoadStoreExtensionString() const {
- return nullptr;
- }
-
- const char* versionDeclString() const {
- return "";
- }
-};
-
-extern StandaloneShaderCaps standaloneCaps;
-
-#else
-
-#define SKSL_CAPS_CLASS GrShaderCaps
// Various sets of caps for use in tests
class ShaderCapsFactory {
public:
@@ -235,38 +98,60 @@ public:
return result;
}
};
-#endif
-void write_stringstream(const StringStream& d, OutputStream& out);
+void write_data(const SkData& d, SkWStream& out);
+
+SkString operator+(const SkString& s, const char* c);
+
+SkString operator+(const char* c, const SkString& s);
+
+SkString operator+(const SkString& s1, const SkString& s2);
+
+bool operator==(const SkString& s1, const char* s2);
+
+bool operator!=(const SkString& s1, const char* s2);
+
+bool operator!=(const char* s1, const SkString& s2);
+
+SkString to_string(double value);
+
+SkString to_string(int32_t value);
+
+SkString to_string(uint32_t value);
+
+SkString to_string(int64_t value);
+
+SkString to_string(uint64_t value);
#if _MSC_VER
#define NORETURN __declspec(noreturn)
#else
#define NORETURN __attribute__((__noreturn__))
#endif
+int stoi(SkString s);
+
+double stod(SkString s);
+
+long stol(SkString s);
NORETURN void sksl_abort();
} // namespace
-#ifdef SKSL_STANDALONE
-#define ASSERT(x) (void)((x) || (ABORT("failed assert(%s): %s:%d\n", #x, __FILE__, __LINE__), 0))
-#define ASSERT_RESULT(x) ASSERT(x)
-#define SKSL_DEBUGCODE(x) x
-#else
-#define ASSERT SkASSERT
-#define ASSERT_RESULT(x) SkAssertResult(x)
-#define SKSL_DEBUGCODE(x) SkDEBUGCODE(x)
-#endif
+#define ASSERT(x) SkASSERT(x)
+#define ASSERT_RESULT(x) SkAssertResult(x);
-#define SKSL_WARN_UNUSED_RESULT __attribute__((warn_unused_result))
-
-#if defined(__clang__) || defined(__GNUC__)
-#define SKSL_PRINTF_LIKE(A, B) __attribute__((format(printf, (A), (B))))
+#ifdef SKIA
+#define ABORT(...) { SkDebugf(__VA_ARGS__); sksl_abort(); }
#else
-#define SKSL_PRINTF_LIKE(A, B)
+#define ABORT(...) { sksl_abort(); }
#endif
-#define ABORT(...) (printf(__VA_ARGS__), sksl_abort())
-
+namespace std {
+ template<> struct hash<SkString> {
+ size_t operator()(const SkString& s) const {
+ return SkOpts::hash_fn(s.c_str(), s.size(), 0);
+ }
+ };
+}
#endif
diff --git a/src/sksl/ast/SkSLASTBinaryExpression.h b/src/sksl/ast/SkSLASTBinaryExpression.h
index 9a24970262..c4b6e3a45b 100644
--- a/src/sksl/ast/SkSLASTBinaryExpression.h
+++ b/src/sksl/ast/SkSLASTBinaryExpression.h
@@ -14,7 +14,7 @@
namespace SkSL {
/**
- * Represents a binary operation, with the operator represented by the token's type.
+ * Represents a binary operation, with the operator represented by the token's type.
*/
struct ASTBinaryExpression : public ASTExpression {
ASTBinaryExpression(std::unique_ptr<ASTExpression> left, Token op,
@@ -24,7 +24,7 @@ struct ASTBinaryExpression : public ASTExpression {
, fOperator(op.fKind)
, fRight(std::move(right)) {}
- String description() const override {
+ SkString description() const override {
return "(" + fLeft->description() + " " + Token::OperatorName(fOperator) + " " +
fRight->description() + ")";
}
diff --git a/src/sksl/ast/SkSLASTBlock.h b/src/sksl/ast/SkSLASTBlock.h
index 37c0e81a95..6b1e9c5551 100644
--- a/src/sksl/ast/SkSLASTBlock.h
+++ b/src/sksl/ast/SkSLASTBlock.h
@@ -4,7 +4,7 @@
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
-
+
#ifndef SKSL_ASTBLOCK
#define SKSL_ASTBLOCK
@@ -13,21 +13,21 @@
namespace SkSL {
/**
- * Represents a curly-braced block of statements.
+ * Represents a curly-braced block of statements.
*/
struct ASTBlock : public ASTStatement {
ASTBlock(Position position, std::vector<std::unique_ptr<ASTStatement>> statements)
: INHERITED(position, kBlock_Kind)
, fStatements(std::move(statements)) {}
- String description() const override {
- String result("{");
+ SkString description() const override {
+ SkString result("{");
for (size_t i = 0; i < fStatements.size(); i++) {
result += "\n";
result += fStatements[i]->description();
}
result += "\n}\n";
- return result;
+ return result;
}
const std::vector<std::unique_ptr<ASTStatement>> fStatements;
diff --git a/src/sksl/ast/SkSLASTBoolLiteral.h b/src/sksl/ast/SkSLASTBoolLiteral.h
index 48e916eed5..02f4bac0da 100644
--- a/src/sksl/ast/SkSLASTBoolLiteral.h
+++ b/src/sksl/ast/SkSLASTBoolLiteral.h
@@ -4,7 +4,7 @@
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
-
+
#ifndef SKSL_ASTBOOLLITERAL
#define SKSL_ASTBOOLLITERAL
@@ -13,15 +13,15 @@
namespace SkSL {
/**
- * Represents "true" or "false".
+ * Represents "true" or "false".
*/
struct ASTBoolLiteral : public ASTExpression {
ASTBoolLiteral(Position position, bool value)
: INHERITED(position, kBool_Kind)
, fValue(value) {}
- String description() const override {
- return String(fValue ? "true" : "false");
+ SkString description() const override {
+ return SkString(fValue ? "true" : "false");
}
const bool fValue;
diff --git a/src/sksl/ast/SkSLASTBreakStatement.h b/src/sksl/ast/SkSLASTBreakStatement.h
index 079ee76d20..dad2a85c0a 100644
--- a/src/sksl/ast/SkSLASTBreakStatement.h
+++ b/src/sksl/ast/SkSLASTBreakStatement.h
@@ -4,7 +4,7 @@
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
-
+
#ifndef SKSL_ASTBREAKSTATEMENT
#define SKSL_ASTBREAKSTATEMENT
@@ -13,14 +13,14 @@
namespace SkSL {
/**
- * A 'break' statement.
+ * A 'break' statement.
*/
struct ASTBreakStatement : public ASTStatement {
ASTBreakStatement(Position position)
: INHERITED(position, kBreak_Kind) {}
- String description() const override {
- return String("break;");
+ SkString description() const override {
+ return SkString("break;");
}
typedef ASTStatement INHERITED;
diff --git a/src/sksl/ast/SkSLASTCallSuffix.h b/src/sksl/ast/SkSLASTCallSuffix.h
index 3ba3f0e60f..356ac850f9 100644
--- a/src/sksl/ast/SkSLASTCallSuffix.h
+++ b/src/sksl/ast/SkSLASTCallSuffix.h
@@ -4,7 +4,7 @@
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
-
+
#ifndef SKSL_ASTCALLSUFFIX
#define SKSL_ASTCALLSUFFIX
@@ -14,16 +14,16 @@
namespace SkSL {
/**
- * A parenthesized list of arguments following an expression, indicating a function call.
+ * A parenthesized list of arguments following an expression, indicating a function call.
*/
struct ASTCallSuffix : public ASTSuffix {
- ASTCallSuffix(Position position, std::vector<std::unique_ptr<ASTExpression>> arguments)
+ ASTCallSuffix(Position position, std::vector<std::unique_ptr<ASTExpression>> arguments)
: INHERITED(position, ASTSuffix::kCall_Kind)
, fArguments(std::move(arguments)) {}
- String description() const override {
- String result("(");
- String separator;
+ SkString description() const override {
+ SkString result("(");
+ SkString separator;
for (size_t i = 0; i < fArguments.size(); ++i) {
result += separator;
separator = ", ";
diff --git a/src/sksl/ast/SkSLASTContinueStatement.h b/src/sksl/ast/SkSLASTContinueStatement.h
index fdfce8598d..4cded3b16b 100644
--- a/src/sksl/ast/SkSLASTContinueStatement.h
+++ b/src/sksl/ast/SkSLASTContinueStatement.h
@@ -4,7 +4,7 @@
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
-
+
#ifndef SKSL_ASTCONTINUESTATEMENT
#define SKSL_ASTCONTINUESTATEMENT
@@ -13,14 +13,14 @@
namespace SkSL {
/**
- * A 'continue' statement.
+ * A 'continue' statement.
*/
struct ASTContinueStatement : public ASTStatement {
ASTContinueStatement(Position position)
: INHERITED(position, kContinue_Kind) {}
- String description() const override {
- return String("continue;");
+ SkString description() const override {
+ return SkString("continue;");
}
typedef ASTStatement INHERITED;
diff --git a/src/sksl/ast/SkSLASTDeclaration.h b/src/sksl/ast/SkSLASTDeclaration.h
index 0395ef91b4..70f0ebc72d 100644
--- a/src/sksl/ast/SkSLASTDeclaration.h
+++ b/src/sksl/ast/SkSLASTDeclaration.h
@@ -4,7 +4,7 @@
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
-
+
#ifndef SKSL_ASTDECLARATION
#define SKSL_ASTDECLARATION
@@ -13,7 +13,7 @@
namespace SkSL {
/**
- * Abstract supertype of declarations such as variables and functions.
+ * Abstract supertype of declarations such as variables and functions.
*/
struct ASTDeclaration : public ASTPositionNode {
enum Kind {
diff --git a/src/sksl/ast/SkSLASTDiscardStatement.h b/src/sksl/ast/SkSLASTDiscardStatement.h
index dcf6b15e64..754bf95efe 100644
--- a/src/sksl/ast/SkSLASTDiscardStatement.h
+++ b/src/sksl/ast/SkSLASTDiscardStatement.h
@@ -4,7 +4,7 @@
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
-
+
#ifndef SKSL_ASTDISCARDSTATEMENT
#define SKSL_ASTDISCARDSTATEMENT
@@ -13,14 +13,14 @@
namespace SkSL {
/**
- * A 'discard' statement.
+ * A 'discard' statement.
*/
struct ASTDiscardStatement : public ASTStatement {
ASTDiscardStatement(Position position)
: INHERITED(position, kDiscard_Kind) {}
- String description() const override {
- return String("discard;");
+ SkString description() const override {
+ return SkString("discard;");
}
typedef ASTStatement INHERITED;
diff --git a/src/sksl/ast/SkSLASTDoStatement.h b/src/sksl/ast/SkSLASTDoStatement.h
index fc97d9e142..9a0caced1c 100644
--- a/src/sksl/ast/SkSLASTDoStatement.h
+++ b/src/sksl/ast/SkSLASTDoStatement.h
@@ -4,7 +4,7 @@
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
-
+
#ifndef SKSL_ASTDOSTATEMENT
#define SKSL_ASTDOSTATEMENT
@@ -13,7 +13,7 @@
namespace SkSL {
/**
- * A 'do' loop.
+ * A 'do' loop.
*/
struct ASTDoStatement : public ASTStatement {
ASTDoStatement(Position position, std::unique_ptr<ASTStatement> statement,
@@ -22,7 +22,7 @@ struct ASTDoStatement : public ASTStatement {
, fStatement(std::move(statement))
, fTest(std::move(test)) {}
- String description() const override {
+ SkString description() const override {
return "do " + fStatement->description() + " while (" + fTest->description() + ");";
}
diff --git a/src/sksl/ast/SkSLASTExpression.h b/src/sksl/ast/SkSLASTExpression.h
index 11815aef84..8a48271042 100644
--- a/src/sksl/ast/SkSLASTExpression.h
+++ b/src/sksl/ast/SkSLASTExpression.h
@@ -4,7 +4,7 @@
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
-
+
#ifndef SKSL_ASTEXPRESSION
#define SKSL_ASTEXPRESSION
@@ -13,7 +13,7 @@
namespace SkSL {
/**
- * Abstract supertype of all expressions.
+ * Abstract supertype of all expressions.
*/
struct ASTExpression : public ASTPositionNode {
enum Kind {
diff --git a/src/sksl/ast/SkSLASTExpressionStatement.h b/src/sksl/ast/SkSLASTExpressionStatement.h
index 398a16a23a..2dbd20940d 100644
--- a/src/sksl/ast/SkSLASTExpressionStatement.h
+++ b/src/sksl/ast/SkSLASTExpressionStatement.h
@@ -4,7 +4,7 @@
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
-
+
#ifndef SKSL_ASTEXPRESSIONSTATEMENT
#define SKSL_ASTEXPRESSIONSTATEMENT
@@ -13,14 +13,14 @@
namespace SkSL {
/**
- * A lone expression being used as a statement.
+ * A lone expression being used as a statement.
*/
struct ASTExpressionStatement : public ASTStatement {
ASTExpressionStatement(std::unique_ptr<ASTExpression> expression)
: INHERITED(expression->fPosition, kExpression_Kind)
, fExpression(std::move(expression)) {}
- String description() const override {
+ SkString description() const override {
return fExpression->description() + ";";
}
diff --git a/src/sksl/ast/SkSLASTExtension.h b/src/sksl/ast/SkSLASTExtension.h
index a6fde0694c..b9df3c52e9 100644
--- a/src/sksl/ast/SkSLASTExtension.h
+++ b/src/sksl/ast/SkSLASTExtension.h
@@ -4,7 +4,7 @@
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
-
+
#ifndef SKSL_ASTEXTENSION
#define SKSL_ASTEXTENSION
@@ -12,19 +12,19 @@
namespace SkSL {
-/**
- * An extension declaration.
+/**
+ * An extension declaration.
*/
struct ASTExtension : public ASTDeclaration {
- ASTExtension(Position position, String name)
+ ASTExtension(Position position, SkString name)
: INHERITED(position, kExtension_Kind)
, fName(std::move(name)) {}
- String description() const override {
+ SkString description() const override {
return "#extension " + fName + " : enable";
}
- const String fName;
+ const SkString fName;
typedef ASTDeclaration INHERITED;
};
diff --git a/src/sksl/ast/SkSLASTFieldSuffix.h b/src/sksl/ast/SkSLASTFieldSuffix.h
index bde1e4aec5..9ee8531bf1 100644
--- a/src/sksl/ast/SkSLASTFieldSuffix.h
+++ b/src/sksl/ast/SkSLASTFieldSuffix.h
@@ -4,7 +4,7 @@
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
-
+
#ifndef SKSL_ASTFIELDSUFFIX
#define SKSL_ASTFIELDSUFFIX
@@ -17,15 +17,15 @@ namespace SkSL {
* actually vector swizzle (which looks the same to the parser).
*/
struct ASTFieldSuffix : public ASTSuffix {
- ASTFieldSuffix(Position position, String field)
+ ASTFieldSuffix(Position position, SkString field)
: INHERITED(position, ASTSuffix::kField_Kind)
, fField(std::move(field)) {}
- String description() const override {
+ SkString description() const override {
return "." + fField;
}
- String fField;
+ SkString fField;
typedef ASTSuffix INHERITED;
};
diff --git a/src/sksl/ast/SkSLASTFloatLiteral.h b/src/sksl/ast/SkSLASTFloatLiteral.h
index 15fe836049..ea0f595abc 100644
--- a/src/sksl/ast/SkSLASTFloatLiteral.h
+++ b/src/sksl/ast/SkSLASTFloatLiteral.h
@@ -4,7 +4,7 @@
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
-
+
#ifndef SKSL_ASTFLOATLITERAL
#define SKSL_ASTFLOATLITERAL
@@ -13,14 +13,14 @@
namespace SkSL {
/**
- * A literal floating point number.
+ * A literal floating point number.
*/
struct ASTFloatLiteral : public ASTExpression {
ASTFloatLiteral(Position position, double value)
: INHERITED(position, kFloat_Kind)
, fValue(value) {}
- String description() const override {
+ SkString description() const override {
return to_string(fValue);
}
diff --git a/src/sksl/ast/SkSLASTForStatement.h b/src/sksl/ast/SkSLASTForStatement.h
index 326713eb62..2706a39954 100644
--- a/src/sksl/ast/SkSLASTForStatement.h
+++ b/src/sksl/ast/SkSLASTForStatement.h
@@ -4,7 +4,7 @@
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
-
+
#ifndef SKSL_ASTFORSTATEMENT
#define SKSL_ASTFORSTATEMENT
@@ -13,10 +13,10 @@
namespace SkSL {
/**
- * A 'for' loop.
+ * A 'for' loop.
*/
struct ASTForStatement : public ASTStatement {
- ASTForStatement(Position position, std::unique_ptr<ASTStatement> initializer,
+ ASTForStatement(Position position, std::unique_ptr<ASTStatement> initializer,
std::unique_ptr<ASTExpression> test, std::unique_ptr<ASTExpression> next,
std::unique_ptr<ASTStatement> statement)
: INHERITED(position, kFor_Kind)
@@ -25,8 +25,8 @@ struct ASTForStatement : public ASTStatement {
, fNext(std::move(next))
, fStatement(std::move(statement)) {}
- String description() const override {
- String result("for (");
+ SkString description() const override {
+ SkString result("for (");
if (fInitializer) {
result.append(fInitializer->description());
}
diff --git a/src/sksl/ast/SkSLASTFunction.h b/src/sksl/ast/SkSLASTFunction.h
index d9f3067baa..32f4da71f2 100644
--- a/src/sksl/ast/SkSLASTFunction.h
+++ b/src/sksl/ast/SkSLASTFunction.h
@@ -4,7 +4,7 @@
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
-
+
#ifndef SKSL_ASTFUNCTION
#define SKSL_ASTFUNCTION
@@ -16,11 +16,11 @@
namespace SkSL {
/**
- * A function declaration or definition. The fBody field will be null for declarations.
+ * A function declaration or definition. The fBody field will be null for declarations.
*/
struct ASTFunction : public ASTDeclaration {
- ASTFunction(Position position, std::unique_ptr<ASTType> returnType, String name,
- std::vector<std::unique_ptr<ASTParameter>> parameters,
+ ASTFunction(Position position, std::unique_ptr<ASTType> returnType, SkString name,
+ std::vector<std::unique_ptr<ASTParameter>> parameters,
std::unique_ptr<ASTBlock> body)
: INHERITED(position, kFunction_Kind)
, fReturnType(std::move(returnType))
@@ -28,8 +28,8 @@ struct ASTFunction : public ASTDeclaration {
, fParameters(std::move(parameters))
, fBody(std::move(body)) {}
- String description() const override {
- String result = fReturnType->description() + " " + fName + "(";
+ SkString description() const override {
+ SkString result = fReturnType->description() + " " + fName + "(";
for (size_t i = 0; i < fParameters.size(); i++) {
if (i > 0) {
result += ", ";
@@ -41,11 +41,11 @@ struct ASTFunction : public ASTDeclaration {
} else {
result += ");";
}
- return result;
+ return result;
}
const std::unique_ptr<ASTType> fReturnType;
- const String fName;
+ const SkString fName;
const std::vector<std::unique_ptr<ASTParameter>> fParameters;
const std::unique_ptr<ASTBlock> fBody;
diff --git a/src/sksl/ast/SkSLASTIdentifier.h b/src/sksl/ast/SkSLASTIdentifier.h
index 016123cf8c..aa0179a18f 100644
--- a/src/sksl/ast/SkSLASTIdentifier.h
+++ b/src/sksl/ast/SkSLASTIdentifier.h
@@ -4,7 +4,7 @@
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
-
+
#ifndef SKSL_ASTIDENTIFIER
#define SKSL_ASTIDENTIFIER
@@ -13,18 +13,18 @@
namespace SkSL {
/**
- * An identifier in an expression context.
+ * An identifier in an expression context.
*/
struct ASTIdentifier : public ASTExpression {
- ASTIdentifier(Position position, String text)
+ ASTIdentifier(Position position, SkString text)
: INHERITED(position, kIdentifier_Kind)
, fText(std::move(text)) {}
- String description() const override {
+ SkString description() const override {
return fText;
}
- const String fText;
+ const SkString fText;
typedef ASTExpression INHERITED;
};
diff --git a/src/sksl/ast/SkSLASTIfStatement.h b/src/sksl/ast/SkSLASTIfStatement.h
index 684bea00d9..d169702710 100644
--- a/src/sksl/ast/SkSLASTIfStatement.h
+++ b/src/sksl/ast/SkSLASTIfStatement.h
@@ -4,7 +4,7 @@
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
-
+
#ifndef SKSL_ASTIFSTATEMENT
#define SKSL_ASTIFSTATEMENT
@@ -13,18 +13,18 @@
namespace SkSL {
/**
- * An 'if' statement.
+ * An 'if' statement.
*/
struct ASTIfStatement : public ASTStatement {
- ASTIfStatement(Position position, std::unique_ptr<ASTExpression> test,
+ ASTIfStatement(Position position, std::unique_ptr<ASTExpression> test,
std::unique_ptr<ASTStatement> ifTrue, std::unique_ptr<ASTStatement> ifFalse)
: INHERITED(position, kIf_Kind)
, fTest(std::move(test))
, fIfTrue(std::move(ifTrue))
, fIfFalse(std::move(ifFalse)) {}
- String description() const override {
- String result("if (");
+ SkString description() const override {
+ SkString result("if (");
result += fTest->description();
result += ") ";
result += fIfTrue->description();
@@ -32,7 +32,7 @@ struct ASTIfStatement : public ASTStatement {
result += " else ";
result += fIfFalse->description();
}
- return result;
+ return result;
}
const std::unique_ptr<ASTExpression> fTest;
diff --git a/src/sksl/ast/SkSLASTIndexSuffix.h b/src/sksl/ast/SkSLASTIndexSuffix.h
index 31142e3685..2b7cd48417 100644
--- a/src/sksl/ast/SkSLASTIndexSuffix.h
+++ b/src/sksl/ast/SkSLASTIndexSuffix.h
@@ -4,7 +4,7 @@
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
-
+
#ifndef SKSL_ASTINDEXSUFFIX
#define SKSL_ASTINDEXSUFFIX
@@ -18,19 +18,19 @@ namespace SkSL {
* 'float[](5, 6)' are represented with a null fExpression.
*/
struct ASTIndexSuffix : public ASTSuffix {
- ASTIndexSuffix(Position position)
+ ASTIndexSuffix(Position position)
: INHERITED(position, ASTSuffix::kIndex_Kind)
, fExpression(nullptr) {}
- ASTIndexSuffix(std::unique_ptr<ASTExpression> expression)
+ ASTIndexSuffix(std::unique_ptr<ASTExpression> expression)
: INHERITED(expression ? expression->fPosition : Position(), ASTSuffix::kIndex_Kind)
, fExpression(std::move(expression)) {}
- String description() const override {
+ SkString description() const override {
if (fExpression) {
return "[" + fExpression->description() + "]";
} else {
- return String("[]");
+ return SkString("[]");
}
}
diff --git a/src/sksl/ast/SkSLASTIntLiteral.h b/src/sksl/ast/SkSLASTIntLiteral.h
index fe04347fd8..f524bc04ad 100644
--- a/src/sksl/ast/SkSLASTIntLiteral.h
+++ b/src/sksl/ast/SkSLASTIntLiteral.h
@@ -4,7 +4,7 @@
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
-
+
#ifndef SKSL_ASTINTLITERAL
#define SKSL_ASTINTLITERAL
@@ -21,7 +21,7 @@ struct ASTIntLiteral : public ASTExpression {
: INHERITED(position, kInt_Kind)
, fValue(value) {}
- String description() const override {
+ SkString description() const override {
return to_string(fValue);
}
diff --git a/src/sksl/ast/SkSLASTInterfaceBlock.h b/src/sksl/ast/SkSLASTInterfaceBlock.h
index e727ae9aad..7647fb5c00 100644
--- a/src/sksl/ast/SkSLASTInterfaceBlock.h
+++ b/src/sksl/ast/SkSLASTInterfaceBlock.h
@@ -25,9 +25,9 @@ struct ASTInterfaceBlock : public ASTDeclaration {
// valueName is empty when it was not present in the source
ASTInterfaceBlock(Position position,
Modifiers modifiers,
- String typeName,
+ SkString typeName,
std::vector<std::unique_ptr<ASTVarDeclarations>> declarations,
- String instanceName,
+ SkString instanceName,
std::vector<std::unique_ptr<ASTExpression>> sizes)
: INHERITED(position, kInterfaceBlock_Kind)
, fModifiers(modifiers)
@@ -36,8 +36,8 @@ struct ASTInterfaceBlock : public ASTDeclaration {
, fInstanceName(std::move(instanceName))
, fSizes(std::move(sizes)) {}
- String description() const override {
- String result = fModifiers.description() + fTypeName + " {\n";
+ SkString description() const override {
+ SkString result = fModifiers.description() + fTypeName + " {\n";
for (size_t i = 0; i < fDeclarations.size(); i++) {
result += fDeclarations[i]->description() + "\n";
}
@@ -56,9 +56,9 @@ struct ASTInterfaceBlock : public ASTDeclaration {
}
const Modifiers fModifiers;
- const String fTypeName;
+ const SkString fTypeName;
const std::vector<std::unique_ptr<ASTVarDeclarations>> fDeclarations;
- const String fInstanceName;
+ const SkString fInstanceName;
const std::vector<std::unique_ptr<ASTExpression>> fSizes;
typedef ASTDeclaration INHERITED;
diff --git a/src/sksl/ast/SkSLASTModifiersDeclaration.h b/src/sksl/ast/SkSLASTModifiersDeclaration.h
index ba07f168b2..7950f6dd5d 100644
--- a/src/sksl/ast/SkSLASTModifiersDeclaration.h
+++ b/src/sksl/ast/SkSLASTModifiersDeclaration.h
@@ -23,7 +23,7 @@ struct ASTModifiersDeclaration : public ASTDeclaration {
: INHERITED(Position(), kModifiers_Kind)
, fModifiers(modifiers) {}
- String description() const {
+ SkString description() const {
return fModifiers.description() + ";";
}
diff --git a/src/sksl/ast/SkSLASTNode.h b/src/sksl/ast/SkSLASTNode.h
index b08bc2a932..af065955f8 100644
--- a/src/sksl/ast/SkSLASTNode.h
+++ b/src/sksl/ast/SkSLASTNode.h
@@ -4,11 +4,11 @@
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
-
+
#ifndef SKSL_ASTNODE
#define SKSL_ASTNODE
-#include "SkSLString.h"
+#include "SkString.h"
namespace SkSL {
@@ -18,8 +18,8 @@ namespace SkSL {
*/
struct ASTNode {
virtual ~ASTNode() {}
-
- virtual String description() const = 0;
+
+ virtual SkString description() const = 0;
};
} // namespace
diff --git a/src/sksl/ast/SkSLASTParameter.h b/src/sksl/ast/SkSLASTParameter.h
index 01227c637e..6bb13acf49 100644
--- a/src/sksl/ast/SkSLASTParameter.h
+++ b/src/sksl/ast/SkSLASTParameter.h
@@ -21,15 +21,15 @@ struct ASTParameter : public ASTPositionNode {
// 'sizes' is a list of the array sizes appearing on a parameter, in source order.
// e.g. int x[3][1] would have sizes [3, 1].
ASTParameter(Position position, Modifiers modifiers, std::unique_ptr<ASTType> type,
- String name, std::vector<int> sizes)
+ SkString name, std::vector<int> sizes)
: INHERITED(position)
, fModifiers(modifiers)
, fType(std::move(type))
, fName(std::move(name))
, fSizes(std::move(sizes)) {}
- String description() const override {
- String result = fModifiers.description() + fType->description() + " " + fName;
+ SkString description() const override {
+ SkString result = fModifiers.description() + fType->description() + " " + fName;
for (int size : fSizes) {
result += "[" + to_string(size) + "]";
}
@@ -38,7 +38,7 @@ struct ASTParameter : public ASTPositionNode {
const Modifiers fModifiers;
const std::unique_ptr<ASTType> fType;
- const String fName;
+ const SkString fName;
const std::vector<int> fSizes;
typedef ASTPositionNode INHERITED;
diff --git a/src/sksl/ast/SkSLASTPositionNode.h b/src/sksl/ast/SkSLASTPositionNode.h
index cc435c486c..226b4ae4b0 100644
--- a/src/sksl/ast/SkSLASTPositionNode.h
+++ b/src/sksl/ast/SkSLASTPositionNode.h
@@ -4,7 +4,7 @@
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
-
+
#ifndef SKSL_ASTPOSITIONNODE
#define SKSL_ASTPOSITIONNODE
diff --git a/src/sksl/ast/SkSLASTPrecision.h b/src/sksl/ast/SkSLASTPrecision.h
index 4b50ed3979..a2f427c9ce 100644
--- a/src/sksl/ast/SkSLASTPrecision.h
+++ b/src/sksl/ast/SkSLASTPrecision.h
@@ -4,7 +4,7 @@
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
-
+
#ifndef SKSL_ASTPRECISION
#define SKSL_ASTPRECISION
@@ -22,17 +22,17 @@ struct ASTPrecision : public ASTDeclaration {
: INHERITED(position, kPrecision_Kind)
, fPrecision(precision) {}
- String description() const {
+ SkString description() const {
switch (fPrecision) {
- case Modifiers::kLowp_Flag: return String("precision lowp float;");
- case Modifiers::kMediump_Flag: return String("precision mediump float;");
- case Modifiers::kHighp_Flag: return String("precision highp float;");
- default:
- ASSERT(false);
- return String("<error>");
+ case Modifiers::kLowp_Flag: return SkString("precision lowp float;");
+ case Modifiers::kMediump_Flag: return SkString("precision mediump float;");
+ case Modifiers::kHighp_Flag: return SkString("precision highp float;");
+ default:
+ ASSERT(false);
+ return SkString("<error>");
}
ASSERT(false);
- return String("<error>");
+ return SkString("<error>");
}
const Modifiers::Flag fPrecision;
diff --git a/src/sksl/ast/SkSLASTPrefixExpression.h b/src/sksl/ast/SkSLASTPrefixExpression.h
index 08e50f7bf1..e06ec41f9e 100644
--- a/src/sksl/ast/SkSLASTPrefixExpression.h
+++ b/src/sksl/ast/SkSLASTPrefixExpression.h
@@ -4,7 +4,7 @@
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
-
+
#ifndef SKSL_ASTPREFIXEXPRESSION
#define SKSL_ASTPREFIXEXPRESSION
@@ -22,7 +22,7 @@ struct ASTPrefixExpression : public ASTExpression {
, fOperator(op.fKind)
, fOperand(std::move(operand)) {}
- String description() const override {
+ SkString description() const override {
return Token::OperatorName(fOperator) + fOperand->description();
}
diff --git a/src/sksl/ast/SkSLASTReturnStatement.h b/src/sksl/ast/SkSLASTReturnStatement.h
index 6762eb3f90..ed24d4a153 100644
--- a/src/sksl/ast/SkSLASTReturnStatement.h
+++ b/src/sksl/ast/SkSLASTReturnStatement.h
@@ -4,7 +4,7 @@
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
-
+
#ifndef SKSL_ASTRETURNSTATEMENT
#define SKSL_ASTRETURNSTATEMENT
@@ -21,12 +21,12 @@ struct ASTReturnStatement : public ASTStatement {
: INHERITED(position, kReturn_Kind)
, fExpression(std::move(expression)) {}
- String description() const override {
- String result("return");
+ SkString description() const override {
+ SkString result("return");
if (fExpression) {
result += " " + fExpression->description();
}
- return result + ";";
+ return result + ";";
}
const std::unique_ptr<ASTExpression> fExpression;
diff --git a/src/sksl/ast/SkSLASTStatement.h b/src/sksl/ast/SkSLASTStatement.h
index 1989a1fce6..6ce320e343 100644
--- a/src/sksl/ast/SkSLASTStatement.h
+++ b/src/sksl/ast/SkSLASTStatement.h
@@ -4,7 +4,7 @@
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
-
+
#ifndef SKSL_ASTSTATEMENT
#define SKSL_ASTSTATEMENT
diff --git a/src/sksl/ast/SkSLASTSuffix.h b/src/sksl/ast/SkSLASTSuffix.h
index f06c6fd362..64178c7682 100644
--- a/src/sksl/ast/SkSLASTSuffix.h
+++ b/src/sksl/ast/SkSLASTSuffix.h
@@ -4,7 +4,7 @@
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
-
+
#ifndef SKSL_ASTSUFFIX
#define SKSL_ASTSUFFIX
@@ -30,15 +30,15 @@ struct ASTSuffix : public ASTPositionNode {
: INHERITED(position)
, fKind(kind) {}
- String description() const override {
+ SkString description() const override {
switch (fKind) {
case kPostIncrement_Kind:
- return String("++");
+ return SkString("++");
case kPostDecrement_Kind:
- return String("--");
+ return SkString("--");
default:
ABORT("unsupported suffix operator");
- }
+ }
}
Kind fKind;
diff --git a/src/sksl/ast/SkSLASTSuffixExpression.h b/src/sksl/ast/SkSLASTSuffixExpression.h
index 2cff9a865f..7ee200fd43 100644
--- a/src/sksl/ast/SkSLASTSuffixExpression.h
+++ b/src/sksl/ast/SkSLASTSuffixExpression.h
@@ -4,7 +4,7 @@
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
-
+
#ifndef SKSL_ASTSUFFIXEXPRESSION
#define SKSL_ASTSUFFIXEXPRESSION
@@ -22,7 +22,7 @@ struct ASTSuffixExpression : public ASTExpression {
, fBase(std::move(base))
, fSuffix(std::move(suffix)) {}
- String description() const override {
+ SkString description() const override {
return fBase->description() + fSuffix->description();
}
diff --git a/src/sksl/ast/SkSLASTSwitchCase.h b/src/sksl/ast/SkSLASTSwitchCase.h
index 405013a6a7..2c0a01c7fa 100644
--- a/src/sksl/ast/SkSLASTSwitchCase.h
+++ b/src/sksl/ast/SkSLASTSwitchCase.h
@@ -23,8 +23,8 @@ struct ASTSwitchCase : public ASTStatement {
, fValue(std::move(value))
, fStatements(std::move(statements)) {}
- String description() const override {
- String result;
+ SkString description() const override {
+ SkString result;
if (fValue) {
result.appendf("case %s:\n", fValue->description().c_str());
} else {
diff --git a/src/sksl/ast/SkSLASTSwitchStatement.h b/src/sksl/ast/SkSLASTSwitchStatement.h
index 4a963ebc7a..3031a7d2b1 100644
--- a/src/sksl/ast/SkSLASTSwitchStatement.h
+++ b/src/sksl/ast/SkSLASTSwitchStatement.h
@@ -23,8 +23,8 @@ struct ASTSwitchStatement : public ASTStatement {
, fValue(std::move(value))
, fCases(std::move(cases)) {}
- String description() const override {
- String result = String::printf("switch (%s) {\n", + fValue->description().c_str());
+ SkString description() const override {
+ SkString result = SkStringPrintf("switch (%s) {\n", + fValue->description().c_str());
for (const auto& c : fCases) {
result += c->description();
}
diff --git a/src/sksl/ast/SkSLASTTernaryExpression.h b/src/sksl/ast/SkSLASTTernaryExpression.h
index 07c92975e0..ddf8e3d120 100644
--- a/src/sksl/ast/SkSLASTTernaryExpression.h
+++ b/src/sksl/ast/SkSLASTTernaryExpression.h
@@ -4,7 +4,7 @@
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
-
+
#ifndef SKSL_ASTTERNARYEXPRESSION
#define SKSL_ASTTERNARYEXPRESSION
@@ -24,9 +24,9 @@ struct ASTTernaryExpression : public ASTExpression {
, fIfTrue(std::move(ifTrue))
, fIfFalse(std::move(ifFalse)) {}
- String description() const override {
+ SkString description() const override {
return "(" + fTest->description() + " ? " + fIfTrue->description() + " : " +
- fIfFalse->description() + ")";
+ fIfFalse->description() + ")";
}
const std::unique_ptr<ASTExpression> fTest;
diff --git a/src/sksl/ast/SkSLASTType.h b/src/sksl/ast/SkSLASTType.h
index 57a8025b7b..b95c3d7a0b 100644
--- a/src/sksl/ast/SkSLASTType.h
+++ b/src/sksl/ast/SkSLASTType.h
@@ -4,7 +4,7 @@
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
-
+
#ifndef SKSL_ASTTYPE
#define SKSL_ASTTYPE
@@ -21,17 +21,17 @@ struct ASTType : public ASTPositionNode {
kStruct_Kind
};
- ASTType(Position position, String name, Kind kind, std::vector<int> sizes)
+ ASTType(Position position, SkString name, Kind kind, std::vector<int> sizes)
: INHERITED(position)
, fName(std::move(name))
, fKind(kind)
, fSizes(std::move(sizes)) {}
- String description() const override {
+ SkString description() const override {
return fName;
}
- const String fName;
+ const SkString fName;
const Kind fKind;
diff --git a/src/sksl/ast/SkSLASTVarDeclaration.h b/src/sksl/ast/SkSLASTVarDeclaration.h
index 2dcb9787ea..7d50a06a50 100644
--- a/src/sksl/ast/SkSLASTVarDeclaration.h
+++ b/src/sksl/ast/SkSLASTVarDeclaration.h
@@ -22,15 +22,15 @@ namespace SkSL {
* instances.
*/
struct ASTVarDeclaration {
- ASTVarDeclaration(const String name,
+ ASTVarDeclaration(const SkString name,
std::vector<std::unique_ptr<ASTExpression>> sizes,
std::unique_ptr<ASTExpression> value)
: fName(name)
, fSizes(std::move(sizes))
, fValue(std::move(value)) {}
- String description() const {
- String result = fName;
+ SkString description() const {
+ SkString result = fName;
for (const auto& size : fSizes) {
if (size) {
result += "[" + size->description() + "]";
@@ -44,7 +44,7 @@ struct ASTVarDeclaration {
return result;
}
- String fName;
+ SkString fName;
// array sizes, if any. e.g. 'foo[3][]' has sizes [3, null]
std::vector<std::unique_ptr<ASTExpression>> fSizes;
@@ -65,9 +65,9 @@ struct ASTVarDeclarations : public ASTDeclaration {
, fType(std::move(type))
, fVars(std::move(vars)) {}
- String description() const override {
- String result = fModifiers.description() + fType->description() + " ";
- String separator;
+ SkString description() const override {
+ SkString result = fModifiers.description() + fType->description() + " ";
+ SkString separator;
for (const auto& var : fVars) {
result += separator;
separator = ", ";
diff --git a/src/sksl/ast/SkSLASTVarDeclarationStatement.h b/src/sksl/ast/SkSLASTVarDeclarationStatement.h
index c3a4069ba0..d71639d797 100644
--- a/src/sksl/ast/SkSLASTVarDeclarationStatement.h
+++ b/src/sksl/ast/SkSLASTVarDeclarationStatement.h
@@ -4,7 +4,7 @@
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
-
+
#ifndef SKSL_ASTVARDECLARATIONSTATEMENT
#define SKSL_ASTVARDECLARATIONSTATEMENT
@@ -21,7 +21,7 @@ struct ASTVarDeclarationStatement : public ASTStatement {
: INHERITED(decl->fPosition, kVarDeclaration_Kind)
, fDeclarations(std::move(decl)) {}
- String description() const override {
+ SkString description() const override {
return fDeclarations->description() + ";";
}
diff --git a/src/sksl/ast/SkSLASTWhileStatement.h b/src/sksl/ast/SkSLASTWhileStatement.h
index e63c50293a..853ac8028d 100644
--- a/src/sksl/ast/SkSLASTWhileStatement.h
+++ b/src/sksl/ast/SkSLASTWhileStatement.h
@@ -4,7 +4,7 @@
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
-
+
#ifndef SKSL_ASTWHILESTATEMENT
#define SKSL_ASTWHILESTATEMENT
@@ -16,13 +16,13 @@ namespace SkSL {
* A 'while' statement.
*/
struct ASTWhileStatement : public ASTStatement {
- ASTWhileStatement(Position position, std::unique_ptr<ASTExpression> test,
+ ASTWhileStatement(Position position, std::unique_ptr<ASTExpression> test,
std::unique_ptr<ASTStatement> statement)
: INHERITED(position, kWhile_Kind)
, fTest(std::move(test))
, fStatement(std::move(statement)) {}
- String description() const override {
+ SkString description() const override {
return "while (" + fTest->description() + ") " + fStatement->description();
}
diff --git a/src/sksl/ir/SkSLBinaryExpression.h b/src/sksl/ir/SkSLBinaryExpression.h
index 73b1829ef2..de85e4812b 100644
--- a/src/sksl/ir/SkSLBinaryExpression.h
+++ b/src/sksl/ir/SkSLBinaryExpression.h
@@ -34,7 +34,7 @@ struct BinaryExpression : public Expression {
*fRight);
}
- virtual String description() const override {
+ virtual SkString description() const override {
return "(" + fLeft->description() + " " + Token::OperatorName(fOperator) + " " +
fRight->description() + ")";
}
diff --git a/src/sksl/ir/SkSLBlock.h b/src/sksl/ir/SkSLBlock.h
index fe58d44135..17970fd561 100644
--- a/src/sksl/ir/SkSLBlock.h
+++ b/src/sksl/ir/SkSLBlock.h
@@ -23,8 +23,8 @@ struct Block : public Statement {
, fSymbols(std::move(symbols))
, fStatements(std::move(statements)) {}
- String description() const override {
- String result("{");
+ SkString description() const override {
+ SkString result("{");
for (size_t i = 0; i < fStatements.size(); i++) {
result += "\n";
result += fStatements[i]->description();
diff --git a/src/sksl/ir/SkSLBoolLiteral.h b/src/sksl/ir/SkSLBoolLiteral.h
index 4e1e050778..b372f2f3ff 100644
--- a/src/sksl/ir/SkSLBoolLiteral.h
+++ b/src/sksl/ir/SkSLBoolLiteral.h
@@ -4,7 +4,7 @@
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
-
+
#ifndef SKSL_BOOLLITERAL
#define SKSL_BOOLLITERAL
@@ -21,8 +21,8 @@ struct BoolLiteral : public Expression {
: INHERITED(position, kBoolLiteral_Kind, *context.fBool_Type)
, fValue(value) {}
- String description() const override {
- return String(fValue ? "true" : "false");
+ SkString description() const override {
+ return SkString(fValue ? "true" : "false");
}
bool isConstant() const override {
diff --git a/src/sksl/ir/SkSLBreakStatement.h b/src/sksl/ir/SkSLBreakStatement.h
index f6edc558e5..cd633c7a91 100644
--- a/src/sksl/ir/SkSLBreakStatement.h
+++ b/src/sksl/ir/SkSLBreakStatement.h
@@ -4,7 +4,7 @@
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
-
+
#ifndef SKSL_BREAKSTATEMENT
#define SKSL_BREAKSTATEMENT
@@ -14,14 +14,14 @@
namespace SkSL {
/**
- * A 'break' statement.
+ * A 'break' statement.
*/
struct BreakStatement : public Statement {
BreakStatement(Position position)
: INHERITED(position, kBreak_Kind) {}
- String description() const override {
- return String("break;");
+ SkString description() const override {
+ return SkString("break;");
}
typedef Statement INHERITED;
diff --git a/src/sksl/ir/SkSLConstructor.h b/src/sksl/ir/SkSLConstructor.h
index 5c647c7cab..3360ace78e 100644
--- a/src/sksl/ir/SkSLConstructor.h
+++ b/src/sksl/ir/SkSLConstructor.h
@@ -44,9 +44,9 @@ struct Constructor : public Expression {
return nullptr;
}
- String description() const override {
- String result = fType.description() + "(";
- String separator;
+ SkString description() const override {
+ SkString result = fType.description() + "(";
+ SkString separator;
for (size_t i = 0; i < fArguments.size(); i++) {
result += separator;
result += fArguments[i]->description();
diff --git a/src/sksl/ir/SkSLContinueStatement.h b/src/sksl/ir/SkSLContinueStatement.h
index 3f5bc1d4bb..b4446940cf 100644
--- a/src/sksl/ir/SkSLContinueStatement.h
+++ b/src/sksl/ir/SkSLContinueStatement.h
@@ -4,7 +4,7 @@
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
-
+
#ifndef SKSL_CONTINUESTATEMENT
#define SKSL_CONTINUESTATEMENT
@@ -14,14 +14,14 @@
namespace SkSL {
/**
- * A 'continue' statement.
+ * A 'continue' statement.
*/
struct ContinueStatement : public Statement {
ContinueStatement(Position position)
: INHERITED(position, kContinue_Kind) {}
- String description() const override {
- return String("continue;");
+ SkString description() const override {
+ return SkString("continue;");
}
typedef Statement INHERITED;
diff --git a/src/sksl/ir/SkSLDiscardStatement.h b/src/sksl/ir/SkSLDiscardStatement.h
index 62124668ee..3ab6b27047 100644
--- a/src/sksl/ir/SkSLDiscardStatement.h
+++ b/src/sksl/ir/SkSLDiscardStatement.h
@@ -4,7 +4,7 @@
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
-
+
#ifndef SKSL_DISCARDSTATEMENT
#define SKSL_DISCARDSTATEMENT
@@ -14,14 +14,14 @@
namespace SkSL {
/**
- * A 'discard' statement.
+ * A 'discard' statement.
*/
struct DiscardStatement : public Statement {
DiscardStatement(Position position)
: INHERITED(position, kDiscard_Kind) {}
- String description() const override {
- return String("discard;");
+ SkString description() const override {
+ return SkString("discard;");
}
typedef Statement INHERITED;
diff --git a/src/sksl/ir/SkSLDoStatement.h b/src/sksl/ir/SkSLDoStatement.h
index 4d3d34864d..e26d3dc974 100644
--- a/src/sksl/ir/SkSLDoStatement.h
+++ b/src/sksl/ir/SkSLDoStatement.h
@@ -4,7 +4,7 @@
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
-
+
#ifndef SKSL_DOSTATEMENT
#define SKSL_DOSTATEMENT
@@ -23,7 +23,7 @@ struct DoStatement : public Statement {
, fStatement(std::move(statement))
, fTest(std::move(test)) {}
- String description() const override {
+ SkString description() const override {
return "do " + fStatement->description() + " while (" + fTest->description() + ");";
}
diff --git a/src/sksl/ir/SkSLExpressionStatement.h b/src/sksl/ir/SkSLExpressionStatement.h
index d1ab8e9ed9..088b1c9ad1 100644
--- a/src/sksl/ir/SkSLExpressionStatement.h
+++ b/src/sksl/ir/SkSLExpressionStatement.h
@@ -4,7 +4,7 @@
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
-
+
#ifndef SKSL_EXPRESSIONSTATEMENT
#define SKSL_EXPRESSIONSTATEMENT
@@ -14,14 +14,14 @@
namespace SkSL {
/**
- * A lone expression being used as a statement.
+ * A lone expression being used as a statement.
*/
struct ExpressionStatement : public Statement {
ExpressionStatement(std::unique_ptr<Expression> expression)
: INHERITED(expression->fPosition, kExpression_Kind)
, fExpression(std::move(expression)) {}
- String description() const override {
+ SkString description() const override {
return fExpression->description() + ";";
}
diff --git a/src/sksl/ir/SkSLExtension.h b/src/sksl/ir/SkSLExtension.h
index 70dc6b3eaf..ea5e0445e3 100644
--- a/src/sksl/ir/SkSLExtension.h
+++ b/src/sksl/ir/SkSLExtension.h
@@ -4,7 +4,7 @@
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
-
+
#ifndef SKSL_EXTENSION
#define SKSL_EXTENSION
@@ -12,19 +12,19 @@
namespace SkSL {
-/**
- * An extension declaration.
+/**
+ * An extension declaration.
*/
struct Extension : public ProgramElement {
- Extension(Position position, String name)
- : INHERITED(position, kExtension_Kind)
+ Extension(Position position, SkString name)
+ : INHERITED(position, kExtension_Kind)
, fName(std::move(name)) {}
- String description() const override {
+ SkString description() const override {
return "#extension " + fName + " : enable";
}
- const String fName;
+ const SkString fName;
typedef ProgramElement INHERITED;
};
diff --git a/src/sksl/ir/SkSLField.h b/src/sksl/ir/SkSLField.h
index abea730da1..53d85e0d5b 100644
--- a/src/sksl/ir/SkSLField.h
+++ b/src/sksl/ir/SkSLField.h
@@ -4,7 +4,7 @@
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
-
+
#ifndef SKSL_FIELD
#define SKSL_FIELD
@@ -16,9 +16,9 @@
namespace SkSL {
-/**
- * A symbol which should be interpreted as a field access. Fields are added to the symboltable
- * whenever a bare reference to an identifier should refer to a struct field; in GLSL, this is the
+/**
+ * A symbol which should be interpreted as a field access. Fields are added to the symboltable
+ * whenever a bare reference to an identifier should refer to a struct field; in GLSL, this is the
* result of declaring anonymous interface blocks.
*/
struct Field : public Symbol {
@@ -27,7 +27,7 @@ struct Field : public Symbol {
, fOwner(owner)
, fFieldIndex(fieldIndex) {}
- virtual String description() const override {
+ virtual SkString description() const override {
return fOwner.description() + "." + fOwner.fType.fields()[fFieldIndex].fName;
}
diff --git a/src/sksl/ir/SkSLFieldAccess.h b/src/sksl/ir/SkSLFieldAccess.h
index eead41c71f..de26a3f626 100644
--- a/src/sksl/ir/SkSLFieldAccess.h
+++ b/src/sksl/ir/SkSLFieldAccess.h
@@ -4,7 +4,7 @@
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
-
+
#ifndef SKSL_FIELDACCESS
#define SKSL_FIELDACCESS
@@ -24,14 +24,14 @@ struct FieldAccess : public Expression {
kAnonymousInterfaceBlock_OwnerKind
};
- FieldAccess(std::unique_ptr<Expression> base, int fieldIndex,
+ FieldAccess(std::unique_ptr<Expression> base, int fieldIndex,
OwnerKind ownerKind = kDefault_OwnerKind)
: INHERITED(base->fPosition, kFieldAccess_Kind, *base->fType.fields()[fieldIndex].fType)
, fBase(std::move(base))
, fFieldIndex(fieldIndex)
, fOwnerKind(ownerKind) {}
- virtual String description() const override {
+ virtual SkString description() const override {
return fBase->description() + "." + fBase->fType.fields()[fFieldIndex].fName;
}
diff --git a/src/sksl/ir/SkSLFloatLiteral.h b/src/sksl/ir/SkSLFloatLiteral.h
index 5ed123575b..8a1a5ad63a 100644
--- a/src/sksl/ir/SkSLFloatLiteral.h
+++ b/src/sksl/ir/SkSLFloatLiteral.h
@@ -4,7 +4,7 @@
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
-
+
#ifndef SKSL_FLOATLITERAL
#define SKSL_FLOATLITERAL
@@ -21,7 +21,7 @@ struct FloatLiteral : public Expression {
: INHERITED(position, kFloatLiteral_Kind, *context.fFloat_Type)
, fValue(value) {}
- virtual String description() const override {
+ virtual SkString description() const override {
return to_string(fValue);
}
diff --git a/src/sksl/ir/SkSLForStatement.h b/src/sksl/ir/SkSLForStatement.h
index b72c26b179..f2bf880ddd 100644
--- a/src/sksl/ir/SkSLForStatement.h
+++ b/src/sksl/ir/SkSLForStatement.h
@@ -4,7 +4,7 @@
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
-
+
#ifndef SKSL_FORSTATEMENT
#define SKSL_FORSTATEMENT
@@ -18,8 +18,8 @@ namespace SkSL {
* A 'for' statement.
*/
struct ForStatement : public Statement {
- ForStatement(Position position, std::unique_ptr<Statement> initializer,
- std::unique_ptr<Expression> test, std::unique_ptr<Expression> next,
+ ForStatement(Position position, std::unique_ptr<Statement> initializer,
+ std::unique_ptr<Expression> test, std::unique_ptr<Expression> next,
std::unique_ptr<Statement> statement, std::shared_ptr<SymbolTable> symbols)
: INHERITED(position, kFor_Kind)
, fSymbols(symbols)
@@ -28,15 +28,15 @@ struct ForStatement : public Statement {
, fNext(std::move(next))
, fStatement(std::move(statement)) {}
- String description() const override {
- String result("for (");
+ SkString description() const override {
+ SkString result("for (");
if (fInitializer) {
result += fInitializer->description();
- }
+ }
result += " ";
if (fTest) {
result += fTest->description();
- }
+ }
result += "; ";
if (fNext) {
result += fNext->description();
diff --git a/src/sksl/ir/SkSLFunctionCall.h b/src/sksl/ir/SkSLFunctionCall.h
index 1a5c6fd693..1838076796 100644
--- a/src/sksl/ir/SkSLFunctionCall.h
+++ b/src/sksl/ir/SkSLFunctionCall.h
@@ -4,7 +4,7 @@
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
-
+
#ifndef SKSL_FUNCTIONCALL
#define SKSL_FUNCTIONCALL
@@ -23,9 +23,9 @@ struct FunctionCall : public Expression {
, fFunction(std::move(function))
, fArguments(std::move(arguments)) {}
- String description() const override {
- String result = fFunction.fName + "(";
- String separator;
+ SkString description() const override {
+ SkString result = fFunction.fName + "(";
+ SkString separator;
for (size_t i = 0; i < fArguments.size(); i++) {
result += separator;
result += fArguments[i]->description();
diff --git a/src/sksl/ir/SkSLFunctionDeclaration.h b/src/sksl/ir/SkSLFunctionDeclaration.h
index 05ba03addb..c15d2b96dc 100644
--- a/src/sksl/ir/SkSLFunctionDeclaration.h
+++ b/src/sksl/ir/SkSLFunctionDeclaration.h
@@ -4,7 +4,7 @@
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
-
+
#ifndef SKSL_FUNCTIONDECLARATION
#define SKSL_FUNCTIONDECLARATION
@@ -21,7 +21,7 @@ namespace SkSL {
* A function declaration (not a definition -- does not contain a body).
*/
struct FunctionDeclaration : public Symbol {
- FunctionDeclaration(Position position, String name,
+ FunctionDeclaration(Position position, SkString name,
std::vector<const Variable*> parameters, const Type& returnType)
: INHERITED(position, kFunctionDeclaration_Kind, std::move(name))
, fDefined(false)
@@ -29,9 +29,9 @@ struct FunctionDeclaration : public Symbol {
, fParameters(std::move(parameters))
, fReturnType(returnType) {}
- String description() const override {
- String result = fReturnType.description() + " " + fName + "(";
- String separator;
+ SkString description() const override {
+ SkString result = fReturnType.description() + " " + fName + "(";
+ SkString separator;
for (auto p : fParameters) {
result += separator;
separator = ", ";
@@ -58,7 +58,7 @@ struct FunctionDeclaration : public Symbol {
/**
* Determine the effective types of this function's parameters and return value when called with
- * the given arguments. This is relevant for functions with generic parameter types, where this
+ * the given arguments. This is relevant for functions with generic parameter types, where this
* will collapse the generic types down into specific concrete types.
*
* Returns true if it was able to select a concrete set of types for the generic function, false
diff --git a/src/sksl/ir/SkSLFunctionDefinition.h b/src/sksl/ir/SkSLFunctionDefinition.h
index e87ee63e7a..bae882525a 100644
--- a/src/sksl/ir/SkSLFunctionDefinition.h
+++ b/src/sksl/ir/SkSLFunctionDefinition.h
@@ -4,7 +4,7 @@
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
-
+
#ifndef SKSL_FUNCTIONDEFINITION
#define SKSL_FUNCTIONDEFINITION
@@ -18,13 +18,13 @@ namespace SkSL {
* A function definition (a declaration plus an associated block of code).
*/
struct FunctionDefinition : public ProgramElement {
- FunctionDefinition(Position position, const FunctionDeclaration& declaration,
+ FunctionDefinition(Position position, const FunctionDeclaration& declaration,
std::unique_ptr<Block> body)
: INHERITED(position, kFunction_Kind)
, fDeclaration(declaration)
, fBody(std::move(body)) {}
- String description() const override {
+ SkString description() const override {
return fDeclaration.description() + " " + fBody->description();
}
diff --git a/src/sksl/ir/SkSLFunctionReference.h b/src/sksl/ir/SkSLFunctionReference.h
index 49ddf839f9..e95833d6e6 100644
--- a/src/sksl/ir/SkSLFunctionReference.h
+++ b/src/sksl/ir/SkSLFunctionReference.h
@@ -4,7 +4,7 @@
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
-
+
#ifndef SKSL_FUNCTIONREFERENCE
#define SKSL_FUNCTIONREFERENCE
@@ -15,18 +15,18 @@
namespace SkSL {
/**
- * An identifier referring to a function name. This is an intermediate value: FunctionReferences are
+ * An identifier referring to a function name. This is an intermediate value: FunctionReferences are
* always eventually replaced by FunctionCalls in valid programs.
*/
struct FunctionReference : public Expression {
- FunctionReference(const Context& context, Position position,
+ FunctionReference(const Context& context, Position position,
std::vector<const FunctionDeclaration*> function)
: INHERITED(position, kFunctionReference_Kind, *context.fInvalid_Type)
, fFunctions(function) {}
- virtual String description() const override {
+ virtual SkString description() const override {
ASSERT(false);
- return String("<function>");
+ return SkString("<function>");
}
const std::vector<const FunctionDeclaration*> fFunctions;
diff --git a/src/sksl/ir/SkSLIRNode.h b/src/sksl/ir/SkSLIRNode.h
index 139be32f44..9a04cddec5 100644
--- a/src/sksl/ir/SkSLIRNode.h
+++ b/src/sksl/ir/SkSLIRNode.h
@@ -4,7 +4,7 @@
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
-
+
#ifndef SKSL_IRNODE
#define SKSL_IRNODE
@@ -13,7 +13,7 @@
namespace SkSL {
/**
- * Represents a node in the intermediate representation (IR) tree. The IR is a fully-resolved
+ * Represents a node in the intermediate representation (IR) tree. The IR is a fully-resolved
* version of the program (all types determined, everything validated), ready for code generation.
*/
struct IRNode {
@@ -22,7 +22,7 @@ struct IRNode {
virtual ~IRNode() {}
- virtual String description() const = 0;
+ virtual SkString description() const = 0;
const Position fPosition;
};
diff --git a/src/sksl/ir/SkSLIfStatement.h b/src/sksl/ir/SkSLIfStatement.h
index a7e0aad00e..8667e932ec 100644
--- a/src/sksl/ir/SkSLIfStatement.h
+++ b/src/sksl/ir/SkSLIfStatement.h
@@ -4,7 +4,7 @@
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
-
+
#ifndef SKSL_IFSTATEMENT
#define SKSL_IFSTATEMENT
@@ -17,15 +17,15 @@ namespace SkSL {
* An 'if' statement.
*/
struct IfStatement : public Statement {
- IfStatement(Position position, std::unique_ptr<Expression> test,
+ IfStatement(Position position, std::unique_ptr<Expression> test,
std::unique_ptr<Statement> ifTrue, std::unique_ptr<Statement> ifFalse)
: INHERITED(position, kIf_Kind)
, fTest(std::move(test))
, fIfTrue(std::move(ifTrue))
, fIfFalse(std::move(ifFalse)) {}
- String description() const override {
- String result = "if (" + fTest->description() + ") " + fIfTrue->description();
+ SkString description() const override {
+ SkString result = "if (" + fTest->description() + ") " + fIfTrue->description();
if (fIfFalse) {
result += " else " + fIfFalse->description();
}
diff --git a/src/sksl/ir/SkSLIndexExpression.h b/src/sksl/ir/SkSLIndexExpression.h
index 68823bf184..d255c7daf6 100644
--- a/src/sksl/ir/SkSLIndexExpression.h
+++ b/src/sksl/ir/SkSLIndexExpression.h
@@ -4,7 +4,7 @@
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
-
+
#ifndef SKSL_INDEX
#define SKSL_INDEX
@@ -43,7 +43,7 @@ static const Type& index_type(const Context& context, const Type& type) {
* An expression which extracts a value from an array or matrix, as in 'm[2]'.
*/
struct IndexExpression : public Expression {
- IndexExpression(const Context& context, std::unique_ptr<Expression> base,
+ IndexExpression(const Context& context, std::unique_ptr<Expression> base,
std::unique_ptr<Expression> index)
: INHERITED(base->fPosition, kIndex_Kind, index_type(context, base->fType))
, fBase(std::move(base))
@@ -51,7 +51,7 @@ struct IndexExpression : public Expression {
ASSERT(fIndex->fType == *context.fInt_Type || fIndex->fType == *context.fUInt_Type);
}
- String description() const override {
+ SkString description() const override {
return fBase->description() + "[" + fIndex->description() + "]";
}
diff --git a/src/sksl/ir/SkSLIntLiteral.h b/src/sksl/ir/SkSLIntLiteral.h
index 2322a3d40a..b6a23d650c 100644
--- a/src/sksl/ir/SkSLIntLiteral.h
+++ b/src/sksl/ir/SkSLIntLiteral.h
@@ -4,7 +4,7 @@
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
-
+
#ifndef SKSL_INTLITERAL
#define SKSL_INTLITERAL
@@ -23,7 +23,7 @@ struct IntLiteral : public Expression {
: INHERITED(position, kIntLiteral_Kind, type ? *type : *context.fInt_Type)
, fValue(value) {}
- virtual String description() const override {
+ virtual SkString description() const override {
return to_string(fValue);
}
diff --git a/src/sksl/ir/SkSLInterfaceBlock.h b/src/sksl/ir/SkSLInterfaceBlock.h
index dd96dc8b9c..0de37c59e8 100644
--- a/src/sksl/ir/SkSLInterfaceBlock.h
+++ b/src/sksl/ir/SkSLInterfaceBlock.h
@@ -4,7 +4,7 @@
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
-
+
#ifndef SKSL_INTERFACEBLOCK
#define SKSL_INTERFACEBLOCK
@@ -25,7 +25,7 @@ namespace SkSL {
* At the IR level, this is represented by a single variable of struct type.
*/
struct InterfaceBlock : public ProgramElement {
- InterfaceBlock(Position position, const Variable& var, String typeName, String instanceName,
+ InterfaceBlock(Position position, const Variable& var, SkString typeName, SkString instanceName,
std::vector<std::unique_ptr<Expression>> sizes,
std::shared_ptr<SymbolTable> typeOwner)
: INHERITED(position, kInterfaceBlock_Kind)
@@ -35,8 +35,8 @@ struct InterfaceBlock : public ProgramElement {
, fSizes(std::move(sizes))
, fTypeOwner(typeOwner) {}
- String description() const override {
- String result = fVariable.fModifiers.description() + fTypeName + " {\n";
+ SkString description() const override {
+ SkString result = fVariable.fModifiers.description() + fTypeName + " {\n";
const Type* structType = &fVariable.fType;
while (structType->kind() == Type::kArray_Kind) {
structType = &structType->componentType();
@@ -59,8 +59,8 @@ struct InterfaceBlock : public ProgramElement {
}
const Variable& fVariable;
- const String fTypeName;
- const String fInstanceName;
+ const SkString fTypeName;
+ const SkString fInstanceName;
const std::vector<std::unique_ptr<Expression>> fSizes;
const std::shared_ptr<SymbolTable> fTypeOwner;
diff --git a/src/sksl/ir/SkSLLayout.h b/src/sksl/ir/SkSLLayout.h
index 3a8416ac4e..5e7ec4486b 100644
--- a/src/sksl/ir/SkSLLayout.h
+++ b/src/sksl/ir/SkSLLayout.h
@@ -8,6 +8,7 @@
#ifndef SKSL_LAYOUT
#define SKSL_LAYOUT
+#include "SkString.h"
#include "SkSLUtil.h"
namespace SkSL {
@@ -54,11 +55,11 @@ struct Layout {
case Format::kRGBA8I: return "rgba8i";
case Format::kR8I: return "r8i";
}
- ABORT("Unexpected format");
+ SkFAIL("Unexpected format");
return "";
}
- static bool ReadFormat(String str, Format* format) {
+ static bool ReadFormat(SkString str, Format* format) {
if (str == "rgba32f") {
*format = Format::kRGBA32F;
return true;
@@ -124,9 +125,9 @@ struct Layout {
, fMaxVertices(-1)
, fInvocations(-1) {}
- String description() const {
- String result;
- String separator;
+ SkString description() const {
+ SkString result;
+ SkString separator;
if (fLocation >= 0) {
result += separator + "location = " + to_string(fLocation);
separator = ", ";
diff --git a/src/sksl/ir/SkSLModifiers.h b/src/sksl/ir/SkSLModifiers.h
index 9fae5b098c..c7a563973e 100644
--- a/src/sksl/ir/SkSLModifiers.h
+++ b/src/sksl/ir/SkSLModifiers.h
@@ -42,8 +42,8 @@ struct Modifiers {
: fLayout(layout)
, fFlags(flags) {}
- String description() const {
- String result = fLayout.description();
+ SkString description() const {
+ SkString result = fLayout.description();
if (fFlags & kUniform_Flag) {
result += "uniform ";
}
diff --git a/src/sksl/ir/SkSLModifiersDeclaration.h b/src/sksl/ir/SkSLModifiersDeclaration.h
index a0ce74852d..625954d7c7 100644
--- a/src/sksl/ir/SkSLModifiersDeclaration.h
+++ b/src/sksl/ir/SkSLModifiersDeclaration.h
@@ -4,7 +4,7 @@
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
-
+
#ifndef SKSL_MODIFIERDECLARATION
#define SKSL_MODIFIERDECLARATION
@@ -23,7 +23,7 @@ struct ModifiersDeclaration : public ProgramElement {
: INHERITED(Position(), kModifiers_Kind)
, fModifiers(modifiers) {}
- String description() const {
+ SkString description() const {
return fModifiers.description() + ";";
}
diff --git a/src/sksl/ir/SkSLPostfixExpression.h b/src/sksl/ir/SkSLPostfixExpression.h
index 2c84af72fd..05ff1675e0 100644
--- a/src/sksl/ir/SkSLPostfixExpression.h
+++ b/src/sksl/ir/SkSLPostfixExpression.h
@@ -4,7 +4,7 @@
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
-
+
#ifndef SKSL_POSTFIXEXPRESSION
#define SKSL_POSTFIXEXPRESSION
@@ -22,7 +22,7 @@ struct PostfixExpression : public Expression {
, fOperand(std::move(operand))
, fOperator(op) {}
- virtual String description() const override {
+ virtual SkString description() const override {
return fOperand->description() + Token::OperatorName(fOperator);
}
diff --git a/src/sksl/ir/SkSLPrefixExpression.h b/src/sksl/ir/SkSLPrefixExpression.h
index 4fa54ca32d..dafe1e9599 100644
--- a/src/sksl/ir/SkSLPrefixExpression.h
+++ b/src/sksl/ir/SkSLPrefixExpression.h
@@ -4,7 +4,7 @@
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
-
+
#ifndef SKSL_PREFIXEXPRESSION
#define SKSL_PREFIXEXPRESSION
@@ -22,7 +22,7 @@ struct PrefixExpression : public Expression {
, fOperand(std::move(operand))
, fOperator(op) {}
- virtual String description() const override {
+ virtual SkString description() const override {
return Token::OperatorName(fOperator) + fOperand->description();
}
diff --git a/src/sksl/ir/SkSLProgram.h b/src/sksl/ir/SkSLProgram.h
index 96bd5c4fbd..2ca9372ec4 100644
--- a/src/sksl/ir/SkSLProgram.h
+++ b/src/sksl/ir/SkSLProgram.h
@@ -26,11 +26,7 @@ namespace SkSL {
*/
struct Program {
struct Settings {
-#ifdef SKSL_STANDALONE
- const StandaloneShaderCaps* fCaps = &standaloneCaps;
-#else
const GrShaderCaps* fCaps = nullptr;
-#endif
// if false, sk_FragCoord is exactly the same as gl_FragCoord. If true, the y coordinate
// must be flipped.
bool fFlipY = false;
diff --git a/src/sksl/ir/SkSLProgramElement.h b/src/sksl/ir/SkSLProgramElement.h
index ebb4e9a84d..2f1ce77199 100644
--- a/src/sksl/ir/SkSLProgramElement.h
+++ b/src/sksl/ir/SkSLProgramElement.h
@@ -4,7 +4,7 @@
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
-
+
#ifndef SKSL_PROGRAMELEMENT
#define SKSL_PROGRAMELEMENT
diff --git a/src/sksl/ir/SkSLReturnStatement.h b/src/sksl/ir/SkSLReturnStatement.h
index 841db94669..dc5ec9aa9c 100644
--- a/src/sksl/ir/SkSLReturnStatement.h
+++ b/src/sksl/ir/SkSLReturnStatement.h
@@ -4,7 +4,7 @@
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
-
+
#ifndef SKSL_RETURNSTATEMENT
#define SKSL_RETURNSTATEMENT
@@ -21,14 +21,14 @@ struct ReturnStatement : public Statement {
: INHERITED(position, kReturn_Kind) {}
ReturnStatement(std::unique_ptr<Expression> expression)
- : INHERITED(expression->fPosition, kReturn_Kind)
+ : INHERITED(expression->fPosition, kReturn_Kind)
, fExpression(std::move(expression)) {}
- String description() const override {
+ SkString description() const override {
if (fExpression) {
return "return " + fExpression->description() + ";";
} else {
- return String("return;");
+ return SkString("return;");
}
}
diff --git a/src/sksl/ir/SkSLStatement.h b/src/sksl/ir/SkSLStatement.h
index ba1a08772e..c3a6f9539e 100644
--- a/src/sksl/ir/SkSLStatement.h
+++ b/src/sksl/ir/SkSLStatement.h
@@ -4,7 +4,7 @@
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
-
+
#ifndef SKSL_STATEMENT
#define SKSL_STATEMENT
diff --git a/src/sksl/ir/SkSLSwitchCase.h b/src/sksl/ir/SkSLSwitchCase.h
index 8043f2e787..1fc2e852bc 100644
--- a/src/sksl/ir/SkSLSwitchCase.h
+++ b/src/sksl/ir/SkSLSwitchCase.h
@@ -23,8 +23,8 @@ struct SwitchCase : public Statement {
, fValue(std::move(value))
, fStatements(std::move(statements)) {}
- String description() const override {
- String result;
+ SkString description() const override {
+ SkString result;
if (fValue) {
result.appendf("case %s:\n", fValue->description().c_str());
} else {
diff --git a/src/sksl/ir/SkSLSwitchStatement.h b/src/sksl/ir/SkSLSwitchStatement.h
index 88e1e70019..31765c4e04 100644
--- a/src/sksl/ir/SkSLSwitchStatement.h
+++ b/src/sksl/ir/SkSLSwitchStatement.h
@@ -23,8 +23,8 @@ struct SwitchStatement : public Statement {
, fValue(std::move(value))
, fCases(std::move(cases)) {}
- String description() const override {
- String result = String::printf("switch (%s) {\n", + fValue->description().c_str());
+ SkString description() const override {
+ SkString result = SkStringPrintf("switch (%s) {\n", + fValue->description().c_str());
for (const auto& c : fCases) {
result += c->description();
}
diff --git a/src/sksl/ir/SkSLSwizzle.h b/src/sksl/ir/SkSLSwizzle.h
index 1725ec2b5a..0803f3bc36 100644
--- a/src/sksl/ir/SkSLSwizzle.h
+++ b/src/sksl/ir/SkSLSwizzle.h
@@ -4,7 +4,7 @@
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
-
+
#ifndef SKSL_SWIZZLE
#define SKSL_SWIZZLE
@@ -15,7 +15,7 @@
namespace SkSL {
/**
- * Given a type and a swizzle component count, returns the type that will result from swizzling. For
+ * Given a type and a swizzle component count, returns the type that will result from swizzling. For
* instance, swizzling a vec3 with two components will result in a vec2. It is possible to swizzle
* with more components than the source vector, as in 'vec2(1).xxxx'.
*/
@@ -69,8 +69,8 @@ struct Swizzle : public Expression {
ASSERT(fComponents.size() >= 1 && fComponents.size() <= 4);
}
- String description() const override {
- String result = fBase->description() + ".";
+ SkString description() const override {
+ SkString result = fBase->description() + ".";
for (int x : fComponents) {
result += "xyzw"[x];
}
diff --git a/src/sksl/ir/SkSLSymbol.h b/src/sksl/ir/SkSLSymbol.h
index e883ea7555..10dcaf9344 100644
--- a/src/sksl/ir/SkSLSymbol.h
+++ b/src/sksl/ir/SkSLSymbol.h
@@ -4,7 +4,7 @@
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
-
+
#ifndef SKSL_SYMBOL
#define SKSL_SYMBOL
@@ -24,13 +24,13 @@ struct Symbol : public IRNode {
kField_Kind
};
- Symbol(Position position, Kind kind, String name)
+ Symbol(Position position, Kind kind, SkString name)
: INHERITED(position)
, fKind(kind)
, fName(std::move(name)) {}
const Kind fKind;
- const String fName;
+ const SkString fName;
typedef IRNode INHERITED;
};
diff --git a/src/sksl/ir/SkSLSymbolTable.cpp b/src/sksl/ir/SkSLSymbolTable.cpp
index 4d39e8bc9d..3ceeab91b0 100644
--- a/src/sksl/ir/SkSLSymbolTable.cpp
+++ b/src/sksl/ir/SkSLSymbolTable.cpp
@@ -21,7 +21,7 @@ std::vector<const FunctionDeclaration*> SymbolTable::GetFunctions(const Symbol&
}
}
-const Symbol* SymbolTable::operator[](const String& name) {
+const Symbol* SymbolTable::operator[](const SkString& name) {
const auto& entry = fSymbols.find(name);
if (entry == fSymbols.end()) {
if (fParent) {
@@ -64,12 +64,12 @@ Symbol* SymbolTable::takeOwnership(Symbol* s) {
return s;
}
-void SymbolTable::add(const String& name, std::unique_ptr<Symbol> symbol) {
+void SymbolTable::add(const SkString& name, std::unique_ptr<Symbol> symbol) {
this->addWithoutOwnership(name, symbol.get());
fOwnedPointers.push_back(std::move(symbol));
}
-void SymbolTable::addWithoutOwnership(const String& name, const Symbol* symbol) {
+void SymbolTable::addWithoutOwnership(const SkString& name, const Symbol* symbol) {
const auto& existing = fSymbols.find(name);
if (existing == fSymbols.end()) {
fSymbols[name] = symbol;
diff --git a/src/sksl/ir/SkSLSymbolTable.h b/src/sksl/ir/SkSLSymbolTable.h
index 5d3aebc266..df8dc713ae 100644
--- a/src/sksl/ir/SkSLSymbolTable.h
+++ b/src/sksl/ir/SkSLSymbolTable.h
@@ -4,7 +4,7 @@
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
-
+
#ifndef SKSL_SYMBOLTABLE
#define SKSL_SYMBOLTABLE
@@ -31,11 +31,11 @@ public:
: fParent(parent)
, fErrorReporter(errorReporter) {}
- const Symbol* operator[](const String& name);
+ const Symbol* operator[](const SkString& name);
- void add(const String& name, std::unique_ptr<Symbol> symbol);
+ void add(const SkString& name, std::unique_ptr<Symbol> symbol);
- void addWithoutOwnership(const String& name, const Symbol* symbol);
+ void addWithoutOwnership(const SkString& name, const Symbol* symbol);
Symbol* takeOwnership(Symbol* s);
@@ -48,7 +48,7 @@ private:
std::vector<std::unique_ptr<Symbol>> fOwnedPointers;
- std::unordered_map<String, const Symbol*> fSymbols;
+ std::unordered_map<SkString, const Symbol*> fSymbols;
ErrorReporter& fErrorReporter;
};
diff --git a/src/sksl/ir/SkSLTernaryExpression.h b/src/sksl/ir/SkSLTernaryExpression.h
index 9fbac19c25..02750049d4 100644
--- a/src/sksl/ir/SkSLTernaryExpression.h
+++ b/src/sksl/ir/SkSLTernaryExpression.h
@@ -4,7 +4,7 @@
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
-
+
#ifndef SKSL_TERNARYEXPRESSION
#define SKSL_TERNARYEXPRESSION
@@ -26,8 +26,8 @@ struct TernaryExpression : public Expression {
ASSERT(fIfTrue->fType == fIfFalse->fType);
}
- String description() const override {
- return "(" + fTest->description() + " ? " + fIfTrue->description() + " : " +
+ SkString description() const override {
+ return "(" + fTest->description() + " ? " + fIfTrue->description() + " : " +
fIfFalse->description() + ")";
}
diff --git a/src/sksl/ir/SkSLType.cpp b/src/sksl/ir/SkSLType.cpp
index c919cbc8ae..d28c4f0666 100644
--- a/src/sksl/ir/SkSLType.cpp
+++ b/src/sksl/ir/SkSLType.cpp
@@ -4,7 +4,7 @@
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
-
+
#include "SkSLType.h"
#include "SkSLContext.h"
@@ -22,7 +22,7 @@ bool Type::determineCoercionCost(const Type& other, int* outCost) const {
return false;
}
if (this->kind() == kMatrix_Kind) {
- if (this->columns() == other.columns() &&
+ if (this->columns() == other.columns() &&
this->rows() == other.rows()) {
return this->componentType().determineCoercionCost(other.componentType(), outCost);
}
diff --git a/src/sksl/ir/SkSLType.h b/src/sksl/ir/SkSLType.h
index 44bc26272b..2f98e53e62 100644
--- a/src/sksl/ir/SkSLType.h
+++ b/src/sksl/ir/SkSLType.h
@@ -26,17 +26,17 @@ class Context;
class Type : public Symbol {
public:
struct Field {
- Field(Modifiers modifiers, String name, const Type* type)
+ Field(Modifiers modifiers, SkString name, const Type* type)
: fModifiers(modifiers)
, fName(std::move(name))
, fType(std::move(type)) {}
- const String description() const {
+ const SkString description() const {
return fType->description() + " " + fName + ";";
}
Modifiers fModifiers;
- String fName;
+ SkString fName;
const Type* fType;
};
@@ -53,24 +53,24 @@ public:
// Create an "other" (special) type with the given name. These types cannot be directly
// referenced from user code.
- Type(String name)
+ Type(SkString name)
: INHERITED(Position(), kType_Kind, std::move(name))
, fTypeKind(kOther_Kind) {}
// Create a generic type which maps to the listed types.
- Type(String name, std::vector<const Type*> types)
+ Type(SkString name, std::vector<const Type*> types)
: INHERITED(Position(), kType_Kind, std::move(name))
, fTypeKind(kGeneric_Kind)
, fCoercibleTypes(std::move(types)) {}
// Create a struct type with the given fields.
- Type(Position position, String name, std::vector<Field> fields)
+ Type(Position position, SkString name, std::vector<Field> fields)
: INHERITED(position, kType_Kind, std::move(name))
, fTypeKind(kStruct_Kind)
, fFields(std::move(fields)) {}
// Create a scalar type.
- Type(String name, bool isNumber)
+ Type(SkString name, bool isNumber)
: INHERITED(Position(), kType_Kind, std::move(name))
, fTypeKind(kScalar_Kind)
, fIsNumber(isNumber)
@@ -78,7 +78,7 @@ public:
, fRows(1) {}
// Create a scalar type which can be coerced to the listed types.
- Type(String name, bool isNumber, std::vector<const Type*> coercibleTypes)
+ Type(SkString name, bool isNumber, std::vector<const Type*> coercibleTypes)
: INHERITED(Position(), kType_Kind, std::move(name))
, fTypeKind(kScalar_Kind)
, fIsNumber(isNumber)
@@ -87,11 +87,11 @@ public:
, fRows(1) {}
// Create a vector type.
- Type(String name, const Type& componentType, int columns)
+ Type(SkString name, const Type& componentType, int columns)
: Type(name, kVector_Kind, componentType, columns) {}
// Create a vector or array type.
- Type(String name, Kind kind, const Type& componentType, int columns)
+ Type(SkString name, Kind kind, const Type& componentType, int columns)
: INHERITED(Position(), kType_Kind, std::move(name))
, fTypeKind(kind)
, fComponentType(&componentType)
@@ -100,7 +100,7 @@ public:
, fDimensions(SpvDim1D) {}
// Create a matrix type.
- Type(String name, const Type& componentType, int columns, int rows)
+ Type(SkString name, const Type& componentType, int columns, int rows)
: INHERITED(Position(), kType_Kind, std::move(name))
, fTypeKind(kMatrix_Kind)
, fComponentType(&componentType)
@@ -109,7 +109,7 @@ public:
, fDimensions(SpvDim1D) {}
// Create a sampler type.
- Type(String name, SpvDim_ dimensions, bool isDepth, bool isArrayed, bool isMultisampled,
+ Type(SkString name, SpvDim_ dimensions, bool isDepth, bool isArrayed, bool isMultisampled,
bool isSampled)
: INHERITED(Position(), kType_Kind, std::move(name))
, fTypeKind(kSampler_Kind)
@@ -119,11 +119,11 @@ public:
, fIsMultisampled(isMultisampled)
, fIsSampled(isSampled) {}
- String name() const {
+ SkString name() const {
return fName;
}
- String description() const override {
+ SkString description() const override {
return fName;
}
diff --git a/src/sksl/ir/SkSLTypeReference.h b/src/sksl/ir/SkSLTypeReference.h
index b12c185ce2..1c6f16ce58 100644
--- a/src/sksl/ir/SkSLTypeReference.h
+++ b/src/sksl/ir/SkSLTypeReference.h
@@ -4,7 +4,7 @@
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
-
+
#ifndef SKSL_TYPEREFERENCE
#define SKSL_TYPEREFERENCE
@@ -14,7 +14,7 @@
namespace SkSL {
/**
- * Represents an identifier referring to a type. This is an intermediate value: TypeReferences are
+ * Represents an identifier referring to a type. This is an intermediate value: TypeReferences are
* always eventually replaced by Constructors in valid programs.
*/
struct TypeReference : public Expression {
@@ -22,7 +22,7 @@ struct TypeReference : public Expression {
: INHERITED(position, kTypeReference_Kind, *context.fInvalid_Type)
, fValue(type) {}
- String description() const override {
+ SkString description() const override {
return fValue.name();
}
diff --git a/src/sksl/ir/SkSLUnresolvedFunction.h b/src/sksl/ir/SkSLUnresolvedFunction.h
index c5fdbd0734..76741cfca8 100644
--- a/src/sksl/ir/SkSLUnresolvedFunction.h
+++ b/src/sksl/ir/SkSLUnresolvedFunction.h
@@ -4,7 +4,7 @@
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
-
+
#ifndef SKSL_UNRESOLVEDFUNCTION
#define SKSL_UNRESOLVEDFUNCTION
@@ -26,7 +26,7 @@ struct UnresolvedFunction : public Symbol {
#endif
}
- virtual String description() const override {
+ virtual SkString description() const override {
return fName;
}
diff --git a/src/sksl/ir/SkSLVarDeclarations.h b/src/sksl/ir/SkSLVarDeclarations.h
index 5a006bd133..5781230ece 100644
--- a/src/sksl/ir/SkSLVarDeclarations.h
+++ b/src/sksl/ir/SkSLVarDeclarations.h
@@ -4,7 +4,7 @@
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
-
+
#ifndef SKSL_VARDECLARATIONS
#define SKSL_VARDECLARATIONS
@@ -17,7 +17,7 @@ namespace SkSL {
/**
* A single variable declaration within a var declaration statement. For instance, the statement
- * 'int x = 2, y[3];' is a VarDeclarations statement containing two individual VarDeclaration
+ * 'int x = 2, y[3];' is a VarDeclarations statement containing two individual VarDeclaration
* instances.
*/
struct VarDeclaration {
@@ -28,8 +28,8 @@ struct VarDeclaration {
, fSizes(std::move(sizes))
, fValue(std::move(value)) {}
- String description() const {
- String result = fVar->fName;
+ SkString description() const {
+ SkString result = fVar->fName;
for (const auto& size : fSizes) {
if (size) {
result += "[" + size->description() + "]";
@@ -40,7 +40,7 @@ struct VarDeclaration {
if (fValue) {
result += " = " + fValue->description();
}
- return result;
+ return result;
}
const Variable* fVar;
@@ -52,18 +52,18 @@ struct VarDeclaration {
* A variable declaration statement, which may consist of one or more individual variables.
*/
struct VarDeclarations : public ProgramElement {
- VarDeclarations(Position position, const Type* baseType,
+ VarDeclarations(Position position, const Type* baseType,
std::vector<VarDeclaration> vars)
: INHERITED(position, kVar_Kind)
, fBaseType(*baseType)
, fVars(std::move(vars)) {}
- String description() const override {
+ SkString description() const override {
if (!fVars.size()) {
- return String();
+ return SkString();
}
- String result = fVars[0].fVar->fModifiers.description() + fBaseType.description() + " ";
- String separator;
+ SkString result = fVars[0].fVar->fModifiers.description() + fBaseType.description() + " ";
+ SkString separator;
for (const auto& var : fVars) {
result += separator;
separator = ", ";
diff --git a/src/sksl/ir/SkSLVarDeclarationsStatement.h b/src/sksl/ir/SkSLVarDeclarationsStatement.h
index 50365decc1..66b570f853 100644
--- a/src/sksl/ir/SkSLVarDeclarationsStatement.h
+++ b/src/sksl/ir/SkSLVarDeclarationsStatement.h
@@ -4,7 +4,7 @@
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
-
+
#ifndef SKSL_VARDECLARATIONSSTATEMENT
#define SKSL_VARDECLARATIONSSTATEMENT
@@ -21,7 +21,7 @@ struct VarDeclarationsStatement : public Statement {
: INHERITED(decl->fPosition, kVarDeclarations_Kind)
, fDeclaration(std::move(decl)) {}
- String description() const override {
+ SkString description() const override {
return fDeclaration->description();
}
diff --git a/src/sksl/ir/SkSLVariable.h b/src/sksl/ir/SkSLVariable.h
index 21f17bad8e..2c3391dfa2 100644
--- a/src/sksl/ir/SkSLVariable.h
+++ b/src/sksl/ir/SkSLVariable.h
@@ -4,7 +4,7 @@
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
-
+
#ifndef SKSL_VARIABLE
#define SKSL_VARIABLE
@@ -27,7 +27,7 @@ struct Variable : public Symbol {
kParameter_Storage
};
- Variable(Position position, Modifiers modifiers, String name, const Type& type,
+ Variable(Position position, Modifiers modifiers, SkString name, const Type& type,
Storage storage)
: INHERITED(position, kVariable_Kind, std::move(name))
, fModifiers(modifiers)
@@ -36,7 +36,7 @@ struct Variable : public Symbol {
, fReadCount(0)
, fWriteCount(0) {}
- virtual String description() const override {
+ virtual SkString description() const override {
return fModifiers.description() + fType.fName + " " + fName;
}
diff --git a/src/sksl/ir/SkSLVariableReference.h b/src/sksl/ir/SkSLVariableReference.h
index af181f84fd..7d90511590 100644
--- a/src/sksl/ir/SkSLVariableReference.h
+++ b/src/sksl/ir/SkSLVariableReference.h
@@ -4,7 +4,7 @@
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
-
+
#ifndef SKSL_VARIABLEREFERENCE
#define SKSL_VARIABLEREFERENCE
@@ -67,7 +67,7 @@ struct VariableReference : public Expression {
fRefKind = refKind;
}
- String description() const override {
+ SkString description() const override {
return fVariable.fName;
}
diff --git a/src/sksl/ir/SkSLWhileStatement.h b/src/sksl/ir/SkSLWhileStatement.h
index c35d6df9e4..a741a0441d 100644
--- a/src/sksl/ir/SkSLWhileStatement.h
+++ b/src/sksl/ir/SkSLWhileStatement.h
@@ -4,7 +4,7 @@
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
-
+
#ifndef SKSL_WHILESTATEMENT
#define SKSL_WHILESTATEMENT
@@ -17,13 +17,13 @@ namespace SkSL {
* A 'while' loop.
*/
struct WhileStatement : public Statement {
- WhileStatement(Position position, std::unique_ptr<Expression> test,
+ WhileStatement(Position position, std::unique_ptr<Expression> test,
std::unique_ptr<Statement> statement)
: INHERITED(position, kWhile_Kind)
, fTest(std::move(test))
, fStatement(std::move(statement)) {}
- String description() const override {
+ SkString description() const override {
return "while (" + fTest->description() + ") " + fStatement->description();
}
diff --git a/tests/SkSLErrorTest.cpp b/tests/SkSLErrorTest.cpp
index bd0c64a93b..bde5e70795 100644
--- a/tests/SkSLErrorTest.cpp
+++ b/tests/SkSLErrorTest.cpp
@@ -13,16 +13,17 @@
static void test_failure(skiatest::Reporter* r, const char* src, const char* error) {
SkSL::Compiler compiler;
+ SkDynamicMemoryWStream out;
SkSL::Program::Settings settings;
sk_sp<GrShaderCaps> caps = SkSL::ShaderCapsFactory::Default();
settings.fCaps = caps.get();
std::unique_ptr<SkSL::Program> program = compiler.convertProgram(SkSL::Program::kFragment_Kind,
SkString(src), settings);
if (program) {
- SkSL::String ignored;
+ SkString ignored;
compiler.toSPIRV(*program, &ignored);
}
- SkSL::String skError(error);
+ SkString skError(error);
if (compiler.errorText() != skError) {
SkDebugf("SKSL ERROR:\n source: %s\n expected: %s received: %s", src, error,
compiler.errorText().c_str());
@@ -32,13 +33,14 @@ static void test_failure(skiatest::Reporter* r, const char* src, const char* err
static void test_success(skiatest::Reporter* r, const char* src) {
SkSL::Compiler compiler;
+ SkDynamicMemoryWStream out;
SkSL::Program::Settings settings;
sk_sp<GrShaderCaps> caps = SkSL::ShaderCapsFactory::Default();
settings.fCaps = caps.get();
std::unique_ptr<SkSL::Program> program = compiler.convertProgram(SkSL::Program::kFragment_Kind,
SkString(src), settings);
REPORTER_ASSERT(r, program);
- SkSL::String ignored;
+ SkString ignored;
REPORTER_ASSERT(r, compiler.toSPIRV(*program, &ignored));
}
diff --git a/tests/SkSLGLSLTest.cpp b/tests/SkSLGLSLTest.cpp
index efae33604b..53e5c6badf 100644
--- a/tests/SkSLGLSLTest.cpp
+++ b/tests/SkSLGLSLTest.cpp
@@ -15,7 +15,7 @@ static void test(skiatest::Reporter* r, const char* src, const SkSL::Program::Se
const char* expected, SkSL::Program::Inputs* inputs,
SkSL::Program::Kind kind = SkSL::Program::kFragment_Kind) {
SkSL::Compiler compiler;
- SkSL::String output;
+ SkString output;
std::unique_ptr<SkSL::Program> program = compiler.convertProgram(kind, SkString(src), settings);
if (!program) {
SkDebugf("Unexpected error compiling %s\n%s", src, compiler.errorText().c_str());
@@ -24,7 +24,7 @@ static void test(skiatest::Reporter* r, const char* src, const SkSL::Program::Se
*inputs = program->fInputs;
REPORTER_ASSERT(r, compiler.toGLSL(*program, &output));
if (program) {
- SkSL::String skExpected(expected);
+ SkString skExpected(expected);
if (output != skExpected) {
SkDebugf("GLSL MISMATCH:\nsource:\n%s\n\nexpected:\n'%s'\n\nreceived:\n'%s'", src,
expected, output.c_str());