From 32152f923b807ad341f431db06c9be1b2e5a1b70 Mon Sep 17 00:00:00 2001 From: Xiaoji Chen Date: Mon, 3 Jun 2019 17:11:12 -0700 Subject: [PATCH] fix render test --- .../layers/src/bitmap-layer/bitmap-layer.js | 26 +++++++++---------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/modules/layers/src/bitmap-layer/bitmap-layer.js b/modules/layers/src/bitmap-layer/bitmap-layer.js index 8e069d9a51f..6b0746e64d9 100644 --- a/modules/layers/src/bitmap-layer/bitmap-layer.js +++ b/modules/layers/src/bitmap-layer/bitmap-layer.js @@ -38,7 +38,7 @@ const DEFAULT_TEXTURE_PARAMETERS = { }; const defaultProps = { - image: {type: 'object', value: null, async: true}, + image: null, bounds: {type: 'array', value: [1, 0, 0, 1], compare: true}, fp64: false, @@ -93,7 +93,7 @@ export default class BitmapLayer extends Layer { } if (props.image !== oldProps.image) { - this.loadTexture(); + this.loadTexture(props.image); } const attributeManager = this.getAttributeManager(); @@ -200,24 +200,22 @@ export default class BitmapLayer extends Layer { } } - loadTexture() { + loadTexture(image) { + if (typeof image === 'string') { + image = loadImage(image); + } + if (image instanceof Promise) { + image.then(data => this.loadTexture(data)); + return; + } + const {gl} = this.context; - const {image} = this.props; if (this.state.bitmapTexture) { this.state.bitmapTexture.delete(); } - if (typeof image === 'string') { - loadImage(image).then(data => { - this.setState({ - bitmapTexture: new Texture2D(gl, { - data, - parameters: DEFAULT_TEXTURE_PARAMETERS - }) - }); - }); - } else if (image instanceof Texture2D) { + if (image instanceof Texture2D) { this.setState({bitmapTexture: image}); } else if ( // browser object