Sat, 03 Jan 2015 20:18:00 +0100
Conditionally enable double key logic according to:
private browsing mode or privacy.thirdparty.isolate preference and
implement in GetCookieStringCommon and FindCookie where it counts...
With some reservations of how to convince FindCookie users to test
condition and pass a nullptr when disabling double key logic.
michael@0 | 1 | // |
michael@0 | 2 | // Copyright (c) 2002-2013 The ANGLE Project Authors. All rights reserved. |
michael@0 | 3 | // Use of this source code is governed by a BSD-style license that can be |
michael@0 | 4 | // found in the LICENSE file. |
michael@0 | 5 | // |
michael@0 | 6 | |
michael@0 | 7 | #ifndef COMPILER_OUTPUTHLSL_H_ |
michael@0 | 8 | #define COMPILER_OUTPUTHLSL_H_ |
michael@0 | 9 | |
michael@0 | 10 | #include <list> |
michael@0 | 11 | #include <set> |
michael@0 | 12 | #include <map> |
michael@0 | 13 | |
michael@0 | 14 | #define GL_APICALL |
michael@0 | 15 | #include <GLES2/gl2.h> |
michael@0 | 16 | |
michael@0 | 17 | #include "compiler/intermediate.h" |
michael@0 | 18 | #include "compiler/ParseHelper.h" |
michael@0 | 19 | #include "compiler/CompilerUniform.h" |
michael@0 | 20 | |
michael@0 | 21 | namespace sh |
michael@0 | 22 | { |
michael@0 | 23 | class UnfoldShortCircuit; |
michael@0 | 24 | |
michael@0 | 25 | class OutputHLSL : public TIntermTraverser |
michael@0 | 26 | { |
michael@0 | 27 | public: |
michael@0 | 28 | OutputHLSL(TParseContext &context, const ShBuiltInResources& resources, ShShaderOutput outputType); |
michael@0 | 29 | ~OutputHLSL(); |
michael@0 | 30 | |
michael@0 | 31 | void output(); |
michael@0 | 32 | |
michael@0 | 33 | TInfoSinkBase &getBodyStream(); |
michael@0 | 34 | const ActiveUniforms &getUniforms(); |
michael@0 | 35 | |
michael@0 | 36 | TString typeString(const TType &type); |
michael@0 | 37 | TString textureString(const TType &type); |
michael@0 | 38 | static TString qualifierString(TQualifier qualifier); |
michael@0 | 39 | static TString arrayString(const TType &type); |
michael@0 | 40 | static TString initializer(const TType &type); |
michael@0 | 41 | static TString decorate(const TString &string); // Prepends an underscore to avoid naming clashes |
michael@0 | 42 | static TString decorateUniform(const TString &string, const TType &type); |
michael@0 | 43 | static TString decorateField(const TString &string, const TType &structure); |
michael@0 | 44 | |
michael@0 | 45 | protected: |
michael@0 | 46 | void header(); |
michael@0 | 47 | |
michael@0 | 48 | // Visit AST nodes and output their code to the body stream |
michael@0 | 49 | void visitSymbol(TIntermSymbol*); |
michael@0 | 50 | void visitConstantUnion(TIntermConstantUnion*); |
michael@0 | 51 | bool visitBinary(Visit visit, TIntermBinary*); |
michael@0 | 52 | bool visitUnary(Visit visit, TIntermUnary*); |
michael@0 | 53 | bool visitSelection(Visit visit, TIntermSelection*); |
michael@0 | 54 | bool visitAggregate(Visit visit, TIntermAggregate*); |
michael@0 | 55 | bool visitLoop(Visit visit, TIntermLoop*); |
michael@0 | 56 | bool visitBranch(Visit visit, TIntermBranch*); |
michael@0 | 57 | |
michael@0 | 58 | void traverseStatements(TIntermNode *node); |
michael@0 | 59 | bool isSingleStatement(TIntermNode *node); |
michael@0 | 60 | bool handleExcessiveLoop(TIntermLoop *node); |
michael@0 | 61 | void outputTriplet(Visit visit, const TString &preString, const TString &inString, const TString &postString); |
michael@0 | 62 | void outputLineDirective(int line); |
michael@0 | 63 | TString argumentString(const TIntermSymbol *symbol); |
michael@0 | 64 | int vectorSize(const TType &type) const; |
michael@0 | 65 | |
michael@0 | 66 | void addConstructor(const TType &type, const TString &name, const TIntermSequence *parameters); |
michael@0 | 67 | const ConstantUnion *writeConstantUnion(const TType &type, const ConstantUnion *constUnion); |
michael@0 | 68 | |
michael@0 | 69 | TString scopeString(unsigned int depthLimit); |
michael@0 | 70 | TString scopedStruct(const TString &typeName); |
michael@0 | 71 | TString structLookup(const TString &typeName); |
michael@0 | 72 | |
michael@0 | 73 | TParseContext &mContext; |
michael@0 | 74 | const ShShaderOutput mOutputType; |
michael@0 | 75 | UnfoldShortCircuit *mUnfoldShortCircuit; |
michael@0 | 76 | bool mInsideFunction; |
michael@0 | 77 | |
michael@0 | 78 | // Output streams |
michael@0 | 79 | TInfoSinkBase mHeader; |
michael@0 | 80 | TInfoSinkBase mBody; |
michael@0 | 81 | TInfoSinkBase mFooter; |
michael@0 | 82 | |
michael@0 | 83 | typedef std::map<TString, TIntermSymbol*> ReferencedSymbols; |
michael@0 | 84 | ReferencedSymbols mReferencedUniforms; |
michael@0 | 85 | ReferencedSymbols mReferencedAttributes; |
michael@0 | 86 | ReferencedSymbols mReferencedVaryings; |
michael@0 | 87 | |
michael@0 | 88 | // Parameters determining what goes in the header output |
michael@0 | 89 | bool mUsesTexture2D; |
michael@0 | 90 | bool mUsesTexture2D_bias; |
michael@0 | 91 | bool mUsesTexture2DLod; |
michael@0 | 92 | bool mUsesTexture2DProj; |
michael@0 | 93 | bool mUsesTexture2DProj_bias; |
michael@0 | 94 | bool mUsesTexture2DProjLod; |
michael@0 | 95 | bool mUsesTextureCube; |
michael@0 | 96 | bool mUsesTextureCube_bias; |
michael@0 | 97 | bool mUsesTextureCubeLod; |
michael@0 | 98 | bool mUsesTexture2DLod0; |
michael@0 | 99 | bool mUsesTexture2DLod0_bias; |
michael@0 | 100 | bool mUsesTexture2DProjLod0; |
michael@0 | 101 | bool mUsesTexture2DProjLod0_bias; |
michael@0 | 102 | bool mUsesTextureCubeLod0; |
michael@0 | 103 | bool mUsesTextureCubeLod0_bias; |
michael@0 | 104 | bool mUsesFragColor; |
michael@0 | 105 | bool mUsesFragData; |
michael@0 | 106 | bool mUsesDepthRange; |
michael@0 | 107 | bool mUsesFragCoord; |
michael@0 | 108 | bool mUsesPointCoord; |
michael@0 | 109 | bool mUsesFrontFacing; |
michael@0 | 110 | bool mUsesPointSize; |
michael@0 | 111 | bool mUsesFragDepth; |
michael@0 | 112 | bool mUsesXor; |
michael@0 | 113 | bool mUsesMod1; |
michael@0 | 114 | bool mUsesMod2v; |
michael@0 | 115 | bool mUsesMod2f; |
michael@0 | 116 | bool mUsesMod3v; |
michael@0 | 117 | bool mUsesMod3f; |
michael@0 | 118 | bool mUsesMod4v; |
michael@0 | 119 | bool mUsesMod4f; |
michael@0 | 120 | bool mUsesFaceforward1; |
michael@0 | 121 | bool mUsesFaceforward2; |
michael@0 | 122 | bool mUsesFaceforward3; |
michael@0 | 123 | bool mUsesFaceforward4; |
michael@0 | 124 | bool mUsesAtan2_1; |
michael@0 | 125 | bool mUsesAtan2_2; |
michael@0 | 126 | bool mUsesAtan2_3; |
michael@0 | 127 | bool mUsesAtan2_4; |
michael@0 | 128 | |
michael@0 | 129 | int mNumRenderTargets; |
michael@0 | 130 | |
michael@0 | 131 | typedef std::set<TString> Constructors; |
michael@0 | 132 | Constructors mConstructors; |
michael@0 | 133 | |
michael@0 | 134 | typedef std::set<TString> StructNames; |
michael@0 | 135 | StructNames mStructNames; |
michael@0 | 136 | |
michael@0 | 137 | typedef std::list<TString> StructDeclarations; |
michael@0 | 138 | StructDeclarations mStructDeclarations; |
michael@0 | 139 | |
michael@0 | 140 | typedef std::vector<int> ScopeBracket; |
michael@0 | 141 | ScopeBracket mScopeBracket; |
michael@0 | 142 | unsigned int mScopeDepth; |
michael@0 | 143 | |
michael@0 | 144 | int mUniqueIndex; // For creating unique names |
michael@0 | 145 | |
michael@0 | 146 | bool mContainsLoopDiscontinuity; |
michael@0 | 147 | bool mOutputLod0Function; |
michael@0 | 148 | bool mInsideDiscontinuousLoop; |
michael@0 | 149 | |
michael@0 | 150 | TIntermSymbol *mExcessiveLoopIndex; |
michael@0 | 151 | |
michael@0 | 152 | int mUniformRegister; |
michael@0 | 153 | int mSamplerRegister; |
michael@0 | 154 | |
michael@0 | 155 | TString registerString(TIntermSymbol *operand); |
michael@0 | 156 | int samplerRegister(TIntermSymbol *sampler); |
michael@0 | 157 | int uniformRegister(TIntermSymbol *uniform); |
michael@0 | 158 | void declareUniform(const TType &type, const TString &name, int index); |
michael@0 | 159 | static GLenum glVariableType(const TType &type); |
michael@0 | 160 | static GLenum glVariablePrecision(const TType &type); |
michael@0 | 161 | |
michael@0 | 162 | ActiveUniforms mActiveUniforms; |
michael@0 | 163 | }; |
michael@0 | 164 | } |
michael@0 | 165 | |
michael@0 | 166 | #endif // COMPILER_OUTPUTHLSL_H_ |