Skip to content

Commit

Permalink
Add performance timing to GL canvas renderer
Browse files Browse the repository at this point in the history
To figure out potential slowness there.
  • Loading branch information
askmeaboutlo0m committed Aug 6, 2024
1 parent 55e0349 commit cebeacf
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion src/desktop/view/glcanvas.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,14 @@
#include "desktop/view/canvascontroller.h"
#include "desktop/view/canvasscene.h"
#include "libclient/canvas/tilecache.h"
#include "libclient/drawdance/perf.h"
#include <QMetaEnum>
#include <QOpenGLFunctions>
#include <QPaintEvent>
#include <QPainter>

#define DP_PERF_CONTEXT "glcanvas"

Q_LOGGING_CATEGORY(lcDpGlCanvas, "net.drawpile.view.canvas.gl", QtWarningMsg)

namespace view {
Expand Down Expand Up @@ -752,6 +755,7 @@ void main()
void
renderCanvasDirtyTextures(QOpenGLFunctions *f, canvas::TileCache &tileCache)
{
DP_PERF_SCOPE("paint_gl:canvas_dirty:textures");
qCDebug(lcDpGlCanvas, "renderCanvasDirtyTexture");
setUpCanvasShader(f);
updateCanvasTextureFilter(f);
Expand All @@ -773,6 +777,7 @@ void main()

void renderCanvasDirty(QOpenGLFunctions *f)
{
DP_PERF_SCOPE("paint_gl:canvas_dirty");
// The loop is necessary because the canvas size may change
// again while we're refreshing the tile cache visible area.
while(true) {
Expand All @@ -796,6 +801,7 @@ void main()

void renderCanvasClean(QOpenGLFunctions *f)
{
DP_PERF_SCOPE("paint_gl:canvas_clean");
setUpCanvasShader(f);
updateCanvasTextureFilter(f);
int textureCount = canvasTextures.size();
Expand Down Expand Up @@ -823,6 +829,7 @@ void main()

void renderOutline(QOpenGLFunctions *f, qreal dpr)
{
DP_PERF_SCOPE("paint_gl:outline");
// Called after renderCanvas, assumes vertex attribute 0 is enabled.
f->glEnable(GL_BLEND);
f->glBlendFuncSeparate(GL_ONE, GL_SRC_COLOR, GL_ONE, GL_ONE);
Expand Down Expand Up @@ -862,6 +869,12 @@ void main()
f->glBlendEquation(GL_FUNC_ADD);
}

void renderScene(QPainter &painter)
{
DP_PERF_SCOPE("paint_gl:scene");
controller->scene()->render(&painter);
}

CanvasController *controller;
QSize viewSize;
QColor checkerColor1;
Expand Down Expand Up @@ -1122,6 +1135,7 @@ void GlCanvas::paintGL()
{
qCDebug(lcDpGlCanvas, "paintGL");
if(!d->viewSize.isEmpty()) {
DP_PERF_SCOPE("paint_gl");
QPainter painter(this);
painter.beginNativePainting();

Expand All @@ -1144,7 +1158,8 @@ void GlCanvas::paintGL()
}

painter.endNativePainting();
d->controller->scene()->render(&painter);

d->renderScene(painter);
}
}

Expand Down

0 comments on commit cebeacf

Please sign in to comment.