LCOV - code coverage report
Current view: top level - dom/canvas - WebGLContextUtils.h (source / functions) Hit Total Coverage
Test: output.info Lines: 0 16 0.0 %
Date: 2017-07-14 16:53:18 Functions: 0 10 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 20; 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/. */
       5             : 
       6             : #ifndef WEBGL_CONTEXT_UTILS_H_
       7             : #define WEBGL_CONTEXT_UTILS_H_
       8             : 
       9             : #include "WebGLContext.h"
      10             : 
      11             : #include "mozilla/Assertions.h"
      12             : #include "mozilla/dom/BindingUtils.h"
      13             : 
      14             : #include "WebGLStrongTypes.h"
      15             : 
      16             : namespace mozilla {
      17             : 
      18             : // For use with the different texture calls, i.e.
      19             : //   TexImage2D, CopyTex[Sub]Image2D, ...
      20             : // that take a "target" parameter. This parameter is not always the same as
      21             : // the texture binding location, like GL_TEXTURE_2D or GL_TEXTURE_CUBE_MAP.
      22             : // For example, cube maps would pass GL_TEXTURE_CUBE_MAP_[POS|NEG]_[X|Y|Z]
      23             : // instead of just GL_TEXTURE_CUBE_MAP.
      24             : //
      25             : // This function converts the texture image target to the texture target a.k.a.
      26             : // binding location. The returned binding location can be used to check that
      27             : // the currently bound texture is appropriate for this texImageTarget.
      28             : //
      29             : // Returns GL_NONE if passed an invalid texture image target
      30             : TexTarget TexImageTargetToTexTarget(TexImageTarget texImageTarget);
      31             : 
      32             : // Helper function to create a JS::Value from a C string
      33             : JS::Value StringValue(JSContext* cx, const char* str, ErrorResult& rv);
      34             : 
      35             : struct GLComponents
      36             : {
      37             :     unsigned char mComponents;
      38             : 
      39             :     enum Components {
      40             :         Red     = (1 << 0),
      41             :         Green   = (1 << 1),
      42             :         Blue    = (1 << 2),
      43             :         Alpha   = (1 << 3),
      44             :         Stencil = (1 << 4),
      45             :         Depth   = (1 << 5),
      46             :     };
      47             : 
      48             :     GLComponents()
      49             :         : mComponents(0)
      50             :     {}
      51             : 
      52             :     explicit GLComponents(TexInternalFormat format);
      53             : 
      54             :     // Returns true iff other has all (or more) of
      55             :     // the components present in this GLComponents
      56             :     bool IsSubsetOf(const GLComponents& other) const;
      57             : };
      58             : 
      59             : template <typename WebGLObjectType>
      60             : JS::Value
      61           0 : WebGLContext::WebGLObjectAsJSValue(JSContext* cx, const WebGLObjectType* object,
      62             :                                    ErrorResult& rv) const
      63             : {
      64           0 :     if (!object)
      65           0 :         return JS::NullValue();
      66             : 
      67           0 :     MOZ_ASSERT(this == object->mContext);
      68           0 :     JS::Rooted<JS::Value> v(cx);
      69           0 :     JS::Rooted<JSObject*> wrapper(cx, GetWrapper());
      70           0 :     JSAutoCompartment ac(cx, wrapper);
      71           0 :     if (!dom::GetOrCreateDOMReflector(cx, const_cast<WebGLObjectType*>(object), &v)) {
      72           0 :         rv.Throw(NS_ERROR_FAILURE);
      73           0 :         return JS::NullValue();
      74             :     }
      75           0 :     return v;
      76             : }
      77             : 
      78             : template <typename WebGLObjectType>
      79             : JSObject*
      80           0 : WebGLContext::WebGLObjectAsJSObject(JSContext* cx,
      81             :                                     const WebGLObjectType* object,
      82             :                                     ErrorResult& rv) const
      83             : {
      84           0 :     JS::Value v = WebGLObjectAsJSValue(cx, object, rv);
      85           0 :     if (v.isNull())
      86           0 :         return nullptr;
      87             : 
      88           0 :     return &v.toObject();
      89             : }
      90             : 
      91             : /**
      92             :  * Return the displayable name for the texture function that is the
      93             :  * source for validation.
      94             :  */
      95             : const char* InfoFrom(WebGLTexImageFunc func, WebGLTexDimensions dims);
      96             : 
      97             : JS::Value StringValue(JSContext* cx, const nsAString& str, ErrorResult& er);
      98             : 
      99             : } // namespace mozilla
     100             : 
     101             : #endif // WEBGL_CONTEXT_UTILS_H_

Generated by: LCOV version 1.13