(width, height)
| 187 | } |
| 188 | |
| 189 | resize(width, height) { |
| 190 | this._prevDrawStyle = ""; |
| 191 | |
| 192 | this._fbWidth = width; |
| 193 | this._fbHeight = height; |
| 194 | |
| 195 | const canvas = this._backbuffer; |
| 196 | if (canvas.width !== width || canvas.height !== height) { |
| 197 | |
| 198 | // We have to save the canvas data since changing the size will clear it |
| 199 | let saveImg = null; |
| 200 | if (canvas.width > 0 && canvas.height > 0) { |
| 201 | saveImg = this._drawCtx.getImageData(0, 0, canvas.width, canvas.height); |
| 202 | } |
| 203 | |
| 204 | if (canvas.width !== width) { |
| 205 | canvas.width = width; |
| 206 | } |
| 207 | if (canvas.height !== height) { |
| 208 | canvas.height = height; |
| 209 | } |
| 210 | |
| 211 | if (saveImg) { |
| 212 | this._drawCtx.putImageData(saveImg, 0, 0); |
| 213 | } |
| 214 | } |
| 215 | |
| 216 | // Readjust the viewport as it may be incorrectly sized |
| 217 | // and positioned |
| 218 | const vp = this._viewportLoc; |
| 219 | this.viewportChangeSize(vp.w, vp.h); |
| 220 | this.viewportChangePos(0, 0); |
| 221 | } |
| 222 | |
| 223 | getImageData() { |
| 224 | return this._drawCtx.getImageData(0, 0, this.width, this.height); |
nothing calls this directly
no test coverage detected