<commit_before>#include "evas_common.h"
#include "evas_private.h"
#include <math.h>

static void
_evas_map_calc_geom_change(Evas_Object *obj)
{
   int is, was = 0;

   evas_object_change(obj);
   evas_object_clip_dirty(obj);
   if (obj->layer->evas->events_frozen <= 0)
     {
        evas_object_recalc_clippees(obj);
        if (!obj->smart.smart)
          {
             is = evas_object_is_in_output_rect(obj,
                                                obj->layer->evas->pointer.x,
                                                obj->layer->evas->pointer.y, 1, 1);
             if ((is ^ was) && obj->cur.visible)
               evas_event_feed_mouse_move(obj->layer->evas,
                                          obj->layer->evas->pointer.x,
                                          obj->layer->evas->pointer.y,
                                          obj->layer->evas->last_timestamp,
                                          NULL);
          }
     }
   evas_object_inform_call_move(obj);
   evas_object_inform_call_resize(obj);
}

static void
_evas_map_calc_map_geometry(Evas_Object *obj)
{
   Evas_Coord x1, x2, yy1, yy2;
   const Evas_Map_Point *p, *p_end;
   Eina_Bool ch = EINA_FALSE;

   if (!obj->cur.map) return;

   // WARN: Do not merge below code to SLP until it is fixed.
   // It has an infinite loop bug.
   if (obj->prev.map)
     {
        if (obj->prev.map != obj->cur.map)
          {
             // FIXME: this causes an infinite loop somewhere... hard to debug
             if (obj->prev.map->count == obj->cur.map->count)
               {
                  const Evas_Map_Point *p2;

                  p = obj->cur.map->points;
                  p_end = p + obj->cur.map->count;
                  p2 = obj->prev.map->points;

                  for (; p < p_end; p++, p2++)
                    {
                       if ((p->a != p2->a) ||
                           (p->r != p2->r) ||
                           (p->g != p2->g) ||
                           (p->b != p2->b))
                         {
                            ch = 1;
                            break;
                         }
                       if ((p->x != p2->x) ||
                           (p->y != p2->y) ||
                           (p->z != p2->z))
                         {
                            ch = 1;
                            break;
                         }
                    }

                  if (!ch)
                    {
                       if (obj->cache_map) evas_map_free(obj->cache_map); 
                       obj->cache_map = obj->cur.map;
                       obj->cur.map = obj->prev.map;
                    }
               }
             else
               ch = 1;
          }
     }
   else
      ch = 1;

   p = obj->cur.map->points;
   p_end = p + obj->cur.map->count;
   x1 = x2 = lround(p->x);
   yy1 = yy2 = lround(p->y);
   p++;
   for (; p < p_end; p++)
     {
        Evas_Coord x, y;
        
        x = lround(p->x);
        y = lround(p->y);
        if (x < x1) x1 = x;
        if (x > x2) x2 = x;
        if (y < yy1) yy1 = y;
        if (y > yy2) yy2 = y;
     }
// this causes clip-out bugs now mapped objs canbe opaque!!!   
//   // add 1 pixel of fuzz around the map region to ensure updates are correct
//   x1 -= 1; yy1 -= 1;
//   x2 += 1; yy2 += 1;
   if (obj->cur.map->normal_geometry.x != x1) ch = 1;
   if (obj->cur.map->normal_geometry.y != yy1) ch = 1;
   if (obj->cur.map->normal_geometry.w != (x2 - x1)) ch = 1;
   if (obj->cur.map->normal_geometry.h != (yy2 - yy1)) ch = 1;
   obj->cur.map->normal_geometry.x = x1;
   obj->cur.map->normal_geometry.y = yy1;
   obj->cur.map->normal_geometry.w = (x2 - x1);
   obj->cur.map->normal_geometry.h = (yy2 - yy1);
   obj->changed_map = ch;
   if (ch) _evas_map_calc_geom_change(obj);
}

static inline Evas_Map *
_evas_map_new(int count)
{
   int i;
   int alloc;
   Evas_Map *m;

   /* Adjust allocation such that: at least 4 points, and always an even
    * number: this allows the software engine to work efficiently */
   alloc = (count < 4) ? 4 : count;
   if (alloc & 0x1) alloc ++;

   m = calloc(1, sizeof(Evas_Map) + (alloc * sizeof(Evas_Map_Point)));
   if (!m) return NULL;
   m->count = count;<commit_msg>evas: try to unbork previous map fix.<commit_after>#include "evas_common.h"
#include "evas_private.h"
#include <math.h>

static void
_evas_map_calc_geom_change(Evas_Object *obj)
{
   int is, was = 0;

   evas_object_change(obj);
   evas_object_clip_dirty(obj);
   if (obj->layer->evas->events_frozen <= 0)
     {
        evas_object_recalc_clippees(obj);
        if (!obj->smart.smart)
          {
             is = evas_object_is_in_output_rect(obj,
                                                obj->layer->evas->pointer.x,
                                                obj->layer->evas->pointer.y, 1, 1);
             if ((is ^ was) && obj->cur.visible)
               evas_event_feed_mouse_move(obj->layer->evas,
                                          obj->layer->evas->pointer.x,
                                          obj->layer->evas->pointer.y,
                                          obj->layer->evas->last_timestamp,
                                          NULL);
          }
     }
   evas_object_inform_call_move(obj);
   evas_object_inform_call_resize(obj);
}

static void
_evas_map_calc_map_geometry(Evas_Object *obj)
{
   Evas_Coord x1, x2, yy1, yy2;
   const Evas_Map_Point *p, *p_end;
   Eina_Bool ch = EINA_FALSE;

   if (!obj->cur.map) return;

   // WARN: Do not merge below code to SLP until it is fixed.
   // It has an infinite loop bug.
   if (obj->prev.map)
     {
        if (obj->prev.map != obj->cur.map)
          {
             // FIXME: this causes an infinite loop somewhere... hard to debug
             if (obj->prev.map->count == obj->cur.map->count)
               {
                  const Evas_Map_Point *p2;

                  p = obj->cur.map->points;
                  p2 = obj->prev.map->points;

                  ch = memcmp(p, p2,
                              sizeof (Evas_Map_Point) * obj->prev.map->count);

                  ch = !!ch;
                  if (!ch)
                    {
                       if (obj->cache_map) evas_map_free(obj->cache_map); 
                       obj->cache_map = obj->cur.map;
                       obj->cur.map = obj->prev.map;
                    }
               }
             else
               ch = 1;
          }
     }
   else
      ch = 1;

   p = obj->cur.map->points;
   p_end = p + obj->cur.map->count;
   x1 = x2 = lround(p->x);
   yy1 = yy2 = lround(p->y);
   p++;
   for (; p < p_end; p++)
     {
        Evas_Coord x, y;
        
        x = lround(p->x);
        y = lround(p->y);
        if (x < x1) x1 = x;
        if (x > x2) x2 = x;
        if (y < yy1) yy1 = y;
        if (y > yy2) yy2 = y;
     }
// this causes clip-out bugs now mapped objs canbe opaque!!!   
//   // add 1 pixel of fuzz around the map region to ensure updates are correct
//   x1 -= 1; yy1 -= 1;
//   x2 += 1; yy2 += 1;
   if (obj->cur.map->normal_geometry.x != x1) ch = 1;
   if (obj->cur.map->normal_geometry.y != yy1) ch = 1;
   if (obj->cur.map->normal_geometry.w != (x2 - x1)) ch = 1;
   if (obj->cur.map->normal_geometry.h != (yy2 - yy1)) ch = 1;
   obj->cur.map->normal_geometry.x = x1;
   obj->cur.map->normal_geometry.y = yy1;
   obj->cur.map->normal_geometry.w = (x2 - x1);
   obj->cur.map->normal_geometry.h = (yy2 - yy1);
   obj->changed_map = ch;
   // This shouldn't really be needed, but without it we do have case
   // where the clip is wrong when a map doesn't change, so always forcing
   // it, as long as someone doesn't find a better fix.
   evas_object_clip_dirty(obj);
   if (ch) _evas_map_calc_geom_change(obj);
}

static inline Evas_Map *
_evas_map_new(int count)
{
   int i;
   int alloc;
   Evas_Map *m;

   /* Adjust allocation such that: at least 4 points, and always an even
    * number: this allows the software engine to work efficiently */
   alloc = (count < 4) ? 4 : count;
   if (alloc & 0x1) alloc ++;

   m = calloc(1, sizeof(Evas_Map) + (alloc * sizeof(Evas_Map_Point)));
   if (!m) return NULL;
   m->count = count;
{'fraction_non_alphanumeric': 0.13638577691183634, 'fraction_numerical': 0.014734534827082318, 'mean_word_length': 1.3764467592592593, 'pattern_counts': {'":': 0, '<': 16, '<?xml version=': 0, '>': 159, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 24, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2612400', 'n_tokens_mistral': 2805, 'n_tokens_neox': 2719, 'n_words': 637}