(deltaX, deltaY)
| 90 | // ===== PUBLIC METHODS ===== |
| 91 | |
| 92 | viewportChangePos(deltaX, deltaY) { |
| 93 | const vp = this._viewportLoc; |
| 94 | deltaX = Math.floor(deltaX); |
| 95 | deltaY = Math.floor(deltaY); |
| 96 | |
| 97 | if (!this._clipViewport) { |
| 98 | deltaX = -vp.w; // clamped later of out of bounds |
| 99 | deltaY = -vp.h; |
| 100 | } |
| 101 | |
| 102 | const vx2 = vp.x + vp.w - 1; |
| 103 | const vy2 = vp.y + vp.h - 1; |
| 104 | |
| 105 | // Position change |
| 106 | |
| 107 | if (deltaX < 0 && vp.x + deltaX < 0) { |
| 108 | deltaX = -vp.x; |
| 109 | } |
| 110 | if (vx2 + deltaX >= this._fbWidth) { |
| 111 | deltaX -= vx2 + deltaX - this._fbWidth + 1; |
| 112 | } |
| 113 | |
| 114 | if (vp.y + deltaY < 0) { |
| 115 | deltaY = -vp.y; |
| 116 | } |
| 117 | if (vy2 + deltaY >= this._fbHeight) { |
| 118 | deltaY -= (vy2 + deltaY - this._fbHeight + 1); |
| 119 | } |
| 120 | |
| 121 | if (deltaX === 0 && deltaY === 0) { |
| 122 | return; |
| 123 | } |
| 124 | Log.Debug("viewportChange deltaX: " + deltaX + ", deltaY: " + deltaY); |
| 125 | |
| 126 | vp.x += deltaX; |
| 127 | vp.y += deltaY; |
| 128 | |
| 129 | this._damage(vp.x, vp.y, vp.w, vp.h); |
| 130 | |
| 131 | this.flip(); |
| 132 | } |
| 133 | |
| 134 | viewportChangeSize(width, height) { |
| 135 |
no test coverage detected