summaryrefslogtreecommitdiff
path: root/legacy/evas/src/modules/engines/software_gdi/evas_outbuf.c
diff options
context:
space:
mode:
authorVincent Torri <vincent.torri@gmail.com>2010-09-18 17:19:11 +0000
committerVincent Torri <vincent.torri@gmail.com>2010-09-18 17:19:11 +0000
commit9acfb018116947b78f17a2f25fbfd80bd65cc945 (patch)
tree578a496b1701adb8d5348f6d7caf5f4b02f4ae1f /legacy/evas/src/modules/engines/software_gdi/evas_outbuf.c
parent6f4d152810c54fbb02db89f1262247b821fdce98 (diff)
Fix shaped windows on Windows. It uses regions.
Advantages: * it is the simplest method to implement Disadvantages: * it's slow * it does not take into account transparency * it does not work with the composite manager (Windows >= Vista) Layered windows should be used (all the disadvantaged above are fixed), but i've never succeeded in making them work. SVN revision: 52416
Diffstat (limited to '')
-rw-r--r--legacy/evas/src/modules/engines/software_gdi/evas_outbuf.c178
1 files changed, 162 insertions, 16 deletions
diff --git a/legacy/evas/src/modules/engines/software_gdi/evas_outbuf.c b/legacy/evas/src/modules/engines/software_gdi/evas_outbuf.c
index 09a2546..e260f82 100644
--- a/legacy/evas/src/modules/engines/software_gdi/evas_outbuf.c
+++ b/legacy/evas/src/modules/engines/software_gdi/evas_outbuf.c
@@ -10,8 +10,8 @@ static int gdicountlimit = 32;
10static Gdi_Output_Buffer * 10static Gdi_Output_Buffer *
11_find_gdiob(HDC dc, BITMAPINFO_GDI *bitmap_info, int depth, int w, int h, void *data) 11_find_gdiob(HDC dc, BITMAPINFO_GDI *bitmap_info, int depth, int w, int h, void *data)
12{ 12{
13 Eina_List *l; 13 Eina_List *l = NULL;
14 Eina_List *gdil; 14 Eina_List *gdil = NULL;
15 Gdi_Output_Buffer *gdiob = NULL; 15 Gdi_Output_Buffer *gdiob = NULL;
16 Gdi_Output_Buffer *gdiob2; 16 Gdi_Output_Buffer *gdiob2;
17 int sz; 17 int sz;
@@ -132,10 +132,10 @@ evas_software_gdi_outbuf_setup(int width,
132 int rotation, 132 int rotation,
133 Outbuf_Depth depth, 133 Outbuf_Depth depth,
134 HWND window, 134 HWND window,
135 HBITMAP mask,
136 int w_depth, 135 int w_depth,
137 unsigned int layered, 136 unsigned int borderless,
138 unsigned int fullscreen, 137 unsigned int fullscreen,
138 unsigned int region,
139 int mask_dither, 139 int mask_dither,
140 int destination_alpha) 140 int destination_alpha)
141{ 141{
@@ -153,7 +153,7 @@ evas_software_gdi_outbuf_setup(int width,
153 buf->priv.mask_dither = mask_dither; 153 buf->priv.mask_dither = mask_dither;
154 buf->priv.destination_alpha = destination_alpha; 154 buf->priv.destination_alpha = destination_alpha;
155 155
156 if (!evas_software_gdi_init(window, mask, w_depth, layered, fullscreen, buf)) 156 if (!evas_software_gdi_init(window, w_depth, borderless, fullscreen, region, buf))
157 { 157 {
158 free(buf); 158 free(buf);
159 return NULL; 159 return NULL;
@@ -205,8 +205,6 @@ evas_software_gdi_outbuf_setup(int width,
205 buf->priv.gdi.bitmap_info->masks[2]); 205 buf->priv.gdi.bitmap_info->masks[2]);
206 } 206 }
207 } 207 }
208 if (buf->priv.gdi.mask != mask)
209 buf->priv.gdi.mask = mask;
210 } 208 }
211 209
212 return buf; 210 return buf;
@@ -226,6 +224,7 @@ evas_software_gdi_outbuf_reconfigure(Outbuf *buf,
226 buf->height = height; 224 buf->height = height;
227 buf->rot = rotation; 225 buf->rot = rotation;
228 evas_software_gdi_bitmap_resize(buf); 226 evas_software_gdi_bitmap_resize(buf);
227 buf->priv.region_built = 0;
229} 228}
230 229
231RGBA_Image * 230RGBA_Image *
@@ -254,7 +253,7 @@ evas_software_gdi_outbuf_new_region_for_update(Outbuf *buf,
254 *cw = w; 253 *cw = w;
255 *ch = h; 254 *ch = h;
256 255
257 alpha = ((buf->priv.gdi.mask) || (buf->priv.destination_alpha)); 256 alpha = ((buf->priv.gdi.region) || (buf->priv.destination_alpha));
258 257
259 if ((buf->rot == 0) && 258 if ((buf->rot == 0) &&
260 (buf->priv.gdi.bitmap_info->masks[0] == 0xff0000) && 259 (buf->priv.gdi.bitmap_info->masks[0] == 0xff0000) &&
@@ -319,7 +318,7 @@ evas_software_gdi_outbuf_new_region_for_update(Outbuf *buf,
319/* 1, */ 318/* 1, */
320/* w, h, NULL); */ 319/* w, h, NULL); */
321 } 320 }
322 if ((buf->priv.gdi.mask) || (buf->priv.destination_alpha)) 321 if ((buf->priv.gdi.region) || (buf->priv.destination_alpha))
323 /* FIXME: faster memset! */ 322 /* FIXME: faster memset! */
324 memset(im->image.data, 0, w * h * sizeof(DATA32)); 323 memset(im->image.data, 0, w * h * sizeof(DATA32));
325 324
@@ -335,6 +334,7 @@ evas_software_gdi_outbuf_push_updated_region(Outbuf *buf,
335 int w, 334 int w,
336 int h) 335 int h)
337{ 336{
337 HRGN regions = NULL;
338 Gfx_Func_Convert conv_func; 338 Gfx_Func_Convert conv_func;
339 Outbuf_Region *obr; 339 Outbuf_Region *obr;
340 DATA32 *src_data; 340 DATA32 *src_data;
@@ -404,13 +404,159 @@ evas_software_gdi_outbuf_push_updated_region(Outbuf *buf,
404 x, 404 x,
405 y, 405 y,
406 NULL); 406 NULL);
407/* if (obr->mxob) */ 407
408/* { */ 408 /* Region code */
409/* int yy; */ 409 if (!buf->priv.gdi.region)
410/* for (yy = 0; yy < obr->h; yy++) */ 410 {
411/* evas_software_xlib_x_write_mask_line(buf, obr->mxob, */ 411 if (regions)
412/* src_data + */ 412 DeleteObject(regions);
413/* (yy * obr->w), obr->w, yy); */ 413 SetWindowRgn(buf->priv.gdi.window, NULL, 1);
414 return;
415 }
416
417 if (!buf->priv.region_built)
418 {
419 RECT rect;
420 POINT pt = { 0, 0 };
421 HRGN region;
422 int *tmp;
423 int i;
424 int j;
425 int ww;
426 int wh;
427 int dx;
428 int dy;
429 int xmin;
430 int xmax;
431
432 if (!GetClientRect(buf->priv.gdi.window, &rect))
433 return;
434
435 ww = rect.right - rect.left;
436 wh = rect.bottom - rect.top;
437 printf ("(%d,%d) (%d,%d)\n", w, h, ww, wh);
438
439 if (!GetWindowRect(buf->priv.gdi.window, &rect))
440 return;
441 if (!ClientToScreen(buf->priv.gdi.window, &pt))
442 return;
443 dx = x + pt.x - rect.left;
444 dy = y + pt.y - rect.top;
445
446 tmp = src_data;
447
448 for (j = 0; j < h; j++)
449 {
450 i = 0;
451 while (i < w)
452 {
453 if ((*tmp & 0xff000000) == 0xff000000)
454 {
455 xmin = dx + i;
456 if ((i + 1) == w)
457 {
458 xmax = dx + i;
459 region = CreateRectRgn(xmin, dy + j, xmax + 1, dy + j + 1);
460 if (regions == NULL)
461 regions = region;
462 else
463 {
464 CombineRgn(regions, regions, region, RGN_OR);
465 DeleteObject(region);
466 }
467 }
468 else
469 {
470 i++;
471 tmp++;
472
473 while (i < w)
474 {
475 if ((*tmp & 0xff000000) == 0xff000000)
476 {
477 if ((i + 1) == w)
478 {
479 xmax = dx + i;
480 region = CreateRectRgn(xmin, dy + j, xmax + 1, dy + j + 1);
481 if (regions == NULL)
482 regions = region;
483 else
484 {
485 CombineRgn(regions, regions, region, RGN_OR);
486 DeleteObject(region);
487 }
488 break;
489 }
490 }
491 else
492 {
493 xmax = dx + i - 1;
494 region = CreateRectRgn(xmin, dy + j, xmax + 1, dy + j + 1);
495 if (regions == NULL)
496 regions = region;
497 else
498 {
499 CombineRgn(regions, regions, region, RGN_OR);
500 DeleteObject(region);
501 }
502 break;
503 }
504 i++;
505 tmp++;
506 }
507 }
508 }
509 i++;
510 tmp++;
511 }
512 }
513
514 if (!buf->priv.gdi.borderless)
515 {
516 RECT rnc;
517 RECT rc;
518 POINT pt = { 0, 0 };
519 LONG ncw;
520 LONG nch;
521 LONG cw;
522 LONG ch;
523
524 if (!GetWindowRect(buf->priv.gdi.window, &rnc))
525 return;
526 if (!GetClientRect(buf->priv.gdi.window, &rc))
527 return;
528 if (!ClientToScreen(buf->priv.gdi.window, &pt))
529 return;
530
531 ncw = rnc.right - rnc.left;
532 nch = rnc.bottom - rnc.top;
533 cw = rc.right - rc.left;
534 ch = rc.bottom - rc.top;
535
536 region = CreateRectRgn(0, 0, ncw, pt.y - rnc.top);
537 if (!regions)
538 regions = region;
539 else
540 {
541 CombineRgn(regions, regions, region, RGN_OR);
542 DeleteObject(region);
543 }
544 region = CreateRectRgn(0, pt.y - rnc.top, pt.x - rnc.left, nch);
545 CombineRgn(regions, regions, region, RGN_OR);
546 DeleteObject(region);
547 region = CreateRectRgn(pt.x - rnc.left, pt.y - rnc.top + ch, pt.x - rnc.left + cw, nch);
548 CombineRgn(regions, regions, region, RGN_OR);
549 DeleteObject(region);
550 region = CreateRectRgn(pt.x - rnc.left + cw, pt.y - rnc.top, ncw, nch);
551 CombineRgn(regions, regions, region, RGN_OR);
552 DeleteObject(region);
553 }
554
555 if (regions)
556 SetWindowRgn(buf->priv.gdi.window, regions, 1);
557
558 buf->priv.region_built = 1;
559 }
414} 560}
415 561
416void 562void