aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/sksl/SkSLParser.cpp
diff options
context:
space:
mode:
authorGravatar Brian Salomon <bsalomon@google.com>2017-08-17 11:07:59 -0400
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2017-08-17 15:08:17 +0000
commit1d816b92bb7cf2258007f3f74ffd143b89f25d01 (patch)
tree07fb1e8e2631208eb007a4abdfe130db91e6cfc2 /src/sksl/SkSLParser.cpp
parent23f92277b916a4bdf11c320799ac9248af60a62e (diff)
Revert "Switched highp float to highfloat and mediump float to half."
This reverts commit 88d99c63878c2d3d340120f0321676f72afcb4f0. Reason for revert: Believed to be causing unit test failures in Chrome roll: https://build.chromium.org/p/tryserver.chromium.android/builders/linux_android_rel_ng/builds/364433 https://luci-logdog.appspot.com/v/?s=chromium%2Fbb%2Ftryserver.chromium.android%2Flinux_android_rel_ng%2F364433%2F%2B%2Frecipes%2Fsteps%2Fcontent_browsertests__with_patch__on_Android%2F0%2Flogs%2FWebRtcCaptureFromElementBrowserTest.VerifyCanvasWebGLCaptureColor%2F0 Original change's description: > Switched highp float to highfloat and mediump float to half. > > The ultimate goal is to end up with "float" and "half", but this > intermediate step uses "highfloat" so that it is clear if I missed a > "float" somewhere. Once this lands, a subsequent CL will switch all > "highfloats" back to "floats". > > Bug: skia: > Change-Id: Ia13225c7a0a0a2901e07665891c473d2500ddcca > Reviewed-on: https://skia-review.googlesource.com/31000 > Commit-Queue: Ethan Nicholas <ethannicholas@google.com> > Reviewed-by: Brian Salomon <bsalomon@google.com> TBR=bsalomon@google.com,csmartdalton@google.com,ethannicholas@google.com Change-Id: I8bfa97547ac3920d433665f161d27df3f15c83aa No-Presubmit: true No-Tree-Checks: true No-Try: true Bug: skia: Reviewed-on: https://skia-review.googlesource.com/35705 Commit-Queue: Brian Salomon <bsalomon@google.com> Reviewed-by: Brian Salomon <bsalomon@google.com>
Diffstat (limited to 'src/sksl/SkSLParser.cpp')
-rw-r--r--src/sksl/SkSLParser.cpp40
1 files changed, 39 insertions, 1 deletions
diff --git a/src/sksl/SkSLParser.cpp b/src/sksl/SkSLParser.cpp
index dd044cde4e..f712b34e1a 100644
--- a/src/sksl/SkSLParser.cpp
+++ b/src/sksl/SkSLParser.cpp
@@ -49,6 +49,7 @@ static_assert(YY_FLEX_MAJOR_VERSION * 10000 + YY_FLEX_MINOR_VERSION * 100 +
#include "ast/SkSLASTIntLiteral.h"
#include "ast/SkSLASTModifiersDeclaration.h"
#include "ast/SkSLASTParameter.h"
+#include "ast/SkSLASTPrecision.h"
#include "ast/SkSLASTPrefixExpression.h"
#include "ast/SkSLASTReturnStatement.h"
#include "ast/SkSLASTSection.h"
@@ -108,13 +109,20 @@ Parser::~Parser() {
layoutlex_destroy(fLayoutScanner);
}
-/* (directive | section | declaration)* END_OF_FILE */
+/* (precision | directive | section | declaration)* END_OF_FILE */
std::vector<std::unique_ptr<ASTDeclaration>> Parser::file() {
std::vector<std::unique_ptr<ASTDeclaration>> result;
for (;;) {
switch (this->peek().fKind) {
case Token::END_OF_FILE:
return result;
+ case Token::PRECISION: {
+ std::unique_ptr<ASTDeclaration> precision = this->precision();
+ if (precision) {
+ result.push_back(std::move(precision));
+ }
+ break;
+ }
case Token::DIRECTIVE: {
std::unique_ptr<ASTDeclaration> decl = this->directive();
if (decl) {
@@ -230,6 +238,36 @@ bool Parser::isType(const String& name) {
return nullptr != fTypes[name];
}
+/* PRECISION (LOWP | MEDIUMP | HIGHP) type SEMICOLON */
+std::unique_ptr<ASTDeclaration> Parser::precision() {
+ if (!this->expect(Token::PRECISION, "'precision'")) {
+ return nullptr;
+ }
+ Modifiers::Flag result;
+ Token p = this->nextToken();
+ switch (p.fKind) {
+ case Token::LOWP:
+ result = Modifiers::kLowp_Flag;
+ break;
+ case Token::MEDIUMP:
+ result = Modifiers::kMediump_Flag;
+ break;
+ case Token::HIGHP:
+ result = Modifiers::kHighp_Flag;
+ break;
+ default:
+ this->error(p.fPosition, "expected 'lowp', 'mediump', or 'highp', but found '" +
+ p.fText + "'");
+ return nullptr;
+ }
+ // FIXME handle the type
+ if (!this->type()) {
+ return nullptr;
+ }
+ this->expect(Token::SEMICOLON, "';'");
+ return std::unique_ptr<ASTDeclaration>(new ASTPrecision(p.fPosition, result));
+}
+
/* DIRECTIVE(#version) INT_LITERAL ("es" | "compatibility")? |
DIRECTIVE(#extension) IDENTIFIER COLON IDENTIFIER */
std::unique_ptr<ASTDeclaration> Parser::directive() {