From c18090169d6bb49e877956701e77e8af338ed675 Mon Sep 17 00:00:00 2001 From: Bent Bisballe Nyeng Date: Mon, 9 Nov 2015 21:26:57 +0100 Subject: Refactor PixelBuffer, and remove unnecessary calls to setPixel and addPixel. --- plugingui/window.cc | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) (limited to 'plugingui/window.cc') diff --git a/plugingui/window.cc b/plugingui/window.cc index afbcb21..a7e220e 100644 --- a/plugingui/window.cc +++ b/plugingui/window.cc @@ -178,8 +178,20 @@ void GUI::Window::updateBuffer() std::vector::iterator pli = pl.begin(); while(pli != pl.end()) { PixelBufferAlpha *pb = *pli; - for(size_t x = 0; x < pb->width; x++) { - for(size_t y = 0; y < pb->height; y++) { + size_t updateWidth = pb->width; + size_t updateHeight = pb->height; + if(updateWidth > (wpixbuf.width - pb->x)) + { + updateWidth = (wpixbuf.width - pb->x); + } + + if(updateHeight > (wpixbuf.height - pb->y)) + { + updateHeight = (wpixbuf.height - pb->y); + } + + for(size_t x = 0; x < updateWidth; x++) { + for(size_t y = 0; y < updateHeight; y++) { unsigned char r,g,b,a; pb->pixel(x,y,&r,&g,&b,&a); wpixbuf.setPixel(x + pb->x, y + pb->y, r, g, b, a); -- cgit v1.2.3