Guest User

Untitled

a guest
Sep 8th, 2011
73
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..5002d8a 100644
  3. --- a/apps/gui/skin_engine/skin_backdrops.c
  4. +++ b/apps/gui/skin_engine/skin_backdrops.c
  5. @@ -22,6 +22,7 @@
  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. @@ -36,9 +37,31 @@ static struct skin_backdrop {
  14. char *buffer;
  15. enum screen_type screen;
  16. bool loaded;
  17. + int buflib_handle;
  18. } backdrops[NB_BDROPS];
  19.  
  20. #define NB_BDROPS SKINNABLE_SCREENS_COUNT*NB_SCREENS
  21. +int handle_being_loaded;
  22. +int current_lcd_backdrop[NB_SCREENS];
  23. +
  24. +int buflib_move_callback(int handle, void* current, void* new)
  25. +{
  26. + int i;
  27. + if (handle == handle_being_loaded)
  28. + return BUFLIB_CB_CANNOT_MOVE;
  29. + for (i=0; i<NB_BDROPS; i++)
  30. + {
  31. + if (backdrops[i].buffer == current)
  32. + {
  33. + backdrops[i].buffer = new;
  34. + break;
  35. + }
  36. + }
  37. + FOR_NB_SCREENS(i)
  38. + skin_backdrop_show(current_lcd_backdrop[i]);
  39. + return BUFLIB_CB_OK;
  40. +}
  41. +static struct buflib_callbacks buflib_ops = {buflib_move_callback, NULL};
  42.  
  43. void skin_backdrop_init(void)
  44. {
  45. @@ -49,6 +72,9 @@ void skin_backdrop_init(void)
  46. backdrops[i].buffer = NULL;
  47. backdrops[i].loaded = false;
  48. }
  49. + FOR_NB_SCREENS(i)
  50. + current_lcd_backdrop[i] = -1;
  51. + handle_being_loaded = -1;
  52. }
  53.  
  54. int skin_backdrop_assign(char* backdrop, char *bmpdir,
  55. @@ -117,10 +143,18 @@ bool skin_backdrops_preload(void)
  56. }
  57. if (*filename && *filename != '-')
  58. {
  59. - backdrops[i].buffer = (char*)skin_buffer_alloc(buf_size);
  60. - backdrops[i].loaded = backdrops[i].buffer &&
  61. - screens[screen].backdrop_load(filename, backdrops[i].buffer);
  62. - if (!backdrops[i].loaded)
  63. + backdrops[i].buflib_handle = core_alloc_ex(filename, buf_size, &buflib_ops);
  64. + if (backdrops[i].buflib_handle > 0)
  65. + {
  66. + backdrops[i].buffer = core_get_data(backdrops[i].buflib_handle);
  67. + handle_being_loaded = backdrops[i].buflib_handle;
  68. + backdrops[i].loaded =
  69. + screens[screen].backdrop_load(filename, backdrops[i].buffer);
  70. + handle_being_loaded = -1;
  71. + if (!backdrops[i].loaded)
  72. + retval = false;
  73. + }
  74. + else
  75. retval = false;
  76. }
  77. if (backdrops[i].name[0] == '-' && backdrops[i].loaded)
  78. @@ -147,6 +181,7 @@ void skin_backdrop_show(int backdrop_id)
  79.  
  80. void skin_backdrop_unload(int backdrop_id)
  81. {
  82. + core_free(backdrops[backdrop_id].buflib_handle);
  83. backdrops[backdrop_id].buffer = NULL;
  84. }
RAW Paste Data