Example #1
0
static int
repaint(glw_gradient_t *gg, glw_root_t *gr, int tile, int w, int h, int tiles)
{
  int x, y, n = showtime_get_ts(), m = 0;
  uint8_t  *p, *pixmap;
  size_t s = h * w * GRAD_BPP;

  if(w < 1 || h < 1)
    return 0;

  p = pixmap = malloc(s);
  for(y = 0; y < h; y++) {
    float a = (float)y / (float)h;
    int r = 65280 * GLW_LERP(a, gg->gg_col1[0], gg->gg_col2[0]);
    int g = 65280 * GLW_LERP(a, gg->gg_col1[1], gg->gg_col2[1]);
    int b = 65280 * GLW_LERP(a, gg->gg_col1[2], gg->gg_col2[2]);

    for(x = 0; x < w; x++) {
      n = n * 1664525 + 1013904223;
      *p++ = (b + (n & 0xff)) >> 8;

      n = n * 1664525 + 1013904223;
      *p++ = (g + (n & 0xff)) >> 8;

      n = n * 1664525 + 1013904223;
      *p++ = (r + (n & 0xff)) >> 8;
    }
    n = n ^ m;
    m = m * 1664525 + 1013904223;
  }

  if(gg->gg_image_flags & GLW_IMAGE_BEVEL_TOP)
    bevel_top(pixmap, w, h);

  if(gg->gg_image_flags & GLW_IMAGE_BEVEL_BOTTOM)
    bevel_bottom(pixmap, w, h);

  glw_tex_upload(gr, &gg->gg_tex[0], pixmap, GLW_TEXTURE_FORMAT_RGB, w, h, 
		 GLW_TEX_REPEAT);

  if(tiles == 3) {
    p = malloc(s);

    memcpy(p, pixmap, s);
    if(gg->gg_image_flags & GLW_IMAGE_BEVEL_LEFT)
      bevel_left(p, w, h);
    glw_tex_upload(gr, &gg->gg_tex[1], p, GLW_TEXTURE_FORMAT_RGB, w, h, 
		   GLW_TEX_REPEAT);

    memcpy(p, pixmap, s);
    if(gg->gg_image_flags & GLW_IMAGE_BEVEL_RIGHT)
      bevel_right(p, w, h);
    glw_tex_upload(gr, &gg->gg_tex[2], p, GLW_TEXTURE_FORMAT_RGB, w, h, 
		   GLW_TEX_REPEAT);

    free(p);
  }
  free(pixmap);
  return 1;
}
Example #2
0
static void
glw_bar_layout(glw_t *w, const glw_rctx_t *rc)
{
  glw_bar_t *gb = (void *)w;
  float r, g, b, x;

  if(w->glw_alpha < GLW_ALPHA_EPSILON)
    return;

  if(!glw_renderer_initialized(&gb->gb_gr)) {
    glw_renderer_init_quad(&gb->gb_gr);
    gb->gb_update = 1;
  }

  if(gb->gb_update) {
    gb->gb_update = 0;

    r = GLW_LERP(gb->gb_fill, gb->gb_col1[0], gb->gb_col2[0]);
    g = GLW_LERP(gb->gb_fill, gb->gb_col1[1], gb->gb_col2[1]);
    b = GLW_LERP(gb->gb_fill, gb->gb_col1[2], gb->gb_col2[2]);
    x = GLW_LERP(gb->gb_fill, -1, 1);

    glw_renderer_vtx_pos(&gb->gb_gr, 0, -1.0, -1.0, 0.0);
    glw_renderer_vtx_col(&gb->gb_gr, 0,
			 gb->gb_col1[0],
			 gb->gb_col1[1],
			 gb->gb_col1[2],
			 1.0);

    glw_renderer_vtx_pos(&gb->gb_gr, 1,  x, -1.0, 0.0);
    glw_renderer_vtx_col(&gb->gb_gr, 1, r, g, b, 1.0);


    glw_renderer_vtx_pos(&gb->gb_gr, 2,  x,  1.0, 0.0);
    glw_renderer_vtx_col(&gb->gb_gr, 2, r, g, b, 1.0);


    glw_renderer_vtx_pos(&gb->gb_gr, 3, -1.0,  1.0, 0.0);
    glw_renderer_vtx_col(&gb->gb_gr, 3,
			 gb->gb_col1[0],
			 gb->gb_col1[1],
			 gb->gb_col1[2],
			 1.0);

    glw_need_refresh(w->glw_root, 0);
  }
}