Kaydet (Commit) b292a276 authored tarafından Noel Grandin's avatar Noel Grandin Kaydeden (comit) Caolán McNamara

tdf#118029 crashtesting ooo24656-1.doc with --convert-to pdf

Revert "dont use GetMask in GeoTexSvxBitmapEx"

This reverts commit 63e65d17.

Until we come up with something better

Change-Id: I246468abdd5e3ee917143e251c2e95430d84f77b
Reviewed-on: https://gerrit.libreoffice.org/55385Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarCaolán McNamara <caolanm@redhat.com>
Tested-by: 's avatarCaolán McNamara <caolanm@redhat.com>
üst e2fcb76d
...@@ -64,22 +64,39 @@ namespace drawinglayer ...@@ -64,22 +64,39 @@ namespace drawinglayer
const BitmapEx& rBitmapEx, const BitmapEx& rBitmapEx,
const basegfx::B2DRange& rRange) const basegfx::B2DRange& rRange)
: maBitmapEx(rBitmapEx), : maBitmapEx(rBitmapEx),
maTransparence(),
maTopLeft(rRange.getMinimum()), maTopLeft(rRange.getMinimum()),
maSize(rRange.getRange()), maSize(rRange.getRange()),
mfMulX(0.0), mfMulX(0.0),
mfMulY(0.0), mfMulY(0.0),
mbIsAlpha(false) mbIsAlpha(false),
mbIsTransparent(maBitmapEx.IsTransparent())
{ {
if(maBitmapEx.IsTransparent()) // #121194# Todo: use alpha channel, too (for 3d)
maBitmap = maBitmapEx.GetBitmap();
if(mbIsTransparent)
{ {
if(maBitmapEx.IsAlpha()) if(maBitmapEx.IsAlpha())
{ {
mbIsAlpha = true; mbIsAlpha = true;
maTransparence = rBitmapEx.GetAlpha().GetBitmap();
} }
else
{
maTransparence = rBitmapEx.GetMask();
} }
mfMulX = static_cast<double>(maBitmapEx.GetSizePixel().Width()) / maSize.getX(); mpReadTransparence = Bitmap::ScopedReadAccess(maTransparence);
mfMulY = static_cast<double>(maBitmapEx.GetSizePixel().Height()) / maSize.getY(); }
mpReadBitmap = Bitmap::ScopedReadAccess(maBitmap);
SAL_WARN_IF(!mpReadBitmap, "drawinglayer", "GeoTexSvxBitmapEx: Got no read access to Bitmap");
if (mpReadBitmap)
{
mfMulX = static_cast<double>(mpReadBitmap->Width()) / maSize.getX();
mfMulY = static_cast<double>(mpReadBitmap->Height()) / maSize.getY();
}
if(maSize.getX() <= 1.0) if(maSize.getX() <= 1.0)
{ {
...@@ -96,20 +113,60 @@ namespace drawinglayer ...@@ -96,20 +113,60 @@ namespace drawinglayer
{ {
} }
sal_uInt8 GeoTexSvxBitmapEx::impGetTransparence(sal_Int32 nX, sal_Int32 nY) const sal_uInt8 GeoTexSvxBitmapEx::impGetTransparence(sal_Int32 rX, sal_Int32 rY) const
{
switch(maBitmapEx.GetTransparentType())
{
case TransparentType::NONE:
{
break;
}
case TransparentType::Color:
{
const BitmapColor aBitmapColor(mpReadBitmap->GetColor(rY, rX));
if(maBitmapEx.GetTransparentColor() == aBitmapColor.GetColor())
{ {
return maBitmapEx.GetTransparency(nX, nY); return 255;
}
break;
}
case TransparentType::Bitmap:
{
OSL_ENSURE(mpReadTransparence, "OOps, transparence type Bitmap, but no read access created in the constructor (?)");
const BitmapColor aBitmapColor(mpReadTransparence->GetPixel(rY, rX));
if(mbIsAlpha)
{
return aBitmapColor.GetIndex();
}
else
{
if(0x00 != aBitmapColor.GetIndex())
{
return 255;
}
}
break;
}
}
return 0;
} }
bool GeoTexSvxBitmapEx::impIsValid(const basegfx::B2DPoint& rUV, sal_Int32& rX, sal_Int32& rY) const bool GeoTexSvxBitmapEx::impIsValid(const basegfx::B2DPoint& rUV, sal_Int32& rX, sal_Int32& rY) const
{
if(mpReadBitmap)
{ {
rX = static_cast<sal_Int32>((rUV.getX() - maTopLeft.getX()) * mfMulX); rX = static_cast<sal_Int32>((rUV.getX() - maTopLeft.getX()) * mfMulX);
if(rX >= 0 && rX < maBitmapEx.GetSizePixel().Width()) if(rX >= 0 && rX < mpReadBitmap->Width())
{ {
rY = static_cast<sal_Int32>((rUV.getY() - maTopLeft.getY()) * mfMulY); rY = static_cast<sal_Int32>((rUV.getY() - maTopLeft.getY()) * mfMulY);
return (rY >= 0 && rY < maBitmapEx.GetSizePixel().Height()); return (rY >= 0 && rY < mpReadBitmap->Height());
}
} }
return false; return false;
...@@ -122,7 +179,7 @@ namespace drawinglayer ...@@ -122,7 +179,7 @@ namespace drawinglayer
if(impIsValid(rUV, nX, nY)) if(impIsValid(rUV, nX, nY))
{ {
const double fConvertColor(1.0 / 255.0); const double fConvertColor(1.0 / 255.0);
const ::Color aBMCol(maBitmapEx.GetPixelColor(nX, nY)); const BitmapColor aBMCol(mpReadBitmap->GetColor(nY, nX));
const basegfx::BColor aBSource( const basegfx::BColor aBSource(
static_cast<double>(aBMCol.GetRed()) * fConvertColor, static_cast<double>(aBMCol.GetRed()) * fConvertColor,
static_cast<double>(aBMCol.GetGreen()) * fConvertColor, static_cast<double>(aBMCol.GetGreen()) * fConvertColor,
...@@ -130,10 +187,10 @@ namespace drawinglayer ...@@ -130,10 +187,10 @@ namespace drawinglayer
rBColor = aBSource; rBColor = aBSource;
if(maBitmapEx.IsTransparent()) if(mbIsTransparent)
{ {
// when we have a transparence, make use of it // when we have a transparence, make use of it
const sal_uInt8 aLuminance = aBMCol.GetTransparency(); const sal_uInt8 aLuminance(impGetTransparence(nX, nY));
rfOpacity = (static_cast<double>(0xff - aLuminance) * (1.0 / 255.0)); rfOpacity = (static_cast<double>(0xff - aLuminance) * (1.0 / 255.0));
} }
...@@ -154,7 +211,7 @@ namespace drawinglayer ...@@ -154,7 +211,7 @@ namespace drawinglayer
if(impIsValid(rUV, nX, nY)) if(impIsValid(rUV, nX, nY))
{ {
if(maBitmapEx.IsTransparent()) if(mbIsTransparent)
{ {
// this texture has an alpha part, use it // this texture has an alpha part, use it
const sal_uInt8 aLuminance(impGetTransparence(nX, nY)); const sal_uInt8 aLuminance(impGetTransparence(nX, nY));
...@@ -165,7 +222,8 @@ namespace drawinglayer ...@@ -165,7 +222,8 @@ namespace drawinglayer
else else
{ {
// this texture is a color bitmap used as transparence map // this texture is a color bitmap used as transparence map
const ::Color aColor(maBitmapEx.GetPixelColor(nX, nY)); const BitmapColor aBMCol(mpReadBitmap->GetColor(nY, nX));
const Color aColor(aBMCol.GetRed(), aBMCol.GetGreen(), aBMCol.GetBlue());
rfOpacity = (static_cast<double>(0xff - aColor.GetLuminance()) * (1.0 / 255.0)); rfOpacity = (static_cast<double>(0xff - aColor.GetLuminance()) * (1.0 / 255.0));
} }
...@@ -237,14 +295,20 @@ namespace drawinglayer ...@@ -237,14 +295,20 @@ namespace drawinglayer
} }
void GeoTexSvxBitmapExTiled::modifyBColor(const basegfx::B2DPoint& rUV, basegfx::BColor& rBColor, double& rfOpacity) const void GeoTexSvxBitmapExTiled::modifyBColor(const basegfx::B2DPoint& rUV, basegfx::BColor& rBColor, double& rfOpacity) const
{
if(mpReadBitmap)
{ {
GeoTexSvxBitmapEx::modifyBColor(impGetCorrected(rUV), rBColor, rfOpacity); GeoTexSvxBitmapEx::modifyBColor(impGetCorrected(rUV), rBColor, rfOpacity);
} }
}
void GeoTexSvxBitmapExTiled::modifyOpacity(const basegfx::B2DPoint& rUV, double& rfOpacity) const void GeoTexSvxBitmapExTiled::modifyOpacity(const basegfx::B2DPoint& rUV, double& rfOpacity) const
{
if(mpReadBitmap)
{ {
GeoTexSvxBitmapEx::modifyOpacity(impGetCorrected(rUV), rfOpacity); GeoTexSvxBitmapEx::modifyOpacity(impGetCorrected(rUV), rfOpacity);
} }
}
} // end of namespace texture } // end of namespace texture
} // end of namespace drawinglayer } // end of namespace drawinglayer
......
...@@ -60,12 +60,16 @@ namespace drawinglayer ...@@ -60,12 +60,16 @@ namespace drawinglayer
protected: protected:
BitmapEx maBitmapEx; BitmapEx maBitmapEx;
Bitmap maBitmap; // Bitmap held within maBitmapEx, to exist during mpReadBitmap scope Bitmap maBitmap; // Bitmap held within maBitmapEx, to exist during mpReadBitmap scope
Bitmap::ScopedReadAccess mpReadBitmap;
Bitmap maTransparence;
Bitmap::ScopedReadAccess mpReadTransparence;
basegfx::B2DPoint maTopLeft; basegfx::B2DPoint maTopLeft;
basegfx::B2DVector maSize; basegfx::B2DVector maSize;
double mfMulX; double mfMulX;
double mfMulY; double mfMulY;
bool mbIsAlpha : 1; bool mbIsAlpha : 1;
bool mbIsTransparent : 1;
// helpers // helpers
bool impIsValid(const basegfx::B2DPoint& rUV, sal_Int32& rX, sal_Int32& rY) const; bool impIsValid(const basegfx::B2DPoint& rUV, sal_Int32& rX, sal_Int32& rY) const;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment