Skip to content

Commit

Permalink
add bitmap_deinit
Browse files Browse the repository at this point in the history
  • Loading branch information
xianjimli committed Nov 29, 2024
1 parent 05f494a commit 7486561
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 2 deletions.
3 changes: 3 additions & 0 deletions docs/changes.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# 最新动态

2024/11/29
* 增加函数 bitmap_deinit

2024/11/28
* 增加函数 bitmap\_set\_dirty/bitmap\_is\_dirty
* 重构bitmap,用bitmap\_init\_ex 实现bitmap\_create\_ex
Expand Down
16 changes: 14 additions & 2 deletions src/base/bitmap.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ ret_t bitmap_destroy_with_self(bitmap_t* bitmap) {
return bitmap_destroy(bitmap);
}

ret_t bitmap_destroy(bitmap_t* bitmap) {
ret_t bitmap_deinit(bitmap_t* bitmap) {
return_value_if_fail(bitmap != NULL, RET_BAD_PARAMS);

if (bitmap->specific_destroy != NULL) {
Expand All @@ -67,14 +67,26 @@ ret_t bitmap_destroy(bitmap_t* bitmap) {

if (bitmap->should_free_handle) {
memset(bitmap, 0x00, sizeof(bitmap_t));
TKMEM_FREE(bitmap);
bitmap->should_free_handle = TRUE;
} else {
memset(bitmap, 0x00, sizeof(bitmap_t));
}

return RET_OK;
}

ret_t bitmap_destroy(bitmap_t* bitmap) {
return_value_if_fail(bitmap != NULL, RET_BAD_PARAMS);

bitmap_deinit(bitmap);
if (bitmap->should_free_handle) {
bitmap->should_free_handle = FALSE;
TKMEM_FREE(bitmap);
}

return RET_OK;
}

#include "base/pixel_pack_unpack.h"

uint32_t bitmap_get_bpp_of_format(bitmap_format_t format) {
Expand Down
9 changes: 9 additions & 0 deletions src/base/bitmap.h
Original file line number Diff line number Diff line change
Expand Up @@ -377,6 +377,15 @@ ret_t bitmap_mono_dump(const uint8_t* buff, uint32_t w, uint32_t h);
*/
ret_t bitmap_destroy_with_self(bitmap_t* bitmap);

/**
* @method bitmap_deinit
* 反初始化图片。
* @annotation ["deconstructor"]
* @param {bitmap_t*} bitmap bitmap对象。
* @return {ret_t} 返回RET_OK表示成功,否则表示失败。
*/
ret_t bitmap_deinit(bitmap_t* bitmap);

/**
* @method bitmap_destroy
* 销毁图片。
Expand Down

0 comments on commit 7486561

Please sign in to comment.