// Class: openfl._internal.renderer.cairo.CairoBitmap

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 lime_graphics_cairo__$CairoPattern_CairoPattern_$Impl_$() {return require("./../../../../lime/graphics/cairo/_CairoPattern/CairoPattern_Impl_");}

// Constructor

var CairoBitmap = function(){}

// Meta

CairoBitmap.__name__ = ["openfl","_internal","renderer","cairo","CairoBitmap"];
CairoBitmap.prototype = {
	
};
CairoBitmap.prototype.__class__ = $hxClasses["openfl._internal.renderer.cairo.CairoBitmap"] = CairoBitmap;

// Init



// Statics

CairoBitmap.render = function(bitmap,renderSession) {
	if(!bitmap.__renderable || bitmap.__worldAlpha <= 0) {
		return;
	}
	var cairo = renderSession.cairo;
	if(bitmap.__bitmapData != null && bitmap.__bitmapData.__isValid) {
		renderSession.blendModeManager.setBlendMode(bitmap.__worldBlendMode);
		renderSession.maskManager.pushObject(bitmap);
		var transform = bitmap.__renderTransform;
		if(renderSession.roundPixels) {
			var matrix = transform.__toMatrix3();
			matrix.tx = Math.round(matrix.tx);
			matrix.ty = Math.round(matrix.ty);
			cairo.set_matrix(matrix);
		} else {
			cairo.set_matrix(transform.__toMatrix3());
		}
		var surface = bitmap.__bitmapData.getSurface();
		if(surface != null) {
			var pattern = (lime_graphics_cairo__$CairoPattern_CairoPattern_$Impl_$().default).createForSurface(surface);
			(lime_graphics_cairo__$CairoPattern_CairoPattern_$Impl_$().default).set_filter(pattern,renderSession.allowSmoothing && bitmap.smoothing ? 1 : 3);
			cairo.set_source(pattern);
			if(bitmap.__worldAlpha == 1) {
				cairo.paint();
			} else {
				cairo.paintWithAlpha(bitmap.__worldAlpha);
			}
		}
		renderSession.maskManager.popObject(bitmap);
	}
}


// Export

exports.default = CairoBitmap;