Esempio n. 1
0
static void
mx_table_paint (ClutterActor *self)
{
  MxTablePrivate *priv = MX_TABLE (self)->priv;
  ClutterActorIter iter;
  ClutterActor *child;


  /* make sure the background gets painted first */
  CLUTTER_ACTOR_CLASS (mx_table_parent_class)->paint (self);

  clutter_actor_iter_init (&iter, self);
  while (clutter_actor_iter_next (&iter, &child))
    {
      if (CLUTTER_ACTOR_IS_VISIBLE (child))
        clutter_actor_paint (child);
    }

  if (_mx_debug (MX_DEBUG_LAYOUT))
    {
      int i;
      float width, height;
      gfloat pos = 0;
      DimensionData *rows, *cols;

      rows = &g_array_index (priv->rows, DimensionData, 0);
      cols = &g_array_index (priv->columns, DimensionData, 0);

      clutter_actor_get_size (self, &width, &height);

      cogl_set_source_color4f (0.0, 0.0, 1.0, 0.7);

      for (i = 0; i < priv->n_rows; i++)
        {
          cogl_rectangle (0, pos, 10, pos + rows[i].final_size);

          pos += rows[i].final_size + priv->row_spacing;
        }


      cogl_set_source_color4f (1.0, 0.0, 0.0, 0.7);

      pos = 0;
      for (i = 0; i < priv->n_rows; i++)
        {
          cogl_rectangle (pos, 0, pos + cols[i].final_size, 10);

          pos += cols[i].final_size + priv->col_spacing;
        }


    }
}
Esempio n. 2
0
static void
st_polygon_paint (ClutterActor *self)
{

    StPolygon *area = ST_POLYGON (self);
    StPolygonPrivate *priv = area->priv;
    if (priv->debug) {
        gfloat coords[8];
        CoglPath *selection_path;

        cogl_set_source_color4f (.50,
                                 .50,
                                 .50,
                                 .50);

        coords[0] = priv->ulc_x;
        coords[1] = priv->ulc_y;
        coords[2] = priv->llc_x;
        coords[3] = priv->llc_y;
        coords[4] = priv->lrc_x;
        coords[5] = priv->lrc_y;
        coords[6] = priv->urc_x;
        coords[7] = priv->urc_y;

        selection_path = cogl_path_new();
        cogl_path_polygon (selection_path, (float *)coords, 4);
        cogl_path_fill (selection_path);
        cogl_object_unref (selection_path);
    }
}
Esempio n. 3
0
static void
test_rectangles (TestState *state)
{
#define RECT_WIDTH 5
#define RECT_HEIGHT 5
  int x;
  int y;

  /* Should the rectangles be randomly positioned/colored/rotated?
   *
   * It could be good to develop equivalent GL and Cairo tests so we can
   * have a sanity check for our Cogl performance.
   *
   * The color should vary to check that we correctly batch color changes
   * The use of alpha should vary so we have a variation of which rectangles
   * require blending.
   *  Should this be a random variation?
   *  It could be good to experiment with focibly enabling blending for
   *  rectangles that don't technically need it for the sake of extending
   *  batching. E.g. if you a long run of interleved rectangles with every
   *  other rectangle needing blending then it may be worth enabling blending
   *  for all the rectangles to avoid the state changes.
   * The modelview should change between rectangles to check the software
   * transform codepath.
   *  Should we group some rectangles under the same modelview? Potentially
   *  we could avoid software transform for long runs of rectangles with the
   *  same modelview.
   *
   */

  for (y = 0; y < STAGE_HEIGHT; y += RECT_HEIGHT)
    {
      for (x = 0; x < STAGE_WIDTH; x += RECT_WIDTH)
        {
          cogl_push_matrix ();
          cogl_translate (x, y, 0);
          cogl_rotate (45, 0, 0, 1);
          cogl_set_source_color4f (1,
                                   (1.0f/STAGE_WIDTH)*y,
                                   (1.0f/STAGE_HEIGHT)*x,
                                   1);
          cogl_rectangle (0, 0, RECT_WIDTH, RECT_HEIGHT);
          cogl_pop_matrix ();
        }
    }

  for (y = 0; y < STAGE_HEIGHT; y += RECT_HEIGHT)
    {
      for (x = 0; x < STAGE_WIDTH; x += RECT_WIDTH)
        {
          cogl_push_matrix ();
          cogl_translate (x, y, 0);
          cogl_rotate (0, 0, 0, 1);
          cogl_set_source_color4f (1,
                                   (1.0f/STAGE_WIDTH)*x,
                                   (1.0f/STAGE_HEIGHT)*y,
                                   (1.0f/STAGE_WIDTH)*x);
          cogl_rectangle (0, 0, RECT_WIDTH, RECT_HEIGHT);
          cogl_pop_matrix ();
        }
    }
}