Changeset View
Changeset View
Standalone View
Standalone View
src/static_libs/vg_common/vg_common_json.c
Show All 12 Lines | |||||
13 | _get_key_val(void *key) | 13 | _get_key_val(void *key) | ||
14 | { | 14 | { | ||
15 | static char buf[30]; | 15 | static char buf[30]; | ||
16 | snprintf(buf, sizeof(buf), "%zu", (size_t) key); | 16 | snprintf(buf, sizeof(buf), "%zu", (size_t) key); | ||
17 | return buf; | 17 | return buf; | ||
18 | } | 18 | } | ||
19 | 19 | | |||
20 | static void | 20 | static void | ||
21 | _construct_drawable_nodes(Efl_Canvas_Vg_Container *parent, const LOTLayerNode *layer, int depth EINA_UNUSED) | 21 | _construct_drawable_nodes(Vg_File_Data *vfd, Efl_Canvas_Vg_Container *parent, const LOTLayerNode *layer, int depth EINA_UNUSED) | ||
22 | { | 22 | { | ||
23 | if (!parent) return; | 23 | if (!parent) return; | ||
24 | 24 | | |||
25 | //This list is used for layer order verification | 25 | //This list is used for layer order verification | ||
26 | Eina_List *list = (Eina_List*) efl_canvas_vg_container_children_direct_get(parent); | 26 | Eina_List *list = (Eina_List*) efl_canvas_vg_container_children_direct_get(parent); | ||
27 | 27 | | |||
28 | for (unsigned int i = 0; i < layer->mNodeList.size; i++) | 28 | for (unsigned int i = 0; i < layer->mNodeList.size; i++) | ||
29 | { | 29 | { | ||
▲ Show 20 Lines • Show All 51 Lines • ▼ Show 20 Line(s) | 80 | if (node->mStroke.enable && node->mStroke.width == 0) | |||
81 | { | 81 | { | ||
82 | efl_gfx_entity_visible_set(shape, EINA_FALSE); | 82 | efl_gfx_entity_visible_set(shape, EINA_FALSE); | ||
83 | continue; | 83 | continue; | ||
84 | } | 84 | } | ||
85 | 85 | | |||
86 | const float *data = node->mPath.ptPtr; | 86 | const float *data = node->mPath.ptPtr; | ||
87 | if (!data) continue; | 87 | if (!data) continue; | ||
88 | 88 | | |||
89 | | ||||
90 | for (unsigned int i = 0; i<node->mPath.ptCount; i++) | ||||
91 | { | ||||
92 | if (i%2 == 0) | ||||
93 | { | ||||
94 | if (vfd->bl > data[i]) vfd->bl = data[i]; | ||||
95 | if (vfd->br < data[i]) vfd->br = data[i]; | ||||
96 | } | ||||
97 | else | ||||
98 | { | ||||
99 | if (vfd->bt > data[i]) vfd->bt = data[i]; | ||||
100 | if (vfd->bb < data[i]) vfd->bb = data[i]; | ||||
101 | } | ||||
102 | } | ||||
103 | | ||||
89 | if (node->keypath) efl_key_data_set(shape, "_lot_node_name", node->keypath); | 104 | if (node->keypath) efl_key_data_set(shape, "_lot_node_name", node->keypath); | ||
90 | efl_gfx_entity_visible_set(shape, EINA_TRUE); | 105 | efl_gfx_entity_visible_set(shape, EINA_TRUE); | ||
91 | #if DEBUG | 106 | #if DEBUG | ||
92 | for (int i = 0; i < depth; i++) printf(" "); | 107 | for (int i = 0; i < depth; i++) printf(" "); | ||
93 | printf("%s (%p) keypath : %s\n", efl_class_name_get(efl_class_get(shape)), shape, node->keypath); | 108 | printf("%s (%p) keypath : %s\n", efl_class_name_get(efl_class_get(shape)), shape, node->keypath); | ||
94 | #endif | 109 | #endif | ||
95 | //0: Path | 110 | //0: Path | ||
96 | efl_gfx_path_reserve(shape, node->mPath.elmCount, node->mPath.ptCount); | 111 | efl_gfx_path_reserve(shape, node->mPath.elmCount, node->mPath.ptCount); | ||
▲ Show 20 Lines • Show All 299 Lines • ▼ Show 20 Line(s) | 408 | { | |||
396 | Efl_VG* child; | 411 | Efl_VG* child; | ||
397 | EINA_LIST_FOREACH(list, list2, child) | 412 | EINA_LIST_FOREACH(list, list2, child) | ||
398 | _reset_vg_tree(child); | 413 | _reset_vg_tree(child); | ||
399 | } | 414 | } | ||
400 | efl_gfx_entity_visible_set(node, EINA_FALSE); | 415 | efl_gfx_entity_visible_set(node, EINA_FALSE); | ||
401 | } | 416 | } | ||
402 | 417 | | |||
403 | static void | 418 | static void | ||
404 | _update_vg_tree(Efl_Canvas_Vg_Container *root, const LOTLayerNode *layer, int depth EINA_UNUSED) | 419 | _update_vg_tree(Vg_File_Data *vfd, Efl_Canvas_Vg_Container *root, const LOTLayerNode *layer, int depth EINA_UNUSED) | ||
405 | { | 420 | { | ||
406 | if (!layer->mVisible) return; | 421 | if (!layer->mVisible) return; | ||
407 | 422 | | |||
408 | efl_gfx_entity_visible_set(root, EINA_TRUE); | 423 | efl_gfx_entity_visible_set(root, EINA_TRUE); | ||
409 | efl_gfx_color_set(root, layer->mAlpha, layer->mAlpha, layer->mAlpha, layer->mAlpha); | 424 | efl_gfx_color_set(root, layer->mAlpha, layer->mAlpha, layer->mAlpha, layer->mAlpha); | ||
410 | 425 | | |||
411 | //Don't need to update it anymore since its layer is invisible. | 426 | //Don't need to update it anymore since its layer is invisible. | ||
412 | if (layer->mAlpha == 0) return; | 427 | if (layer->mAlpha == 0) return; | ||
Show All 18 Lines | 445 | { | |||
431 | ctree = efl_add(EFL_CANVAS_VG_CONTAINER_CLASS, root); | 446 | ctree = efl_add(EFL_CANVAS_VG_CONTAINER_CLASS, root); | ||
432 | efl_key_data_set(root, key, ctree); | 447 | efl_key_data_set(root, key, ctree); | ||
433 | if (clayer->keypath) efl_key_data_set(ctree, "_lot_node_name", clayer->keypath); | 448 | if (clayer->keypath) efl_key_data_set(ctree, "_lot_node_name", clayer->keypath); | ||
434 | } | 449 | } | ||
435 | #if DEBUG | 450 | #if DEBUG | ||
436 | for (int i = 0; i < depth; i++) printf(" "); | 451 | for (int i = 0; i < depth; i++) printf(" "); | ||
437 | printf("%s (%p) matte:%d => %p %s\n", efl_class_name_get(efl_class_get(ctree)), ctree, matte_mode, ptree, clayer->keypath); | 452 | printf("%s (%p) matte:%d => %p %s\n", efl_class_name_get(efl_class_get(ctree)), ctree, matte_mode, ptree, clayer->keypath); | ||
438 | #endif | 453 | #endif | ||
439 | _update_vg_tree(ctree, clayer, depth+1); | 454 | _update_vg_tree(vfd, ctree, clayer, depth+1); | ||
440 | 455 | | |||
441 | if (matte_mode != 0) | 456 | if (matte_mode != 0) | ||
442 | { | 457 | { | ||
443 | efl_canvas_vg_node_comp_method_set(ptree, ctree, matte_mode); | 458 | efl_canvas_vg_node_comp_method_set(ptree, ctree, matte_mode); | ||
444 | mtarget = ctree; | 459 | mtarget = ctree; | ||
445 | } | 460 | } | ||
446 | matte_mode = (int) clayer->mMatte; | 461 | matte_mode = (int) clayer->mMatte; | ||
447 | 462 | | |||
Show All 32 Lines | 493 | default: | |||
480 | break; | 495 | break; | ||
481 | } | 496 | } | ||
482 | 497 | | |||
483 | //Construct node that have mask. | 498 | //Construct node that have mask. | ||
484 | if (mlayer && mtarget) | 499 | if (mlayer && mtarget) | ||
485 | ptree = _construct_masks(mtarget, mlayer->mMaskList.ptr, mlayer->mMaskList.size, depth + 1); | 500 | ptree = _construct_masks(mtarget, mlayer->mMaskList.ptr, mlayer->mMaskList.size, depth + 1); | ||
486 | } | 501 | } | ||
487 | 502 | | |||
503 | efl_key_data_set(root, "_lot_node_size", &layer->mNodeList.size); | ||||
488 | //Construct drawable nodes. | 504 | //Construct drawable nodes. | ||
489 | if (layer->mNodeList.size > 0) | 505 | if (layer->mNodeList.size > 0) | ||
490 | _construct_drawable_nodes(root, layer, depth); | 506 | _construct_drawable_nodes(vfd, root, layer, depth); | ||
491 | 507 | | |||
492 | } | 508 | } | ||
493 | #endif | 509 | #endif | ||
494 | 510 | | |||
495 | #ifdef BUILD_VG_LOADER_JSON | 511 | #ifdef BUILD_VG_LOADER_JSON | ||
496 | void | 512 | void | ||
497 | _value_provider_override(Vg_File_Data *vfd) | 513 | _value_provider_override(Vg_File_Data *vfd) | ||
498 | { | 514 | { | ||
▲ Show 20 Lines • Show All 87 Lines • ▼ Show 20 Line(s) | |||||
586 | { | 602 | { | ||
587 | #ifdef BUILD_VG_LOADER_JSON | 603 | #ifdef BUILD_VG_LOADER_JSON | ||
588 | Lottie_Animation *lot_anim = (Lottie_Animation *) vfd->loader_data; | 604 | Lottie_Animation *lot_anim = (Lottie_Animation *) vfd->loader_data; | ||
589 | if (!lot_anim) return EINA_FALSE; | 605 | if (!lot_anim) return EINA_FALSE; | ||
590 | 606 | | |||
591 | if (vfd->vp_list) _value_provider_override(vfd); | 607 | if (vfd->vp_list) _value_provider_override(vfd); | ||
592 | 608 | | |||
593 | unsigned int frame_num = (vfd->anim_data) ? vfd->anim_data->frame_num : 0; | 609 | unsigned int frame_num = (vfd->anim_data) ? vfd->anim_data->frame_num : 0; | ||
610 | | ||||
611 | //This Calculates Bound Size using Raw Data | ||||
612 | vfd->bl = 100000; | ||||
613 | vfd->bt = 100000; | ||||
614 | vfd->br = -1; | ||||
615 | vfd->bb = -1; | ||||
616 | | ||||
617 | int lot_render_w, lot_render_h; | ||||
618 | lot_render_w = vfd->is_wrap?vfd->w:vfd->view_box.w; | ||||
619 | lot_render_h = vfd->is_wrap?vfd->h:vfd->view_box.h; | ||||
620 | | ||||
594 | const LOTLayerNode *tree = | 621 | const LOTLayerNode *tree = | ||
595 | lottie_animation_render_tree(lot_anim, frame_num, | 622 | lottie_animation_render_tree(lot_anim, frame_num, | ||
596 | vfd->view_box.w, vfd->view_box.h); | 623 | lot_render_w, lot_render_h); | ||
597 | //Root node | 624 | //Root node | ||
598 | Efl_Canvas_Vg_Container *root = vfd->root; | 625 | Efl_Canvas_Vg_Container *root = vfd->root; | ||
599 | if (!root) | 626 | if (!root) | ||
600 | { | 627 | { | ||
601 | root = efl_add_ref(EFL_CANVAS_VG_CONTAINER_CLASS, NULL); | 628 | root = efl_add_ref(EFL_CANVAS_VG_CONTAINER_CLASS, NULL); | ||
602 | if (!root) return EINA_FALSE; | 629 | if (!root) return EINA_FALSE; | ||
603 | efl_key_data_set(root, _get_key_val((void *) tree), tree); | 630 | efl_key_data_set(root, _get_key_val((void *) tree), tree); | ||
604 | if (tree->keypath) efl_key_data_set(root, "_lot_node_name", tree->keypath); | 631 | if (tree->keypath) efl_key_data_set(root, "_lot_node_name", tree->keypath); | ||
605 | vfd->root = root; | 632 | vfd->root = root; | ||
606 | } | 633 | } | ||
607 | else _reset_vg_tree(root); | 634 | else _reset_vg_tree(root); | ||
608 | 635 | | |||
609 | #if DEBUG | 636 | #if DEBUG | ||
610 | printf("%s (%p)\n", efl_class_name_get(efl_class_get(vfd->root)), vfd->root); | 637 | printf("%s (%p)\n", efl_class_name_get(efl_class_get(vfd->root)), vfd->root); | ||
611 | #endif | 638 | #endif | ||
612 | 639 | | |||
613 | _update_vg_tree(root, tree, 1); | 640 | _update_vg_tree(vfd, root, tree, 1); | ||
641 | | ||||
642 | vfd->minw = (int)(vfd->br - vfd->bl); | ||||
643 | vfd->minh = (int)(vfd->bb - vfd->bt); | ||||
644 | | ||||
614 | #else | 645 | #else | ||
615 | return EINA_FALSE; | 646 | return EINA_FALSE; | ||
616 | #endif | 647 | #endif | ||
617 | return EINA_TRUE; | 648 | return EINA_TRUE; | ||
618 | } | 649 | } |