content/canvas/src/WebGLShader.h

Thu, 15 Jan 2015 21:03:48 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 15 Jan 2015 21:03:48 +0100
branch
TOR_BUG_9701
changeset 11
deefc01c0e14
permissions
-rw-r--r--

Integrate friendly tips from Tor colleagues to make (or not) 4.5 alpha 3;
This includes removal of overloaded (but unused) methods, and addition of
a overlooked call to DataStruct::SetData(nsISupports, uint32_t, bool.)

michael@0 1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
michael@0 2 /* This Source Code Form is subject to the terms of the Mozilla Public
michael@0 3 * License, v. 2.0. If a copy of the MPL was not distributed with this
michael@0 4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
michael@0 5
michael@0 6 #ifndef WEBGLSHADER_H_
michael@0 7 #define WEBGLSHADER_H_
michael@0 8
michael@0 9 #include "WebGLObjectModel.h"
michael@0 10 #include "WebGLUniformInfo.h"
michael@0 11
michael@0 12 #include "nsWrapperCache.h"
michael@0 13
michael@0 14 #include "angle/ShaderLang.h"
michael@0 15
michael@0 16 #include "mozilla/LinkedList.h"
michael@0 17 #include "mozilla/MemoryReporting.h"
michael@0 18
michael@0 19 namespace mozilla {
michael@0 20
michael@0 21 struct WebGLMappedIdentifier {
michael@0 22 nsCString original, mapped; // ASCII strings
michael@0 23 WebGLMappedIdentifier(const nsACString& o, const nsACString& m) : original(o), mapped(m) {}
michael@0 24 };
michael@0 25
michael@0 26 class WebGLShader MOZ_FINAL
michael@0 27 : public nsWrapperCache
michael@0 28 , public WebGLRefCountedObject<WebGLShader>
michael@0 29 , public LinkedListElement<WebGLShader>
michael@0 30 , public WebGLContextBoundObject
michael@0 31 {
michael@0 32 friend class WebGLContext;
michael@0 33 friend class WebGLProgram;
michael@0 34
michael@0 35 public:
michael@0 36 WebGLShader(WebGLContext *context, GLenum stype);
michael@0 37
michael@0 38 ~WebGLShader() {
michael@0 39 DeleteOnce();
michael@0 40 }
michael@0 41
michael@0 42 size_t SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const;
michael@0 43
michael@0 44 GLuint GLName() { return mGLName; }
michael@0 45 GLenum ShaderType() { return mType; }
michael@0 46
michael@0 47 void SetSource(const nsAString& src) {
michael@0 48 // XXX do some quick gzip here maybe -- getting this will be very rare
michael@0 49 mSource.Assign(src);
michael@0 50 }
michael@0 51
michael@0 52 const nsString& Source() const { return mSource; }
michael@0 53
michael@0 54 void SetNeedsTranslation() { mNeedsTranslation = true; }
michael@0 55 bool NeedsTranslation() const { return mNeedsTranslation; }
michael@0 56
michael@0 57 void SetCompileStatus (bool status) {
michael@0 58 mCompileStatus = status;
michael@0 59 }
michael@0 60
michael@0 61 void Delete();
michael@0 62
michael@0 63 bool CompileStatus() const {
michael@0 64 return mCompileStatus;
michael@0 65 }
michael@0 66
michael@0 67 void SetTranslationSuccess();
michael@0 68
michael@0 69 void SetTranslationFailure(const nsCString& msg) {
michael@0 70 mTranslationLog.Assign(msg);
michael@0 71 }
michael@0 72
michael@0 73 const nsCString& TranslationLog() const { return mTranslationLog; }
michael@0 74
michael@0 75 const nsString& TranslatedSource() const { return mTranslatedSource; }
michael@0 76
michael@0 77 WebGLContext *GetParentObject() const {
michael@0 78 return Context();
michael@0 79 }
michael@0 80
michael@0 81 virtual JSObject* WrapObject(JSContext *cx) MOZ_OVERRIDE;
michael@0 82
michael@0 83 NS_INLINE_DECL_CYCLE_COLLECTING_NATIVE_REFCOUNTING(WebGLShader)
michael@0 84 NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_NATIVE_CLASS(WebGLShader)
michael@0 85
michael@0 86 protected:
michael@0 87
michael@0 88 GLuint mGLName;
michael@0 89 GLenum mType;
michael@0 90 nsString mSource;
michael@0 91 nsString mTranslatedSource;
michael@0 92 nsCString mTranslationLog; // The translation log should contain only ASCII characters
michael@0 93 bool mNeedsTranslation;
michael@0 94 nsTArray<WebGLMappedIdentifier> mAttributes;
michael@0 95 nsTArray<WebGLMappedIdentifier> mUniforms;
michael@0 96 nsTArray<WebGLUniformInfo> mUniformInfos;
michael@0 97 int mAttribMaxNameLength;
michael@0 98 bool mCompileStatus;
michael@0 99 };
michael@0 100 } // namespace mozilla
michael@0 101
michael@0 102 #endif

mercurial