Commit Graph

25 Commits (master)

Author SHA1 Message Date
rgl 3a79916c9b libmemdraw: remove inexistent build targets 2020-04-19 15:30:58 +02:00
cinap_lenrek a0acae173e libmemdraw: remove static Point p00 and use ZP instead 2019-03-09 17:36:19 +01:00
cinap_lenrek 5a724464d9 libmemdraw: handle memarc() phi == 0 and phi <= -360, keep alpha in bounds 2019-03-09 17:34:22 +01:00
cinap_lenrek 56611ced39 libmemdraw: get rid of kernel iprint() emulation 2017-04-29 21:13:48 +02:00
cinap_lenrek 9a5e55782d libmemdraw/libmemlayer: get rid of drawdebug prints 2017-04-29 21:10:28 +02:00
cinap_lenrek 28f4567ba6 libmemdraw: cleanup fillpoly(), remove unused fillcolor hack 2016-11-17 20:10:07 +01:00
cinap_lenrek b4db73795e libmemdraw: remove unused static drawbuf variables and ptrfn() declaration 2016-11-17 19:42:12 +01:00
cinap_lenrek 68571320fa libmemdraw: remove unused static variable from memimagedraw() 2016-05-29 18:23:42 +02:00
cinap_lenrek e725771b5d libdraw: use readn() to read headers and Fontchar array
the Fontchar array might be bigger than the i/o unit,
so we have to use readn() to properly read it.
2015-03-01 05:39:45 +01:00
cinap_lenrek 4235556c16 libdraw: check fontchar count in openmemsubfont() and readsubfont() 2015-02-24 03:30:21 +01:00
cinap_lenrek 9f880e595c libmemdraw: never point Buffer.alpha to nil (thanks mischief)
the boolcopy optimization doesnt doesnt use Buffer.alpha, tho
the debug function dumpbuf() still can dereference it. to keep
it simple, always have Buffer.alpha point to the channel or
&ones when not used.
2014-12-30 12:44:42 +01:00
mischief f188158f1c libmemdraw: fix fd leak in openmemsubfont and memory leak in freememsubfont 2014-12-28 22:46:39 -08:00
cinap_lenrek f899e55818 libmemdraw: fix byte ordering in memfillcolor()
memfillcolor() used to write longs in host byte
order which is wrong. have to always use little
endian.

to simplify, moved little endian conversion into
memsetl() and memsets() avoiding code duplication.
2014-09-19 17:49:48 +02:00
cinap_lenrek fdf3883ce4 libmemdraw: update drawtest to use same rounding in alpha calculation as libmemdraw 2014-09-14 17:03:56 +02:00
cinap_lenrek 96a94c3891 libmemdraw: improve readbyte() and writebyte() routines
remove unused memsetb() routine.

replace foo ? 1 : 0 with foo != 0

avoid double calculation of rgb components in readbyte()

handle byte aligned color components in writebyte()
which lets us avoid the read-modify-write and the shifting.
surprisingly, the branches in the loop are way less important
than avoiding the memory access.

this change makes ganes/snes playable at -3 scaling.
2014-04-12 21:59:52 +02:00
cinap_lenrek 9a52340313 libmemdraw: apply erik quanstros fix for sign preserving in byteaddr() 2014-02-01 09:54:09 +01:00
cinap_lenrek 71dbddef16 draw: fix drawing of replicated source image on memlayer with a clip rectangle
when a replicated source image with a clipr with clipr.min > Pt(0, 0),
drawclip() would properly translate the src->clipr on the dstr
but then clamp the source rectangle back on src->r.

while traversing down multiple layers, this would cause the translation to
be applied multiple times to the dst rectangle giving the wrong image result.

this change adds a new drawclipnorepl() function that avoids the clamping
of source and mask rectangles to src->r and mask->r. this is then used in
libmemlayer.

the final memimagedraw() call will call drawclip() which will do the final
claming.

a testcase is provided:

#include <u.h>
#include <libc.h>
#include <draw.h>

Image *blue;
Image *red;

void
main(int, char *argv[])
{
	Image *i;

	if(initdraw(nil, nil, argv[0]) < 0)
		sysfatal("initdraw: %r");
	i = allocimage(display, screen->r, screen->chan, 1, DWhite);

	red = allocimage(display, Rect(0,0,1,1), screen->chan, 1, DRed);
	blue = allocimage(display, Rect(0,0,1,1), screen->chan, 1, DPaleblue);
	replclipr(red, 1, Rect(10, 10, 110, 110));
	replclipr(blue, 1, Rect(11, 11, 111, 111));

	/* draw on non-layer, works correctly */
	draw(i, i->r, red, nil, ZP);
	draw(i, i->r, blue, nil, ZP);
	draw(screen, screen->r, i, nil, i->r.min);
	flushimage(display, 1);

	/* draw on (screen) layer is too far to the right */
	draw(screen, screen->r, red, nil, ZP);
	draw(screen, screen->r, blue, nil, ZP);
	flushimage(display, 1);

	for(;;){
		sleep(1000);
	}
}
2013-12-09 03:35:01 +01:00
cinap_lenrek d56a6fadc5 libmemdraw: change memimageinit() to return integer error (for kernel), minor cleanups 2013-11-12 21:42:05 +01:00
cinap_lenrek 202be57bb9 draw: add badrect() function to reject zero, negative size or orverly huge rectangles
not checking the rectangle dimensions causes integer overflows
and memory corruption. adding a new badrect() function that checks
for these cases.
2013-06-16 19:01:46 +02:00
cinap_lenrek 56073b7381 libmemdraw: fix drawing to color mapped with alpha chan (m8a8) 2013-06-16 00:39:31 +02:00
cinap_lenrek f6e73a6a22 libdraw: reduce memory for writeimage/writememimage 2011-09-04 04:38:08 +02:00
cinap_lenrek b5bbc62dda libdraw: fix unloadimage() for wide images, libmemdraw: work arround width limit by outputting uncompressed image in writememimage() if compressed blocksize exceeds chunk limit 2011-09-04 23:51:14 +02:00
cinap_lenrek 632defb656 vesa-changes 2011-04-11 20:56:59 +00:00
Taru Karttunen a9060cc06b Import sources from 2011-03-30 iso image - lib 2011-03-30 19:35:09 +03:00
Taru Karttunen e5888a1ffd Import sources from 2011-03-30 iso image 2011-03-30 15:46:40 +03:00