Bug 1918529 - fix some subpixel misalignment issues with gfx.webrender.svg-filter...
[gecko.git] / dom / canvas / test / webgl-conf / checkout / deqp / framework / common / tcuPixelFormat.js
blobdaf3297a9341c27e4abccf9d36152a3db8937783
1 /*-------------------------------------------------------------------------
2 * drawElements Quality Program OpenGL ES Utilities
3 * ------------------------------------------------
5 * Copyright 2014 The Android Open Source Project
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
21 'use strict';
22 goog.provide('framework.common.tcuPixelFormat');
24 goog.scope(function() {
26 var tcuPixelFormat = framework.common.tcuPixelFormat;
28 /**
29 * @constructor
30 * @param {number=} r
31 * @param {number=} g
32 * @param {number=} b
33 * @param {number=} a
35 tcuPixelFormat.PixelFormat = function(r, g, b, a) {
36 this.redBits = r || 0;
37 this.greenBits = g || 0;
38 this.blueBits = b || 0;
39 this.alphaBits = a || 0;
42 /**
43 * @param {WebGL2RenderingContext} context
44 * @return {tcuPixelFormat.PixelFormat}
46 tcuPixelFormat.PixelFormatFromContext = function(context) {
47 var r = /** @type {number} */ (context.getParameter(gl.RED_BITS));
48 var g = /** @type {number} */ (context.getParameter(gl.GREEN_BITS));
49 var b = /** @type {number} */ (context.getParameter(gl.BLUE_BITS));
50 var a = /** @type {number} */ (context.getParameter(gl.ALPHA_BITS));
52 return new tcuPixelFormat.PixelFormat(r, g, b, a);
55 /**
56 * @param {number} r
57 * @param {number} g
58 * @param {number} b
59 * @param {number} a
60 * @return {boolean}
62 tcuPixelFormat.PixelFormat.prototype.equals = function(r, g, b, a) {
63 return this.redBits === r &&
64 this.greenBits === g &&
65 this.blueBits === b &&
66 this.alphaBits === a;
69 /**
70 * @return {Array<number>}
72 tcuPixelFormat.PixelFormat.prototype.getColorThreshold = function() {
73 return [1 << (8 - this.redBits),
74 1 << (8 - this.greenBits),
75 1 << (8 - this.blueBits),
76 (this.alphaBits > 0) ? (1 << (8 - this.alphaBits)) : 0];
79 });