-
- // now that we've reconstructed this region in the backbuffer, queue it to be reblitted
- screenDirtyRegions.dirty(x, y, w, h);
- }
-
- // blit out all the areas we've just reconstructed
- blitDirtyScreenRegions();
- }
-
- /** blits from the backbuffer to the screen for all regions of the screen which have become dirty */
- public synchronized void blitDirtyScreenRegions() { blitDirtyScreenRegions(-1, -1, 0, 0); }
-
- /** same as blitDirtyScreenRegions(), except that it will skip any regions within a,b,c,d */
- private synchronized void blitDirtyScreenRegions(int a, int b, int c, int d) {
-
- int[][] dirt = screenDirtyRegions.flush();
- if (Main.showRenders && dirt != null && dirt.length > 0 && a == -1)
- blit(backbuffer, 0, 0, 0, 0, width, height);
-
- for(int i = 0; dirt != null && i < dirt.length; i++) {
- if (dirt[i] == null) continue;
- int x = dirt[i][0];
- int y = dirt[i][1];
- int w = dirt[i][2];
- int h = dirt[i][3];
- if (x < 0) x = 0;
- if (y < 0) y = 0;
- if (x+w > root.width) w = root.width - x;
- if (y+h > root.height) h = root.height - y;
- if (w <= 0 || h <= 0) continue;
-
- // if any part of this region falls within the "bad region", just skip it
- boolean hhit = (x >= a && x <= a + c) || (x+w >= a && x+w <= a + c);
- boolean vhit = (y >= b && y <= b + d) || (y+h >= b && y+h <= b + d);
- if (hhit && vhit) {
- screenDirtyRegions.dirty(x, y, w, h);
- continue;
- }
-
- blit(backbuffer, x, y, x, y, w + x, h + y);
-
- if (Main.showRenders) {
- if (showRenderBuf == null) {
- showRenderBuf = Platform.createDoubleBuffer(10, 10, this);
- showRenderBuf.fillRect(0, 0, 10, 10, 0x00FF0000);
- showRenderBuf2 = Platform.createDoubleBuffer(100, 100, this);
- for(int y1 = 0; y1<100; y1++)
- for(int x1 = 0; x1<100; x1++)
- if ((x1 + y1) % 5 == 0)
- showRenderBuf2.fillRect(x1, y1, x1 + 1, y1 + 1, 0x00FF0000);
- }
- for(int x1 = x; x1<x + w; x1 += 100)
- for(int y1 = y; y1< y + h; y1 += 100) {
- blit(showRenderBuf2, 0, 0, x1, y1, Math.min(x1 + 100, x + w), Math.min(y1 + 100, y + h));
- }
- for(int j=x; j<x + w; j += 10) {
- blit(showRenderBuf, 0, 0, j, y, Math.min(j+ 10, x + w), y + 1);
- blit(showRenderBuf, 0, 0, j, y + h, Math.min(j + 10, x + w), y + h + 1);
- }
- for(int j=y; j<y + h; j += 10) {
- blit(showRenderBuf, 0, 0, x, j, x + 1, Math.min(j + 10, y + h));
- blit(showRenderBuf, 0, 0, x + w, j, x + w + 1, Math.min(j + 10, y + h));
- }
- }
-