Switch to startUse/drawEmbedded/endUse for cursortrail and star stream.

This should be much more efficient when repeatedly rendering the same texture, as in these two cases.

Signed-off-by: Jeffrey Han <itdelatrisu@gmail.com>
This commit is contained in:
Jeffrey Han 2015-09-05 09:32:26 -05:00
parent ffe4d5d415
commit 97dbb36e43
2 changed files with 20 additions and 8 deletions

View File

@ -190,19 +190,25 @@ public class Cursor {
// draw a fading trail
float alpha = 0f;
float t = 2f / cursorX.size();
if (skin.isCursorTrailRotated())
cursorTrail.setRotation(cursorAngle);
int cursorTrailWidth = cursorTrail.getWidth(), cursorTrailHeight = cursorTrail.getHeight();
float cursorTrailRotation = (skin.isCursorTrailRotated()) ? cursorAngle : 0;
Iterator<Integer> iterX = cursorX.iterator();
Iterator<Integer> iterY = cursorY.iterator();
cursorTrail.startUse();
while (iterX.hasNext()) {
int cx = iterX.next();
int cy = iterY.next();
alpha += t;
cursorTrail.setAlpha(alpha);
cursorTrail.setImageColor(1f, 1f, 1f, alpha);
// if (cx != x || cy != y)
cursorTrail.drawCentered(cx, cy);
cursorTrail.drawEmbedded(
cx - (cursorTrailWidth / 2f), cy - (cursorTrailHeight / 2f),
cursorTrailWidth, cursorTrailHeight, cursorTrailRotation);
}
cursorTrail.drawCentered(mouseX, mouseY);
cursorTrail.drawEmbedded(
mouseX - (cursorTrailWidth / 2f), mouseY - (cursorTrailHeight / 2f),
cursorTrailWidth, cursorTrailHeight, cursorTrailRotation);
cursorTrail.endUse();
// draw the other components
if (newStyle && skin.isCursorRotated())

View File

@ -77,9 +77,10 @@ public class StarStream {
*/
public void draw() {
float t = animatedValue.getValue();
starImg.setAlpha(Math.min((1 - t) * 5f, 1f));
starImg.setRotation(angle);
starImg.draw(containerWidth - (distance * t), ((containerHeight - starImg.getHeight()) / 2) + yOffset);
starImg.setImageColor(1f, 1f, 1f, Math.min((1 - t) * 5f, 1f));
starImg.drawEmbedded(
containerWidth - (distance * t), ((containerHeight - starImg.getHeight()) / 2) + yOffset,
starImg.getWidth(), starImg.getHeight(), angle);
}
/**
@ -107,8 +108,13 @@ public class StarStream {
* Draws the star stream.
*/
public void draw() {
if (stars.isEmpty())
return;
starImg.startUse();
for (Star star : stars)
star.draw();
starImg.endUse();
}
/**