summaryrefslogtreecommitdiff
path: root/canvas
diff options
context:
space:
mode:
authorNoel <noel.grandin@collabora.co.uk>2021-01-11 08:54:37 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2021-01-12 17:38:53 +0100
commitd765ec2295d12ccde1fb25aa92c5d821de748add (patch)
treec2f806389478df23b78319c6043971f92995851c /canvas
parenta1d6701105456248f6ff39766a6699f26a8f3d60 (diff)
transparency->alpha in tools::Color
this just changes the Get/Set methods, the constructor and internal representation of Color is not changed. Change-Id: Idb6e07cc08bbaa5bd55b6bd4b585e648aef507b6 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/109074 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'canvas')
-rw-r--r--canvas/source/cairo/cairo_canvashelper_text.cxx4
-rw-r--r--canvas/source/directx/dx_textlayout_drawhelper.cxx2
-rw-r--r--canvas/source/vcl/canvasbitmaphelper.cxx2
-rw-r--r--canvas/source/vcl/canvashelper.cxx16
-rw-r--r--canvas/source/vcl/canvashelper.hxx2
5 files changed, 13 insertions, 13 deletions
diff --git a/canvas/source/cairo/cairo_canvashelper_text.cxx b/canvas/source/cairo/cairo_canvashelper_text.cxx
index 4ee68f94de46..056ae519201f 100644
--- a/canvas/source/cairo/cairo_canvashelper_text.cxx
+++ b/canvas/source/cairo/cairo_canvashelper_text.cxx
@@ -135,8 +135,8 @@ namespace cairocanvas
// extract alpha, and make color opaque
// afterwards. Otherwise, OutputDevice won't draw anything
- nTransparency = aColor.GetTransparency();
- aColor.SetTransparency(0);
+ nTransparency = 255 - aColor.GetAlpha();
+ aColor.SetAlpha(255);
rOutDev.SetTextColor( aColor );
diff --git a/canvas/source/directx/dx_textlayout_drawhelper.cxx b/canvas/source/directx/dx_textlayout_drawhelper.cxx
index 312b72983b67..1ffeb612de3d 100644
--- a/canvas/source/directx/dx_textlayout_drawhelper.cxx
+++ b/canvas/source/directx/dx_textlayout_drawhelper.cxx
@@ -101,7 +101,7 @@ namespace dxcanvas
aColor = vcl::unotools::doubleSequenceToColor(
rRenderState.DeviceColor,
mxGraphicDevice->getDeviceColorSpace());
- aColor.SetTransparency(0);
+ aColor.SetAlpha(255);
xVirtualDevice->SetTextColor(aColor);
// create the font
diff --git a/canvas/source/vcl/canvasbitmaphelper.cxx b/canvas/source/vcl/canvasbitmaphelper.cxx
index 336c12b83047..dd1898486e8a 100644
--- a/canvas/source/vcl/canvasbitmaphelper.cxx
+++ b/canvas/source/vcl/canvasbitmaphelper.cxx
@@ -148,7 +148,7 @@ namespace vclcanvas
pRes[ 0 ] = aColor.GetRed();
pRes[ 1 ] = aColor.GetGreen();
pRes[ 2 ] = aColor.GetBlue();
- pRes[ 3 ] = aColor.GetTransparency();
+ pRes[ 3 ] = 255 - aColor.GetAlpha();
return aRes;
}
diff --git a/canvas/source/vcl/canvashelper.cxx b/canvas/source/vcl/canvashelper.cxx
index 1f95b900592f..c3d31557c09d 100644
--- a/canvas/source/vcl/canvashelper.cxx
+++ b/canvas/source/vcl/canvashelper.cxx
@@ -479,7 +479,7 @@ namespace vclcanvas
{
tools::OutDevStateKeeper aStateKeeper( mpProtectedOutDevProvider );
- const int nTransparency( setupOutDevState( viewState, renderState, FILL_COLOR ) );
+ const int nAlpha( setupOutDevState( viewState, renderState, FILL_COLOR ) );
::basegfx::B2DPolyPolygon aB2DPolyPoly(
::basegfx::unotools::b2DPolyPolygonFromXPolyPolygon2D(xPolyPolygon));
aB2DPolyPoly.setClosed(true); // ensure closed poly, otherwise VCL does not fill
@@ -487,13 +487,13 @@ namespace vclcanvas
aB2DPolyPoly,
viewState, renderState ) );
const bool bSourceAlpha( renderState.CompositeOperation == rendering::CompositeOperation::SOURCE );
- if( !nTransparency || bSourceAlpha )
+ if( nAlpha == 255 || bSourceAlpha )
{
mpOutDevProvider->getOutDev().DrawPolyPolygon( aPolyPoly );
}
else
{
- const int nTransPercent( (nTransparency * 100 + 128) / 255 ); // normal rounding, no truncation here
+ const int nTransPercent( ((255 - nAlpha) * 100 + 128) / 255 ); // normal rounding, no truncation here
mpOutDevProvider->getOutDev().DrawTransparent( aPolyPoly, static_cast<sal_uInt16>(nTransPercent) );
}
@@ -503,7 +503,7 @@ namespace vclcanvas
// actually what mp2ndOutDev is... well, here we do &
// assume a 1bpp target - everything beyond 97%
// transparency is fully transparent
- if( nTransparency < 253 )
+ if( nAlpha > 2 )
{
mp2ndOutDevProvider->getOutDev().SetFillColor( COL_BLACK );
mp2ndOutDevProvider->getOutDev().DrawPolyPolygon( aPolyPoly );
@@ -1016,7 +1016,7 @@ namespace vclcanvas
if( mp2ndOutDevProvider )
p2ndOutDev = &mp2ndOutDevProvider->getOutDev();
- int nTransparency(0);
+ int nAlpha(255);
// TODO(P2): Don't change clipping all the time, maintain current clip
// state and change only when update is necessary
@@ -1032,8 +1032,8 @@ namespace vclcanvas
// extract alpha, and make color opaque
// afterwards. Otherwise, OutputDevice won't draw anything
- nTransparency = aColor.GetTransparency();
- aColor.SetTransparency(0);
+ nAlpha = aColor.GetAlpha();
+ aColor.SetAlpha(255);
if( eColorType != IGNORE_COLOR )
{
@@ -1075,7 +1075,7 @@ namespace vclcanvas
}
}
- return nTransparency;
+ return nAlpha;
}
bool CanvasHelper::setupTextOutput( ::Point& o_rOutPos,
diff --git a/canvas/source/vcl/canvashelper.hxx b/canvas/source/vcl/canvashelper.hxx
index 48a6a2742431..ba385110bf71 100644
--- a/canvas/source/vcl/canvashelper.hxx
+++ b/canvas/source/vcl/canvashelper.hxx
@@ -262,7 +262,7 @@ namespace vclcanvas
LINE_COLOR, FILL_COLOR, TEXT_COLOR, IGNORE_COLOR
};
- // returns transparency of color
+ // returns alpha of color
int setupOutDevState( const css::rendering::ViewState& viewState,
const css::rendering::RenderState& renderState,
ColorType eColorType ) const;