From c2edca6d7bf25ab7598aa5e44f6ae03942c33df5 Mon Sep 17 00:00:00 2001 From: gazer Date: Fri, 29 Jan 2016 11:03:39 +0300 Subject: [PATCH] a little optimization --- src/dlangui/graphics/gldrawbuf.d | 5 +---- src/dlangui/platforms/sdl/sdlapp.d | 16 ++++++++-------- 2 files changed, 9 insertions(+), 12 deletions(-) diff --git a/src/dlangui/graphics/gldrawbuf.d b/src/dlangui/graphics/gldrawbuf.d index 2cca3ed5..73c28fa6 100644 --- a/src/dlangui/graphics/gldrawbuf.d +++ b/src/dlangui/graphics/gldrawbuf.d @@ -46,10 +46,8 @@ class GLDrawBuf : DrawBuf, GLConfigCallback { @property Scene scene() { return _scene; } this(int dx, int dy, bool framebuffer = false) { - _dx = dx; - _dy = dy; + resize(dx, dy); _framebuffer = framebuffer; - resetClipping(); } /// returns current width @@ -65,7 +63,6 @@ class GLDrawBuf : DrawBuf, GLConfigCallback { /// reserved for hardware-accelerated drawing - begins drawing batch override void beforeDrawing() { - resetClipping(); _alpha = 0; if (_scene !is null) { _scene.reset(); diff --git a/src/dlangui/platforms/sdl/sdlapp.d b/src/dlangui/platforms/sdl/sdlapp.d index 421a4375..a16e07db 100644 --- a/src/dlangui/platforms/sdl/sdlapp.d +++ b/src/dlangui/platforms/sdl/sdlapp.d @@ -422,12 +422,13 @@ class SDLWindow : Window { float b = ((_backgroundColor >> 0) & 255) / 255.0f; glClearColor(r, g, b, a); glClear(GL_COLOR_BUFFER_BIT); - GLDrawBuf buf = new GLDrawBuf(_dx, _dy, false); - buf.beforeDrawing(); - onDraw(buf); - buf.afterDrawing(); + if (!_drawbuf) + _drawbuf = new GLDrawBuf(_dx, _dy); + _drawbuf.resize(_dx, _dy); + _drawbuf.beforeDrawing(); + onDraw(_drawbuf); + _drawbuf.afterDrawing(); SDL_GL_SwapWindow(_win); - destroy(buf); } } else { // Select the color for drawing. @@ -441,10 +442,9 @@ class SDLWindow : Window { if (!_drawbuf) _drawbuf = new ColorDrawBuf(_dx, _dy); _drawbuf.resize(_dx, _dy); - _drawbuf.resetClipping(); _drawbuf.fill(_backgroundColor); onDraw(_drawbuf); - draw(_drawbuf); + draw(cast(ColorDrawBuf)_drawbuf); // Up until now everything was drawn behind the scenes. // This will show the new, red contents of the window. @@ -452,7 +452,7 @@ class SDLWindow : Window { } } - ColorDrawBuf _drawbuf; + DrawBuf _drawbuf; //bool _exposeSent; void processExpose() {