mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-11-13 04:10:13 +00:00
gdk: Remove an unused texture api
gdk_gl_texture_from_surface wasn't used anywhere, so lets drop it.
This commit is contained in:
parent
a20291f235
commit
45f162fc50
121
gdk/gdkgl.c
121
gdk/gdkgl.c
@ -437,127 +437,6 @@ out:
|
||||
cairo_region_destroy (clip_region);
|
||||
}
|
||||
|
||||
/* This is always called with the paint context current */
|
||||
void
|
||||
gdk_gl_texture_from_surface (cairo_surface_t *cairo_surface,
|
||||
cairo_region_t *region)
|
||||
{
|
||||
GdkGLContext *paint_context;
|
||||
cairo_surface_t *image;
|
||||
double device_x_offset, device_y_offset;
|
||||
cairo_rectangle_int_t rect, e;
|
||||
int n_rects, i;
|
||||
GdkSurface *surface;
|
||||
int unscaled_surface_height;
|
||||
unsigned int texture_id;
|
||||
int surface_scale;
|
||||
double sx, sy;
|
||||
float umax, vmax;
|
||||
gboolean use_texture_rectangle;
|
||||
guint target;
|
||||
|
||||
paint_context = gdk_gl_context_get_current ();
|
||||
|
||||
#ifdef G_ENABLE_DEBUG
|
||||
if (paint_context != NULL)
|
||||
{
|
||||
GdkDisplay *display = gdk_draw_context_get_display (GDK_DRAW_CONTEXT (paint_context));
|
||||
|
||||
if (GDK_DISPLAY_DEBUG_CHECK (display, GL_SOFTWARE) == 0)
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (paint_context != NULL &&
|
||||
GDK_GL_CONTEXT_GET_CLASS (paint_context)->texture_from_surface &&
|
||||
GDK_GL_CONTEXT_GET_CLASS (paint_context)->texture_from_surface (paint_context, cairo_surface, region))
|
||||
return;
|
||||
|
||||
/* Software fallback */
|
||||
use_texture_rectangle = gdk_gl_context_use_texture_rectangle (paint_context);
|
||||
|
||||
surface = gdk_gl_context_get_surface (paint_context);
|
||||
surface_scale = gdk_surface_get_scale_factor (surface);
|
||||
gdk_surface_get_unscaled_size (surface, NULL, &unscaled_surface_height);
|
||||
|
||||
sx = sy = 1;
|
||||
cairo_surface_get_device_scale (cairo_surface, &sx, &sy);
|
||||
cairo_surface_get_device_offset (cairo_surface, &device_x_offset, &device_y_offset);
|
||||
|
||||
glGenTextures (1, &texture_id);
|
||||
if (use_texture_rectangle)
|
||||
target = GL_TEXTURE_RECTANGLE_ARB;
|
||||
else
|
||||
target = GL_TEXTURE_2D;
|
||||
|
||||
glBindTexture (target, texture_id);
|
||||
glEnable (GL_SCISSOR_TEST);
|
||||
|
||||
glTexParameteri (target, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
||||
glTexParameteri (target, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
||||
glTexParameteri (target, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
||||
glTexParameteri (target, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
||||
|
||||
n_rects = cairo_region_num_rectangles (region);
|
||||
|
||||
#define FLIP_Y(_y) (unscaled_surface_height - (_y))
|
||||
|
||||
for (i = 0; i < n_rects; i++)
|
||||
{
|
||||
cairo_region_get_rectangle (region, i, &rect);
|
||||
|
||||
glScissor (rect.x * surface_scale, FLIP_Y ((rect.y + rect.height) * surface_scale),
|
||||
rect.width * surface_scale, rect.height * surface_scale);
|
||||
|
||||
e = rect;
|
||||
e.x *= sx;
|
||||
e.y *= sy;
|
||||
e.x += (int)device_x_offset;
|
||||
e.y += (int)device_y_offset;
|
||||
e.width *= sx;
|
||||
e.height *= sy;
|
||||
image = cairo_surface_map_to_image (cairo_surface, &e);
|
||||
|
||||
gdk_gl_context_upload_texture (paint_context,
|
||||
cairo_image_surface_get_data (image),
|
||||
e.width,
|
||||
e.height,
|
||||
cairo_image_surface_get_stride (image),
|
||||
target);
|
||||
|
||||
cairo_surface_unmap_image (cairo_surface, image);
|
||||
|
||||
if (use_texture_rectangle)
|
||||
{
|
||||
umax = rect.width * sx;
|
||||
vmax = rect.height * sy;
|
||||
}
|
||||
else
|
||||
{
|
||||
umax = 1.0;
|
||||
vmax = 1.0;
|
||||
}
|
||||
|
||||
{
|
||||
GdkTexturedQuad quad = {
|
||||
rect.x * surface_scale, FLIP_Y(rect.y * surface_scale),
|
||||
(rect.x + rect.width) * surface_scale, FLIP_Y((rect.y + rect.height) * surface_scale),
|
||||
0, 0,
|
||||
umax, vmax,
|
||||
};
|
||||
|
||||
/* We don't want to combine the quads here, because they have different textures.
|
||||
* And we don't want to upload the unused source areas to make it one texture. */
|
||||
gdk_gl_texture_quads (paint_context, target, 1, &quad, TRUE);
|
||||
}
|
||||
}
|
||||
|
||||
#undef FLIP_Y
|
||||
|
||||
glDisable (GL_SCISSOR_TEST);
|
||||
glDeleteTextures (1, &texture_id);
|
||||
}
|
||||
|
||||
/**
|
||||
* gdk_cairo_surface_upload_to_gl:
|
||||
* @surface: a Cairo surface
|
||||
|
@ -127,8 +127,6 @@ void _gdk_event_queue_flush (GdkDisplay *display);
|
||||
|
||||
gboolean _gdk_cairo_surface_extents (cairo_surface_t *surface,
|
||||
GdkRectangle *extents);
|
||||
void gdk_gl_texture_from_surface (cairo_surface_t *surface,
|
||||
cairo_region_t *region);
|
||||
|
||||
typedef struct {
|
||||
float x1, y1, x2, y2;
|
||||
|
Loading…
Reference in New Issue
Block a user