119
115
g_free (tile_buf);
123
if (render_blend_dark_check)
125
g_free (render_blend_dark_check);
126
render_blend_dark_check = NULL;
129
if (render_blend_light_check)
131
g_free (render_blend_light_check);
132
render_blend_light_check = NULL;
135
if (render_blend_white)
137
g_free (render_blend_white);
138
render_blend_white = NULL;
141
if (render_check_buf)
143
g_free (render_check_buf);
144
render_check_buf = NULL;
147
if (render_empty_buf)
149
g_free (render_empty_buf);
150
render_empty_buf = NULL;
153
if (render_white_buf)
155
g_free (render_white_buf);
156
render_white_buf = NULL;
161
g_free (render_temp_buf);
162
render_temp_buf = NULL;
168
121
render_setup_notify (gpointer config,
169
122
GParamSpec *param_spec,
172
GimpCheckType check_type;
173
125
GimpCheckSize check_size;
177
127
g_object_get (config,
178
"transparency-type", &check_type,
179
128
"transparency-size", &check_size,
182
/* based on the tile size, determine the tile shift amount
183
* (assume here that tile_height and tile_width are equal)
186
while ((1 << tile_shift) < TILE_WIDTH)
189
/* allocate a buffer for arranging information from a row of tiles */
191
tile_buf = g_new (guchar,
192
GIMP_DISPLAY_SHELL_RENDER_BUF_WIDTH * MAX_CHANNELS);
194
if (! render_blend_dark_check)
195
render_blend_dark_check = g_new (guchar, 65536);
196
if (! render_blend_light_check)
197
render_blend_light_check = g_new (guchar, 65536);
198
if (! render_blend_white)
199
render_blend_white = g_new (guchar, 65536);
201
gimp_checks_get_shades (check_type, &light, &dark);
203
for (i = 0; i < 256; i++)
204
for (j = 0; j < 256; j++)
206
render_blend_dark_check [(i << 8) + j] =
207
(guchar) ((j * i + dark * (255 - i)) / 255);
208
render_blend_light_check [(i << 8) + j] =
209
(guchar) ((j * i + light * (255 - i)) / 255);
210
render_blend_white [(i << 8) + j] =
211
(guchar) ((j * i + 255 * (255 - i)) / 255);
214
131
switch (check_size)
216
133
case GIMP_CHECK_SIZE_SMALL_CHECKS:
447
427
render_image_indexed (RenderInfo *info)
432
gboolean initial = TRUE;
458
cmap = gimp_image_get_colormap (info->shell->gdisp->gimage);
434
cmap = gimp_image_get_colormap (info->shell->display->image);
461
437
ye = info->y + info->h;
462
438
xe = info->x + info->w;
465
byte_order = info->byte_order;
466
440
info->src = render_image_tile_fault (info);
470
gint error = RINT (floor ((y + 1) / info->scaley)
471
- floor (y / info->scaley));
445
RINT (floor ((y + 1) / info->scaley) - floor (y / info->scaley));
473
447
if (!initial && (error == 0))
475
memcpy (info->dest, info->dest - info->dest_bpl, info->dest_width);
449
memcpy (info->dest, info->dest - info->dest_bpl, info->dest_width);
482
g_return_if_fail (src != NULL);
484
for (x = info->x; x < xe; x++)
486
val = src[INDEXED_PIX] * 3;
489
dest[0] = cmap[val+0];
490
dest[1] = cmap[val+1];
491
dest[2] = cmap[val+2];
453
const guchar *src = info->src;
454
guchar *dest = info->dest;
456
for (x = info->x; x < xe; x++)
458
guint val = src[INDEXED_PIX] * 3;
462
dest[0] = cmap[val + 0];
463
dest[1] = cmap[val + 1];
464
dest[2] = cmap[val + 2];
496
472
info->dest += info->dest_bpl;
476
info->src_y += error;
477
info->src = render_image_tile_fault (info);
502
info->src_y += error;
503
info->src = render_image_tile_fault (info);
510
489
render_image_indexed_a (RenderInfo *info)
525
cmap = gimp_image_get_colormap (info->shell->gdisp->gimage);
491
const guint *alpha = info->alpha;
492
const guchar *cmap = gimp_image_get_colormap (info->shell->display->image);
495
gboolean initial = TRUE;
529
498
ye = info->y + info->h;
530
499
xe = info->x + info->w;
533
byte_order = info->byte_order;
534
501
info->src = render_image_tile_fault (info);
538
gint error = RINT (floor ((y + 1) / info->scaley)
539
- floor (y / info->scaley));
506
RINT (floor ((y + 1) / info->scaley) - floor (y / info->scaley));
541
508
if (!initial && (error == 0) && (y & check_mod))
543
memcpy (info->dest, info->dest - info->dest_bpl, info->dest_width);
510
memcpy (info->dest, info->dest - info->dest_bpl, info->dest_width);
550
dark_light = (y >> check_shift) + (info->x >> check_shift);
552
g_return_if_fail (src != NULL);
554
for (x = info->x; x < xe; x++)
556
a = alpha[src[ALPHA_I_PIX]];
557
val = src[INDEXED_PIX] * 3;
560
if (dark_light & 0x1)
562
r = render_blend_dark_check[(a | cmap[val + 0])];
563
g = render_blend_dark_check[(a | cmap[val + 1])];
564
b = render_blend_dark_check[(a | cmap[val + 2])];
568
r = render_blend_light_check[(a | cmap[val + 0])];
569
g = render_blend_light_check[(a | cmap[val + 1])];
570
b = render_blend_light_check[(a | cmap[val + 2])];
578
if (((x + 1) & check_mod) == 0)
514
const guchar *src = info->src;
515
guchar *dest = info->dest;
518
dark_light = (y >> check_shift) + (info->x >> check_shift);
520
for (x = info->x; x < xe; x++)
522
guint r, g, b, a = alpha[src[ALPHA_I_PIX]];
523
guint val = src[INDEXED_PIX] * 3;
527
if (dark_light & 0x1)
529
r = gimp_render_blend_dark_check[(a | cmap[val + 0])];
530
g = gimp_render_blend_dark_check[(a | cmap[val + 1])];
531
b = gimp_render_blend_dark_check[(a | cmap[val + 2])];
535
r = gimp_render_blend_light_check[(a | cmap[val + 0])];
536
g = gimp_render_blend_light_check[(a | cmap[val + 1])];
537
b = gimp_render_blend_light_check[(a | cmap[val + 2])];
545
if (((x + 1) & check_mod) == 0)
583
553
info->dest += info->dest_bpl;
557
info->src_y += error;
558
info->src = render_image_tile_fault (info);
589
info->src_y += error;
590
info->src = render_image_tile_fault (info);
597
570
render_image_gray (RenderInfo *info)
574
gboolean initial = TRUE;
608
577
ye = info->y + info->h;
609
578
xe = info->x + info->w;
612
byte_order = info->byte_order;
613
580
info->src = render_image_tile_fault (info);
617
gint error = RINT (floor ((y + 1) / info->scaley)
618
- floor (y / info->scaley));
585
RINT (floor ((y + 1) / info->scaley) - floor (y / info->scaley));
620
587
if (!initial && (error == 0))
622
memcpy (info->dest, info->dest - info->dest_bpl, info->dest_width);
589
memcpy (info->dest, info->dest - info->dest_bpl, info->dest_width);
629
g_return_if_fail (src != NULL);
631
for (x = info->x; x < xe; x++)
593
const guchar *src = info->src;
594
guchar *dest = info->dest;
596
for (x = info->x; x < xe; x++)
598
guint val = src[GRAY_PIX];
643
612
info->dest += info->dest_bpl;
616
info->src_y += error;
617
info->src = render_image_tile_fault (info);
649
info->src_y += error;
650
info->src = render_image_tile_fault (info);
657
629
render_image_gray_a (RenderInfo *info)
631
const guint *alpha = info->alpha;
634
gboolean initial = TRUE;
673
637
ye = info->y + info->h;
674
638
xe = info->x + info->w;
677
byte_order = info->byte_order;
678
640
info->src = render_image_tile_fault (info);
682
gint error = RINT (floor ((y + 1) / info->scaley)
683
- floor (y / info->scaley));
645
RINT (floor ((y + 1) / info->scaley) - floor (y / info->scaley));
685
647
if (!initial && (error == 0) && (y & check_mod))
687
memcpy (info->dest, info->dest - info->dest_bpl, info->dest_width);
649
memcpy (info->dest, info->dest - info->dest_bpl, info->dest_width);
694
dark_light = (y >> check_shift) + (info->x >> check_shift);
696
g_return_if_fail (src != NULL);
698
for (x = info->x; x < xe; x++)
700
a = alpha[src[ALPHA_G_PIX]];
701
if (dark_light & 0x1)
702
val = render_blend_dark_check[(a | src[GRAY_PIX])];
704
val = render_blend_light_check[(a | src[GRAY_PIX])];
712
if (((x + 1) & check_mod) == 0)
653
const guchar *src = info->src;
654
guchar *dest = info->dest;
657
dark_light = (y >> check_shift) + (info->x >> check_shift);
659
for (x = info->x; x < xe; x++)
661
guint a = alpha[src[ALPHA_G_PIX]];
664
if (dark_light & 0x1)
665
val = gimp_render_blend_dark_check[(a | src[GRAY_PIX])];
667
val = gimp_render_blend_light_check[(a | src[GRAY_PIX])];
676
if (((x + 1) & check_mod) == 0)
717
684
info->dest += info->dest_bpl;
688
info->src_y += error;
689
info->src = render_image_tile_fault (info);
723
info->src_y += error;
724
info->src = render_image_tile_fault (info);
731
701
render_image_rgb (RenderInfo *info)
705
gboolean initial = TRUE;
739
708
ye = info->y + info->h;
740
709
xe = info->x + info->w;
743
byte_order = info->byte_order;
744
711
info->src = render_image_tile_fault (info);
748
gint error = RINT (floor ((y + 1) / info->scaley)
749
- floor (y / info->scaley));
716
RINT (floor ((y + 1) / info->scaley) - floor (y / info->scaley));
751
718
if (!initial && (error == 0))
753
memcpy (info->dest, info->dest - info->dest_bpl, info->dest_width);
720
memcpy (info->dest, info->dest - info->dest_bpl, info->dest_width);
757
g_return_if_fail (info->src != NULL);
759
724
memcpy (info->dest, info->src, 3 * info->w);
762
730
info->dest += info->dest_bpl;
734
info->src_y += error;
735
info->src = render_image_tile_fault (info);
768
info->src_y += error;
769
info->src = render_image_tile_fault (info);
776
747
render_image_rgb_a (RenderInfo *info)
749
const guint *alpha = info->alpha;
792
755
ye = info->y + info->h;
793
756
xe = info->x + info->w;
796
byte_order = info->byte_order;
797
758
info->src = render_image_tile_fault (info);
801
gint error = RINT (floor ((y + 1) / info->scaley)
802
- floor (y / info->scaley));
763
RINT (floor ((y + 1) / info->scaley) - floor (y / info->scaley));
804
765
if (!initial && (error == 0) && (y & check_mod))
806
memcpy (info->dest, info->dest - info->dest_bpl, info->dest_width);
767
memcpy (info->dest, info->dest - info->dest_bpl, info->dest_width);
813
dark_light = (y >> check_shift) + (info->x >> check_shift);
815
g_return_if_fail (src != NULL);
817
for (x = info->x; x < xe; x++)
819
a = alpha[src[ALPHA_PIX]];
820
if (dark_light & 0x1)
822
r = render_blend_dark_check[(a | src[RED_PIX])];
823
g = render_blend_dark_check[(a | src[GREEN_PIX])];
824
b = render_blend_dark_check[(a | src[BLUE_PIX])];
828
r = render_blend_light_check[(a | src[RED_PIX])];
829
g = render_blend_light_check[(a | src[GREEN_PIX])];
830
b = render_blend_light_check[(a | src[BLUE_PIX])];
840
if (((x + 1) & check_mod) == 0)
771
const guchar *src = info->src;
772
guchar *dest = info->dest;
775
dark_light = (y >> check_shift) + (info->x >> check_shift);
777
for (x = info->x; x < xe; x++)
779
guint r, g, b, a = alpha[src[ALPHA_PIX]];
781
if (dark_light & 0x1)
783
r = gimp_render_blend_dark_check[(a | src[RED_PIX])];
784
g = gimp_render_blend_dark_check[(a | src[GREEN_PIX])];
785
b = gimp_render_blend_dark_check[(a | src[BLUE_PIX])];
789
r = gimp_render_blend_light_check[(a | src[RED_PIX])];
790
g = gimp_render_blend_light_check[(a | src[GREEN_PIX])];
791
b = gimp_render_blend_light_check[(a | src[BLUE_PIX])];
801
if (((x + 1) & check_mod) == 0)
845
809
info->dest += info->dest_bpl;
813
info->src_y += error;
814
info->src = render_image_tile_fault (info);
851
info->src_y += error;
852
info->src = render_image_tile_fault (info);
859
render_image_init_info (RenderInfo *info,
860
GimpDisplayShell *shell,
826
render_image_init_info_full (RenderInfo *info,
827
GimpDisplayShell *shell,
832
GimpProjection *projection)
866
GimpImage *gimage = shell->gdisp->gimage;
868
834
info->shell = shell;
869
info->src_tiles = gimp_projection_get_tiles (gimage->projection);
870
info->x = x + shell->offset_x;
871
info->y = y + shell->offset_y;
874
info->scalex = SCALEFACTOR_X (shell);
875
info->scaley = SCALEFACTOR_Y (shell);
876
info->src_x = (gdouble) info->x / info->scalex;
877
info->src_y = (gdouble) info->y / info->scaley;
878
info->src_bpp = gimp_projection_get_bytes (gimage->projection);
879
info->dest = shell->render_buf;
837
info->scalex = shell->scale_x;
838
info->scaley = shell->scale_y;
880
839
info->dest_bpp = 3;
881
info->dest_bpl = info->dest_bpp * GIMP_DISPLAY_SHELL_RENDER_BUF_WIDTH;
882
info->dest_width = info->w * info->dest_bpp;
883
info->byte_order = GDK_MSB_FIRST;
884
info->scale = render_image_accelerate_scaling (w,
885
info->x, info->scalex);
888
if (GIMP_IMAGE_TYPE_HAS_ALPHA (gimp_projection_get_image_type (gimage->projection)))
840
info->dest_bpl = info->dest_bpp * GIMP_RENDER_BUF_WIDTH;
841
info->dest_width = info->dest_bpp * info->w;
843
render_image_init_info (info, shell, x, y,
844
gimp_projection_get_tiles (projection));
846
info->scale = render_image_accelerate_scaling (w, info->x, info->scalex);
848
if (GIMP_IMAGE_TYPE_HAS_ALPHA (gimp_projection_get_image_type (projection)))
891
render_image_init_alpha (gimp_projection_get_opacity (gimage->projection) * 255.999);
850
gdouble opacity = gimp_projection_get_opacity (projection);
852
info->alpha = render_image_init_alpha (opacity * 255.999);
857
render_image_init_info (RenderInfo *info,
858
GimpDisplayShell *shell,
863
info->src_tiles = tiles;
864
info->x = x + shell->offset_x;
865
info->y = y + shell->offset_y;
866
info->src_x = (gdouble) info->x / info->scalex;
867
info->src_y = (gdouble) info->y / info->scaley;
868
info->dest = shell->render_buf;
896
872
render_image_init_alpha (gint mult)
898
874
static guint *alpha_mult = NULL;