aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrodri <rgl@antares-labs.eu>2020-06-14 13:02:55 +0000
committerrodri <rgl@antares-labs.eu>2020-06-14 13:02:55 +0000
commitd80ac9e9f103779aa61871c65d9939a3478c19a6 (patch)
tree91729b24d6cfdc3edf2fd38109ad7d552b6ba132
parent74ad09082610d27ef278fdbed892897f704168d6 (diff)
downloadpuppeteer-d80ac9e9f103779aa61871c65d9939a3478c19a6.tar.gz
puppeteer-d80ac9e9f103779aa61871c65d9939a3478c19a6.tar.bz2
puppeteer-d80ac9e9f103779aa61871c65d9939a3478c19a6.zip
fix layer image instantiation and canvas drawing rectangle.
-rw-r--r--layer.c11
-rw-r--r--main.c2
2 files changed, 11 insertions, 2 deletions
diff --git a/layer.c b/layer.c
index b8a2742..e3a389d 100644
--- a/layer.c
+++ b/layer.c
@@ -5,6 +5,15 @@
#include "dat.h"
#include "fns.h"
+static int
+alphachan(ulong chan)
+{
+ for(; chan; chan >>= 8)
+ if(TYPE(chan) == CAlpha)
+ return 1;
+ return 0;
+}
+
Layer*
newlayer(Canvas *c)
{
@@ -14,7 +23,7 @@ newlayer(Canvas *c)
l->p = Pt2(0,0,1);
l->bx = c->bx;
l->by = c->by;
- l->image = eallocimage(display, c->image->r, c->image->chan, 0, DNofill);
+ l->image = eallocimage(display, c->image->r, c->image->chan, 0, alphachan(c->image->chan)? DTransparent: DNofill);
l->prev = c->layers.prev;
l->next = &c->layers;
c->layers.prev->next = l;
diff --git a/main.c b/main.c
index 5cb401d..dad91f1 100644
--- a/main.c
+++ b/main.c
@@ -72,7 +72,7 @@ drawcanvas(Canvas *c)
for(l = c->layers.next; l != &c->layers; l = l->next)
drawlayer(c, l);
- draw(screen, screen->r, c->image, nil, ZP);
+ draw(screen, rectaddpt(c->image->r, toscreen(c->p)), c->image, nil, ZP);
}
void