コード例 #1
0
ファイル: xrdp_cache.c プロジェクト: 340211173/xrdp
void APP_CC
xrdp_cache_delete(struct xrdp_cache *self)
{
    int i;
    int j;

    if (self == 0)
    {
        return;
    }

    /* free all the cached bitmaps */
    for (i = 0; i < XRDP_MAX_BITMAP_CACHE_ID; i++)
    {
        for (j = 0; j < XRDP_MAX_BITMAP_CACHE_IDX; j++)
        {
            xrdp_bitmap_delete(self->bitmap_items[i][j].bitmap);
        }
    }

    /* free all the cached font items */
    for (i = 0; i < 12; i++)
    {
        for (j = 0; j < 256; j++)
        {
            g_free(self->char_items[i][j].font_item.data);
        }
    }

    /* free all the off screen bitmaps */
    for (i = 0; i < 2000; i++)
    {
        xrdp_bitmap_delete(self->os_bitmap_items[i].bitmap);
    }

    list_delete(self->xrdp_os_del_list);

    /* free all crc lists */
    for (i = 0; i < XRDP_MAX_BITMAP_CACHE_ID; i++)
    {
        for (j = 0; j < 64 * 1024; j++)
        {
            list16_deinit(&(self->crc16[i][j]));
        }
    }

    g_free(self);
}
コード例 #2
0
ファイル: xrdp_cache.c プロジェクト: authentic8/xrdp
/* returns error */
int APP_CC
xrdp_cache_remove_os_bitmap(struct xrdp_cache *self, int rdpindex)
{
    struct xrdp_os_bitmap_item *bi;
    int index;

    if ((rdpindex < 0) || (rdpindex >= 2000))
    {
        return 1;
    }

    bi = self->os_bitmap_items + rdpindex;

    if (bi->bitmap->tab_stop)
    {
        index = list_index_of(self->xrdp_os_del_list, rdpindex);

        if (index == -1)
        {
            list_add_item(self->xrdp_os_del_list, rdpindex);
        }
    }

    xrdp_bitmap_delete(bi->bitmap);
    g_memset(bi, 0, sizeof(struct xrdp_os_bitmap_item));
    return 0;
}
コード例 #3
0
ファイル: xrdp_cache.c プロジェクト: zeha/xrdp-suse-fork
void APP_CC
xrdp_cache_delete(struct xrdp_cache* self)
{
  int i;
  int j;

  if (self == 0)
  {
    return;
  }
  /* free all the cached bitmaps */
  for (i = 0; i < 3; i++)
  {
    for (j = 0; j < 2000; j++)
    {
      xrdp_bitmap_delete(self->bitmap_items[i][j].bitmap);
    }
  }
  /* free all the cached font items */
  for (i = 0; i < 12; i++)
  {
    for (j = 0; j < 256; j++)
    {
      g_free(self->char_items[i][j].font_item.data);
    }
  }
  g_free(self);
}
コード例 #4
0
ファイル: xrdp_cache.c プロジェクト: authentic8/xrdp
void APP_CC
xrdp_cache_delete(struct xrdp_cache *self)
{
    int i;
    int j;

    if (self == 0)
    {
        return;
    }

    /* free all the cached bitmaps */
    for (i = 0; i < 3; i++)
    {
        for (j = 0; j < XRDP_BITMAP_CACHE_ENTRIES; j++)
        {
            xrdp_bitmap_delete(self->bitmap_items[i][j].bitmap);
        }
    }

    /* free all the cached font items */
    for (i = 0; i < 12; i++)
    {
        for (j = 0; j < 256; j++)
        {
            g_free(self->char_items[i][j].font_item.data);
        }
    }

    /* free all the off screen bitmaps */
    for (i = 0; i < 2000; i++)
    {
        xrdp_bitmap_delete(self->os_bitmap_items[i].bitmap);
    }

    list_delete(self->xrdp_os_del_list);

    g_free(self);
}
コード例 #5
0
ファイル: xrdp_cache.c プロジェクト: 340211173/xrdp
int APP_CC
xrdp_cache_reset(struct xrdp_cache *self,
                 struct xrdp_client_info *client_info)
{
    struct xrdp_wm *wm;
    struct xrdp_session *session;
    int i;
    int j;

    /* free all the cached bitmaps */
    for (i = 0; i < XRDP_MAX_BITMAP_CACHE_ID; i++)
    {
        for (j = 0; j < XRDP_MAX_BITMAP_CACHE_IDX; j++)
        {
            xrdp_bitmap_delete(self->bitmap_items[i][j].bitmap);
        }
    }

    /* free all the cached font items */
    for (i = 0; i < 12; i++)
    {
        for (j = 0; j < 256; j++)
        {
            g_free(self->char_items[i][j].font_item.data);
        }
    }

    /* save these */
    wm = self->wm;
    session = self->session;
    /* set whole struct to zero */
    g_memset(self, 0, sizeof(struct xrdp_cache));
    /* set some stuff back */
    self->wm = wm;
    self->session = session;
    self->use_bitmap_comp = client_info->use_bitmap_comp;
    self->cache1_entries = client_info->cache1_entries;
    self->cache1_size = client_info->cache1_size;
    self->cache2_entries = client_info->cache2_entries;
    self->cache2_size = client_info->cache2_size;
    self->cache3_entries = client_info->cache3_entries;
    self->cache3_size = client_info->cache3_size;
    self->bitmap_cache_persist_enable = client_info->bitmap_cache_persist_enable;
    self->bitmap_cache_version = client_info->bitmap_cache_version;
    self->pointer_cache_entries = client_info->pointer_cache_entries;
    xrdp_cache_reset_lru(self);
    xrdp_cache_reset_crc(self);
    return 0;
}
コード例 #6
0
ファイル: xrdp_mm.c プロジェクト: LawrenceK/xrdp
int DEFAULT_CC
server_paint_rect(struct xrdp_mod* mod, int x, int y, int cx, int cy,
                  char* data, int width, int height, int srcx, int srcy)
{
  struct xrdp_wm* wm;
  struct xrdp_bitmap* b;
  struct xrdp_painter* p;

  wm = (struct xrdp_wm*)(mod->wm);
  p = (struct xrdp_painter*)(mod->painter);
  b = xrdp_bitmap_create_with_data(width, height, wm->screen->bpp, data, wm);
  xrdp_painter_copy(p, b, wm->screen, x, y, cx, cy, srcx, srcy);
  xrdp_bitmap_delete(b);
  return 0;
}
コード例 #7
0
ファイル: xrdp_cache.c プロジェクト: authentic8/xrdp
/* returns cache id */
int APP_CC
xrdp_cache_add_bitmap(struct xrdp_cache *self, struct xrdp_bitmap *bitmap,
                      int hints)
{
    int i = 0;
    int j = 0;
    int oldest = 0;
    int cache_id = 0;
    int cache_idx = 0;
    int bmp_size = 0;
    int e = 0;
    int Bpp = 0;

    e = bitmap->width % 4;

    if (e != 0)
    {
        e = 4 - e;
    }

    Bpp = (bitmap->bpp + 7) / 8;
    bmp_size = (bitmap->width + e) * bitmap->height * Bpp;
    self->bitmap_stamp++;

    /* look for match */
    if (bmp_size <= self->cache1_size)
    {
        i = 0;

        for (j = 0; j < self->cache1_entries; j++)
        {
#ifdef USE_CRC

            if (xrdp_bitmap_compare_with_crc(self->bitmap_items[i][j].bitmap, bitmap))
#else
            if (xrdp_bitmap_compare(self->bitmap_items[i][j].bitmap, bitmap))
#endif
            {
                self->bitmap_items[i][j].stamp = self->bitmap_stamp;
                LLOGLN(10, ("found bitmap at %d %d", i, j));
                xrdp_bitmap_delete(bitmap);
                return MAKELONG(j, i);
            }
        }
    }
    else if (bmp_size <= self->cache2_size)
    {
        i = 1;

        for (j = 0; j < self->cache2_entries; j++)
        {
#ifdef USE_CRC

            if (xrdp_bitmap_compare_with_crc(self->bitmap_items[i][j].bitmap, bitmap))
#else
            if (xrdp_bitmap_compare(self->bitmap_items[i][j].bitmap, bitmap))
#endif
            {
                self->bitmap_items[i][j].stamp = self->bitmap_stamp;
                LLOGLN(10, ("found bitmap at %d %d", i, j));
                xrdp_bitmap_delete(bitmap);
                return MAKELONG(j, i);
            }
        }
    }
    else if (bmp_size <= self->cache3_size)
    {
        i = 2;

        for (j = 0; j < self->cache3_entries; j++)
        {
#ifdef USE_CRC

            if (xrdp_bitmap_compare_with_crc(self->bitmap_items[i][j].bitmap, bitmap))
#else
            if (xrdp_bitmap_compare(self->bitmap_items[i][j].bitmap, bitmap))
#endif
            {
                self->bitmap_items[i][j].stamp = self->bitmap_stamp;
                LLOGLN(10, ("found bitmap at %d %d", i, j));
                xrdp_bitmap_delete(bitmap);
                return MAKELONG(j, i);
            }
        }
    }
    else
    {
        log_message(LOG_LEVEL_ERROR,"error in xrdp_cache_add_bitmap, too big(%d) bpp %d", bmp_size, bitmap->bpp);
    }

    /* look for oldest */
    cache_id = 0;
    cache_idx = 0;
    oldest = 0x7fffffff;

    if (bmp_size <= self->cache1_size)
    {
        i = 0;

        for (j = 0; j < self->cache1_entries; j++)
        {
            if (self->bitmap_items[i][j].stamp < oldest)
            {
                oldest = self->bitmap_items[i][j].stamp;
                cache_id = i;
                cache_idx = j;
            }
        }
    }
    else if (bmp_size <= self->cache2_size)
    {
        i = 1;

        for (j = 0; j < self->cache2_entries; j++)
        {
            if (self->bitmap_items[i][j].stamp < oldest)
            {
                oldest = self->bitmap_items[i][j].stamp;
                cache_id = i;
                cache_idx = j;
            }
        }
    }
    else if (bmp_size <= self->cache3_size)
    {
        i = 2;

        for (j = 0; j < self->cache3_entries; j++)
        {
            if (self->bitmap_items[i][j].stamp < oldest)
            {
                oldest = self->bitmap_items[i][j].stamp;
                cache_id = i;
                cache_idx = j;
            }
        }
    }

    LLOGLN(10, ("adding bitmap at %d %d ptr %p", cache_id, cache_idx,
                self->bitmap_items[cache_id][cache_idx].bitmap));
    /* set, send bitmap and return */
    xrdp_bitmap_delete(self->bitmap_items[cache_id][cache_idx].bitmap);
    self->bitmap_items[cache_id][cache_idx].bitmap = bitmap;
    self->bitmap_items[cache_id][cache_idx].stamp = self->bitmap_stamp;

    if (self->use_bitmap_comp)
    {
        if (self->bitmap_cache_version & 4)
        {
            if (libxrdp_orders_send_bitmap3(self->session, bitmap->width,
                                            bitmap->height, bitmap->bpp,
                                            bitmap->data, cache_id, cache_idx,
                                            hints) == 0)
            {
                return MAKELONG(cache_idx, cache_id);
            }
        }

        if (self->bitmap_cache_version & 2)
        {
            libxrdp_orders_send_bitmap2(self->session, bitmap->width,
                                        bitmap->height, bitmap->bpp,
                                        bitmap->data, cache_id, cache_idx,
                                        hints);
        }
        else if (self->bitmap_cache_version & 1)
        {
            libxrdp_orders_send_bitmap(self->session, bitmap->width,
                                       bitmap->height, bitmap->bpp,
                                       bitmap->data, cache_id, cache_idx);
        }
    }
    else
    {
        if (self->bitmap_cache_version & 2)
        {
            libxrdp_orders_send_raw_bitmap2(self->session, bitmap->width,
                                            bitmap->height, bitmap->bpp,
                                            bitmap->data, cache_id, cache_idx);
        }
        else if (self->bitmap_cache_version & 1)
        {
            libxrdp_orders_send_raw_bitmap(self->session, bitmap->width,
                                           bitmap->height, bitmap->bpp,
                                           bitmap->data, cache_id, cache_idx);
        }
    }

    return MAKELONG(cache_idx, cache_id);
}
コード例 #8
0
ファイル: xrdp_cache.c プロジェクト: 340211173/xrdp
/* returns cache id */
int APP_CC
xrdp_cache_add_bitmap(struct xrdp_cache *self, struct xrdp_bitmap *bitmap,
                      int hints)
{
    int index;
    int jndex;
    int cache_id;
    int cache_idx;
    int bmp_size;
    int e;
    int Bpp;
    int crc16;
    int iig;
    int found;
    int cache_entries;
    int lru_index;
    struct list16 *ll;
    struct xrdp_bitmap *lbm;
    struct xrdp_lru_item *llru;

    LLOGLN(10, ("xrdp_cache_add_bitmap:"));
    LLOGLN(10, ("xrdp_cache_add_bitmap: crc16 0x%4.4x",
           bitmap->crc16));

    e = (4 - (bitmap->width % 4)) & 3;
    found = 0;
    cache_id = 0;
    cache_entries = 0;

    /* client Bpp, bmp_size */
    Bpp = (bitmap->bpp + 7) / 8;
    bmp_size = (bitmap->width + e) * bitmap->height * Bpp;
    self->bitmap_stamp++;

    if (bmp_size <= self->cache1_size)
    {
        cache_id = 0;
        cache_entries = self->cache1_entries;
    }
    else if (bmp_size <= self->cache2_size)
    {
        cache_id = 1;
        cache_entries = self->cache2_entries;
    }
    else if (bmp_size <= self->cache3_size)
    {
        cache_id = 2;
        cache_entries = self->cache3_entries;
    }
    else
    {
        log_message(LOG_LEVEL_ERROR, "error in xrdp_cache_add_bitmap, "
                    "too big(%d) bpp %d", bmp_size, bitmap->bpp);
        return 0;
    }

    crc16 = bitmap->crc16;
    ll = &(self->crc16[cache_id][crc16]);
    for (jndex = 0; jndex < ll->count; jndex++)
    {
        cache_idx = list16_get_item(ll, jndex);
        if (COMPARE_WITH_CRC32
                 (self->bitmap_items[cache_id][cache_idx].bitmap, bitmap))
        {
            LLOGLN(10, ("found bitmap at %d %d", index, jndex));
            found = 1;
            break;
        }
    }
    if (found)
    {
        lru_index = self->bitmap_items[cache_id][cache_idx].lru_index;
        self->bitmap_items[cache_id][cache_idx].stamp = self->bitmap_stamp;
        xrdp_bitmap_delete(bitmap);

        /* update lru to end */
        xrdp_cache_update_lru(self, cache_id, lru_index);

        return MAKELONG(cache_idx, cache_id);
    }

    /* find lru */

    /* check for reset */
    if (self->lru_reset[cache_id])
    {
        self->lru_reset[cache_id] = 0;
        LLOGLN(0, ("xrdp_cache_add_bitmap: reset detected cache_id %d",
               cache_id));
        self->lru_tail[cache_id] = cache_entries - 1;
        index = self->lru_tail[cache_id];
        llru = &(self->bitmap_lrus[cache_id][index]);
        llru->next = -1;
    }

    /* lru is item at head */
    lru_index = self->lru_head[cache_id];
    cache_idx = lru_index;

    /* update lru to end */
    xrdp_cache_update_lru(self, cache_id, lru_index);

    LLOGLN(10, ("xrdp_cache_add_bitmap: oldest %d %d", cache_id, cache_idx));

    LLOGLN(10, ("adding bitmap at %d %d old ptr %p new ptr %p",
           cache_id, cache_idx,
           self->bitmap_items[cache_id][cache_idx].bitmap,
           bitmap));

    /* remove old, about to be deleted, from crc16 list */
    lbm = self->bitmap_items[cache_id][cache_idx].bitmap;
    if (lbm != 0)
    {
        crc16 = lbm->crc16;
        ll = &(self->crc16[cache_id][crc16]);
        iig = list16_index_of(ll, cache_idx);
        if (iig == -1)
        {
            LLOGLN(0, ("xrdp_cache_add_bitmap: error removing cache_idx"));
        }
        LLOGLN(10, ("xrdp_cache_add_bitmap: removing index %d from crc16 %d",
               iig, crc16));
        list16_remove_item(ll, iig);
        xrdp_bitmap_delete(lbm);
    }

    /* set, send bitmap and return */

    self->bitmap_items[cache_id][cache_idx].bitmap = bitmap;
    self->bitmap_items[cache_id][cache_idx].stamp = self->bitmap_stamp;
    self->bitmap_items[cache_id][cache_idx].lru_index = lru_index;

    /* add to crc16 list */
    crc16 = bitmap->crc16;
    ll = &(self->crc16[cache_id][crc16]);
    list16_add_item(ll, cache_idx);
    if (ll->count > 1)
    {
        LLOGLN(10, ("xrdp_cache_add_bitmap: count %d", ll->count));
    }

    if (self->use_bitmap_comp)
    {
        if (self->bitmap_cache_version & 4)
        {
            if (libxrdp_orders_send_bitmap3(self->session, bitmap->width,
                                            bitmap->height, bitmap->bpp,
                                            bitmap->data, cache_id, cache_idx,
                                            hints) == 0)
            {
                return MAKELONG(cache_idx, cache_id);
            }
        }

        if (self->bitmap_cache_version & 2)
        {
            libxrdp_orders_send_bitmap2(self->session, bitmap->width,
                                        bitmap->height, bitmap->bpp,
                                        bitmap->data, cache_id, cache_idx,
                                        hints);
        }
        else if (self->bitmap_cache_version & 1)
        {
            libxrdp_orders_send_bitmap(self->session, bitmap->width,
                                       bitmap->height, bitmap->bpp,
                                       bitmap->data, cache_id, cache_idx);
        }
    }
    else
    {
        if (self->bitmap_cache_version & 2)
        {
            libxrdp_orders_send_raw_bitmap2(self->session, bitmap->width,
                                            bitmap->height, bitmap->bpp,
                                            bitmap->data, cache_id, cache_idx);
        }
        else if (self->bitmap_cache_version & 1)
        {
            libxrdp_orders_send_raw_bitmap(self->session, bitmap->width,
                                           bitmap->height, bitmap->bpp,
                                           bitmap->data, cache_id, cache_idx);
        }
    }

    return MAKELONG(cache_idx, cache_id);
}
コード例 #9
0
ファイル: xrdp_cache.c プロジェクト: zeha/xrdp-suse-fork
/* returns cache id */
int APP_CC
xrdp_cache_add_bitmap(struct xrdp_cache* self, struct xrdp_bitmap* bitmap)
{
  int i;
  int j;
  int oldest;
  int cache_id;
  int cache_idx;
  int bmp_size;
  int e;
  int Bpp;

  e = bitmap->width % 4;
  if (e != 0)
  {
    e = 4 - e;
  }
  Bpp = (bitmap->bpp + 7) / 8;
  bmp_size = (bitmap->width + e) * bitmap->height * Bpp;
  self->bitmap_stamp++;
  /* look for match */
  if (bmp_size <= self->cache1_size)
  {
    i = 0;
    for (j = 0; j < self->cache1_entries; j++)
    {
#ifdef USE_CRC
      if (xrdp_bitmap_compare_with_crc(self->bitmap_items[i][j].bitmap, bitmap))
#else
      if (xrdp_bitmap_compare(self->bitmap_items[i][j].bitmap, bitmap))
#endif
      {
        self->bitmap_items[i][j].stamp = self->bitmap_stamp;
        DEBUG(("found bitmap at %d %d", i, j));
        xrdp_bitmap_delete(bitmap);
        return MAKELONG(j, i);
      }
    }
  }
  else if (bmp_size <= self->cache2_size)
  {
    i = 1;
    for (j = 0; j < self->cache2_entries; j++)
    {
#ifdef USE_CRC
      if (xrdp_bitmap_compare_with_crc(self->bitmap_items[i][j].bitmap, bitmap))
#else
      if (xrdp_bitmap_compare(self->bitmap_items[i][j].bitmap, bitmap))
#endif
      {
        self->bitmap_items[i][j].stamp = self->bitmap_stamp;
        DEBUG(("found bitmap at %d %d", i, j));
        xrdp_bitmap_delete(bitmap);
        return MAKELONG(j, i);
      }
    }
  }
  else if (bmp_size <= self->cache3_size)
  {
    i = 2;
    for (j = 0; j < self->cache3_entries; j++)
    {
#ifdef USE_CRC
      if (xrdp_bitmap_compare_with_crc(self->bitmap_items[i][j].bitmap, bitmap))
#else
      if (xrdp_bitmap_compare(self->bitmap_items[i][j].bitmap, bitmap))
#endif
      {
        self->bitmap_items[i][j].stamp = self->bitmap_stamp;
        DEBUG(("found bitmap at %d %d", i, j));
        xrdp_bitmap_delete(bitmap);
        return MAKELONG(j, i);
      }
    }
  }
  else
  {
    g_writeln("error in xrdp_cache_add_bitmap, too big(%d)", bmp_size);
  }
  /* look for oldest */
  cache_id = 0;
  cache_idx = 0;
  oldest = 0x7fffffff;
  if (bmp_size <= self->cache1_size)
  {
    i = 0;
    for (j = 0; j < self->cache1_entries; j++)
    {
      if (self->bitmap_items[i][j].stamp < oldest)
      {
        oldest = self->bitmap_items[i][j].stamp;
        cache_id = i;
        cache_idx = j;
      }
    }
  }
  else if (bmp_size <= self->cache2_size)
  {
    i = 1;
    for (j = 0; j < self->cache2_entries; j++)
    {
      if (self->bitmap_items[i][j].stamp < oldest)
      {
        oldest = self->bitmap_items[i][j].stamp;
        cache_id = i;
        cache_idx = j;
      }
    }
  }
  else if (bmp_size <= self->cache3_size)
  {
    i = 2;
    for (j = 0; j < self->cache3_entries; j++)
    {
      if (self->bitmap_items[i][j].stamp < oldest)
      {
        oldest = self->bitmap_items[i][j].stamp;
        cache_id = i;
        cache_idx = j;
      }
    }
  }
  DEBUG(("adding bitmap at %d %d", cache_id, cache_idx));
  /* set, send bitmap and return */
  xrdp_bitmap_delete(self->bitmap_items[cache_id][cache_idx].bitmap);
  self->bitmap_items[cache_id][cache_idx].bitmap = bitmap;
  self->bitmap_items[cache_id][cache_idx].stamp = self->bitmap_stamp;
  if (self->bitmap_cache_version == 0) /* orginal version */
  {
    if (self->use_bitmap_comp)
    {
      libxrdp_orders_send_bitmap(self->session, bitmap->width,
                                 bitmap->height, bitmap->bpp,
                                 bitmap->data, cache_id, cache_idx);
    }
    else
    {
      libxrdp_orders_send_raw_bitmap(self->session, bitmap->width,
                                     bitmap->height, bitmap->bpp,
                                     bitmap->data, cache_id, cache_idx);
    }
  }
  else
  {
    if (self->use_bitmap_comp)
    {
      libxrdp_orders_send_bitmap2(self->session, bitmap->width,
                                  bitmap->height, bitmap->bpp,
                                  bitmap->data, cache_id, cache_idx);
    }
    else
    {
      libxrdp_orders_send_raw_bitmap2(self->session, bitmap->width,
                                      bitmap->height, bitmap->bpp,
                                      bitmap->data, cache_id, cache_idx);
    }
  }
  return MAKELONG(cache_idx, cache_id);
}