Guest User

Untitled

a guest
Sep 8th, 2011
91
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. diff --git a/apps/gui/skin_engine/skin_backdrops.c b/apps/gui/skin_engine/skin_backdrops.c
  2. index 12950a6..e195ec6 100644
  3. --- a/apps/gui/skin_engine/skin_backdrops.c
  4. +++ b/apps/gui/skin_engine/skin_backdrops.c
  5. @@ -22,11 +22,11 @@
  6. #include "config.h"
  7. #include <stdio.h>
  8. #include <stdlib.h>
  9. +#include "core_alloc.h"
  10. #include "string-extra.h"
  11. #include "settings.h"
  12. #include "wps_internals.h"
  13. #include "skin_engine.h"
  14. -#include "skin_buffer.h"
  15.  
  16. #if (LCD_DEPTH > 1) || (defined(HAVE_REMOTE_LCD) && (LCD_REMOTE_DEPTH > 1))
  17.  
  18. @@ -36,19 +36,51 @@ static struct skin_backdrop {
  19. char *buffer;
  20. enum screen_type screen;
  21. bool loaded;
  22. + int buflib_handle;
  23. } backdrops[NB_BDROPS];
  24.  
  25. #define NB_BDROPS SKINNABLE_SCREENS_COUNT*NB_SCREENS
  26. +int handle_being_loaded;
  27. +int current_lcd_backdrop[NB_SCREENS];
  28.  
  29. +int buflib_move_callback(int handle, void* current, void* new)
  30. +{
  31. + int i;
  32. + if (handle == handle_being_loaded)
  33. + return BUFLIB_CB_CANNOT_MOVE;
  34. + for (i=0; i<NB_BDROPS; i++)
  35. + {
  36. + if (backdrops[i].buffer == current)
  37. + {
  38. + backdrops[i].buffer = new;
  39. + break;
  40. + }
  41. + }
  42. + FOR_NB_SCREENS(i)
  43. + skin_backdrop_show(current_lcd_backdrop[i]);
  44. + return BUFLIB_CB_OK;
  45. +}
  46. +static struct buflib_callbacks buflib_ops = {buflib_move_callback, NULL};
  47. +static bool first_go = true;
  48. void skin_backdrop_init(void)
  49. {
  50. int i;
  51. + printf("backdrop_init\n");
  52. for (i=0; i<NB_BDROPS; i++)
  53. {
  54. + if (first_go)
  55. + backdrops[i].buflib_handle = -1;
  56. + else
  57. + skin_backdrop_unload(backdrops[i].buflib_handle);
  58. backdrops[i].name[0] = '\0';
  59. backdrops[i].buffer = NULL;
  60. backdrops[i].loaded = false;
  61. +
  62. }
  63. + first_go = false;
  64. + FOR_NB_SCREENS(i)
  65. + current_lcd_backdrop[i] = -1;
  66. + handle_being_loaded = -1;
  67. }
  68.  
  69. int skin_backdrop_assign(char* backdrop, char *bmpdir,
  70. @@ -117,10 +149,19 @@ bool skin_backdrops_preload(void)
  71. }
  72. if (*filename && *filename != '-')
  73. {
  74. - backdrops[i].buffer = (char*)skin_buffer_alloc(buf_size);
  75. - backdrops[i].loaded = backdrops[i].buffer &&
  76. - screens[screen].backdrop_load(filename, backdrops[i].buffer);
  77. - if (!backdrops[i].loaded)
  78. + backdrops[i].buflib_handle = core_alloc_ex(filename, buf_size, &buflib_ops);
  79. + if (backdrops[i].buflib_handle > 0)
  80. + {
  81. + backdrops[i].buffer = core_get_data(backdrops[i].buflib_handle);
  82. + printf("load2: %d %d\n", i, backdrops[i].buflib_handle);
  83. + handle_being_loaded = backdrops[i].buflib_handle;
  84. + backdrops[i].loaded =
  85. + screens[screen].backdrop_load(filename, backdrops[i].buffer);
  86. + handle_being_loaded = -1;
  87. + if (!backdrops[i].loaded)
  88. + retval = false;
  89. + }
  90. + else
  91. retval = false;
  92. }
  93. if (backdrops[i].name[0] == '-' && backdrops[i].loaded)
  94. @@ -147,7 +188,11 @@ void skin_backdrop_show(int backdrop_id)
  95.  
  96. void skin_backdrop_unload(int backdrop_id)
  97. {
  98. + printf("unload: %d %d\n", backdrop_id, backdrops[backdrop_id].buflib_handle);
  99. + if (backdrops[backdrop_id].buflib_handle > 0)
  100. + core_free(backdrops[backdrop_id].buflib_handle);
  101. backdrops[backdrop_id].buffer = NULL;
  102. + backdrops[backdrop_id].buflib_handle = -1;
  103. }
  104.  
  105. void skin_backdrop_load_setting(void)
  106. @@ -161,13 +206,22 @@ void skin_backdrop_load_setting(void)
  107. global_settings.backdrop_file[0] != '-')
  108. {
  109. if (!backdrops[i].buffer)
  110. - backdrops[i].buffer = (char*)skin_buffer_alloc(LCD_BACKDROP_BYTES);
  111. -
  112. - bool loaded = backdrops[i].buffer &&
  113. - screens[SCREEN_MAIN].backdrop_load(
  114. - global_settings.backdrop_file,
  115. - backdrops[i].buffer);
  116. - backdrops[i].name[2] = loaded ? '.' : '\0';
  117. + {
  118. + bool loaded;
  119. + backdrops[i].buflib_handle =
  120. + core_alloc_ex(global_settings.backdrop_file,
  121. + LCD_BACKDROP_BYTES, &buflib_ops);
  122. + printf("load1: %d %d\n", i, backdrops[i].buflib_handle);
  123. + if (backdrops[i].buflib_handle < 0)
  124. + return;
  125. + backdrops[i].buffer = core_get_data(backdrops[i].buflib_handle);
  126. + handle_being_loaded = backdrops[i].buflib_handle;
  127. + loaded = screens[SCREEN_MAIN].backdrop_load(
  128. + global_settings.backdrop_file,
  129. + backdrops[i].buffer);
  130. + handle_being_loaded = -1;
  131. + backdrops[i].name[2] = loaded ? '.' : '\0';
  132. + }
  133. return;
  134. }
  135. else
RAW Paste Data