// Class: openfl.filters._ColorMatrixFilter.ColorMatrixShader

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;
var $extend = require("./../../../extend_stub").default;
function openfl_display_Shader() {return require("./../../../openfl/display/Shader");}

// Constructor

var ColorMatrixShader = function() {
	if(this.__glFragmentSource == null) {
		this.__glFragmentSource = "varying float vAlpha;\n\t\tvarying vec2 vTexCoord;\n\t\tuniform sampler2D uImage0;\n\t\t\n\t\tuniform mat4 uMultipliers;\n\t\tuniform vec4 uOffsets;\n\t\t\n\t\tvoid main(void) {\n\t\t\t\n\t\t\tvec4 color = texture2D (uImage0, vTexCoord);\n\t\t\t\n\t\t\tif (color.a == 0.0) {\n\t\t\t\t\n\t\t\t\tgl_FragColor = vec4 (0.0, 0.0, 0.0, 0.0);\n\t\t\t\t\n\t\t\t} else {\n\t\t\t\t\n\t\t\t\tcolor = vec4 (color.rgb / color.a, color.a);\n\t\t\t\tcolor = uOffsets + color * uMultipliers;\n\t\t\t\t\n\t\t\t\tgl_FragColor = vec4 (color.rgb * color.a * vAlpha, color.a * vAlpha);\n\t\t\t\t\n\t\t\t}\n\t\t\t\n\t\t}";
	}
	(openfl_display_Shader().default).call(this);
	this.get_data().uMultipliers.value = [1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1];
	this.get_data().uOffsets.value = [0,0,0,0];
}

// Meta

ColorMatrixShader.__name__ = ["openfl","filters","_ColorMatrixFilter","ColorMatrixShader"];
ColorMatrixShader.__super__ = (openfl_display_Shader().default);
ColorMatrixShader.prototype = $extend((openfl_display_Shader().default).prototype, {
	init: function(matrix) {
		var multipliers = this.get_data().uMultipliers.value;
		var offsets = this.get_data().uOffsets.value;
		multipliers[0] = matrix[0];
		multipliers[1] = matrix[1];
		multipliers[2] = matrix[2];
		multipliers[3] = matrix[3];
		multipliers[4] = matrix[5];
		multipliers[5] = matrix[6];
		multipliers[6] = matrix[7];
		multipliers[7] = matrix[8];
		multipliers[8] = matrix[10];
		multipliers[9] = matrix[11];
		multipliers[10] = matrix[12];
		multipliers[11] = matrix[13];
		multipliers[12] = matrix[15];
		multipliers[13] = matrix[16];
		multipliers[14] = matrix[17];
		multipliers[15] = matrix[18];
		offsets[0] = matrix[4] / 255.0;
		offsets[1] = matrix[9] / 255.0;
		offsets[2] = matrix[14] / 255.0;
		offsets[3] = matrix[19] / 255.0;
	}
});
ColorMatrixShader.prototype.__class__ = $hxClasses["openfl.filters._ColorMatrixFilter.ColorMatrixShader"] = ColorMatrixShader;

// Init



// Statics




// Export

exports.default = ColorMatrixShader;