GdkWin32: Use gdk_pixbuf_read_pixels () where applicable
This is an optimization in case of reading unmodifiable GdkPixbufs. Also replace uses of GLib integral types with <stdlib.h> integral types.
This commit is contained in:
@@ -17,34 +17,29 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
#define GDK_PIXBUF_ENABLE_BACKEND /* Ugly? */
|
|
||||||
#include "gdkdisplay.h"
|
#include "gdkdisplay.h"
|
||||||
#include "gdkcursor.h"
|
#include "gdkcursor.h"
|
||||||
#include "gdkwin32.h"
|
#include "gdkwin32.h"
|
||||||
#include "gdktextureprivate.h"
|
#include "gdktextureprivate.h"
|
||||||
#include <glib/gi18n-lib.h>
|
|
||||||
|
|
||||||
#include "gdkdisplay-win32.h"
|
#include "gdkdisplay-win32.h"
|
||||||
|
|
||||||
#ifdef __MINGW32__
|
|
||||||
#include <w32api.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "xcursors.h"
|
#include "xcursors.h"
|
||||||
|
|
||||||
typedef struct _DefaultCursor {
|
#include <stdint.h>
|
||||||
|
|
||||||
|
static struct {
|
||||||
char *name;
|
char *name;
|
||||||
char *id;
|
char *id;
|
||||||
} DefaultCursor;
|
} default_cursors[] = {
|
||||||
|
/* -- Win32 cursor names: -- */
|
||||||
static DefaultCursor default_cursors[] = {
|
|
||||||
{ "appstarting", IDC_APPSTARTING },
|
{ "appstarting", IDC_APPSTARTING },
|
||||||
{ "arrow", IDC_ARROW },
|
{ "arrow", IDC_ARROW },
|
||||||
{ "cross", IDC_CROSS },
|
{ "cross", IDC_CROSS },
|
||||||
{ "hand", IDC_HAND },
|
{ "hand", IDC_HAND },
|
||||||
{ "help", IDC_HELP },
|
{ "help", IDC_HELP },
|
||||||
{ "ibeam", IDC_IBEAM },
|
{ "ibeam", IDC_IBEAM },
|
||||||
/* an X cursor name, for compatibility with GTK: */
|
/* -- X11 cursor names: -- */
|
||||||
{ "left_ptr_watch", IDC_APPSTARTING },
|
{ "left_ptr_watch", IDC_APPSTARTING },
|
||||||
{ "sizeall", IDC_SIZEALL },
|
{ "sizeall", IDC_SIZEALL },
|
||||||
{ "sizenesw", IDC_SIZENESW },
|
{ "sizenesw", IDC_SIZENESW },
|
||||||
@@ -53,7 +48,7 @@ static DefaultCursor default_cursors[] = {
|
|||||||
{ "sizewe", IDC_SIZEWE },
|
{ "sizewe", IDC_SIZEWE },
|
||||||
{ "uparrow", IDC_UPARROW },
|
{ "uparrow", IDC_UPARROW },
|
||||||
{ "wait", IDC_WAIT },
|
{ "wait", IDC_WAIT },
|
||||||
/* css cursor names: */
|
/* -- CSS cursor names: -- */
|
||||||
{ "default", IDC_ARROW },
|
{ "default", IDC_ARROW },
|
||||||
{ "pointer", IDC_HAND },
|
{ "pointer", IDC_HAND },
|
||||||
{ "progress", IDC_APPSTARTING },
|
{ "progress", IDC_APPSTARTING },
|
||||||
@@ -93,18 +88,17 @@ struct _GdkWin32HCursor
|
|||||||
|
|
||||||
/* Do not do any modifications to the handle
|
/* Do not do any modifications to the handle
|
||||||
* (i.e. do not call DestroyCursor() on it).
|
* (i.e. do not call DestroyCursor() on it).
|
||||||
* It's a "read-only" copy, the original is stored
|
* It's a "read-only" copy, the original is
|
||||||
* in the display instance.
|
* stored in the display instance */
|
||||||
*/
|
|
||||||
HANDLE readonly_handle;
|
HANDLE readonly_handle;
|
||||||
|
|
||||||
/* This is a way to access the real handle stored
|
/* This is a way to access the real handle
|
||||||
* in the display.
|
* stored in the display.
|
||||||
* TODO: make it a weak reference
|
* TODO: make it a weak reference */
|
||||||
*/
|
|
||||||
GdkWin32Display *display;
|
GdkWin32Display *display;
|
||||||
|
|
||||||
/* A copy of the "destoyable" attribute of the handle */
|
/* A copy of the "destoyable" attribute of
|
||||||
|
* the handle */
|
||||||
gboolean readonly_destroyable;
|
gboolean readonly_destroyable;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -382,7 +376,8 @@ hcursor_from_x_cursor (int i,
|
|||||||
int j, x, y, ofs;
|
int j, x, y, ofs;
|
||||||
HCURSOR rv;
|
HCURSOR rv;
|
||||||
int w, h;
|
int w, h;
|
||||||
guchar *and_plane, *xor_plane;
|
uint8_t *and_plane;
|
||||||
|
uint8_t *xor_plane;
|
||||||
|
|
||||||
w = GetSystemMetrics (SM_CXCURSOR);
|
w = GetSystemMetrics (SM_CXCURSOR);
|
||||||
h = GetSystemMetrics (SM_CYCURSOR);
|
h = GetSystemMetrics (SM_CYCURSOR);
|
||||||
@@ -406,7 +401,7 @@ hcursor_from_x_cursor (int i,
|
|||||||
for (x = 0; x < cursors[i].width && x < w ; x++, j++)
|
for (x = 0; x < cursors[i].width && x < w ; x++, j++)
|
||||||
{
|
{
|
||||||
int pofs = ofs + x / 8;
|
int pofs = ofs + x / 8;
|
||||||
guchar data = (cursors[i].data[j/4] & (0xc0 >> (2 * (j%4)))) >> (2 * (3 - (j%4)));
|
uint8_t data = (cursors[i].data[j/4] & (0xc0 >> (2 * (j%4)))) >> (2 * (3 - (j%4)));
|
||||||
int bit = 7 - (j % cursors[i].width) % 8;
|
int bit = 7 - (j % cursors[i].width) % 8;
|
||||||
|
|
||||||
if (data)
|
if (data)
|
||||||
@@ -852,7 +847,7 @@ static GdkWin32HCursor *
|
|||||||
create_blank_win32hcursor (GdkWin32Display *display)
|
create_blank_win32hcursor (GdkWin32Display *display)
|
||||||
{
|
{
|
||||||
int w, h;
|
int w, h;
|
||||||
guchar *and_plane, *xor_plane;
|
uint8_t *and_plane, *xor_plane;
|
||||||
HCURSOR rv;
|
HCURSOR rv;
|
||||||
|
|
||||||
w = GetSystemMetrics (SM_CXCURSOR);
|
w = GetSystemMetrics (SM_CXCURSOR);
|
||||||
@@ -1009,7 +1004,7 @@ gdk_win32_icon_to_pixbuf_libgtk_only (HICON hicon,
|
|||||||
RGBQUAD colors[2];
|
RGBQUAD colors[2];
|
||||||
} bmi;
|
} bmi;
|
||||||
HDC hdc;
|
HDC hdc;
|
||||||
guchar *pixels, *bits;
|
uint8_t *pixels, *bits;
|
||||||
int rowstride, x, y, w, h;
|
int rowstride, x, y, w, h;
|
||||||
|
|
||||||
if (!GDI_CALL (GetIconInfo, (hicon, &ii)))
|
if (!GDI_CALL (GetIconInfo, (hicon, &ii)))
|
||||||
@@ -1117,7 +1112,7 @@ gdk_win32_icon_to_pixbuf_libgtk_only (HICON hicon,
|
|||||||
|
|
||||||
for (y = 0; y < h; y++)
|
for (y = 0; y < h; y++)
|
||||||
{
|
{
|
||||||
const guchar *andp, *xorp;
|
const uint8_t *andp, *xorp;
|
||||||
if (bmi.bi.biHeight < 0)
|
if (bmi.bi.biHeight < 0)
|
||||||
{
|
{
|
||||||
andp = bits + bpl*y;
|
andp = bits + bpl*y;
|
||||||
@@ -1178,8 +1173,8 @@ gdk_win32_icon_to_pixbuf_libgtk_only (HICON hicon,
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
static HBITMAP
|
static HBITMAP
|
||||||
create_alpha_bitmap (int size,
|
create_alpha_bitmap (int size,
|
||||||
guchar **outdata)
|
uint8_t **outdata)
|
||||||
{
|
{
|
||||||
BITMAPV5HEADER bi;
|
BITMAPV5HEADER bi;
|
||||||
HDC hdc;
|
HDC hdc;
|
||||||
@@ -1216,9 +1211,9 @@ create_alpha_bitmap (int size,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static HBITMAP
|
static HBITMAP
|
||||||
create_color_bitmap (int size,
|
create_color_bitmap (int size,
|
||||||
guchar **outdata,
|
uint8_t **outdata,
|
||||||
int bits)
|
int bits)
|
||||||
{
|
{
|
||||||
struct {
|
struct {
|
||||||
BITMAPV4HEADER bmiHeader;
|
BITMAPV4HEADER bmiHeader;
|
||||||
@@ -1265,8 +1260,9 @@ pixbuf_to_hbitmaps_alpha_winxp (GdkPixbuf *pixbuf,
|
|||||||
* http://www.dotnet247.com/247reference/msgs/13/66301.aspx
|
* http://www.dotnet247.com/247reference/msgs/13/66301.aspx
|
||||||
*/
|
*/
|
||||||
HBITMAP hColorBitmap, hMaskBitmap;
|
HBITMAP hColorBitmap, hMaskBitmap;
|
||||||
guchar *indata, *inrow;
|
const uint8_t *indata;
|
||||||
guchar *colordata, *colorrow, *maskdata, *maskbyte;
|
const uint8_t *inrow;
|
||||||
|
uint8_t *colordata, *colorrow, *maskdata, *maskbyte;
|
||||||
int width, height, size, i, i_offset, j, j_offset, rowstride;
|
int width, height, size, i, i_offset, j, j_offset, rowstride;
|
||||||
guint maskstride, mask_bit;
|
guint maskstride, mask_bit;
|
||||||
|
|
||||||
@@ -1289,7 +1285,7 @@ pixbuf_to_hbitmaps_alpha_winxp (GdkPixbuf *pixbuf,
|
|||||||
/* MSDN says mask rows are aligned to "LONG" boundaries */
|
/* MSDN says mask rows are aligned to "LONG" boundaries */
|
||||||
maskstride = (((size + 31) & ~31) >> 3);
|
maskstride = (((size + 31) & ~31) >> 3);
|
||||||
|
|
||||||
indata = gdk_pixbuf_get_pixels (pixbuf);
|
indata = gdk_pixbuf_read_pixels (pixbuf);
|
||||||
rowstride = gdk_pixbuf_get_rowstride (pixbuf);
|
rowstride = gdk_pixbuf_get_rowstride (pixbuf);
|
||||||
|
|
||||||
if (width > height)
|
if (width > height)
|
||||||
@@ -1343,8 +1339,9 @@ pixbuf_to_hbitmaps_normal (GdkPixbuf *pixbuf,
|
|||||||
* http://www.dotnet247.com/247reference/msgs/13/66301.aspx
|
* http://www.dotnet247.com/247reference/msgs/13/66301.aspx
|
||||||
*/
|
*/
|
||||||
HBITMAP hColorBitmap, hMaskBitmap;
|
HBITMAP hColorBitmap, hMaskBitmap;
|
||||||
guchar *indata, *inrow;
|
const uint8_t *indata;
|
||||||
guchar *colordata, *colorrow, *maskdata, *maskbyte;
|
const uint8_t *inrow;
|
||||||
|
uint8_t *colordata, *colorrow, *maskdata, *maskbyte;
|
||||||
int width, height, size, i, i_offset, j, j_offset, rowstride, nc, bmstride;
|
int width, height, size, i, i_offset, j, j_offset, rowstride, nc, bmstride;
|
||||||
gboolean has_alpha;
|
gboolean has_alpha;
|
||||||
guint maskstride, mask_bit;
|
guint maskstride, mask_bit;
|
||||||
@@ -1373,7 +1370,7 @@ pixbuf_to_hbitmaps_normal (GdkPixbuf *pixbuf,
|
|||||||
/* MSDN says mask rows are aligned to "LONG" boundaries */
|
/* MSDN says mask rows are aligned to "LONG" boundaries */
|
||||||
maskstride = (((size + 31) & ~31) >> 3);
|
maskstride = (((size + 31) & ~31) >> 3);
|
||||||
|
|
||||||
indata = gdk_pixbuf_get_pixels (pixbuf);
|
indata = gdk_pixbuf_read_pixels (pixbuf);
|
||||||
rowstride = gdk_pixbuf_get_rowstride (pixbuf);
|
rowstride = gdk_pixbuf_get_rowstride (pixbuf);
|
||||||
nc = gdk_pixbuf_get_n_channels (pixbuf);
|
nc = gdk_pixbuf_get_n_channels (pixbuf);
|
||||||
has_alpha = gdk_pixbuf_get_has_alpha (pixbuf);
|
has_alpha = gdk_pixbuf_get_has_alpha (pixbuf);
|
||||||
|
|||||||
Reference in New Issue
Block a user