コード例 #1
0
ファイル: circuitmux_ewma.c プロジェクト: jfrazelle/tor
/** Adjust the cell count of <b>ewma</b> so that it is scaled with respect to
 * <b>cur_tick</b> */
static void
scale_single_cell_ewma(cell_ewma_t *ewma, unsigned cur_tick)
{
  double factor = get_scale_factor(ewma->last_adjusted_tick, cur_tick);
  ewma->cell_count *= factor;
  ewma->last_adjusted_tick = cur_tick;
}
コード例 #2
0
wxBitmap KiScaledBitmap( BITMAP_DEF aBitmap, EDA_BASE_FRAME* aWindow )
{
    // Bitmap conversions are cached because they can be slow.
    static std::unordered_map<SCALED_BITMAP_ID, wxBitmap> bitmap_cache;
    static std::mutex bitmap_cache_mutex;
    const int scale = get_scale_factor( aWindow );

    SCALED_BITMAP_ID id = { aBitmap, scale };

    std::lock_guard<std::mutex> guard( bitmap_cache_mutex );
    auto it = bitmap_cache.find( id );

    if( it != bitmap_cache.end() )
    {
        return it->second;
    }
    else
    {
        wxMemoryInputStream is( aBitmap->png, aBitmap->byteCount );
        wxImage image( is, wxBITMAP_TYPE_PNG );

        // Bilinear seems to genuinely look better for these line-drawing icons
        // than bicubic, despite claims in the wx documentation that bicubic is
        // "highest quality". I don't recommend changing this. Bicubic looks
        // blurry and makes me want an eye exam.
        image.Rescale( scale * image.GetWidth() / 4, scale * image.GetHeight() / 4,
                wxIMAGE_QUALITY_BILINEAR );
        return bitmap_cache.emplace( id, wxBitmap( image ) ).first->second;
    }
}
コード例 #3
0
ファイル: h264_direct.c プロジェクト: neerfri/FFmpeg
void ff_h264_direct_dist_scale_factor(H264Context * const h){
    MpegEncContext * const s = &h->s;
    const int poc = h->s.current_picture_ptr->field_poc[ s->picture_structure == PICT_BOTTOM_FIELD ];
    const int poc1 = h->ref_list[1][0].poc;
    int i, field;
    for(field=0; field<2; field++){
        const int poc  = h->s.current_picture_ptr->field_poc[field];
        const int poc1 = h->ref_list[1][0].field_poc[field];
        for(i=0; i < 2*h->ref_count[0]; i++)
            h->dist_scale_factor_field[field][i^field] = get_scale_factor(h, poc, poc1, i+16);
    }

    for(i=0; i<h->ref_count[0]; i++){
        h->dist_scale_factor[i] = get_scale_factor(h, poc, poc1, i);
    }
}
コード例 #4
0
ファイル: h264_direct.c プロジェクト: 0xFFeng/ffmpeg
void ff_h264_direct_dist_scale_factor(H264Context * const h){
    const int poc = h->cur_pic_ptr->field_poc[h->picture_structure == PICT_BOTTOM_FIELD];
    const int poc1 = h->ref_list[1][0].poc;
    int i, field;

    if (FRAME_MBAFF(h))
        for (field = 0; field < 2; field++){
            const int poc  = h->cur_pic_ptr->field_poc[field];
            const int poc1 = h->ref_list[1][0].field_poc[field];
            for (i = 0; i < 2 * h->ref_count[0]; i++)
                h->dist_scale_factor_field[field][i^field] =
                    get_scale_factor(h, poc, poc1, i+16);
        }

    for (i = 0; i < h->ref_count[0]; i++){
        h->dist_scale_factor[i] = get_scale_factor(h, poc, poc1, i);
    }
}
コード例 #5
0
ファイル: h264_direct.c プロジェクト: 411697643/FFmpeg
void ff_h264_direct_dist_scale_factor(const H264Context *const h,
                                      H264SliceContext *sl)
{
    const int poc  = FIELD_PICTURE(h) ? h->cur_pic_ptr->field_poc[h->picture_structure == PICT_BOTTOM_FIELD]
                                      : h->cur_pic_ptr->poc;
    const int poc1 = sl->ref_list[1][0].poc;
    int i, field;

    if (FRAME_MBAFF(h))
        for (field = 0; field < 2; field++) {
            const int poc  = h->cur_pic_ptr->field_poc[field];
            const int poc1 = sl->ref_list[1][0].parent->field_poc[field];
            for (i = 0; i < 2 * sl->ref_count[0]; i++)
                sl->dist_scale_factor_field[field][i ^ field] =
                    get_scale_factor(sl, poc, poc1, i + 16);
        }

    for (i = 0; i < sl->ref_count[0]; i++)
        sl->dist_scale_factor[i] = get_scale_factor(sl, poc, poc1, i);
}
コード例 #6
0
ファイル: fonts.c プロジェクト: LeifAndersen/TuxRider
void get_font_metrics( font_t *font, char *string,
		       int *width, int *max_ascent, int *max_descent)
{
    scalar_t scale_fact = get_scale_factor( font );
    get_tex_font_string_bbox( font->node->tfm, string, width, 
			      max_ascent, max_descent );

    *width *= scale_fact;
    *max_ascent *= scale_fact;
    *max_descent *= scale_fact;
}
コード例 #7
0
ファイル: gtkiconhelper.c プロジェクト: 3dfxmadscientist/gtk
static void
ensure_surface_from_pixbuf (GtkIconHelper   *self,
			    GtkStyleContext *context)
{
  gint width, height;
  GdkPixbuf *pixbuf;
  int scale;

  if (!check_invalidate_surface (self, context))
    return;

  if (self->priv->rendered_surface)
    return;

  scale = get_scale_factor (self, context);

  if (self->priv->force_scale_pixbuf &&
      (self->priv->pixel_size != -1 ||
       self->priv->icon_size != GTK_ICON_SIZE_INVALID))
    {
      ensure_icon_size (self, context, &width, &height);

      if (scale != self->priv->orig_pixbuf_scale ||
	  width < gdk_pixbuf_get_width (self->priv->orig_pixbuf) / self->priv->orig_pixbuf_scale ||
          height < gdk_pixbuf_get_height (self->priv->orig_pixbuf) / self->priv->orig_pixbuf_scale)
	{
	  width = MIN (width * scale, gdk_pixbuf_get_width (self->priv->orig_pixbuf) * scale / self->priv->orig_pixbuf_scale);
	  height = MIN (height * scale, gdk_pixbuf_get_height (self->priv->orig_pixbuf) * scale / self->priv->orig_pixbuf_scale);

	  pixbuf = gdk_pixbuf_scale_simple (self->priv->orig_pixbuf,
					    width, height,
					    GDK_INTERP_BILINEAR);
	}
      else
	{
	  pixbuf = g_object_ref (self->priv->orig_pixbuf); 
	  scale = self->priv->orig_pixbuf_scale;
	}
    }
  else
    {
      pixbuf = g_object_ref (self->priv->orig_pixbuf);
      scale = self->priv->orig_pixbuf_scale;
    }

  self->priv->rendered_surface_width = (gdk_pixbuf_get_width (pixbuf) + scale - 1) / scale;
  self->priv->rendered_surface_height = (gdk_pixbuf_get_height (pixbuf) + scale - 1) / scale;

  self->priv->rendered_surface = gdk_cairo_surface_create_from_pixbuf (pixbuf, scale, self->priv->window);
  g_object_unref (pixbuf);
}
コード例 #8
0
ファイル: fonts.c プロジェクト: LeifAndersen/TuxRider
static void start_font_draw( font_t *font )
{
    scalar_t scale_fact = get_scale_factor( font );
    glPushMatrix();
    glScalef( scale_fact,
	      scale_fact,
	      scale_fact );

#ifdef __APPLE__DISABLED__
	glColor4f( (float)font->colour.r, (float)font->colour.g, (float)font->colour.b, (float)font->colour.a );
#else
    glColor4dv( (scalar_t*) &font->colour );
#endif
}
コード例 #9
0
ファイル: gtkiconhelper.c プロジェクト: Distrotech/gtk
static gboolean
get_pixbuf_size (GtkIconHelper   *self,
                 GtkStyleContext *context,
                 gint *width_out,
                 gint *height_out,
                 gint *scale_out)
{
  gboolean scale_pixmap;
  gint width, height;
  int scale;

  scale = get_scale_factor (self, context);
  scale_pixmap = FALSE;

  if (self->priv->force_scale_pixbuf &&
      (self->priv->pixel_size != -1 ||
       self->priv->icon_size != GTK_ICON_SIZE_INVALID))
    {
      ensure_icon_size (self, context, &width, &height);

      if (scale != self->priv->orig_pixbuf_scale ||
	  width < gdk_pixbuf_get_width (self->priv->orig_pixbuf) / self->priv->orig_pixbuf_scale ||
          height < gdk_pixbuf_get_height (self->priv->orig_pixbuf) / self->priv->orig_pixbuf_scale)
	{
	  width = MIN (width * scale, gdk_pixbuf_get_width (self->priv->orig_pixbuf) * scale / self->priv->orig_pixbuf_scale);
	  height = MIN (height * scale, gdk_pixbuf_get_height (self->priv->orig_pixbuf) * scale / self->priv->orig_pixbuf_scale);

          scale_pixmap = TRUE;
	}
      else
	{
	  width = gdk_pixbuf_get_width (self->priv->orig_pixbuf);
	  height = gdk_pixbuf_get_height (self->priv->orig_pixbuf);
	  scale = self->priv->orig_pixbuf_scale;
	}
    }
  else
    {
      width = gdk_pixbuf_get_width (self->priv->orig_pixbuf);
      height = gdk_pixbuf_get_height (self->priv->orig_pixbuf);
      scale = self->priv->orig_pixbuf_scale;
    }

  *width_out = width;
  *height_out = height;
  *scale_out = scale;

  return scale_pixmap;
}
コード例 #10
0
void KiScaledSeparator( wxAuiToolBar* aToolbar, EDA_BASE_FRAME* aWindow )
{
    const int scale = get_scale_factor( aWindow );

    if( scale > 4 )
    {
        aToolbar->AddSpacer( 16 * ( scale - 4 ) / 4 );
    }

    aToolbar->AddSeparator();

    if( scale > 4 )
    {
        aToolbar->AddSpacer( 16 * ( scale - 4 ) / 4 );
    }
}
コード例 #11
0
wxBitmap KiScaledBitmap( const wxBitmap& aBitmap, EDA_BASE_FRAME* aWindow )
{
    const int scale = get_scale_factor( aWindow );

    if( scale == 4)
    {
        return wxBitmap( aBitmap );
    }
    else
    {
        wxImage image = aBitmap.ConvertToImage();
        image.Rescale( scale * image.GetWidth() / 4, scale * image.GetHeight() / 4,
            wxIMAGE_QUALITY_BILINEAR );

        return wxBitmap( image );
    }
}
コード例 #12
0
ファイル: gtkiconhelper.c プロジェクト: 3dfxmadscientist/gtk
static void
ensure_surface_for_icon_name_or_gicon (GtkIconHelper *self,
				       GtkStyleContext *context)
{
  GtkIconTheme *icon_theme;
  gint width, height, scale;
  GtkIconInfo *info;
  GtkIconLookupFlags flags;

  if (!check_invalidate_surface (self, context))
    return;

  icon_theme = gtk_icon_theme_get_default ();
  flags = get_icon_lookup_flags (self);

  ensure_icon_size (self, context, &width, &height);
  scale = get_scale_factor (self, context);

  if (self->priv->storage_type == GTK_IMAGE_ICON_NAME &&
      self->priv->icon_name != NULL)
    {
      info = gtk_icon_theme_lookup_icon_for_scale (icon_theme,
						   self->priv->icon_name,
						   MIN (width, height),
						   scale, flags);
    }
  else if (self->priv->storage_type == GTK_IMAGE_GICON &&
           self->priv->gicon != NULL)
    {
      info = gtk_icon_theme_lookup_by_gicon_for_scale (icon_theme,
						       self->priv->gicon,
						       MIN (width, height),
						       scale, flags);
    }
  else
    {
      g_assert_not_reached ();
      return;
    }

  ensure_stated_surface_from_info (self, context, info, scale);

  if (info)
    g_object_unref (info);
}
コード例 #13
0
ファイル: circuitmux_ewma.c プロジェクト: jfrazelle/tor
/** Adjust the cell count of every active circuit on <b>chan</b> so
 * that they are scaled with respect to <b>cur_tick</b> */
static void
scale_active_circuits(ewma_policy_data_t *pol, unsigned cur_tick)
{
  double factor;

  tor_assert(pol);
  tor_assert(pol->active_circuit_pqueue);

  factor =
    get_scale_factor(
      pol->active_circuit_pqueue_last_recalibrated,
      cur_tick);
  /** Ordinarily it isn't okay to change the value of an element in a heap,
   * but it's okay here, since we are preserving the order. */
  SMARTLIST_FOREACH_BEGIN(
      pol->active_circuit_pqueue,
      cell_ewma_t *, e) {
    tor_assert(e->last_adjusted_tick ==
               pol->active_circuit_pqueue_last_recalibrated);
    e->cell_count *= factor;
    e->last_adjusted_tick = cur_tick;
  } SMARTLIST_FOREACH_END(e);
  pol->active_circuit_pqueue_last_recalibrated = cur_tick;
}
コード例 #14
0
ファイル: gtkiconhelper.c プロジェクト: Distrotech/gtk
static void
ensure_surface_for_icon_set (GtkIconHelper *self,
			     GtkStyleContext *context,
			     GtkIconSet *icon_set)
{
  gint scale;

  if (!check_invalidate_surface (self, context))
    return;

  scale = get_scale_factor (self, context);

  G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
  self->priv->rendered_surface =
    gtk_icon_set_render_icon_surface (icon_set, context, 
				      self->priv->icon_size,
				      scale, self->priv->window);
  G_GNUC_END_IGNORE_DEPRECATIONS;

  if (self->priv->rendered_surface)
    get_surface_size (self, context, self->priv->rendered_surface, 
		      &self->priv->rendered_surface_width, 
		      &self->priv->rendered_surface_height);
}
コード例 #15
0
ファイル: gtkiconhelper.c プロジェクト: Distrotech/gtk
static gboolean
check_invalidate_surface (GtkIconHelper *self,
			  GtkStyleContext *context)
{
  GtkStateFlags state;
  int scale;

  state = gtk_style_context_get_state (context);
  scale = get_scale_factor (self, context);

  if ((self->priv->rendered_surface != NULL) &&
      (self->priv->last_surface_state == state) &&
      (self->priv->last_surface_scale == scale))
    return FALSE;

  self->priv->last_surface_state = state;
  self->priv->last_surface_scale = scale;

  if (self->priv->rendered_surface)
    cairo_surface_destroy (self->priv->rendered_surface);
  self->priv->rendered_surface = NULL;

  return TRUE;
}