// Class: openfl._internal.renderer.opengl.GLCompressedTextureFormats

var $global = typeof window != "undefined" ? window : typeof global != "undefined" ? global : typeof self != "undefined" ? self : this

$global.Object.defineProperty(exports, "__esModule", {value: true});

var __map_reserved = {};

// Imports

var $hxClasses = require("./../../../../hxClasses_stub").default;
var $import = require("./../../../../import_stub").default;
function haxe_ds_IntMap() {return require("./../../../../haxe/ds/IntMap");}

// Constructor

var GLCompressedTextureFormats = function(context) {
	this.__formatMapAlpha = new (haxe_ds_IntMap().default)();
	this.__formatMap = new (haxe_ds_IntMap().default)();
	this.checkDXT(context);
	this.checkETC1(context);
	this.checkPVRTC(context);
}

// Meta

GLCompressedTextureFormats.__name__ = ["openfl","_internal","renderer","opengl","GLCompressedTextureFormats"];
GLCompressedTextureFormats.prototype = {
	checkDXT: function(context) {
		var gl = context.webgl;
		var compressedExtension = gl.getExtension("WEBGL_compressed_texture_s3tc");
		if(compressedExtension != null) {
			var v = compressedExtension.COMPRESSED_RGBA_S3TC_DXT1_EXT;
			this.__formatMap.set(0,v);
			var v1 = compressedExtension.COMPRESSED_RGBA_S3TC_DXT5_EXT;
			this.__formatMapAlpha.set(0,v1);
		}
	},
	checkETC1: function(context) {
		var gl = context.webgl;
		var compressedExtension = gl.getExtension("WEBGL_compressed_texture_etc1");
		if(compressedExtension != null) {
			var v = compressedExtension.COMPRESSED_RGB_ETC1_WEBGL;
			this.__formatMap.set(2,v);
			var v1 = compressedExtension.COMPRESSED_RGB_ETC1_WEBGL;
			this.__formatMapAlpha.set(2,v1);
		}
	},
	checkPVRTC: function(context) {
		var gl = context.webgl;
		var compressedExtension = gl.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc");
		if(compressedExtension != null) {
			var v = compressedExtension.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;
			this.__formatMap.set(1,v);
			var v1 = compressedExtension.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;
			this.__formatMapAlpha.set(1,v1);
		}
	},
	toTextureFormat: function(alpha,gpuFormat) {
		if(alpha) {
			return this.__formatMapAlpha.get(gpuFormat);
		} else {
			return this.__formatMap.get(gpuFormat);
		}
	}
};
GLCompressedTextureFormats.prototype.__class__ = GLCompressedTextureFormats.prototype.constructor = $hxClasses["openfl._internal.renderer.opengl.GLCompressedTextureFormats"] = GLCompressedTextureFormats;

// Init



// Statics




// Export

exports.default = GLCompressedTextureFormats;