Ticket #69291: patch-gdk-quartz.diff
File patch-gdk-quartz.diff, 3.2 KB (added by DanielO (Daniel O'Connor), 9 months ago) |
---|
-
gdk/quartz/gdkimage-quartz.c
old new 37 37 gint height) 38 38 { 39 39 GdkScreen *screen; 40 int depth; 40 41 41 42 g_return_val_if_fail (GDK_IS_DRAWABLE_IMPL_QUARTZ (drawable), NULL); 42 43 g_return_val_if_fail (image != NULL || (dest_x == 0 && dest_y == 0), NULL); 43 44 44 45 screen = gdk_drawable_get_screen (drawable); 46 depth = gdk_drawable_get_depth (drawable); 45 47 if (!image) 46 48 image = _gdk_image_new_for_depth (screen, GDK_IMAGE_FASTEST, NULL, 47 width, height, 48 gdk_drawable_get_depth (drawable)); 49 width, height, depth); 49 50 50 51 if (GDK_IS_PIXMAP_IMPL_QUARTZ (drawable)) 51 52 { … … 63 64 return image; 64 65 } 65 66 66 switch ( gdk_drawable_get_depth (drawable))67 switch (depth) 67 68 { 68 69 case 24: 69 70 bytes_per_row = pix_impl->width * 4; … … 123 124 break; 124 125 125 126 default: 126 g_warning ("Unsupported bit depth %d\n", gdk_drawable_get_depth (drawable));127 g_warning ("Unsupported bit depth %d\n", depth); 127 128 return image; 128 129 } 129 130 } … … 322 323 if (visual) 323 324 depth = visual->depth; 324 325 325 g_assert (depth == 24 || depth == 32);326 g_assert (depth == 1 || depth == 24 || depth == 32); 326 327 327 328 image = g_object_new (gdk_image_get_type (), NULL); 328 329 image->type = type; … … 333 334 334 335 image->byte_order = (G_BYTE_ORDER == G_LITTLE_ENDIAN) ? GDK_LSB_FIRST : GDK_MSB_FIRST; 335 336 336 /* We only support images with bpp 4 */ 337 image->bpp = 4; 338 image->bpl = image->width * image->bpp; 339 image->bits_per_pixel = image->bpp * 8; 340 337 if (depth == 1) { 338 image->bpp = 1; 339 image->bpl = (image->width >> 3) + 1; 340 image->bits_per_pixel = 1; 341 } else { 342 image->bpp = 4; 343 image->bpl = image->width * image->bpp; 344 image->bits_per_pixel = image->bpp * 8; 345 } 346 341 347 image->mem = g_malloc (image->bpl * image->height); 342 348 memset (image->mem, 0x00, image->bpl * image->height); 343 349 … … 355 361 g_return_val_if_fail (x >= 0 && x < image->width, 0); 356 362 g_return_val_if_fail (y >= 0 && y < image->height, 0); 357 363 358 ptr = image->mem + y * image->bpl + x * image->bpp; 364 ptr = image->mem + y * image->bpl; 365 if (image->depth == 1) { 366 guchar data = (image->byte_order == GDK_MSB_FIRST ? (0x80 >> (x & 7)) : (1 << (x & 7))); 367 return (ptr[x >> 3] & data) ? 0x1 : 0x0; 368 } else { 369 ptr += x * image->bpp; 370 return *(guint32 *)ptr; 371 } 359 372 360 373 return *(guint32 *)ptr; 361 374 } … … 366 379 gint y, 367 380 guint32 pixel) 368 381 { 369 guchar *ptr; 382 guchar *ptr = image->mem + y * image->bpl; 383 if (image->depth == 1) { 384 guchar data = (image->byte_order == GDK_MSB_FIRST ? (0x80 >> (x & 7)) : (1 << (x & 7))); 385 if (pixel) { 386 ptr[x >> 3] |= data; 387 } else { 388 ptr[x >> 3] &= ~data; 389 } 390 } else { 391 ptr += x * image->bpp; 392 *(guint32 *)ptr = pixel; 393 } 370 394 371 ptr = image->mem + y * image->bpl + x * image->bpp;372 373 395 *(guint32 *)ptr = pixel; 374 396 } 375 397 … … 377 399 _gdk_windowing_get_bits_for_depth (GdkDisplay *display, 378 400 gint depth) 379 401 { 380 if (depth == 24 || depth == 32) 402 if (depth == 1) 403 return 1; 404 else if (depth == 24 || depth == 32) 381 405 return 32; 382 406 else 383 407 g_assert_not_reached ();