content/canvas/src/WebGLShader.cpp

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: 20; 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 #include "WebGLObjectModel.h"
michael@0 7 #include "WebGLShader.h"
michael@0 8 #include "WebGLContext.h"
michael@0 9 #include "mozilla/MemoryReporting.h"
michael@0 10 #include "mozilla/dom/WebGLRenderingContextBinding.h"
michael@0 11 #include "GLContext.h"
michael@0 12
michael@0 13 using namespace mozilla;
michael@0 14
michael@0 15 JSObject*
michael@0 16 WebGLShader::WrapObject(JSContext *cx) {
michael@0 17 return dom::WebGLShaderBinding::Wrap(cx, this);
michael@0 18 }
michael@0 19
michael@0 20 WebGLShader::WebGLShader(WebGLContext *context, GLenum stype)
michael@0 21 : WebGLContextBoundObject(context)
michael@0 22 , mType(stype)
michael@0 23 , mNeedsTranslation(true)
michael@0 24 , mAttribMaxNameLength(0)
michael@0 25 , mCompileStatus(false)
michael@0 26 {
michael@0 27 SetIsDOMBinding();
michael@0 28 mContext->MakeContextCurrent();
michael@0 29 mGLName = mContext->gl->fCreateShader(mType);
michael@0 30 mContext->mShaders.insertBack(this);
michael@0 31 }
michael@0 32
michael@0 33 void
michael@0 34 WebGLShader::Delete() {
michael@0 35 mSource.Truncate();
michael@0 36 mTranslationLog.Truncate();
michael@0 37 mContext->MakeContextCurrent();
michael@0 38 mContext->gl->fDeleteShader(mGLName);
michael@0 39 LinkedListElement<WebGLShader>::removeFrom(mContext->mShaders);
michael@0 40 }
michael@0 41
michael@0 42 size_t
michael@0 43 WebGLShader::SizeOfIncludingThis(MallocSizeOf aMallocSizeOf) const {
michael@0 44 return aMallocSizeOf(this) +
michael@0 45 mSource.SizeOfExcludingThisIfUnshared(aMallocSizeOf) +
michael@0 46 mTranslationLog.SizeOfExcludingThisIfUnshared(aMallocSizeOf);
michael@0 47 }
michael@0 48
michael@0 49 void
michael@0 50 WebGLShader::SetTranslationSuccess() {
michael@0 51 mTranslationLog.SetIsVoid(true);
michael@0 52 mNeedsTranslation = false;
michael@0 53 }
michael@0 54
michael@0 55 NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE_0(WebGLShader)
michael@0 56
michael@0 57 NS_IMPL_CYCLE_COLLECTION_ROOT_NATIVE(WebGLShader, AddRef)
michael@0 58 NS_IMPL_CYCLE_COLLECTION_UNROOT_NATIVE(WebGLShader, Release)

mercurial