aboutsummaryrefslogtreecommitdiffstats
path: root/src/w32term.c
diff options
context:
space:
mode:
authorJason Rumney2002-11-15 18:55:19 +0000
committerJason Rumney2002-11-15 18:55:19 +0000
commitd30591dcceac5cd7cf1c9cc7fa55abd7c847b7da (patch)
tree8c9be98fb7272519e6e272a8a6a8306b59d4dad8 /src/w32term.c
parenta4478a76adc7fe3a9cfcca36b8b6b837359b0983 (diff)
downloademacs-d30591dcceac5cd7cf1c9cc7fa55abd7c847b7da.tar.gz
emacs-d30591dcceac5cd7cf1c9cc7fa55abd7c847b7da.zip
(x_draw_image_foreground, x_draw_image_glyph_string)
(w32_draw_image_foreground_1): Handle image masks. (x_draw_image_glyph_string): Don't BitBlt transparently.
Diffstat (limited to 'src/w32term.c')
-rw-r--r--src/w32term.c163
1 files changed, 65 insertions, 98 deletions
diff --git a/src/w32term.c b/src/w32term.c
index 313f9348ce1..ecd734ca694 100644
--- a/src/w32term.c
+++ b/src/w32term.c
@@ -3888,58 +3888,40 @@ x_draw_image_foreground (s)
3888 3888
3889 if (s->img->pixmap) 3889 if (s->img->pixmap)
3890 { 3890 {
3891#if 0 /* TODO: image mask */ 3891 HDC compat_hdc = CreateCompatibleDC (s->hdc);
3892 HBRUSH fg_brush = CreateSolidBrush (s->gc->foreground);
3893 HBRUSH orig_brush = SelectObject (s->hdc, fg_brush);
3894 HGDIOBJ orig_obj = SelectObject (compat_hdc, s->img->pixmap);
3895 SetBkColor (compat_hdc, RGB (255, 255, 255));
3896 SetTextColor (s->hdc, RGB (0, 0, 0));
3897 x_set_glyph_string_clipping (s);
3898
3892 if (s->img->mask) 3899 if (s->img->mask)
3893 { 3900 {
3894 /* We can't set both a clip mask and use XSetClipRectangles 3901 HDC mask_dc = CreateCompatibleDC (s->hdc);
3895 because the latter also sets a clip mask. We also can't 3902 HGDIOBJ mask_orig_obj = SelectObject (mask_dc, s->img->mask);
3896 trust on the shape extension to be available 3903
3897 (XShapeCombineRegion). So, compute the rectangle to draw 3904 SetTextColor (s->hdc, RGB (255, 255, 255));
3898 manually. */ 3905 SetBkColor (s->hdc, RGB (0, 0, 0));
3899 unsigned long mask = (GCClipMask | GCClipXOrigin | GCClipYOrigin 3906
3900 | GCFunction); 3907 BitBlt (s->hdc, x, y, s->img->width, s->img->height,
3901 XGCValues xgcv; 3908 compat_hdc, 0, 0, 0x990066);
3902 XRectangle clip_rect, image_rect, r; 3909 BitBlt (s->hdc, x, y, s->img->width, s->img->height,
3903 3910 mask_dc, 0, 0, SRCAND);
3904 xgcv.clip_mask = s->img->mask; 3911 BitBlt (s->hdc, x, y, s->img->width, s->img->height,
3905 xgcv.clip_x_origin = x; 3912 compat_hdc, 0, 0, 0x990066);
3906 xgcv.clip_y_origin = y; 3913
3907 xgcv.function = GXcopy; 3914 SelectObject (mask_dc, mask_orig_obj);
3908 XChangeGC (s->display, s->gc, mask, &xgcv); 3915 DeleteDC (mask_dc);
3909
3910 w32_get_glyph_string_clip_rect (s, &clip_rect);
3911 image_rect.x = x;
3912 image_rect.y = y;
3913 image_rect.width = s->img->width;
3914 image_rect.height = s->img->height;
3915 if (IntersectRect (&r, &clip_rect, &image_rect))
3916 XCopyArea (s->display, s->img->pixmap, s->window, s->gc,
3917 r.x - x, r.y - y, r.width, r.height, r.x, r.y);
3918 } 3916 }
3919 else 3917 else
3920#endif
3921 { 3918 {
3922 HDC compat_hdc = CreateCompatibleDC (s->hdc); 3919 SetTextColor (s->hdc, s->gc->foreground);
3923 HBRUSH fg_brush = CreateSolidBrush (s->gc->foreground); 3920 SetBkColor (s->hdc, s->gc->background);
3924 HBRUSH orig_brush = SelectObject (s->hdc, fg_brush); 3921
3925 HGDIOBJ orig_obj = SelectObject (compat_hdc, s->img->pixmap);
3926 x_set_glyph_string_clipping (s);
3927
3928 SetTextColor (s->hdc, s->gc->foreground);
3929 SetBkColor (s->hdc, s->gc->background);
3930#if 0 /* From w32bdf.c (which is from Meadow). */
3931 BitBlt (s->hdc, x, y, s->img->width, s->img->height,
3932 compat_hdc, 0, 0, SRCCOPY);
3933 BitBlt (s->hdc, x, y, s->img->width, s->img->height,
3934 compat_hdc, 0, 0, 0xB8074A);
3935#else
3936 BitBlt (s->hdc, x, y, s->img->width, s->img->height, 3922 BitBlt (s->hdc, x, y, s->img->width, s->img->height,
3937 compat_hdc, 0, 0, 0xE20746); 3923 compat_hdc, 0, 0, NOTSRCCOPY);
3938#endif 3924 /* Meadow uses 0xE20746, previously SRCCOPY and 0xB8074A. */
3939 SelectObject (s->hdc, orig_brush);
3940 DeleteObject (fg_brush);
3941 SelectObject (compat_hdc, orig_obj);
3942 DeleteDC (compat_hdc);
3943 3925
3944 /* When the image has a mask, we can expect that at 3926 /* When the image has a mask, we can expect that at
3945 least part of a mouse highlight or a block cursor will 3927 least part of a mouse highlight or a block cursor will
@@ -3954,8 +3936,13 @@ x_draw_image_foreground (s)
3954 w32_draw_rectangle (s->hdc, s->gc, x - r, y - r , 3936 w32_draw_rectangle (s->hdc, s->gc, x - r, y - r ,
3955 s->img->width + r*2 - 1, s->img->height + r*2 - 1); 3937 s->img->width + r*2 - 1, s->img->height + r*2 - 1);
3956 } 3938 }
3957 w32_set_clip_rectangle (s->hdc, NULL);
3958 } 3939 }
3940
3941 w32_set_clip_rectangle (s->hdc, NULL);
3942 SelectObject (s->hdc, orig_brush);
3943 DeleteObject (fg_brush);
3944 SelectObject (compat_hdc, orig_obj);
3945 DeleteDC (compat_hdc);
3959 } 3946 }
3960 else 3947 else
3961 w32_draw_rectangle (s->hdc, s->gc, x, y, s->img->width -1, 3948 w32_draw_rectangle (s->hdc, s->gc, x, y, s->img->width -1,
@@ -4040,51 +4027,35 @@ w32_draw_image_foreground_1 (s, pixmap)
4040 4027
4041 if (s->img->pixmap) 4028 if (s->img->pixmap)
4042 { 4029 {
4043#if 0 /* TODO: image mask */ 4030 HDC compat_hdc = CreateCompatibleDC (hdc);
4031 HBRUSH fg_brush = CreateSolidBrush (s->gc->foreground);
4032 HBRUSH orig_brush = SelectObject (hdc, fg_brush);
4033 HGDIOBJ orig_obj = SelectObject (compat_hdc, s->img->pixmap);
4034
4044 if (s->img->mask) 4035 if (s->img->mask)
4045 { 4036 {
4046 /* We can't set both a clip mask and use XSetClipRectangles 4037 HDC mask_dc = CreateCompatibleDC (hdc);
4047 because the latter also sets a clip mask. We also can't 4038 HGDIOBJ mask_orig_obj = SelectObject (mask_dc, s->img->mask);
4048 trust on the shape extension to be available 4039
4049 (XShapeCombineRegion). So, compute the rectangle to draw 4040 SetTextColor (hdc, RGB (0, 0, 0));
4050 manually. */ 4041 SetBkColor (hdc, RGB (255, 255, 255));
4051 unsigned long mask = (GCClipMask | GCClipXOrigin | GCClipYOrigin 4042 BitBlt (hdc, x, y, s->img->width, s->img->height,
4052 | GCFunction); 4043 compat_hdc, 0, 0, SRCINVERT);
4053 XGCValues xgcv; 4044 BitBlt (hdc, x, y, s->img->width, s->img->height,
4054 4045 mask_dc, 0, 0, SRCAND);
4055 xgcv.clip_mask = s->img->mask; 4046 BitBlt (hdc, x, y, s->img->width, s->img->height,
4056 xgcv.clip_x_origin = x; 4047 compat_hdc, 0, 0, SRCINVERT);
4057 xgcv.clip_y_origin = y; 4048
4058 xgcv.function = GXcopy; 4049 SelectObject (mask_dc, mask_orig_obj);
4059 XChangeGC (s->display, s->gc, mask, &xgcv); 4050 DeleteDC (mask_dc);
4060
4061 XCopyArea (s->display, s->img->pixmap, pixmap, s->gc,
4062 0, 0, s->img->width, s->img->height, x, y);
4063 XSetClipMask (s->display, s->gc, None);
4064 } 4051 }
4065 else 4052 else
4066#endif
4067 { 4053 {
4068 HDC compat_hdc = CreateCompatibleDC (hdc); 4054 SetTextColor (hdc, s->gc->foreground);
4069 HBRUSH fg_brush = CreateSolidBrush (s->gc->foreground); 4055 SetBkColor (hdc, s->gc->background);
4070 HBRUSH orig_brush = SelectObject (hdc, fg_brush); 4056
4071 HGDIOBJ orig_obj = SelectObject (compat_hdc, s->img->pixmap);
4072
4073 SetTextColor (hdc, s->gc->foreground);
4074 SetBkColor (hdc, s->gc->background);
4075#if 0 /* From w32bdf.c (which is from Meadow). */
4076 BitBlt (hdc, x, y, s->img->width, s->img->height,
4077 compat_hdc, 0, 0, SRCCOPY);
4078 BitBlt (hdc, x, y, s->img->width, s->img->height,
4079 compat_hdc, 0, 0, 0xB8074A);
4080#else
4081 BitBlt (hdc, x, y, s->img->width, s->img->height, 4057 BitBlt (hdc, x, y, s->img->width, s->img->height,
4082 compat_hdc, 0, 0, 0xE20746); 4058 compat_hdc, 0, 0, NOTSRCCOPY);
4083#endif
4084 SelectObject (hdc, orig_brush);
4085 DeleteObject (fg_brush);
4086 SelectObject (compat_hdc, orig_obj);
4087 DeleteDC (compat_hdc);
4088 4059
4089 /* When the image has a mask, we can expect that at 4060 /* When the image has a mask, we can expect that at
4090 least part of a mouse highlight or a block cursor will 4061 least part of a mouse highlight or a block cursor will
@@ -4096,10 +4067,15 @@ w32_draw_image_foreground_1 (s, pixmap)
4096 { 4067 {
4097 int r = s->img->relief; 4068 int r = s->img->relief;
4098 if (r < 0) r = -r; 4069 if (r < 0) r = -r;
4099 w32_draw_rectangle (s->hdc, s->gc, x - r, y - r , 4070 w32_draw_rectangle (hdc, s->gc, x - r, y - r ,
4100 s->img->width + r*2 - 1, s->img->height + r*2 - 1); 4071 s->img->width + r*2 - 1, s->img->height + r*2 - 1);
4101 } 4072 }
4102 } 4073 }
4074
4075 SelectObject (hdc, orig_brush);
4076 DeleteObject (fg_brush);
4077 SelectObject (compat_hdc, orig_obj);
4078 DeleteDC (compat_hdc);
4103 } 4079 }
4104 else 4080 else
4105 w32_draw_rectangle (hdc, s->gc, x, y, s->img->width - 1, 4081 w32_draw_rectangle (hdc, s->gc, x, y, s->img->width - 1,
@@ -4165,9 +4141,7 @@ x_draw_image_glyph_string (s)
4165 if (height > s->img->height 4141 if (height > s->img->height
4166 || s->img->hmargin 4142 || s->img->hmargin
4167 || s->img->vmargin 4143 || s->img->vmargin
4168#if 0 /* TODO: image mask */
4169 || s->img->mask 4144 || s->img->mask
4170#endif
4171 || s->img->pixmap == 0 4145 || s->img->pixmap == 0
4172 || s->width != s->background_width) 4146 || s->width != s->background_width)
4173 { 4147 {
@@ -4177,7 +4151,7 @@ x_draw_image_glyph_string (s)
4177 x = s->x; 4151 x = s->x;
4178 4152
4179 y = s->y + box_line_vwidth; 4153 y = s->y + box_line_vwidth;
4180#if 0 /* TODO: image mask */ 4154#if 0 /* TODO: figure out if we need to do this on Windows. */
4181 if (s->img->mask) 4155 if (s->img->mask)
4182 { 4156 {
4183 /* Create a pixmap as large as the glyph string. Fill it 4157 /* Create a pixmap as large as the glyph string. Fill it
@@ -4235,15 +4209,9 @@ x_draw_image_glyph_string (s)
4235 4209
4236 SetTextColor (s->hdc, s->gc->foreground); 4210 SetTextColor (s->hdc, s->gc->foreground);
4237 SetBkColor (s->hdc, s->gc->background); 4211 SetBkColor (s->hdc, s->gc->background);
4238#if 0 /* From w32bdf.c (which is from Meadow). */
4239 BitBlt (s->hdc, s->x, s->y, s->background_width, s->height, 4212 BitBlt (s->hdc, s->x, s->y, s->background_width, s->height,
4240 compat_hdc, 0, 0, SRCCOPY); 4213 compat_hdc, 0, 0, SRCCOPY);
4241 BitBlt (s->hdc, s->x, s->y, s->background_width, s->height, 4214
4242 compat_hdc, 0, 0, 0xB8074A);
4243#else
4244 BitBlt (s->hdc, s->x, s->y, s->background_width, s->height,
4245 compat_hdc, 0, 0, 0xE20746);
4246#endif
4247 SelectObject (s->hdc, orig_brush); 4215 SelectObject (s->hdc, orig_brush);
4248 DeleteObject (fg_brush); 4216 DeleteObject (fg_brush);
4249 SelectObject (compat_hdc, orig_obj); 4217 SelectObject (compat_hdc, orig_obj);
@@ -6586,7 +6554,6 @@ note_mode_line_highlight (w, x, mode_line_p)
6586 } 6554 }
6587 } 6555 }
6588 } 6556 }
6589
6590#if 0 /* TODO: mouse cursor */ 6557#if 0 /* TODO: mouse cursor */
6591 XDefineCursor (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f), cursor); 6558 XDefineCursor (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f), cursor);
6592#endif 6559#endif