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

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 openfl__$internal_renderer_canvas_CanvasGraphics() {return require("./../../../../openfl/_internal/renderer/canvas/CanvasGraphics");}

// Constructor

var CanvasShape = function(){}

// Meta

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

// Init



// Statics

CanvasShape.render = function(shape,renderer) {
	if(!shape.__renderable || shape.__worldAlpha <= 0) {
		return;
	}
	var graphics = shape.__graphics;
	if(graphics != null) {
		(openfl__$internal_renderer_canvas_CanvasGraphics().default).render(graphics,renderer);
		var bounds = graphics.__bounds;
		var width = graphics.__width;
		var height = graphics.__height;
		if(graphics.__canvas != null) {
			var context = renderer.context;
			var scrollRect = shape.__scrollRect;
			if(width > 0 && height > 0 && (scrollRect == null || scrollRect.width > 0 && scrollRect.height > 0)) {
				renderer.__setBlendMode(shape.__worldBlendMode);
				renderer.__pushMaskObject(shape);
				context.globalAlpha = shape.__worldAlpha;
				renderer.setTransform(graphics.__worldTransform,context);
				if(renderer.__isDOM) {
					var reverseScale = 1 / renderer.pixelRatio;
					context.scale(reverseScale,reverseScale);
				}
				context.drawImage(graphics.__canvas,0,0,width,height);
				renderer.__popMaskObject(shape);
			}
		}
	}
}


// Export

exports.default = CanvasShape;