SkSLPipelineStageCodeGenerator.h 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. /*
  2. * Copyright 2017 Google Inc.
  3. *
  4. * Use of this source code is governed by a BSD-style license that can be
  5. * found in the LICENSE file.
  6. */
  7. #ifndef SKSL_PIPELINESTAGECODEGENERATOR
  8. #define SKSL_PIPELINESTAGECODEGENERATOR
  9. #include "src/sksl/SkSLGLSLCodeGenerator.h"
  10. #include "src/sksl/SkSLSectionAndParameterHelper.h"
  11. #include <set>
  12. namespace SkSL {
  13. class PipelineStageCodeGenerator : public GLSLCodeGenerator {
  14. public:
  15. PipelineStageCodeGenerator(const Context* context, const Program* program,
  16. ErrorReporter* errors, OutputStream* out,
  17. std::vector<Compiler::FormatArg>* outFormatArgs);
  18. private:
  19. void writef(const char* s, va_list va) SKSL_PRINTF_LIKE(2, 0);
  20. void writef(const char* s, ...) SKSL_PRINTF_LIKE(2, 3);
  21. bool writeSection(const char* name, const char* prefix = "");
  22. void writeHeader() override;
  23. bool usesPrecisionModifiers() const override;
  24. String getTypeName(const Type& type) override;
  25. void writeBinaryExpression(const BinaryExpression& b, Precedence parentPrecedence) override;
  26. void writeFunctionCall(const FunctionCall& c) override;
  27. void writeIntLiteral(const IntLiteral& i) override;
  28. void writeVariableReference(const VariableReference& ref) override;
  29. void writeIfStatement(const IfStatement& s) override;
  30. void writeSwitchStatement(const SwitchStatement& s) override;
  31. void writeFunction(const FunctionDefinition& f) override;
  32. void writeProgramElement(const ProgramElement& p) override;
  33. bool writeEmitCode(std::vector<const Variable*>& uniforms);
  34. String fName;
  35. String fFullName;
  36. SectionAndParameterHelper fSectionAndParameterHelper;
  37. String fExtraEmitCodeCode;
  38. std::set<int> fWrittenTransformedCoords;
  39. std::vector<Compiler::FormatArg>* fFormatArgs;
  40. const FunctionDeclaration* fCurrentFunction;
  41. typedef GLSLCodeGenerator INHERITED;
  42. };
  43. }
  44. #endif