// Class: openfl._internal.renderer.canvas.CanvasBitmap

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_utils_ImageCanvasUtil() {return require("./../../../../lime/graphics/utils/ImageCanvasUtil");}

// Constructor

var CanvasBitmap = function(){}

// Meta

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

// Init



// Statics

CanvasBitmap.render = function(bitmap,renderer) {
	if(!bitmap.__renderable || bitmap.__worldAlpha <= 0) {
		return;
	}
	var context = renderer.context;
	if(bitmap.__bitmapData != null && bitmap.__bitmapData.__isValid && bitmap.__bitmapData.readable) {
		renderer.__setBlendMode(bitmap.__worldBlendMode);
		renderer.__pushMaskObject(bitmap,false);
		(lime_graphics_utils_ImageCanvasUtil().default).convertToCanvas(bitmap.__bitmapData.image);
		context.globalAlpha = bitmap.__worldAlpha;
		var scrollRect = bitmap.__scrollRect;
		renderer.setTransform(bitmap.__renderTransform,context);
		if(!renderer.__allowSmoothing || !bitmap.smoothing) {
			context.mozImageSmoothingEnabled = false;
			context.msImageSmoothingEnabled = false;
			context.imageSmoothingEnabled = false;
		}
		if(scrollRect == null) {
			context.drawImage(bitmap.__bitmapData.image.get_src(),0,0,bitmap.__bitmapData.image.width,bitmap.__bitmapData.image.height);
		} else {
			context.drawImage(bitmap.__bitmapData.image.get_src(),scrollRect.x,scrollRect.y,scrollRect.width,scrollRect.height);
		}
		if(!renderer.__allowSmoothing || !bitmap.smoothing) {
			context.mozImageSmoothingEnabled = true;
			context.msImageSmoothingEnabled = true;
			context.imageSmoothingEnabled = true;
		}
		renderer.__popMaskObject(bitmap,false);
	}
}


// Export

exports.default = CanvasBitmap;