Пример #1
0
static void
gtk_scaler_paintable_snapshot (GdkPaintable *paintable,
                               GdkSnapshot  *snapshot,
                               double        width,
                               double        height)
{
  GtkScaler *self = GTK_SCALER (paintable);

  if (self->scale_factor == 1.0)
    {
      gdk_paintable_snapshot (self->paintable, snapshot, width, height);
    }
  else
    {
      graphene_matrix_t scale_matrix;

      graphene_matrix_init_scale (&scale_matrix, 1.0 / self->scale_factor, 1.0 / self->scale_factor, 1.0);
      gtk_snapshot_push_transform (snapshot, &scale_matrix);
      gdk_paintable_snapshot (self->paintable,
                              snapshot,
                              width * self->scale_factor,
                              height * self->scale_factor);
      gtk_snapshot_pop (snapshot);
    }
}
Пример #2
0
static void
gst_gl_transformation_build_mvp (GstGLTransformation * transformation)
{
  graphene_point3d_t translation_vector =
      GRAPHENE_POINT3D_INIT (transformation->xtranslation * 2.0 *
      transformation->aspect,
      transformation->ytranslation * 2.0,
      transformation->ztranslation * 2.0);

  graphene_matrix_t model_matrix;
  graphene_matrix_t projection_matrix;
  graphene_matrix_t view_matrix;
  graphene_matrix_t vp_matrix;

  graphene_vec3_t eye;
  graphene_vec3_t center;
  graphene_vec3_t up;

  graphene_vec3_init (&eye, 0.f, 0.f, 1.f);
  graphene_vec3_init (&center, 0.f, 0.f, 0.f);
  graphene_vec3_init (&up, 0.f, 1.f, 0.f);

  graphene_matrix_init_scale (&model_matrix,
      transformation->xscale, transformation->yscale, 1.0f);

  graphene_matrix_rotate (&model_matrix,
      transformation->xrotation, graphene_vec3_x_axis ());
  graphene_matrix_rotate (&model_matrix,
      transformation->yrotation, graphene_vec3_y_axis ());
  graphene_matrix_rotate (&model_matrix,
      transformation->zrotation, graphene_vec3_z_axis ());

  graphene_matrix_translate (&model_matrix, &translation_vector);

  if (transformation->ortho) {
    graphene_matrix_init_ortho (&projection_matrix,
        -transformation->aspect, transformation->aspect,
        -1, 1, transformation->znear, transformation->zfar);
  } else {
    graphene_matrix_init_perspective (&projection_matrix,
        transformation->fov,
        transformation->aspect, transformation->znear, transformation->zfar);
  }

  graphene_matrix_init_look_at (&view_matrix, &eye, &center, &up);

  graphene_matrix_multiply (&view_matrix, &projection_matrix, &vp_matrix);
  graphene_matrix_multiply (&model_matrix, &vp_matrix,
      &transformation->mvp_matrix);
}
Пример #3
0
static void
gtk_render_node_paintable_paintable_snapshot (GdkPaintable *paintable,
                                              GdkSnapshot  *snapshot,
                                              double        width,
                                              double        height)
{
  GtkRenderNodePaintable *self = GTK_RENDER_NODE_PAINTABLE (paintable);
  gboolean needs_transform;

  needs_transform = self->bounds.size.width != width ||
                    self->bounds.size.height != height;

  if (needs_transform)
    {
      graphene_matrix_t transform;

      graphene_matrix_init_scale (&transform,
                                  width / (self->bounds.size.width),
                                  height / (self->bounds.size.height),
                                  1.0);
      gtk_snapshot_push_transform (snapshot,
                                   &transform);
    }

  gtk_snapshot_offset (snapshot, -self->bounds.origin.x, -self->bounds.origin.y);

  gtk_snapshot_push_clip (snapshot, &self->bounds);

  gtk_snapshot_append_node (snapshot, self->node);
  //gtk_snapshot_append_color (snapshot, &(GdkRGBA) { 1, 0, 0, 1 }, &self->bounds);

  gtk_snapshot_pop (snapshot);

  gtk_snapshot_offset (snapshot, self->bounds.origin.x, self->bounds.origin.y);

  if (needs_transform)
    gtk_snapshot_pop (snapshot);
}