Bug 1839170 - Refactor Snap pulling, Add Firefox Snap Core22 and GNOME 42 SDK symbols...
[gecko.git] / dom / canvas / WebGLShader.h
blobe2fc17664db77cafeb131c57f8be550320ee0298
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 #ifndef WEBGL_SHADER_H_
7 #define WEBGL_SHADER_H_
9 #include <map>
10 #include <memory>
11 #include <string>
12 #include <vector>
14 #include "GLDefs.h"
15 #include "mozilla/MemoryReporting.h"
17 #include "WebGLObjectModel.h"
19 namespace mozilla {
21 namespace webgl {
22 class ShaderValidatorResults;
23 } // namespace webgl
25 class WebGLShader final : public WebGLContextBoundObject {
26 friend class WebGLContext;
27 friend class WebGLProgram;
29 MOZ_DECLARE_REFCOUNTED_VIRTUAL_TYPENAME(WebGLShader, override)
31 public:
32 WebGLShader(WebGLContext* webgl, GLenum type);
34 protected:
35 ~WebGLShader() override;
37 public:
38 // GL funcs
39 void CompileShader();
40 void ShaderSource(const std::string& source);
42 // Util funcs
43 size_t CalcNumSamplerUniforms() const;
44 size_t NumAttributes() const;
46 const auto& CompileResults() const { return mCompileResults; }
47 const auto& CompileLog() const { return mCompilationLog; }
48 bool IsCompiled() const { return mCompilationSuccessful; }
50 private:
51 void BindAttribLocation(GLuint prog, const std::string& userName,
52 GLuint index) const;
53 void MapTransformFeedbackVaryings(
54 const std::vector<std::string>& varyings,
55 std::vector<std::string>* out_mappedVaryings) const;
57 public:
58 // Other funcs
59 size_t SizeOfIncludingThis(mozilla::MallocSizeOf mallocSizeOf) const;
61 public:
62 const GLuint mGLName;
63 const GLenum mType;
65 protected:
66 std::string mSource;
68 std::unique_ptr<const webgl::ShaderValidatorResults>
69 mCompileResults; // Never null.
70 bool mCompilationSuccessful = false;
71 std::string mCompilationLog;
74 } // namespace mozilla
76 #endif // WEBGL_SHADER_H_