Debian Codegraph @

lvgl/src/draw/renesas/dave2d/lv_draw_dave2d.c

raw symbols SCIP
1 /**
2 * @file lv_draw_dave2d.c
3 *
4 */
5
6 /*********************
7 * INCLUDES
8 *********************/
9 #include "lv_draw_dave2d.h"
10 #if LV_USE_DRAW_DAVE2D
11 #include "../../lv_draw_buf_private.h"
12 #include "../../../misc/lv_area_private.h"
13
14 /*********************
15 * DEFINES
16 *********************/
17 #define DRAW_UNIT_ID_DAVE2D 4
18 /* The amount of tasks exercising pressure to the current to get finished
19 * This one is used as the main signal to start to render a block of tasks.
20 */
21 #ifndef LV_DAVE2D_MAX_DRAW_PRESSURE
22 #define LV_DAVE2D_MAX_DRAW_PRESSURE 256
23 #endif
24
25 #if (LV_DAVE2D_MAX_DRAW_PRESSURE < 256)
26 #error "DRAW Pressure should be at least 256 otherwise the Dave engine may crash!"
27 #endif
28 /**********************
29 * TYPEDEFS
30 **********************/
31
32 /**********************
33 * STATIC PROTOTYPES
34 **********************/
35
36 static void execute_drawing(lv_draw_dave2d_unit_t * u);
37 #if defined(RENESAS_CORTEX_M85) || defined(_RENESAS_RZA_)
38 #if (BSP_CFG_DCACHE_ENABLED) || defined(_RENESAS_RZA_)
39 static void _dave2d_buf_invalidate_cache_cb(const lv_draw_buf_t * draw_buf, const lv_area_t * area);
40 #endif
41 #endif
42
43 static int32_t _dave2d_evaluate(lv_draw_unit_t * draw_unit, lv_draw_task_t * task);
44 static int32_t _dave2d_wait_finish(lv_draw_unit_t * draw_unit);
45 static int32_t lv_draw_dave2d_dispatch(lv_draw_unit_t * draw_unit, lv_layer_t * layer);
46
47 static d2_s32 lv_dave2d_init(void);
48 static void lv_draw_buf_dave2d_init_handlers(void);
49 static bool lv_draw_dave2d_image_color_format_supported(lv_color_format_t color_format);
50 void dave2d_execute_dlist_and_flush(void);
51
52 /**********************
53 * GLOBAL PROTOTYPES
54 **********************/
55
56 /**********************
57 * STATIC VARIABLES
58 **********************/
59
60 static d2_device * _d2_handle;
61
62 /* Main render buffer, used to carry the block of dave commands for any shape */
63 static d2_renderbuffer * _renderbuffer;
64
65 /* Label dedicated render buffer, used to carry only label related dave commands */
66 static d2_renderbuffer * _label_renderbuffer;
67
68 static lv_ll_t draw_tasks_on_dlist;
69 static uint32_t draw_pressure = 0;
70
71 #if LV_USE_OS
72 lv_mutex_t xd2Semaphore;
73 #endif
74
75 /**********************
76 * MACROS
77 **********************/
78
79 /**********************
80 * GLOBAL FUNCTIONS
81 **********************/
82
83 void lv_draw_dave2d_init(void)
84 {
85 d2_s32 result = D2_OK;
86
87 lv_draw_buf_dave2d_init_handlers();
88
89 lv_draw_dave2d_unit_t * draw_dave2d_unit = lv_draw_create_unit(sizeof(lv_draw_dave2d_unit_t));
90 draw_dave2d_unit->base_unit.dispatch_cb = lv_draw_dave2d_dispatch;
91 draw_dave2d_unit->base_unit.evaluate_cb = _dave2d_evaluate;
92 draw_dave2d_unit->base_unit.wait_for_finish_cb = _dave2d_wait_finish;
93 draw_dave2d_unit->base_unit.name = "DAVE2D";
94 draw_dave2d_unit->idx = DRAW_UNIT_ID_DAVE2D;
95
96 result = lv_dave2d_init();
97 LV_ASSERT(D2_OK == result);
98
99 #if LV_USE_OS
100 lv_result_t res;
101 res = lv_mutex_init(&xd2Semaphore);
102 LV_ASSERT(LV_RESULT_OK == res);
103 draw_dave2d_unit->pd2Mutex = &xd2Semaphore;
104 #endif
105
106 draw_dave2d_unit->d2_handle = _d2_handle;
107 draw_dave2d_unit->renderbuffer = _renderbuffer;
108 draw_dave2d_unit->label_renderbuffer = _label_renderbuffer;
109 lv_ll_init(&draw_tasks_on_dlist, sizeof(uintptr_t));
110 }
111
112 /**********************
113 * STATIC FUNCTIONS
114 **********************/
115
116 static void lv_draw_buf_dave2d_init_handlers(void)
117 {
118
119 #if defined(RENESAS_CORTEX_M85) || defined(_RENESAS_RZA_)
120 #if (BSP_CFG_DCACHE_ENABLED) || defined(_RENESAS_RZA_)
121 lv_draw_buf_handlers_t * handlers = lv_draw_buf_get_handlers();
122 handlers->invalidate_cache_cb = _dave2d_buf_invalidate_cache_cb;
123 #endif
124 #endif
125 }
126
127 #if defined(RENESAS_CORTEX_M85) || defined(_RENESAS_RZA_)
128 #if (BSP_CFG_DCACHE_ENABLED) || defined(_RENESAS_RZA_)
129 static void _dave2d_buf_invalidate_cache_cb(const lv_draw_buf_t * draw_buf, const lv_area_t * area)
130 {
131 const lv_image_header_t * header = &draw_buf->header;
132 uint32_t stride = header->stride;
133 lv_color_format_t cf = header->cf;
134
135 uint8_t * address = draw_buf->data;
136 int32_t i = 0;
137 uint32_t bytes_per_pixel = lv_color_format_get_size(cf);
138 int32_t width = lv_area_get_width(area);
139 int32_t lines = lv_area_get_height(area);
140 int32_t bytes_to_flush_per_line = (int32_t)width * (int32_t)bytes_per_pixel;
141
142 /* Stride is in bytes, not pixels */
143 address = address + (area->x1 * (int32_t)bytes_per_pixel) + (stride * (uint32_t)area->y1);
144
145 for(i = 0; i < lines; i++) {
146 #if defined(RENESAS_CORTEX_M85)
147 SCB_CleanInvalidateDCache_by_Addr(address, bytes_to_flush_per_line);
148 #else /* _RENESAS_RZA_ */
149 R_BSP_CACHE_CleanInvalidateRange((uint64_t) address, (uint64_t) bytes_to_flush_per_line);
150 #endif
151 address += stride;
152 }
153 }
154 #endif
155 #endif
156
157 /**
158 * @todo
159 * LVGL needs to use hardware acceleration for buf_copy and do not affect GPU rendering.
160 */
161 #if 0
162 static void _dave2d_buf_copy(void * dest_buf, uint32_t dest_w, uint32_t dest_h, const lv_area_t * dest_area,
163 void * src_buf, uint32_t src_w, uint32_t src_h, const lv_area_t * src_area, lv_color_format_t color_format)
164 {
165 d2_s32 result;
166
167 #if LV_USE_OS
168 lv_result_t status;
169
170 status = lv_mutex_lock(&xd2Semaphore);
171 LV_ASSERT(LV_RESULT_OK == status);
172 #endif
173
174 d2_u32 src_blend_mode = d2_getblendmodesrc(_d2_handle);
175 d2_u32 dst_blend_mode = d2_getblendmodedst(_d2_handle);
176
177 result = d2_selectrenderbuffer(_d2_handle, _blit_renderbuffer);
178 LV_ASSERT(D2_OK == result);
179
180 result = d2_setblendmode(_d2_handle, d2_bm_one, d2_bm_zero);
181 LV_ASSERT(D2_OK == result);
182
183 // Generate render operations
184 result = d2_framebuffer(_d2_handle, (uint16_t *)dest_buf, DISPLAY_HSIZE_INPUT0, DISPLAY_BUFFER_STRIDE_PIXELS_INPUT0,
185 DISPLAY_VSIZE_INPUT0, lv_draw_dave2d_cf_fb_get());
186 LV_ASSERT(D2_OK == result);
187
188 result = d2_cliprect(_d2_handle, (d2_border)dest_area->x1, (d2_border)dest_area->y1, (d2_border)dest_area->x2,
189 (d2_border)dest_area->y2);
190 LV_ASSERT(D2_OK == result);
191
192 result = d2_setblitsrc(_d2_handle, (void *) src_buf, (d2_s32)src_w, (d2_s32)src_w, (d2_s32)src_h,
193 lv_draw_dave2d_lv_colour_fmt_to_d2_fmt(color_format));
194 LV_ASSERT(D2_OK == result);
195
196 result = d2_blitcopy(_d2_handle, (d2_s32)src_w, (d2_s32)src_h, (d2_blitpos)src_area->x1, (d2_blitpos)src_area->y1,
197 D2_FIX4(dest_w), D2_FIX4(dest_h),
198 D2_FIX4(dest_area->x1), D2_FIX4(dest_area->y1), 0);
199 LV_ASSERT(D2_OK == result);
200
201 // Execute render operations
202 result = d2_executerenderbuffer(_d2_handle, _blit_renderbuffer, 0);
203 LV_ASSERT(D2_OK == result) ;
204
205 result = d2_flushframe(_d2_handle);
206 LV_ASSERT(D2_OK == result);
207
208 result = d2_selectrenderbuffer(_d2_handle, _renderbuffer);
209 LV_ASSERT(D2_OK == result);
210
211 result = d2_setblendmode(_d2_handle, src_blend_mode, dst_blend_mode);
212 LV_ASSERT(D2_OK != result);
213
214 #if LV_USE_OS
215 status = lv_mutex_unlock(&xd2Semaphore);
216 LV_ASSERT(LV_RESULT_OK == status);
217 #endif
218
219 }
220 #endif
221
222 static bool lv_draw_dave2d_image_color_format_supported(lv_color_format_t color_format)
223 {
224 bool supported = false;
225
226 switch(color_format) {
227 case LV_COLOR_FORMAT_A8:
228 case LV_COLOR_FORMAT_RGB565:
229 case LV_COLOR_FORMAT_ARGB1555:
230 case LV_COLOR_FORMAT_ARGB4444:
231 case LV_COLOR_FORMAT_ARGB8888:
232 case LV_COLOR_FORMAT_XRGB8888:
233 supported = true;
234 break;
235 default:
236 break;
237 }
238
239 return supported;
240 }
241
242 #define USE_D2 (1)
243
244 static int32_t _dave2d_evaluate(lv_draw_unit_t * u, lv_draw_task_t * t)
245 {
246 LV_UNUSED(u);
247 int32_t ret = 0;
248
249 lv_draw_dsc_base_t * draw_dsc_base = (lv_draw_dsc_base_t *) t->draw_dsc;
250
251 if(!lv_draw_dave2d_is_dest_cf_supported(draw_dsc_base->layer->color_format))
252 return 0;
253
254 switch(t->type) {
255 case LV_DRAW_TASK_TYPE_FILL: {
256 #if USE_D2
257 lv_draw_fill_dsc_t * dsc = t->draw_dsc;
258 if(dsc->grad.dir == LV_GRAD_DIR_NONE
259 || ((dsc->grad.dir != LV_GRAD_DIR_NONE)
260 && ((dsc->grad.stops[0].color.blue == dsc->grad.stops[dsc->grad.stops_count - 1].color.blue)
261 && (dsc->grad.stops[0].color.red == dsc->grad.stops[dsc->grad.stops_count - 1].color.red)
262 && (dsc->grad.stops[0].color.green == dsc->grad.stops[dsc->grad.stops_count - 1].color.green)))) {
263
264 t->preferred_draw_unit_id = DRAW_UNIT_ID_DAVE2D;
265 t->preference_score = 0;
266
267 }
268 else
269 #endif
270 {
271 }
272 ret = 0;
273 break;
274 }
275 case LV_DRAW_TASK_TYPE_LAYER: {
276 ret = 0;
277 break;
278 }
279
280 case LV_DRAW_TASK_TYPE_IMAGE: {
281 lv_draw_image_dsc_t * dsc = t->draw_dsc;
282 if(!lv_draw_dave2d_image_color_format_supported(dsc->header.cf)) {
283 ret = 0;
284 break;
285 }
286 #if USE_D2
287 t->preferred_draw_unit_id = DRAW_UNIT_ID_DAVE2D;
288 t->preference_score = 0;
289 #endif
290 ret = 0;
291 break;
292 }
293
294 case LV_DRAW_TASK_TYPE_BORDER: {
295 #if USE_D2
296 t->preferred_draw_unit_id = DRAW_UNIT_ID_DAVE2D;
297 t->preference_score = 0;
298 #endif
299 ret = 0;
300 break;
301 }
302
303 case LV_DRAW_TASK_TYPE_BOX_SHADOW: {
304 ret = 0;
305 break;
306 }
307
308 case LV_DRAW_TASK_TYPE_LABEL: {
309 #if USE_D2
310 t->preferred_draw_unit_id = DRAW_UNIT_ID_DAVE2D;
311 t->preference_score = 0;
312 #endif
313 ret = 0;
314 break;
315 }
316
317 case LV_DRAW_TASK_TYPE_LINE: {
318 #if USE_D2
319 t->preferred_draw_unit_id = DRAW_UNIT_ID_DAVE2D;
320 t->preference_score = 0;
321 #endif
322 ret = 0;
323 break;
324 }
325
326 case LV_DRAW_TASK_TYPE_ARC: {
327 #if USE_D2
328 t->preferred_draw_unit_id = DRAW_UNIT_ID_DAVE2D;
329 t->preference_score = 0;
330 #endif
331 ret = 0;
332 break;
333 }
334
335 case LV_DRAW_TASK_TYPE_TRIANGLE: {
336 #if USE_D2
337 lv_draw_fill_dsc_t * dsc = t->draw_dsc;
338 if(dsc->grad.dir == LV_GRAD_DIR_NONE
339 || ((dsc->grad.dir != LV_GRAD_DIR_NONE)
340 && ((dsc->grad.stops[0].color.blue == dsc->grad.stops[dsc->grad.stops_count - 1].color.blue)
341 && (dsc->grad.stops[0].color.red == dsc->grad.stops[dsc->grad.stops_count - 1].color.red)
342 && (dsc->grad.stops[0].color.green == dsc->grad.stops[dsc->grad.stops_count - 1].color.green)))) {
343 t->preferred_draw_unit_id = DRAW_UNIT_ID_DAVE2D;
344 t->preference_score = 0;
345 }
346 else {
347 }
348 #endif
349 ret = 0;
350 break;
351 }
352
353 case LV_DRAW_TASK_TYPE_MASK_RECTANGLE: {
354 #if 0//USE_D2
355 t->preferred_draw_unit_id = DRAW_UNIT_ID_DAVE2D;
356 t->preference_score = 0;
357 #endif
358 ret = 0;
359 break;
360 }
361
362 case LV_DRAW_TASK_TYPE_MASK_BITMAP: {
363 ret = 0;
364 break;
365 }
366
367 default:
368 ret = 0;
369 break;
370 }
371
372 return ret;
373 }
374
375
376 static int32_t lv_draw_dave2d_dispatch(lv_draw_unit_t * draw_unit, lv_layer_t * layer)
377 {
378 lv_draw_dave2d_unit_t * draw_dave2d_unit = (lv_draw_dave2d_unit_t *) draw_unit;
379 uint32_t deps = 0;
380
381 if(draw_dave2d_unit->task_act) {
382 /* Return immediately if it's busy with draw task */
383 return LV_DRAW_UNIT_IDLE;
384 }
385
386 lv_draw_task_t * t = NULL;
387 t = lv_draw_get_next_available_task(layer, NULL, DRAW_UNIT_ID_DAVE2D);
388 if(t == NULL) {
389 /* No valid task, but there are tasks waiting to be rendered,
390 * start to draw then immediately.
391 */
392 if(false == lv_ll_is_empty(&draw_tasks_on_dlist)) {
393 draw_pressure = 0;
394 dave2d_execute_dlist_and_flush();
395 }
396 return LV_DRAW_UNIT_IDLE; /* This task is not for us. */
397 }
398
399 if((t->preferred_draw_unit_id != DRAW_UNIT_ID_DAVE2D)) return LV_DRAW_UNIT_IDLE;
400 if(!lv_draw_dave2d_is_dest_cf_supported(layer->color_format)) return LV_DRAW_UNIT_IDLE;
401
402 void * buf = lv_draw_layer_alloc_buf(layer);
403 if(buf == NULL) return LV_DRAW_UNIT_IDLE;
404
405 deps = lv_draw_get_dependent_count(t);
406 if(deps > 0 || draw_pressure > 0) {
407 draw_pressure += deps;
408 if(draw_pressure < LV_DAVE2D_MAX_DRAW_PRESSURE) {
409 /* No other tasks are pressuring to get the current block
410 * of tasks including the latest one, just accumulate it
411 * and tells the drawing pipeline to send a new one if there is any
412 */
413 lv_draw_task_t ** p_new_list_entry;
414 p_new_list_entry = lv_ll_ins_tail(&draw_tasks_on_dlist);
415 *p_new_list_entry = t;
416
417 draw_dave2d_unit->task_act = t;
418 draw_dave2d_unit->task_act->state = LV_DRAW_TASK_STATE_IN_PROGRESS;
419 execute_drawing(draw_dave2d_unit);
420
421 draw_dave2d_unit->task_act = NULL;
422 lv_draw_dispatch_request();
423
424 return 1;
425 }
426 /* If the pressure for drawing value was maxed-out, it is time to render
427 * return IDLE to force the drawing pipeline to wait while the Dave
428 * draw the block of tasks in a single row
429 */
430 return LV_DRAW_UNIT_IDLE;
431 }
432 else {
433 /* Handles a special case when there is no sufficient draw pressure
434 * But the actual task did not carry any extra pressure to get drew
435 * in this case, the drawing pipeline have a few set of tasks that
436 * don't make sense to accumulate them, just do a run to completion
437 * here, that is it, render the incoming task immediately.
438 */
439 draw_dave2d_unit->task_act = t;
440 draw_dave2d_unit->task_act->state = LV_DRAW_TASK_STATE_IN_PROGRESS;
441 d2_selectrenderbuffer(_d2_handle, _renderbuffer);
442 execute_drawing(draw_dave2d_unit);
443 d2_executerenderbuffer(_d2_handle, _renderbuffer, 0);
444 d2_flushframe(_d2_handle);
445
446 draw_dave2d_unit->task_act->state = LV_DRAW_TASK_STATE_FINISHED;
447 draw_dave2d_unit->task_act = NULL;
448 lv_draw_dispatch_request();
449
450 return 1;
451 }
452 }
453
454 static int32_t _dave2d_wait_finish(lv_draw_unit_t * draw_unit)
455 {
456 /* If the drawing pipeline is waiting it means the pressure for drawing
457 * has been maxed out, defer the block of tasks to be rendered by the
458 * Dave and wait for its interrupt. (Dave2D driver is RTOS aware, no need for semaphores);
459 */
460 lv_draw_dave2d_unit_t * draw_dave2d_unit = (lv_draw_dave2d_unit_t *) draw_unit;
461
462 if(!draw_pressure) {
463 /* It reached here because Dave2D Draw Unit was not suitable to take a task
464 * While there is nothing being rendered, prevent the dead lock
465 * by flushing the GPU command buffer empty and just return.
466 */
467 return 0;
468 }
469 dave2d_execute_dlist_and_flush();
470 draw_pressure = 0;
471
472 return 0;
473 }
474
475 static void execute_drawing(lv_draw_dave2d_unit_t * u)
476 {
477 /*Render the draw task*/
478 lv_draw_task_t * t = u->task_act;
479
480 /* remember draw unit for access to unit's context */
481 t->draw_unit = (lv_draw_unit_t *)u;
482
483 #if defined(RENESAS_CORTEX_M85) || defined(_RENESAS_RZA_)
484 #if (BSP_CFG_DCACHE_ENABLED) || defined(_RENESAS_RZA_)
485 lv_layer_t * layer = t->target_layer;
486 lv_area_t clipped_area;
487 int32_t x;
488 int32_t y;
489
490 lv_area_intersect(&clipped_area, &t->area, &t->clip_area);
491
492 x = 0 - t->target_layer->buf_area.x1;
493 y = 0 - t->target_layer->buf_area.y1;
494
495 lv_area_move(&clipped_area, x, y);
496
497 /* Invalidate cache */
498 lv_draw_buf_invalidate_cache(layer->draw_buf, &clipped_area);
499 #endif
500 #endif
501
502 switch(t->type) {
503 case LV_DRAW_TASK_TYPE_FILL:
504 lv_draw_dave2d_fill(t, t->draw_dsc, &t->area);
505 break;
506 case LV_DRAW_TASK_TYPE_BORDER:
507 lv_draw_dave2d_border(t, t->draw_dsc, &t->area);
508 break;
509 case LV_DRAW_TASK_TYPE_BOX_SHADOW:
510 //lv_draw_dave2d_box_shadow(t, t->draw_dsc, &t->area);
511 break;
512 #if 0
513 case LV_DRAW_TASK_TYPE_BG_IMG:
514 //lv_draw_dave2d_bg_image(t, t->draw_dsc, &t->area);
515 break;
516 #endif
517 case LV_DRAW_TASK_TYPE_LABEL:
518 lv_draw_dave2d_label(t, t->draw_dsc, &t->area);
519 break;
520 case LV_DRAW_TASK_TYPE_IMAGE:
521 lv_draw_dave2d_image(t, t->draw_dsc, &t->area);
522 break;
523 case LV_DRAW_TASK_TYPE_LINE:
524 lv_draw_line_iterate(t, t->draw_dsc, lv_draw_dave2d_line);
525 break;
526 case LV_DRAW_TASK_TYPE_ARC:
527 lv_draw_dave2d_arc(t, t->draw_dsc, &t->area);
528 break;
529 case LV_DRAW_TASK_TYPE_TRIANGLE:
530 lv_draw_dave2d_triangle(t, t->draw_dsc);
531 break;
532 case LV_DRAW_TASK_TYPE_LAYER:
533 //lv_draw_dave2d_layer(t, t->draw_dsc, &t->area);
534 break;
535 case LV_DRAW_TASK_TYPE_MASK_RECTANGLE:
536 //lv_draw_dave2d_mask_rect(t, t->draw_dsc, &t->area);
537 break;
538 default:
539 break;
540 }
541
542 #if defined(RENESAS_CORTEX_M85) || defined(_RENESAS_RZA_)
543 #if (BSP_CFG_DCACHE_ENABLED) || defined(_RENESAS_RZA_)
544 lv_draw_buf_invalidate_cache(layer->draw_buf, &clipped_area);
545 #endif
546 #endif
547 }
548
549 static d2_s32 lv_dave2d_init(void)
550 {
551 d2_s32 result = D2_OK;
552
553 if(_d2_handle != NULL) {
554 return D2_NOMEMORY;
555 }
556
557 _d2_handle = d2_opendevice(0);
558 if(_d2_handle == NULL) {
559 return D2_NOMEMORY;
560 }
561
562 /* bind the hardware */
563 result = d2_inithw(_d2_handle, 0);
564 if(result != D2_OK) {
565 LV_LOG_ERROR("Could NOT d2_inithw");
566 d2_closedevice(_d2_handle);
567 return result;
568 }
569
570 //
571 // Set various D2 parameters
572 //
573 result = d2_setblendmode(_d2_handle, d2_bm_alpha, d2_bm_one_minus_alpha);
574 result = d2_setalphamode(_d2_handle, d2_am_constant);
575 result = d2_setalpha(_d2_handle, UINT8_MAX);
576 result = d2_setantialiasing(_d2_handle, 1);
577 result = d2_setlinecap(_d2_handle, d2_lc_butt);
578 result = d2_setlinejoin(_d2_handle, d2_lj_miter);
579
580 /* set blocksize for default displaylist */
581 result = d2_setdlistblocksize(_d2_handle, 20);
582 if(D2_OK != result) {
583 LV_LOG_ERROR("Could NOT d2_setdlistblocksize");
584 d2_closedevice(_d2_handle);
585 return result;
586 }
587
588 _renderbuffer = d2_newrenderbuffer(_d2_handle, 250, 25);
589 if(!_renderbuffer) {
590 LV_LOG_ERROR("NO renderbuffer");
591 d2_closedevice(_d2_handle);
592
593 return D2_NOMEMORY;
594 }
595
596 _label_renderbuffer = d2_newrenderbuffer(_d2_handle, 250, 25);
597 if(!_label_renderbuffer) {
598 LV_LOG_ERROR("NO renderbuffer");
599 d2_closedevice(_d2_handle);
600
601 return D2_NOMEMORY;
602 }
603
604 result = d2_selectrenderbuffer(_d2_handle, _renderbuffer);
605 if(D2_OK != result) {
606 LV_LOG_ERROR("Could NOT d2_selectrenderbuffer");
607 d2_closedevice(_d2_handle);
608 }
609
610 return result;
611 }
612
613 void dave2d_execute_dlist_and_flush(void)
614 {
615 d2_s32 result;
616 lv_draw_task_t ** p_list_entry;
617 lv_draw_task_t * p_list_entry1;
618
619 #if LV_USE_OS
620 lv_result_t status;
621
622 status = lv_mutex_lock(&xd2Semaphore);
623 LV_ASSERT(LV_RESULT_OK == status);
624 #endif
625
626 result = d2_executerenderbuffer(_d2_handle, _renderbuffer, 0);
627 LV_ASSERT(D2_OK == result);
628
629 result = d2_flushframe(_d2_handle);
630 LV_ASSERT(D2_OK == result);
631
632 result = d2_selectrenderbuffer(_d2_handle, _renderbuffer);
633 LV_ASSERT(D2_OK == result);
634
635 while(false == lv_ll_is_empty(&draw_tasks_on_dlist)) {
636 p_list_entry = lv_ll_get_tail(&draw_tasks_on_dlist);
637 p_list_entry1 = *p_list_entry;
638 p_list_entry1->state = LV_DRAW_TASK_STATE_FINISHED;
639 lv_ll_remove(&draw_tasks_on_dlist, p_list_entry);
640 lv_free(p_list_entry);
641 }
642
643 #if LV_USE_OS
644 status = lv_mutex_unlock(&xd2Semaphore);
645 LV_ASSERT(LV_RESULT_OK == status);
646 #endif
647 }
648
649 #endif /*LV_USE_DRAW_DAVE2D*/