mirror of
https://github.com/koreader/koreader.git
synced 2025-08-10 00:52:38 +00:00
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.
This commit is contained in:
@@ -21,7 +21,7 @@
|
||||
static int newBlitBuffer(lua_State *L) {
|
||||
int w = luaL_checkint(L, 1);
|
||||
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");
|
||||
lua_setmetatable(L, -2);
|
||||
|
||||
|
||||
@@ -28,7 +28,6 @@ typedef struct BlitBuffer {
|
||||
int h;
|
||||
uint8_t data[1];
|
||||
} BlitBuffer;
|
||||
#define BLITBUFFER_BYTESPP 2
|
||||
|
||||
int luaopen_blitbuffer(lua_State *L);
|
||||
|
||||
|
||||
20
einkfb.c
20
einkfb.c
@@ -126,16 +126,8 @@ static int blitFullToFrameBuffer(lua_State *L) {
|
||||
return luaL_error(L, "blitbuffer size must be framebuffer size!");
|
||||
}
|
||||
|
||||
uint8_t *fbptr = (uint8_t*)fb->data;
|
||||
uint32_t *bbptr = (uint32_t*)bb->data;
|
||||
memcpy(fb->data, bb->data, bb->w * bb->h / 2);
|
||||
|
||||
int c = fb->vinfo.xres * fb->vinfo.yres / 2;
|
||||
|
||||
while(c--) {
|
||||
*fbptr = (((*bbptr & 0x00F00000) >> 20) | (*bbptr & 0x000000F0)) ^ 0xFF;
|
||||
fbptr++;
|
||||
bbptr++;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -177,14 +169,12 @@ static int blitToFrameBuffer(lua_State *L) {
|
||||
uint8_t *fbptr = (uint8_t*)(fb->data +
|
||||
ydest * fb->finfo.line_length +
|
||||
xdest / 2);
|
||||
uint32_t *bbptr = (uint32_t*)(bb->data +
|
||||
yoffs * bb->w * BLITBUFFER_BYTESPP +
|
||||
xoffs * BLITBUFFER_BYTESPP);
|
||||
uint8_t *bbptr = (uint32_t*)(bb->data +
|
||||
yoffs * bb->w / 2 +
|
||||
xoffs / 2 );
|
||||
|
||||
for(y = 0; y < h; y++) {
|
||||
for(x = 0; x < w; x++) {
|
||||
fbptr[x] = (((bbptr[x] & 0x00F00000) >> 20) | (bbptr[x] & 0x000000F0)) ^ 0xFF;
|
||||
}
|
||||
memcpy(fbptr, bbptr, w);
|
||||
fbptr += fb->finfo.line_length;
|
||||
bbptr += (bb->w / 2);
|
||||
}
|
||||
|
||||
22
pdf.c
22
pdf.c
@@ -227,7 +227,7 @@ static int drawPage(lua_State *L) {
|
||||
rect.y0 = luaL_checkint(L, 5);
|
||||
rect.x1 = rect.x0 + bb->w;
|
||||
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);
|
||||
|
||||
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(dc->rotate));
|
||||
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);
|
||||
#ifdef USE_DISPLAY_LIST
|
||||
#ifdef MUPDF_TRACE
|
||||
bbox = fz_round_rect(fz_transform_rect(ctm, page->page->mediabox));
|
||||
fz_device *tdev;
|
||||
tdev = fz_new_trace_device();
|
||||
fz_execute_display_list(page->list, tdev, ctm, bbox);
|
||||
@@ -246,6 +246,12 @@ static int drawPage(lua_State *L) {
|
||||
#endif
|
||||
fz_execute_display_list(page->list, dev, ctm, bbox);
|
||||
#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);
|
||||
#endif
|
||||
if(dc->gamma >= 0.0) {
|
||||
@@ -253,6 +259,18 @@ static int drawPage(lua_State *L) {
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
return 0;
|
||||
|
||||
Reference in New Issue
Block a user