Mercurial > hg > ristipolku
comparison game/Engine.java @ 86:454a9fcd13ca
Turn antialiasing rendering hints on only for the needed elements to improve rendering speed and CPU usage.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Thu, 03 Mar 2011 16:33:02 +0200 |
parents | b8bc5d08b512 |
children | 6afbf88c8bda |
comparison
equal
deleted
inserted
replaced
85:e9fab3c96043 | 86:454a9fcd13ca |
---|---|
548 | 548 |
549 public void paintComponent(Graphics g) | 549 public void paintComponent(Graphics g) |
550 { | 550 { |
551 Graphics2D g2 = (Graphics2D) g; | 551 Graphics2D g2 = (Graphics2D) g; |
552 | 552 |
553 // Use antialiasing when rendering the game elements | |
554 g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, | |
555 RenderingHints.VALUE_ANTIALIAS_ON); | |
556 | |
557 g2.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, | |
558 RenderingHints.VALUE_TEXT_ANTIALIAS_ON); | |
559 | |
560 | |
561 // Rescale if parent component size has changed | 553 // Rescale if parent component size has changed |
562 Dimension dim = getSize(); | 554 Dimension dim = getSize(); |
563 if (G.screenDim == null || !dim.equals(G.screenDim)) | 555 if (G.screenDim == null || !dim.equals(G.screenDim)) |
564 { | 556 { |
565 // Rescale IDM GUI widgets | 557 // Rescale IDM GUI widgets |
586 G.metrics[i] = g2.getFontMetrics(G.fonts[i]); | 578 G.metrics[i] = g2.getFontMetrics(G.fonts[i]); |
587 } | 579 } |
588 | 580 |
589 // Draw background image, pieces, widgets | 581 // Draw background image, pieces, widgets |
590 g2.drawImage(G.lautaBGScaled, 0, 0, null); | 582 g2.drawImage(G.lautaBGScaled, 0, 0, null); |
583 | |
584 // Use antialiasing when rendering the game elements | |
585 g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, | |
586 RenderingHints.VALUE_ANTIALIAS_ON); | |
587 | |
588 g2.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, | |
589 RenderingHints.VALUE_TEXT_ANTIALIAS_ON); | |
590 | |
591 widgets.paint(g2); | 591 widgets.paint(g2); |
592 | 592 |
593 if (!lauta.flagGameOver) | 593 if (!lauta.flagGameOver) |
594 { | 594 { |
595 if (lauta.nextPiece != null) | 595 if (lauta.nextPiece != null) |