mirror of
https://github.com/JetBrains/JetBrainsRuntime.git
synced 2026-01-10 10:31:39 +01:00
JBR-7040 implemented FPS counter on D3D
This commit is contained in:
committed by
Maxim Kartashev
parent
0910d05156
commit
7fd007bd08
@@ -168,6 +168,9 @@ public final class D3DRenderQueue extends RenderQueue {
|
||||
refSet.clear();
|
||||
}
|
||||
|
||||
public static native int getFramePresentedStatus();
|
||||
public static native int setPresentStatistic(int status);
|
||||
|
||||
private class QueueFlusher implements Runnable {
|
||||
private static volatile boolean needsFlush;
|
||||
|
||||
|
||||
@@ -42,6 +42,7 @@ import java.awt.image.DirectColorModel;
|
||||
import java.awt.image.Raster;
|
||||
import java.awt.image.SampleModel;
|
||||
import java.awt.image.SinglePixelPackedSampleModel;
|
||||
import sun.awt.AWTAccessor;
|
||||
import sun.awt.SunHints;
|
||||
import sun.awt.image.DataBufferNative;
|
||||
import sun.awt.image.PixelConverter;
|
||||
@@ -183,6 +184,7 @@ public class D3DSurfaceData extends SurfaceData implements AccelSurface {
|
||||
private VSyncType syncType;
|
||||
private int backBuffersNum;
|
||||
private Timer resizeTimer = null;
|
||||
private boolean frameStatisticEnabled = false;
|
||||
|
||||
private WritableRasterNative wrn;
|
||||
|
||||
@@ -262,6 +264,9 @@ public class D3DSurfaceData extends SurfaceData implements AccelSurface {
|
||||
initSurface();
|
||||
}
|
||||
setBlitProxyCache(gc.getSurfaceDataProxyCache());
|
||||
|
||||
frameStatisticEnabled = AWTAccessor.getWindowAccessor().countersEnabled(null);
|
||||
D3DRenderQueue.setPresentStatistic(frameStatisticEnabled ? 1 : 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -821,6 +826,19 @@ public class D3DSurfaceData extends SurfaceData implements AccelSurface {
|
||||
} finally {
|
||||
rq.unlock();
|
||||
}
|
||||
|
||||
if (sd.frameStatisticEnabled) {
|
||||
if (sd.getPeer().getTarget() instanceof Window window) {
|
||||
switch (D3DRenderQueue.getFramePresentedStatus()) {
|
||||
case 1:
|
||||
AWTAccessor.getWindowAccessor().bumpCounter(window, "java2d.native.framesPresentRequested");
|
||||
break;
|
||||
case 0:
|
||||
default:
|
||||
AWTAccessor.getWindowAccessor().bumpCounter(window, "java2d.native.framesPresentFailed");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void replaceSurfaceDataDelayed() {
|
||||
|
||||
@@ -50,6 +50,8 @@ BOOL DWMIsCompositionEnabled();
|
||||
static D3DContext *d3dc = NULL;
|
||||
static D3DSDOps *dstOps = NULL;
|
||||
static BOOL bLostDevices = FALSE;
|
||||
static int lastFramePresented = 0;
|
||||
static BOOL enablePresentStatistic = FALSE;
|
||||
|
||||
typedef struct {
|
||||
byte *buffer;
|
||||
@@ -165,6 +167,13 @@ D3DRQ_SwapBuffers(D3DPipelineManager *pMgr, D3DSDOps *d3dsdo,
|
||||
}
|
||||
|
||||
res = pSwapChain->Present(pSrcRect, pDstRect, 0, NULL, 0);
|
||||
if (enablePresentStatistic) {
|
||||
if (FAILED(res)) {
|
||||
lastFramePresented = 0;
|
||||
} else {
|
||||
lastFramePresented = 1;
|
||||
}
|
||||
}
|
||||
res = D3DRQ_MarkLostIfNeeded(res, d3dsdo);
|
||||
|
||||
return res;
|
||||
@@ -200,6 +209,16 @@ D3DRQ_MarkLostIfNeeded(HRESULT res, D3DSDOps *d3dops)
|
||||
|
||||
extern "C" {
|
||||
|
||||
JNIEXPORT BOOL JNICALL
|
||||
Java_sun_java2d_d3d_D3DRenderQueue_getFramePresentedStatus(JNIEnv *env, jobject obj) {
|
||||
return lastFramePresented;
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL
|
||||
Java_sun_java2d_d3d_D3DRenderQueue_setPresentStatistic(JNIEnv *env, jobject obj, jint enablePresentStatisticStatus) {
|
||||
enablePresentStatistic = enablePresentStatisticStatus;
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL
|
||||
Java_sun_java2d_d3d_D3DRenderQueue_flushBuffer
|
||||
(JNIEnv *env, jobject d3dr, jlong buf, jint limit)
|
||||
|
||||
Reference in New Issue
Block a user