summaryrefslogtreecommitdiff
path: root/plugingui/window.cc
diff options
context:
space:
mode:
authorBent Bisballe Nyeng <deva@aasimon.org>2015-11-09 21:26:57 +0100
committerBent Bisballe Nyeng <deva@aasimon.org>2015-11-09 21:26:57 +0100
commitc18090169d6bb49e877956701e77e8af338ed675 (patch)
tree7a18b46d809fc839acc56c4b0fd2e1938614513c /plugingui/window.cc
parent74ab9aea168bb5706e9c36aa6252f366926f5b41 (diff)
Refactor PixelBuffer, and remove unnecessary calls to setPixel and addPixel.
Diffstat (limited to 'plugingui/window.cc')
-rw-r--r--plugingui/window.cc16
1 files changed, 14 insertions, 2 deletions
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<PixelBufferAlpha *>::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);