content/canvas/src/WebGLContextUtils.h

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

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 #ifndef WEBGLCONTEXTUTILS_H_
michael@0 7 #define WEBGLCONTEXTUTILS_H_
michael@0 8
michael@0 9 #include "WebGLContext.h"
michael@0 10 #include "mozilla/Assertions.h"
michael@0 11 #include "mozilla/dom/BindingUtils.h"
michael@0 12
michael@0 13 namespace mozilla {
michael@0 14
michael@0 15 bool IsGLDepthFormat(GLenum webGLFormat);
michael@0 16 bool IsGLDepthStencilFormat(GLenum webGLFormat);
michael@0 17 bool FormatHasAlpha(GLenum webGLFormat);
michael@0 18 void DriverFormatsFromFormatAndType(gl::GLContext* gl, GLenum webGLFormat, GLenum webGLType,
michael@0 19 GLenum* out_driverInternalFormat, GLenum* out_driverFormat);
michael@0 20 GLenum DriverTypeFromType(gl::GLContext* gl, GLenum webGLType);
michael@0 21
michael@0 22 template <typename WebGLObjectType>
michael@0 23 JS::Value
michael@0 24 WebGLContext::WebGLObjectAsJSValue(JSContext *cx, const WebGLObjectType *object, ErrorResult& rv) const
michael@0 25 {
michael@0 26 if (!object) {
michael@0 27 return JS::NullValue();
michael@0 28 }
michael@0 29 MOZ_ASSERT(this == object->Context());
michael@0 30 JS::Rooted<JS::Value> v(cx);
michael@0 31 JS::Rooted<JSObject*> wrapper(cx, GetWrapper());
michael@0 32 JSAutoCompartment ac(cx, wrapper);
michael@0 33 if (!dom::WrapNewBindingObject(cx, const_cast<WebGLObjectType*>(object), &v)) {
michael@0 34 rv.Throw(NS_ERROR_FAILURE);
michael@0 35 return JS::NullValue();
michael@0 36 }
michael@0 37 return v;
michael@0 38 }
michael@0 39
michael@0 40 template <typename WebGLObjectType>
michael@0 41 JSObject*
michael@0 42 WebGLContext::WebGLObjectAsJSObject(JSContext *cx, const WebGLObjectType *object, ErrorResult& rv) const
michael@0 43 {
michael@0 44 JS::Value v = WebGLObjectAsJSValue(cx, object, rv);
michael@0 45 if (v.isNull()) {
michael@0 46 return nullptr;
michael@0 47 }
michael@0 48 return &v.toObject();
michael@0 49 }
michael@0 50
michael@0 51 } // namespace mozilla
michael@0 52
michael@0 53 #endif // WEBGLCONTEXTUTILS_H_

mercurial