UNPKG

starling-framework

Version:

A fast, productive library for 2D cross-platform development.

178 lines (161 loc) 5.92 kB
// Class: starling.textures.ConcreteTexture 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 $hxEnums = require("./../../hxEnums_stub").default; var $import = require("./../../import_stub").default; var $bind = require("./../../bind_stub").default; var $extend = require("./../../extend_stub").default; function starling_textures_Texture() {return require("./../../starling/textures/Texture");} function js__$Boot_HaxeError() {return require("./../../js/_Boot/HaxeError");} function starling_errors_NotSupportedError() {return require("./../../starling/errors/NotSupportedError");} function starling_errors_AbstractMethodError() {return require("./../../starling/errors/AbstractMethodError");} function starling_utils_Color() {return require("./../../starling/utils/Color");} function Std() {return require("./../../Std");} function starling_core_Starling() {return require("./../../starling/core/Starling");} // Constructor var ConcreteTexture = function(base,format,width,height,mipMapping,premultipliedAlpha,optimizedForRenderTexture,scale) { if(scale == null) { scale = 1; } if(optimizedForRenderTexture == null) { optimizedForRenderTexture = false; } (starling_textures_Texture().default).call(this); this._scale = scale <= 0 ? 1.0 : scale; this._base = base; this._format = format; this._width = width; this._height = height; this._mipMapping = mipMapping; this._premultipliedAlpha = premultipliedAlpha; this._optimizedForRenderTexture = optimizedForRenderTexture; this._onRestore = null; this._dataUploaded = false; } // Meta ConcreteTexture.__name__ = "starling.textures.ConcreteTexture"; ConcreteTexture.__isInterface__ = false; ConcreteTexture.__super__ = (starling_textures_Texture().default); ConcreteTexture.prototype = $extend((starling_textures_Texture().default).prototype, { dispose: function() { if(this._base != null) { this._base.dispose(); } this.set_onRestore(null); (starling_textures_Texture().default).prototype.dispose.call(this); }, uploadBitmap: function(bitmap,async) { this.uploadBitmapData(bitmap.get_bitmapData(),async); }, uploadBitmapData: function(data,async) { throw new (js__$Boot_HaxeError().default)(new (starling_errors_NotSupportedError().default)()); }, uploadAtfData: function(data,offset,async) { if(offset == null) { offset = 0; } throw new (js__$Boot_HaxeError().default)(new (starling_errors_NotSupportedError().default)()); }, attachNetStream: function(netStream,onComplete) { this.attachVideo("NetStream",netStream,onComplete); }, attachVideo: function(type,attachment,onComplete) { throw new (js__$Boot_HaxeError().default)(new (starling_errors_NotSupportedError().default)()); }, onContextCreated: function() { this._dataUploaded = false; this._base = this.createBase(); this._onRestore(this); if(!this._dataUploaded) { this.clear(); } }, createBase: function() { throw new (js__$Boot_HaxeError().default)(new (starling_errors_AbstractMethodError().default)()); }, recreateBase: function() { this._base = this.createBase(); }, clear: function(color,alpha) { if(alpha == null) { alpha = 0.0; } if(color == null) { color = 0; } if(this._premultipliedAlpha && alpha < 1.0) { color = (starling_utils_Color().default).rgb((Std().default).int((starling_utils_Color().default).getRed(color) * alpha),(Std().default).int((starling_utils_Color().default).getGreen(color) * alpha),(Std().default).int((starling_utils_Color().default).getBlue(color) * alpha)); } var painter = (starling_core_Starling().default).get_current().get_painter(); painter.pushState(); painter.get_state().set_renderTarget(this); try { painter.clear(color,alpha); } catch( e ) { var e1 = ((e) instanceof (js__$Boot_HaxeError().default)) ? e.val : e; } painter.popState(); this.setDataUploaded(); }, setDataUploaded: function() { this._dataUploaded = true; }, get_optimizedForRenderTexture: function() { return this._optimizedForRenderTexture; }, get_isPotTexture: function() { return false; }, get_onRestore: function() { return this._onRestore; }, set_onRestore: function(value) { (starling_core_Starling().default).get_current().removeEventListener("context3DCreate",$bind(this,this.onContextCreated)); if(value != null) { this._onRestore = value; (starling_core_Starling().default).get_current().addEventListener("context3DCreate",$bind(this,this.onContextCreated)); } else { this._onRestore = null; } return value; }, get_base: function() { return this._base; }, get_root: function() { return this; }, get_format: function() { return this._format; }, get_width: function() { return this._width / this._scale; }, get_height: function() { return this._height / this._scale; }, get_nativeWidth: function() { return this._width; }, get_nativeHeight: function() { return this._height; }, get_scale: function() { return this._scale; }, get_mipMapping: function() { return this._mipMapping; }, get_premultipliedAlpha: function() { return this._premultipliedAlpha; } }); ConcreteTexture.prototype.__class__ = ConcreteTexture.prototype.constructor = $hxClasses["starling.textures.ConcreteTexture"] = ConcreteTexture; // Init Object.defineProperties(ConcreteTexture.prototype,{ optimizedForRenderTexture : { get : function () { return this.get_optimizedForRenderTexture (); }}, isPotTexture : { get : function () { return this.get_isPotTexture (); }}, onRestore : { get : function () { return this.get_onRestore (); }, set : function (v) { return this.set_onRestore (v); }}}); // Statics // Export exports.default = ConcreteTexture;