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 | // Shader.h: Defines the abstract gl::Shader class and its concrete derived |
michael@0 | 8 | // classes VertexShader and FragmentShader. Implements GL shader objects and |
michael@0 | 9 | // related functionality. [OpenGL ES 2.0.24] section 2.10 page 24 and section |
michael@0 | 10 | // 3.8 page 84. |
michael@0 | 11 | |
michael@0 | 12 | #ifndef LIBGLESV2_SHADER_H_ |
michael@0 | 13 | #define LIBGLESV2_SHADER_H_ |
michael@0 | 14 | |
michael@0 | 15 | #define GL_APICALL |
michael@0 | 16 | #include <GLES2/gl2.h> |
michael@0 | 17 | #include <string> |
michael@0 | 18 | #include <list> |
michael@0 | 19 | #include <vector> |
michael@0 | 20 | |
michael@0 | 21 | #include "compiler/CompilerUniform.h" |
michael@0 | 22 | #include "common/angleutils.h" |
michael@0 | 23 | |
michael@0 | 24 | namespace rx |
michael@0 | 25 | { |
michael@0 | 26 | class Renderer; |
michael@0 | 27 | } |
michael@0 | 28 | |
michael@0 | 29 | namespace gl |
michael@0 | 30 | { |
michael@0 | 31 | class ResourceManager; |
michael@0 | 32 | |
michael@0 | 33 | struct Varying |
michael@0 | 34 | { |
michael@0 | 35 | Varying(GLenum type, const std::string &name, int size, bool array) |
michael@0 | 36 | : type(type), name(name), size(size), array(array), reg(-1), col(-1) |
michael@0 | 37 | { |
michael@0 | 38 | } |
michael@0 | 39 | |
michael@0 | 40 | GLenum type; |
michael@0 | 41 | std::string name; |
michael@0 | 42 | int size; // Number of 'type' elements |
michael@0 | 43 | bool array; |
michael@0 | 44 | |
michael@0 | 45 | int reg; // First varying register, assigned during link |
michael@0 | 46 | int col; // First register element, assigned during link |
michael@0 | 47 | }; |
michael@0 | 48 | |
michael@0 | 49 | typedef std::list<Varying> VaryingList; |
michael@0 | 50 | |
michael@0 | 51 | class Shader |
michael@0 | 52 | { |
michael@0 | 53 | friend class ProgramBinary; |
michael@0 | 54 | |
michael@0 | 55 | public: |
michael@0 | 56 | Shader(ResourceManager *manager, const rx::Renderer *renderer, GLuint handle); |
michael@0 | 57 | |
michael@0 | 58 | virtual ~Shader(); |
michael@0 | 59 | |
michael@0 | 60 | virtual GLenum getType() = 0; |
michael@0 | 61 | GLuint getHandle() const; |
michael@0 | 62 | |
michael@0 | 63 | void deleteSource(); |
michael@0 | 64 | void setSource(GLsizei count, const char **string, const GLint *length); |
michael@0 | 65 | int getInfoLogLength() const; |
michael@0 | 66 | void getInfoLog(GLsizei bufSize, GLsizei *length, char *infoLog); |
michael@0 | 67 | int getSourceLength() const; |
michael@0 | 68 | void getSource(GLsizei bufSize, GLsizei *length, char *buffer); |
michael@0 | 69 | int getTranslatedSourceLength() const; |
michael@0 | 70 | void getTranslatedSource(GLsizei bufSize, GLsizei *length, char *buffer); |
michael@0 | 71 | const sh::ActiveUniforms &getUniforms(); |
michael@0 | 72 | |
michael@0 | 73 | virtual void compile() = 0; |
michael@0 | 74 | virtual void uncompile(); |
michael@0 | 75 | bool isCompiled(); |
michael@0 | 76 | const char *getHLSL(); |
michael@0 | 77 | |
michael@0 | 78 | void addRef(); |
michael@0 | 79 | void release(); |
michael@0 | 80 | unsigned int getRefCount() const; |
michael@0 | 81 | bool isFlaggedForDeletion() const; |
michael@0 | 82 | void flagForDeletion(); |
michael@0 | 83 | |
michael@0 | 84 | static void releaseCompiler(); |
michael@0 | 85 | |
michael@0 | 86 | protected: |
michael@0 | 87 | void parseVaryings(); |
michael@0 | 88 | void resetVaryingsRegisterAssignment(); |
michael@0 | 89 | |
michael@0 | 90 | void compileToHLSL(void *compiler); |
michael@0 | 91 | |
michael@0 | 92 | void getSourceImpl(char *source, GLsizei bufSize, GLsizei *length, char *buffer); |
michael@0 | 93 | |
michael@0 | 94 | static GLenum parseType(const std::string &type); |
michael@0 | 95 | static bool compareVarying(const Varying &x, const Varying &y); |
michael@0 | 96 | |
michael@0 | 97 | const rx::Renderer *const mRenderer; |
michael@0 | 98 | |
michael@0 | 99 | VaryingList mVaryings; |
michael@0 | 100 | |
michael@0 | 101 | bool mUsesMultipleRenderTargets; |
michael@0 | 102 | bool mUsesFragColor; |
michael@0 | 103 | bool mUsesFragData; |
michael@0 | 104 | bool mUsesFragCoord; |
michael@0 | 105 | bool mUsesFrontFacing; |
michael@0 | 106 | bool mUsesPointSize; |
michael@0 | 107 | bool mUsesPointCoord; |
michael@0 | 108 | bool mUsesDepthRange; |
michael@0 | 109 | bool mUsesFragDepth; |
michael@0 | 110 | |
michael@0 | 111 | static void *mFragmentCompiler; |
michael@0 | 112 | static void *mVertexCompiler; |
michael@0 | 113 | |
michael@0 | 114 | private: |
michael@0 | 115 | DISALLOW_COPY_AND_ASSIGN(Shader); |
michael@0 | 116 | |
michael@0 | 117 | void initializeCompiler(); |
michael@0 | 118 | |
michael@0 | 119 | const GLuint mHandle; |
michael@0 | 120 | unsigned int mRefCount; // Number of program objects this shader is attached to |
michael@0 | 121 | bool mDeleteStatus; // Flag to indicate that the shader can be deleted when no longer in use |
michael@0 | 122 | |
michael@0 | 123 | char *mSource; |
michael@0 | 124 | char *mHlsl; |
michael@0 | 125 | char *mInfoLog; |
michael@0 | 126 | sh::ActiveUniforms mActiveUniforms; |
michael@0 | 127 | |
michael@0 | 128 | ResourceManager *mResourceManager; |
michael@0 | 129 | }; |
michael@0 | 130 | |
michael@0 | 131 | struct Attribute |
michael@0 | 132 | { |
michael@0 | 133 | Attribute() : type(GL_NONE), name("") |
michael@0 | 134 | { |
michael@0 | 135 | } |
michael@0 | 136 | |
michael@0 | 137 | Attribute(GLenum type, const std::string &name) : type(type), name(name) |
michael@0 | 138 | { |
michael@0 | 139 | } |
michael@0 | 140 | |
michael@0 | 141 | GLenum type; |
michael@0 | 142 | std::string name; |
michael@0 | 143 | }; |
michael@0 | 144 | |
michael@0 | 145 | typedef std::vector<Attribute> AttributeArray; |
michael@0 | 146 | |
michael@0 | 147 | class VertexShader : public Shader |
michael@0 | 148 | { |
michael@0 | 149 | friend class ProgramBinary; |
michael@0 | 150 | |
michael@0 | 151 | public: |
michael@0 | 152 | VertexShader(ResourceManager *manager, const rx::Renderer *renderer, GLuint handle); |
michael@0 | 153 | |
michael@0 | 154 | ~VertexShader(); |
michael@0 | 155 | |
michael@0 | 156 | virtual GLenum getType(); |
michael@0 | 157 | virtual void compile(); |
michael@0 | 158 | virtual void uncompile(); |
michael@0 | 159 | int getSemanticIndex(const std::string &attributeName); |
michael@0 | 160 | |
michael@0 | 161 | private: |
michael@0 | 162 | DISALLOW_COPY_AND_ASSIGN(VertexShader); |
michael@0 | 163 | |
michael@0 | 164 | void parseAttributes(); |
michael@0 | 165 | |
michael@0 | 166 | AttributeArray mAttributes; |
michael@0 | 167 | }; |
michael@0 | 168 | |
michael@0 | 169 | class FragmentShader : public Shader |
michael@0 | 170 | { |
michael@0 | 171 | public: |
michael@0 | 172 | FragmentShader(ResourceManager *manager,const rx::Renderer *renderer, GLuint handle); |
michael@0 | 173 | |
michael@0 | 174 | ~FragmentShader(); |
michael@0 | 175 | |
michael@0 | 176 | virtual GLenum getType(); |
michael@0 | 177 | virtual void compile(); |
michael@0 | 178 | |
michael@0 | 179 | private: |
michael@0 | 180 | DISALLOW_COPY_AND_ASSIGN(FragmentShader); |
michael@0 | 181 | }; |
michael@0 | 182 | } |
michael@0 | 183 | |
michael@0 | 184 | #endif // LIBGLESV2_SHADER_H_ |