1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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/. */
9 #include "WebGLObjectModel.h"
10 #include "WebGLUniformInfo.h"
12 #include "nsWrapperCache.h"
14 #include "angle/ShaderLang.h"
16 #include "mozilla/LinkedList.h"
17 #include "mozilla/MemoryReporting.h"
21 struct WebGLMappedIdentifier
{
22 nsCString original
, mapped
; // ASCII strings
23 WebGLMappedIdentifier(const nsACString
& o
, const nsACString
& m
) : original(o
), mapped(m
) {}
26 class WebGLShader MOZ_FINAL
27 : public nsWrapperCache
28 , public WebGLRefCountedObject
<WebGLShader
>
29 , public LinkedListElement
<WebGLShader
>
30 , public WebGLContextBoundObject
32 friend class WebGLContext
;
33 friend class WebGLProgram
;
36 WebGLShader(WebGLContext
*context
, GLenum stype
);
38 size_t SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf
) const;
40 GLuint
GLName() { return mGLName
; }
41 GLenum
ShaderType() { return mType
; }
43 void SetSource(const nsAString
& src
) {
44 // XXX do some quick gzip here maybe -- getting this will be very rare
48 const nsString
& Source() const { return mSource
; }
50 void SetNeedsTranslation() { mNeedsTranslation
= true; }
51 bool NeedsTranslation() const { return mNeedsTranslation
; }
53 void SetCompileStatus (bool status
) {
54 mCompileStatus
= status
;
59 bool CompileStatus() const {
60 return mCompileStatus
;
63 void SetTranslationSuccess();
65 void SetTranslationFailure(const nsCString
& msg
) {
66 mTranslationLog
.Assign(msg
);
69 const nsCString
& TranslationLog() const { return mTranslationLog
; }
71 const nsString
& TranslatedSource() const { return mTranslatedSource
; }
73 WebGLContext
*GetParentObject() const {
77 virtual JSObject
* WrapObject(JSContext
*cx
) MOZ_OVERRIDE
;
79 NS_INLINE_DECL_CYCLE_COLLECTING_NATIVE_REFCOUNTING(WebGLShader
)
80 NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_NATIVE_CLASS(WebGLShader
)
90 nsString mTranslatedSource
;
91 nsCString mTranslationLog
; // The translation log should contain only ASCII characters
92 bool mNeedsTranslation
;
93 nsTArray
<WebGLMappedIdentifier
> mAttributes
;
94 nsTArray
<WebGLMappedIdentifier
> mUniforms
;
95 nsTArray
<WebGLUniformInfo
> mUniformInfos
;
96 int mAttribMaxNameLength
;
99 } // namespace mozilla