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.
22 goog
.provide('framework.common.tcuPixelFormat');
24 goog
.scope(function() {
26 var tcuPixelFormat
= framework
.common
.tcuPixelFormat
;
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;
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
);
62 tcuPixelFormat
.PixelFormat
.prototype.equals = function(r
, g
, b
, a
) {
63 return this.redBits
=== r
&&
64 this.greenBits
=== g
&&
65 this.blueBits
=== b
&&
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];