summaryrefslogtreecommitdiff
path: root/atari
diff options
context:
space:
mode:
authorOle Loots <ole@monochrom.net>2012-04-14 11:40:57 +0000
committerOle Loots <ole@monochrom.net>2012-04-14 11:40:57 +0000
commit4467766786d301308761fe7b1296a2a25de796ec (patch)
treede1744ed6a9059e83fd970a0c18298b40c6c216e /atari
parent3f262e4803ae4ceafcd872c5e5fc640c18f15f14 (diff)
downloadnetsurf-4467766786d301308761fe7b1296a2a25de796ec.tar.gz
netsurf-4467766786d301308761fe7b1296a2a25de796ec.tar.bz2
Fix bitmap creation - JPEG where always set to opaque = false, which lead to blitter checking all pixels for transparency in an loop.
Prepare for caching of converted bitmaps. svn path=/trunk/netsurf/; revision=13869
Diffstat (limited to 'atari')
-rwxr-xr-xatari/bitmap.c52
-rwxr-xr-xatari/bitmap.h1
2 files changed, 30 insertions, 23 deletions
diff --git a/atari/bitmap.c b/atari/bitmap.c
index e123546ab..3b3f58654 100755
--- a/atari/bitmap.c
+++ b/atari/bitmap.c
@@ -79,7 +79,7 @@ void * bitmap_create_ex( int w, int h, short bpp, int rowstride, unsigned int st
if (bitmap->pixdata != NULL) {
bitmap->width = w;
bitmap->height = h;
- bitmap->opaque = false;
+ bitmap->opaque = (state & BITMAP_OPAQUE) ? true : false;
bitmap->bpp = bpp;
bitmap->resized = NULL;
bitmap->rowstride = rowstride;
@@ -121,7 +121,6 @@ void * bitmap_realloc( int w, int h, short bpp, int rowstride, unsigned int stat
if( state & BITMAP_CLEAR ){
memset( bitmap->pixdata, 0x00, newsize + 128 );
}
-
bitmap->width = w;
bitmap->height = h;
bitmap->bpp = bpp;
@@ -240,7 +239,7 @@ void bitmap_destroy(void *bitmap)
if( bm->resized != NULL ) {
bitmap_destroy(bm->resized);
}
- if( bm->native.fd_addr )
+ if( bm->converted && ( bm->native.fd_addr != bm->pixdata ) )
free( bm->native.fd_addr );
free(bm->pixdata);
free(bm);
@@ -268,11 +267,18 @@ bool bitmap_save(void *bitmap, const char *path, unsigned flags)
void bitmap_modified(void *bitmap)
{
struct bitmap *bm = bitmap;
-
if( bm->resized != NULL ) {
bitmap_destroy( bm->resized );
bm->resized = NULL;
}
+ if( bm->converted ){
+ if( bm->pixdata != bm->native.fd_addr ){
+ free( bm->native.fd_addr );
+ }
+ bm->native.fd_addr = NULL;
+ bm->converted = false;
+ }
+
}
@@ -298,13 +304,13 @@ void bitmap_set_opaque(void *bitmap, bool opaque)
{
struct bitmap *bm = bitmap;
- if (bitmap == NULL) {
- LOG(("NULL bitmap!"));
- return;
- }
+ if (bitmap == NULL) {
+ LOG(("NULL bitmap!"));
+ return;
+ }
- LOG(("setting bitmap %p to %s", bm, opaque?"opaque":"transparent"));
- bm->opaque = opaque;
+ LOG(("setting bitmap %p to %s", bm, opaque?"opaque":"transparent"));
+ bm->opaque = opaque;
}
@@ -316,23 +322,23 @@ void bitmap_set_opaque(void *bitmap, bool opaque)
*/
bool bitmap_test_opaque(void *bitmap)
{
- int tst;
+ int tst;
struct bitmap *bm = bitmap;
- if (bitmap == NULL) {
- LOG(("NULL bitmap!"));
- return false;
- }
+ if (bitmap == NULL) {
+ LOG(("NULL bitmap!"));
+ return false;
+ }
- tst = bm->width * bm->height;
+ tst = bm->width * bm->height;
- while (tst-- > 0) {
- if (bm->pixdata[(tst << 2) + 3] != 0xff) {
- LOG(("bitmap %p has transparency",bm));
- return false;
- }
- }
- LOG(("bitmap %p is opaque", bm));
+ while (tst-- > 0) {
+ if (bm->pixdata[(tst << 2) + 3] != 0xff) {
+ LOG(("bitmap %p has transparency",bm));
+ return false;
+ }
+ }
+ LOG(("bitmap %p is opaque", bm));
return true;
}
diff --git a/atari/bitmap.h b/atari/bitmap.h
index f198db48e..f917f5560 100755
--- a/atari/bitmap.h
+++ b/atari/bitmap.h
@@ -32,6 +32,7 @@ struct bitmap {
size_t rowstride;
struct bitmap * resized;
MFDB native;
+ bool converted;
};
#define NS_BMP_DEFAULT_BPP 4