switched blitbuffer to 4bpp (from 8bpp alpha + 8bpp gray)

this should allow to cache more, bigger pixmaps. We'll need this for
zoomed-in pages.
pull/2/merge
HW 13 years ago
parent 13fc5cefbb
commit c2dd2d9897

@ -21,7 +21,7 @@
static int newBlitBuffer(lua_State *L) { static int newBlitBuffer(lua_State *L) {
int w = luaL_checkint(L, 1); int w = luaL_checkint(L, 1);
int h = luaL_checkint(L, 2); int h = luaL_checkint(L, 2);
BlitBuffer *bb = (BlitBuffer*) lua_newuserdata(L, sizeof(BlitBuffer) + (w * h * BLITBUFFER_BYTESPP) - 1); BlitBuffer *bb = (BlitBuffer*) lua_newuserdata(L, sizeof(BlitBuffer) + (w * h / 2) - 1);
luaL_getmetatable(L, "blitbuffer"); luaL_getmetatable(L, "blitbuffer");
lua_setmetatable(L, -2); lua_setmetatable(L, -2);

@ -28,7 +28,6 @@ typedef struct BlitBuffer {
int h; int h;
uint8_t data[1]; uint8_t data[1];
} BlitBuffer; } BlitBuffer;
#define BLITBUFFER_BYTESPP 2
int luaopen_blitbuffer(lua_State *L); int luaopen_blitbuffer(lua_State *L);

@ -126,16 +126,8 @@ static int blitFullToFrameBuffer(lua_State *L) {
return luaL_error(L, "blitbuffer size must be framebuffer size!"); return luaL_error(L, "blitbuffer size must be framebuffer size!");
} }
uint8_t *fbptr = (uint8_t*)fb->data; memcpy(fb->data, bb->data, bb->w * bb->h / 2);
uint32_t *bbptr = (uint32_t*)bb->data;
int c = fb->vinfo.xres * fb->vinfo.yres / 2;
while(c--) {
*fbptr = (((*bbptr & 0x00F00000) >> 20) | (*bbptr & 0x000000F0)) ^ 0xFF;
fbptr++;
bbptr++;
}
return 0; return 0;
} }
@ -177,14 +169,12 @@ static int blitToFrameBuffer(lua_State *L) {
uint8_t *fbptr = (uint8_t*)(fb->data + uint8_t *fbptr = (uint8_t*)(fb->data +
ydest * fb->finfo.line_length + ydest * fb->finfo.line_length +
xdest / 2); xdest / 2);
uint32_t *bbptr = (uint32_t*)(bb->data + uint8_t *bbptr = (uint32_t*)(bb->data +
yoffs * bb->w * BLITBUFFER_BYTESPP + yoffs * bb->w / 2 +
xoffs * BLITBUFFER_BYTESPP); xoffs / 2 );
for(y = 0; y < h; y++) { for(y = 0; y < h; y++) {
for(x = 0; x < w; x++) { memcpy(fbptr, bbptr, w);
fbptr[x] = (((bbptr[x] & 0x00F00000) >> 20) | (bbptr[x] & 0x000000F0)) ^ 0xFF;
}
fbptr += fb->finfo.line_length; fbptr += fb->finfo.line_length;
bbptr += (bb->w / 2); bbptr += (bb->w / 2);
} }

22
pdf.c

@ -227,7 +227,7 @@ static int drawPage(lua_State *L) {
rect.y0 = luaL_checkint(L, 5); rect.y0 = luaL_checkint(L, 5);
rect.x1 = rect.x0 + bb->w; rect.x1 = rect.x0 + bb->w;
rect.y1 = rect.y0 + bb->h; rect.y1 = rect.y0 + bb->h;
pix = fz_new_pixmap_with_rect_and_data(fz_device_gray, rect, bb->data); pix = fz_new_pixmap_with_rect(fz_device_gray, rect);
fz_clear_pixmap_with_color(pix, 0xff); fz_clear_pixmap_with_color(pix, 0xff);
ctm = fz_translate(-page->page->mediabox.x0, -page->page->mediabox.y1); ctm = fz_translate(-page->page->mediabox.x0, -page->page->mediabox.y1);
@ -235,10 +235,10 @@ static int drawPage(lua_State *L) {
ctm = fz_concat(ctm, fz_rotate(page->page->rotate)); ctm = fz_concat(ctm, fz_rotate(page->page->rotate));
ctm = fz_concat(ctm, fz_rotate(dc->rotate)); ctm = fz_concat(ctm, fz_rotate(dc->rotate));
ctm = fz_concat(ctm, fz_translate(dc->offset_x, dc->offset_y)); ctm = fz_concat(ctm, fz_translate(dc->offset_x, dc->offset_y));
bbox = fz_round_rect(fz_transform_rect(ctm, page->page->mediabox));
dev = fz_new_draw_device(page->doc->glyphcache, pix); dev = fz_new_draw_device(page->doc->glyphcache, pix);
#ifdef USE_DISPLAY_LIST #ifdef USE_DISPLAY_LIST
#ifdef MUPDF_TRACE #ifdef MUPDF_TRACE
bbox = fz_round_rect(fz_transform_rect(ctm, page->page->mediabox));
fz_device *tdev; fz_device *tdev;
tdev = fz_new_trace_device(); tdev = fz_new_trace_device();
fz_execute_display_list(page->list, tdev, ctm, bbox); fz_execute_display_list(page->list, tdev, ctm, bbox);
@ -246,6 +246,12 @@ static int drawPage(lua_State *L) {
#endif #endif
fz_execute_display_list(page->list, dev, ctm, bbox); fz_execute_display_list(page->list, dev, ctm, bbox);
#else #else
#ifdef MUPDF_TRACE
fz_device *tdev;
tdev = fz_new_trace_device();
pdf_run_page(page->doc->xref, page->page, tdev, ctm);
fz_free_device(tdev);
#endif
pdf_run_page(page->doc->xref, page->page, dev, ctm); pdf_run_page(page->doc->xref, page->page, dev, ctm);
#endif #endif
if(dc->gamma >= 0.0) { if(dc->gamma >= 0.0) {
@ -253,6 +259,18 @@ static int drawPage(lua_State *L) {
} }
fz_free_device(dev); fz_free_device(dev);
uint8_t *bbptr = (uint8_t*)bb->data;
uint32_t *pmptr = (uint32_t*)pix->samples;
int c = bb->w * bb->h / 2;
while(c--) {
*bbptr = (((*pmptr & 0x00F00000) >> 20) | (*pmptr & 0x000000F0)) ^ 0xFF;
bbptr++;
pmptr++;
}
fz_drop_pixmap(pix); fz_drop_pixmap(pix);
return 0; return 0;

Loading…
Cancel
Save