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.)

     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/. */
     6 #ifndef WEBGLSHADER_H_
     7 #define WEBGLSHADER_H_
     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"
    19 namespace mozilla {
    21 struct WebGLMappedIdentifier {
    22     nsCString original, mapped; // ASCII strings
    23     WebGLMappedIdentifier(const nsACString& o, const nsACString& m) : original(o), mapped(m) {}
    24 };
    26 class WebGLShader MOZ_FINAL
    27     : public nsWrapperCache
    28     , public WebGLRefCountedObject<WebGLShader>
    29     , public LinkedListElement<WebGLShader>
    30     , public WebGLContextBoundObject
    31 {
    32     friend class WebGLContext;
    33     friend class WebGLProgram;
    35 public:
    36     WebGLShader(WebGLContext *context, GLenum stype);
    38     ~WebGLShader() {
    39         DeleteOnce();
    40     }
    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
    49         mSource.Assign(src);
    50     }
    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;
    59     }
    61     void Delete();
    63     bool CompileStatus() const {
    64         return mCompileStatus;
    65     }
    67     void SetTranslationSuccess();
    69     void SetTranslationFailure(const nsCString& msg) {
    70         mTranslationLog.Assign(msg); 
    71     }
    73     const nsCString& TranslationLog() const { return mTranslationLog; }
    75     const nsString& TranslatedSource() const { return mTranslatedSource; }
    77     WebGLContext *GetParentObject() const {
    78         return Context();
    79     }
    81     virtual JSObject* WrapObject(JSContext *cx) MOZ_OVERRIDE;
    83     NS_INLINE_DECL_CYCLE_COLLECTING_NATIVE_REFCOUNTING(WebGLShader)
    84     NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_NATIVE_CLASS(WebGLShader)
    86 protected:
    88     GLuint mGLName;
    89     GLenum mType;
    90     nsString mSource;
    91     nsString mTranslatedSource;
    92     nsCString mTranslationLog; // The translation log should contain only ASCII characters
    93     bool mNeedsTranslation;
    94     nsTArray<WebGLMappedIdentifier> mAttributes;
    95     nsTArray<WebGLMappedIdentifier> mUniforms;
    96     nsTArray<WebGLUniformInfo> mUniformInfos;
    97     int mAttribMaxNameLength;
    98     bool mCompileStatus;
    99 };
   100 } // namespace mozilla
   102 #endif

mercurial