(x, y, width, height, arr, offset, fromQueue)
| 392 | } |
| 393 | |
| 394 | blitImage(x, y, width, height, arr, offset, fromQueue) { |
| 395 | if (this._renderQ.length !== 0 && !fromQueue) { |
| 396 | // NB(directxman12): it's technically more performant here to use preallocated arrays, |
| 397 | // but it's a lot of extra work for not a lot of payoff -- if we're using the render queue, |
| 398 | // this probably isn't getting called *nearly* as much |
| 399 | const newArr = new Uint8Array(width * height * 4); |
| 400 | newArr.set(new Uint8Array(arr.buffer, 0, newArr.length)); |
| 401 | this._renderQPush({ |
| 402 | 'type': 'blit', |
| 403 | 'data': newArr, |
| 404 | 'x': x, |
| 405 | 'y': y, |
| 406 | 'width': width, |
| 407 | 'height': height, |
| 408 | }); |
| 409 | } else { |
| 410 | // NB(directxman12): arr must be an Type Array view |
| 411 | let data = new Uint8ClampedArray(arr.buffer, |
| 412 | arr.byteOffset + offset, |
| 413 | width * height * 4); |
| 414 | let img = new ImageData(data, width, height); |
| 415 | this._drawCtx.putImageData(img, x, y); |
| 416 | this._damage(x, y, width, height); |
| 417 | } |
| 418 | } |
| 419 | |
| 420 | drawImage(img, ...args) { |
| 421 | this._drawCtx.drawImage(img, ...args); |
no test coverage detected