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

          Line data    Source code
       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/. */
       5             : 
       6             : #include "WebGL2Context.h"
       7             : #include "WebGLSampler.h"
       8             : #include "GLContext.h"
       9             : 
      10             : namespace mozilla {
      11             : 
      12             : already_AddRefed<WebGLSampler>
      13           0 : WebGL2Context::CreateSampler()
      14             : {
      15           0 :     if (IsContextLost())
      16           0 :         return nullptr;
      17             : 
      18             :     GLuint sampler;
      19           0 :     MakeContextCurrent();
      20           0 :     gl->fGenSamplers(1, &sampler);
      21             : 
      22           0 :     RefPtr<WebGLSampler> globj = new WebGLSampler(this, sampler);
      23           0 :     return globj.forget();
      24             : }
      25             : 
      26             : void
      27           0 : WebGL2Context::DeleteSampler(WebGLSampler* sampler)
      28             : {
      29           0 :     if (!ValidateDeleteObject("deleteSampler", sampler))
      30           0 :         return;
      31             : 
      32           0 :     for (int n = 0; n < mGLMaxTextureUnits; n++) {
      33           0 :         if (mBoundSamplers[n] == sampler) {
      34           0 :             mBoundSamplers[n] = nullptr;
      35             : 
      36           0 :             InvalidateResolveCacheForTextureWithTexUnit(n);
      37             :         }
      38             :     }
      39             : 
      40           0 :     sampler->RequestDelete();
      41             : }
      42             : 
      43             : bool
      44           0 : WebGL2Context::IsSampler(const WebGLSampler* sampler)
      45             : {
      46           0 :     if (!ValidateIsObject("isSampler", sampler))
      47           0 :         return false;
      48             : 
      49           0 :     MakeContextCurrent();
      50           0 :     return gl->fIsSampler(sampler->mGLName);
      51             : }
      52             : 
      53             : void
      54           0 : WebGL2Context::BindSampler(GLuint unit, WebGLSampler* sampler)
      55             : {
      56           0 :     if (IsContextLost())
      57           0 :         return;
      58             : 
      59           0 :     if (sampler && !ValidateObject("bindSampler", *sampler))
      60           0 :         return;
      61             : 
      62           0 :     if (GLint(unit) >= mGLMaxTextureUnits)
      63           0 :         return ErrorInvalidValue("bindSampler: unit must be < %d", mGLMaxTextureUnits);
      64             : 
      65             :     ////
      66             : 
      67           0 :     gl->MakeCurrent();
      68           0 :     gl->fBindSampler(unit, sampler ? sampler->mGLName : 0);
      69             : 
      70           0 :     InvalidateResolveCacheForTextureWithTexUnit(unit);
      71           0 :     mBoundSamplers[unit] = sampler;
      72             : }
      73             : 
      74             : void
      75           0 : WebGL2Context::SamplerParameteri(WebGLSampler& sampler, GLenum pname, GLint param)
      76             : {
      77           0 :     const char funcName[] = "samplerParameteri";
      78           0 :     if (IsContextLost())
      79           0 :         return;
      80             : 
      81           0 :     if (!ValidateObject(funcName, sampler))
      82           0 :         return;
      83             : 
      84           0 :     sampler.SamplerParameter(funcName, pname, FloatOrInt(param));
      85             : }
      86             : 
      87             : void
      88           0 : WebGL2Context::SamplerParameterf(WebGLSampler& sampler, GLenum pname, GLfloat param)
      89             : {
      90           0 :     const char funcName[] = "samplerParameterf";
      91           0 :     if (IsContextLost())
      92           0 :         return;
      93             : 
      94           0 :     if (!ValidateObject(funcName, sampler))
      95           0 :         return;
      96             : 
      97           0 :     sampler.SamplerParameter(funcName, pname, FloatOrInt(param));
      98             : }
      99             : 
     100             : void
     101           0 : WebGL2Context::GetSamplerParameter(JSContext*, const WebGLSampler& sampler, GLenum pname,
     102             :                                    JS::MutableHandleValue retval)
     103             : {
     104           0 :     const char funcName[] = "getSamplerParameter";
     105           0 :     retval.setNull();
     106             : 
     107           0 :     if (IsContextLost())
     108           0 :         return;
     109             : 
     110           0 :     if (!ValidateObject(funcName, sampler))
     111           0 :         return;
     112             : 
     113             :     ////
     114             : 
     115           0 :     gl->MakeCurrent();
     116             : 
     117           0 :     switch (pname) {
     118             :     case LOCAL_GL_TEXTURE_MIN_FILTER:
     119             :     case LOCAL_GL_TEXTURE_MAG_FILTER:
     120             :     case LOCAL_GL_TEXTURE_WRAP_S:
     121             :     case LOCAL_GL_TEXTURE_WRAP_T:
     122             :     case LOCAL_GL_TEXTURE_WRAP_R:
     123             :     case LOCAL_GL_TEXTURE_COMPARE_MODE:
     124             :     case LOCAL_GL_TEXTURE_COMPARE_FUNC:
     125             :         {
     126           0 :             GLint param = 0;
     127           0 :             gl->fGetSamplerParameteriv(sampler.mGLName, pname, &param);
     128           0 :             retval.set(JS::Int32Value(param));
     129             :         }
     130           0 :         return;
     131             : 
     132             :     case LOCAL_GL_TEXTURE_MIN_LOD:
     133             :     case LOCAL_GL_TEXTURE_MAX_LOD:
     134             :         {
     135           0 :             GLfloat param = 0;
     136           0 :             gl->fGetSamplerParameterfv(sampler.mGLName, pname, &param);
     137           0 :             retval.set(JS::Float32Value(param));
     138             :         }
     139           0 :         return;
     140             : 
     141             :     default:
     142           0 :         ErrorInvalidEnumArg(funcName, "pname", pname);
     143           0 :         return;
     144             :     }
     145             : }
     146             : 
     147             : } // namespace mozilla

Generated by: LCOV version 1.13