Compare commits

..

7 Commits

Author SHA1 Message Date
Matthias Clasen
ac03248334 gridview: Rewrite size_allocate
Rewrite size_allocate to use the new split_tiles
function and the multirow helper, and move the handling
of the footer tile at the end into the regular allocation
loop.

This is preparing the code to work with sections.
For now, nothing has changed.
2023-05-27 22:23:37 -04:00
Matthias Clasen
2dcda12369 gridview: Add tests for tile split
These tests are reusing the section model plumbing
of the listitemmanager tests, and just check that
splitting tiles according to a certain number of
columns works and produces multi-row tiles starting
and ending on the first or last column.
2023-05-27 22:23:37 -04:00
Matthias Clasen
7eb2de05a0 gridview: Export some functions privately
This will let us write tests for the tile splitting code.
2023-05-27 22:23:37 -04:00
Matthias Clasen
dda24956a1 gridview: Add a function to split tiles
Break this part of size_allocate out as a separate function.
Future commits will rewrite size_allocate to make use of it.

Making this a standalone function taking just a listitemmanager
and n_columns as arguments will make it easy to write tests for it.
2023-05-27 22:23:37 -04:00
Matthias Clasen
243914ff6a gridview: Add a multi-row helper
This is another trivial helper function
that will become more interesting when sections
enter the picture.
2023-05-27 22:23:37 -04:00
Matthias Clasen
7fd42c4a05 gridview: Rewrite get_position_from_allocation
Use the new column helper, and write this function
in a way that will keep working with sections.

The most important point here is that we determine the
column that the anchor item will fall into *after*
other adjustments for position.

This means that the column will be accurate, unless n_columns
or has_sections changes between get_position_for_allocation
and size_allocate.
2023-05-27 22:23:37 -04:00
Matthias Clasen
b6d0a04199 gridview: Add a column helper
This is currently a trivial function, but it
will become more interesting when we introduce
sections.
2023-05-27 22:23:37 -04:00
144 changed files with 3359 additions and 5009 deletions

36
NEWS
View File

@@ -1,4 +1,4 @@
Overview of Changes in 4.11.3, 05-06 2023
Overview of Changes in 4.11.3, xx-xx-xxxx
=========================================
* GtkGridView:
@@ -8,9 +8,6 @@ Overview of Changes in 4.11.3, 05-06 2023
* GtkListView:
- Don't leak the factories
* GtkColumnView:
- Support displaying sections
* GtkNotebook:
- Make the pages model implement GtkSelectionModel
@@ -20,41 +17,18 @@ Overview of Changes in 4.11.3, 05-06 2023
* GtkPopoverMenu:
- Avoid unnecessary left padding
* GtkSearchEntry:
- Improve size allocation for the clear icon
* GtkBoxLayout:
- Fix a regression from recent baseline work
* CSS:
* Css:
- Add new binding-friendly css provider apis
* Theme:
- Show focus in the shortcuts window
* GDK:
- Support grayscale and alpha texture formats for loading
and saving to png and tiff, and in GL
- Fix some regressions in GL context initialization
* GSK:
- Support grayscale and alpha texture formats in the GL renderer
- Support straight alpha textures in the GL renderer
- Many improvements to the experimental Vulkan renderer
* Tests:
- Improve test coverage
* Wayland:
- Make exporting surface handles more flexible
* X11:
- Trap XRandr errors
- Stop using passive grabs during DND
* Windows:
- Many cleanups and simplifications
* Tests:
- Improve test coverage
* Build:
- Some build options have been renamed:
demos -> build-demos
@@ -74,9 +48,7 @@ Overview of Changes in 4.11.3, 05-06 2023
* Translation updates:
Basque
Catalan
Georgian
Russian
Turkish
Overview of Changes in 4.11.2, 09-05-2023

View File

@@ -30,8 +30,6 @@
#include <glib.h>
#include <gdk/version/gdkversionmacros.h>
G_BEGIN_DECLS
/**
@@ -308,20 +306,6 @@ typedef enum
* the alpha value. Since: 4.6
* @GDK_MEMORY_R32G32B32A32_FLOAT: 4 float values; for red, green, blue and
* alpha. Since: 4.6
* @GDK_MEMORY_G8A8_PREMULTIPLIED: 2 bytes; for grayscale, alpha. The color
* values are premultiplied with the alpha value. Since: 4.12
* @GDK_MEMORY_G8A8: 2 bytes; for grayscale, alpha. Since: 4.12
* @GDK_MEMORY_G8: One byte; for grayscale. The data is opaque.
* Since: 4.12
* @GDK_MEMORY_G16A16_PREMULTIPLIED: 2 guint16 values; for grayscale, alpha.
* The color values are premultiplied with the alpha value. Since: 4.12
* @GDK_MEMORY_G16A16: 2 guint16 values; for grayscale, alpha. Since: 4.12
* @GDK_MEMORY_G16: One guint16 value; for grayscale. The data is opaque.
* Since: 4.12
* @GDK_MEMORY_A8: One byte; for alpha.
* Since: 4.12
* @GDK_MEMORY_A16: One guint16 value; for alpha.
* Since: 4.12
* @GDK_MEMORY_N_FORMATS: The number of formats. This value will change as
* more formats get added, so do not rely on its concrete integer.
*
@@ -356,14 +340,6 @@ typedef enum {
GDK_MEMORY_R32G32B32_FLOAT,
GDK_MEMORY_R32G32B32A32_FLOAT_PREMULTIPLIED,
GDK_MEMORY_R32G32B32A32_FLOAT,
GDK_MEMORY_G8A8_PREMULTIPLIED GDK_AVAILABLE_ENUMERATOR_IN_4_12,
GDK_MEMORY_G8A8 GDK_AVAILABLE_ENUMERATOR_IN_4_12,
GDK_MEMORY_G8 GDK_AVAILABLE_ENUMERATOR_IN_4_12,
GDK_MEMORY_G16A16_PREMULTIPLIED GDK_AVAILABLE_ENUMERATOR_IN_4_12,
GDK_MEMORY_G16A16 GDK_AVAILABLE_ENUMERATOR_IN_4_12,
GDK_MEMORY_G16 GDK_AVAILABLE_ENUMERATOR_IN_4_12,
GDK_MEMORY_A8 GDK_AVAILABLE_ENUMERATOR_IN_4_12,
GDK_MEMORY_A16 GDK_AVAILABLE_ENUMERATOR_IN_4_12,
GDK_MEMORY_N_FORMATS
} GdkMemoryFormat;

View File

@@ -173,8 +173,12 @@ static GPrivate thread_current_context = G_PRIVATE_INIT (unref_unmasked);
static void
gdk_gl_context_clear_old_updated_area (GdkGLContext *context)
{
for (unsigned int i = 0; i < GDK_GL_MAX_TRACKED_BUFFERS; i++)
g_clear_pointer (&context->old_updated_area[i], cairo_region_destroy);
int i;
for (i = 0; i < 2; i++)
{
g_clear_pointer (&context->old_updated_area[i], cairo_region_destroy);
}
}
static void

View File

@@ -138,7 +138,6 @@ static gboolean
gdk_gl_texture_find_format (gboolean use_es,
guint gl_major,
guint gl_minor,
GdkMemoryAlpha alpha,
GLint gl_format,
GLint gl_type,
GdkMemoryFormat *out_format)
@@ -148,12 +147,8 @@ gdk_gl_texture_find_format (gboolean use_es,
for (format = 0; format < GDK_MEMORY_N_FORMATS; format++)
{
GLenum q_internal_format, q_format, q_type;
GLint q_swizzle[4];
if (gdk_memory_format_alpha (format) != alpha)
continue;
if (!gdk_memory_format_gl_format (format, use_es, gl_major, gl_minor, &q_internal_format, &q_format, &q_type, &q_swizzle))
if (!gdk_memory_format_gl_format (format, use_es, gl_major, gl_minor, &q_internal_format, &q_format, &q_type))
continue;
if (q_format != gl_format || q_type != gl_type)
@@ -172,57 +167,23 @@ gdk_gl_texture_do_download (GdkGLTexture *self,
gpointer download_)
{
GdkTexture *texture = GDK_TEXTURE (self);
GdkMemoryFormat format;
gsize expected_stride;
Download *download = download_;
GLenum gl_internal_format, gl_format, gl_type;
GLint gl_swizzle[4];
int major, minor;
format = gdk_texture_get_format (texture),
expected_stride = texture->width * gdk_memory_format_bytes_per_pixel (download->format);
gdk_gl_context_get_version (context, &major, &minor);
if (!gdk_gl_context_get_use_es (context) &&
gdk_memory_format_gl_format (format,
FALSE,
major, minor,
&gl_internal_format,
&gl_format, &gl_type, &gl_swizzle))
if (download->stride == expected_stride &&
!gdk_gl_context_get_use_es (context) &&
gdk_memory_format_gl_format (download->format, TRUE, major, minor, &gl_internal_format, &gl_format, &gl_type))
{
if (download->stride == expected_stride &&
download->format == format)
{
glGetTexImage (GL_TEXTURE_2D,
0,
gl_format,
gl_type,
download->data);
}
else
{
gsize stride = texture->width * gdk_memory_format_bytes_per_pixel (format);
guchar *pixels = g_malloc_n (stride, texture->height);
glPixelStorei (GL_PACK_ALIGNMENT, 1);
glGetTexImage (GL_TEXTURE_2D,
0,
gl_format,
gl_type,
pixels);
gdk_memory_convert (download->data,
download->stride,
download->format,
pixels,
stride,
format,
texture->width,
texture->height);
g_free (pixels);
}
glGetTexImage (GL_TEXTURE_2D,
0,
gl_format,
gl_type,
download->data);
}
else
{
@@ -235,26 +196,17 @@ gdk_gl_texture_do_download (GdkGLTexture *self,
glFramebufferTexture2D (GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, self->id, 0);
if (gdk_gl_context_check_version (context, "4.3", "3.1"))
{
gdk_gl_context_get_version (context, &major, &minor);
glGetFramebufferParameteriv (GL_FRAMEBUFFER, GL_IMPLEMENTATION_COLOR_READ_FORMAT, &gl_read_format);
glGetFramebufferParameteriv (GL_FRAMEBUFFER, GL_IMPLEMENTATION_COLOR_READ_TYPE, &gl_read_type);
if (!gdk_gl_texture_find_format (TRUE, major, minor, gdk_memory_format_alpha (format), gl_read_format, gl_read_type, &actual_format))
{
gl_read_format = GL_RGBA;
gl_read_type = GL_UNSIGNED_BYTE;
if (gdk_memory_format_alpha (format) == GDK_MEMORY_ALPHA_PREMULTIPLIED)
actual_format = GDK_MEMORY_R8G8B8A8_PREMULTIPLIED; /* pray */
else
actual_format = GDK_MEMORY_R8G8B8A8;
}
if (!gdk_gl_texture_find_format (gdk_gl_context_get_use_es (context), major, minor, gl_read_format, gl_read_type, &actual_format))
actual_format = GDK_MEMORY_R8G8B8A8_PREMULTIPLIED; /* pray */
}
else
{
gl_read_format = GL_RGBA;
gl_read_type = GL_UNSIGNED_BYTE;
if (gdk_memory_format_alpha (format) == GDK_MEMORY_ALPHA_PREMULTIPLIED)
actual_format = GDK_MEMORY_R8G8B8A8_PREMULTIPLIED; /* pray */
else
actual_format = GDK_MEMORY_R8G8B8A8;
actual_format = GDK_MEMORY_R8G8B8A8_PREMULTIPLIED;
}
if (download->format == actual_format &&
@@ -269,95 +221,19 @@ gdk_gl_texture_do_download (GdkGLTexture *self,
else
{
gsize actual_bpp = gdk_memory_format_bytes_per_pixel (actual_format);
gsize stride = actual_bpp * texture->width;
guchar *pixels = g_malloc_n (stride, texture->height);
guchar *pixels = g_malloc_n (texture->width * actual_bpp, texture->height);
glPixelStorei (GL_PACK_ALIGNMENT, 1);
glReadPixels (0, 0,
texture->width, texture->height,
gl_read_format,
gl_read_type,
pixels);
/* Fix up gles inadequacies */
if (gl_read_format == GL_RGBA &&
gl_read_type == GL_UNSIGNED_BYTE &&
(format == GDK_MEMORY_G8A8 ||
format == GDK_MEMORY_G8A8_PREMULTIPLIED ||
format == GDK_MEMORY_G8 ||
format == GDK_MEMORY_A8))
{
for (unsigned int y = 0; y < texture->height; y++)
{
for (unsigned int x = 0; x < texture->width; x++)
{
guchar *data = &pixels[y * stride + x * actual_bpp];
if (format == GDK_MEMORY_G8A8 ||
format == GDK_MEMORY_G8A8_PREMULTIPLIED)
{
data[3] = data[1];
data[1] = data[0];
data[2] = data[0];
}
else if (format == GDK_MEMORY_G8)
{
data[1] = data[0];
data[2] = data[0];
data[3] = 0xff;
}
else if (format == GDK_MEMORY_A8)
{
data[3] = data[0];
data[0] = 0;
data[1] = 0;
data[2] = 0;
}
}
}
}
if (gl_read_format == GL_RGBA &&
gl_read_type == GL_UNSIGNED_SHORT &&
(format == GDK_MEMORY_G16A16 ||
format == GDK_MEMORY_G16A16_PREMULTIPLIED ||
format == GDK_MEMORY_G16 ||
format == GDK_MEMORY_A16))
{
for (unsigned int y = 0; y < texture->height; y++)
{
for (unsigned int x = 0; x < texture->width; x++)
{
guint16 *data = (guint16 *) &pixels[y * stride + x * actual_bpp];
if (format == GDK_MEMORY_G16A16 ||
format == GDK_MEMORY_G16A16_PREMULTIPLIED)
{
data[3] = data[1];
data[1] = data[0];
data[2] = data[0];
}
else if (format == GDK_MEMORY_G16)
{
data[1] = data[0];
data[2] = data[0];
data[3] = 0xffff;
}
else if (format == GDK_MEMORY_A16)
{
data[3] = data[0];
data[0] = 0;
data[1] = 0;
data[2] = 0;
}
}
}
}
gdk_memory_convert (download->data,
download->stride,
download->format,
pixels,
stride,
texture->width * actual_bpp,
actual_format,
texture->width,
texture->height);

View File

@@ -644,18 +644,10 @@ gdk_gl_texture_builder_get_format (GdkGLTextureBuilder *self)
* The format is the preferred format the texture data should be downloaded to. The
* format must be supported by the GL version of [property@Gdk.GLTextureBuilder:context].
*
* GDK's texture download code assumes that the format corresponds to the storage
* parameters of the GL texture in an obvious way. For example, a format of
* `GDK_MEMORY_R16G16B16A16_PREMULTIPLIED` is expected to be stored as `GL_RGBA16`
* texture, and `GDK_MEMORY_G8A8` is expected to be stored as `GL_RG8` texture.
*
* Setting the right format is particularly useful when using high bit depth textures
* to preserve the bit depth, to set the correct value for unpremultiplied textures
* and to make sure opaque textures are treated as such.
*
* Non-RGBA textures need to have swizzling parameters set up properly to be usable
* in GSK's shaders.
*
* Since: 4.12
*/
void

View File

@@ -60,36 +60,6 @@ name ## _from_float (guchar *dest_data, \
} \
}
#define TYPED_GRAY_FUNCS(name, T, G, A, bpp, scale) \
static void \
name ## _to_float (float *dest, \
const guchar *src_data, \
gsize n) \
{ \
for (gsize i = 0; i < n; i++) \
{ \
T *src = (T *) (src_data + i * bpp); \
if (G >= 0) dest[0] = (float) src[G] / scale; else dest[0] = 1.0; \
dest[1] = dest[2] = dest[0]; \
if (A >= 0) dest[3] = (float) src[A] / scale; else dest[3] = 1.0; \
dest += 4; \
} \
} \
\
static void \
name ## _from_float (guchar *dest_data, \
const float *src, \
gsize n) \
{ \
for (gsize i = 0; i < n; i++) \
{ \
T *dest = (T *) (dest_data + i * bpp); \
if (G >= 0) dest[G] = CLAMP ((src[0] + src[1] + src[2]) * scale / 3.f + 0.5, 0, scale); \
if (A >= 0) dest[A] = CLAMP (src[3] * scale + 0.5, 0, scale); \
src += 4; \
} \
}
TYPED_FUNCS (b8g8r8a8_premultiplied, guchar, 2, 1, 0, 3, 4, 255)
TYPED_FUNCS (a8r8g8b8_premultiplied, guchar, 1, 2, 3, 0, 4, 255)
TYPED_FUNCS (r8g8b8a8_premultiplied, guchar, 0, 1, 2, 3, 4, 255)
@@ -102,15 +72,6 @@ TYPED_FUNCS (b8g8r8, guchar, 2, 1, 0, -1, 3, 255)
TYPED_FUNCS (r16g16b16, guint16, 0, 1, 2, -1, 6, 65535)
TYPED_FUNCS (r16g16b16a16, guint16, 0, 1, 2, 3, 8, 65535)
TYPED_GRAY_FUNCS (g8a8_premultiplied, guchar, 0, 1, 2, 255)
TYPED_GRAY_FUNCS (g8a8, guchar, 0, 1, 2, 255)
TYPED_GRAY_FUNCS (g8, guchar, 0, -1, 1, 255)
TYPED_GRAY_FUNCS (a8, guchar, -1, 0, 1, 255)
TYPED_GRAY_FUNCS (g16a16_premultiplied, guint16, 0, 1, 4, 65535)
TYPED_GRAY_FUNCS (g16a16, guint16, 0, 1, 4, 65535)
TYPED_GRAY_FUNCS (g16, guint16, 0, -1, 2, 65535)
TYPED_GRAY_FUNCS (a16, guint16, -1, 0, 2, 65535)
static void
r16g16b16_float_to_float (float *dest,
const guchar *src_data,
@@ -269,7 +230,6 @@ struct _GdkMemoryFormatDescription
guint internal_format;
guint format;
guint type;
GLint swizzle[4];
} gl;
/* no premultiplication going on here */
void (* to_float) (float *, const guchar*, gsize);
@@ -291,7 +251,7 @@ static const GdkMemoryFormatDescription memory_formats[GDK_MEMORY_N_FORMATS] = {
G_ALIGNOF (guchar),
FALSE,
{ 0, 0, G_MAXUINT, G_MAXUINT },
{ GL_RGBA8, GL_BGRA, GL_UNSIGNED_BYTE, { GL_RED, GL_GREEN, GL_BLUE, GL_ALPHA } },
{ GL_RGBA8, GL_BGRA, GL_UNSIGNED_BYTE },
b8g8r8a8_premultiplied_to_float,
b8g8r8a8_premultiplied_from_float,
},
@@ -301,7 +261,7 @@ static const GdkMemoryFormatDescription memory_formats[GDK_MEMORY_N_FORMATS] = {
G_ALIGNOF (guchar),
FALSE,
{ 0, 0, G_MAXUINT, G_MAXUINT },
{ GL_RGBA8, GL_BGRA, GDK_GL_UNSIGNED_BYTE_FLIPPED, { GL_RED, GL_GREEN, GL_BLUE, GL_ALPHA } },
{ GL_RGBA8, GL_BGRA, GDK_GL_UNSIGNED_BYTE_FLIPPED },
a8r8g8b8_premultiplied_to_float,
a8r8g8b8_premultiplied_from_float,
},
@@ -311,7 +271,7 @@ static const GdkMemoryFormatDescription memory_formats[GDK_MEMORY_N_FORMATS] = {
G_ALIGNOF (guchar),
FALSE,
{ 0, 0, 0, 0 },
{ GL_RGBA8, GL_RGBA, GL_UNSIGNED_BYTE, { GL_RED, GL_GREEN, GL_BLUE, GL_ALPHA } },
{ GL_RGBA8, GL_RGBA, GL_UNSIGNED_BYTE },
r8g8b8a8_premultiplied_to_float,
r8g8b8a8_premultiplied_from_float,
},
@@ -321,7 +281,7 @@ static const GdkMemoryFormatDescription memory_formats[GDK_MEMORY_N_FORMATS] = {
G_ALIGNOF (guchar),
FALSE,
{ 0, 0, G_MAXUINT, G_MAXUINT },
{ GL_RGBA8, GL_BGRA, GL_UNSIGNED_BYTE, { GL_RED, GL_GREEN, GL_BLUE, GL_ALPHA } },
{ GL_RGBA8, GL_BGRA, GL_UNSIGNED_BYTE },
b8g8r8a8_to_float,
b8g8r8a8_from_float,
},
@@ -331,7 +291,7 @@ static const GdkMemoryFormatDescription memory_formats[GDK_MEMORY_N_FORMATS] = {
G_ALIGNOF (guchar),
FALSE,
{ 0, 0, G_MAXUINT, G_MAXUINT },
{ GL_RGBA8, GL_RGBA, GDK_GL_UNSIGNED_BYTE_FLIPPED, { GL_RED, GL_GREEN, GL_BLUE, GL_ALPHA } },
{ GL_RGBA8, GL_RGBA, GDK_GL_UNSIGNED_BYTE_FLIPPED },
a8r8g8b8_to_float,
a8r8g8b8_from_float,
},
@@ -341,7 +301,7 @@ static const GdkMemoryFormatDescription memory_formats[GDK_MEMORY_N_FORMATS] = {
G_ALIGNOF (guchar),
FALSE,
{ 0, 0, 0, 0 },
{ GL_RGBA8, GL_RGBA, GL_UNSIGNED_BYTE, { GL_RED, GL_GREEN, GL_BLUE, GL_ALPHA } },
{ GL_RGBA8, GL_RGBA, GL_UNSIGNED_BYTE },
r8g8b8a8_to_float,
r8g8b8a8_from_float,
},
@@ -351,7 +311,7 @@ static const GdkMemoryFormatDescription memory_formats[GDK_MEMORY_N_FORMATS] = {
G_ALIGNOF (guchar),
FALSE,
{ 0, 0, G_MAXUINT, G_MAXUINT },
{ GL_RGBA8, GL_BGRA, GDK_GL_UNSIGNED_BYTE_FLIPPED, { GL_RED, GL_GREEN, GL_BLUE, GL_ALPHA } },
{ GL_RGBA8, GL_BGRA, GDK_GL_UNSIGNED_BYTE_FLIPPED },
a8b8g8r8_to_float,
a8b8g8r8_from_float,
},
@@ -361,7 +321,7 @@ static const GdkMemoryFormatDescription memory_formats[GDK_MEMORY_N_FORMATS] = {
G_ALIGNOF (guchar),
FALSE,
{ 0, 0, 0, 0 },
{ GL_RGB8, GL_RGB, GL_UNSIGNED_BYTE, { GL_RED, GL_GREEN, GL_BLUE, GL_ONE } },
{ GL_RGB8, GL_RGB, GL_UNSIGNED_BYTE },
r8g8b8_to_float,
r8g8b8_from_float,
},
@@ -371,7 +331,7 @@ static const GdkMemoryFormatDescription memory_formats[GDK_MEMORY_N_FORMATS] = {
G_ALIGNOF (guchar),
FALSE,
{ 0, 0, G_MAXUINT, G_MAXUINT },
{ GL_RGB8, GL_BGR, GL_UNSIGNED_BYTE, { GL_RED, GL_GREEN, GL_BLUE, GL_ONE } },
{ GL_RGB8, GL_BGR, GL_UNSIGNED_BYTE },
b8g8r8_to_float,
b8g8r8_from_float,
},
@@ -381,7 +341,7 @@ static const GdkMemoryFormatDescription memory_formats[GDK_MEMORY_N_FORMATS] = {
G_ALIGNOF (guint16),
TRUE,
{ 0, 0, 3, 0 },
{ GL_RGB16, GL_RGB, GL_UNSIGNED_SHORT, { GL_RED, GL_GREEN, GL_BLUE, GL_ONE } },
{ GL_RGB16, GL_RGB, GL_UNSIGNED_SHORT },
r16g16b16_to_float,
r16g16b16_from_float,
},
@@ -391,7 +351,7 @@ static const GdkMemoryFormatDescription memory_formats[GDK_MEMORY_N_FORMATS] = {
G_ALIGNOF (guint16),
TRUE,
{ 0, 0, 3, 0 },
{ GL_RGBA16, GL_RGBA, GL_UNSIGNED_SHORT, { GL_RED, GL_GREEN, GL_BLUE, GL_ALPHA } },
{ GL_RGBA16, GL_RGBA, GL_UNSIGNED_SHORT },
r16g16b16a16_to_float,
r16g16b16a16_from_float,
},
@@ -401,7 +361,7 @@ static const GdkMemoryFormatDescription memory_formats[GDK_MEMORY_N_FORMATS] = {
G_ALIGNOF (guint16),
TRUE,
{ 0, 0, 3, 0 },
{ GL_RGBA16, GL_RGBA, GL_UNSIGNED_SHORT, { GL_RED, GL_GREEN, GL_BLUE, GL_ALPHA } },
{ GL_RGBA16, GL_RGBA, GL_UNSIGNED_SHORT },
r16g16b16a16_to_float,
r16g16b16a16_from_float,
},
@@ -411,7 +371,7 @@ static const GdkMemoryFormatDescription memory_formats[GDK_MEMORY_N_FORMATS] = {
G_ALIGNOF (guint16),
TRUE,
{ 0, 0, 3, 0 },
{ GL_RGB16F, GL_RGB, GL_HALF_FLOAT, { GL_RED, GL_GREEN, GL_BLUE, GL_ONE } },
{ GL_RGB16F, GL_RGB, GL_HALF_FLOAT },
r16g16b16_float_to_float,
r16g16b16_float_from_float,
},
@@ -421,7 +381,7 @@ static const GdkMemoryFormatDescription memory_formats[GDK_MEMORY_N_FORMATS] = {
G_ALIGNOF (guint16),
TRUE,
{ 0, 0, 3, 0 },
{ GL_RGBA16F, GL_RGBA, GL_HALF_FLOAT, { GL_RED, GL_GREEN, GL_BLUE, GL_ALPHA } },
{ GL_RGBA16F, GL_RGBA, GL_HALF_FLOAT },
r16g16b16a16_float_to_float,
r16g16b16a16_float_from_float,
},
@@ -431,7 +391,7 @@ static const GdkMemoryFormatDescription memory_formats[GDK_MEMORY_N_FORMATS] = {
G_ALIGNOF (guint16),
TRUE,
{ 0, 0, 3, 0 },
{ GL_RGBA16F, GL_RGBA, GL_HALF_FLOAT, { GL_RED, GL_GREEN, GL_BLUE, GL_ALPHA } },
{ GL_RGBA16F, GL_RGBA, GL_HALF_FLOAT },
r16g16b16a16_float_to_float,
r16g16b16a16_float_from_float,
},
@@ -441,7 +401,7 @@ static const GdkMemoryFormatDescription memory_formats[GDK_MEMORY_N_FORMATS] = {
G_ALIGNOF (float),
TRUE,
{ 0, 0, 3, 0 },
{ GL_RGB32F, GL_RGB, GL_FLOAT, { GL_RED, GL_GREEN, GL_BLUE, GL_ONE } },
{ GL_RGB32F, GL_RGB, GL_FLOAT },
r32g32b32_float_to_float,
r32g32b32_float_from_float,
},
@@ -451,7 +411,7 @@ static const GdkMemoryFormatDescription memory_formats[GDK_MEMORY_N_FORMATS] = {
G_ALIGNOF (float),
TRUE,
{ 0, 0, 3, 0 },
{ GL_RGBA32F, GL_RGBA, GL_FLOAT, { GL_RED, GL_GREEN, GL_BLUE, GL_ALPHA } },
{ GL_RGBA32F, GL_RGBA, GL_FLOAT },
r32g32b32a32_float_to_float,
r32g32b32a32_float_from_float,
},
@@ -461,89 +421,9 @@ static const GdkMemoryFormatDescription memory_formats[GDK_MEMORY_N_FORMATS] = {
G_ALIGNOF (float),
TRUE,
{ 0, 0, 3, 0 },
{ GL_RGBA32F, GL_RGBA, GL_FLOAT, { GL_RED, GL_GREEN, GL_BLUE, GL_ALPHA } },
{ GL_RGBA32F, GL_RGBA, GL_FLOAT },
r32g32b32a32_float_to_float,
r32g32b32a32_float_from_float,
},
[GDK_MEMORY_G8A8_PREMULTIPLIED] = {
GDK_MEMORY_ALPHA_PREMULTIPLIED,
2,
G_ALIGNOF (guchar),
FALSE,
{ 0, 0, 3, 0 },
{ GL_RG8, GL_RG, GL_UNSIGNED_BYTE, { GL_RED, GL_RED, GL_RED, GL_GREEN } },
g8a8_premultiplied_to_float,
g8a8_premultiplied_from_float,
},
[GDK_MEMORY_G8A8] = {
GDK_MEMORY_ALPHA_STRAIGHT,
2,
G_ALIGNOF (guchar),
FALSE,
{ 0, 0, 3, 0 },
{ GL_RG8, GL_RG, GL_UNSIGNED_BYTE, { GL_RED, GL_RED, GL_RED, GL_GREEN } },
g8a8_to_float,
g8a8_from_float,
},
[GDK_MEMORY_G8] = {
GDK_MEMORY_ALPHA_OPAQUE,
1,
G_ALIGNOF (guchar),
FALSE,
{ 0, 0, 3, 0 },
{ GL_R8, GL_RED, GL_UNSIGNED_BYTE, { GL_RED, GL_RED, GL_RED, GL_ONE } },
g8_to_float,
g8_from_float,
},
[GDK_MEMORY_G16A16_PREMULTIPLIED] = {
GDK_MEMORY_ALPHA_PREMULTIPLIED,
4,
G_ALIGNOF (guint16),
TRUE,
{ 0, 0, 3, 0 },
{ GL_RG16, GL_RG, GL_UNSIGNED_SHORT, { GL_RED, GL_RED, GL_RED, GL_GREEN } },
g16a16_premultiplied_to_float,
g16a16_premultiplied_from_float,
},
[GDK_MEMORY_G16A16] = {
GDK_MEMORY_ALPHA_STRAIGHT,
4,
G_ALIGNOF (guint16),
TRUE,
{ 0, 0, 3, 0 },
{ GL_RG16, GL_RG, GL_UNSIGNED_SHORT, { GL_RED, GL_RED, GL_RED, GL_GREEN } },
g16a16_to_float,
g16a16_from_float,
},
[GDK_MEMORY_G16] = {
GDK_MEMORY_ALPHA_OPAQUE,
2,
G_ALIGNOF (guint16),
TRUE,
{ 0, 0, 3, 0 },
{ GL_R16, GL_RED, GL_UNSIGNED_SHORT, { GL_RED, GL_RED, GL_RED, GL_ONE } },
g16_to_float,
g16_from_float,
},
[GDK_MEMORY_A8] = {
GDK_MEMORY_ALPHA_STRAIGHT,
1,
G_ALIGNOF (guchar),
FALSE,
{ 0, 0, 3, 0 },
{ GL_R8, GL_RED, GL_UNSIGNED_BYTE, { GL_ONE, GL_ONE, GL_ONE, GL_RED } },
a8_to_float,
a8_from_float,
},
[GDK_MEMORY_A16] = {
GDK_MEMORY_ALPHA_STRAIGHT,
2,
G_ALIGNOF (guint16),
TRUE,
{ 0, 0, 3, 0 },
{ GL_R16, GL_RED, GL_UNSIGNED_SHORT, { GL_ONE, GL_ONE, GL_ONE, GL_RED } },
a16_to_float,
a16_from_float,
}
};
@@ -592,13 +472,14 @@ gdk_memory_format_gl_format (GdkMemoryFormat format,
guint gl_minor,
guint *out_internal_format,
guint *out_format,
guint *out_type,
GLint (*out_swizzle)[4])
guint *out_type)
{
*out_internal_format = memory_formats[format].gl.internal_format;
*out_format = memory_formats[format].gl.format;
*out_type = memory_formats[format].gl.type;
memcpy (out_swizzle, &memory_formats[format].gl.swizzle, sizeof(GLint) * 4);
if (memory_formats[format].alpha == GDK_MEMORY_ALPHA_STRAIGHT)
return FALSE;
if (gles)
{

View File

@@ -21,8 +21,6 @@
#include "gdkenums.h"
#include <epoxy/gl.h>
G_BEGIN_DECLS
typedef enum {
@@ -41,8 +39,7 @@ gboolean gdk_memory_format_gl_format (GdkMemoryFormat
guint gl_minor,
guint *out_internal_format,
guint *out_format,
guint *out_type,
GLint (*out_gizzle)[4]);
guint *out_type);
void gdk_memory_convert (guchar *dest_data,
gsize dest_stride,

View File

@@ -1053,30 +1053,26 @@ gdk_display_create_vulkan_device (GdkDisplay *display,
device_extensions = g_ptr_array_new ();
g_ptr_array_add (device_extensions, (gpointer) VK_KHR_SWAPCHAIN_EXTENSION_NAME);
g_ptr_array_add (device_extensions, (gpointer) VK_KHR_MAINTENANCE_3_EXTENSION_NAME);
g_ptr_array_add (device_extensions, (gpointer) VK_EXT_DESCRIPTOR_INDEXING_EXTENSION_NAME);
if (has_incremental_present)
g_ptr_array_add (device_extensions, (gpointer) VK_KHR_INCREMENTAL_PRESENT_EXTENSION_NAME);
GDK_DISPLAY_DEBUG (display, VULKAN, "Using Vulkan device %u, queue %u", i, j);
if (GDK_VK_CHECK (vkCreateDevice, devices[i],
&(VkDeviceCreateInfo) {
.sType = VK_STRUCTURE_TYPE_DEVICE_CREATE_INFO,
.queueCreateInfoCount = 1,
.pQueueCreateInfos = &(VkDeviceQueueCreateInfo) {
VK_STRUCTURE_TYPE_DEVICE_CREATE_INFO,
NULL,
0,
1,
&(VkDeviceQueueCreateInfo) {
.sType = VK_STRUCTURE_TYPE_DEVICE_QUEUE_CREATE_INFO,
.queueFamilyIndex = j,
.queueCount = 1,
.pQueuePriorities = (float []) { 1.0f },
},
.enabledExtensionCount = device_extensions->len,
.ppEnabledExtensionNames = (const char * const *) device_extensions->pdata,
.pNext = &(VkPhysicalDeviceDescriptorIndexingFeatures) {
.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DESCRIPTOR_INDEXING_FEATURES,
.descriptorBindingPartiallyBound = VK_TRUE,
.descriptorBindingVariableDescriptorCount = VK_TRUE,
.descriptorBindingSampledImageUpdateAfterBind = VK_TRUE,
}
0,
NULL,
device_extensions->len,
(const char * const *) device_extensions->pdata
},
NULL,
&display->vk_device) != VK_SUCCESS)
@@ -1148,7 +1144,6 @@ gdk_display_create_vulkan_instance (GdkDisplay *display,
used_extensions = g_ptr_array_new ();
g_ptr_array_add (used_extensions, (gpointer) VK_KHR_SURFACE_EXTENSION_NAME);
g_ptr_array_add (used_extensions, (gpointer) VK_KHR_GET_PHYSICAL_DEVICE_PROPERTIES_2_EXTENSION_NAME);
g_ptr_array_add (used_extensions, (gpointer) GDK_DISPLAY_GET_CLASS (display)->vk_extension_name);
for (i = 0; i < n_extensions; i++)
@@ -1220,7 +1215,7 @@ gdk_display_create_vulkan_instance (GdkDisplay *display,
.enabledLayerCount = used_layers->len,
.ppEnabledLayerNames = (const char * const *) used_layers->pdata,
.enabledExtensionCount = used_extensions->len,
.ppEnabledExtensionNames = (const char * const *) used_extensions->pdata,
.ppEnabledExtensionNames = (const char * const *) used_extensions->pdata
},
NULL,
&display->vk_instance);

View File

@@ -183,7 +183,8 @@ gdk_load_png (GBytes *bytes,
if (color_type == PNG_COLOR_TYPE_PALETTE)
png_set_palette_to_rgb (png);
if (color_type == PNG_COLOR_TYPE_GRAY)
if (color_type == PNG_COLOR_TYPE_GRAY ||
color_type == PNG_COLOR_TYPE_GRAY_ALPHA)
png_set_expand_gray_1_2_4_to_8 (png);
if (png_get_valid (png, info, PNG_INFO_tRNS))
@@ -192,6 +193,10 @@ gdk_load_png (GBytes *bytes,
if (depth < 8)
png_set_packing (png);
if (color_type == PNG_COLOR_TYPE_GRAY ||
color_type == PNG_COLOR_TYPE_GRAY_ALPHA)
png_set_gray_to_rgb (png);
if (interlace != PNG_INTERLACE_NONE)
png_set_interlace_handling (png);
@@ -234,26 +239,6 @@ gdk_load_png (GBytes *bytes,
format = GDK_MEMORY_R16G16B16;
}
break;
case PNG_COLOR_TYPE_GRAY:
if (depth == 8)
{
format = GDK_MEMORY_G8;
}
else if (depth == 16)
{
format = GDK_MEMORY_G16;
}
break;
case PNG_COLOR_TYPE_GRAY_ALPHA:
if (depth == 8)
{
format = GDK_MEMORY_G8A8;
}
else if (depth == 16)
{
format = GDK_MEMORY_G16A16;
}
break;
default:
png_destroy_read_struct (&png, &info, NULL);
g_set_error (error,
@@ -364,34 +349,6 @@ gdk_save_png (GdkTexture *texture)
depth = 16;
break;
case GDK_MEMORY_G8:
format = GDK_MEMORY_G8;
png_format = PNG_COLOR_TYPE_GRAY;
depth = 8;
break;
case GDK_MEMORY_G8A8_PREMULTIPLIED:
case GDK_MEMORY_G8A8:
case GDK_MEMORY_A8:
format = GDK_MEMORY_G8A8;
png_format = PNG_COLOR_TYPE_GRAY_ALPHA;
depth = 8;
break;
case GDK_MEMORY_G16:
format = GDK_MEMORY_G16;
png_format = PNG_COLOR_TYPE_GRAY;
depth = 16;
break;
case GDK_MEMORY_G16A16_PREMULTIPLIED:
case GDK_MEMORY_G16A16:
case GDK_MEMORY_A16:
format = GDK_MEMORY_G16A16;
png_format = PNG_COLOR_TYPE_GRAY_ALPHA;
depth = 16;
break;
case GDK_MEMORY_N_FORMATS:
default:
g_assert_not_reached ();

View File

@@ -229,36 +229,27 @@ struct _FormatData {
guint16 samples_per_pixel;
guint16 sample_format;
guint16 alpha_samples;
guint16 photometric;
};
static const FormatData format_data[] = {
[GDK_MEMORY_B8G8R8A8_PREMULTIPLIED] = { GDK_MEMORY_R8G8B8A8_PREMULTIPLIED, 8, 4, SAMPLEFORMAT_UINT, EXTRASAMPLE_ASSOCALPHA, PHOTOMETRIC_RGB },
[GDK_MEMORY_A8R8G8B8_PREMULTIPLIED] = { GDK_MEMORY_R8G8B8A8_PREMULTIPLIED, 8, 4, SAMPLEFORMAT_UINT, EXTRASAMPLE_ASSOCALPHA, PHOTOMETRIC_RGB },
[GDK_MEMORY_R8G8B8A8_PREMULTIPLIED] = { GDK_MEMORY_R8G8B8A8_PREMULTIPLIED, 8, 4, SAMPLEFORMAT_UINT, EXTRASAMPLE_ASSOCALPHA, PHOTOMETRIC_RGB },
[GDK_MEMORY_B8G8R8A8] = { GDK_MEMORY_R8G8B8A8, 8, 4, SAMPLEFORMAT_UINT, EXTRASAMPLE_UNASSALPHA, PHOTOMETRIC_RGB },
[GDK_MEMORY_A8R8G8B8] = { GDK_MEMORY_R8G8B8A8, 8, 4, SAMPLEFORMAT_UINT, EXTRASAMPLE_UNASSALPHA, PHOTOMETRIC_RGB },
[GDK_MEMORY_R8G8B8A8] = { GDK_MEMORY_R8G8B8A8, 8, 4, SAMPLEFORMAT_UINT, EXTRASAMPLE_UNASSALPHA, PHOTOMETRIC_RGB },
[GDK_MEMORY_A8B8G8R8] = { GDK_MEMORY_R8G8B8A8, 8, 4, SAMPLEFORMAT_UINT, EXTRASAMPLE_UNASSALPHA, PHOTOMETRIC_RGB },
[GDK_MEMORY_R8G8B8] = { GDK_MEMORY_R8G8B8, 8, 3, SAMPLEFORMAT_UINT, 0, PHOTOMETRIC_RGB },
[GDK_MEMORY_B8G8R8] = { GDK_MEMORY_R8G8B8, 8, 3, SAMPLEFORMAT_UINT, 0, PHOTOMETRIC_RGB },
[GDK_MEMORY_R16G16B16] = { GDK_MEMORY_R16G16B16, 16, 3, SAMPLEFORMAT_UINT, 0, PHOTOMETRIC_RGB },
[GDK_MEMORY_R16G16B16A16_PREMULTIPLIED] = { GDK_MEMORY_R16G16B16A16_PREMULTIPLIED, 16, 4, SAMPLEFORMAT_UINT, EXTRASAMPLE_ASSOCALPHA, PHOTOMETRIC_RGB },
[GDK_MEMORY_R16G16B16A16] = { GDK_MEMORY_R16G16B16A16, 16, 4, SAMPLEFORMAT_UINT, EXTRASAMPLE_UNASSALPHA, PHOTOMETRIC_RGB },
[GDK_MEMORY_R16G16B16_FLOAT] = { GDK_MEMORY_R16G16B16_FLOAT, 16, 3, SAMPLEFORMAT_IEEEFP, 0, PHOTOMETRIC_RGB },
[GDK_MEMORY_R16G16B16A16_FLOAT_PREMULTIPLIED] = { GDK_MEMORY_R16G16B16A16_FLOAT_PREMULTIPLIED, 16, 4, SAMPLEFORMAT_IEEEFP, EXTRASAMPLE_ASSOCALPHA, PHOTOMETRIC_RGB },
[GDK_MEMORY_R16G16B16A16_FLOAT] = { GDK_MEMORY_R16G16B16A16_FLOAT, 16, 4, SAMPLEFORMAT_IEEEFP, EXTRASAMPLE_UNASSALPHA, PHOTOMETRIC_RGB },
[GDK_MEMORY_R32G32B32_FLOAT] = { GDK_MEMORY_R32G32B32_FLOAT, 32, 3, SAMPLEFORMAT_IEEEFP, 0, PHOTOMETRIC_RGB },
[GDK_MEMORY_R32G32B32A32_FLOAT_PREMULTIPLIED] = { GDK_MEMORY_R32G32B32A32_FLOAT_PREMULTIPLIED, 32, 4, SAMPLEFORMAT_IEEEFP, EXTRASAMPLE_ASSOCALPHA, PHOTOMETRIC_RGB },
[GDK_MEMORY_R32G32B32A32_FLOAT] = { GDK_MEMORY_R32G32B32A32_FLOAT, 32, 4, SAMPLEFORMAT_IEEEFP, EXTRASAMPLE_UNASSALPHA, PHOTOMETRIC_RGB },
[GDK_MEMORY_G8A8_PREMULTIPLIED] = { GDK_MEMORY_G8A8_PREMULTIPLIED, 8, 2, SAMPLEFORMAT_UINT, EXTRASAMPLE_ASSOCALPHA, PHOTOMETRIC_MINISBLACK },
[GDK_MEMORY_G8A8] = { GDK_MEMORY_G8A8, 8, 2, SAMPLEFORMAT_UINT, EXTRASAMPLE_UNASSALPHA, PHOTOMETRIC_MINISBLACK },
[GDK_MEMORY_G8] = { GDK_MEMORY_G8, 8, 1, SAMPLEFORMAT_UINT, 0, PHOTOMETRIC_MINISBLACK },
[GDK_MEMORY_G16A16_PREMULTIPLIED] = { GDK_MEMORY_G16A16_PREMULTIPLIED, 16, 2, SAMPLEFORMAT_UINT, EXTRASAMPLE_ASSOCALPHA, PHOTOMETRIC_MINISBLACK },
[GDK_MEMORY_G16A16] = { GDK_MEMORY_G16A16, 16, 2, SAMPLEFORMAT_UINT, EXTRASAMPLE_UNASSALPHA, PHOTOMETRIC_MINISBLACK },
[GDK_MEMORY_G16] = { GDK_MEMORY_G16, 16, 1, SAMPLEFORMAT_UINT, 0, PHOTOMETRIC_MINISBLACK },
[GDK_MEMORY_A8] = { GDK_MEMORY_G8A8, 8, 2, SAMPLEFORMAT_UINT, EXTRASAMPLE_UNASSALPHA, PHOTOMETRIC_MINISBLACK },
[GDK_MEMORY_A16] = { GDK_MEMORY_G16A16, 16, 2, SAMPLEFORMAT_UINT, EXTRASAMPLE_UNASSALPHA, PHOTOMETRIC_MINISBLACK },
[GDK_MEMORY_B8G8R8A8_PREMULTIPLIED] = { GDK_MEMORY_R8G8B8A8_PREMULTIPLIED, 8, 4, SAMPLEFORMAT_UINT, EXTRASAMPLE_ASSOCALPHA },
[GDK_MEMORY_A8R8G8B8_PREMULTIPLIED] = { GDK_MEMORY_R8G8B8A8_PREMULTIPLIED, 8, 4, SAMPLEFORMAT_UINT, EXTRASAMPLE_ASSOCALPHA },
[GDK_MEMORY_R8G8B8A8_PREMULTIPLIED] = { GDK_MEMORY_R8G8B8A8_PREMULTIPLIED, 8, 4, SAMPLEFORMAT_UINT, EXTRASAMPLE_ASSOCALPHA },
[GDK_MEMORY_B8G8R8A8] = { GDK_MEMORY_R8G8B8A8, 8, 4, SAMPLEFORMAT_UINT, EXTRASAMPLE_UNASSALPHA },
[GDK_MEMORY_A8R8G8B8] = { GDK_MEMORY_R8G8B8A8, 8, 4, SAMPLEFORMAT_UINT, EXTRASAMPLE_UNASSALPHA },
[GDK_MEMORY_R8G8B8A8] = { GDK_MEMORY_R8G8B8A8, 8, 4, SAMPLEFORMAT_UINT, EXTRASAMPLE_UNASSALPHA },
[GDK_MEMORY_A8B8G8R8] = { GDK_MEMORY_R8G8B8A8, 8, 4, SAMPLEFORMAT_UINT, EXTRASAMPLE_UNASSALPHA },
[GDK_MEMORY_R8G8B8] = { GDK_MEMORY_R8G8B8, 8, 3, SAMPLEFORMAT_UINT, 0 },
[GDK_MEMORY_B8G8R8] = { GDK_MEMORY_R8G8B8, 8, 3, SAMPLEFORMAT_UINT, 0 },
[GDK_MEMORY_R16G16B16] = { GDK_MEMORY_R16G16B16, 16, 3, SAMPLEFORMAT_UINT, 0 },
[GDK_MEMORY_R16G16B16A16_PREMULTIPLIED] = { GDK_MEMORY_R16G16B16A16_PREMULTIPLIED, 16, 4, SAMPLEFORMAT_UINT, EXTRASAMPLE_ASSOCALPHA },
[GDK_MEMORY_R16G16B16A16] = { GDK_MEMORY_R16G16B16A16, 16, 4, SAMPLEFORMAT_UINT, EXTRASAMPLE_UNASSALPHA },
[GDK_MEMORY_R16G16B16_FLOAT] = { GDK_MEMORY_R16G16B16_FLOAT, 16, 3, SAMPLEFORMAT_IEEEFP, 0 },
[GDK_MEMORY_R16G16B16A16_FLOAT_PREMULTIPLIED] = { GDK_MEMORY_R16G16B16A16_FLOAT_PREMULTIPLIED, 16, 4, SAMPLEFORMAT_IEEEFP, EXTRASAMPLE_ASSOCALPHA },
[GDK_MEMORY_R16G16B16A16_FLOAT] = { GDK_MEMORY_R16G16B16A16_FLOAT, 16, 4, SAMPLEFORMAT_IEEEFP, EXTRASAMPLE_UNASSALPHA },
[GDK_MEMORY_R32G32B32_FLOAT] = { GDK_MEMORY_R32G32B32_FLOAT, 32, 3, SAMPLEFORMAT_IEEEFP, 0 },
[GDK_MEMORY_R32G32B32A32_FLOAT_PREMULTIPLIED] = { GDK_MEMORY_R32G32B32A32_FLOAT_PREMULTIPLIED, 32, 4, SAMPLEFORMAT_IEEEFP, EXTRASAMPLE_ASSOCALPHA },
[GDK_MEMORY_R32G32B32A32_FLOAT] = { GDK_MEMORY_R32G32B32A32_FLOAT, 32, 4, SAMPLEFORMAT_IEEEFP, EXTRASAMPLE_UNASSALPHA },
};
/* if this fails, somebody forgot to add formats above */
@@ -298,7 +289,7 @@ gdk_save_tiff (GdkTexture *texture)
if (fdata->alpha_samples)
TIFFSetField (tif, TIFFTAG_EXTRASAMPLES, 1, &fdata->alpha_samples);
TIFFSetField (tif, TIFFTAG_PHOTOMETRIC, fdata->photometric);
TIFFSetField (tif, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_RGB);
TIFFSetField (tif, TIFFTAG_PLANARCONFIG, PLANARCONFIG_CONTIG);
gdk_texture_downloader_init (&downloader, texture);
@@ -406,7 +397,7 @@ gdk_load_tiff (GBytes *input_bytes,
TIFFGetFieldDefaulted (tif, TIFFTAG_IMAGEWIDTH, &width);
TIFFGetFieldDefaulted (tif, TIFFTAG_IMAGELENGTH, &height);
if (samples_per_pixel == 2 || samples_per_pixel == 4)
if (samples_per_pixel == 4)
{
guint16 extra;
guint16 *extra_types;
@@ -435,15 +426,14 @@ gdk_load_tiff (GBytes *input_bytes,
if (format_data[format].sample_format == sample_format &&
format_data[format].bits_per_sample == bits_per_sample &&
format_data[format].samples_per_pixel == samples_per_pixel &&
format_data[format].alpha_samples == alpha_samples &&
format_data[format].photometric == photometric)
format_data[format].alpha_samples == alpha_samples)
{
break;
}
}
if (format == G_N_ELEMENTS(format_data) ||
(photometric != PHOTOMETRIC_RGB && photometric != PHOTOMETRIC_MINISBLACK) ||
photometric != PHOTOMETRIC_RGB ||
planarconfig != PLANARCONFIG_CONTIG ||
TIFFIsTiled (tif) ||
orientation != ORIENTATION_TOPLEFT)

View File

@@ -344,14 +344,14 @@ create_pixel_format (GdkGLVersion *version,
if (gdk_gl_version_get_major (version) >= 4)
{
attrs[1] = (CGLPixelFormatAttribute)kCGLOGLPVersion_GL4_Core;
if (CHECK (error, CGLChoosePixelFormat (attrs, &format, &n_format)))
if (CGLChoosePixelFormat (attrs, &format, &n_format))
return g_steal_pointer (&format);
}
if (gdk_gl_version_greater_equal (version, &GDK_GL_MIN_GL_VERSION))
{
attrs[1] = (CGLPixelFormatAttribute)kCGLOGLPVersion_GL3_Core;
if (CHECK (error, CGLChoosePixelFormat (attrs, &format, &n_format)))
if (CGLChoosePixelFormat (attrs, &format, &n_format))
return g_steal_pointer (&format);
}
@@ -396,7 +396,7 @@ gdk_macos_gl_context_real_realize (GdkGLContext *context,
gdk_gl_context_get_matching_version (context,
GDK_GL_API_GL,
FALSE,
&min_version);
&version);
display = gdk_gl_context_get_display (context);
shared = gdk_display_get_gl_context (display);

View File

@@ -207,7 +207,7 @@ wl_cursor_create_from_xcursor_images(struct wl_cursor_theme *theme,
{
char *path;
XcursorImages *images;
struct wl_cursor *cursor;
struct cursor *cursor;
struct cursor_image *image;
int i, nbytes;
unsigned int load_size;
@@ -240,16 +240,17 @@ wl_cursor_create_from_xcursor_images(struct wl_cursor_theme *theme,
return NULL;
}
cursor->images =
malloc(images->nimage * sizeof cursor->images[0]);
if (!cursor->images) {
cursor->cursor.images =
malloc(images->nimage * sizeof cursor->cursor.images[0]);
if (!cursor->cursor.images) {
free(cursor);
xcursor_images_destroy (images);
return NULL;
}
cursor->name = strdup(name);
cursor->size = load_size;
cursor->cursor.name = strdup(name);
cursor->cursor.size = load_size;
cursor->total_delay = 0;
for (i = 0; i < images->nimage; i++) {
image = malloc(sizeof *image);
@@ -290,13 +291,14 @@ wl_cursor_create_from_xcursor_images(struct wl_cursor_theme *theme,
}
}
}
cursor->images[i] = (struct wl_cursor_image *) image;
cursor->total_delay += image->image.delay;
cursor->cursor.images[i] = (struct wl_cursor_image *) image;
}
cursor->image_count = i;
cursor->cursor.image_count = i;
if (cursor->image_count == 0) {
free(cursor->name);
free(cursor->images);
if (cursor->cursor.image_count == 0) {
free(cursor->cursor.name);
free(cursor->cursor.images);
free(cursor);
xcursor_images_destroy (images);
return NULL;
@@ -304,7 +306,7 @@ wl_cursor_create_from_xcursor_images(struct wl_cursor_theme *theme,
xcursor_images_destroy (images);
return cursor;
return &cursor->cursor;
}
static void

View File

@@ -1436,7 +1436,7 @@ register_clipboard_notification ()
wclass.lpszClassName = "GdkClipboardNotification";
wclass.lpfnWndProc = _clipboard_window_procedure;
wclass.hInstance = this_module ();
wclass.hInstance = _gdk_dll_hinstance;
wclass.cbWndExtra = sizeof (GdkWin32ClipboardThread *);
klass = RegisterClass (&wclass);
@@ -1446,7 +1446,7 @@ register_clipboard_notification ()
clipboard_thread_data->clipboard_window = CreateWindow (MAKEINTRESOURCE (klass),
NULL, WS_POPUP,
0, 0, 0, 0, NULL, NULL,
this_module (), NULL);
_gdk_dll_hinstance, NULL);
if (clipboard_thread_data->clipboard_window == NULL)
goto failed;
@@ -1471,7 +1471,7 @@ register_clipboard_notification ()
failed:
g_critical ("Failed to install clipboard viewer");
UnregisterClass (MAKEINTRESOURCE (klass), this_module ());
UnregisterClass (MAKEINTRESOURCE (klass), _gdk_dll_hinstance);
return FALSE;
}

View File

@@ -417,12 +417,13 @@ hcursor_from_x_cursor (int i,
#undef SET_BIT
#undef RESET_BIT
rv = CreateCursor (NULL, cursors[i].hotx, cursors[i].hoty,
rv = CreateCursor (_gdk_app_hmodule, cursors[i].hotx, cursors[i].hoty,
w, h, and_plane, xor_plane);
}
else
{
rv = CreateCursor (NULL, 0, 0, w, h, and_plane, xor_plane);
rv = CreateCursor (_gdk_app_hmodule, 0, 0,
w, h, and_plane, xor_plane);
}
if (rv == NULL)
@@ -465,7 +466,7 @@ win32_cursor_create_win32hcursor (GdkWin32Display *display,
break;
case GDK_WIN32_CURSOR_LOAD_FROM_RESOURCE_THIS:
result = gdk_win32_hcursor_new (display,
LoadImageA (GetModuleHandle (NULL),
LoadImageA (_gdk_app_hmodule,
(const char *) cursor->resource_name,
IMAGE_CURSOR,
cursor->width,
@@ -475,7 +476,7 @@ win32_cursor_create_win32hcursor (GdkWin32Display *display,
break;
case GDK_WIN32_CURSOR_LOAD_FROM_RESOURCE_GTK:
result = gdk_win32_hcursor_new (display,
LoadImageA (this_module (),
LoadImageA (_gdk_dll_hinstance,
(const char *) cursor->resource_name,
IMAGE_CURSOR,
cursor->width,
@@ -857,7 +858,9 @@ create_blank_win32hcursor (GdkWin32Display *display)
xor_plane = g_malloc ((w/8) * h);
memset (xor_plane, 0, (w/8) * h);
rv = CreateCursor (NULL, 0, 0, w, h, and_plane, xor_plane);
rv = CreateCursor (_gdk_app_hmodule, 0, 0,
w, h, and_plane, xor_plane);
if (rv == NULL)
WIN32_API_FAILED ("CreateCursor");
@@ -868,7 +871,6 @@ static GdkWin32HCursor *
gdk_win32hcursor_create_for_name (GdkWin32Display *display,
const char *name)
{
const HINSTANCE hinstance = GetModuleHandle (NULL);
GdkWin32HCursor *win32hcursor = NULL;
/* Blank cursor case */
@@ -883,7 +885,7 @@ gdk_win32hcursor_create_for_name (GdkWin32Display *display,
/* Allow to load named cursor resources linked into the executable.
* Cursors obtained with LoadCursor() cannot be destroyed.
*/
return gdk_win32_hcursor_new (display, LoadCursor (hinstance, name), FALSE);
return gdk_win32_hcursor_new (display, LoadCursor (_gdk_app_hmodule, name), FALSE);
}
static HICON
@@ -1450,6 +1452,27 @@ pixbuf_to_hicon (GdkPixbuf *pixbuf,
return icon;
}
HICON
_gdk_win32_texture_to_hicon (GdkTexture *texture)
{
cairo_surface_t *surface;
GdkPixbuf *pixbuf;
int width, height;
HICON icon;
surface = gdk_texture_download_surface (texture);
width = cairo_image_surface_get_width (surface);
height = cairo_image_surface_get_height (surface);
pixbuf = gdk_pixbuf_get_from_surface (surface, 0, 0, width, height);
icon = pixbuf_to_hicon (pixbuf, TRUE, 0, 0);
g_object_unref (pixbuf);
return icon;
}
/**
* gdk_win32_display_get_win32hcursor:
* @display: (type GdkWin32Display): a `GdkDisplay`

View File

@@ -292,7 +292,6 @@ _gdk_win32_display_init_monitors (GdkWin32Display *win32_display)
if (!w32_ex_monitor->remove)
continue;
w32_ex_monitor->hmonitor = NULL;
g_list_store_remove (G_LIST_STORE (win32_display->monitors), i);
gdk_monitor_invalidate (ex_monitor);
}
@@ -481,7 +480,7 @@ register_display_change_notification (GdkDisplay *display)
wclass.lpszClassName = "GdkDisplayChange";
wclass.lpfnWndProc = display_change_window_procedure;
wclass.hInstance = this_module ();
wclass.hInstance = _gdk_app_hmodule;
wclass.style = CS_OWNDC;
klass = RegisterClass (&wclass);
@@ -490,10 +489,10 @@ register_display_change_notification (GdkDisplay *display)
display_win32->hwnd = CreateWindow (MAKEINTRESOURCE (klass),
NULL, WS_POPUP,
0, 0, 0, 0, NULL, NULL,
this_module (), NULL);
_gdk_app_hmodule, NULL);
if (!display_win32->hwnd)
{
UnregisterClass (MAKEINTRESOURCE (klass), this_module ());
UnregisterClass (MAKEINTRESOURCE (klass), _gdk_app_hmodule);
}
}
}

View File

@@ -413,7 +413,8 @@ set_up_low_level_keyboard_hook (void)
hook_handle = SetWindowsHookEx (WH_KEYBOARD_LL,
(HOOKPROC) low_level_keyboard_proc,
this_module (), 0);
_gdk_dll_hinstance,
0);
if (hook_handle != NULL)
keyboard_hook = hook_handle;

View File

@@ -261,7 +261,7 @@ create_dummy_gl_window (void)
wclass.lpszClassName = "GdkGLDummyWindow";
wclass.lpfnWndProc = DefWindowProc;
wclass.hInstance = this_module ();
wclass.hInstance = _gdk_app_hmodule;
wclass.style = CS_OWNDC;
klass = RegisterClass (&wclass);
@@ -270,10 +270,10 @@ create_dummy_gl_window (void)
hwnd = CreateWindow (MAKEINTRESOURCE (klass),
NULL, WS_POPUP,
0, 0, 0, 0, NULL, NULL,
this_module (), NULL);
_gdk_app_hmodule, NULL);
if (!hwnd)
{
UnregisterClass (MAKEINTRESOURCE (klass), this_module ());
UnregisterClass (MAKEINTRESOURCE (klass), _gdk_app_hmodule);
}
}

View File

@@ -30,6 +30,10 @@
GdkDisplay *_gdk_display = NULL;
GdkDeviceManagerWin32 *_gdk_device_manager = NULL;
HDC _gdk_display_hdc;
HINSTANCE _gdk_dll_hinstance;
HINSTANCE _gdk_app_hmodule;
int _gdk_input_ignore_core;
HKL _gdk_input_locale;

View File

@@ -1003,7 +1003,7 @@ winpointer_notif_window_create (void)
wndclassex.cbSize = sizeof (wndclassex);
wndclassex.lpszClassName = L"GdkWin32WinpointerNotificationsWindowClass";
wndclassex.lpfnWndProc = winpointer_notifications_window_procedure;
wndclassex.hInstance = this_module ();
wndclassex.hInstance = _gdk_dll_hinstance;
if ((notifications_window_class = RegisterClassExW (&wndclassex)) == 0)
{
@@ -1018,7 +1018,7 @@ winpointer_notif_window_create (void)
0, 0, 0, 0,
HWND_MESSAGE,
NULL,
this_module (),
_gdk_dll_hinstance,
NULL)))
{
WIN32_API_FAILED ("CreateWindowExW");

View File

@@ -576,6 +576,19 @@ gdk_mod_mask_to_mod_bits (GdkModifierType mod_mask)
return result;
}
/* keypad decimal mark depends on active keyboard layout
* return current decimal mark as unicode character
*/
guint32
_gdk_win32_keymap_get_decimal_mark (GdkWin32Keymap *keymap)
{
guint32 c = MapVirtualKeyW (VK_DECIMAL, MAPVK_VK_TO_CHAR);
if (!c)
c = (guint32) '.';
return c;
}
static void
update_keymap (GdkWin32Keymap *keymap)
{

View File

@@ -45,6 +45,9 @@
#include <wintab.h>
#include <imm.h>
/* for CFSTR_SHELLIDLIST */
#include <shlobj.h>
static gboolean gdk_synchronize = FALSE;
/* Whether GDK initialized COM */
@@ -63,6 +66,8 @@ _gdk_win32_surfaceing_init (void)
if (gdk_synchronize)
GdiSetBatchLimit (1);
_gdk_app_hmodule = GetModuleHandle (NULL);
_gdk_display_hdc = CreateDC ("DISPLAY", NULL, NULL, NULL);
_gdk_input_locale = GetKeyboardLayout (0);
_gdk_win32_keymap_set_active_layout (win32_keymap, _gdk_input_locale);
@@ -182,6 +187,135 @@ static_printf (const char *format,
return retval;
}
void
_gdk_win32_print_paletteentries (const PALETTEENTRY *pep,
const int nentries)
{
char buf[20];
int i;
for (i = 0; i < nentries; i++)
g_print (" %3d %02x: %02x %02x %02x%s\n",
i, i,
pep[i].peRed, pep[i].peGreen, pep[i].peBlue,
(pep[i].peFlags == 0 ? "" :
(pep[i].peFlags == PC_EXPLICIT ? " PC_EXPLICIT" :
(pep[i].peFlags == PC_NOCOLLAPSE ? " PC_NOCOLLAPSE" :
(pep[i].peFlags == PC_RESERVED ? " PC_RESERVED" :
(g_sprintf (buf, " %d", pep[i].peFlags), buf))))));
}
void
_gdk_win32_print_system_palette (void)
{
PALETTEENTRY *pe;
int k;
k = GetSystemPaletteEntries (_gdk_display_hdc, 0, 0, NULL);
pe = g_new (PALETTEENTRY, k);
k = GetSystemPaletteEntries (_gdk_display_hdc, 0, k, pe);
if (!k)
g_print ("GetSystemPaletteEntries failed: %s\n",
g_win32_error_message (GetLastError ()));
else
{
g_print ("System palette: %d entries\n", k);
_gdk_win32_print_paletteentries (pe, k);
}
g_free (pe);
}
static int
palette_size (HPALETTE hpal)
{
WORD npal = 0;
if (!GetObject (hpal, sizeof (npal), &npal))
WIN32_GDI_FAILED ("GetObject (HPALETTE)");
return npal;
}
void
_gdk_win32_print_hpalette (HPALETTE hpal)
{
PALETTEENTRY *pe;
int n, npal;
npal = palette_size (hpal);
pe = g_new (PALETTEENTRY, npal);
n = GetPaletteEntries (hpal, 0, npal, pe);
if (!n)
g_print ("HPALETTE %p: GetPaletteEntries failed: %s\n",
hpal, g_win32_error_message (GetLastError ()));
else
{
g_print ("HPALETTE %p: %d (%d) entries\n", hpal, n, npal);
_gdk_win32_print_paletteentries (pe, n);
}
g_free (pe);
}
void
_gdk_win32_print_dc (HDC hdc)
{
HGDIOBJ obj;
LOGBRUSH logbrush;
EXTLOGPEN extlogpen;
HRGN hrgn;
RECT rect;
int flag;
g_print ("%p:\n", hdc);
obj = GetCurrentObject (hdc, OBJ_BRUSH);
GetObject (obj, sizeof (LOGBRUSH), &logbrush);
g_print ("brush: %s color=%06lx hatch=%p\n",
_gdk_win32_lbstyle_to_string (logbrush.lbStyle),
logbrush.lbColor, (gpointer) logbrush.lbHatch);
obj = GetCurrentObject (hdc, OBJ_PEN);
GetObject (obj, sizeof (EXTLOGPEN), &extlogpen);
g_print ("pen: %s %s %s %s w=%d %s\n",
_gdk_win32_pstype_to_string (extlogpen.elpPenStyle),
_gdk_win32_psstyle_to_string (extlogpen.elpPenStyle),
_gdk_win32_psendcap_to_string (extlogpen.elpPenStyle),
_gdk_win32_psjoin_to_string (extlogpen.elpPenStyle),
(int) extlogpen.elpWidth,
_gdk_win32_lbstyle_to_string (extlogpen.elpBrushStyle));
g_print ("rop2: %s textcolor=%06lx\n",
_gdk_win32_rop2_to_string (GetROP2 (hdc)),
GetTextColor (hdc));
hrgn = CreateRectRgn (0, 0, 0, 0);
if ((flag = GetClipRgn (hdc, hrgn)) == -1)
WIN32_API_FAILED ("GetClipRgn");
else if (flag == 0)
g_print ("no clip region\n");
else if (flag == 1)
{
GetRgnBox (hrgn, &rect);
g_print ("clip region: %p bbox: %s\n",
hrgn, _gdk_win32_rect_to_string (&rect));
}
DeleteObject (hrgn);
}
char *
_gdk_win32_drag_protocol_to_string (GdkDragProtocol protocol)
{
switch (protocol)
{
#define CASE(x) case GDK_DRAG_PROTO_##x: return #x
CASE (NONE);
CASE (WIN32_DROPFILES);
CASE (OLE2);
#undef CASE
default: return static_printf ("illegal_%d", protocol);
}
/* NOTREACHED */
return NULL;
}
char *
_gdk_win32_surface_state_to_string (GdkToplevelState state)
{
@@ -344,7 +478,7 @@ _gdk_win32_drag_action_to_string (GdkDragAction actions)
return static_printf ("%s", buf);
}
static char *
char *
_gdk_win32_rop2_to_string (int rop2)
{
switch (rop2)
@@ -373,7 +507,7 @@ _gdk_win32_rop2_to_string (int rop2)
return NULL;
}
static char *
char *
_gdk_win32_lbstyle_to_string (UINT brush_style)
{
switch (brush_style)
@@ -392,7 +526,7 @@ _gdk_win32_lbstyle_to_string (UINT brush_style)
return NULL;
}
static char *
char *
_gdk_win32_pstype_to_string (DWORD pen_style)
{
switch (pen_style & PS_TYPE_MASK)
@@ -405,7 +539,7 @@ _gdk_win32_pstype_to_string (DWORD pen_style)
return NULL;
}
static char *
char *
_gdk_win32_psstyle_to_string (DWORD pen_style)
{
switch (pen_style & PS_STYLE_MASK)
@@ -427,7 +561,7 @@ _gdk_win32_psstyle_to_string (DWORD pen_style)
return NULL;
}
static char *
char *
_gdk_win32_psendcap_to_string (DWORD pen_style)
{
switch (pen_style & PS_ENDCAP_MASK)
@@ -443,7 +577,7 @@ _gdk_win32_psendcap_to_string (DWORD pen_style)
return NULL;
}
static char *
char *
_gdk_win32_psjoin_to_string (DWORD pen_style)
{
switch (pen_style & PS_JOIN_MASK)
@@ -459,56 +593,6 @@ _gdk_win32_psjoin_to_string (DWORD pen_style)
return NULL;
}
void
_gdk_win32_print_dc (HDC hdc)
{
HGDIOBJ obj;
LOGBRUSH logbrush;
EXTLOGPEN extlogpen;
HRGN hrgn;
RECT rect;
int flag;
g_print ("%p:\n", hdc);
obj = GetCurrentObject (hdc, OBJ_BRUSH);
GetObject (obj, sizeof (LOGBRUSH), &logbrush);
g_print ("brush: %s color=%06lx hatch=%p\n",
_gdk_win32_lbstyle_to_string (logbrush.lbStyle),
logbrush.lbColor, (gpointer) logbrush.lbHatch);
obj = GetCurrentObject (hdc, OBJ_PEN);
GetObject (obj, sizeof (EXTLOGPEN), &extlogpen);
g_print ("pen: %s %s %s %s w=%d %s\n",
_gdk_win32_pstype_to_string (extlogpen.elpPenStyle),
_gdk_win32_psstyle_to_string (extlogpen.elpPenStyle),
_gdk_win32_psendcap_to_string (extlogpen.elpPenStyle),
_gdk_win32_psjoin_to_string (extlogpen.elpPenStyle),
(int) extlogpen.elpWidth,
_gdk_win32_lbstyle_to_string (extlogpen.elpBrushStyle));
g_print ("rop2: %s textcolor=%06lx\n",
_gdk_win32_rop2_to_string (GetROP2 (hdc)),
GetTextColor (hdc));
hrgn = CreateRectRgn (0, 0, 0, 0);
if ((flag = GetClipRgn (hdc, hrgn)) == -1)
WIN32_API_FAILED ("GetClipRgn");
else if (flag == 0)
g_print ("no clip region\n");
else if (flag == 1)
{
GetRgnBox (hrgn, &rect);
g_print ("clip region: %p bbox: %s\n",
hrgn, _gdk_win32_rect_to_string (&rect));
}
DeleteObject (hrgn);
}
char *
_gdk_win32_message_to_string (UINT msg)
{
@@ -809,6 +893,26 @@ _gdk_win32_cf_to_string (UINT format)
}
}
char *
_gdk_win32_data_to_string (const guchar *data,
int nbytes)
{
GString *s = g_string_new ("");
int i;
char *retval;
for (i = 0; i < nbytes; i++)
if (data[i] >=' ' && data[i] <= '~')
g_string_append_printf (s, "%c ", data[i]);
else
g_string_append_printf (s, "%02X ", data[i]);
retval = static_printf ("%s", s->str);
g_string_free (s, TRUE);
return retval;
}
char *
_gdk_win32_rect_to_string (const RECT *rect)
{
@@ -817,4 +921,34 @@ _gdk_win32_rect_to_string (const RECT *rect)
rect->left, rect->top);
}
char *
_gdk_win32_gdkrectangle_to_string (const GdkRectangle *rect)
{
return static_printf ("%dx%d@%+d%+d",
rect->width, rect->height,
rect->x, rect->y);
}
char *
_gdk_win32_cairo_region_to_string (const cairo_region_t *rgn)
{
cairo_rectangle_int_t extents;
cairo_region_get_extents (rgn, &extents);
return static_printf ("%dx%d@%+d%+d",
extents.width, extents.height,
extents.x, extents.y);
}
char *
_gdk_win32_surface_description (GdkSurface *d)
{
g_return_val_if_fail (GDK_IS_SURFACE (d), NULL);
return static_printf ("%s:%p:%dx%d",
G_OBJECT_TYPE_NAME (d),
GDK_SURFACE_HWND (d),
gdk_surface_get_width (GDK_SURFACE (d)),
gdk_surface_get_height (GDK_SURFACE (d)));
}
#endif /* G_ENABLE_DEBUG */

View File

@@ -443,6 +443,9 @@ populate_monitor_devices_from_display_config (GPtrArray *monitors)
char *path, *path_lower;
DISPLAYCONFIG_RATIONAL *refresh;
if ((dispconf_paths[path_index].flags & DISPLAYCONFIG_PATH_ACTIVE) == 0)
continue;
tdn.header.type = DISPLAYCONFIG_DEVICE_INFO_GET_TARGET_NAME;
tdn.header.size = sizeof (tdn);
tdn.header.adapterId = dispconf_paths[path_index].targetInfo.adapterId;
@@ -478,12 +481,6 @@ populate_monitor_devices_from_display_config (GPtrArray *monitors)
if (w32mon == NULL)
continue;
if ((dispconf_paths[path_index].flags & DISPLAYCONFIG_PATH_ACTIVE) == 0)
{
w32mon->remove = TRUE;
continue;
}
mon = GDK_MONITOR (w32mon);
if (!tdn.flags.friendlyNameForced)
@@ -601,8 +598,6 @@ enum_monitor (HMONITOR hmonitor,
if (w32mon == NULL)
continue;
w32mon->hmonitor = hmonitor;
}
else
{

View File

@@ -35,9 +35,6 @@ struct _GdkWin32Monitor
/* Device instance path (used to match GdkWin32Monitor to monitor device) */
char *instance_path;
/* MOnitor handle (used to fullscreen windows on monitors) */
HMONITOR hmonitor;
/* TRUE if monitor is made up by us
* (this happens when system has logical monitors, but no physical ones).
*/

View File

@@ -15,9 +15,14 @@
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
/*
* Modified by the GTK+ Team and others 1997-2000. See the AUTHORS
* file for a list of people on the GTK+ Team. See the ChangeLog
* files for a list of changes. These files are distributed with
* GTK+ at ftp://ftp.gtk.org/pub/gtk/.
*/
#include "config.h"
#pragma once
#include <gdk/gdkcursorprivate.h>
#include <gdk/gdkdebugprivate.h>
@@ -27,6 +32,10 @@
#include <gdk/win32/gdkwin32keys.h>
#include <gdk/win32/gdkdevicemanager-win32.h>
#include <gdk/win32/gdkclipdrop-win32.h>
//#include <gdk/win32/gdkselection-win32.h>
#include "config.h"
/* Old debug macros */
@@ -45,6 +54,62 @@
#endif
/* Make up for some minor w32api or MSVC6 header lossage */
#ifndef PS_JOIN_MASK
#define PS_JOIN_MASK (PS_JOIN_BEVEL|PS_JOIN_MITER|PS_JOIN_ROUND)
#endif
#ifndef FS_VIETNAMESE
#define FS_VIETNAMESE 0x100
#endif
#ifndef WM_GETOBJECT
#define WM_GETOBJECT 0x3D
#endif
#ifndef WM_NCXBUTTONDOWN
#define WM_NCXBUTTONDOWN 0xAB
#endif
#ifndef WM_NCXBUTTONUP
#define WM_NCXBUTTONUP 0xAC
#endif
#ifndef WM_NCXBUTTONDBLCLK
#define WM_NCXBUTTONDBLCLK 0xAD
#endif
#ifndef WM_CHANGEUISTATE
#define WM_CHANGEUISTATE 0x127
#endif
#ifndef WM_UPDATEUISTATE
#define WM_UPDATEUISTATE 0x128
#endif
#ifndef WM_QUERYUISTATE
#define WM_QUERYUISTATE 0x129
#endif
#ifndef WM_XBUTTONDOWN
#define WM_XBUTTONDOWN 0x20B
#endif
#ifndef WM_XBUTTONUP
#define WM_XBUTTONUP 0x20C
#endif
#ifndef WM_XBUTTONDBLCLK
#define WM_XBUTTONDBLCLK 0x20D
#endif
#ifndef WM_NCMOUSEHOVER
#define WM_NCMOUSEHOVER 0x2A0
#endif
#ifndef WM_NCMOUSELEAVE
#define WM_NCMOUSELEAVE 0x2A2
#endif
#ifndef WM_APPCOMMAND
#define WM_APPCOMMAND 0x319
#endif
#ifndef WM_MOUSEHWHEEL
#define WM_MOUSEHWHEEL 0x20E
#endif
#ifndef WM_DPICHANGED
#define WM_DPICHANGED 0x02E0
#endif
/* According to
* http://blog.airesoft.co.uk/2009/11/wm_messages/
* this is the actual internal name MS uses for this undocumented message.
@@ -57,6 +122,11 @@
#define WM_SYSMENU 0x313
#endif
#ifndef CF_DIBV5
#define CF_DIBV5 17
#endif
/* Define some combinations of GdkDebugFlags */
#define GDK_DEBUG_EVENTS_OR_INPUT (GDK_DEBUG_EVENTS|GDK_DEBUG_INPUT)
#define GDK_DEBUG_MISC_OR_EVENTS (GDK_DEBUG_MISC|GDK_DEBUG_EVENTS)
@@ -70,6 +140,22 @@ GdkWin32Screen *GDK_SURFACE_SCREEN(GObject *win);
*/
#define SWP_NOZORDER_SPECIFIED HWND_TOP
typedef struct _GdkWin32SingleFont GdkWin32SingleFont;
struct _GdkWin32SingleFont
{
HFONT hfont;
UINT charset;
UINT codepage;
FONTSIGNATURE fs;
};
typedef enum {
GDK_WIN32_PE_STATIC,
GDK_WIN32_PE_AVAILABLE,
GDK_WIN32_PE_INUSE
} GdkWin32PalEntryState;
typedef enum
{
GDK_DRAG_PROTO_NONE = 0,
@@ -77,23 +163,51 @@ typedef enum
GDK_DRAG_PROTO_OLE2,
} GdkDragProtocol;
GType _gdk_gc_win32_get_type (void);
gulong _gdk_win32_get_next_tick (gulong suggested_tick);
BOOL _gdk_win32_get_cursor_pos (LPPOINT lpPoint);
void _gdk_surface_init_position (GdkSurface *window);
void _gdk_surface_move_resize_child (GdkSurface *window,
int x,
int y,
int width,
int height);
gboolean _gdk_win32_surface_enable_transparency (GdkSurface *window);
/* GdkSurfaceImpl methods */
void _gdk_win32_surface_scroll (GdkSurface *window,
int dx,
int dy);
void _gdk_win32_surface_move_region (GdkSurface *window,
const cairo_region_t *region,
int dx,
int dy);
void _gdk_win32_selection_init (void);
void _gdk_win32_dnd_exit (void);
void gdk_win32_handle_table_insert (HANDLE *handle,
gpointer data);
void gdk_win32_handle_table_remove (HANDLE handle);
HRGN _gdk_win32_cairo_region_to_hrgn (const cairo_region_t *region,
int x_origin,
int y_origin);
cairo_region_t *_gdk_win32_hrgn_to_region (HRGN hrgn,
guint scale);
void _gdk_win32_adjust_client_rect (GdkSurface *window,
RECT *RECT);
void _gdk_selection_property_delete (GdkSurface *);
void _gdk_push_modal_window (GdkSurface *window);
void _gdk_remove_modal_window (GdkSurface *window);
GdkSurface *_gdk_modal_current (void);
@@ -103,22 +217,41 @@ gboolean gdk_win32_ensure_com (void);
gboolean gdk_win32_ensure_ole (void);
#ifdef G_ENABLE_DEBUG
void _gdk_win32_print_paletteentries (const PALETTEENTRY *pep,
const int nentries);
void _gdk_win32_print_system_palette (void);
void _gdk_win32_print_hpalette (HPALETTE hpal);
void _gdk_win32_print_dc (HDC hdc);
char *_gdk_win32_drag_protocol_to_string (GdkDragProtocol protocol);
char *_gdk_win32_surface_state_to_string (GdkToplevelState state);
char *_gdk_win32_surface_style_to_string (LONG style);
char *_gdk_win32_surface_exstyle_to_string (LONG style);
char *_gdk_win32_surface_pos_bits_to_string (UINT flags);
char *_gdk_win32_drag_action_to_string (GdkDragAction actions);
char *_gdk_win32_surface_description (GdkSurface *d);
char *_gdk_win32_rop2_to_string (int rop2);
char *_gdk_win32_lbstyle_to_string (UINT brush_style);
char *_gdk_win32_pstype_to_string (DWORD pen_style);
char *_gdk_win32_psstyle_to_string (DWORD pen_style);
char *_gdk_win32_psendcap_to_string (DWORD pen_style);
char *_gdk_win32_psjoin_to_string (DWORD pen_style);
char *_gdk_win32_message_to_string (UINT msg);
char *_gdk_win32_key_to_string (LONG lParam);
char *_gdk_win32_cf_to_string (UINT format);
char *_gdk_win32_data_to_string (const guchar*data,
int nbytes);
char *_gdk_win32_rect_to_string (const RECT *rect);
char *_gdk_win32_gdkrectangle_to_string (const GdkRectangle *rect);
char *_gdk_win32_cairo_region_to_string (const cairo_region_t *box);
void _gdk_win32_print_event (GdkEvent *event);
#endif
char *_gdk_win32_last_error_string (void);
void _gdk_win32_api_failed (const char *where,
const char *api);
void _gdk_other_api_failed (const char *where,
@@ -151,6 +284,10 @@ extern GdkDisplay *_gdk_display;
extern GdkDeviceManagerWin32 *_gdk_device_manager;
extern HDC _gdk_display_hdc;
extern HINSTANCE _gdk_dll_hinstance;
extern HINSTANCE _gdk_app_hmodule;
extern int _gdk_input_ignore_core;
/* These are thread specific, but GDK/win32 works OK only when invoked
@@ -167,6 +304,8 @@ extern GdkWin32Clipdrop *_win32_clipdrop;
/* Used to identify the main thread */
extern GThread *_win32_main_thread;
void _gdk_win32_dnd_do_dragdrop (void);
typedef enum {
GDK_WIN32_MODAL_OP_NONE = 0x0,
GDK_WIN32_MODAL_OP_SIZE = 0x1 << 0,
@@ -185,9 +324,16 @@ extern HWND _modal_move_resize_window;
void _gdk_win32_begin_modal_call (GdkWin32ModalOpKind kind);
void _gdk_win32_end_modal_call (GdkWin32ModalOpKind kind);
/* Convert a pixbuf to an HICON (or HCURSOR). Supports alpha under
* Windows XP, thresholds alpha otherwise.
*/
HICON _gdk_win32_texture_to_hicon (GdkTexture *texture);
void _gdk_win32_display_init_cursors (GdkWin32Display *display);
void _gdk_win32_display_finalize_cursors (GdkWin32Display *display);
void _gdk_win32_display_update_cursors (GdkWin32Display *display);
GdkCursor *_gdk_win32_display_get_cursor_for_name (GdkDisplay *display, const char * cursor_name);
GdkCursor *gdk_win32_display_cursor_from_hcursor (GdkDisplay *display, HCURSOR hcursor);
typedef struct _Win32CursorTheme Win32CursorTheme;
@@ -221,6 +367,9 @@ Win32Cursor * win32_cursor_theme_get_cursor (Win32CursorTheme *theme,
void win32_cursor_theme_destroy (Win32CursorTheme *theme);
Win32CursorTheme *_gdk_win32_display_get_cursor_theme (GdkWin32Display *win32_display);
/* GdkDisplay member functions */
GList *_gdk_win32_display_list_devices (GdkDisplay *dpy);
gboolean _gdk_win32_display_has_pending (GdkDisplay *display);
void _gdk_win32_display_queue_events (GdkDisplay *display);
@@ -246,11 +395,16 @@ GdkDrag *_gdk_win32_surface_drag_begin (GdkSurface *window,
/* Stray GdkWin32Screen members */
gboolean _gdk_win32_get_setting (const char *name, GValue *value);
void _gdk_win32_screen_on_displaychange_event (GdkWin32Screen *screen);
GdkSurface *gdk_win32_screen_get_root_window (GdkWin32Screen *screen);
GdkSurface *gdk_win32_display_get_root_window (GdkDisplay *display);
/* Distributed display manager implementation */
GdkDisplay *_gdk_win32_display_open (const char *display_name);
void _gdk_win32_append_event (GdkEvent *event);
guint32 _gdk_win32_keymap_get_decimal_mark (GdkWin32Keymap *keymap);
void _gdk_win32_surface_handle_aerosnap (GdkSurface *window,
GdkWin32AeroSnapCombo combo);
@@ -295,15 +449,8 @@ gboolean _gdk_win32_check_processor (GdkWin32ProcessorCheckType check_type);
GdkPixbuf *gdk_win32_icon_to_pixbuf_libgtk_only (HICON hicon,
double *x_hot,
double *y_hot);
HICON gdk_win32_pixbuf_to_hicon_libgtk_only (GdkPixbuf *pixbuf);
void gdk_win32_set_modal_dialog_libgtk_only (HWND window);
gpointer gdk_win32_handle_table_lookup_ (HWND handle);
extern IMAGE_DOS_HEADER __ImageBase;
static inline HMODULE
this_module (void)
{
return (HMODULE) &__ImageBase;
}

View File

@@ -113,15 +113,7 @@ _gdk_win32_get_setting (const char *name,
}
else if (strcmp ("gtk-font-name", name) == 0)
{
char *font_name = NULL;
HDC hdc = NULL;
if ((hdc = GetDC (HWND_DESKTOP)) != NULL)
{
font_name = _get_system_font_name (hdc);
ReleaseDC (HWND_DESKTOP, hdc);
hdc = NULL;
}
char *font_name = _get_system_font_name (_gdk_display_hdc);
if (font_name)
{

View File

@@ -50,7 +50,6 @@
#include "gdkdisplay-win32.h"
#include "gdkdevice-win32.h"
#include "gdkcairocontext-win32.h"
#include "gdkmonitor-win32.h"
#include <cairo-win32.h>
#include <dwmapi.h>
@@ -339,7 +338,7 @@ RegisterGdkClass (GType wtype)
wcl.lpfnWndProc = _gdk_win32_surface_procedure;
wcl.cbClsExtra = 0;
wcl.cbWndExtra = 0;
wcl.hInstance = this_module ();
wcl.hInstance = _gdk_dll_hinstance;
wcl.hIcon = 0;
wcl.hIconSm = 0;
@@ -356,7 +355,7 @@ RegisterGdkClass (GType wtype)
if (0 == hAppIcon && 0 == hAppIconSm)
{
// fallback : load icon from GTK DLL
if (0 != GetModuleFileName (this_module (), sLoc, MAX_PATH))
if (0 != GetModuleFileName (_gdk_dll_hinstance, sLoc, MAX_PATH))
{
ExtractIconEx (sLoc, 0, &hAppIcon, &hAppIconSm, 1);
}
@@ -493,7 +492,7 @@ gdk_win32_surface_constructed (GObject *object)
CW_USEDEFAULT, CW_USEDEFAULT,
owner,
NULL,
this_module (),
_gdk_dll_hinstance,
surface);
if (impl->handle == NULL)
{
@@ -626,8 +625,7 @@ get_outer_rect (GdkSurface *window,
}
static void
gdk_win32_surface_fullscreen (GdkSurface *window,
GdkMonitor *monitor);
gdk_win32_surface_fullscreen (GdkSurface *window);
static void
show_window_internal (GdkSurface *window,
@@ -791,7 +789,11 @@ show_window_internal (GdkSurface *window,
}
if (window->state & GDK_TOPLEVEL_STATE_MAXIMIZED)
if (window->state & GDK_TOPLEVEL_STATE_FULLSCREEN)
{
gdk_win32_surface_fullscreen (window);
}
else if (window->state & GDK_TOPLEVEL_STATE_MAXIMIZED)
{
GtkShowWindow (window, SW_MAXIMIZE);
}
@@ -2404,7 +2406,7 @@ RegisterGdkDumbClass ()
wcl.lpfnWndProc = DefWindowProcW;
wcl.cbClsExtra = 0;
wcl.cbWndExtra = 0;
wcl.hInstance = this_module ();
wcl.hInstance = _gdk_dll_hinstance;
wcl.hIcon = 0;
wcl.hIconSm = 0;
wcl.lpszMenuName = NULL;
@@ -2445,7 +2447,7 @@ ensure_snap_indicator_exists (GdkW32DragMoveResizeContext *context)
0, 0,
NULL,
NULL,
this_module (),
_gdk_dll_hinstance,
NULL);
context->shape_indicator = handle;
@@ -4006,12 +4008,11 @@ gdk_win32_surface_unmaximize (GdkSurface *surface)
}
static void
gdk_win32_surface_fullscreen (GdkSurface *window,
GdkMonitor *monitor)
gdk_win32_surface_fullscreen (GdkSurface *window)
{
int x, y, width, height;
FullscreenInfo *fi;
HMONITOR hmonitor = NULL;
HMONITOR monitor;
MONITORINFO mi;
g_return_if_fail (GDK_IS_SURFACE (window));
@@ -4024,14 +4025,9 @@ gdk_win32_surface_fullscreen (GdkSurface *window,
{
GdkWin32Surface *impl = GDK_WIN32_SURFACE (window);
if (monitor && GDK_IS_WIN32_MONITOR (monitor))
hmonitor = GDK_WIN32_MONITOR (monitor)->hmonitor;
if (!hmonitor)
hmonitor = MonitorFromWindow (GDK_SURFACE_HWND (window), MONITOR_DEFAULTTONEAREST);
monitor = MonitorFromWindow (GDK_SURFACE_HWND (window), MONITOR_DEFAULTTONEAREST);
mi.cbSize = sizeof (mi);
if (hmonitor && GetMonitorInfo (hmonitor, &mi))
if (monitor && GetMonitorInfo (monitor, &mi))
{
x = mi.rcMonitor.left;
y = mi.rcMonitor.top;
@@ -4873,16 +4869,9 @@ gdk_win32_toplevel_present (GdkToplevel *toplevel,
if (gdk_toplevel_layout_get_fullscreen (layout, &fullscreen))
{
if (fullscreen)
{
GdkMonitor *monitor;
monitor = gdk_toplevel_layout_get_fullscreen_monitor (layout);
gdk_win32_surface_fullscreen (surface, monitor);
}
gdk_win32_surface_fullscreen (surface);
else
{
gdk_win32_surface_unfullscreen (surface);
}
gdk_win32_surface_unfullscreen (surface);
}
gdk_win32_surface_show (surface, FALSE);

View File

@@ -30,6 +30,8 @@
#include "gdkprivate-win32.h"
#include "gdkwin32misc.h"
extern HINSTANCE _gdk_dll_hinstance;
G_DEFINE_TYPE (GdkWin32VulkanContext, gdk_win32_vulkan_context, GDK_TYPE_VULKAN_CONTEXT)
static VkResult
@@ -45,7 +47,7 @@ gdk_win32_vulkan_context_create_surface (GdkVulkanContext *context,
info.sType = VK_STRUCTURE_TYPE_WIN32_SURFACE_CREATE_INFO_KHR;
info.pNext = NULL;
info.flags = 0;
info.hinstance = this_module ();
info.hinstance = _gdk_dll_hinstance;
info.hwnd = GDK_SURFACE_HWND (window);
/* This is necessary so that Vulkan sees the Window.

View File

@@ -134,6 +134,35 @@ struct _GdkX11DragClass
GdkDragClass parent_class;
};
typedef struct {
int keysym;
int modifiers;
} GrabKey;
static GrabKey grab_keys[] = {
{ XK_Escape, 0 },
{ XK_space, 0 },
{ XK_KP_Space, 0 },
{ XK_Return, 0 },
{ XK_KP_Enter, 0 },
{ XK_Up, 0 },
{ XK_Up, Mod1Mask },
{ XK_Down, 0 },
{ XK_Down, Mod1Mask },
{ XK_Left, 0 },
{ XK_Left, Mod1Mask },
{ XK_Right, 0 },
{ XK_Right, Mod1Mask },
{ XK_KP_Up, 0 },
{ XK_KP_Up, Mod1Mask },
{ XK_KP_Down, 0 },
{ XK_KP_Down, Mod1Mask },
{ XK_KP_Left, 0 },
{ XK_KP_Left, Mod1Mask },
{ XK_KP_Right, 0 },
{ XK_KP_Right, Mod1Mask }
};
/* Forward declarations */
static GdkSurfaceCache *gdk_surface_cache_ref (GdkSurfaceCache *cache);
@@ -1832,15 +1861,20 @@ drag_grab (GdkDrag *drag)
{
GdkX11Drag *x11_drag = GDK_X11_DRAG (drag);
GdkSeatCapabilities capabilities;
GdkDisplay *display;
Window root;
GdkSeat *seat;
int keycode, i;
GdkCursor *cursor;
if (!x11_drag->ipc_surface)
return FALSE;
display = gdk_drag_get_display (drag);
root = GDK_DISPLAY_XROOTWIN (display);
seat = gdk_device_get_seat (gdk_drag_get_device (drag));
capabilities = GDK_SEAT_CAPABILITY_ALL_POINTING;
capabilities = GDK_SEAT_CAPABILITY_ALL_POINTING | GDK_SEAT_CAPABILITY_KEYBOARD;
cursor = gdk_drag_get_cursor (drag, x11_drag->current_action);
g_set_object (&x11_drag->cursor, cursor);
@@ -1852,6 +1886,46 @@ drag_grab (GdkDrag *drag)
g_set_object (&x11_drag->grab_seat, seat);
gdk_x11_display_error_trap_push (display);
for (i = 0; i < G_N_ELEMENTS (grab_keys); ++i)
{
int deviceid = gdk_x11_device_get_id (gdk_seat_get_keyboard (seat));
unsigned char mask[XIMaskLen(XI_LASTEVENT)];
XIGrabModifiers mods;
XIEventMask evmask;
int num_mods;
keycode = XKeysymToKeycode (GDK_DISPLAY_XDISPLAY (display),
grab_keys[i].keysym);
if (keycode == NoSymbol)
continue;
memset (mask, 0, sizeof (mask));
XISetMask (mask, XI_KeyPress);
XISetMask (mask, XI_KeyRelease);
evmask.deviceid = deviceid;
evmask.mask_len = sizeof (mask);
evmask.mask = mask;
num_mods = 1;
mods.modifiers = grab_keys[i].modifiers;
XIGrabKeycode (GDK_DISPLAY_XDISPLAY (display),
deviceid,
keycode,
root,
GrabModeAsync,
GrabModeAsync,
False,
&evmask,
num_mods,
&mods);
}
gdk_x11_display_error_trap_pop_ignored (display);
return TRUE;
}
@@ -1859,13 +1933,41 @@ static void
drag_ungrab (GdkDrag *drag)
{
GdkX11Drag *x11_drag = GDK_X11_DRAG (drag);
GdkDisplay *display;
GdkDevice *keyboard;
Window root;
int keycode, i;
if (!x11_drag->grab_seat)
return;
gdk_seat_ungrab (x11_drag->grab_seat);
display = gdk_drag_get_display (drag);
keyboard = gdk_seat_get_keyboard (x11_drag->grab_seat);
root = GDK_DISPLAY_XROOTWIN (display);
g_clear_object (&x11_drag->grab_seat);
for (i = 0; i < G_N_ELEMENTS (grab_keys); ++i)
{
XIGrabModifiers mods;
int num_mods;
keycode = XKeysymToKeycode (GDK_DISPLAY_XDISPLAY (display),
grab_keys[i].keysym);
if (keycode == NoSymbol)
continue;
num_mods = 1;
mods.modifiers = grab_keys[i].modifiers;
XIUngrabKeycode (GDK_DISPLAY_XDISPLAY (display),
gdk_x11_device_get_id (keyboard),
keycode,
root,
num_mods,
&mods);
}
}
GdkDrag *
@@ -2089,6 +2191,103 @@ gdk_dnd_handle_motion_event (GdkDrag *drag,
return TRUE;
}
static gboolean
gdk_dnd_handle_key_event (GdkDrag *drag,
GdkEvent *event)
{
GdkX11Drag *x11_drag = GDK_X11_DRAG (drag);
GdkModifierType state;
GdkDevice *pointer;
GdkSeat *seat;
int dx, dy;
dx = dy = 0;
state = gdk_event_get_modifier_state (event);
seat = gdk_event_get_seat (event);
pointer = gdk_seat_get_pointer (seat);
if (event->event_type == GDK_KEY_PRESS)
{
guint keyval = gdk_key_event_get_keyval (event);
switch (keyval)
{
case GDK_KEY_Escape:
gdk_drag_cancel (drag, GDK_DRAG_CANCEL_USER_CANCELLED);
return TRUE;
case GDK_KEY_space:
case GDK_KEY_Return:
case GDK_KEY_ISO_Enter:
case GDK_KEY_KP_Enter:
case GDK_KEY_KP_Space:
if ((gdk_drag_get_selected_action (drag) != 0) &&
(x11_drag->proxy_xid != None))
{
g_signal_emit_by_name (drag, "drop-performed");
}
else
gdk_drag_cancel (drag, GDK_DRAG_CANCEL_NO_TARGET);
return TRUE;
case GDK_KEY_Up:
case GDK_KEY_KP_Up:
dy = (state & GDK_ALT_MASK) ? -BIG_STEP : -SMALL_STEP;
break;
case GDK_KEY_Down:
case GDK_KEY_KP_Down:
dy = (state & GDK_ALT_MASK) ? BIG_STEP : SMALL_STEP;
break;
case GDK_KEY_Left:
case GDK_KEY_KP_Left:
dx = (state & GDK_ALT_MASK) ? -BIG_STEP : -SMALL_STEP;
break;
case GDK_KEY_Right:
case GDK_KEY_KP_Right:
dx = (state & GDK_ALT_MASK) ? BIG_STEP : SMALL_STEP;
break;
default:
break;
}
}
/* The state is not yet updated in the event, so we need
* to query it here. We could use XGetModifierMapping, but
* that would be overkill.
*/
gdk_x11_device_xi2_query_state (pointer, NULL, NULL, NULL, &state);
if (dx != 0 || dy != 0)
{
GdkDisplay *display;
Display *xdisplay;
GdkX11Screen *screen;
Window dest;
x11_drag->last_x += dx;
x11_drag->last_y += dy;
display = gdk_event_get_display ((GdkEvent *)event);
xdisplay = GDK_DISPLAY_XDISPLAY (display);
screen = GDK_X11_DISPLAY (display)->screen;
dest = GDK_SCREEN_XROOTWIN (screen);
XWarpPointer (xdisplay, None, dest, 0, 0, 0, 0,
round (x11_drag->last_x * screen->surface_scale),
round (x11_drag->last_y * screen->surface_scale));
}
gdk_drag_update (drag, x11_drag->last_x, x11_drag->last_y, state,
gdk_event_get_time (event));
return TRUE;
}
static gboolean
gdk_dnd_handle_grab_broken_event (GdkDrag *drag,
GdkEvent *event)
@@ -2155,6 +2354,10 @@ gdk_x11_drag_handle_event (GdkDrag *drag,
case GDK_BUTTON_RELEASE:
return gdk_dnd_handle_button_event (drag, event);
case GDK_KEY_PRESS:
case GDK_KEY_RELEASE:
return gdk_dnd_handle_key_event (drag, event);
case GDK_GRAB_BROKEN:
return gdk_dnd_handle_grab_broken_event (drag, event);

View File

@@ -543,14 +543,14 @@ gdk_x11_context_create_glx_context (GdkGLContext *context,
if (share != NULL)
share_glx = GDK_X11_GL_CONTEXT_GLX (share);
gdk_x11_display_error_trap_push (display);
supported_versions = gdk_gl_versions_get_for_api (api);
for (j = 0; gdk_gl_version_greater_equal (&supported_versions[j], &version); j++)
{
context_attribs [major_idx] = gdk_gl_version_get_major (&supported_versions[j]);
context_attribs [minor_idx] = gdk_gl_version_get_minor (&supported_versions[j]);
gdk_x11_display_error_trap_push (display);
/* If we don't have access to GLX_ARB_create_context_profile, then
* we have to fall back to the old GLX 1.3 API.
*/
@@ -568,19 +568,22 @@ gdk_x11_context_create_glx_context (GdkGLContext *context,
True,
context_attribs);
if (ctx == NULL)
{
gdk_x11_display_error_trap_pop_ignored (display);
}
else if (gdk_x11_display_error_trap_pop (display))
{
glXDestroyContext (dpy, ctx);
ctx = NULL;
}
else
if (ctx)
break;
}
if (ctx == NULL)
{
gdk_x11_display_error_trap_pop_ignored (display);
return 0;
}
if (gdk_x11_display_error_trap_pop (display))
{
glXDestroyContext (dpy, ctx);
return 0;
}
GDK_DISPLAY_DEBUG (display, OPENGL,
"Realized GLX context[%p], %s, version: %d.%d",
context_glx->glx_context,

View File

@@ -685,13 +685,8 @@ init_randr13 (GdkX11Screen *x11_screen)
for (i = 0; i < resources->noutput; ++i)
{
RROutput output = resources->outputs[i];
XRROutputInfo *output_info;
gdk_x11_display_error_trap_push (display);
output_info = XRRGetOutputInfo (x11_screen->xdisplay, resources, output);
if (gdk_x11_display_error_trap_pop (display))
continue;
XRROutputInfo *output_info =
XRRGetOutputInfo (x11_screen->xdisplay, resources, output);
if (output_info->connection == RR_Disconnected)
{
@@ -702,22 +697,13 @@ init_randr13 (GdkX11Screen *x11_screen)
if (output_info->crtc)
{
GdkX11Monitor *monitor;
XRRCrtcInfo *crtc;
XRRCrtcInfo *crtc = XRRGetCrtcInfo (x11_screen->xdisplay, resources, output_info->crtc);
char *name;
GdkRectangle geometry;
GdkRectangle newgeo;
int j;
int refresh_rate = 0;
gdk_x11_display_error_trap_push (display);
crtc = XRRGetCrtcInfo (x11_screen->xdisplay, resources, output_info->crtc);
if (gdk_x11_display_error_trap_pop (display))
{
XRRFreeOutputInfo (output_info);
continue;
}
for (j = 0; j < resources->nmode; j++)
{
XRRModeInfo *xmode = &resources->modes[j];
@@ -789,10 +775,8 @@ init_randr13 (GdkX11Screen *x11_screen)
}
x11_display->primary_monitor = 0;
gdk_x11_display_error_trap_push (display);
primary_output = XRRGetOutputPrimary (x11_screen->xdisplay,
x11_screen->xroot_window);
gdk_x11_display_error_trap_pop_ignored (display);
for (i = 0; i < g_list_model_get_n_items (G_LIST_MODEL (x11_display->monitors)); i++)
{

View File

@@ -89,7 +89,7 @@ gdk_x11_selection_input_stream_fill_buffer (GdkX11SelectionInputStream *stream,
if (size == 0)
{
/* EOF marker, put it back */
g_async_queue_push_front_unlocked (priv->chunks, g_steal_pointer (&bytes));
g_async_queue_push_front_unlocked (priv->chunks, bytes);
break;
}
else if (size > count)
@@ -107,7 +107,7 @@ gdk_x11_selection_input_stream_fill_buffer (GdkX11SelectionInputStream *stream,
memcpy (buffer, g_bytes_get_data (bytes, NULL), size);
}
g_bytes_unref (g_steal_pointer (&bytes));
g_bytes_unref (bytes);
result += size;
if (buffer)
buffer += size;
@@ -165,7 +165,9 @@ gdk_x11_selection_input_stream_complete (GdkX11SelectionInputStream *stream)
GDK_X11_DISPLAY (priv->display)->streams = g_slist_remove (GDK_X11_DISPLAY (priv->display)->streams, stream);
g_signal_handlers_disconnect_by_func (priv->display,
gdk_x11_selection_input_stream_xevent,
g_steal_pointer (&stream));
stream);
g_object_unref (stream);
}
static gssize
@@ -414,7 +416,7 @@ gdk_x11_selection_input_stream_xevent (GdkDisplay *display,
"%s:%s: got PropertyNotify erroring out of INCR",
priv->selection, priv->target);
/* error, should we signal one? */
g_clear_pointer (&stream, gdk_x11_selection_input_stream_complete);
gdk_x11_selection_input_stream_complete (stream);
}
else if (g_bytes_get_size (bytes) == 0 || type == None)
{
@@ -422,7 +424,7 @@ gdk_x11_selection_input_stream_xevent (GdkDisplay *display,
"%s:%s: got PropertyNotify ending INCR",
priv->selection, priv->target);
g_bytes_unref (bytes);
g_clear_pointer (&stream, gdk_x11_selection_input_stream_complete);
gdk_x11_selection_input_stream_complete (stream);
}
else
{
@@ -465,7 +467,7 @@ gdk_x11_selection_input_stream_xevent (GdkDisplay *display,
G_IO_ERROR,
G_IO_ERROR_NOT_FOUND,
_("Format %s not supported"), priv->target);
g_clear_pointer (&stream, gdk_x11_selection_input_stream_complete);
gdk_x11_selection_input_stream_complete (stream);
}
else
{
@@ -476,7 +478,7 @@ gdk_x11_selection_input_stream_xevent (GdkDisplay *display,
if (bytes == NULL)
{
g_clear_pointer (&stream, gdk_x11_selection_input_stream_complete);
gdk_x11_selection_input_stream_complete (stream);
}
else
{
@@ -498,7 +500,7 @@ gdk_x11_selection_input_stream_xevent (GdkDisplay *display,
g_bytes_get_size (bytes));
g_async_queue_push (priv->chunks, bytes);
g_clear_pointer (&stream, gdk_x11_selection_input_stream_complete);
gdk_x11_selection_input_stream_complete (stream);
}
}
@@ -539,10 +541,7 @@ gdk_x11_selection_input_stream_new_async (GdkDisplay *display,
priv->property = g_strdup_printf ("GDK_SELECTION_%p", stream);
priv->xproperty = gdk_x11_get_xatom_by_name_for_display (display, priv->property);
g_signal_connect_data (display, "xevent",
G_CALLBACK (gdk_x11_selection_input_stream_xevent),
g_steal_pointer (&stream),
(GClosureNotify) g_object_unref, 0);
g_signal_connect (display, "xevent", G_CALLBACK (gdk_x11_selection_input_stream_xevent), stream);
XConvertSelection (GDK_DISPLAY_XDISPLAY (display),
priv->xselection,
@@ -578,6 +577,7 @@ gdk_x11_selection_input_stream_new_finish (GAsyncResult *result,
*type = priv->type;
if (format)
*format = priv->format;
g_object_ref (stream);
}
return G_INPUT_STREAM (stream);

View File

@@ -1447,7 +1447,6 @@ gsk_gl_command_queue_create_framebuffer (GskGLCommandQueue *self)
return fbo_id;
}
static GdkMemoryFormat
memory_format_gl_format (GdkMemoryFormat data_format,
gboolean use_es,
@@ -1455,8 +1454,7 @@ memory_format_gl_format (GdkMemoryFormat data_format,
guint minor,
guint *gl_internalformat,
guint *gl_format,
guint *gl_type,
GLint (*gl_swizzle)[4])
guint *gl_type)
{
if (gdk_memory_format_gl_format (data_format,
use_es,
@@ -1464,9 +1462,7 @@ memory_format_gl_format (GdkMemoryFormat data_format,
minor,
gl_internalformat,
gl_format,
gl_type,
gl_swizzle) &&
gdk_memory_format_alpha (data_format) != GDK_MEMORY_ALPHA_STRAIGHT)
gl_type))
return data_format;
if (gdk_memory_format_prefers_high_depth (data_format))
@@ -1478,8 +1474,7 @@ memory_format_gl_format (GdkMemoryFormat data_format,
minor,
gl_internalformat,
gl_format,
gl_type,
gl_swizzle))
gl_type))
return data_format;
}
@@ -1490,8 +1485,7 @@ memory_format_gl_format (GdkMemoryFormat data_format,
minor,
gl_internalformat,
gl_format,
gl_type,
gl_swizzle))
gl_type))
{
g_assert_not_reached ();
}
@@ -1514,7 +1508,6 @@ gsk_gl_command_queue_do_upload_texture_chunk (GskGLCommandQueue *self,
GLenum gl_internalformat;
GLenum gl_format;
GLenum gl_type;
GLint gl_swizzle[4];
gsize bpp;
gboolean use_es;
int major, minor;
@@ -1531,8 +1524,7 @@ gsk_gl_command_queue_do_upload_texture_chunk (GskGLCommandQueue *self,
minor,
&gl_internalformat,
&gl_format,
&gl_type,
&gl_swizzle);
&gl_type);
gdk_texture_downloader_init (&downloader, texture);
gdk_texture_downloader_set_format (&downloader, data_format);
@@ -1567,18 +1559,6 @@ gsk_gl_command_queue_do_upload_texture_chunk (GskGLCommandQueue *self,
glPixelStorei (GL_UNPACK_ALIGNMENT, 4);
/* Only apply swizzle if really needed, might not even be
* supported if default values are set
*/
if (gl_swizzle[0] != GL_RED || gl_swizzle[1] != GL_GREEN || gl_swizzle[2] != GL_BLUE)
{
/* Set each channel independently since GLES 3.0 doesn't support the iv method */
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_R, gl_swizzle[0]);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_G, gl_swizzle[1]);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_B, gl_swizzle[2]);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_A, gl_swizzle[3]);
}
g_bytes_unref (bytes);
}
@@ -1593,7 +1573,6 @@ gsk_gl_command_queue_upload_texture_chunks (GskGLCommandQueue *self,
GLenum gl_internalformat;
GLenum gl_format;
GLenum gl_type;
GLint gl_swizzle[4];
gboolean use_es;
int texture_id;
int major, minor;
@@ -1632,14 +1611,13 @@ gsk_gl_command_queue_upload_texture_chunks (GskGLCommandQueue *self,
use_es = gdk_gl_context_get_use_es (self->context);
gdk_gl_context_get_version (self->context, &major, &minor);
data_format = gdk_texture_get_format (chunks[0].texture);
data_format = memory_format_gl_format (data_format,
use_es,
major,
minor,
&gl_internalformat,
&gl_format,
&gl_type,
&gl_swizzle);
memory_format_gl_format (data_format,
use_es,
major,
minor,
&gl_internalformat,
&gl_format,
&gl_type);
glTexImage2D (GL_TEXTURE_2D, 0, gl_internalformat, width, height, 0, gl_format, gl_type, NULL);

View File

@@ -761,8 +761,7 @@ gsk_gl_driver_load_texture (GskGLDriver *self,
GdkGLContext *texture_context = gdk_gl_texture_get_context (gl_texture);
if (gdk_gl_context_is_shared (context, texture_context) &&
(!ensure_mipmap || gdk_gl_texture_has_mipmap (gl_texture)) &&
gdk_memory_format_alpha (gdk_texture_get_format (texture)) != GDK_MEMORY_ALPHA_STRAIGHT)
(!ensure_mipmap || gdk_gl_texture_has_mipmap (gl_texture)))
{
/* A GL texture from the same GL context is a simple task... */
return gdk_gl_texture_get_id (gl_texture);

View File

@@ -372,8 +372,6 @@ gsk_renderer_render_texture (GskRenderer *renderer,
gsk_render_node_get_bounds (root, &real_viewport);
viewport = &real_viewport;
}
g_return_val_if_fail (viewport->size.width > 0, NULL);
g_return_val_if_fail (viewport->size.height > 0, NULL);
texture = GSK_RENDERER_GET_CLASS (renderer)->render_texture (renderer, root, viewport);

View File

@@ -3956,29 +3956,27 @@ gsk_repeat_node_draw (GskRenderNode *node,
cairo_pattern_t *pattern;
cairo_surface_t *surface;
cairo_t *surface_cr;
double scale_x, scale_y, width, height;
cairo_matrix_t matrix;
cairo_get_matrix (cr, &matrix);
width = ceil (self->child_bounds.size.width * (ABS (matrix.xx) + ABS (matrix.yx)));
height = ceil (self->child_bounds.size.height * (ABS (matrix.xy) + ABS (matrix.yy)));
surface = cairo_surface_create_similar (cairo_get_target (cr),
CAIRO_CONTENT_COLOR_ALPHA,
width, height);
cairo_surface_get_device_scale (surface, &scale_x, &scale_y);
scale_x *= width / self->child_bounds.size.width;
scale_y *= height / self->child_bounds.size.height;
cairo_surface_set_device_scale (surface, scale_x, scale_y);
cairo_surface_set_device_offset (surface,
- self->child_bounds.origin.x * scale_x,
- self->child_bounds.origin.y * scale_y);
ceilf (self->child_bounds.size.width),
ceilf (self->child_bounds.size.height));
surface_cr = cairo_create (surface);
cairo_translate (surface_cr,
- self->child_bounds.origin.x,
- self->child_bounds.origin.y);
gsk_render_node_draw (self->child, surface_cr);
cairo_destroy (surface_cr);
pattern = cairo_pattern_create_for_surface (surface);
cairo_pattern_set_extend (pattern, CAIRO_EXTEND_REPEAT);
cairo_pattern_set_matrix (pattern,
&(cairo_matrix_t) {
.xx = 1.0,
.yy = 1.0,
.x0 = - self->child_bounds.origin.x,
.y0 = - self->child_bounds.origin.y
});
cairo_set_source (cr, pattern);
cairo_pattern_destroy (pattern);
cairo_surface_destroy (surface);

View File

@@ -2892,14 +2892,6 @@ append_texture_param (Printer *p,
case GDK_MEMORY_R16G16B16:
case GDK_MEMORY_R16G16B16A16_PREMULTIPLIED:
case GDK_MEMORY_R16G16B16A16:
case GDK_MEMORY_G8A8_PREMULTIPLIED:
case GDK_MEMORY_G8A8:
case GDK_MEMORY_G8:
case GDK_MEMORY_G16A16_PREMULTIPLIED:
case GDK_MEMORY_G16A16:
case GDK_MEMORY_G16:
case GDK_MEMORY_A8:
case GDK_MEMORY_A16:
bytes = gdk_texture_save_to_png_bytes (texture);
g_string_append (p->str, "url(\"data:image/png;base64,");
break;

View File

@@ -689,134 +689,6 @@ gsk_rounded_rect_intersect_with_rect (const GskRoundedRect *self,
return GSK_INTERSECTION_NONEMPTY;
}
static gboolean
check_nonintersecting_corner (const GskRoundedRect *out,
const GskRoundedRect *in,
GskCorner corner,
float diff_x,
float diff_y,
GskRoundedRect *result)
{
g_assert (diff_x >= 0);
g_assert (diff_y >= 0);
if (out->corner[corner].width < diff_x ||
out->corner[corner].height < diff_y ||
(out->corner[corner].width <= in->corner[corner].width + diff_x &&
out->corner[corner].height <= in->corner[corner].height + diff_y))
{
result->corner[corner] = in->corner[corner];
return TRUE;
}
if (diff_x > 0 || diff_y > 0)
return FALSE;
if (out->corner[corner].width > in->corner[corner].width &&
out->corner[corner].height > in->corner[corner].height)
{
result->corner[corner] = out->corner[corner];
return TRUE;
}
return FALSE;
}
/* a is outside in x direction, b is outside in y direction */
static gboolean
check_intersecting_corner (const GskRoundedRect *a,
const GskRoundedRect *b,
GskCorner corner,
float diff_x,
float diff_y,
GskRoundedRect *result)
{
g_assert (diff_x > 0);
g_assert (diff_y > 0);
if (diff_x < a->corner[corner].width ||
diff_x > a->bounds.size.width - a->corner[corner].width - a->corner[OPPOSITE_CORNER_X (corner)].width ||
diff_y < b->corner[corner].height ||
diff_y > b->bounds.size.height - b->corner[corner].height - b->corner[OPPOSITE_CORNER_Y (corner)].height)
return FALSE;
result->corner[corner] = GRAPHENE_SIZE_INIT (0, 0);
return TRUE;
}
static gboolean
check_corner (const GskRoundedRect *a,
const GskRoundedRect *b,
GskCorner corner,
float diff_x,
float diff_y,
GskRoundedRect *result)
{
if (diff_x >= 0)
{
if (diff_y >= 0)
{
return check_nonintersecting_corner (a, b, corner, diff_x, diff_y, result);
}
else if (diff_x == 0)
{
return check_nonintersecting_corner (b, a, corner, 0, - diff_y, result);
}
else
{
return check_intersecting_corner (a, b, corner, diff_x, - diff_y, result);
}
}
else
{
if (diff_y <= 0)
{
return check_nonintersecting_corner (b, a, corner, - diff_x, - diff_y, result);
}
else
{
return check_intersecting_corner (b, a, corner, - diff_x, diff_y, result);
}
}
}
GskRoundedRectIntersection
gsk_rounded_rect_intersection (const GskRoundedRect *a,
const GskRoundedRect *b,
GskRoundedRect *result)
{
float top, left, bottom, right;
if (!graphene_rect_intersection (&a->bounds, &b->bounds, &result->bounds))
return GSK_INTERSECTION_EMPTY;
left = b->bounds.origin.x - a->bounds.origin.x;
top = b->bounds.origin.y - a->bounds.origin.y;
right = a->bounds.origin.x + a->bounds.size.width - b->bounds.origin.x - b->bounds.size.width;
bottom = a->bounds.origin.y + a->bounds.size.height - b->bounds.origin.y - b->bounds.size.height;
if (check_corner (a, b,
GSK_CORNER_TOP_LEFT,
left, top,
result) &&
check_corner (a, b,
GSK_CORNER_TOP_RIGHT,
right, top,
result) &&
check_corner (a, b,
GSK_CORNER_BOTTOM_LEFT,
left, bottom,
result) &&
check_corner (a, b,
GSK_CORNER_BOTTOM_RIGHT,
right, bottom,
result))
return GSK_INTERSECTION_NONEMPTY;
return GSK_INTERSECTION_NOT_REPRESENTABLE;
}
static void
append_arc (cairo_t *cr, double angle1, double angle2, gboolean negative)
{
@@ -894,14 +766,13 @@ gsk_rounded_rect_path (const GskRoundedRect *self,
* only look at the last vec4 if they have to.
*/
void
gsk_rounded_rect_to_float (const GskRoundedRect *self,
const graphene_point_t *offset,
float rect[12])
gsk_rounded_rect_to_float (const GskRoundedRect *self,
float rect[12])
{
guint i;
rect[0] = self->bounds.origin.x + offset->x;
rect[1] = self->bounds.origin.y + offset->y;
rect[0] = self->bounds.origin.x;
rect[1] = self->bounds.origin.y;
rect[2] = self->bounds.size.width;
rect[3] = self->bounds.size.height;

View File

@@ -6,24 +6,6 @@
G_BEGIN_DECLS
#define OPPOSITE_CORNER(corner) ((corner) ^ 2)
G_STATIC_ASSERT (OPPOSITE_CORNER (GSK_CORNER_TOP_LEFT) == GSK_CORNER_BOTTOM_RIGHT);
G_STATIC_ASSERT (OPPOSITE_CORNER (GSK_CORNER_TOP_RIGHT) == GSK_CORNER_BOTTOM_LEFT);
G_STATIC_ASSERT (OPPOSITE_CORNER (GSK_CORNER_BOTTOM_LEFT) == GSK_CORNER_TOP_RIGHT);
G_STATIC_ASSERT (OPPOSITE_CORNER (GSK_CORNER_BOTTOM_RIGHT) == GSK_CORNER_TOP_LEFT);
#define OPPOSITE_CORNER_X(corner) ((corner) ^ 1)
G_STATIC_ASSERT (OPPOSITE_CORNER_X (GSK_CORNER_TOP_LEFT) == GSK_CORNER_TOP_RIGHT);
G_STATIC_ASSERT (OPPOSITE_CORNER_X (GSK_CORNER_TOP_RIGHT) == GSK_CORNER_TOP_LEFT);
G_STATIC_ASSERT (OPPOSITE_CORNER_X (GSK_CORNER_BOTTOM_LEFT) == GSK_CORNER_BOTTOM_RIGHT);
G_STATIC_ASSERT (OPPOSITE_CORNER_X (GSK_CORNER_BOTTOM_RIGHT) == GSK_CORNER_BOTTOM_LEFT);
#define OPPOSITE_CORNER_Y(corner) ((corner) ^ 3)
G_STATIC_ASSERT (OPPOSITE_CORNER_Y (GSK_CORNER_TOP_LEFT) == GSK_CORNER_BOTTOM_LEFT);
G_STATIC_ASSERT (OPPOSITE_CORNER_Y (GSK_CORNER_TOP_RIGHT) == GSK_CORNER_BOTTOM_RIGHT);
G_STATIC_ASSERT (OPPOSITE_CORNER_Y (GSK_CORNER_BOTTOM_LEFT) == GSK_CORNER_TOP_LEFT);
G_STATIC_ASSERT (OPPOSITE_CORNER_Y (GSK_CORNER_BOTTOM_RIGHT) == GSK_CORNER_TOP_RIGHT);
#define GSK_ROUNDED_RECT_INIT_FROM_RECT(_r) \
(GskRoundedRect) { .bounds = _r, \
.corner = { \
@@ -46,7 +28,6 @@ gboolean gsk_rounded_rect_is_circular (const GskRounde
void gsk_rounded_rect_path (const GskRoundedRect *self,
cairo_t *cr);
void gsk_rounded_rect_to_float (const GskRoundedRect *self,
const graphene_point_t *offset,
float rect[12]);
gboolean gsk_rounded_rect_equal (gconstpointer rect1,
@@ -62,9 +43,6 @@ typedef enum {
GskRoundedRectIntersection gsk_rounded_rect_intersect_with_rect (const GskRoundedRect *self,
const graphene_rect_t *rect,
GskRoundedRect *result) G_GNUC_PURE;
GskRoundedRectIntersection gsk_rounded_rect_intersection (const GskRoundedRect *a,
const GskRoundedRect *b,
GskRoundedRect *result);
G_END_DECLS

View File

@@ -12,12 +12,8 @@ typedef struct _GskVulkanBlendModeInstance GskVulkanBlendModeInstance;
struct _GskVulkanBlendModeInstance
{
float rect[4];
float top_rect[4];
float bottom_rect[4];
float top_tex_rect[4];
float bottom_tex_rect[4];
guint32 top_tex_id[2];
guint32 bottom_tex_id[2];
float start_tex_rect[4];
float end_tex_rect[4];
guint32 blend_mode;
};
@@ -44,42 +40,18 @@ gsk_vulkan_blend_mode_pipeline_get_input_state_create_info (GskVulkanPipeline *s
.location = 1,
.binding = 0,
.format = VK_FORMAT_R32G32B32A32_SFLOAT,
.offset = G_STRUCT_OFFSET (GskVulkanBlendModeInstance, top_rect),
.offset = G_STRUCT_OFFSET (GskVulkanBlendModeInstance, start_tex_rect),
},
{
.location = 2,
.binding = 0,
.format = VK_FORMAT_R32G32B32A32_SFLOAT,
.offset = G_STRUCT_OFFSET (GskVulkanBlendModeInstance, bottom_rect),
.offset = G_STRUCT_OFFSET (GskVulkanBlendModeInstance, end_tex_rect),
},
{
.location = 3,
.binding = 0,
.format = VK_FORMAT_R32G32B32A32_SFLOAT,
.offset = G_STRUCT_OFFSET (GskVulkanBlendModeInstance, top_tex_rect),
},
{
.location = 4,
.binding = 0,
.format = VK_FORMAT_R32G32B32A32_SFLOAT,
.offset = G_STRUCT_OFFSET (GskVulkanBlendModeInstance, bottom_tex_rect),
},
{
.location = 5,
.binding = 0,
.format = VK_FORMAT_R32_UINT,
.offset = G_STRUCT_OFFSET (GskVulkanBlendModeInstance, top_tex_id),
},
{
.location = 6,
.binding = 0,
.format = VK_FORMAT_R32G32_UINT,
.offset = G_STRUCT_OFFSET (GskVulkanBlendModeInstance, bottom_tex_id),
},
{
.location = 7,
.binding = 0,
.format = VK_FORMAT_R32G32_UINT,
.offset = G_STRUCT_OFFSET (GskVulkanBlendModeInstance, blend_mode),
}
};
@@ -126,50 +98,37 @@ gsk_vulkan_blend_mode_pipeline_new (GdkVulkanContext *context,
return gsk_vulkan_pipeline_new (GSK_TYPE_VULKAN_BLEND_MODE_PIPELINE, context, layout, shader_name, render_pass);
}
gsize
gsk_vulkan_blend_mode_pipeline_count_vertex_data (GskVulkanBlendModePipeline *pipeline)
{
return sizeof (GskVulkanBlendModeInstance);
}
void
gsk_vulkan_blend_mode_pipeline_collect_vertex_data (GskVulkanBlendModePipeline *pipeline,
guchar *data,
guint32 top_tex_id[2],
guint32 bottom_tex_id[2],
const graphene_point_t *offset,
const graphene_rect_t *bounds,
const graphene_rect_t *top_bounds,
const graphene_rect_t *bottom_bounds,
const graphene_rect_t *top_tex_rect,
const graphene_rect_t *bottom_tex_rect,
GskBlendMode blend_mode)
guchar *data,
const graphene_rect_t *bounds,
const graphene_rect_t *start_tex_rect,
const graphene_rect_t *end_tex_rect,
GskBlendMode blend_mode)
{
GskVulkanBlendModeInstance *instance = (GskVulkanBlendModeInstance *) data;
instance->rect[0] = bounds->origin.x + offset->x;
instance->rect[1] = bounds->origin.y + offset->y;
instance->rect[0] = bounds->origin.x;
instance->rect[1] = bounds->origin.y;
instance->rect[2] = bounds->size.width;
instance->rect[3] = bounds->size.height;
instance->top_rect[0] = top_bounds->origin.x + offset->x;
instance->top_rect[1] = top_bounds->origin.y + offset->y;
instance->top_rect[2] = top_bounds->size.width;
instance->top_rect[3] = top_bounds->size.height;
instance->start_tex_rect[0] = start_tex_rect->origin.x;
instance->start_tex_rect[1] = start_tex_rect->origin.y;
instance->start_tex_rect[2] = start_tex_rect->size.width;
instance->start_tex_rect[3] = start_tex_rect->size.height;
instance->bottom_rect[0] = bottom_bounds->origin.x + offset->x;
instance->bottom_rect[1] = bottom_bounds->origin.y + offset->y;
instance->bottom_rect[2] = bottom_bounds->size.width;
instance->bottom_rect[3] = bottom_bounds->size.height;
instance->end_tex_rect[0] = end_tex_rect->origin.x;
instance->end_tex_rect[1] = end_tex_rect->origin.y;
instance->end_tex_rect[2] = end_tex_rect->size.width;
instance->end_tex_rect[3] = end_tex_rect->size.height;
instance->top_tex_rect[0] = top_tex_rect->origin.x;
instance->top_tex_rect[1] = top_tex_rect->origin.y;
instance->top_tex_rect[2] = top_tex_rect->size.width;
instance->top_tex_rect[3] = top_tex_rect->size.height;
instance->bottom_tex_rect[0] = bottom_tex_rect->origin.x;
instance->bottom_tex_rect[1] = bottom_tex_rect->origin.y;
instance->bottom_tex_rect[2] = bottom_tex_rect->size.width;
instance->bottom_tex_rect[3] = bottom_tex_rect->size.height;
instance->top_tex_id[0] = top_tex_id[0];
instance->top_tex_id[1] = top_tex_id[1];
instance->bottom_tex_id[0] = bottom_tex_id[0];
instance->bottom_tex_id[1] = bottom_tex_id[1];
instance->blend_mode = blend_mode;
}

View File

@@ -18,16 +18,12 @@ GskVulkanPipeline * gsk_vulkan_blend_mode_pipeline_new (GdkVulka
const char *shader_name,
VkRenderPass render_pass);
gsize gsk_vulkan_blend_mode_pipeline_count_vertex_data (GskVulkanBlendModePipeline *pipeline);
void gsk_vulkan_blend_mode_pipeline_collect_vertex_data (GskVulkanBlendModePipeline *pipeline,
guchar *data,
guint32 top_tex_id[2],
guint32 bottom_tex_id[2],
const graphene_point_t *offset,
const graphene_rect_t *bounds,
const graphene_rect_t *top_bounds,
const graphene_rect_t *bottom_bounds,
const graphene_rect_t *top_tex_rect,
const graphene_rect_t *bottom_tex_rect,
const graphene_rect_t *start_bounds,
const graphene_rect_t *end_bounds,
GskBlendMode blend_mode);
gsize gsk_vulkan_blend_mode_pipeline_draw (GskVulkanBlendModePipeline *pipeline,
VkCommandBuffer command_buffer,

View File

@@ -14,7 +14,6 @@ struct _GskVulkanBlurInstance
float rect[4];
float tex_rect[4];
float blur_radius;
guint32 tex_id[2];
};
G_DEFINE_TYPE (GskVulkanBlurPipeline, gsk_vulkan_blur_pipeline, GSK_TYPE_VULKAN_PIPELINE)
@@ -47,12 +46,6 @@ gsk_vulkan_blur_pipeline_get_input_state_create_info (GskVulkanPipeline *self)
.binding = 0,
.format = VK_FORMAT_R32_SFLOAT,
.offset = G_STRUCT_OFFSET (GskVulkanBlurInstance, blur_radius),
},
{
.location = 3,
.binding = 0,
.format = VK_FORMAT_R32G32_UINT,
.offset = G_STRUCT_OFFSET (GskVulkanBlurInstance, tex_id),
}
};
static const VkPipelineVertexInputStateCreateInfo info = {
@@ -98,19 +91,23 @@ gsk_vulkan_blur_pipeline_new (GdkVulkanContext *context,
return gsk_vulkan_pipeline_new (GSK_TYPE_VULKAN_BLUR_PIPELINE, context, layout, shader_name, render_pass);
}
gsize
gsk_vulkan_blur_pipeline_count_vertex_data (GskVulkanBlurPipeline *pipeline)
{
return sizeof (GskVulkanBlurInstance);
}
void
gsk_vulkan_blur_pipeline_collect_vertex_data (GskVulkanBlurPipeline *pipeline,
guchar *data,
guint32 tex_id[2],
const graphene_point_t *offset,
const graphene_rect_t *rect,
const graphene_rect_t *tex_rect,
double blur_radius)
gsk_vulkan_blur_pipeline_collect_vertex_data (GskVulkanBlurPipeline *pipeline,
guchar *data,
const graphene_rect_t *rect,
const graphene_rect_t *tex_rect,
double blur_radius)
{
GskVulkanBlurInstance *instance = (GskVulkanBlurInstance *) data;
instance->rect[0] = rect->origin.x + offset->x;
instance->rect[1] = rect->origin.y + offset->y;
instance->rect[0] = rect->origin.x;
instance->rect[1] = rect->origin.y;
instance->rect[2] = rect->size.width;
instance->rect[3] = rect->size.height;
instance->tex_rect[0] = tex_rect->origin.x;
@@ -118,8 +115,6 @@ gsk_vulkan_blur_pipeline_collect_vertex_data (GskVulkanBlurPipeline *pipeline,
instance->tex_rect[2] = tex_rect->size.width;
instance->tex_rect[3] = tex_rect->size.height;
instance->blur_radius = blur_radius;
instance->tex_id[0] = tex_id[0];
instance->tex_id[1] = tex_id[1];
}
gsize

View File

@@ -17,10 +17,9 @@ GskVulkanPipeline * gsk_vulkan_blur_pipeline_new (GdkVulka
const char *shader_name,
VkRenderPass render_pass);
gsize gsk_vulkan_blur_pipeline_count_vertex_data (GskVulkanBlurPipeline *pipeline);
void gsk_vulkan_blur_pipeline_collect_vertex_data (GskVulkanBlurPipeline *pipeline,
guchar *data,
guint32 tex_id[2],
const graphene_point_t *offset,
const graphene_rect_t *rect,
const graphene_rect_t *tex_rect,
double radius);

View File

@@ -123,10 +123,15 @@ gsk_vulkan_border_pipeline_new (GdkVulkanContext *context,
return gsk_vulkan_pipeline_new (GSK_TYPE_VULKAN_BORDER_PIPELINE, context, layout, shader_name, render_pass);
}
gsize
gsk_vulkan_border_pipeline_count_vertex_data (GskVulkanBorderPipeline *pipeline)
{
return sizeof (GskVulkanBorderInstance);
}
void
gsk_vulkan_border_pipeline_collect_vertex_data (GskVulkanBorderPipeline *pipeline,
guchar *data,
const graphene_point_t *offset,
const GskRoundedRect *rect,
const float widths[4],
const GdkRGBA colors[4])
@@ -134,7 +139,7 @@ gsk_vulkan_border_pipeline_collect_vertex_data (GskVulkanBorderPipeline *pipelin
GskVulkanBorderInstance *instance = (GskVulkanBorderInstance *) data;
guint i;
gsk_rounded_rect_to_float (rect, offset, instance->rect);
gsk_rounded_rect_to_float (rect, instance->rect);
for (i = 0; i < 4; i++)
{
instance->widths[i] = widths[i];

View File

@@ -18,9 +18,9 @@ GskVulkanPipeline * gsk_vulkan_border_pipeline_new (GdkVulk
const char *shader_name,
VkRenderPass render_pass);
gsize gsk_vulkan_border_pipeline_count_vertex_data (GskVulkanBorderPipeline *pipeline);
void gsk_vulkan_border_pipeline_collect_vertex_data (GskVulkanBorderPipeline *pipeline,
guchar *data,
const graphene_point_t *offset,
const GskRoundedRect *rect,
const float widths[4],
const GdkRGBA colors[4]);

View File

@@ -119,10 +119,15 @@ gsk_vulkan_box_shadow_pipeline_new (GdkVulkanContext *context,
return gsk_vulkan_pipeline_new (GSK_TYPE_VULKAN_BOX_SHADOW_PIPELINE, context, layout, shader_name, render_pass);
}
gsize
gsk_vulkan_box_shadow_pipeline_count_vertex_data (GskVulkanBoxShadowPipeline *pipeline)
{
return sizeof (GskVulkanBoxShadowInstance);
}
void
gsk_vulkan_box_shadow_pipeline_collect_vertex_data (GskVulkanBoxShadowPipeline *pipeline,
guchar *data,
const graphene_point_t *offset,
const GskRoundedRect *outline,
const GdkRGBA *color,
float dx,
@@ -132,7 +137,7 @@ gsk_vulkan_box_shadow_pipeline_collect_vertex_data (GskVulkanBoxShadowPipeline *
{
GskVulkanBoxShadowInstance *instance = (GskVulkanBoxShadowInstance *) data;
gsk_rounded_rect_to_float (outline, offset, instance->outline);
gsk_rounded_rect_to_float (outline, instance->outline);
instance->color[0] = color->red;
instance->color[1] = color->green;
instance->color[2] = color->blue;

View File

@@ -18,9 +18,9 @@ GskVulkanPipeline * gsk_vulkan_box_shadow_pipeline_new (GdkVulk
const char *shader_name,
VkRenderPass render_pass);
gsize gsk_vulkan_box_shadow_pipeline_count_vertex_data (GskVulkanBoxShadowPipeline *pipeline);
void gsk_vulkan_box_shadow_pipeline_collect_vertex_data (GskVulkanBoxShadowPipeline *pipeline,
guchar *data,
const graphene_point_t *offset,
const GskRoundedRect *outline,
const GdkRGBA *color,
float dx,

View File

@@ -13,15 +13,7 @@ gsk_vulkan_clip_init_empty (GskVulkanClip *clip,
gsk_rounded_rect_init_from_rect (&clip->rect, rect, 0);
}
void
gsk_vulkan_clip_init_rect (GskVulkanClip *clip,
const graphene_rect_t *rect)
{
clip->type = GSK_VULKAN_CLIP_RECT;
gsk_rounded_rect_init_from_rect (&clip->rect, rect, 0);
}
void
static void
gsk_vulkan_clip_init_copy (GskVulkanClip *self,
const GskVulkanClip *src)
{
@@ -29,30 +21,11 @@ gsk_vulkan_clip_init_copy (GskVulkanClip *self,
gsk_rounded_rect_init_copy (&self->rect, &src->rect);
}
static gboolean
gsk_vulkan_clip_init_after_intersection (GskVulkanClip *self,
GskRoundedRectIntersection res)
{
if (res == GSK_INTERSECTION_NOT_REPRESENTABLE)
return FALSE;
if (res == GSK_INTERSECTION_EMPTY)
self->type = GSK_VULKAN_CLIP_ALL_CLIPPED;
else if (gsk_rounded_rect_is_rectilinear (&self->rect))
self->type = GSK_VULKAN_CLIP_RECT;
else
self->type = GSK_VULKAN_CLIP_ROUNDED;
return TRUE;
}
gboolean
gsk_vulkan_clip_intersect_rect (GskVulkanClip *dest,
const GskVulkanClip *src,
const graphene_rect_t *rect)
{
GskRoundedRectIntersection res;
if (graphene_rect_contains_rect (rect, &src->rect.bounds))
{
gsk_vulkan_clip_init_copy (dest, src);
@@ -84,10 +57,22 @@ gsk_vulkan_clip_intersect_rect (GskVulkanClip *dest,
dest->type = GSK_VULKAN_CLIP_ALL_CLIPPED;
break;
case GSK_VULKAN_CLIP_ROUNDED_CIRCULAR:
case GSK_VULKAN_CLIP_ROUNDED:
res = gsk_rounded_rect_intersect_with_rect (&src->rect, rect, &dest->rect);
if (!gsk_vulkan_clip_init_after_intersection (dest, res))
return FALSE;
if (gsk_rounded_rect_contains_rect (&src->rect, rect))
{
dest->type = GSK_VULKAN_CLIP_RECT;
gsk_rounded_rect_init_from_rect (&dest->rect, rect, 0);
}
else
{
/* some points of rect are inside src's rounded rect,
* some are outside. */
/* XXX: If the 2 rects don't intersect on rounded corners,
* we could actually compute a new clip here.
*/
return FALSE;
}
break;
default:
@@ -103,8 +88,6 @@ gsk_vulkan_clip_intersect_rounded_rect (GskVulkanClip *dest,
const GskVulkanClip *src,
const GskRoundedRect *rounded)
{
GskRoundedRectIntersection res;
if (gsk_rounded_rect_contains_rect (rounded, &src->rect.bounds))
{
gsk_vulkan_clip_init_copy (dest, src);
@@ -123,21 +106,34 @@ gsk_vulkan_clip_intersect_rounded_rect (GskVulkanClip *dest,
break;
case GSK_VULKAN_CLIP_NONE:
dest->type = GSK_VULKAN_CLIP_ROUNDED;
dest->type = gsk_rounded_rect_is_circular (rounded) ? GSK_VULKAN_CLIP_ROUNDED_CIRCULAR : GSK_VULKAN_CLIP_ROUNDED;
gsk_rounded_rect_init_copy (&dest->rect, rounded);
break;
case GSK_VULKAN_CLIP_RECT:
res = gsk_rounded_rect_intersect_with_rect (rounded, &src->rect.bounds, &dest->rect);
if (!gsk_vulkan_clip_init_after_intersection (dest, res))
return FALSE;
break;
if (graphene_rect_contains_rect (&src->rect.bounds, &rounded->bounds))
{
dest->type = gsk_rounded_rect_is_circular (rounded) ? GSK_VULKAN_CLIP_ROUNDED_CIRCULAR : GSK_VULKAN_CLIP_ROUNDED;
gsk_rounded_rect_init_copy (&dest->rect, rounded);
return TRUE;
}
/* some points of rect are inside src's rounded rect,
* some are outside. */
/* XXX: If the 2 rects don't intersect on rounded corners,
* we could actually compute a new clip here.
*/
return FALSE;
case GSK_VULKAN_CLIP_ROUNDED_CIRCULAR:
case GSK_VULKAN_CLIP_ROUNDED:
res = gsk_rounded_rect_intersection (&src->rect, rounded, &dest->rect);
if (!gsk_vulkan_clip_init_after_intersection (dest, res))
return FALSE;
break;
if (gsk_rounded_rect_contains_rect (&src->rect, &rounded->bounds))
{
dest->type = gsk_rounded_rect_is_circular (rounded) ? GSK_VULKAN_CLIP_ROUNDED_CIRCULAR : GSK_VULKAN_CLIP_ROUNDED;
gsk_rounded_rect_init_copy (&dest->rect, rounded);
return TRUE;
}
/* XXX: Can be improved for the case where one of the rects is a slightly shrunk version of the other */
return FALSE;
default:
g_assert_not_reached ();
@@ -147,19 +143,6 @@ gsk_vulkan_clip_intersect_rounded_rect (GskVulkanClip *dest,
return TRUE;
}
void
gsk_vulkan_clip_scale (GskVulkanClip *dest,
const GskVulkanClip *src,
float scale_x,
float scale_y)
{
dest->type = src->type;
gsk_rounded_rect_scale_affine (&dest->rect,
&src->rect,
1.0f / scale_x, 1.0f / scale_y,
0, 0);
}
gboolean
gsk_vulkan_clip_transform (GskVulkanClip *dest,
const GskVulkanClip *src,
@@ -181,6 +164,7 @@ gsk_vulkan_clip_transform (GskVulkanClip *dest,
return TRUE;
case GSK_VULKAN_CLIP_RECT:
case GSK_VULKAN_CLIP_ROUNDED_CIRCULAR:
case GSK_VULKAN_CLIP_ROUNDED:
switch (gsk_transform_get_category (transform))
{
@@ -236,14 +220,9 @@ gsk_vulkan_clip_transform (GskVulkanClip *dest,
}
gboolean
gsk_vulkan_clip_intersects_rect (const GskVulkanClip *self,
const graphene_point_t *offset,
const graphene_rect_t *rect)
gsk_vulkan_clip_contains_rect (const GskVulkanClip *self,
const graphene_rect_t *rect)
{
graphene_rect_t r = *rect;
r.origin.x += offset->x;
r.origin.y += offset->y;
switch (self->type)
{
default:
@@ -255,36 +234,10 @@ gsk_vulkan_clip_intersects_rect (const GskVulkanClip *self,
return TRUE;
case GSK_VULKAN_CLIP_RECT:
return graphene_rect_intersection (&self->rect.bounds, &r, NULL);
return graphene_rect_contains_rect (&self->rect.bounds, rect);
case GSK_VULKAN_CLIP_ROUNDED_CIRCULAR:
case GSK_VULKAN_CLIP_ROUNDED:
return gsk_rounded_rect_intersects_rect (&self->rect, &r);
}
}
gboolean
gsk_vulkan_clip_contains_rect (const GskVulkanClip *self,
const graphene_point_t *offset,
const graphene_rect_t *rect)
{
graphene_rect_t r = *rect;
r.origin.x += offset->x;
r.origin.y += offset->y;
switch (self->type)
{
default:
g_assert_not_reached();
case GSK_VULKAN_CLIP_ALL_CLIPPED:
return FALSE;
case GSK_VULKAN_CLIP_NONE:
return TRUE;
case GSK_VULKAN_CLIP_RECT:
return graphene_rect_contains_rect (&self->rect.bounds, &r);
case GSK_VULKAN_CLIP_ROUNDED:
return gsk_rounded_rect_contains_rect (&self->rect, &r);
return gsk_rounded_rect_contains_rect (&self->rect, rect);
}
}

View File

@@ -18,6 +18,10 @@ typedef enum {
GSK_VULKAN_CLIP_NONE,
/* The clip is a rectangular area */
GSK_VULKAN_CLIP_RECT,
/* The clip is a rounded rectangle, and for every corner
* corner.width == corner.height is true
*/
GSK_VULKAN_CLIP_ROUNDED_CIRCULAR,
/* The clip is a rounded rectangle */
GSK_VULKAN_CLIP_ROUNDED
} GskVulkanClipComplexity;
@@ -32,10 +36,6 @@ struct _GskVulkanClip
void gsk_vulkan_clip_init_empty (GskVulkanClip *clip,
const graphene_rect_t *rect);
void gsk_vulkan_clip_init_copy (GskVulkanClip *self,
const GskVulkanClip *src);
void gsk_vulkan_clip_init_rect (GskVulkanClip *clip,
const graphene_rect_t *rect);
gboolean gsk_vulkan_clip_intersect_rect (GskVulkanClip *dest,
const GskVulkanClip *src,
@@ -43,20 +43,12 @@ gboolean gsk_vulkan_clip_intersect_rect (GskVulk
gboolean gsk_vulkan_clip_intersect_rounded_rect (GskVulkanClip *dest,
const GskVulkanClip *src,
const GskRoundedRect *rounded) G_GNUC_WARN_UNUSED_RESULT;
void gsk_vulkan_clip_scale (GskVulkanClip *dest,
const GskVulkanClip *src,
float scale_x,
float scale_y);
gboolean gsk_vulkan_clip_transform (GskVulkanClip *dest,
const GskVulkanClip *src,
GskTransform *transform,
const graphene_rect_t *viewport) G_GNUC_WARN_UNUSED_RESULT;
gboolean gsk_vulkan_clip_contains_rect (const GskVulkanClip *self,
const graphene_point_t *offset,
const graphene_rect_t *rect) G_GNUC_WARN_UNUSED_RESULT;
gboolean gsk_vulkan_clip_intersects_rect (const GskVulkanClip *self,
const graphene_point_t *offset,
const graphene_rect_t *rect) G_GNUC_WARN_UNUSED_RESULT;
G_END_DECLS

View File

@@ -84,17 +84,22 @@ gsk_vulkan_color_pipeline_new (GdkVulkanContext *context,
return gsk_vulkan_pipeline_new (GSK_TYPE_VULKAN_COLOR_PIPELINE, context, layout, shader_name, render_pass);
}
gsize
gsk_vulkan_color_pipeline_count_vertex_data (GskVulkanColorPipeline *pipeline)
{
return sizeof (GskVulkanColorInstance);
}
void
gsk_vulkan_color_pipeline_collect_vertex_data (GskVulkanColorPipeline *pipeline,
guchar *data,
const graphene_point_t *offset,
const graphene_rect_t *rect,
const GdkRGBA *color)
{
GskVulkanColorInstance *instance = (GskVulkanColorInstance *) data;
instance->rect[0] = rect->origin.x + offset->x;
instance->rect[1] = rect->origin.y + offset->y;
instance->rect[0] = rect->origin.x;
instance->rect[1] = rect->origin.y;
instance->rect[2] = rect->size.width;
instance->rect[3] = rect->size.height;
instance->color[0] = color->red;

View File

@@ -17,9 +17,9 @@ GskVulkanPipeline * gsk_vulkan_color_pipeline_new (GdkVulk
const char *shader_name,
VkRenderPass render_pass);
gsize gsk_vulkan_color_pipeline_count_vertex_data (GskVulkanColorPipeline *pipeline);
void gsk_vulkan_color_pipeline_collect_vertex_data (GskVulkanColorPipeline *pipeline,
guchar *data,
const graphene_point_t *offset,
const graphene_rect_t *rect,
const GdkRGBA *color);
gsize gsk_vulkan_color_pipeline_draw (GskVulkanColorPipeline *pipeline,

View File

@@ -13,7 +13,6 @@ struct _GskVulkanColorTextInstance
{
float rect[4];
float tex_rect[4];
guint32 tex_id[2];
};
G_DEFINE_TYPE (GskVulkanColorTextPipeline, gsk_vulkan_color_text_pipeline, GSK_TYPE_VULKAN_PIPELINE)
@@ -41,12 +40,6 @@ gsk_vulkan_color_text_pipeline_get_input_state_create_info (GskVulkanPipeline *s
.format = VK_FORMAT_R32G32B32A32_SFLOAT,
.offset = G_STRUCT_OFFSET (GskVulkanColorTextInstance, tex_rect),
},
{
.location = 2,
.binding = 0,
.format = VK_FORMAT_R32G32_UINT,
.offset = G_STRUCT_OFFSET (GskVulkanColorTextInstance, tex_id),
}
};
static const VkPipelineVertexInputStateCreateInfo info = {
.sType = VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO,
@@ -91,12 +84,18 @@ gsk_vulkan_color_text_pipeline_new (GdkVulkanContext *context,
return gsk_vulkan_pipeline_new (GSK_TYPE_VULKAN_COLOR_TEXT_PIPELINE, context, layout, shader_name, render_pass);
}
gsize
gsk_vulkan_color_text_pipeline_count_vertex_data (GskVulkanColorTextPipeline *pipeline,
int num_instances)
{
return sizeof (GskVulkanColorTextInstance) * num_instances;
}
void
gsk_vulkan_color_text_pipeline_collect_vertex_data (GskVulkanColorTextPipeline *pipeline,
guchar *data,
GskVulkanRenderer *renderer,
const graphene_rect_t *rect,
guint tex_id[2],
PangoFont *font,
guint total_glyphs,
const PangoGlyphInfo *glyphs,
@@ -141,9 +140,6 @@ gsk_vulkan_color_text_pipeline_collect_vertex_data (GskVulkanColorTextPipeline *
instance->tex_rect[2] = glyph->tw;
instance->tex_rect[3] = glyph->th;
instance->tex_id[0] = tex_id[0];
instance->tex_id[1] = tex_id[1];
count++;
}
x_position += gi->geometry.width;

View File

@@ -18,11 +18,12 @@ GskVulkanPipeline * gsk_vulkan_color_text_pipeline_new (Gd
const char *shader_name,
VkRenderPass render_pass);
gsize gsk_vulkan_color_text_pipeline_count_vertex_data (GskVulkanColorTextPipeline *pipeline,
int num_instances);
void gsk_vulkan_color_text_pipeline_collect_vertex_data (GskVulkanColorTextPipeline *pipeline,
guchar *data,
GskVulkanRenderer *renderer,
const graphene_rect_t *rect,
guint tex_id[2],
PangoFont *font,
guint total_glyphs,
const PangoGlyphInfo *glyphs,

View File

@@ -12,12 +12,8 @@ typedef struct _GskVulkanCrossFadeInstance GskVulkanCrossFadeInstance;
struct _GskVulkanCrossFadeInstance
{
float rect[4];
float start_rect[4];
float end_rect[4];
float start_tex_rect[4];
float end_tex_rect[4];
guint32 start_tex_id[2];
guint32 end_tex_id[2];
float progress;
};
@@ -44,40 +40,16 @@ gsk_vulkan_cross_fade_pipeline_get_input_state_create_info (GskVulkanPipeline *s
.location = 1,
.binding = 0,
.format = VK_FORMAT_R32G32B32A32_SFLOAT,
.offset = G_STRUCT_OFFSET (GskVulkanCrossFadeInstance, start_rect),
.offset = G_STRUCT_OFFSET (GskVulkanCrossFadeInstance, start_tex_rect),
},
{
.location = 2,
.binding = 0,
.format = VK_FORMAT_R32G32B32A32_SFLOAT,
.offset = G_STRUCT_OFFSET (GskVulkanCrossFadeInstance, end_rect),
},
{
.location = 3,
.binding = 0,
.format = VK_FORMAT_R32G32B32A32_SFLOAT,
.offset = G_STRUCT_OFFSET (GskVulkanCrossFadeInstance, start_tex_rect),
},
{
.location = 4,
.binding = 0,
.format = VK_FORMAT_R32G32B32A32_SFLOAT,
.offset = G_STRUCT_OFFSET (GskVulkanCrossFadeInstance, end_tex_rect),
},
{
.location = 5,
.binding = 0,
.format = VK_FORMAT_R32G32_UINT,
.offset = G_STRUCT_OFFSET (GskVulkanCrossFadeInstance, start_tex_id),
},
{
.location = 6,
.binding = 0,
.format = VK_FORMAT_R32G32_UINT,
.offset = G_STRUCT_OFFSET (GskVulkanCrossFadeInstance, end_tex_id),
},
{
.location = 7,
.location = 3,
.binding = 0,
.format = VK_FORMAT_R32_SFLOAT,
.offset = G_STRUCT_OFFSET (GskVulkanCrossFadeInstance, progress),
@@ -126,36 +98,27 @@ gsk_vulkan_cross_fade_pipeline_new (GdkVulkanContext *context,
return gsk_vulkan_pipeline_new (GSK_TYPE_VULKAN_CROSS_FADE_PIPELINE, context, layout, shader_name, render_pass);
}
gsize
gsk_vulkan_cross_fade_pipeline_count_vertex_data (GskVulkanCrossFadePipeline *pipeline)
{
return sizeof (GskVulkanCrossFadeInstance);
}
void
gsk_vulkan_cross_fade_pipeline_collect_vertex_data (GskVulkanCrossFadePipeline *pipeline,
guchar *data,
guint32 start_tex_id[2],
guint32 end_tex_id[2],
const graphene_point_t *offset,
const graphene_rect_t *bounds,
const graphene_rect_t *start_bounds,
const graphene_rect_t *end_bounds,
const graphene_rect_t *start_tex_rect,
const graphene_rect_t *end_tex_rect,
double progress)
guchar *data,
const graphene_rect_t *bounds,
const graphene_rect_t *start_tex_rect,
const graphene_rect_t *end_tex_rect,
double progress)
{
GskVulkanCrossFadeInstance *instance = (GskVulkanCrossFadeInstance *) data;
instance->rect[0] = bounds->origin.x + offset->x;
instance->rect[1] = bounds->origin.y + offset->y;
instance->rect[0] = bounds->origin.x;
instance->rect[1] = bounds->origin.y;
instance->rect[2] = bounds->size.width;
instance->rect[3] = bounds->size.height;
instance->start_rect[0] = start_bounds->origin.x + offset->x;
instance->start_rect[1] = start_bounds->origin.y + offset->y;
instance->start_rect[2] = start_bounds->size.width;
instance->start_rect[3] = start_bounds->size.height;
instance->end_rect[0] = end_bounds->origin.x + offset->x;
instance->end_rect[1] = end_bounds->origin.y + offset->y;
instance->end_rect[2] = end_bounds->size.width;
instance->end_rect[3] = end_bounds->size.height;
instance->start_tex_rect[0] = start_tex_rect->origin.x;
instance->start_tex_rect[1] = start_tex_rect->origin.y;
instance->start_tex_rect[2] = start_tex_rect->size.width;
@@ -166,10 +129,6 @@ gsk_vulkan_cross_fade_pipeline_collect_vertex_data (GskVulkanCrossFadePipeline *
instance->end_tex_rect[2] = end_tex_rect->size.width;
instance->end_tex_rect[3] = end_tex_rect->size.height;
instance->start_tex_id[0] = start_tex_id[0];
instance->start_tex_id[1] = start_tex_id[1];
instance->end_tex_id[0] = end_tex_id[0];
instance->end_tex_id[1] = end_tex_id[1];
instance->progress = progress;
}

View File

@@ -17,16 +17,12 @@ GskVulkanPipeline * gsk_vulkan_cross_fade_pipeline_new (GdkVulka
const char *shader_name,
VkRenderPass render_pass);
gsize gsk_vulkan_cross_fade_pipeline_count_vertex_data (GskVulkanCrossFadePipeline *pipeline);
void gsk_vulkan_cross_fade_pipeline_collect_vertex_data (GskVulkanCrossFadePipeline *pipeline,
guchar *data,
guint32 start_tex_id[2],
guint32 end_tex_id[2],
const graphene_point_t *offset,
const graphene_rect_t *bounds,
const graphene_rect_t *start_bounds,
const graphene_rect_t *end_bounds,
const graphene_rect_t *start_tex_rect,
const graphene_rect_t *end_tex_rect,
double progress);
gsize gsk_vulkan_cross_fade_pipeline_draw (GskVulkanCrossFadePipeline *pipeline,
VkCommandBuffer command_buffer,

View File

@@ -15,7 +15,6 @@ struct _GskVulkanEffectInstance
float tex_rect[4];
float color_matrix[16];
float color_offset[4];
guint32 tex_id[2];
};
G_DEFINE_TYPE (GskVulkanEffectPipeline, gsk_vulkan_effect_pipeline, GSK_TYPE_VULKAN_PIPELINE)
@@ -72,12 +71,6 @@ gsk_vulkan_effect_pipeline_get_input_state_create_info (GskVulkanPipeline *self)
.binding = 0,
.format = VK_FORMAT_R32G32B32A32_SFLOAT,
.offset = G_STRUCT_OFFSET (GskVulkanEffectInstance, color_offset),
},
{
.location = 7,
.binding = 0,
.format = VK_FORMAT_R32G32_UINT,
.offset = G_STRUCT_OFFSET (GskVulkanEffectInstance, tex_id),
}
};
static const VkPipelineVertexInputStateCreateInfo info = {
@@ -123,11 +116,15 @@ gsk_vulkan_effect_pipeline_new (GdkVulkanContext *context,
return gsk_vulkan_pipeline_new (GSK_TYPE_VULKAN_EFFECT_PIPELINE, context, layout, shader_name, render_pass);
}
gsize
gsk_vulkan_effect_pipeline_count_vertex_data (GskVulkanEffectPipeline *pipeline)
{
return sizeof (GskVulkanEffectInstance);
}
void
gsk_vulkan_effect_pipeline_collect_vertex_data (GskVulkanEffectPipeline *pipeline,
guchar *data,
guint32 tex_id[2],
const graphene_point_t *offset,
const graphene_rect_t *rect,
const graphene_rect_t *tex_rect,
const graphene_matrix_t *color_matrix,
@@ -135,8 +132,8 @@ gsk_vulkan_effect_pipeline_collect_vertex_data (GskVulkanEffectPipeline *pipelin
{
GskVulkanEffectInstance *instance = (GskVulkanEffectInstance *) data;
instance->rect[0] = rect->origin.x + offset->x;
instance->rect[1] = rect->origin.y + offset->y;
instance->rect[0] = rect->origin.x;
instance->rect[1] = rect->origin.y;
instance->rect[2] = rect->size.width;
instance->rect[3] = rect->size.height;
instance->tex_rect[0] = tex_rect->origin.x;
@@ -145,8 +142,6 @@ gsk_vulkan_effect_pipeline_collect_vertex_data (GskVulkanEffectPipeline *pipelin
instance->tex_rect[3] = tex_rect->size.height;
graphene_matrix_to_float (color_matrix, instance->color_matrix);
graphene_vec4_to_float (color_offset, instance->color_offset);
instance->tex_id[0] = tex_id[0];
instance->tex_id[1] = tex_id[1];
}
gsize

View File

@@ -17,10 +17,9 @@ GskVulkanPipeline * gsk_vulkan_effect_pipeline_new (GdkVulk
const char *shader_name,
VkRenderPass render_pass);
gsize gsk_vulkan_effect_pipeline_count_vertex_data (GskVulkanEffectPipeline *pipeline);
void gsk_vulkan_effect_pipeline_collect_vertex_data (GskVulkanEffectPipeline *pipeline,
guchar *data,
guint32 tex_id[2],
const graphene_point_t *offset,
const graphene_rect_t *rect,
const graphene_rect_t *tex_rect,
const graphene_matrix_t *color_matrix,

View File

@@ -209,8 +209,6 @@ gsk_vulkan_image_new (GdkVulkanContext *context,
VkMemoryRequirements requirements;
GskVulkanImage *self;
g_assert (width > 0 && height > 0);
self = g_object_new (GSK_TYPE_VULKAN_IMAGE, NULL);
self->vulkan = g_object_ref (context);
@@ -608,9 +606,9 @@ gsk_vulkan_image_new_for_atlas (GdkVulkanContext *context,
}
GskVulkanImage *
gsk_vulkan_image_new_for_offscreen (GdkVulkanContext *context,
gsize width,
gsize height)
gsk_vulkan_image_new_for_texture (GdkVulkanContext *context,
gsize width,
gsize height)
{
GskVulkanImage *self;
@@ -622,7 +620,7 @@ gsk_vulkan_image_new_for_offscreen (GdkVulkanContext *context,
VK_IMAGE_USAGE_SAMPLED_BIT |
VK_IMAGE_USAGE_TRANSFER_SRC_BIT,
VK_IMAGE_LAYOUT_UNDEFINED,
VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT,
0,
VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT);
gsk_vulkan_image_ensure_view (self, VK_FORMAT_B8G8R8A8_UNORM);

View File

@@ -49,7 +49,7 @@ GskVulkanImage * gsk_vulkan_image_new_for_framebuffer (GdkVulk
GskVulkanImage * gsk_vulkan_image_new_for_atlas (GdkVulkanContext *context,
gsize width,
gsize height);
GskVulkanImage * gsk_vulkan_image_new_for_offscreen (GdkVulkanContext *context,
GskVulkanImage * gsk_vulkan_image_new_for_texture (GdkVulkanContext *context,
gsize width,
gsize height);

View File

@@ -167,10 +167,15 @@ gsk_vulkan_linear_gradient_pipeline_new (GdkVulkanContext *context,
return gsk_vulkan_pipeline_new (GSK_TYPE_VULKAN_LINEAR_GRADIENT_PIPELINE, context, layout, shader_name, render_pass);
}
gsize
gsk_vulkan_linear_gradient_pipeline_count_vertex_data (GskVulkanLinearGradientPipeline *pipeline)
{
return sizeof (GskVulkanLinearGradientInstance);
}
void
gsk_vulkan_linear_gradient_pipeline_collect_vertex_data (GskVulkanLinearGradientPipeline *pipeline,
guchar *data,
const graphene_point_t *offset,
const graphene_rect_t *rect,
const graphene_point_t *start,
const graphene_point_t *end,
@@ -186,14 +191,14 @@ gsk_vulkan_linear_gradient_pipeline_collect_vertex_data (GskVulkanLinearGradient
g_warning ("Only %u color stops supported.", GSK_VULKAN_LINEAR_GRADIENT_PIPELINE_MAX_COLOR_STOPS);
n_stops = GSK_VULKAN_LINEAR_GRADIENT_PIPELINE_MAX_COLOR_STOPS;
}
instance->rect[0] = rect->origin.x + offset->x;
instance->rect[1] = rect->origin.y + offset->y;
instance->rect[0] = rect->origin.x;
instance->rect[1] = rect->origin.y;
instance->rect[2] = rect->size.width;
instance->rect[3] = rect->size.height;
instance->start[0] = start->x + offset->x;
instance->start[1] = start->y + offset->y;
instance->end[0] = end->x + offset->x;
instance->end[1] = end->y + offset->y;
instance->start[0] = start->x;
instance->start[1] = start->y;
instance->end[0] = end->x;
instance->end[1] = end->y;
instance->repeating = repeating;
instance->stop_count = n_stops;
for (i = 0; i < n_stops; i++)

View File

@@ -20,10 +20,11 @@ GskVulkanPipeline * gsk_vulkan_linear_gradient_pipeline_new (GdkVulk
const char *shader_name,
VkRenderPass render_pass);
gsize gsk_vulkan_linear_gradient_pipeline_count_vertex_data
(GskVulkanLinearGradientPipeline*pipeline);
void gsk_vulkan_linear_gradient_pipeline_collect_vertex_data
(GskVulkanLinearGradientPipeline*pipeline,
guchar *data,
const graphene_point_t *offset,
const graphene_rect_t *rect,
const graphene_point_t *start,
const graphene_point_t *end,

View File

@@ -16,11 +16,10 @@ struct _GskVulkanPipelinePrivate
GdkVulkanContext *context;
VkPipeline pipeline;
VkPipelineLayout layout;
GskVulkanShader *vertex_shader;
GskVulkanShader *fragment_shader;
gsize vertex_stride;
};
G_DEFINE_TYPE_WITH_PRIVATE (GskVulkanPipeline, gsk_vulkan_pipeline, G_TYPE_OBJECT)
@@ -55,13 +54,12 @@ gsk_vulkan_pipeline_init (GskVulkanPipeline *self)
}
GskVulkanPipeline *
gsk_vulkan_pipeline_new (GType pipeline_type,
GdkVulkanContext *context,
VkPipelineLayout layout,
const char *shader_name,
VkRenderPass render_pass)
gsk_vulkan_pipeline_new (GType pipeline_type,
GdkVulkanContext *context,
VkPipelineLayout layout,
const char *shader_name,
VkRenderPass render_pass)
{
const VkPipelineVertexInputStateCreateInfo *vertex_input_state;
GskVulkanPipelinePrivate *priv;
GskVulkanPipeline *self;
VkDevice device;
@@ -78,14 +76,11 @@ gsk_vulkan_pipeline_new (GType pipeline_type,
device = gdk_vulkan_context_get_device (context);
priv->context = context;
priv->layout = layout;
priv->vertex_shader = gsk_vulkan_shader_new_from_resource (context, GSK_VULKAN_SHADER_VERTEX, shader_name, NULL);
priv->fragment_shader = gsk_vulkan_shader_new_from_resource (context, GSK_VULKAN_SHADER_FRAGMENT, shader_name, NULL);
vertex_input_state = GSK_VULKAN_PIPELINE_GET_CLASS (self)->get_input_state_create_info (self);
g_assert (vertex_input_state->vertexBindingDescriptionCount == 1);
priv->vertex_stride = vertex_input_state->pVertexBindingDescriptions[0].stride;
GSK_VK_CHECK (vkCreateGraphicsPipelines, device,
VK_NULL_HANDLE,
1,
@@ -96,7 +91,7 @@ gsk_vulkan_pipeline_new (GType pipeline_type,
GST_VULKAN_SHADER_STAGE_CREATE_INFO (priv->vertex_shader),
GST_VULKAN_SHADER_STAGE_CREATE_INFO (priv->fragment_shader)
},
.pVertexInputState = vertex_input_state,
.pVertexInputState = GSK_VULKAN_PIPELINE_GET_CLASS (self)->get_input_state_create_info (self),
.pInputAssemblyState = &(VkPipelineInputAssemblyStateCreateInfo) {
.sType = VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO,
.topology = VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST,
@@ -113,7 +108,7 @@ gsk_vulkan_pipeline_new (GType pipeline_type,
.depthClampEnable = VK_FALSE,
.rasterizerDiscardEnable = VK_FALSE,
.polygonMode = VK_POLYGON_MODE_FILL,
.cullMode = VK_CULL_MODE_NONE,
.cullMode = VK_CULL_MODE_BACK_BIT,
.frontFace = VK_FRONT_FACE_CLOCKWISE,
.lineWidth = 1.0f,
},
@@ -151,7 +146,7 @@ gsk_vulkan_pipeline_new (GType pipeline_type,
VK_DYNAMIC_STATE_SCISSOR
},
},
.layout = layout,
.layout = priv->layout,
.renderPass = render_pass,
.subpass = 0,
.basePipelineHandle = VK_NULL_HANDLE,
@@ -171,10 +166,10 @@ gsk_vulkan_pipeline_get_pipeline (GskVulkanPipeline *self)
return priv->pipeline;
}
gsize
gsk_vulkan_pipeline_get_vertex_stride (GskVulkanPipeline *self)
VkPipelineLayout
gsk_vulkan_pipeline_get_pipeline_layout (GskVulkanPipeline *self)
{
GskVulkanPipelinePrivate *priv = gsk_vulkan_pipeline_get_instance_private (self);
return priv->vertex_stride;
return priv->layout;
}

View File

@@ -37,7 +37,7 @@ GskVulkanPipeline * gsk_vulkan_pipeline_new (GType
const char *shader_name,
VkRenderPass render_pass);
VkPipeline gsk_vulkan_pipeline_get_pipeline (GskVulkanPipeline *self);
gsize gsk_vulkan_pipeline_get_vertex_stride (GskVulkanPipeline *self);
VkPipelineLayout gsk_vulkan_pipeline_get_pipeline_layout (GskVulkanPipeline *self);
G_END_DECLS

View File

@@ -12,37 +12,83 @@ struct _GskVulkanPushConstantsWire
struct {
float mvp[16];
float clip[12];
float scale[2];
} common;
};
/* This is the value we know every conformant GPU must provide.
* See value for maxPushConstantsSize in table 55 of
* https://registry.khronos.org/vulkan/specs/1.3-extensions/html/vkspec.html#limits-minmax
*/
G_STATIC_ASSERT (sizeof (GskVulkanPushConstantsWire) <= 128);
static void
gsk_vulkan_push_constants_wire_init (GskVulkanPushConstantsWire *wire,
const graphene_vec2_t *scale,
const graphene_matrix_t *mvp,
const GskRoundedRect *clip)
void
gsk_vulkan_push_constants_init (GskVulkanPushConstants *constants,
const graphene_matrix_t *mvp,
const graphene_rect_t *viewport)
{
graphene_matrix_to_float (mvp, wire->common.mvp);
gsk_rounded_rect_to_float (clip, graphene_point_zero (), wire->common.clip);
graphene_vec2_to_float (scale, wire->common.scale);
graphene_matrix_init_from_matrix (&constants->mvp, mvp);
gsk_vulkan_clip_init_empty (&constants->clip, viewport);
}
void
gsk_vulkan_push_constants_push (VkCommandBuffer command_buffer,
VkPipelineLayout pipeline_layout,
const graphene_vec2_t *scale,
const graphene_matrix_t *mvp,
const GskRoundedRect *clip)
gsk_vulkan_push_constants_init_copy (GskVulkanPushConstants *self,
const GskVulkanPushConstants *src)
{
*self = *src;
}
gboolean
gsk_vulkan_push_constants_transform (GskVulkanPushConstants *self,
const GskVulkanPushConstants *src,
GskTransform *transform,
const graphene_rect_t *viewport)
{
graphene_matrix_t matrix;
if (!gsk_vulkan_clip_transform (&self->clip, &src->clip, transform, viewport))
return FALSE;
gsk_transform_to_matrix (transform, &matrix);
graphene_matrix_multiply (&matrix, &src->mvp, &self->mvp);
return TRUE;
}
gboolean
gsk_vulkan_push_constants_intersect_rect (GskVulkanPushConstants *self,
const GskVulkanPushConstants *src,
const graphene_rect_t *rect)
{
if (!gsk_vulkan_clip_intersect_rect (&self->clip, &src->clip, rect))
return FALSE;
graphene_matrix_init_from_matrix (&self->mvp, &src->mvp);
return TRUE;
}
gboolean
gsk_vulkan_push_constants_intersect_rounded (GskVulkanPushConstants *self,
const GskVulkanPushConstants *src,
const GskRoundedRect *rect)
{
if (!gsk_vulkan_clip_intersect_rounded_rect (&self->clip, &src->clip, rect))
return FALSE;
graphene_matrix_init_from_matrix (&self->mvp, &src->mvp);
return TRUE;
}
static void
gsk_vulkan_push_constants_wire_init (GskVulkanPushConstantsWire *wire,
const GskVulkanPushConstants *self)
{
graphene_matrix_to_float (&self->mvp, wire->common.mvp);
gsk_rounded_rect_to_float (&self->clip.rect, wire->common.clip);
}
void
gsk_vulkan_push_constants_push (const GskVulkanPushConstants *self,
VkCommandBuffer command_buffer,
VkPipelineLayout pipeline_layout)
{
GskVulkanPushConstantsWire wire;
gsk_vulkan_push_constants_wire_init (&wire, scale, mvp, clip);
gsk_vulkan_push_constants_wire_init (&wire, self);
vkCmdPushConstants (command_buffer,
pipeline_layout,

View File

@@ -6,15 +6,38 @@
G_BEGIN_DECLS
typedef struct _GskVulkanPushConstants GskVulkanPushConstants;
struct _GskVulkanPushConstants
{
graphene_matrix_t mvp;
GskVulkanClip clip;
};
const VkPushConstantRange *
gsk_vulkan_push_constants_get_ranges (void) G_GNUC_PURE;
uint32_t gsk_vulkan_push_constants_get_range_count (void) G_GNUC_PURE;
void gsk_vulkan_push_constants_push (VkCommandBuffer command_buffer,
VkPipelineLayout pipeline_layout,
const graphene_vec2_t *scale,
void gsk_vulkan_push_constants_init (GskVulkanPushConstants *constants,
const graphene_matrix_t *mvp,
const GskRoundedRect *clip);
const graphene_rect_t *viewport);
void gsk_vulkan_push_constants_init_copy (GskVulkanPushConstants *self,
const GskVulkanPushConstants *src);
gboolean gsk_vulkan_push_constants_transform (GskVulkanPushConstants *self,
const GskVulkanPushConstants *src,
GskTransform *transform,
const graphene_rect_t *viewport);
gboolean gsk_vulkan_push_constants_intersect_rect (GskVulkanPushConstants *self,
const GskVulkanPushConstants *src,
const graphene_rect_t *rect);
gboolean gsk_vulkan_push_constants_intersect_rounded (GskVulkanPushConstants *self,
const GskVulkanPushConstants *src,
const GskRoundedRect *rect);
void gsk_vulkan_push_constants_push (const GskVulkanPushConstants *self,
VkCommandBuffer command_buffer,
VkPipelineLayout pipeline_layout);
G_END_DECLS

View File

@@ -23,15 +23,8 @@
#include "gskvulkantexturepipelineprivate.h"
#include "gskvulkanpushconstantsprivate.h"
#define DESCRIPTOR_POOL_MAXITEMS 50000
#define GDK_ARRAY_NAME gsk_descriptor_image_infos
#define GDK_ARRAY_TYPE_NAME GskDescriptorImageInfos
#define GDK_ARRAY_ELEMENT_TYPE VkDescriptorImageInfo
#define GDK_ARRAY_BY_VALUE 1
#define GDK_ARRAY_PREALLOC 1024
#define GDK_ARRAY_NO_MEMSET 1
#include "gdk/gdkarrayimpl.c"
#define DESCRIPTOR_POOL_MAXSETS 128
#define DESCRIPTOR_POOL_MAXSETS_INCREASE 128
struct _GskVulkanRender
{
@@ -47,18 +40,20 @@ struct _GskVulkanRender
VkFence fence;
VkRenderPass render_pass;
VkDescriptorSetLayout descriptor_set_layout;
VkPipelineLayout pipeline_layout;
VkPipelineLayout pipeline_layout[3]; /* indexed by number of textures */
GskVulkanUploader *uploader;
GskDescriptorImageInfos descriptor_images;
GskDescriptorImageInfos descriptor_samplers;
GHashTable *descriptor_set_indexes;
VkDescriptorPool descriptor_pool;
VkDescriptorSet descriptor_set;
uint32_t descriptor_pool_maxsets;
VkDescriptorSet *descriptor_sets;
gsize n_descriptor_sets;
GskVulkanPipeline *pipelines[GSK_VULKAN_N_PIPELINES];
GskVulkanImage *target;
VkSampler samplers[3];
VkSampler sampler;
VkSampler repeating_sampler;
GList *render_passes;
GSList *cleanup_images;
@@ -108,6 +103,9 @@ gsk_vulkan_render_setup (GskVulkanRender *self,
}
}
static guint desc_set_index_hash (gconstpointer v);
static gboolean desc_set_index_equal (gconstpointer v1, gconstpointer v2);
GskVulkanRender *
gsk_vulkan_render_new (GskRenderer *renderer,
GdkVulkanContext *context)
@@ -120,8 +118,7 @@ gsk_vulkan_render_new (GskRenderer *renderer,
self->vulkan = context;
self->renderer = renderer;
self->framebuffers = g_hash_table_new (g_direct_hash, g_direct_equal);
gsk_descriptor_image_infos_init (&self->descriptor_images);
gsk_descriptor_image_infos_init (&self->descriptor_samplers);
self->descriptor_set_indexes = g_hash_table_new_full (desc_set_index_hash, desc_set_index_equal, NULL, g_free);
device = gdk_vulkan_context_get_device (self->vulkan);
@@ -134,20 +131,16 @@ gsk_vulkan_render_new (GskRenderer *renderer,
NULL,
&self->fence);
self->descriptor_pool_maxsets = DESCRIPTOR_POOL_MAXSETS;
GSK_VK_CHECK (vkCreateDescriptorPool, device,
&(VkDescriptorPoolCreateInfo) {
.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO,
.flags = VK_DESCRIPTOR_POOL_CREATE_UPDATE_AFTER_BIND_BIT,
.maxSets = 1,
.poolSizeCount = 2,
.pPoolSizes = (VkDescriptorPoolSize[2]) {
.maxSets = self->descriptor_pool_maxsets,
.poolSizeCount = 1,
.pPoolSizes = (VkDescriptorPoolSize[1]) {
{
.type = VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE,
.descriptorCount = DESCRIPTOR_POOL_MAXITEMS
},
{
.type = VK_DESCRIPTOR_TYPE_SAMPLER,
.descriptorCount = DESCRIPTOR_POOL_MAXITEMS
.type = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER,
.descriptorCount = self->descriptor_pool_maxsets
}
}
},
@@ -197,65 +190,53 @@ gsk_vulkan_render_new (GskRenderer *renderer,
GSK_VK_CHECK (vkCreateDescriptorSetLayout, device,
&(VkDescriptorSetLayoutCreateInfo) {
.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO,
.bindingCount = 2,
.flags = VK_DESCRIPTOR_SET_LAYOUT_CREATE_UPDATE_AFTER_BIND_POOL_BIT,
.pBindings = (VkDescriptorSetLayoutBinding[2]) {
.bindingCount = 1,
.pBindings = (VkDescriptorSetLayoutBinding[1]) {
{
.binding = 0,
.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE,
.descriptorCount = DESCRIPTOR_POOL_MAXITEMS,
.stageFlags = VK_SHADER_STAGE_FRAGMENT_BIT
},
{
.binding = 1,
.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER,
.descriptorCount = DESCRIPTOR_POOL_MAXITEMS,
.descriptorType = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER,
.descriptorCount = 1,
.stageFlags = VK_SHADER_STAGE_FRAGMENT_BIT
}
},
.pNext = &(VkDescriptorSetLayoutBindingFlagsCreateInfo) {
.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_BINDING_FLAGS_CREATE_INFO,
.bindingCount = 2,
.pBindingFlags = (VkDescriptorBindingFlags[2]) {
VK_DESCRIPTOR_BINDING_PARTIALLY_BOUND_BIT
| VK_DESCRIPTOR_BINDING_VARIABLE_DESCRIPTOR_COUNT_BIT
| VK_DESCRIPTOR_BINDING_UPDATE_AFTER_BIND_BIT,
VK_DESCRIPTOR_BINDING_PARTIALLY_BOUND_BIT
| VK_DESCRIPTOR_BINDING_VARIABLE_DESCRIPTOR_COUNT_BIT
| VK_DESCRIPTOR_BINDING_UPDATE_AFTER_BIND_BIT,
},
}
},
NULL,
&self->descriptor_set_layout);
GSK_VK_CHECK (vkCreatePipelineLayout, device,
&(VkPipelineLayoutCreateInfo) {
.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO,
.setLayoutCount = 1,
.pSetLayouts = (VkDescriptorSetLayout[1]) {
self->descriptor_set_layout
for (guint i = 0; i < 3; i++)
{
VkDescriptorSetLayout layouts[3] = {
self->descriptor_set_layout,
self->descriptor_set_layout,
self->descriptor_set_layout
};
GSK_VK_CHECK (vkCreatePipelineLayout, device,
&(VkPipelineLayoutCreateInfo) {
.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO,
.setLayoutCount = i,
.pSetLayouts = layouts,
.pushConstantRangeCount = gsk_vulkan_push_constants_get_range_count (),
.pPushConstantRanges = gsk_vulkan_push_constants_get_ranges ()
},
.pushConstantRangeCount = gsk_vulkan_push_constants_get_range_count (),
.pPushConstantRanges = gsk_vulkan_push_constants_get_ranges ()
},
NULL,
&self->pipeline_layout);
NULL,
&self->pipeline_layout[i]);
}
GSK_VK_CHECK (vkCreateSampler, device,
&(VkSamplerCreateInfo) {
.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO,
.magFilter = VK_FILTER_LINEAR,
.minFilter = VK_FILTER_LINEAR,
.addressModeU = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE,
.addressModeV = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE,
.addressModeU = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER,
.addressModeV = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER,
.addressModeW = VK_SAMPLER_ADDRESS_MODE_REPEAT,
.borderColor = VK_BORDER_COLOR_FLOAT_TRANSPARENT_BLACK,
.unnormalizedCoordinates = VK_FALSE,
.maxAnisotropy = 1.0,
},
NULL,
&self->samplers[GSK_VULKAN_SAMPLER_DEFAULT]);
&self->sampler);
GSK_VK_CHECK (vkCreateSampler, device,
&(VkSamplerCreateInfo) {
@@ -270,23 +251,7 @@ gsk_vulkan_render_new (GskRenderer *renderer,
.maxAnisotropy = 1.0,
},
NULL,
&self->samplers[GSK_VULKAN_SAMPLER_REPEAT]);
GSK_VK_CHECK (vkCreateSampler, device,
&(VkSamplerCreateInfo) {
.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO,
.magFilter = VK_FILTER_NEAREST,
.minFilter = VK_FILTER_NEAREST,
.addressModeU = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE,
.addressModeV = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE,
.addressModeW = VK_SAMPLER_ADDRESS_MODE_REPEAT,
.borderColor = VK_BORDER_COLOR_FLOAT_TRANSPARENT_BLACK,
.unnormalizedCoordinates = VK_FALSE,
.maxAnisotropy = 1.0,
},
NULL,
&self->samplers[GSK_VULKAN_SAMPLER_NEAREST]);
&self->repeating_sampler);
self->uploader = gsk_vulkan_uploader_new (self->vulkan, self->command_pool);
@@ -350,12 +315,6 @@ gsk_vulkan_render_get_framebuffer (GskVulkanRender *self,
return fb->framebuffer;
}
VkFence
gsk_vulkan_render_get_fence (GskVulkanRender *self)
{
return self->fence;
}
void
gsk_vulkan_render_add_cleanup_image (GskVulkanRender *self,
GskVulkanImage *image)
@@ -379,13 +338,15 @@ gsk_vulkan_render_add_node (GskVulkanRender *self,
GskRenderNode *node)
{
GskVulkanRenderPass *pass;
graphene_vec2_t scale;
graphene_matrix_t mv;
graphene_vec2_init (&scale, self->scale, self->scale);
graphene_matrix_init_scale (&mv, self->scale, self->scale, 1.0);
pass = gsk_vulkan_render_pass_new (self->vulkan,
self->target,
&scale,
self->scale,
self->scale,
&mv,
&self->viewport,
self->clip,
VK_NULL_HANDLE);
@@ -464,7 +425,7 @@ gsk_vulkan_render_get_pipeline (GskVulkanRender *self,
if (self->pipelines[type] == NULL)
self->pipelines[type] = pipeline_info[type].create_func (self->vulkan,
self->pipeline_layout,
self->pipeline_layout[pipeline_info[type].num_textures],
pipeline_info[type].name,
self->render_pass);
@@ -472,59 +433,71 @@ gsk_vulkan_render_get_pipeline (GskVulkanRender *self,
}
VkDescriptorSet
gsk_vulkan_render_get_descriptor_set (GskVulkanRender *self)
gsk_vulkan_render_get_descriptor_set (GskVulkanRender *self,
gsize id)
{
return self->descriptor_set;
g_assert (id < self->n_descriptor_sets);
return self->descriptor_sets[id];
}
typedef struct {
gsize index;
GskVulkanImage *image;
gboolean repeat;
} HashDescriptorSetIndexEntry;
static guint
desc_set_index_hash (gconstpointer v)
{
const HashDescriptorSetIndexEntry *e = v;
return GPOINTER_TO_UINT (e->image) + e->repeat;
}
static gboolean
desc_set_index_equal (gconstpointer v1, gconstpointer v2)
{
const HashDescriptorSetIndexEntry *e1 = v1;
const HashDescriptorSetIndexEntry *e2 = v2;
return e1->image == e2->image && e1->repeat == e2->repeat;
}
gsize
gsk_vulkan_render_get_sampler_descriptor (GskVulkanRender *self,
GskVulkanRenderSampler render_sampler)
gsk_vulkan_render_reserve_descriptor_set (GskVulkanRender *self,
GskVulkanImage *source,
gboolean repeat)
{
VkSampler sampler = self->samplers[render_sampler];
gsize i;
HashDescriptorSetIndexEntry lookup;
HashDescriptorSetIndexEntry *entry;
/* If this ever shows up in profiles, add a hash table */
for (i = 0; i < gsk_descriptor_image_infos_get_size (&self->descriptor_samplers); i++)
{
if (gsk_descriptor_image_infos_get (&self->descriptor_samplers, i)->sampler == sampler)
return i;
}
g_assert (source != NULL);
g_assert (i < DESCRIPTOR_POOL_MAXITEMS);
lookup.image = source;
lookup.repeat = repeat;
gsk_descriptor_image_infos_append (&self->descriptor_samplers,
&(VkDescriptorImageInfo) {
.sampler = sampler,
});
entry = g_hash_table_lookup (self->descriptor_set_indexes, &lookup);
if (entry)
return entry->index;
return i;
}
entry = g_new (HashDescriptorSetIndexEntry, 1);
entry->image = source;
entry->repeat = repeat;
entry->index = g_hash_table_size (self->descriptor_set_indexes);
g_hash_table_add (self->descriptor_set_indexes, entry);
gsize
gsk_vulkan_render_get_image_descriptor (GskVulkanRender *self,
GskVulkanImage *image)
{
gsize result;
result = gsk_descriptor_image_infos_get_size (&self->descriptor_images);
gsk_descriptor_image_infos_append (&self->descriptor_images,
&(VkDescriptorImageInfo) {
.sampler = VK_NULL_HANDLE,
.imageView = gsk_vulkan_image_get_image_view (image),
.imageLayout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL
});
g_assert (result < DESCRIPTOR_POOL_MAXITEMS);
return result;
return entry->index;
}
static void
gsk_vulkan_render_prepare_descriptor_sets (GskVulkanRender *self)
{
GHashTableIter iter;
gpointer key;
VkDevice device;
GList *l;
guint i, needed_sets;
device = gdk_vulkan_context_get_device (self->vulkan);
@@ -534,50 +507,85 @@ gsk_vulkan_render_prepare_descriptor_sets (GskVulkanRender *self)
gsk_vulkan_render_pass_reserve_descriptor_sets (pass, self);
}
if (gsk_descriptor_image_infos_get_size (&self->descriptor_samplers) == 0 &&
gsk_descriptor_image_infos_get_size (&self->descriptor_images) == 0)
return;
needed_sets = g_hash_table_size (self->descriptor_set_indexes);
if (needed_sets > self->n_descriptor_sets)
{
if (needed_sets > self->descriptor_pool_maxsets)
{
guint added_sets = needed_sets - self->descriptor_pool_maxsets;
added_sets = added_sets + DESCRIPTOR_POOL_MAXSETS_INCREASE - 1;
added_sets -= added_sets % DESCRIPTOR_POOL_MAXSETS_INCREASE;
vkDestroyDescriptorPool (device,
self->descriptor_pool,
NULL);
self->descriptor_pool_maxsets += added_sets;
GSK_VK_CHECK (vkCreateDescriptorPool, device,
&(VkDescriptorPoolCreateInfo) {
.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO,
.maxSets = self->descriptor_pool_maxsets,
.poolSizeCount = 1,
.pPoolSizes = (VkDescriptorPoolSize[1]) {
{
.type = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER,
.descriptorCount = self->descriptor_pool_maxsets
}
}
},
NULL,
&self->descriptor_pool);
}
else
{
GSK_VK_CHECK (vkResetDescriptorPool, device,
self->descriptor_pool,
0);
}
self->n_descriptor_sets = needed_sets;
self->descriptor_sets = g_renew (VkDescriptorSet, self->descriptor_sets, needed_sets);
}
VkDescriptorSetLayout *layouts = g_newa (VkDescriptorSetLayout, needed_sets);
for (i = 0; i < needed_sets; i++)
layouts[i] = self->descriptor_set_layout;
GSK_VK_CHECK (vkAllocateDescriptorSets, device,
&(VkDescriptorSetAllocateInfo) {
.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO,
.descriptorPool = self->descriptor_pool,
.descriptorSetCount = 1,
.pSetLayouts = &self->descriptor_set_layout,
.pNext = &(VkDescriptorSetVariableDescriptorCountAllocateInfo) {
.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_VARIABLE_DESCRIPTOR_COUNT_ALLOCATE_INFO,
.descriptorSetCount = 1,
.pDescriptorCounts = (uint32_t[1]) {
gsk_descriptor_image_infos_get_size (&self->descriptor_images)
+ gsk_descriptor_image_infos_get_size (&self->descriptor_samplers)
}
}
.descriptorSetCount = needed_sets,
.pSetLayouts = layouts
},
&self->descriptor_set);
self->descriptor_sets);
vkUpdateDescriptorSets (device,
2,
(VkWriteDescriptorSet[2]) {
{
.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET,
.dstSet = self->descriptor_set,
.dstBinding = 0,
.dstArrayElement = 0,
.descriptorCount = gsk_descriptor_image_infos_get_size (&self->descriptor_images),
.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE,
.pImageInfo = gsk_descriptor_image_infos_get_data (&self->descriptor_images)
g_hash_table_iter_init (&iter, self->descriptor_set_indexes);
while (g_hash_table_iter_next (&iter, &key, NULL))
{
HashDescriptorSetIndexEntry *entry = key;
GskVulkanImage *image = entry->image;
gsize id = entry->index;
gboolean repeat = entry->repeat;
vkUpdateDescriptorSets (device,
1,
(VkWriteDescriptorSet[1]) {
{
.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET,
.dstSet = self->descriptor_sets[id],
.dstBinding = 0,
.dstArrayElement = 0,
.descriptorCount = 1,
.descriptorType = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER,
.pImageInfo = &(VkDescriptorImageInfo) {
.sampler = repeat ? self->repeating_sampler : self->sampler,
.imageView = gsk_vulkan_image_get_image_view (image),
.imageLayout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL
}
}
},
{
.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET,
.dstSet = self->descriptor_set,
.dstBinding = 1,
.dstArrayElement = 0,
.descriptorCount = gsk_descriptor_image_infos_get_size (&self->descriptor_samplers),
.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER,
.pImageInfo = gsk_descriptor_image_infos_get_data (&self->descriptor_samplers)
}
},
0, NULL);
0, NULL);
}
}
void
@@ -606,7 +614,7 @@ gsk_vulkan_render_draw (GskVulkanRender *self)
command_buffer = gsk_vulkan_command_pool_get_buffer (self->command_pool);
gsk_vulkan_render_pass_draw (pass, self, self->pipeline_layout, command_buffer);
gsk_vulkan_render_pass_draw (pass, self, 3, self->pipeline_layout, command_buffer);
gsk_vulkan_command_pool_submit_buffer (self->command_pool,
command_buffer,
@@ -667,11 +675,10 @@ gsk_vulkan_render_cleanup (GskVulkanRender *self)
gsk_vulkan_command_pool_reset (self->command_pool);
g_hash_table_remove_all (self->descriptor_set_indexes);
GSK_VK_CHECK (vkResetDescriptorPool, device,
self->descriptor_pool,
0);
gsk_descriptor_image_infos_set_size (&self->descriptor_images, 0);
gsk_descriptor_image_infos_set_size (&self->descriptor_samplers, 0);
g_list_free_full (self->render_passes, (GDestroyNotify) gsk_vulkan_render_pass_free);
self->render_passes = NULL;
@@ -713,10 +720,10 @@ gsk_vulkan_render_free (GskVulkanRender *self)
g_clear_pointer (&self->uploader, gsk_vulkan_uploader_free);
vkDestroyPipelineLayout (device,
self->pipeline_layout,
NULL);
for (i = 0; i < 3; i++)
vkDestroyPipelineLayout (device,
self->pipeline_layout[i],
NULL);
vkDestroyRenderPass (device,
self->render_pass,
@@ -725,8 +732,8 @@ gsk_vulkan_render_free (GskVulkanRender *self)
vkDestroyDescriptorPool (device,
self->descriptor_pool,
NULL);
gsk_descriptor_image_infos_clear (&self->descriptor_images);
gsk_descriptor_image_infos_clear (&self->descriptor_samplers);
g_free (self->descriptor_sets);
g_hash_table_unref (self->descriptor_set_indexes);
vkDestroyDescriptorSetLayout (device,
self->descriptor_set_layout,
@@ -736,12 +743,13 @@ gsk_vulkan_render_free (GskVulkanRender *self)
self->fence,
NULL);
for (i = 0; i < G_N_ELEMENTS (self->samplers); i++)
{
vkDestroySampler (device,
self->samplers[i],
NULL);
}
vkDestroySampler (device,
self->sampler,
NULL);
vkDestroySampler (device,
self->repeating_sampler,
NULL);
gsk_vulkan_command_pool_free (self->command_pool);

View File

@@ -17,8 +17,6 @@
#include <graphene.h>
#define GSK_VULKAN_MAX_RENDERS 4
typedef struct _GskVulkanTextureData GskVulkanTextureData;
struct _GskVulkanTextureData {
@@ -53,7 +51,7 @@ struct _GskVulkanRenderer
guint n_targets;
GskVulkanImage **targets;
GskVulkanRender *renders[GSK_VULKAN_MAX_RENDERS];
GskVulkanRender *render;
GSList *textures;
@@ -163,38 +161,6 @@ gsk_vulkan_renderer_update_images_cb (GdkVulkanContext *context,
}
}
static GskVulkanRender *
gsk_vulkan_renderer_get_render (GskVulkanRenderer *self)
{
VkFence fences[G_N_ELEMENTS (self->renders)];
VkDevice device;
guint i;
device = gdk_vulkan_context_get_device (self->vulkan);
while (TRUE)
{
for (i = 0; i < G_N_ELEMENTS (self->renders); i++)
{
if (self->renders[i] == NULL)
{
self->renders[i] = gsk_vulkan_render_new (GSK_RENDERER (self), self->vulkan);
return self->renders[i];
}
fences[i] = gsk_vulkan_render_get_fence (self->renders[i]);
if (vkGetFenceStatus (device, fences[i]) == VK_SUCCESS)
return self->renders[i];
}
GSK_VK_CHECK (vkWaitForFences, device,
G_N_ELEMENTS (fences),
fences,
VK_FALSE,
INT64_MAX);
}
}
static gboolean
gsk_vulkan_renderer_realize (GskRenderer *renderer,
GdkSurface *surface,
@@ -219,6 +185,8 @@ gsk_vulkan_renderer_realize (GskRenderer *renderer,
self);
gsk_vulkan_renderer_update_images_cb (self->vulkan, self);
self->render = gsk_vulkan_render_new (renderer, self->vulkan);
self->glyph_cache = gsk_vulkan_glyph_cache_new (renderer, self->vulkan);
return TRUE;
@@ -229,7 +197,6 @@ gsk_vulkan_renderer_unrealize (GskRenderer *renderer)
{
GskVulkanRenderer *self = GSK_VULKAN_RENDERER (renderer);
GSList *l;
guint i;
g_clear_object (&self->glyph_cache);
@@ -242,8 +209,7 @@ gsk_vulkan_renderer_unrealize (GskRenderer *renderer)
}
g_clear_pointer (&self->textures, g_slist_free);
for (i = 0; i < G_N_ELEMENTS (self->renders); i++)
g_clear_pointer (&self->renders[i], gsk_vulkan_render_free);
g_clear_pointer (&self->render, gsk_vulkan_render_free);
gsk_vulkan_renderer_free_targets (self);
g_signal_handlers_disconnect_by_func(self->vulkan,
@@ -262,7 +228,6 @@ gsk_vulkan_renderer_render_texture (GskRenderer *renderer,
GskVulkanRender *render;
GskVulkanImage *image;
GdkTexture *texture;
graphene_rect_t rounded_viewport;
#ifdef G_ENABLE_DEBUG
GskProfiler *profiler;
gint64 cpu_time;
@@ -279,15 +244,11 @@ gsk_vulkan_renderer_render_texture (GskRenderer *renderer,
render = gsk_vulkan_render_new (renderer, self->vulkan);
rounded_viewport = GRAPHENE_RECT_INIT (viewport->origin.x,
viewport->origin.y,
ceil (viewport->size.width),
ceil (viewport->size.height));
image = gsk_vulkan_image_new_for_framebuffer (self->vulkan,
rounded_viewport.size.width,
rounded_viewport.size.height);
ceil (viewport->size.width),
ceil (viewport->size.height));
gsk_vulkan_render_reset (render, image, &rounded_viewport, NULL);
gsk_vulkan_render_reset (render, image, viewport, NULL);
gsk_vulkan_render_add_node (render, root);
gsk_vulkan_render_upload (render);
gsk_vulkan_render_draw (render);
@@ -340,7 +301,7 @@ gsk_vulkan_renderer_render (GskRenderer *renderer,
#endif
gdk_draw_context_begin_frame (GDK_DRAW_CONTEXT (self->vulkan), region);
render = gsk_vulkan_renderer_get_render (self);
render = self->render;
render_region = get_render_region (self);
draw_index = gdk_vulkan_context_get_draw_index (self->vulkan);

File diff suppressed because it is too large Load Diff

View File

@@ -12,8 +12,10 @@ G_BEGIN_DECLS
GskVulkanRenderPass * gsk_vulkan_render_pass_new (GdkVulkanContext *context,
GskVulkanImage *target,
const graphene_vec2_t *scale,
const graphene_rect_t *viewport,
float scale_x,
float scale_y,
graphene_matrix_t *mv,
graphene_rect_t *viewport,
cairo_region_t *clip,
VkSemaphore signal_semaphore);
@@ -30,7 +32,8 @@ void gsk_vulkan_render_pass_reserve_descriptor_sets (GskVulk
GskVulkanRender *render);
void gsk_vulkan_render_pass_draw (GskVulkanRenderPass *self,
GskVulkanRender *render,
VkPipelineLayout pipeline_layout,
guint layout_count,
VkPipelineLayout *pipeline_layout,
VkCommandBuffer command_buffer);
gsize gsk_vulkan_render_pass_get_wait_semaphores (GskVulkanRenderPass *self,
VkSemaphore **semaphores);

View File

@@ -51,12 +51,6 @@ typedef enum {
GSK_VULKAN_N_PIPELINES
} GskVulkanPipelineType;
typedef enum {
GSK_VULKAN_SAMPLER_DEFAULT,
GSK_VULKAN_SAMPLER_REPEAT,
GSK_VULKAN_SAMPLER_NEAREST
} GskVulkanRenderSampler;
GskVulkanRender * gsk_vulkan_render_new (GskRenderer *renderer,
GdkVulkanContext *context);
void gsk_vulkan_render_free (GskVulkanRender *self);
@@ -82,12 +76,11 @@ void gsk_vulkan_render_upload (GskVulk
GskVulkanPipeline * gsk_vulkan_render_get_pipeline (GskVulkanRender *self,
GskVulkanPipelineType pipeline_type);
gsize gsk_vulkan_render_get_sampler_descriptor (GskVulkanRender *self,
GskVulkanRenderSampler render_sampler);
gsize gsk_vulkan_render_get_image_descriptor (GskVulkanRender *self,
GskVulkanImage *source);
VkDescriptorSet gsk_vulkan_render_get_descriptor_set (GskVulkanRender *self);
VkDescriptorSet gsk_vulkan_render_get_descriptor_set (GskVulkanRender *self,
gsize id);
gsize gsk_vulkan_render_reserve_descriptor_set (GskVulkanRender *self,
GskVulkanImage *source,
gboolean repeat);
void gsk_vulkan_render_draw (GskVulkanRender *self);
void gsk_vulkan_render_submit (GskVulkanRender *self);
@@ -95,7 +88,6 @@ void gsk_vulkan_render_submit (GskVulk
GdkTexture * gsk_vulkan_render_download_target (GskVulkanRender *self);
VkFramebuffer gsk_vulkan_render_get_framebuffer (GskVulkanRender *self,
GskVulkanImage *image);
VkFence gsk_vulkan_render_get_fence (GskVulkanRender *self);
G_END_DECLS

View File

@@ -14,7 +14,6 @@ struct _GskVulkanTextInstance
float rect[4];
float tex_rect[4];
float color[4];
guint32 tex_id[2];
};
G_DEFINE_TYPE (GskVulkanTextPipeline, gsk_vulkan_text_pipeline, GSK_TYPE_VULKAN_PIPELINE)
@@ -47,12 +46,6 @@ gsk_vulkan_text_pipeline_get_input_state_create_info (GskVulkanPipeline *self)
.binding = 0,
.format = VK_FORMAT_R32G32B32A32_SFLOAT,
.offset = G_STRUCT_OFFSET (GskVulkanTextInstance, color),
},
{
.location = 3,
.binding = 0,
.format = VK_FORMAT_R32G32_UINT,
.offset = G_STRUCT_OFFSET (GskVulkanTextInstance, tex_id),
}
};
static const VkPipelineVertexInputStateCreateInfo info = {
@@ -98,12 +91,18 @@ gsk_vulkan_text_pipeline_new (GdkVulkanContext *context,
return gsk_vulkan_pipeline_new (GSK_TYPE_VULKAN_TEXT_PIPELINE, context, layout, shader_name, render_pass);
}
gsize
gsk_vulkan_text_pipeline_count_vertex_data (GskVulkanTextPipeline *pipeline,
int num_instances)
{
return sizeof (GskVulkanTextInstance) * num_instances;
}
void
gsk_vulkan_text_pipeline_collect_vertex_data (GskVulkanTextPipeline *pipeline,
guchar *data,
GskVulkanRenderer *renderer,
const graphene_rect_t *rect,
guint tex_id[2],
PangoFont *font,
guint total_glyphs,
const PangoGlyphInfo *glyphs,
@@ -154,9 +153,6 @@ gsk_vulkan_text_pipeline_collect_vertex_data (GskVulkanTextPipeline *pipeline,
instance->color[2] = color->blue;
instance->color[3] = color->alpha;
instance->tex_id[0] = tex_id[0];
instance->tex_id[1] = tex_id[1];
count++;
}
x_position += gi->geometry.width;

View File

@@ -18,23 +18,24 @@ GskVulkanPipeline * gsk_vulkan_text_pipeline_new (GdkVulka
const char *shader_name,
VkRenderPass render_pass);
gsize gsk_vulkan_text_pipeline_count_vertex_data (GskVulkanTextPipeline *pipeline,
int num_instances);
void gsk_vulkan_text_pipeline_collect_vertex_data (GskVulkanTextPipeline *pipeline,
guchar *data,
GskVulkanRenderer *renderer,
const graphene_rect_t *rect,
guint32 tex_id[2],
PangoFont *font,
guint total_glyphs,
const PangoGlyphInfo *glyphs,
const GdkRGBA *color,
const graphene_point_t *offset,
guint start_glyph,
guint num_glyphs,
float scale);
guchar *data,
GskVulkanRenderer *renderer,
const graphene_rect_t *rect,
PangoFont *font,
guint total_glyphs,
const PangoGlyphInfo *glyphs,
const GdkRGBA *color,
const graphene_point_t *offset,
guint start_glyph,
guint num_glyphs,
float scale);
gsize gsk_vulkan_text_pipeline_draw (GskVulkanTextPipeline *pipeline,
VkCommandBuffer command_buffer,
gsize offset,
gsize n_commands);
VkCommandBuffer command_buffer,
gsize offset,
gsize n_commands);
G_END_DECLS

View File

@@ -13,7 +13,6 @@ struct _GskVulkanTextureInstance
{
float rect[4];
float tex_rect[4];
guint32 tex_id[2];
};
G_DEFINE_TYPE (GskVulkanTexturePipeline, gsk_vulkan_texture_pipeline, GSK_TYPE_VULKAN_PIPELINE)
@@ -40,12 +39,6 @@ gsk_vulkan_texture_pipeline_get_input_state_create_info (GskVulkanPipeline *self
.binding = 0,
.format = VK_FORMAT_R32G32B32A32_SFLOAT,
.offset = G_STRUCT_OFFSET (GskVulkanTextureInstance, tex_rect),
},
{
.location = 2,
.binding = 0,
.format = VK_FORMAT_R32G32_UINT,
.offset = G_STRUCT_OFFSET (GskVulkanTextureInstance, tex_id),
}
};
static const VkPipelineVertexInputStateCreateInfo info = {
@@ -91,26 +84,28 @@ gsk_vulkan_texture_pipeline_new (GdkVulkanContext *context,
return gsk_vulkan_pipeline_new (GSK_TYPE_VULKAN_TEXTURE_PIPELINE, context, layout, shader_name, render_pass);
}
gsize
gsk_vulkan_texture_pipeline_count_vertex_data (GskVulkanTexturePipeline *pipeline)
{
return sizeof (GskVulkanTextureInstance);
}
void
gsk_vulkan_texture_pipeline_collect_vertex_data (GskVulkanTexturePipeline *pipeline,
guchar *data,
guint32 tex_id[2],
const graphene_point_t *offset,
const graphene_rect_t *rect,
const graphene_rect_t *tex_rect)
{
GskVulkanTextureInstance *instance = (GskVulkanTextureInstance *) data;
instance->rect[0] = rect->origin.x + offset->x;
instance->rect[1] = rect->origin.y + offset->y;
instance->rect[0] = rect->origin.x;
instance->rect[1] = rect->origin.y;
instance->rect[2] = rect->size.width;
instance->rect[3] = rect->size.height;
instance->tex_rect[0] = tex_rect->origin.x;
instance->tex_rect[1] = tex_rect->origin.y;
instance->tex_rect[2] = tex_rect->size.width;
instance->tex_rect[3] = tex_rect->size.height;
instance->tex_id[0] = tex_id[0];
instance->tex_id[1] = tex_id[1];
}
gsize

View File

@@ -17,10 +17,9 @@ GskVulkanPipeline * gsk_vulkan_texture_pipeline_new (GdkVulk
const char *shader_name,
VkRenderPass render_pass);
gsize gsk_vulkan_texture_pipeline_count_vertex_data (GskVulkanTexturePipeline *pipeline);
void gsk_vulkan_texture_pipeline_collect_vertex_data (GskVulkanTexturePipeline *pipeline,
guchar *data,
guint32 tex_id[2],
const graphene_point_t *offset,
const graphene_rect_t *rect,
const graphene_rect_t *tex_rect);
gsize gsk_vulkan_texture_pipeline_draw (GskVulkanTexturePipeline *pipeline,

View File

@@ -1,19 +1,16 @@
#version 420 core
#include "common.frag.glsl"
#include "clip.frag.glsl"
#include "rect.frag.glsl"
layout(location = 0) in vec2 inPos;
layout(location = 1) in Rect inTopRect;
layout(location = 2) in Rect inBottomRect;
layout(location = 3) in vec2 inTopTexCoord;
layout(location = 4) in vec2 inBottomTexCoord;
layout(location = 5) flat in uvec2 inTopTexId;
layout(location = 6) flat in uvec2 inBottomTexId;
layout(location = 7) flat in uint inBlendMode;
layout(location = 1) in vec2 inStartTexCoord;
layout(location = 2) in vec2 inEndTexCoord;
layout(location = 3) flat in uint inBlendMode;
layout(location = 0) out vec4 color;
layout(set = 0, binding = 0) uniform sampler2D startTexture;
layout(set = 1, binding = 0) uniform sampler2D endTexture;
layout(location = 0) out vec4 outColor;
float
combine (float source, float backdrop)
@@ -245,7 +242,7 @@ set_sat (vec3 c, float s)
}
vec4
colorize (vec4 Cs, vec4 Cb)
color (vec4 Cs, vec4 Cb)
{
vec3 B = set_lum (Cs.rgb, lum (Cb.rgb));
return composite (Cs, Cb, B);
@@ -274,10 +271,8 @@ luminosity (vec4 Cs, vec4 Cb)
void main()
{
float source_alpha = rect_coverage (inTopRect, inPos);
vec4 source = texture (get_sampler (inTopTexId), inTopTexCoord) * source_alpha;
float backdrop_alpha = rect_coverage (inBottomRect, inPos);
vec4 backdrop = texture (get_sampler (inBottomTexId), inBottomTexCoord) * backdrop_alpha;
vec4 source = texture (startTexture, inStartTexCoord);
vec4 backdrop = texture (endTexture, inEndTexCoord);
vec4 result;
if (inBlendMode == 0)
@@ -305,7 +300,7 @@ void main()
else if (inBlendMode == 11)
result = exclusion (source, backdrop);
else if (inBlendMode == 12)
result = colorize (source, backdrop);
result = color (source, backdrop);
else if (inBlendMode == 13)
result = hue (source, backdrop);
else if (inBlendMode == 14)
@@ -315,5 +310,5 @@ void main()
else
discard;
color = clip_scaled (inPos, result);
outColor = clip (inPos, result);
}

View File

@@ -1,36 +1,40 @@
#version 420 core
#include "common.vert.glsl"
#include "rect.vert.glsl"
#include "clip.vert.glsl"
layout(location = 0) in vec4 inRect;
layout(location = 1) in vec4 inTopRect;
layout(location = 2) in vec4 inBottomRect;
layout(location = 3) in vec4 inTopTexRect;
layout(location = 4) in vec4 inBottomTexRect;
layout(location = 5) in uvec2 inTopTexId;
layout(location = 6) in uvec2 inBottomTexId;
layout(location = 7) in uint inBlendMode;
layout(location = 1) in vec4 inStartTexRect;
layout(location = 2) in vec4 inEndTexRect;
layout(location = 3) in uint inBlendMode;
layout(location = 0) out vec2 outPos;
layout(location = 1) flat out Rect outTopRect;
layout(location = 2) flat out Rect outBottomRect;
layout(location = 3) out vec2 outTopTexCoord;
layout(location = 4) out vec2 outBottomTexCoord;
layout(location = 5) flat out uvec2 outTopTexId;
layout(location = 6) flat out uvec2 outBottomTexId;
layout(location = 7) flat out uint outBlendMode;
layout(location = 1) out vec2 outStartTexCoord;
layout(location = 2) out vec2 outEndTexCoord;
layout(location = 3) flat out uint outBlendMode;
vec2 offsets[6] = { vec2(0.0, 0.0),
vec2(1.0, 0.0),
vec2(0.0, 1.0),
vec2(0.0, 1.0),
vec2(1.0, 0.0),
vec2(1.0, 1.0) };
void main() {
Rect r = rect_from_gsk (inRect);
vec2 pos = set_position_from_rect (r);
vec4 rect = clip (inRect);
vec2 pos = rect.xy + rect.zw * offsets[gl_VertexIndex];
gl_Position = push.mvp * vec4 (pos, 0.0, 1.0);
outPos = pos;
outTopRect = rect_from_gsk (inTopRect);
outBottomRect = rect_from_gsk (inBottomRect);
outTopTexCoord = scale_tex_coord (pos, r, inTopTexRect);
outBottomTexCoord = scale_tex_coord (pos, r, inBottomTexRect);
outTopTexId = inTopTexId;
outBottomTexId = inBottomTexId;
vec4 texrect = vec4((rect.xy - inRect.xy) / inRect.zw,
rect.zw / inRect.zw);
vec4 starttexrect = vec4(inStartTexRect.xy + inStartTexRect.zw * texrect.xy,
inStartTexRect.zw * texrect.zw);
vec4 endtexrect = vec4(inEndTexRect.xy + inEndTexRect.zw * texrect.xy,
inEndTexRect.zw * texrect.zw);
outStartTexCoord = starttexrect.xy + starttexrect.zw * offsets[gl_VertexIndex];
outEndTexCoord = endtexrect.xy + endtexrect.zw * offsets[gl_VertexIndex];
outBlendMode = inBlendMode;
}

View File

@@ -1,13 +1,13 @@
#version 420 core
#include "common.frag.glsl"
#include "clip.frag.glsl"
layout(location = 0) in vec2 inPos;
layout(location = 1) in flat vec2 inSize;
layout(location = 2) in vec2 inTexCoord;
layout(location = 3) in float inRadius;
layout(location = 4) in flat uvec2 inTexId;
layout(set = 0, binding = 0) uniform sampler2D inTexture;
layout(location = 0) out vec4 color;
@@ -38,7 +38,7 @@ vec4 blur_pixel (in vec2 uv)
float fx = Gaussian (inRadius, float(x) - float(half_samples_x));
float offset_x = float(x - half_samples_x) * pixel_size_x;
total += fx * fy;
ret += texture(get_sampler (inTexId), uv + vec2(offset_x, offset_y)) * fx * fy;
ret += texture(inTexture, uv + vec2(offset_x, offset_y)) * fx * fy;
}
}
return ret / total;

View File

@@ -6,13 +6,11 @@
layout(location = 0) in vec4 inRect;
layout(location = 1) in vec4 inTexRect;
layout(location = 2) in float inRadius;
layout(location = 3) in uvec2 inTexId;
layout(location = 0) out vec2 outPos;
layout(location = 1) out flat vec2 outSize;
layout(location = 2) out vec2 outTexCoord;
layout(location = 3) out flat float outRadius;
layout(location = 4) out flat uvec2 outTexId;
vec2 offsets[6] = { vec2(0.0, 0.0),
vec2(1.0, 0.0),
@@ -24,7 +22,7 @@ vec2 offsets[6] = { vec2(0.0, 0.0),
void main() {
vec4 rect = clip (inRect);
vec2 pos = rect.xy + rect.zw * offsets[gl_VertexIndex];
gl_Position = push.mvp * vec4 (push.scale * pos, 0.0, 1.0);
gl_Position = push.mvp * vec4 (pos, 0.0, 1.0);
outPos = pos;
outSize = inRect.zw;
@@ -34,6 +32,6 @@ void main() {
texrect = vec4(inTexRect.xy + inTexRect.zw * texrect.xy,
inTexRect.zw * texrect.zw);
outTexCoord = texrect.xy + texrect.zw * offsets[gl_VertexIndex];
outTexId = inTexId;
outRadius = inRadius;
}

View File

@@ -5,18 +5,20 @@
layout(location = 0) in vec2 inPos;
layout(location = 1) in vec4 inColor;
layout(location = 2) in RoundedRect inRect;
layout(location = 2) in vec4 inRect;
layout(location = 3) in vec4 inCornerWidths;
layout(location = 4) in vec4 inCornerHeights;
layout(location = 5) in vec4 inBorderWidths;
layout(location = 0) out vec4 color;
void main()
{
RoundedRect routside = inRect;
RoundedRect routside = RoundedRect (vec4(inRect.xy, inRect.xy + inRect.zw), inCornerWidths, inCornerHeights);
RoundedRect rinside = rounded_rect_shrink (routside, inBorderWidths);
float alpha = clamp (rounded_rect_coverage (routside, inPos) -
rounded_rect_coverage (rinside, inPos),
0.0, 1.0);
color = clip_scaled (inPos, vec4(inColor.rgb * inColor.a, inColor.a) * alpha);
color = clip (inPos, vec4(inColor.rgb * inColor.a, inColor.a) * alpha);
}

View File

@@ -1,7 +1,6 @@
#version 420 core
#include "clip.vert.glsl"
#include "rounded-rect.glsl"
layout(location = 0) in vec4 inRect;
layout(location = 1) in vec4 inCornerWidths;
@@ -11,7 +10,9 @@ layout(location = 4) in mat4 inBorderColors;
layout(location = 0) out vec2 outPos;
layout(location = 1) out flat vec4 outColor;
layout(location = 2) out flat RoundedRect outRect;
layout(location = 2) out flat vec4 outRect;
layout(location = 3) out flat vec4 outCornerWidths;
layout(location = 4) out flat vec4 outCornerHeights;
layout(location = 5) out flat vec4 outBorderWidths;
vec2 offsets[6] = { vec2(0.0, 0.0),
@@ -47,59 +48,51 @@ void main() {
vec4 corner_widths = max (inCornerWidths, inBorderWidths.wyyw);
vec4 corner_heights = max (inCornerHeights, inBorderWidths.xxzz);
Rect rect;
vec4 rect;
switch (slice_index)
{
case SLICE_TOP_LEFT:
rect = rect_from_gsk (vec4(inRect.xy, corner_widths[TOP_LEFT], corner_heights[TOP_LEFT]));
rect = rect_round_larger (rect);
rect = vec4(inRect.xy, corner_widths[TOP_LEFT], corner_heights[TOP_LEFT]);
vert_index = (vert_index + 3) % 6;
break;
case SLICE_TOP:
rect = rect_from_gsk (vec4(inRect.x + corner_widths[TOP_LEFT], inRect.y, inRect.z - corner_widths[TOP_LEFT] - corner_widths[TOP_RIGHT], inBorderWidths[TOP]));
rect = rect_round_smaller_larger (rect);
rect = vec4(inRect.x + corner_widths[TOP_LEFT], inRect.y, inRect.z - corner_widths[TOP_LEFT] - corner_widths[TOP_RIGHT], inBorderWidths[TOP]);
outColor = inBorderColors[TOP];
break;
case SLICE_TOP_RIGHT:
rect = rect_from_gsk (vec4(inRect.x + inRect.z - corner_widths[TOP_RIGHT], inRect.y, corner_widths[TOP_RIGHT], corner_heights[TOP_RIGHT]));
rect = rect_round_larger (rect);
rect = vec4(inRect.x + inRect.z - corner_widths[TOP_RIGHT], inRect.y, corner_widths[TOP_RIGHT], corner_heights[TOP_RIGHT]);
break;
case SLICE_RIGHT:
rect = rect_from_gsk (vec4(inRect.x + inRect.z - inBorderWidths[RIGHT], inRect.y + corner_heights[TOP_RIGHT], inBorderWidths[RIGHT], inRect.w - corner_heights[TOP_RIGHT] - corner_heights[BOTTOM_RIGHT]));
rect = rect_round_larger_smaller (rect);
rect = vec4(inRect.x + inRect.z - inBorderWidths[RIGHT], inRect.y + corner_heights[TOP_RIGHT], inBorderWidths[RIGHT], inRect.w - corner_heights[TOP_RIGHT] - corner_heights[BOTTOM_RIGHT]);
outColor = inBorderColors[RIGHT];
break;
case SLICE_BOTTOM_RIGHT:
rect = rect_from_gsk (vec4(inRect.x + inRect.z - corner_widths[BOTTOM_RIGHT], inRect.y + inRect.w - corner_heights[BOTTOM_RIGHT], corner_widths[BOTTOM_RIGHT], corner_heights[BOTTOM_RIGHT]));
rect = rect_round_larger (rect);
rect = vec4(inRect.x + inRect.z - corner_widths[BOTTOM_RIGHT], inRect.y + inRect.w - corner_heights[BOTTOM_RIGHT], corner_widths[BOTTOM_RIGHT], corner_heights[BOTTOM_RIGHT]);
break;
case SLICE_BOTTOM:
rect = rect_from_gsk (vec4(inRect.x + corner_widths[BOTTOM_LEFT], inRect.y + inRect.w - inBorderWidths[BOTTOM], inRect.z - corner_widths[BOTTOM_LEFT] - corner_widths[BOTTOM_RIGHT], inBorderWidths[BOTTOM]));
rect = rect_round_smaller_larger (rect);
rect = vec4(inRect.x + corner_widths[BOTTOM_LEFT], inRect.y + inRect.w - inBorderWidths[BOTTOM], inRect.z - corner_widths[BOTTOM_LEFT] - corner_widths[BOTTOM_RIGHT], inBorderWidths[BOTTOM]);
break;
case SLICE_BOTTOM_LEFT:
rect = rect_from_gsk (vec4(inRect.x, inRect.y + inRect.w - corner_heights[BOTTOM_LEFT], corner_widths[BOTTOM_LEFT], corner_heights[BOTTOM_LEFT]));
rect = vec4(inRect.x, inRect.y + inRect.w - corner_heights[BOTTOM_LEFT], corner_widths[BOTTOM_LEFT], corner_heights[BOTTOM_LEFT]);
vert_index = (vert_index + 3) % 6;
rect = rect_round_larger (rect);
break;
case SLICE_LEFT:
rect = rect_from_gsk (vec4(inRect.x, inRect.y + corner_heights[TOP_LEFT], inBorderWidths[LEFT], inRect.w - corner_heights[TOP_LEFT] - corner_heights[BOTTOM_LEFT]));
rect = rect_round_larger_smaller (rect);
rect = vec4(inRect.x, inRect.y + corner_heights[TOP_LEFT], inBorderWidths[LEFT], inRect.w - corner_heights[TOP_LEFT] - corner_heights[BOTTOM_LEFT]);
break;
}
rect = clip_rect (rect);
rect = clip (rect);
vec2 pos;
if ((slice_index % 4) != 0 || (vert_index % 3) != 2)
pos = mix (rect.bounds.xy, rect.bounds.zw, offsets[vert_index]);
pos = rect.xy + rect.zw * offsets[vert_index];
else
pos = mix (rect.bounds.zy, rect.bounds.xw, offsets[vert_index]);
pos = rect.xy + rect.zw * vec2(1.0 - offsets[vert_index].x, offsets[vert_index].y);
gl_Position = push.mvp * vec4 (pos, 0.0, 1.0);
outColor = inBorderColors[((gl_VertexIndex / 3 + 15) / 4) % 4];
outPos = pos;
outRect = RoundedRect(inRect.xyxy + vec4(0,0,inRect.zw), inCornerWidths, inCornerHeights);
outRect = rounded_rect_scale (outRect, push.scale);
outBorderWidths = inBorderWidths * push.scale.yxyx;
outRect = inRect;
outCornerWidths = inCornerWidths;
outCornerHeights = inCornerHeights;
outBorderWidths = inBorderWidths;
}

View File

@@ -1,45 +1,29 @@
#include "constants.glsl"
#include "rounded-rect.frag.glsl"
#include "rounded-rect.glsl"
#ifndef _CLIP_
#define _CLIP_
#ifdef CLIP_ROUNDED_RECT
vec4
clip_scaled (vec2 pos, vec4 color)
vec4 clip(vec2 pos, vec4 color)
{
RoundedRect r = RoundedRect(vec4(push.clip_bounds.xy, push.clip_bounds.xy + push.clip_bounds.zw), push.clip_widths, push.clip_heights);
r = rounded_rect_scale (r, push.scale);
return color * rounded_rect_coverage (r, pos);
}
#elif defined(CLIP_RECT)
vec4
clip_scaled (vec2 pos, vec4 color)
vec4 clip(vec2 pos, vec4 color)
{
/* clipped in vertex shader already */
return color;
}
#elif defined(CLIP_NONE)
vec4
clip_scaled (vec2 pos, vec4 color)
vec4 clip(vec2 pos, vec4 color)
{
return color;
}
#else
#error "No clipping define given. Need CLIP_NONE, CLIP_RECT or CLIP_ROUNDED_RECT"
#endif
vec4
clip (vec2 pos, vec4 color)
{
return clip_scaled (pos * push.scale, color);
}
#endif

View File

@@ -1,5 +1,4 @@
#include "constants.glsl"
#include "rect.vert.glsl"
#ifndef _CLIP_
#define _CLIP_
@@ -15,47 +14,21 @@ vec4 intersect(vec4 a, vec4 b)
}
#ifdef CLIP_ROUNDED_RECT
vec4
clip(vec4 rect)
vec4 clip(vec4 rect)
{
/* rounded corner clipping is done in fragment shader */
return intersect(rect, push.clip_bounds);
}
Rect
clip_rect (Rect r)
{
/* rounded corner clipping is done in fragment shader */
return rect_intersect (r, rect_round_larger (rect_from_gsk (push.clip_bounds)));
}
#elif defined(CLIP_RECT)
vec4
clip(vec4 rect)
vec4 clip(vec4 rect)
{
return intersect(rect, push.clip_bounds);
}
Rect
clip_rect (Rect r)
{
return rect_intersect (r, rect_round_larger (rect_from_gsk (push.clip_bounds)));
}
#elif defined(CLIP_NONE)
vec4 clip(vec4 rect)
{
return rect;
}
Rect
clip_rect (Rect r)
{
return r;
}
#else
#error "No clipping define given. Need CLIP_NONE, CLIP_RECT or CLIP_ROUNDED_RECT"
#endif

View File

@@ -1,13 +1,13 @@
#version 420 core
#include "common.frag.glsl"
#include "clip.frag.glsl"
layout(location = 0) in vec2 inPos;
layout(location = 1) in vec2 inTexCoord;
layout(location = 2) in flat mat4 inColorMatrix;
layout(location = 6) in flat vec4 inColorOffset;
layout(location = 7) in flat uvec2 inTexId;
layout(set = 0, binding = 0) uniform sampler2D inTexture;
layout(location = 0) out vec4 color;
@@ -29,5 +29,5 @@ color_matrix (vec4 color, mat4 color_matrix, vec4 color_offset)
void main()
{
color = clip (inPos, color_matrix (texture (get_sampler (inTexId), inTexCoord), inColorMatrix, inColorOffset));
color = clip (inPos, color_matrix (texture (inTexture, inTexCoord), inColorMatrix, inColorOffset));
}

View File

@@ -6,13 +6,11 @@ layout(location = 0) in vec4 inRect;
layout(location = 1) in vec4 inTexRect;
layout(location = 2) in mat4 inColorMatrix;
layout(location = 6) in vec4 inColorOffset;
layout(location = 7) in uvec2 inTexId;
layout(location = 0) out vec2 outPos;
layout(location = 1) out vec2 outTexCoord;
layout(location = 2) out flat mat4 outColorMatrix;
layout(location = 6) out flat vec4 outColorOffset;
layout(location = 7) out flat uvec2 outTexId;
vec2 offsets[6] = { vec2(0.0, 0.0),
vec2(1.0, 0.0),
@@ -24,7 +22,7 @@ vec2 offsets[6] = { vec2(0.0, 0.0),
void main() {
vec4 rect = clip (inRect);
vec2 pos = rect.xy + rect.zw * offsets[gl_VertexIndex];
gl_Position = push.mvp * vec4 (push.scale * pos, 0.0, 1.0);
gl_Position = push.mvp * vec4 (pos, 0.0, 1.0);
outPos = pos;
@@ -33,7 +31,6 @@ void main() {
texrect = vec4(inTexRect.xy + inTexRect.zw * texrect.xy,
inTexRect.zw * texrect.zw);
outTexCoord = texrect.xy + texrect.zw * offsets[gl_VertexIndex];
outTexId = inTexId;
outColorMatrix = inColorMatrix;
outColorOffset = inColorOffset;
}

View File

@@ -1,16 +1,13 @@
#version 420 core
#include "clip.frag.glsl"
#include "rect.frag.glsl"
layout(location = 0) in vec2 inPos;
layout(location = 1) in Rect inRect;
layout(location = 2) in vec4 inColor;
layout(location = 1) in vec4 inColor;
layout(location = 0) out vec4 color;
void main()
{
float alpha = inColor.a * rect_coverage (inRect, inPos);
color = clip_scaled (inPos, vec4(inColor.rgb, 1) * alpha);
color = clip (inPos, vec4(inColor.rgb * inColor.a, inColor.a));
}

View File

@@ -1,18 +1,25 @@
#version 420 core
#include "common.vert.glsl"
#include "rect.vert.glsl"
#include "clip.vert.glsl"
layout(location = 0) in vec4 inRect;
layout(location = 1) in vec4 inColor;
layout(location = 0) out vec2 outPos;
layout(location = 1) out flat Rect outRect;
layout(location = 2) out flat vec4 outColor;
layout(location = 1) out flat vec4 outColor;
vec2 offsets[6] = { vec2(0.0, 0.0),
vec2(1.0, 0.0),
vec2(0.0, 1.0),
vec2(0.0, 1.0),
vec2(1.0, 0.0),
vec2(1.0, 1.0) };
void main() {
Rect r = rect_from_gsk (inRect);
outPos = set_position_from_rect (r);
outRect = r;
vec4 rect = clip (inRect);
vec2 pos = rect.xy + rect.zw * offsets[gl_VertexIndex];
gl_Position = push.mvp * vec4 (pos, 0.0, 1.0);
outPos = pos;
outColor = inColor;
}

View File

@@ -1,6 +0,0 @@
layout(set = 0, binding = 0) uniform texture2D textures[50000];
layout(set = 0, binding = 1) uniform sampler samplers[50000];
#define get_sampler(id) sampler2D(textures[id.x], samplers[id.y])

View File

@@ -1,34 +0,0 @@
#ifndef _COMMON_VERT_
#define _COMMON_VERT_
#include "clip.vert.glsl"
#include "constants.glsl"
#include "rect.glsl"
vec2 offsets[6] = { vec2(0.0, 0.0),
vec2(1.0, 0.0),
vec2(0.0, 1.0),
vec2(0.0, 1.0),
vec2(1.0, 0.0),
vec2(1.0, 1.0) };
vec2
set_position_from_rect (Rect rect)
{
Rect r = rect_round_larger (clip_rect (rect));
vec2 pos = mix (r.bounds.xy, r.bounds.zw, offsets[gl_VertexIndex]);
gl_Position = push.mvp * vec4 (pos, 0.0, 1.0);
return pos;
}
vec2
scale_tex_coord (vec2 in_pos,
Rect in_rect,
vec4 tex_rect)
{
return tex_rect.xy + (in_pos - in_rect.bounds.xy) / rect_size (in_rect) * tex_rect.zw;
}
#endif

View File

@@ -6,7 +6,6 @@ layout(push_constant) uniform PushConstants {
vec4 clip_bounds;
vec4 clip_widths;
vec4 clip_heights;
vec2 scale;
} push;
#endif

View File

@@ -1,26 +1,21 @@
#version 420 core
#include "common.frag.glsl"
#include "clip.frag.glsl"
#include "rect.frag.glsl"
layout(location = 0) in vec2 inPos;
layout(location = 1) in Rect inStartRect;
layout(location = 2) in Rect inEndRect;
layout(location = 3) in vec2 inStartTexCoord;
layout(location = 4) in vec2 inEndTexCoord;
layout(location = 5) flat in uvec2 inStartTexId;
layout(location = 6) flat in uvec2 inEndTexId;
layout(location = 7) in float inProgress;
layout(location = 1) in vec2 inStartTexCoord;
layout(location = 2) in vec2 inEndTexCoord;
layout(location = 3) in float inProgress;
layout(set = 0, binding = 0) uniform sampler2D startTexture;
layout(set = 1, binding = 0) uniform sampler2D endTexture;
layout(location = 0) out vec4 color;
void main()
{
float start_alpha = rect_coverage (inStartRect, inPos);
vec4 start = texture (get_sampler (inStartTexId), inStartTexCoord) * start_alpha;
float end_alpha = rect_coverage (inEndRect, inPos);
vec4 end = texture (get_sampler (inEndTexId), inEndTexCoord) * end_alpha;
vec4 start = texture (startTexture, inStartTexCoord);
vec4 end = texture (endTexture, inEndTexCoord);
color = clip_scaled (inPos, mix (start, end, inProgress));
color = clip (inPos, mix (start, end, inProgress));
}

View File

@@ -1,36 +1,40 @@
#version 420 core
#include "common.vert.glsl"
#include "rect.vert.glsl"
#include "clip.vert.glsl"
layout(location = 0) in vec4 inRect;
layout(location = 1) in vec4 inStartRect;
layout(location = 2) in vec4 inEndRect;
layout(location = 3) in vec4 inStartTexRect;
layout(location = 4) in vec4 inEndTexRect;
layout(location = 5) in uvec2 inStartTexId;
layout(location = 6) in uvec2 inEndTexId;
layout(location = 7) in float inProgress;
layout(location = 1) in vec4 inStartTexRect;
layout(location = 2) in vec4 inEndTexRect;
layout(location = 3) in float inProgress;
layout(location = 0) out vec2 outPos;
layout(location = 1) flat out Rect outStartRect;
layout(location = 2) flat out Rect outEndRect;
layout(location = 3) out vec2 outStartTexCoord;
layout(location = 4) out vec2 outEndTexCoord;
layout(location = 5) flat out uvec2 outStartTexId;
layout(location = 6) flat out uvec2 outEndTexId;
layout(location = 7) flat out float outProgress;
layout(location = 1) out vec2 outStartTexCoord;
layout(location = 2) out vec2 outEndTexCoord;
layout(location = 3) out float outProgress;
vec2 offsets[6] = { vec2(0.0, 0.0),
vec2(1.0, 0.0),
vec2(0.0, 1.0),
vec2(0.0, 1.0),
vec2(1.0, 0.0),
vec2(1.0, 1.0) };
void main() {
Rect r = rect_from_gsk (inRect);
vec2 pos = set_position_from_rect (r);
vec4 rect = clip (inRect);
vec2 pos = rect.xy + rect.zw * offsets[gl_VertexIndex];
gl_Position = push.mvp * vec4 (pos, 0.0, 1.0);
outPos = pos;
outStartRect = rect_from_gsk (inStartRect);
outEndRect = rect_from_gsk (inEndRect);
outStartTexCoord = scale_tex_coord (pos, r, inStartTexRect);
outEndTexCoord = scale_tex_coord (pos, r, inEndTexRect);
outStartTexId = inStartTexId;
outEndTexId = inEndTexId;
vec4 texrect = vec4((rect.xy - inRect.xy) / inRect.zw,
rect.zw / inRect.zw);
vec4 starttexrect = vec4(inStartTexRect.xy + inStartTexRect.zw * texrect.xy,
inStartTexRect.zw * texrect.zw);
vec4 endtexrect = vec4(inEndTexRect.xy + inEndTexRect.zw * texrect.xy,
inEndTexRect.zw * texrect.zw);
outStartTexCoord = starttexrect.xy + starttexrect.zw * offsets[gl_VertexIndex];
outEndTexCoord = endtexrect.xy + endtexrect.zw * offsets[gl_VertexIndex];
outProgress = inProgress;
}

View File

@@ -1,38 +0,0 @@
#ifndef _ELLIPSE_
#define _ELLIPSE_
struct Ellipse
{
vec2 center;
vec2 radius;
};
float
ellipse_distance (Ellipse r, vec2 p)
{
vec2 e = r.radius;
p = p - r.center;
if (e.x == e.y)
return length (p) - e.x;
/* from https://www.shadertoy.com/view/tt3yz7 */
vec2 pAbs = abs(p);
vec2 ei = 1.0 / e;
vec2 e2 = e*e;
vec2 ve = ei * vec2(e2.x - e2.y, e2.y - e2.x);
vec2 t = vec2(0.70710678118654752, 0.70710678118654752);
for (int i = 0; i < 3; i++) {
vec2 v = ve*t*t*t;
vec2 u = normalize(pAbs - v) * length(t * e - v);
vec2 w = ei * (v + u);
t = normalize(clamp(w, 0.0, 1.0));
}
vec2 nearestAbs = t * e;
float dist = length(pAbs - nearestAbs);
return dot(pAbs, pAbs) < dot(nearestAbs, nearestAbs) ? -dist : dist;
}
#endif

View File

@@ -29,7 +29,7 @@ void main() {
vec4 rect = clip (inOutline);
vec2 pos = rect.xy + rect.zw * offsets[gl_VertexIndex];
gl_Position = push.mvp * vec4 (push.scale * pos, 0.0, 1.0);
gl_Position = push.mvp * vec4 (pos, 0.0, 1.0);
outPos = pos;
outOutline = inOutline;

View File

@@ -48,7 +48,7 @@ get_gradient_pos (vec2 pos)
void main() {
vec4 rect = clip (inRect);
vec2 pos = rect.xy + rect.zw * offsets[gl_VertexIndex];
gl_Position = push.mvp * vec4 (push.scale * pos, 0.0, 1.0);
gl_Position = push.mvp * vec4 (pos, 0.0, 1.0);
outPos = pos;
outGradientPos = get_gradient_pos (pos);
outRepeating = inRepeating;

View File

@@ -1,16 +1,16 @@
#version 420 core
#include "common.frag.glsl"
#include "clip.frag.glsl"
layout(location = 0) in vec2 inPos;
layout(location = 1) in vec2 inTexCoord;
layout(location = 2) in vec4 inColor;
layout(location = 3) flat in uvec2 inTexId;
layout(set = 0, binding = 0) uniform sampler2D inTexture;
layout(location = 0) out vec4 color;
void main()
{
color = clip (inPos, vec4(inColor.rgb * inColor.a, inColor.a) * texture(get_sampler (inTexId), inTexCoord).a);
color = clip (inPos, vec4(inColor.rgb * inColor.a, inColor.a) * texture(inTexture, inTexCoord).a);
}

View File

@@ -5,12 +5,10 @@
layout(location = 0) in vec4 inRect;
layout(location = 1) in vec4 inTexRect;
layout(location = 2) in vec4 inColor;
layout(location = 3) in uvec2 inTexId;
layout(location = 0) out vec2 outPos;
layout(location = 1) out vec2 outTexCoord;
layout(location = 2) out flat vec4 outColor;
layout(location = 3) out flat uvec2 outTexId;
vec2 offsets[6] = { vec2(0.0, 0.0),
vec2(1.0, 0.0),
@@ -22,7 +20,7 @@ vec2 offsets[6] = { vec2(0.0, 0.0),
void main() {
vec4 rect = clip (inRect);
vec2 pos = rect.xy + rect.zw * offsets[gl_VertexIndex];
gl_Position = push.mvp * vec4 (push.scale * pos, 0.0, 1.0);
gl_Position = push.mvp * vec4 (pos, 0.0, 1.0);
outPos = pos;
@@ -31,6 +29,6 @@ void main() {
texrect = vec4(inTexRect.xy + inTexRect.zw * texrect.xy,
inTexRect.zw * texrect.zw);
outTexCoord = texrect.xy + texrect.zw * offsets[gl_VertexIndex];
outTexId = inTexId;
outColor = inColor;
}

View File

@@ -1,14 +1,8 @@
gsk_private_vulkan_include_shaders = [
'clip.frag.glsl',
'clip.vert.glsl',
'common.frag.glsl',
'common.vert.glsl',
'constants.glsl',
'rect.glsl',
'rect.frag.glsl',
'rect.vert.glsl',
'rounded-rect.glsl',
'rounded-rect.frag.glsl',
]
gsk_private_vulkan_fragment_shaders = [

View File

@@ -38,7 +38,7 @@ void main() {
clip (inOutline);
vec2 pos = rect.xy + rect.zw * offsets[gl_VertexIndex];
gl_Position = push.mvp * vec4 (push.scale * pos, 0.0, 1.0);
gl_Position = push.mvp * vec4 (pos, 0.0, 1.0);
outPos = pos;
outOutline = inOutline;

View File

@@ -1,16 +0,0 @@
#ifndef _RECT_FRAG_
#define _RECT_FRAG_
#include "rect.glsl"
float
rect_coverage (Rect r, vec2 p)
{
vec2 dFdp = abs(fwidth (p));
Rect prect = Rect(vec4(p - 0.5 * dFdp, p + 0.5 * dFdp));
Rect coverect = rect_intersect (r, prect);
vec2 coverage = rect_size(coverect) / dFdp;
return coverage.x * coverage.y;
}
#endif

View File

@@ -1,58 +0,0 @@
#ifndef _RECT_
#define _RECT_
struct Rect
{
/* x,y and y,w make up the 2 points of this rect,
note that this is not containing width or height */
vec4 bounds;
};
Rect
rect_from_gsk (vec4 xywh)
{
return Rect((xywh.xyxy + vec4(0,0,xywh.zw)) * push.scale.xyxy);
}
float
rect_distance (Rect r, vec2 p)
{
vec4 distance = (r.bounds - p.xyxy) * vec4(1.0, 1.0, -1.0, -1.0);
vec2 max2 = max (distance.xy, distance.zw);
return length (max (max2, 0)) + min (max(max2.x, max2.y), 0);
}
vec2
rect_size (Rect r)
{
return r.bounds.zw - r.bounds.xy;
}
Rect
rect_round_larger (Rect r)
{
return Rect (vec4 (floor(r.bounds.xy), ceil (r.bounds.zw)));
}
Rect
rect_round_larger_smaller (Rect r)
{
return Rect (mix (floor(r.bounds), ceil (r.bounds), bvec4(0, 1, 1, 0)));
}
Rect
rect_round_smaller_larger (Rect r)
{
return Rect (mix (floor(r.bounds), ceil (r.bounds), bvec4(1, 0, 0, 1)));
}
Rect
rect_intersect (Rect a, Rect b)
{
vec4 result = vec4(max(a.bounds.xy, b.bounds.xy), min(a.bounds.zw, b.bounds.zw));
if (any (greaterThanEqual (result.xy, result.zw)))
return Rect (vec4(0.0));
return Rect(result);
}
#endif

View File

@@ -1,6 +0,0 @@
#ifndef _RECT_VERT_
#define _RECT_VERT_
#include "rect.glsl"
#endif

Some files were not shown because too many files have changed in this diff Show More