From f3333c89bf05fc602d9bf8e1e24547668c660383 Mon Sep 17 00:00:00 2001 From: Ethan Nicholas Date: Fri, 31 Mar 2017 09:33:41 -0400 Subject: skslc can now be compiled with no Skia dependencies, in preparation for its eventual role in Skia's build process. This reverts commit bcf35f86d50b784b165de703b404998dd4299f6a. BUG=skia: Change-Id: Id0a12dfc4d804d69a3c6bf60fed37e89ee130f02 Reviewed-on: https://skia-review.googlesource.com/10802 Commit-Queue: Ethan Nicholas Reviewed-by: Ben Wagner --- src/sksl/SkSLGLSLCodeGenerator.cpp | 43 ++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 23 deletions(-) (limited to 'src/sksl/SkSLGLSLCodeGenerator.cpp') diff --git a/src/sksl/SkSLGLSLCodeGenerator.cpp b/src/sksl/SkSLGLSLCodeGenerator.cpp index a19de8f844..ab64e66f7c 100644 --- a/src/sksl/SkSLGLSLCodeGenerator.cpp +++ b/src/sksl/SkSLGLSLCodeGenerator.cpp @@ -7,8 +7,6 @@ #include "SkSLGLSLCodeGenerator.h" -#include "string.h" - #include "GLSL.std.450.h" #include "SkSLCompiler.h" @@ -35,15 +33,15 @@ void GLSLCodeGenerator::write(const char* s) { void GLSLCodeGenerator::writeLine(const char* s) { this->write(s); - fOut->writeText("\n"); + fOut->write8('\n'); fAtLineStart = true; } -void GLSLCodeGenerator::write(const SkString& s) { +void GLSLCodeGenerator::write(const String& s) { this->write(s.c_str()); } -void GLSLCodeGenerator::writeLine(const SkString& s) { +void GLSLCodeGenerator::writeLine(const String& s) { this->writeLine(s.c_str()); } @@ -137,8 +135,8 @@ static bool is_abs(Expression& expr) { // Tegra3 compiler bug. void GLSLCodeGenerator::writeMinAbsHack(Expression& absExpr, Expression& otherExpr) { ASSERT(!fProgram.fSettings.fCaps->canUseMinAndAbsTogether()); - SkString tmpVar1 = "minAbsHackVar" + to_string(fVarCount++); - SkString tmpVar2 = "minAbsHackVar" + to_string(fVarCount++); + String tmpVar1 = "minAbsHackVar" + to_string(fVarCount++); + String tmpVar2 = "minAbsHackVar" + to_string(fVarCount++); this->fFunctionHeader += " " + absExpr.fType.name() + " " + tmpVar1 + ";\n"; this->fFunctionHeader += " " + otherExpr.fType.name() + " " + tmpVar2 + ";\n"; this->write("((" + tmpVar1 + " = "); @@ -411,7 +409,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) { @@ -425,7 +423,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("("); @@ -440,7 +438,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("("); @@ -452,7 +450,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("("); @@ -507,8 +505,8 @@ void GLSLCodeGenerator::writeFunction(const FunctionDefinition& f) { this->writeLine(") {"); fFunctionHeader = ""; - SkWStream* oldOut = fOut; - SkDynamicMemoryWStream buffer; + OutputStream* oldOut = fOut; + StringStream buffer; fOut = &buffer; fIndentation++; for (const auto& s : f.fBody->fStatements) { @@ -520,8 +518,7 @@ void GLSLCodeGenerator::writeFunction(const FunctionDefinition& f) { fOut = oldOut; this->write(fFunctionHeader); - sk_sp data(buffer.detachAsData()); - this->write(SkString((const char*) data->data(), data->size())); + this->write(String(buffer.data(), buffer.size())); } void GLSLCodeGenerator::writeModifiers(const Modifiers& modifiers, @@ -532,7 +529,7 @@ void GLSLCodeGenerator::writeModifiers(const Modifiers& modifiers, if (modifiers.fFlags & Modifiers::kNoPerspective_Flag) { this->write("noperspective "); } - SkString layout = modifiers.fLayout.description(); + String layout = modifiers.fLayout.description(); if (layout.size()) { this->write(layout + " "); } @@ -625,11 +622,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); - SkString separator(" "); + String separator(" "); for (const auto& var : decl.fVars) { ASSERT(var.fVar->fModifiers == decl.fVars[0].fVar->fModifiers); this->write(separator); - separator = SkString(", "); + separator = String(", "); this->write(var.fVar->fName); for (const auto& size : var.fSizes) { this->write("["); @@ -663,7 +660,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: @@ -787,7 +784,7 @@ void GLSLCodeGenerator::writeReturnStatement(const ReturnStatement& r) { } bool GLSLCodeGenerator::generateCode() { - SkWStream* rawOut = fOut; + OutputStream* rawOut = fOut; fOut = &fHeader; fProgramKind = fProgram.fKind; this->write(fProgram.fSettings.fCaps->versionDeclString()); @@ -797,7 +794,7 @@ bool GLSLCodeGenerator::generateCode() { this->writeExtension((Extension&) *e); } } - SkDynamicMemoryWStream body; + StringStream body; fOut = &body; if (fProgram.fSettings.fCaps->usesPrecisionModifiers()) { this->write("precision "); @@ -857,8 +854,8 @@ bool GLSLCodeGenerator::generateCode() { } fOut = nullptr; - write_data(*fHeader.detachAsData(), *rawOut); - write_data(*body.detachAsData(), *rawOut); + write_stringstream(fHeader, *rawOut); + write_stringstream(body, *rawOut); return true; } -- cgit v1.2.3