fix graphic buffer for lcd reg

This commit is contained in:
lixianjing 2019-11-06 09:19:25 +08:00
parent 9a520f412e
commit 38d6c696ee
5 changed files with 23 additions and 17 deletions

View File

@ -393,7 +393,7 @@
#include "assets/default/inc/images/visible.data"
#include "assets/default/inc/images/warn.data"
#include "assets/default/inc/images/zh.data"
#endif/*WITH_STB_IMAGE*/
#endif /*WITH_STB_IMAGE*/
#ifdef WITH_VGCANVAS
#include "assets/default/inc/images/ball.bsvg"
#include "assets/default/inc/images/china.bsvg"
@ -401,13 +401,13 @@
#include "assets/default/inc/images/pointer.bsvg"
#include "assets/default/inc/images/pointer_1.bsvg"
#include "assets/default/inc/images/pointer_4.bsvg"
#endif/*WITH_VGCANVAS*/
#endif /*WITH_VGCANVAS*/
#if defined(WITH_TRUETYPE_FONT)
#include "assets/default/inc/fonts/default.res"
#else/*WITH_TRUETYPE_FONT*/
#else /*WITH_TRUETYPE_FONT*/
#include "assets/default/inc/fonts/default.data"
#endif/*WITH_TRUETYPE_FONT*/
#endif/*WITH_FS_RES*/
#endif /*WITH_TRUETYPE_FONT*/
#endif /*WITH_FS_RES*/
ret_t assets_init(void) {
assets_manager_t* am = assets_manager();
@ -693,7 +693,7 @@ ret_t assets_init(void) {
assets_manager_add(am, image_pointer);
assets_manager_add(am, image_pointer_1);
assets_manager_add(am, image_pointer_4);
#endif/*WITH_VGCANVAS*/
#endif /*WITH_VGCANVAS*/
#endif
tk_init_assets();

View File

@ -137,6 +137,7 @@ ret_t application_init() {
progress_bar = progress_bar_create(win, 260, 80, 20, 118);
widget_set_value(progress_bar, 40);
progress_bar_set_vertical(progress_bar, TRUE);
timer_add(on_timer, progress_bar, 500);
slider = slider_create(win, 230, 80, 20, 118);
widget_set_value(slider, 40);

View File

@ -1,4 +1,4 @@
/**
/**
* File: image_manager.c
* Author: AWTK Develop Team
* Brief: bitmap manager
@ -178,11 +178,11 @@ static ret_t image_manager_get_bitmap_impl(image_manager_t* imm, const char* nam
image->format = header->format;
image->name = res->name;
image->image_manager = imm;
image->buffer =
GRAPHIC_BUFFER_CREATE_WITH_DATA(header->data, header->w, header->h, header->format);
#if defined(WITH_NANOVG_GPU) || defined(WITH_NANOVG_SOFT)
image->buffer = GRAPHIC_BUFFER_CREATE_WITH_DATA(header->data, header->w, header->h,
(bitmap_format_t)(header->format));
image_manager_add(imm, name, image);
#endif
return RET_OK;
} else if (res->subtype != ASSET_TYPE_IMAGE_BSVG) {
ret_t ret = image_loader_load_image(res, image);

View File

@ -35,7 +35,8 @@ typedef struct _lcd_mem_graphic_buffer_cache_t {
static darray_t lcd_mem_graphic_buffer_cache;
static int lcd_mem_graphic_buffer_cache_cmp(const lcd_mem_graphic_buffer_cache_t* a, const lcd_mem_graphic_buffer_cache_t* b) {
static int lcd_mem_graphic_buffer_cache_cmp(const lcd_mem_graphic_buffer_cache_t* a,
const lcd_mem_graphic_buffer_cache_t* b) {
if (a->fb == b->fb) {
return 0;
}
@ -95,7 +96,8 @@ static bitmap_t* lcd_mem_init_online_fb(lcd_t* lcd, bitmap_t* fb, lcd_orientatio
return fb;
}
static inline graphic_buffer_t* lcd_mem_get_graphic_buffer(uint8_t* fb, uint32_t w, uint32_t h, bitmap_format_t format) {
static inline graphic_buffer_t* lcd_mem_get_graphic_buffer(uint8_t* fb, uint32_t w, uint32_t h,
bitmap_format_t format) {
graphic_buffer_t* gb = NULL;
lcd_mem_graphic_buffer_cache_t tmp;
lcd_mem_graphic_buffer_cache_t* cache = NULL;
@ -107,12 +109,11 @@ static inline graphic_buffer_t* lcd_mem_get_graphic_buffer(uint8_t* fb, uint32_t
if (cache == NULL) {
cache = (lcd_mem_graphic_buffer_cache_t*)TKMEM_ZALLOC(lcd_mem_graphic_buffer_cache_t);
gb = graphic_buffer_create_with_data(fb, w, h, format);
cache->fb = fb;
cache->gb = gb;
darray_push(&lcd_mem_graphic_buffer_cache, cache);
}
else {
} else {
gb = cache->gb;
}
return gb;
@ -428,7 +429,7 @@ static lcd_t* lcd_mem_create(wh_t w, wh_t h, bool_t alloc) {
system_info_set_lcd_type(info, base->type);
system_info_set_device_pixel_ratio(info, 1);
darray_init(&lcd_mem_graphic_buffer_cache, LCD_MEM_GRAPHIC_BUFFER_CACHE_MAX_NUMBER,
darray_init(&lcd_mem_graphic_buffer_cache, LCD_MEM_GRAPHIC_BUFFER_CACHE_MAX_NUMBER,
(tk_destroy_t)lcd_mem_graphic_buffer_cache_destroy,
(tk_compare_t)lcd_mem_graphic_buffer_cache_cmp);

View File

@ -77,6 +77,8 @@ static inline ret_t lcd_reg_image_copy(lcd_t* lcd, bitmap_t* img, rect_t* src, r
return_value_if_fail(src->w == dst->w && src->h == dst->h, RET_BAD_PARAMS);
data = (pixel_t*)bitmap_lock_buffer_for_read(img);
return_value_if_fail(data != NULL, RET_BAD_PARAMS);
if (reg->ffb != NULL) {
fragment_frame_buffer_image_copy(reg->ffb, img, src, dst);
} else {
@ -190,6 +192,7 @@ static ret_t lcd_reg_draw_image_bgr565(lcd_t* lcd, bitmap_t* img, rect_t* src, r
wh_t dh = dst->h;
const uint16_t* data = (uint16_t*)bitmap_lock_buffer_for_read(img);
return_value_if_fail(data != NULL, RET_BAD_PARAMS);
lcd_reg_set_window(lcd, x, y, x + dw - 1, y + dh - 1);
if (src->w == dst->w && src->h == dst->h) {
lcd_reg_image_copy(lcd, img, src, dst);
@ -231,6 +234,7 @@ static ret_t lcd_reg_draw_image_8888(lcd_t* lcd, bitmap_t* img, rect_t* src, rec
pixel_t fill_pixel = color_to_pixel(fill_color);
const color_t* data = (color_t*)bitmap_lock_buffer_for_read(img);
return_value_if_fail(data != NULL, RET_BAD_PARAMS);
lcd_reg_set_window(lcd, x, y, x + dw - 1, y + dh - 1);
if (src->w == dst->w && src->h == dst->h) {
const color_t* src_p = data + img->w * src->y + src->x;