michael@0: /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #ifndef WEBGLSHADER_H_ michael@0: #define WEBGLSHADER_H_ michael@0: michael@0: #include "WebGLObjectModel.h" michael@0: #include "WebGLUniformInfo.h" michael@0: michael@0: #include "nsWrapperCache.h" michael@0: michael@0: #include "angle/ShaderLang.h" michael@0: michael@0: #include "mozilla/LinkedList.h" michael@0: #include "mozilla/MemoryReporting.h" michael@0: michael@0: namespace mozilla { michael@0: michael@0: struct WebGLMappedIdentifier { michael@0: nsCString original, mapped; // ASCII strings michael@0: WebGLMappedIdentifier(const nsACString& o, const nsACString& m) : original(o), mapped(m) {} michael@0: }; michael@0: michael@0: class WebGLShader MOZ_FINAL michael@0: : public nsWrapperCache michael@0: , public WebGLRefCountedObject michael@0: , public LinkedListElement michael@0: , public WebGLContextBoundObject michael@0: { michael@0: friend class WebGLContext; michael@0: friend class WebGLProgram; michael@0: michael@0: public: michael@0: WebGLShader(WebGLContext *context, GLenum stype); michael@0: michael@0: ~WebGLShader() { michael@0: DeleteOnce(); michael@0: } michael@0: michael@0: size_t SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const; michael@0: michael@0: GLuint GLName() { return mGLName; } michael@0: GLenum ShaderType() { return mType; } michael@0: michael@0: void SetSource(const nsAString& src) { michael@0: // XXX do some quick gzip here maybe -- getting this will be very rare michael@0: mSource.Assign(src); michael@0: } michael@0: michael@0: const nsString& Source() const { return mSource; } michael@0: michael@0: void SetNeedsTranslation() { mNeedsTranslation = true; } michael@0: bool NeedsTranslation() const { return mNeedsTranslation; } michael@0: michael@0: void SetCompileStatus (bool status) { michael@0: mCompileStatus = status; michael@0: } michael@0: michael@0: void Delete(); michael@0: michael@0: bool CompileStatus() const { michael@0: return mCompileStatus; michael@0: } michael@0: michael@0: void SetTranslationSuccess(); michael@0: michael@0: void SetTranslationFailure(const nsCString& msg) { michael@0: mTranslationLog.Assign(msg); michael@0: } michael@0: michael@0: const nsCString& TranslationLog() const { return mTranslationLog; } michael@0: michael@0: const nsString& TranslatedSource() const { return mTranslatedSource; } michael@0: michael@0: WebGLContext *GetParentObject() const { michael@0: return Context(); michael@0: } michael@0: michael@0: virtual JSObject* WrapObject(JSContext *cx) MOZ_OVERRIDE; michael@0: michael@0: NS_INLINE_DECL_CYCLE_COLLECTING_NATIVE_REFCOUNTING(WebGLShader) michael@0: NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_NATIVE_CLASS(WebGLShader) michael@0: michael@0: protected: michael@0: michael@0: GLuint mGLName; michael@0: GLenum mType; michael@0: nsString mSource; michael@0: nsString mTranslatedSource; michael@0: nsCString mTranslationLog; // The translation log should contain only ASCII characters michael@0: bool mNeedsTranslation; michael@0: nsTArray mAttributes; michael@0: nsTArray mUniforms; michael@0: nsTArray mUniformInfos; michael@0: int mAttribMaxNameLength; michael@0: bool mCompileStatus; michael@0: }; michael@0: } // namespace mozilla michael@0: michael@0: #endif