1
0
Fork 0
mirror of https://github.com/openstf/stf synced 2025-10-06 12:00:08 +02:00

- Removed PixiRender, it was too slow.

- Fixed bug not removing onLoad infinite loop.
This commit is contained in:
Gunther Brunner 2014-03-07 18:20:34 +09:00
parent 667ba512ae
commit 180bc42f38
2 changed files with 5 additions and 56 deletions

View file

@ -6,53 +6,6 @@
// ------------------------------------------------------------------------------------------------- // -------------------------------------------------------------------------------------------------
function FastPixiRender(canvasElement, options) {
this.options = options
this.stage = new PIXI.Stage(0x000000)
this.canvasWidth = 643
this.canvasHeight = 1149
switch (this.options.render) {
case 'pixi':
this.renderer = new PIXI.autoDetectRenderer(this.canvasWidth, this.canvasHeight, canvasElement)
break;
case 'pixi-canvas':
this.renderer = new PIXI.CanvasRenderer(this.canvasWidth, this.canvasHeight, canvasElement)
break;
case 'pixi-webgl':
this.renderer = new PIXI.WebGLRenderer(this.canvasWidth, this.canvasHeight, canvasElement)
break;
}
}
FastPixiRender.prototype.draw = function (image) {
// if (this.baseTexture) {
// this.baseTexture.destroy()
// }
this.baseTexture = new PIXI.BaseTexture(image)
if (this.texture) {
this.texture.destroy(true)
}
this.texture = new PIXI.Texture(this.baseTexture)
if (this.sprite) {
this.sprite.setTexture(this.texture)
//this.stage.removeChild(this.sprite)
} else {
this.sprite = new PIXI.Sprite(this.texture)
this.stage.addChild(this.sprite)
}
this.renderer.render(this.stage)
}
// -------------------------------------------------------------------------------------------------
function CanvasRender(canvasElement, options) { function CanvasRender(canvasElement, options) {
var checkForCanvasElement = function checkForCanvasElement() { var checkForCanvasElement = function checkForCanvasElement() {
if (!canvasElement) { if (!canvasElement) {
@ -454,8 +407,6 @@ function FastImageRender(canvasElement, options) {
if (this.options.render === 'webgl') { if (this.options.render === 'webgl') {
this.render = new WebGLRender(canvasElement, options) this.render = new WebGLRender(canvasElement, options)
} else if (this.options.render.indexOf('pixi') !== -1) {
this.render = new FastPixiRender(canvasElement, options)
} else { } else {
this.render = new CanvasRender(canvasElement, options) this.render = new CanvasRender(canvasElement, options)
} }

View file

@ -1,4 +1,3 @@
var FastImageLoader = require('./fast-image-render').FastImageLoader
var FastImageRender = require('./fast-image-render').FastImageRender var FastImageRender = require('./fast-image-render').FastImageRender
module.exports = function DeviceScreenDirective($document, ScalingService, $rootScope) { module.exports = function DeviceScreenDirective($document, ScalingService, $rootScope) {
@ -7,8 +6,7 @@ module.exports = function DeviceScreenDirective($document, ScalingService, $root
template: require('./screen.jade'), template: require('./screen.jade'),
link: function (scope, element, attrs) { link: function (scope, element, attrs) {
scope.device.promise.then(function (device) { scope.device.promise.then(function (device) {
var imageLoader = new FastImageLoader() var canvas = element.find('canvas')[0]
, canvas = element.find('canvas')[0]
, imageRender = new FastImageRender(canvas, {render: 'canvas'}) , imageRender = new FastImageRender(canvas, {render: 'canvas'})
, finger = element.find('span') , finger = element.find('span')
, input = element.find('textarea') , input = element.find('textarea')
@ -60,14 +58,14 @@ module.exports = function DeviceScreenDirective($document, ScalingService, $root
} }
function loadScreen() { function loadScreen() {
imageLoader.load(device.display.url + imageRender.load(device.display.url +
'?width=' + displayWidth + '?width=' + displayWidth +
'&height=' + displayHeight + '&height=' + displayHeight +
'&time=' + Date.now() '&time=' + Date.now()
) )
} }
imageLoader.onLoad = function (image) { imageRender.onLoad = function (image) {
if (scope.canView && scope.showScreen) { if (scope.canView && scope.showScreen) {
// Check to set the size only if updated // Check to set the size only if updated
@ -102,7 +100,7 @@ module.exports = function DeviceScreenDirective($document, ScalingService, $root
} }
imageLoader.onError = function () { imageRender.onError = function () {
scope.$apply(function () { scope.$apply(function () {
scope.displayError = true scope.displayError = true
}) })
@ -152,7 +150,7 @@ module.exports = function DeviceScreenDirective($document, ScalingService, $root
} }
scope.$on('$destroy', function () { scope.$on('$destroy', function () {
loader.onload = loader.onerror = null imageRender.onLoad = imageRender.onError = null
stop() stop()
}) })