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
);
42 size_t SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf
) const;
44 GLuint
GLName() { return mGLName
; }
45 GLenum
ShaderType() { return mType
; }
47 void SetSource(const nsAString
& src
) {
48 // XXX do some quick gzip here maybe -- getting this will be very rare
52 const nsString
& Source() const { return mSource
; }
54 void SetNeedsTranslation() { mNeedsTranslation
= true; }
55 bool NeedsTranslation() const { return mNeedsTranslation
; }
57 void SetCompileStatus (bool status
) {
58 mCompileStatus
= status
;
63 bool CompileStatus() const {
64 return mCompileStatus
;
67 void SetTranslationSuccess();
69 void SetTranslationFailure(const nsCString
& msg
) {
70 mTranslationLog
.Assign(msg
);
73 const nsCString
& TranslationLog() const { return mTranslationLog
; }
75 WebGLContext
*GetParentObject() const {
79 virtual JSObject
* WrapObject(JSContext
*cx
,
80 JS::Handle
<JSObject
*> scope
) MOZ_OVERRIDE
;
82 NS_INLINE_DECL_CYCLE_COLLECTING_NATIVE_REFCOUNTING(WebGLShader
)
83 NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_NATIVE_CLASS(WebGLShader
)
90 nsCString mTranslationLog
; // The translation log should contain only ASCII characters
91 bool mNeedsTranslation
;
92 nsTArray
<WebGLMappedIdentifier
> mAttributes
;
93 nsTArray
<WebGLMappedIdentifier
> mUniforms
;
94 nsTArray
<WebGLUniformInfo
> mUniformInfos
;
95 int mAttribMaxNameLength
;
98 } // namespace mozilla