Skip to content

Commit

Permalink
fix code
Browse files Browse the repository at this point in the history
fix code
  • Loading branch information
cping committed Dec 19, 2024
1 parent 667da20 commit 1bf3b6f
Show file tree
Hide file tree
Showing 16 changed files with 94 additions and 29 deletions.
4 changes: 2 additions & 2 deletions Java/Loon-Lite(PureJava)/LoonLiteCore/src/loon/Display.java
Original file line number Diff line number Diff line change
Expand Up @@ -461,8 +461,8 @@ protected void draw(LTimerContext clock) {
_glEx.end();
_glEx.restoreTx();
_process.resetTouch();
GraphicsDrawCall.clear();
}

}

private void onFrame() {
Expand Down Expand Up @@ -576,7 +576,7 @@ private final void drawDebug(final GLEx gl, final LSetting setting, final long d

displayMessage.setLength(0);
displayMessage.append(DRAWCALL_STR);
displayMessage.append(gl.getDrawCallCount());
displayMessage.append(gl.getDrawCallCount() + GraphicsDrawCall.getCount());

displayDrawCall = displayMessage.toString();

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/**
* Copyright 2008 - 2019 The Loon Game Engine Authors
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*
* @project loon
* @author cping
* @email:[email protected]
* @version 0.5
*/
package loon;

public class GraphicsDrawCall {

private static int GLOBAL_COUNT;

public static void clear() {
GLOBAL_COUNT = 0;
}

public static void add(int count) {
GLOBAL_COUNT += count;
}

public static int getCount() {
return GLOBAL_COUNT;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,7 @@ public LTextureBatch submit(float x, float y) {
canvas.setTransform(gl.tx());
canvas.draw(_buffer.snapshot(), x, y);
_drawCallCount++;
GraphicsDrawCall.add(_drawCallCount);
}
return this;
}
Expand Down Expand Up @@ -305,7 +306,7 @@ public LTextureBatch commit(float x, float y, float sx, float sy, float ax, floa
Canvas canvas = gl.getCanvas();
canvas.setTransform(display);
canvas.draw(_buffer.snapshot(), x, y);
_drawCallCount++;
GraphicsDrawCall.add(1);
}
return this;
}
Expand Down Expand Up @@ -529,7 +530,6 @@ public LTextureBatch draw(float x, float y, float pivotX, float pivotY, float or
}

vertexIdx += 9;
_drawCallCount++;
return this;
}

Expand Down Expand Up @@ -603,7 +603,7 @@ public LTextureBatch postCache(Cache cache, LColor color, float x, float y, floa
Canvas canvas = gl.getCanvas();
canvas.setTransform(display);
canvas.draw(cache._image, x, y);
_drawCallCount++;
GraphicsDrawCall.add(1);
}
return this;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public void clearDrawCall() {
}

public void flush() {

this.drawCallCount++;
}

public void end() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ public void end() {
super.end();
lastTexId = -1;
curTexId = -1;
drawCallCount = -1;
}

public int getDrawCallCount() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,6 @@ public void addQuad(int tint, float m00, float m01, float m10, float m11, float
meshData.texture = getCurrentTexture();
meshObject.setMesh(meshData);
meshObject.paint(tint, m00, m01, m10, m11, tx, ty, left, top, right, bottom, sl, st, sr, sb);
this.drawCallCount++;
}

@Override
Expand Down
6 changes: 3 additions & 3 deletions Java/Loon-Neo/src/loon/Display.java
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ public void close() {
private LSetting _setting;

private int _displayTop;

protected boolean showLogo = false, initDrawConfig = false;

private boolean logDisplayCreated = false;
Expand Down Expand Up @@ -496,8 +496,8 @@ protected void draw(LTimerContext clock) {
_glEx.restoreTx();
_glEx.clearFrame();
_process.resetTouch();
GraphicsDrawCall.clear();
}

}

private void onFrame() {
Expand Down Expand Up @@ -611,7 +611,7 @@ private final void drawDebug(final GLEx gl, final LSetting setting, final long d

displayMessage.setLength(0);
displayMessage.append(DRAWCALL_STR);
displayMessage.append(gl.getDrawCallCount());
displayMessage.append(GraphicsDrawCall.getCount() + gl.getDrawCallCount());

displayDrawCall = displayMessage.toString();

Expand Down
39 changes: 39 additions & 0 deletions Java/Loon-Neo/src/loon/GraphicsDrawCall.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/**
* Copyright 2008 - 2019 The Loon Game Engine Authors
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*
* @project loon
* @author cping
* @email:[email protected]
* @version 0.5
*/
package loon;

public class GraphicsDrawCall {

private static int GLOBAL_COUNT;

public static void clear() {
GLOBAL_COUNT = 0;
}

public static void add(int count) {
GLOBAL_COUNT += count;
}

public static int getCount() {
return GLOBAL_COUNT;
}

}
9 changes: 3 additions & 6 deletions Java/Loon-Neo/src/loon/LTextureBatch.java
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,6 @@ public LTextureBatch draw(float[] vertices, int offset, int length) {
offset += vertexCount;
vertexIdx += vertexCount;
}
drawCallCount++;
return this;
}

Expand Down Expand Up @@ -478,6 +477,8 @@ public LTextureBatch submit(BlendState state) {
mesh.reset(name, expandVertices.length());
}
GLUtils.setBlendMode(gl, old);
drawCallCount++;
GraphicsDrawCall.add(drawCallCount);
}
return this;
}
Expand Down Expand Up @@ -610,6 +611,7 @@ private LTextureBatch commit(Matrix4 view, Cache cache, LColor baseColor, BlendS
globalShader.end();
LSystem.mainBeginDraw();
runningCache = true;
GraphicsDrawCall.add(1);
return this;
}

Expand Down Expand Up @@ -741,7 +743,6 @@ public LTextureBatch draw(LColor[] colors, float x, float y, float width, float
glTexCoord2f(widthRatio, yOff);

}
drawCallCount++;
return this;
}

Expand Down Expand Up @@ -776,7 +777,6 @@ public LTextureBatch drawQuad(float drawX, float drawY, float c1, float drawX2,
glVertex2f(drawX + drawWidth, drawY);
glColor4f(c4);
glTexCoord2f(textureSrcX + renderWidth, textureSrcY);
drawCallCount++;
return this;
}

Expand Down Expand Up @@ -1019,7 +1019,6 @@ public LTextureBatch draw(LColor[] colors, float x, float y, float originX, floa
glColor4f(colors[LTexture.TOP_RIGHT]);
glTexCoord2f(widthRatio, yOff);
}
drawCallCount++;
return this;
}

Expand Down Expand Up @@ -1082,7 +1081,6 @@ public LTextureBatch draw(LColor[] colors, float x, float y, float width, float
glColor4f(colors[LTexture.TOP_RIGHT]);
glTexCoord2f(widthRatio, yOff);
}
drawCallCount++;
return this;
}

Expand Down Expand Up @@ -1148,7 +1146,6 @@ public LTextureBatch draw(short[] indexArray, float[] vertexArray, float[] uvArr
glTexCoord2f(uvArray[idx], uvArray[idx + 1]);
}
}
drawCallCount++;
return this;
}

Expand Down
12 changes: 3 additions & 9 deletions Java/Loon-Neo/src/loon/action/sprite/SpriteBatch.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
*/
package loon.action.sprite;

import loon.GraphicsDrawCall;
import loon.LGame;
import loon.LSysException;
import loon.LSystem;
Expand Down Expand Up @@ -499,6 +500,8 @@ public synchronized void submit(BlendState state) {
if (!lockSubmit) {
idx = 0;
}
this.drawCallCount++;
GraphicsDrawCall.add(drawCallCount);
}
}

Expand Down Expand Up @@ -1112,7 +1115,6 @@ public void draw(LTexture texture, float x, float y, float originX, float origin
expandVertices.setVertice(idx++, v);

this.idx = idx;
this.drawCallCount++;
}

public void draw(LTexture texture, float x, float y, float width, float height, float rotation, LColor c) {
Expand Down Expand Up @@ -1255,7 +1257,6 @@ public void draw(LTexture texture, float x, float y, float width, float height,
expandVertices.setVertice(idx++, v);

this.idx = idx;
this.drawCallCount++;
}

public void draw(LTexture texture, Vector2f pos, RectBox srcBox, LColor c) {
Expand Down Expand Up @@ -1321,7 +1322,6 @@ public void draw(LTexture texture, float x, float y, float srcX, float srcY, flo
expandVertices.setVertice(idx++, v);

this.idx = idx;
this.drawCallCount++;
}

public void draw(LTexture texture, float x, float y) {
Expand Down Expand Up @@ -1395,7 +1395,6 @@ public void draw(LTexture texture, float x, float y, float width, float height)
expandVertices.setVertice(idx++, v);

this.idx = idx;
this.drawCallCount++;
}

public void draw(LTexture texture, float[] spriteVertices, int offset, int length) {
Expand All @@ -1421,7 +1420,6 @@ public void draw(LTexture texture, float[] spriteVertices, int offset, int lengt
offset += vertexCount;
idx += vertexCount;
}
this.drawCallCount++;
}

public void draw(LTextureRegion region, float x, float y, float rotation) {
Expand Down Expand Up @@ -1476,7 +1474,6 @@ public void draw(LTextureRegion region, float x, float y, float width, float hei
expandVertices.setVertice(idx++, v);

this.idx = idx;
this.drawCallCount++;
}

public void draw(LTextureRegion region, float x, float y, float originX, float originY, float width, float height,
Expand Down Expand Up @@ -1588,7 +1585,6 @@ public void draw(LTextureRegion region, float x, float y, float originX, float o
expandVertices.setVertice(idx++, v);

this.idx = idx;
this.drawCallCount++;
}

@Override
Expand Down Expand Up @@ -1642,7 +1638,6 @@ private void quad(LTexture texture, float x1, float y1, float c1, float x2, floa
expandVertices.setVertice(idx++, v);

this.idx = idx;
this.drawCallCount++;
}

public void draw(LTextureRegion region, float x, float y, float originX, float originY, float width, float height,
Expand Down Expand Up @@ -1770,7 +1765,6 @@ public void draw(LTextureRegion region, float x, float y, float originX, float o
expandVertices.setVertice(idx++, v4);

this.idx = idx;
this.drawCallCount++;
}

public void drawPoint(int x, int y) {
Expand Down
2 changes: 1 addition & 1 deletion Java/Loon-Neo/src/loon/opengl/GLBase.java
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public void clearDrawCall() {
}

public void flush() {

this.drawCallCount++;
}

public void end() {
Expand Down
2 changes: 0 additions & 2 deletions Java/Loon-Neo/src/loon/opengl/TrilateralBatch.java
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,6 @@ public void addQuad(int tint, float m00, float m01, float m10, float m11, float
if (lastTexId != curTexId) {
flush();
}
this.drawCallCount++;
}

@Override
Expand Down Expand Up @@ -216,7 +215,6 @@ public void quad(float m00, float m01, float m10, float m11, float tx, float ty,
if (lastTexId != curTexId) {
flush();
}
this.drawCallCount++;
}

@Override
Expand Down
Binary file modified Java/loon-core-0.5-source.jar
Binary file not shown.
Binary file modified Java/loon-core-0.5.jar
Binary file not shown.
Binary file modified Java/loon-lite-core-0.5-source.jar
Binary file not shown.
Binary file modified Java/loon-lite-core-0.5.jar
Binary file not shown.

0 comments on commit 1bf3b6f

Please sign in to comment.