From a75ccf9e6481c6ee0d65c999e5766585f988d27f Mon Sep 17 00:00:00 2001 From: Carsten Haitzler Date: Sun, 16 Apr 2006 17:04:36 +0000 Subject: [PATCH] fix color multiply whiel blend (ergh! need temporary image! yuk!) SVN revision: 22163 --- legacy/evas/src/bin/evas_test_main.c | 5 +- .../evas/src/modules/engines/gl_x11/evas_engine.c | 9 ++ .../engines/xrender_x11/evas_engine_xrender.c | 119 ++++++++++++++------- 3 files changed, 95 insertions(+), 38 deletions(-) diff --git a/legacy/evas/src/bin/evas_test_main.c b/legacy/evas/src/bin/evas_test_main.c index 74a1dfd..5dd6e0c 100644 --- a/legacy/evas/src/bin/evas_test_main.c +++ b/legacy/evas/src/bin/evas_test_main.c @@ -184,8 +184,9 @@ loop(void) evas_object_move(panel_clip, 0, win_h - 240); evas_object_move(panel_top, 0, win_h - 240 - 10); evas_object_move(panel_shadow, 0, win_h - 240); - evas_object_color_set(evas_logo, 255, 255, 255, - (int)(255 * (((6.0) - t) / 4.0))); + evas_object_color_set(evas_logo, 255, 255, 255, + (int)(255 * (((6.0) - t) / 4.0)) + ); } else if (t <= 26.0) { diff --git a/legacy/evas/src/modules/engines/gl_x11/evas_engine.c b/legacy/evas/src/modules/engines/gl_x11/evas_engine.c index f5c19d0..20c11d2 100644 --- a/legacy/evas/src/modules/engines/gl_x11/evas_engine.c +++ b/legacy/evas/src/modules/engines/gl_x11/evas_engine.c @@ -426,6 +426,15 @@ eng_output_flush(void *data) re->win->draw.x2 - re->win->draw.x1 + 1, re->win->draw.y2 - re->win->draw.y1 + 1); #else +#if 1 + glFlush(); + { + unsigned int rc; + + glXGetVideoSyncSGI(&rc); + glXWaitVideoSyncSGI(2, (rc + 1) % 2, &rc); + } +#endif glXSwapBuffers(re->win->disp, re->win->win); #endif // glFlush(); diff --git a/legacy/evas/src/modules/engines/xrender_x11/evas_engine_xrender.c b/legacy/evas/src/modules/engines/xrender_x11/evas_engine_xrender.c index 44223be..c789ba3 100644 --- a/legacy/evas/src/modules/engines/xrender_x11/evas_engine_xrender.c +++ b/legacy/evas/src/modules/engines/xrender_x11/evas_engine_xrender.c @@ -302,6 +302,7 @@ _xr_render_surface_clips_set(Xrender_Surface *rs, RGBA_Draw_Context *dc, int rx, void _xr_render_surface_composite(Xrender_Surface *srs, Xrender_Surface *drs, RGBA_Draw_Context *dc, int sx, int sy, int sw, int sh, int x, int y, int w, int h, int smooth) { + Xrender_Surface *trs = NULL; XTransform xf; XRenderPictureAttributes att; Picture mask; @@ -310,6 +311,64 @@ _xr_render_surface_composite(Xrender_Surface *srs, Xrender_Surface *drs, RGBA_Dr if ((sw <= 0) || (sh <= 0) || (w <= 0) || (h <= 0)) return; + att.clip_mask = None; + XRenderChangePicture(srs->xinf->disp, srs->pic, CPClipMask, &att); + XRenderChangePicture(srs->xinf->disp, drs->pic, CPClipMask, &att); + + op = PictOpSrc; + if (srs->alpha) op = PictOpOver; + mask = None; + if ((dc) && (dc->mul.use)) + { + r = (int)(R_VAL(&dc->mul.col)); + g = (int)(G_VAL(&dc->mul.col)); + b = (int)(B_VAL(&dc->mul.col)); + a = (int)(A_VAL(&dc->mul.col)); + if (!(r == g == b == a == 0xff)) + { + if ((srs->xinf->mul_r != r) || (srs->xinf->mul_g != g) || + (srs->xinf->mul_b != b) || (srs->xinf->mul_a != a)) + { + srs->xinf->mul_r = r; + srs->xinf->mul_g = g; + srs->xinf->mul_b = b; + srs->xinf->mul_a = a; + _xr_render_surface_solid_rectangle_set(srs->xinf->mul, + r, + g, + b, + a, + 0, 0, 1, 1); + } + att.component_alpha = 1; + op = PictOpOver; + mask = srs->xinf->mul->pic; + XRenderChangePicture(srs->xinf->disp, mask, CPComponentAlpha, &att); + if ((r == g == b == 0xff) && (a != 0xff)) + { + } + else + { + xf.matrix[0][0] = 1; + xf.matrix[0][1] = 0; + xf.matrix[0][2] = 0; + + xf.matrix[1][0] = 0; + xf.matrix[1][1] = 1; + xf.matrix[1][2] = 0; + + xf.matrix[2][0] = 0; + xf.matrix[2][1] = 0; + xf.matrix[2][2] = 1; + trs = _xr_render_surface_new(srs->xinf, sw, sh, srs->fmt, srs->alpha); + XRenderSetPictureTransform(srs->xinf->disp, srs->pic, &xf); + XRenderComposite(srs->xinf->disp, PictOpSrc, srs->pic, mask, + trs->pic, sx, sy, 0, 0, 0, 0, sw, sh); + mask = 0; + } + } + } + sf = MAX(sw, sh); #define BMAX 26 if (sf <= 8 ) sf = 1 << (BMAX - 3); @@ -338,44 +397,32 @@ _xr_render_surface_composite(Xrender_Surface *srs, Xrender_Surface *drs, RGBA_Dr xf.matrix[2][1] = 0; xf.matrix[2][2] = sf; - op = PictOpSrc; - if (srs->alpha) op = PictOpOver; - mask = None; - if ((dc) && (dc->mul.use)) + _xr_render_surface_clips_set(drs, dc, x, y, w, h); + if (trs) { - r = (int)(R_VAL(&dc->mul.col)); - g = (int)(G_VAL(&dc->mul.col)); - b = (int)(B_VAL(&dc->mul.col)); - a = (int)(A_VAL(&dc->mul.col)); - if (!(r == g == b == a == 0xff)) - { - if ((srs->xinf->mul_r != r) || (srs->xinf->mul_g != g) || - (srs->xinf->mul_b != b) || (srs->xinf->mul_a != a)) - { - srs->xinf->mul_r = r; - srs->xinf->mul_g = g; - srs->xinf->mul_b = b; - srs->xinf->mul_a = a; - _xr_render_surface_solid_rectangle_set(srs->xinf->mul, r, g, b, a, 0, 0, 1, 1); - } - op = PictOpOver; - mask = srs->xinf->mul->pic; - } + if (smooth) + XRenderSetPictureFilter(trs->xinf->disp, trs->pic, "best", NULL, 0); + else + XRenderSetPictureFilter(trs->xinf->disp, trs->pic, "nearest", NULL, 0); + XRenderSetPictureTransform(trs->xinf->disp, trs->pic, &xf); + + XRenderComposite(srs->xinf->disp, op, trs->pic, mask, drs->pic, + 0, 0, 0, 0, x, y, w, h); + _xr_render_surface_free(trs); + } + else + { + if (smooth) + XRenderSetPictureFilter(srs->xinf->disp, srs->pic, "best", NULL, 0); + else + XRenderSetPictureFilter(srs->xinf->disp, srs->pic, "nearest", NULL, 0); + XRenderSetPictureTransform(srs->xinf->disp, srs->pic, &xf); + + XRenderComposite(srs->xinf->disp, op, srs->pic, mask, drs->pic, + ((sx * w) + (sw / 2)) / sw, + ((sy * h) + (sh / 2)) / sh, + 0, 0, x, y, w, h); } - - XRenderSetPictureTransform(srs->xinf->disp, srs->pic, &xf); - att.clip_mask = None; - XRenderChangePicture(srs->xinf->disp, srs->pic, CPClipMask, &att); - XRenderChangePicture(srs->xinf->disp, drs->pic, CPClipMask, &att); - - if (smooth) XRenderSetPictureFilter(srs->xinf->disp, srs->pic, "best", NULL, 0); - else XRenderSetPictureFilter(srs->xinf->disp, srs->pic, "nearest", NULL, 0); - - _xr_render_surface_clips_set(drs, dc, x, y, w, h); - XRenderComposite(srs->xinf->disp, op, srs->pic, mask, drs->pic, - ((sx * w) + (sw / 2)) / sw, - ((sy * h) + (sh / 2)) / sh, - 0, 0, x, y, w, h); } void -- 2.7.4