Skip to content

Commit 7a4d5ee

Browse files
committed
Some optimizations
1 parent 2f2a14e commit 7a4d5ee

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

src/qt/qt_openglrenderer_pcem.cpp

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -770,7 +770,7 @@ OpenGLRendererPCem::OpenGLRendererPCem(QWidget *parent)
770770

771771
parentWidget = parent;
772772

773-
source.setRect(0, 0, 2048, 2048);
773+
source.setRect(0, 0, 100, 100);
774774
isInitialized = false;
775775
isFinalized = false;
776776
}
@@ -1075,11 +1075,18 @@ OpenGLRendererPCem::onBlit(int buf_idx, int x, int y, int w, int h)
10751075
destination.width() * devicePixelRatio(),
10761076
destination.height() * devicePixelRatio());
10771077
#endif
1078+
1079+
if (source.width() != w || source.height() != h) {
1080+
glw.glBindTexture(GL_TEXTURE_2D, scene_texture.id);
1081+
glw.glTexImage2D(GL_TEXTURE_2D, 0, (GLenum) QOpenGLTexture::RGBA8_UNorm, w, h, 0, (GLenum) QOpenGLTexture::BGRA, (GLenum) QOpenGLTexture::UInt32_RGBA8_Rev, NULL);
1082+
glw.glBindTexture(GL_TEXTURE_2D, 0);
1083+
}
1084+
10781085
source.setRect(x, y, w, h);
10791086

10801087
glw.glBindTexture(GL_TEXTURE_2D, scene_texture.id);
10811088
glw.glPixelStorei(GL_UNPACK_ROW_LENGTH, 2048);
1082-
glw.glTexSubImage2D(GL_TEXTURE_2D, 0, x, y, w, h, (GLenum) QOpenGLTexture::BGRA, (GLenum) QOpenGLTexture::UInt32_RGBA8_Rev, (const void *) ((uintptr_t) imagebufs[buf_idx].get() + (uintptr_t) (2048 * 4 * y + x * 4)));
1089+
glw.glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, w, h, (GLenum) QOpenGLTexture::BGRA, (GLenum) QOpenGLTexture::UInt32_RGBA8_Rev, (const void *) ((uintptr_t) imagebufs[buf_idx].get() + (uintptr_t) (2048 * 4 * y + x * 4)));
10831090
glw.glPixelStorei(GL_UNPACK_ROW_LENGTH, 0);
10841091
glw.glBindTexture(GL_TEXTURE_2D, 0);
10851092

@@ -1369,10 +1376,10 @@ OpenGLRendererPCem::render()
13691376
pass->state.tex_coords[7] = maxy;
13701377

13711378
// create input tex coords
1372-
minx = video_rect.x / 2048.f;
1373-
miny = video_rect.y / 2048.f;
1374-
maxx = (video_rect.x + video_rect.w) / (float) 2048.f;
1375-
maxy = (video_rect.y + video_rect.h) / (float) 2048.f;
1379+
minx = 0;
1380+
miny = 0;
1381+
maxx = 1;
1382+
maxy = 1;
13761383

13771384
GLfloat tex_coords[] = { minx, miny, minx, maxy, maxx, miny, maxx, maxy };
13781385

0 commit comments

Comments
 (0)