summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/drv/cdgl.c7
-rw-r--r--src/drv/cdirgb.c3
-rw-r--r--src/gdiplus/cdwinp.cpp22
3 files changed, 16 insertions, 16 deletions
diff --git a/src/drv/cdgl.c b/src/drv/cdgl.c
index 4357e5a..fb1739d 100644
--- a/src/drv/cdgl.c
+++ b/src/drv/cdgl.c
@@ -638,10 +638,11 @@ static long int cdforeground(cdCtxCanvas *ctxcanvas, long int color)
static void cdclear(cdCtxCanvas* ctxcanvas)
{
- unsigned char r, g, b;
+ unsigned char r, g, b, a;
cdDecodeColor(ctxcanvas->canvas->background, &r, &g, &b);
- glClearColor((GLclampf)((double)r/255.0), (GLclampf)((double)g/255.0), (GLclampf)((double)b/255.0), 0);
- glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
+ a = cdDecodeAlpha(ctxcanvas->canvas->background);
+ glClearColor((GLclampf)r/255.0f, (GLclampf)g/255.0f, (GLclampf)b/255.0f, (GLclampf)a/255.0f);
+ glClear(GL_COLOR_BUFFER_BIT);
}
static void cdfline(cdCtxCanvas *ctxcanvas, double x1, double y1, double x2, double y2)
diff --git a/src/drv/cdirgb.c b/src/drv/cdirgb.c
index 68a5766..d9dd6a8 100644
--- a/src/drv/cdirgb.c
+++ b/src/drv/cdirgb.c
@@ -430,7 +430,8 @@ static void cdclear(cdCtxCanvas* ctxcanvas)
memset(ctxcanvas->red, cdRed(ctxcanvas->canvas->background), size);
memset(ctxcanvas->green, cdGreen(ctxcanvas->canvas->background), size);
memset(ctxcanvas->blue, cdBlue(ctxcanvas->canvas->background), size);
- if (ctxcanvas->alpha) memset(ctxcanvas->alpha, cdAlpha(ctxcanvas->canvas->background), size); /* here is the normal alpha coding */
+ if (ctxcanvas->alpha)
+ memset(ctxcanvas->alpha, cdAlpha(ctxcanvas->canvas->background), size); /* here is the normal alpha coding */
}
static void irgPostProcessIntersect(unsigned char* clip, int size)
diff --git a/src/gdiplus/cdwinp.cpp b/src/gdiplus/cdwinp.cpp
index db09cd6..522f136 100644
--- a/src/gdiplus/cdwinp.cpp
+++ b/src/gdiplus/cdwinp.cpp
@@ -139,9 +139,7 @@ static void sUpdateFillBrush(cdCtxCanvas* ctxcanvas)
{
// only stipple depends on Foreground and Background Color.
if (ctxcanvas->canvas->interior_style == CD_STIPPLE)
- {
cdstipple(ctxcanvas, ctxcanvas->canvas->stipple_w, ctxcanvas->canvas->stipple_h, ctxcanvas->canvas->stipple);
- }
break;
}
}
@@ -158,18 +156,17 @@ static long int cdforeground(cdCtxCanvas* ctxcanvas, long int color)
return color;
}
-static Color sSetAlpha(const Color& c, BYTE alpha)
+static Color sTranspAlpha(const Color& c)
{
- return Color(alpha, c.GetRed(), c.GetGreen(), c.GetBlue());
+ return Color(0, c.GetRed(), c.GetGreen(), c.GetBlue());
}
static long int cdbackground(cdCtxCanvas* ctxcanvas, long int color)
{
ctxcanvas->bg = sColor2Windows(color);
- if ((ctxcanvas->canvas->back_opacity == CD_TRANSPARENT) &&
- (cdAlpha(ctxcanvas->canvas->background) == 255))
- ctxcanvas->bg = sSetAlpha(ctxcanvas->bg, (BYTE)0);
+ if (ctxcanvas->canvas->back_opacity == CD_TRANSPARENT)
+ ctxcanvas->bg = sTranspAlpha(ctxcanvas->bg); /* set background as full transparent */
sUpdateFillBrush(ctxcanvas);
@@ -181,10 +178,10 @@ static int cdbackopacity(cdCtxCanvas* ctxcanvas, int opacity)
switch (opacity)
{
case CD_TRANSPARENT:
- ctxcanvas->bg = sSetAlpha(ctxcanvas->bg, (BYTE)0);
+ ctxcanvas->bg = sTranspAlpha(ctxcanvas->bg); /* set background as full transparent */
break;
case CD_OPAQUE:
- ctxcanvas->bg = sSetAlpha(ctxcanvas->bg, (BYTE)255);
+ ctxcanvas->bg = sColor2Windows(ctxcanvas->canvas->background);
break;
}
@@ -1619,7 +1616,8 @@ static void cdclear(cdCtxCanvas* ctxcanvas)
if (ctxcanvas->canvas->clip_mode != CD_CLIPOFF)
ctxcanvas->graphics->ResetClip();
- ctxcanvas->graphics->Clear(sSetAlpha(ctxcanvas->bg, (BYTE)255));
+ /* do NOT use "ctxcanvas->bg" here, because it depends on backopacity */
+ ctxcanvas->graphics->Clear(sColor2Windows(ctxcanvas->canvas->background));
if (ctxcanvas->canvas->clip_mode != CD_CLIPOFF)
cdclip(ctxcanvas, ctxcanvas->canvas->clip_mode);
@@ -2717,8 +2715,8 @@ cdCtxCanvas *cdwpCreateCanvas(cdCanvas* canvas, Graphics* graphics, int wtype)
set_aa_attrib(ctxcanvas, "1"); // default is ANTIALIAS=1
- ctxcanvas->fg = Color(); // black
- ctxcanvas->bg = Color(255, 255, 255); // white
+ ctxcanvas->fg = Color(); // black,opaque
+ ctxcanvas->bg = Color(255, 255, 255); // white,opaque => used only for fill
canvas->invert_yaxis = 1;