mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-12-28 06:21:14 +00:00
286b473f55
... and use it to initialize the "proper" projection matrix to use in shaders. The resulting viewport will go from top left (0,0) to bottom right (width, height) and the z clipping plane will go from -10000 to 10000.
86 lines
2.0 KiB
C
86 lines
2.0 KiB
C
#include "config.h"
|
|
|
|
#include "gskgpuimageprivate.h"
|
|
|
|
typedef struct _GskGpuImagePrivate GskGpuImagePrivate;
|
|
|
|
struct _GskGpuImagePrivate
|
|
{
|
|
GdkMemoryFormat format;
|
|
gsize width;
|
|
gsize height;
|
|
};
|
|
|
|
#define ORTHO_NEAR_PLANE -10000
|
|
#define ORTHO_FAR_PLANE 10000
|
|
|
|
G_DEFINE_TYPE_WITH_PRIVATE (GskGpuImage, gsk_gpu_image, G_TYPE_OBJECT)
|
|
|
|
static void
|
|
gsk_gpu_image_get_default_projection_matrix (GskGpuImage *self,
|
|
graphene_matrix_t *out_projection)
|
|
{
|
|
GskGpuImagePrivate *priv = gsk_gpu_image_get_instance_private (self);
|
|
|
|
graphene_matrix_init_ortho (out_projection,
|
|
0, priv->width,
|
|
0, priv->height,
|
|
ORTHO_NEAR_PLANE,
|
|
ORTHO_FAR_PLANE);
|
|
}
|
|
|
|
static void
|
|
gsk_gpu_image_class_init (GskGpuImageClass *klass)
|
|
{
|
|
klass->get_projection_matrix = gsk_gpu_image_get_default_projection_matrix;
|
|
}
|
|
|
|
static void
|
|
gsk_gpu_image_init (GskGpuImage *self)
|
|
{
|
|
}
|
|
|
|
void
|
|
gsk_gpu_image_setup (GskGpuImage *self,
|
|
GdkMemoryFormat format,
|
|
gsize width,
|
|
gsize height)
|
|
{
|
|
GskGpuImagePrivate *priv = gsk_gpu_image_get_instance_private (self);
|
|
|
|
priv->format = format;
|
|
priv->width = width;
|
|
priv->height = height;
|
|
}
|
|
|
|
GdkMemoryFormat
|
|
gsk_gpu_image_get_format (GskGpuImage *self)
|
|
{
|
|
GskGpuImagePrivate *priv = gsk_gpu_image_get_instance_private (self);
|
|
|
|
return priv->format;
|
|
}
|
|
|
|
gsize
|
|
gsk_gpu_image_get_width (GskGpuImage *self)
|
|
{
|
|
GskGpuImagePrivate *priv = gsk_gpu_image_get_instance_private (self);
|
|
|
|
return priv->width;
|
|
}
|
|
|
|
gsize
|
|
gsk_gpu_image_get_height (GskGpuImage *self)
|
|
{
|
|
GskGpuImagePrivate *priv = gsk_gpu_image_get_instance_private (self);
|
|
|
|
return priv->height;
|
|
}
|
|
|
|
void
|
|
gsk_gpu_image_get_projection_matrix (GskGpuImage *self,
|
|
graphene_matrix_t *out_projection)
|
|
{
|
|
GSK_GPU_IMAGE_GET_CLASS (self)->get_projection_matrix (self, out_projection);
|
|
}
|