You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openoffice.apache.org by al...@apache.org on 2012/10/16 11:44:04 UTC
svn commit: r1398711 [4/4] - in /incubator/ooo/trunk/main: drawinglayer/
drawinglayer/inc/drawinglayer/attribute/
drawinglayer/inc/drawinglayer/primitive2d/
drawinglayer/inc/drawinglayer/primitive3d/
drawinglayer/inc/drawinglayer/processor2d/ drawingla...
Modified: incubator/ooo/trunk/main/drawinglayer/source/processor2d/vclmetafileprocessor2d.cxx
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/drawinglayer/source/processor2d/vclmetafileprocessor2d.cxx?rev=1398711&r1=1398710&r2=1398711&view=diff
==============================================================================
--- incubator/ooo/trunk/main/drawinglayer/source/processor2d/vclmetafileprocessor2d.cxx (original)
+++ incubator/ooo/trunk/main/drawinglayer/source/processor2d/vclmetafileprocessor2d.cxx Tue Oct 16 09:44:02 2012
@@ -590,7 +590,7 @@ namespace drawinglayer
Even for XFillTransparenceItem it is used, thus it may need to be supported in
UnifiedTransparencePrimitive2D, too, when interpreted as normally filled PolyPolygon.
Implemented for:
- PRIMITIVE2D_ID_POLYPOLYGONBITMAPPRIMITIVE2D,
+ PRIMITIVE2D_ID_POLYPOLYGONGRAPHICPRIMITIVE2D,
PRIMITIVE2D_ID_POLYPOLYGONHATCHPRIMITIVE2D,
PRIMITIVE2D_ID_POLYPOLYGONGRADIENTPRIMITIVE2D,
PRIMITIVE2D_ID_POLYPOLYGONCOLORPRIMITIVE2D,
@@ -1300,19 +1300,19 @@ namespace drawinglayer
RenderBitmapPrimitive2D(static_cast< const primitive2d::BitmapPrimitive2D& >(rCandidate));
break;
}
- case PRIMITIVE2D_ID_POLYPOLYGONBITMAPPRIMITIVE2D :
+ case PRIMITIVE2D_ID_POLYPOLYGONGRAPHICPRIMITIVE2D :
{
- // need to handle PolyPolygonBitmapPrimitive2D here to support XPATHFILL_SEQ_BEGIN/XPATHFILL_SEQ_END
- const primitive2d::PolyPolygonBitmapPrimitive2D& rBitmapCandidate = static_cast< const primitive2d::PolyPolygonBitmapPrimitive2D& >(rCandidate);
+ // need to handle PolyPolygonGraphicPrimitive2D here to support XPATHFILL_SEQ_BEGIN/XPATHFILL_SEQ_END
+ const primitive2d::PolyPolygonGraphicPrimitive2D& rBitmapCandidate = static_cast< const primitive2d::PolyPolygonGraphicPrimitive2D& >(rCandidate);
basegfx::B2DPolyPolygon aLocalPolyPolygon(rBitmapCandidate.getB2DPolyPolygon());
if(fillPolyPolygonNeededToBeSplit(aLocalPolyPolygon))
{
// #i112245# Metafiles use tools Polygon and are not able to have more than 65535 points
// per polygon. If there are more use the splitted polygon and call recursively
- const primitive2d::PolyPolygonBitmapPrimitive2D aSplitted(
+ const primitive2d::PolyPolygonGraphicPrimitive2D aSplitted(
aLocalPolyPolygon,
- rBitmapCandidate.getFillBitmap());
+ rBitmapCandidate.getFillGraphic());
processBasePrimitive2D(aSplitted);
}
@@ -1322,62 +1322,57 @@ namespace drawinglayer
if(!mnSvtGraphicFillCount && aLocalPolyPolygon.count())
{
- aLocalPolyPolygon.transform(maCurrentTransformation);
- // calculate transformation. Get real object size, all values in FillBitmapAttribute
+ // #121194# Changed implementation and checked usages fo convert to metafile,
+ // presentation start (uses SvtGraphicFill) and printing.
+
+ // calculate transformation. Get real object size, all values in FillGraphicAttribute
// are relative to the unified object
- const attribute::FillBitmapAttribute& rFillBitmapAttribute = rBitmapCandidate .getFillBitmap();
- const basegfx::B2DRange aOutlineRange(basegfx::tools::getRange(aLocalPolyPolygon));
- const basegfx::B2DVector aOutlineSize(aOutlineRange.getRange());
-
- // get absolute values
- const basegfx::B2DVector aFillBitmapSize(rFillBitmapAttribute.getSize() * aOutlineSize);
- const basegfx::B2DPoint aFillBitmapTopLeft(rFillBitmapAttribute.getTopLeft() * aOutlineSize);
+ aLocalPolyPolygon.transform(maCurrentTransformation);
+ const basegfx::B2DVector aOutlineSize(aLocalPolyPolygon.getB2DRange().getRange());
// the scaling needs scale from pixel to logic coordinate system
- const BitmapEx& rBitmapEx = rFillBitmapAttribute.getBitmapEx();
- Size aBmpSizePixel(rBitmapEx.GetSizePixel());
+ const attribute::FillGraphicAttribute& rFillGraphicAttribute = rBitmapCandidate.getFillGraphic();
+ const Size aBmpSizePixel(rFillGraphicAttribute.getGraphic().GetSizePixel());
- if(!aBmpSizePixel.Width())
- {
- aBmpSizePixel.Width() = 1;
- }
-
- if(!aBmpSizePixel.Height())
- {
- aBmpSizePixel.Height() = 1;
- }
+ // setup transformation like in impgrfll. Multiply with aOutlineSize
+ // to get from unit coordinates in rFillGraphicAttribute.getGraphicRange()
+ // to object coordinates with object's top left being at (0,0). Divide
+ // by pixel size so that scale from pixel to logic will work in SvtGraphicFill.
+ const basegfx::B2DVector aTransformScale(
+ rFillGraphicAttribute.getGraphicRange().getRange() /
+ basegfx::B2DVector(
+ std::max(1.0, double(aBmpSizePixel.Width())),
+ std::max(1.0, double(aBmpSizePixel.Height()))) *
+ aOutlineSize);
+ const basegfx::B2DPoint aTransformPosition(
+ rFillGraphicAttribute.getGraphicRange().getMinimum() * aOutlineSize);
// setup transformation like in impgrfll
SvtGraphicFill::Transform aTransform;
// scale values are divided by bitmap pixel sizes
- aTransform.matrix[0] = aFillBitmapSize.getX() / aBmpSizePixel.Width();
- aTransform.matrix[4] = aFillBitmapSize.getY() / aBmpSizePixel.Height();
+ aTransform.matrix[0] = aTransformScale.getX();
+ aTransform.matrix[4] = aTransformScale.getY();
// translates are absolute
- aTransform.matrix[2] = aFillBitmapTopLeft.getX();
- aTransform.matrix[5] = aFillBitmapTopLeft.getY();
-
- // setup fill graphic like in impgrfll
- Graphic aFillGraphic = Graphic(rBitmapEx);
- aFillGraphic.SetPrefMapMode(MapMode(MAP_PIXEL));
- aFillGraphic.SetPrefSize(aBmpSizePixel);
+ aTransform.matrix[2] = aTransformPosition.getX();
+ aTransform.matrix[5] = aTransformPosition.getY();
- pSvtGraphicFill = new SvtGraphicFill(
+ pSvtGraphicFill = new SvtGraphicFill(
PolyPolygon(aLocalPolyPolygon),
Color(),
0.0,
SvtGraphicFill::fillEvenOdd,
SvtGraphicFill::fillTexture,
aTransform,
- rFillBitmapAttribute.getTiling(),
+ rFillGraphicAttribute.getTiling(),
SvtGraphicFill::hatchSingle,
Color(),
SvtGraphicFill::gradientLinear,
Color(),
Color(),
0,
- aFillGraphic);
+ rFillGraphicAttribute.getGraphic());
}
// Do use decomposition; encapsulate with SvtGraphicFill
@@ -1748,7 +1743,7 @@ namespace drawinglayer
}
// PolyPolygonGradientPrimitive2D, PolyPolygonHatchPrimitive2D and
- // PolyPolygonBitmapPrimitive2D are derived from PolyPolygonColorPrimitive2D.
+ // PolyPolygonGraphicPrimitive2D are derived from PolyPolygonColorPrimitive2D.
// Check also for correct ID to exclude derived implementations
if(pPoPoColor && PRIMITIVE2D_ID_POLYPOLYGONCOLORPRIMITIVE2D == pPoPoColor->getPrimitive2DID())
{
Modified: incubator/ooo/trunk/main/drawinglayer/source/processor2d/vclpixelprocessor2d.cxx
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/drawinglayer/source/processor2d/vclpixelprocessor2d.cxx?rev=1398711&r1=1398710&r2=1398711&view=diff
==============================================================================
--- incubator/ooo/trunk/main/drawinglayer/source/processor2d/vclpixelprocessor2d.cxx (original)
+++ incubator/ooo/trunk/main/drawinglayer/source/processor2d/vclpixelprocessor2d.cxx Tue Oct 16 09:44:02 2012
@@ -31,7 +31,7 @@
#include <drawinglayer/primitive2d/polypolygonprimitive2d.hxx>
#include <drawinglayer/primitive2d/polygonprimitive2d.hxx>
#include <drawinglayer/primitive2d/bitmapprimitive2d.hxx>
-#include <drawinglayer/primitive2d/fillbitmapprimitive2d.hxx>
+#include <drawinglayer/primitive2d/fillgraphicprimitive2d.hxx>
#include <drawinglayer/primitive2d/metafileprimitive2d.hxx>
#include <drawinglayer/primitive2d/maskprimitive2d.hxx>
#include <drawinglayer/primitive2d/modifiedcolorprimitive2d.hxx>
@@ -186,10 +186,10 @@ namespace drawinglayer
RenderBitmapPrimitive2D(static_cast< const primitive2d::BitmapPrimitive2D& >(rCandidate));
break;
}
- case PRIMITIVE2D_ID_FILLBITMAPPRIMITIVE2D :
+ case PRIMITIVE2D_ID_FILLGRAPHICPRIMITIVE2D :
{
// direct draw of fillBitmapPrimitive
- RenderFillBitmapPrimitive2D(static_cast< const primitive2d::FillBitmapPrimitive2D& >(rCandidate));
+ RenderFillGraphicPrimitive2D(static_cast< const primitive2d::FillGraphicPrimitive2D& >(rCandidate));
break;
}
case PRIMITIVE2D_ID_POLYPOLYGONGRADIENTPRIMITIVE2D :
@@ -198,10 +198,10 @@ namespace drawinglayer
RenderPolyPolygonGradientPrimitive2D(static_cast< const primitive2d::PolyPolygonGradientPrimitive2D& >(rCandidate));
break;
}
- case PRIMITIVE2D_ID_POLYPOLYGONBITMAPPRIMITIVE2D :
+ case PRIMITIVE2D_ID_POLYPOLYGONGRAPHICPRIMITIVE2D :
{
// direct draw of bitmap
- RenderPolyPolygonBitmapPrimitive2D(static_cast< const primitive2d::PolyPolygonBitmapPrimitive2D& >(rCandidate));
+ RenderPolyPolygonGraphicPrimitive2D(static_cast< const primitive2d::PolyPolygonGraphicPrimitive2D& >(rCandidate));
break;
}
case PRIMITIVE2D_ID_POLYPOLYGONCOLORPRIMITIVE2D :
Modified: incubator/ooo/trunk/main/drawinglayer/source/processor2d/vclprocessor2d.cxx
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/drawinglayer/source/processor2d/vclprocessor2d.cxx?rev=1398711&r1=1398710&r2=1398711&view=diff
==============================================================================
--- incubator/ooo/trunk/main/drawinglayer/source/processor2d/vclprocessor2d.cxx (original)
+++ incubator/ooo/trunk/main/drawinglayer/source/processor2d/vclprocessor2d.cxx Tue Oct 16 09:44:02 2012
@@ -34,8 +34,8 @@
#include <vclhelperbitmaptransform.hxx>
#include <basegfx/polygon/b2dpolygontools.hxx>
#include <vclhelperbitmaprender.hxx>
-#include <drawinglayer/attribute/sdrfillbitmapattribute.hxx>
-#include <drawinglayer/primitive2d/fillbitmapprimitive2d.hxx>
+#include <drawinglayer/attribute/sdrfillgraphicattribute.hxx>
+#include <drawinglayer/primitive2d/fillgraphicprimitive2d.hxx>
#include <drawinglayer/primitive2d/polypolygonprimitive2d.hxx>
#include <vclhelpergradient.hxx>
#include <drawinglayer/primitive2d/metafileprimitive2d.hxx>
@@ -59,6 +59,7 @@
#include <drawinglayer/primitive2d/svggradientprimitive2d.hxx>
#include <basegfx/color/bcolor.hxx>
#include <basegfx/matrix/b2dhommatrixtools.hxx>
+#include <vcl/graph.hxx>
//////////////////////////////////////////////////////////////////////////////
// control support
@@ -448,127 +449,197 @@ namespace drawinglayer
}
}
- void VclProcessor2D::RenderFillBitmapPrimitive2D(const primitive2d::FillBitmapPrimitive2D& rFillBitmapCandidate)
+ void VclProcessor2D::RenderFillGraphicPrimitive2D(const primitive2d::FillGraphicPrimitive2D& rFillBitmapCandidate)
{
- const attribute::FillBitmapAttribute& rFillBitmapAttribute(rFillBitmapCandidate.getFillBitmap());
+ const attribute::FillGraphicAttribute& rFillGraphicAttribute(rFillBitmapCandidate.getFillGraphic());
bool bPrimitiveAccepted(false);
+ static bool bTryTilingDirect = true;
- if(rFillBitmapAttribute.getTiling())
- {
- // decompose matrix to check for shear, rotate and mirroring
- basegfx::B2DHomMatrix aLocalTransform(maCurrentTransformation * rFillBitmapCandidate.getTransformation());
- basegfx::B2DVector aScale, aTranslate;
- double fRotate, fShearX;
- aLocalTransform.decompose(aScale, aTranslate, fRotate, fShearX);
-
- if(basegfx::fTools::equalZero(fRotate) && basegfx::fTools::equalZero(fShearX))
- {
- // no shear or rotate, draw direct in pixel coordinates
- bPrimitiveAccepted = true;
- BitmapEx aBitmapEx(rFillBitmapAttribute.getBitmapEx());
- bool bPainted(false);
-
- if(maBColorModifierStack.count())
- {
- aBitmapEx = impModifyBitmapEx(maBColorModifierStack, aBitmapEx);
-
- if(aBitmapEx.IsEmpty())
- {
- // color gets completely replaced, get it
- const basegfx::BColor aModifiedColor(maBColorModifierStack.getModifiedColor(basegfx::BColor()));
- basegfx::B2DPolygon aPolygon(basegfx::tools::createUnitPolygon());
- aPolygon.transform(aLocalTransform);
-
- mpOutputDevice->SetFillColor(Color(aModifiedColor));
- mpOutputDevice->SetLineColor();
- mpOutputDevice->DrawPolygon(aPolygon);
-
- bPainted = true;
- }
- }
+ // #121194# when tiling is used and content is bitmap-based, do direct tiling in the
+ // renderer on pixel base to ensure tight fitting. Do not do this when
+ // the fill is rotated or sheared.
+
+ // ovveride static bool (for debug) and tiling is active
+ if(bTryTilingDirect && rFillGraphicAttribute.getTiling())
+ {
+ // content is bitmap(ex)
+ //
+ // for SVG support, force decomposition when SVG is present. This will lead to use
+ // the primitive representation of the svg directly.
+ //
+ // when graphic is animated, force decomposition to use the correct graphic, else
+ // fill style will not be animated
+ if(GRAPHIC_BITMAP == rFillGraphicAttribute.getGraphic().GetType()
+ && !rFillGraphicAttribute.getGraphic().getSvgData().get()
+ && !rFillGraphicAttribute.getGraphic().IsAnimated())
+ {
+ // decompose matrix to check for shear, rotate and mirroring
+ basegfx::B2DHomMatrix aLocalTransform(maCurrentTransformation * rFillBitmapCandidate.getTransformation());
+ basegfx::B2DVector aScale, aTranslate;
+ double fRotate, fShearX;
+ aLocalTransform.decompose(aScale, aTranslate, fRotate, fShearX);
- if(!bPainted)
- {
- const basegfx::B2DPoint aObjTopLeft(aTranslate.getX(), aTranslate.getY());
- const basegfx::B2DPoint aObjBottomRight(aTranslate.getX() + aScale.getX(), aTranslate.getY() + aScale.getY());
- const Point aObjTL(mpOutputDevice->LogicToPixel(Point((sal_Int32)aObjTopLeft.getX(), (sal_Int32)aObjTopLeft.getY())));
- const Point aObjBR(mpOutputDevice->LogicToPixel(Point((sal_Int32)aObjBottomRight.getX(), (sal_Int32)aObjBottomRight.getY())));
-
- const basegfx::B2DPoint aBmpTopLeft(aLocalTransform * rFillBitmapAttribute.getTopLeft());
- const basegfx::B2DPoint aBmpBottomRight(aLocalTransform * basegfx::B2DPoint(rFillBitmapAttribute.getTopLeft() + rFillBitmapAttribute.getSize()));
- const Point aBmpTL(mpOutputDevice->LogicToPixel(Point((sal_Int32)aBmpTopLeft.getX(), (sal_Int32)aBmpTopLeft.getY())));
- const Point aBmpBR(mpOutputDevice->LogicToPixel(Point((sal_Int32)aBmpBottomRight.getX(), (sal_Int32)aBmpBottomRight.getY())));
+ // when nopt rotated/sheared
+ if(basegfx::fTools::equalZero(fRotate) && basegfx::fTools::equalZero(fShearX))
+ {
+ // no shear or rotate, draw direct in pixel coordinates
+ bPrimitiveAccepted = true;
- sal_Int32 nOWidth(aObjBR.X() - aObjTL.X());
- sal_Int32 nOHeight(aObjBR.Y() - aObjTL.Y());
+ // transform object range to device coordinates (pixels). Use
+ // the device transformation for better accuracy
+ basegfx::B2DRange aObjectRange(aTranslate, aTranslate + aScale);
+ aObjectRange.transform(mpOutputDevice->GetViewTransformation());
+
+ // extract discrete size of object
+ const sal_Int32 nOWidth(basegfx::fround(aObjectRange.getWidth()));
+ const sal_Int32 nOHeight(basegfx::fround(aObjectRange.getHeight()));
// only do something when object has a size in discrete units
if(nOWidth > 0 && nOHeight > 0)
{
- sal_Int32 nBWidth(aBmpBR.X() - aBmpTL.X());
- sal_Int32 nBHeight(aBmpBR.Y() - aBmpTL.Y());
+ // transform graphic range to device coordinates (pixels). Use
+ // the device transformation for better accuracy
+ basegfx::B2DRange aGraphicRange(rFillGraphicAttribute.getGraphicRange());
+ aGraphicRange.transform(mpOutputDevice->GetViewTransformation() * aLocalTransform);
+
+ // extract discrete size of graphic
+ const sal_Int32 nBWidth(basegfx::fround(aGraphicRange.getWidth()));
+ const sal_Int32 nBHeight(basegfx::fround(aGraphicRange.getHeight()));
// only do something when bitmap fill has a size in discrete units
if(nBWidth > 0 && nBHeight > 0)
{
- sal_Int32 nBLeft(aBmpTL.X());
- sal_Int32 nBTop(aBmpTL.Y());
-
- if(nBLeft > aObjTL.X())
- {
- nBLeft -= ((nBLeft / nBWidth) + 1L) * nBWidth;
- }
-
- if(nBLeft + nBWidth <= aObjTL.X())
- {
- nBLeft -= (nBLeft / nBWidth) * nBWidth;
- }
-
- if(nBTop > aObjTL.Y())
- {
- nBTop -= ((nBTop / nBHeight) + 1L) * nBHeight;
- }
-
- if(nBTop + nBHeight <= aObjTL.Y())
- {
- nBTop -= (nBTop / nBHeight) * nBHeight;
- }
-
// nBWidth, nBHeight is the pixel size of the neede bitmap. To not need to scale it
// in vcl many times, create a size-optimized version
const Size aNeededBitmapSizePixel(nBWidth, nBHeight);
-
- if(aNeededBitmapSizePixel != aBitmapEx.GetSizePixel())
- {
- aBitmapEx.Scale(aNeededBitmapSizePixel);
- }
-
- // prepare OutDev
- const Point aEmptyPoint(0, 0);
- const Rectangle aVisiblePixel(aEmptyPoint, mpOutputDevice->GetOutputSizePixel());
- const bool bWasEnabled(mpOutputDevice->IsMapModeEnabled());
- mpOutputDevice->EnableMapMode(false);
-
- for(sal_Int32 nXPos(nBLeft); nXPos < aObjTL.X() + nOWidth; nXPos += nBWidth)
- {
- for(sal_Int32 nYPos(nBTop); nYPos < aObjTL.Y() + nOHeight; nYPos += nBHeight)
- {
- const Rectangle aOutRectPixel(Point(nXPos, nYPos), aNeededBitmapSizePixel);
-
- if(aOutRectPixel.IsOver(aVisiblePixel))
- {
- mpOutputDevice->DrawBitmapEx(aOutRectPixel.TopLeft(), aBitmapEx);
- }
- }
- }
-
- // restore OutDev
- mpOutputDevice->EnableMapMode(bWasEnabled);
+ BitmapEx aBitmapEx(rFillGraphicAttribute.getGraphic().GetBitmapEx(
+ GraphicConversionParameters(
+ aNeededBitmapSizePixel, // get the correct size immediately
+ false, // no unlimited size
+ false, // Use AntiAliasing
+ false, //SnapHorVerLines
+ true // ScaleHighQuality
+ )));
+ bool bPainted(false);
+
+ if(maBColorModifierStack.count())
+ {
+ // when color modifier, apply to bitmap
+ aBitmapEx = impModifyBitmapEx(maBColorModifierStack, aBitmapEx);
+
+ // impModifyBitmapEx uses empty bitmap as sign to return that
+ // the content will be completely replaced to mono color, use shortcut
+ if(aBitmapEx.IsEmpty())
+ {
+ // color gets completely replaced, get it
+ const basegfx::BColor aModifiedColor(maBColorModifierStack.getModifiedColor(basegfx::BColor()));
+ basegfx::B2DPolygon aPolygon(basegfx::tools::createUnitPolygon());
+ aPolygon.transform(aLocalTransform);
+
+ mpOutputDevice->SetFillColor(Color(aModifiedColor));
+ mpOutputDevice->SetLineColor();
+ mpOutputDevice->DrawPolygon(aPolygon);
+
+ bPainted = true;
+ }
+ }
+
+ if(!bPainted)
+ {
+ sal_Int32 nBLeft(basegfx::fround(aGraphicRange.getMinX()));
+ sal_Int32 nBTop(basegfx::fround(aGraphicRange.getMinY()));
+ const sal_Int32 nOLeft(basegfx::fround(aObjectRange.getMinX()));
+ const sal_Int32 nOTop(basegfx::fround(aObjectRange.getMinY()));
+ sal_Int32 nPosX(0);
+ sal_Int32 nPosY(0);
+
+ if(nBLeft > nOLeft)
+ {
+ const sal_Int32 nDiff((nBLeft / nBWidth) + 1);
+
+ nPosX -= nDiff;
+ nBLeft -= nDiff * nBWidth;
+ }
+
+ if(nBLeft + nBWidth <= nOLeft)
+ {
+ const sal_Int32 nDiff(-nBLeft / nBWidth);
+
+ nPosX += nDiff;
+ nBLeft += nDiff * nBWidth;
+ }
+
+ if(nBTop > nOTop)
+ {
+ const sal_Int32 nDiff((nBTop / nBHeight) + 1);
+
+ nPosY -= nDiff;
+ nBTop -= nDiff * nBHeight;
+ }
+
+ if(nBTop + nBHeight <= nOTop)
+ {
+ const sal_Int32 nDiff(-nBTop / nBHeight);
+
+ nPosY += nDiff;
+ nBTop += nDiff * nBHeight;
+ }
+
+ // prepare OutDev
+ const Point aEmptyPoint(0, 0);
+ const Rectangle aVisiblePixel(aEmptyPoint, mpOutputDevice->GetOutputSizePixel());
+ const bool bWasEnabled(mpOutputDevice->IsMapModeEnabled());
+ mpOutputDevice->EnableMapMode(false);
+
+ // check if offset is used
+ const sal_Int32 nOffsetX(basegfx::fround(rFillGraphicAttribute.getOffsetX() * nBWidth));
+
+ if(nOffsetX)
+ {
+ // offset in X, so iterate over Y first and draw lines
+ for(sal_Int32 nYPos(nBTop); nYPos < nOTop + nOHeight; nYPos += nBHeight, nPosY++)
+ {
+ for(sal_Int32 nXPos(nPosY % 2 ? nBLeft - nBWidth + nOffsetX : nBLeft);
+ nXPos < nOLeft + nOWidth; nXPos += nBWidth)
+ {
+ const Rectangle aOutRectPixel(Point(nXPos, nYPos), aNeededBitmapSizePixel);
+
+ if(aOutRectPixel.IsOver(aVisiblePixel))
+ {
+ mpOutputDevice->DrawBitmapEx(aOutRectPixel.TopLeft(), aBitmapEx);
+ }
+ }
+ }
+ }
+ else
+ {
+ // check if offset is used
+ const sal_Int32 nOffsetY(basegfx::fround(rFillGraphicAttribute.getOffsetY() * nBHeight));
+
+ // possible offset in Y, so iterate over X first and draw columns
+ for(sal_Int32 nXPos(nBLeft); nXPos < nOLeft + nOWidth; nXPos += nBWidth, nPosX++)
+ {
+ for(sal_Int32 nYPos(nPosX % 2 ? nBTop - nBHeight + nOffsetY : nBTop);
+ nYPos < nOTop + nOHeight; nYPos += nBHeight)
+ {
+ const Rectangle aOutRectPixel(Point(nXPos, nYPos), aNeededBitmapSizePixel);
+
+ if(aOutRectPixel.IsOver(aVisiblePixel))
+ {
+ mpOutputDevice->DrawBitmapEx(aOutRectPixel.TopLeft(), aBitmapEx);
+ }
+ }
+ }
+ }
+
+ // restore OutDev
+ mpOutputDevice->EnableMapMode(bWasEnabled);
+ }
}
}
- }
- }
- }
+ }
+ }
+ }
if(!bPrimitiveAccepted)
{
@@ -615,97 +686,112 @@ namespace drawinglayer
}
}
- // direct draw of bitmap
- void VclProcessor2D::RenderPolyPolygonBitmapPrimitive2D(const primitive2d::PolyPolygonBitmapPrimitive2D& rPolygonCandidate)
+ // direct draw of Graphic
+ void VclProcessor2D::RenderPolyPolygonGraphicPrimitive2D(const primitive2d::PolyPolygonGraphicPrimitive2D& rPolygonCandidate)
{
- bool bDone(false);
- const basegfx::B2DPolyPolygon& rPolyPolygon = rPolygonCandidate.getB2DPolyPolygon();
-
- if(rPolyPolygon.count())
- {
- const attribute::FillBitmapAttribute& rFillBitmapAttribute = rPolygonCandidate.getFillBitmap();
- const BitmapEx& rBitmapEx = rFillBitmapAttribute.getBitmapEx();
+ bool bDone(false);
+ const basegfx::B2DPolyPolygon& rPolyPolygon = rPolygonCandidate.getB2DPolyPolygon();
- if(rBitmapEx.IsEmpty())
- {
- // empty bitmap, done
- bDone = true;
- }
- else
- {
- // try to catch cases where the bitmap will be color-modified to a single
- // color (e.g. shadow). This would NOT be optimizable with an transparence channel
- // at the Bitmap which we do not have here. When this should change, this
- // optimization has to be reworked accordingly.
- const sal_uInt32 nBColorModifierStackCount(maBColorModifierStack.count());
+ // #121194# Todo: check if this works
+ if(!rPolyPolygon.count())
+ {
+ // empty polyPolygon, done
+ bDone = true;
+ }
+ else
+ {
+ const attribute::FillGraphicAttribute& rFillGraphicAttribute = rPolygonCandidate.getFillGraphic();
- if(nBColorModifierStackCount)
- {
- const basegfx::BColorModifier& rTopmostModifier = maBColorModifierStack.getBColorModifier(nBColorModifierStackCount - 1);
+ // try to catch cases where the graphic will be color-modified to a single
+ // color (e.g. shadow)
+ switch(rFillGraphicAttribute.getGraphic().GetType())
+ {
+ case GRAPHIC_GDIMETAFILE:
+ {
+ // metafiles are potentially transparent, cannot optimize´, not done
+ break;
+ }
+ case GRAPHIC_BITMAP:
+ {
+ if(!rFillGraphicAttribute.getGraphic().IsTransparent() && !rFillGraphicAttribute.getGraphic().IsAlpha())
+ {
+ // bitmap is not transparent and has no alpha
+ const sal_uInt32 nBColorModifierStackCount(maBColorModifierStack.count());
- if(basegfx::BCOLORMODIFYMODE_REPLACE == rTopmostModifier.getMode())
- {
- // the bitmap fill is in unified color, so we can replace it with
- // a single polygon fill. The form of the fill depends on tiling
- if(rFillBitmapAttribute.getTiling())
- {
- // with tiling, fill the whole PolyPolygon with the modifier color
- basegfx::B2DPolyPolygon aLocalPolyPolygon(rPolyPolygon);
-
- aLocalPolyPolygon.transform(maCurrentTransformation);
- mpOutputDevice->SetLineColor();
- mpOutputDevice->SetFillColor(Color(rTopmostModifier.getBColor()));
- mpOutputDevice->DrawPolyPolygon(aLocalPolyPolygon);
- }
- else
- {
- // without tiling, only the area common to the bitmap tile and the
- // PolyPolygon is filled. Create the bitmap tile area in object
- // coordinates. For this, the object transformation needs to be created
- // from the already scaled PolyPolygon. The tile area in object
- // coordinates wil always be non-rotated, so it's not necessary to
- // work with a polygon here
- basegfx::B2DRange aTileRange(rFillBitmapAttribute.getTopLeft(),
- rFillBitmapAttribute.getTopLeft() + rFillBitmapAttribute.getSize());
- const basegfx::B2DRange aPolyPolygonRange(rPolyPolygon.getB2DRange());
- basegfx::B2DHomMatrix aNewObjectTransform;
-
- aNewObjectTransform.set(0, 0, aPolyPolygonRange.getWidth());
- aNewObjectTransform.set(1, 1, aPolyPolygonRange.getHeight());
- aNewObjectTransform.set(0, 2, aPolyPolygonRange.getMinX());
- aNewObjectTransform.set(1, 2, aPolyPolygonRange.getMinY());
- aTileRange.transform(aNewObjectTransform);
-
- // now clip the object polyPolygon against the tile range
- // to get the common area (OR)
- basegfx::B2DPolyPolygon aTarget = basegfx::tools::clipPolyPolygonOnRange(rPolyPolygon, aTileRange, true, false);
-
- if(aTarget.count())
- {
- aTarget.transform(maCurrentTransformation);
- mpOutputDevice->SetLineColor();
- mpOutputDevice->SetFillColor(Color(rTopmostModifier.getBColor()));
- mpOutputDevice->DrawPolyPolygon(aTarget);
- }
- }
+ if(nBColorModifierStackCount)
+ {
+ const basegfx::BColorModifier& rTopmostModifier = maBColorModifierStack.getBColorModifier(nBColorModifierStackCount - 1);
- bDone = true;
- }
- }
- }
- }
- else
- {
- // empty polyPolygon, done
- bDone = true;
- }
+ if(basegfx::BCOLORMODIFYMODE_REPLACE == rTopmostModifier.getMode())
+ {
+ // the bitmap fill is in unified color, so we can replace it with
+ // a single polygon fill. The form of the fill depends on tiling
+ if(rFillGraphicAttribute.getTiling())
+ {
+ // with tiling, fill the whole PolyPolygon with the modifier color
+ basegfx::B2DPolyPolygon aLocalPolyPolygon(rPolyPolygon);
+
+ aLocalPolyPolygon.transform(maCurrentTransformation);
+ mpOutputDevice->SetLineColor();
+ mpOutputDevice->SetFillColor(Color(rTopmostModifier.getBColor()));
+ mpOutputDevice->DrawPolyPolygon(aLocalPolyPolygon);
+ }
+ else
+ {
+ // without tiling, only the area common to the bitmap tile and the
+ // PolyPolygon is filled. Create the bitmap tile area in object
+ // coordinates. For this, the object transformation needs to be created
+ // from the already scaled PolyPolygon. The tile area in object
+ // coordinates wil always be non-rotated, so it's not necessary to
+ // work with a polygon here
+ basegfx::B2DRange aTileRange(rFillGraphicAttribute.getGraphicRange());
+ const basegfx::B2DRange aPolyPolygonRange(rPolyPolygon.getB2DRange());
+ const basegfx::B2DHomMatrix aNewObjectTransform(
+ basegfx::tools::createScaleTranslateB2DHomMatrix(
+ aPolyPolygonRange.getRange(),
+ aPolyPolygonRange.getMinimum()));
+
+ aTileRange.transform(aNewObjectTransform);
+
+ // now clip the object polyPolygon against the tile range
+ // to get the common area
+ basegfx::B2DPolyPolygon aTarget = basegfx::tools::clipPolyPolygonOnRange(
+ rPolyPolygon,
+ aTileRange,
+ true,
+ false);
+
+ if(aTarget.count())
+ {
+ aTarget.transform(maCurrentTransformation);
+ mpOutputDevice->SetLineColor();
+ mpOutputDevice->SetFillColor(Color(rTopmostModifier.getBColor()));
+ mpOutputDevice->DrawPolyPolygon(aTarget);
+ }
+ }
+
+ // simplified output executed, we are done
+ bDone = true;
+ }
+ }
+ }
+ break;
+ }
+ default: //GRAPHIC_NONE, GRAPHIC_DEFAULT
+ {
+ // empty graphic, we are done
+ bDone = true;
+ break;
+ }
+ }
+ }
- if(!bDone)
- {
- // use default decomposition
- process(rPolygonCandidate.get2DDecomposition(getViewInformation2D()));
- }
- }
+ if(!bDone)
+ {
+ // use default decomposition
+ process(rPolygonCandidate.get2DDecomposition(getViewInformation2D()));
+ }
+ }
// direct draw of PolyPolygon with color
void VclProcessor2D::RenderPolyPolygonColorPrimitive2D(const primitive2d::PolyPolygonColorPrimitive2D& rPolygonCandidate)
Modified: incubator/ooo/trunk/main/drawinglayer/source/processor3d/defaultprocessor3d.cxx
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/drawinglayer/source/processor3d/defaultprocessor3d.cxx?rev=1398711&r1=1398710&r2=1398711&view=diff
==============================================================================
--- incubator/ooo/trunk/main/drawinglayer/source/processor3d/defaultprocessor3d.cxx (original)
+++ incubator/ooo/trunk/main/drawinglayer/source/processor3d/defaultprocessor3d.cxx Tue Oct 16 09:44:02 2012
@@ -41,6 +41,8 @@
#include <vcl/bitmapex.hxx>
#include <drawinglayer/attribute/sdrsceneattribute3d.hxx>
#include <drawinglayer/attribute/sdrlightingattribute3d.hxx>
+#include <vcl/graph.hxx>
+#include <basegfx/matrix/b2dhommatrixtools.hxx>
//////////////////////////////////////////////////////////////////////////////
@@ -217,21 +219,33 @@ namespace drawinglayer
boost::shared_ptr< texture::GeoTexSvx > pOldTex = mpGeoTexSvx;
// create texture
- const attribute::FillBitmapAttribute& rFillBitmapAttribute = rPrimitive.getFillBitmapAttribute();
-
- if(rFillBitmapAttribute.getTiling())
- {
- mpGeoTexSvx.reset(new texture::GeoTexSvxBitmapTiled(
- rFillBitmapAttribute.getBitmapEx().GetBitmap(),
- rFillBitmapAttribute.getTopLeft() * rPrimitive.getTextureSize(),
- rFillBitmapAttribute.getSize() * rPrimitive.getTextureSize()));
+ const attribute::FillGraphicAttribute& rFillGraphicAttribute = rPrimitive.getFillGraphicAttribute();
+
+ // #121194# For 3D texture we will use the BitmapRex representation
+ const BitmapEx aBitmapEx(rFillGraphicAttribute.getGraphic().GetBitmapEx());
+
+ // create range scaled by texture size
+ basegfx::B2DRange aGraphicRange(rFillGraphicAttribute.getGraphicRange());
+
+ aGraphicRange.transform(
+ basegfx::tools::createScaleB2DHomMatrix(
+ rPrimitive.getTextureSize()));
+
+ if(rFillGraphicAttribute.getTiling())
+ {
+ mpGeoTexSvx.reset(
+ new texture::GeoTexSvxBitmapExTiled(
+ aBitmapEx,
+ aGraphicRange,
+ rFillGraphicAttribute.getOffsetX(),
+ rFillGraphicAttribute.getOffsetY()));
}
else
{
- mpGeoTexSvx.reset(new texture::GeoTexSvxBitmap(
- rFillBitmapAttribute.getBitmapEx().GetBitmap(),
- rFillBitmapAttribute.getTopLeft() * rPrimitive.getTextureSize(),
- rFillBitmapAttribute.getSize() * rPrimitive.getTextureSize()));
+ mpGeoTexSvx.reset(
+ new texture::GeoTexSvxBitmapEx(
+ aBitmapEx,
+ aGraphicRange));
}
// process sub-list
Modified: incubator/ooo/trunk/main/drawinglayer/source/texture/texture.cxx
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/drawinglayer/source/texture/texture.cxx?rev=1398711&r1=1398710&r2=1398711&view=diff
==============================================================================
--- incubator/ooo/trunk/main/drawinglayer/source/texture/texture.cxx (original)
+++ incubator/ooo/trunk/main/drawinglayer/source/texture/texture.cxx Tue Oct 16 09:44:02 2012
@@ -610,20 +610,17 @@ namespace drawinglayer
namespace texture
{
GeoTexSvxTiled::GeoTexSvxTiled(
- const basegfx::B2DPoint& rTopLeft,
- const basegfx::B2DVector& rSize)
- : maTopLeft(rTopLeft),
- maSize(rSize)
+ const basegfx::B2DRange& rRange,
+ double fOffsetX,
+ double fOffsetY)
+ : maRange(rRange),
+ mfOffsetX(basegfx::clamp(fOffsetX, 0.0, 1.0)),
+ mfOffsetY(basegfx::clamp(fOffsetY, 0.0, 1.0))
{
- if(basegfx::fTools::lessOrEqual(maSize.getX(), 0.0))
- {
- maSize.setX(1.0);
- }
-
- if(basegfx::fTools::lessOrEqual(maSize.getY(), 0.0))
- {
- maSize.setY(1.0);
- }
+ if(!basegfx::fTools::equalZero(mfOffsetX))
+ {
+ mfOffsetY = 0.0;
+ }
}
GeoTexSvxTiled::~GeoTexSvxTiled()
@@ -633,50 +630,94 @@ namespace drawinglayer
bool GeoTexSvxTiled::operator==(const GeoTexSvx& rGeoTexSvx) const
{
const GeoTexSvxTiled* pCompare = dynamic_cast< const GeoTexSvxTiled* >(&rGeoTexSvx);
- return (pCompare
- && maTopLeft == pCompare->maTopLeft
- && maSize == pCompare->maSize);
+
+ return (pCompare
+ && maRange == pCompare->maRange
+ && mfOffsetX == pCompare->mfOffsetX
+ && mfOffsetY == pCompare->mfOffsetY);
}
void GeoTexSvxTiled::appendTransformations(::std::vector< basegfx::B2DHomMatrix >& rMatrices)
{
- double fStartX(maTopLeft.getX());
- double fStartY(maTopLeft.getY());
+ const double fWidth(maRange.getWidth());
- if(basegfx::fTools::more(fStartX, 0.0))
- {
- fStartX -= (floor(fStartX / maSize.getX()) + 1.0) * maSize.getX();
- }
-
- if(basegfx::fTools::less(fStartX + maSize.getX(), 0.0))
- {
- fStartX += floor(-fStartX / maSize.getX()) * maSize.getX();
- }
-
- if(basegfx::fTools::more(fStartY, 0.0))
- {
- fStartY -= (floor(fStartY / maSize.getY()) + 1.0) * maSize.getY();
- }
-
- if(basegfx::fTools::less(fStartY + maSize.getY(), 0.0))
- {
- fStartY += floor(-fStartY / maSize.getY()) * maSize.getY();
- }
-
- for(double fPosY(fStartY); basegfx::fTools::less(fPosY, 1.0); fPosY += maSize.getY())
- {
- for(double fPosX(fStartX); basegfx::fTools::less(fPosX, 1.0); fPosX += maSize.getX())
- {
- basegfx::B2DHomMatrix aNew;
-
- aNew.set(0, 0, maSize.getX());
- aNew.set(1, 1, maSize.getY());
- aNew.set(0, 2, fPosX);
- aNew.set(1, 2, fPosY);
-
- rMatrices.push_back(aNew);
- }
- }
+ if(!basegfx::fTools::equalZero(fWidth))
+ {
+ const double fHeight(maRange.getHeight());
+
+ if(!basegfx::fTools::equalZero(fHeight))
+ {
+ double fStartX(maRange.getMinX());
+ double fStartY(maRange.getMinY());
+ sal_Int32 nPosX(0);
+ sal_Int32 nPosY(0);
+
+ if(basegfx::fTools::more(fStartX, 0.0))
+ {
+ const sal_Int32 nDiff(static_cast<sal_Int32>(floor(fStartX / fWidth)) + 1);
+
+ nPosX -= nDiff;
+ fStartX -= nDiff * fWidth;
+ }
+
+ if(basegfx::fTools::less(fStartX + fWidth, 0.0))
+ {
+ const sal_Int32 nDiff(static_cast<sal_Int32>(floor(-fStartX / fWidth)));
+
+ nPosX += nDiff;
+ fStartX += nDiff * fWidth;
+ }
+
+ if(basegfx::fTools::more(fStartY, 0.0))
+ {
+ const sal_Int32 nDiff(static_cast<sal_Int32>(floor(fStartY / fHeight)) + 1);
+
+ nPosY -= nDiff;
+ fStartY -= nDiff * fHeight;
+ }
+
+ if(basegfx::fTools::less(fStartY + fHeight, 0.0))
+ {
+ const sal_Int32 nDiff(static_cast<sal_Int32>(floor(-fStartY / fHeight)));
+
+ nPosY += nDiff;
+ fStartY += nDiff * fHeight;
+ }
+
+ if(!basegfx::fTools::equalZero(mfOffsetY))
+ {
+ for(double fPosX(fStartX); basegfx::fTools::less(fPosX, 1.0); fPosX += fWidth, nPosX++)
+ {
+ for(double fPosY(nPosX % 2 ? fStartY - fHeight + (mfOffsetY * fHeight) : fStartY);
+ basegfx::fTools::less(fPosY, 1.0); fPosY += fHeight)
+ {
+ rMatrices.push_back(
+ basegfx::tools::createScaleTranslateB2DHomMatrix(
+ fWidth,
+ fHeight,
+ fPosX,
+ fPosY));
+ }
+ }
+ }
+ else
+ {
+ for(double fPosY(fStartY); basegfx::fTools::less(fPosY, 1.0); fPosY += fHeight, nPosY++)
+ {
+ for(double fPosX(nPosY % 2 ? fStartX - fWidth + (mfOffsetX * fWidth) : fStartX);
+ basegfx::fTools::less(fPosX, 1.0); fPosX += fWidth)
+ {
+ rMatrices.push_back(
+ basegfx::tools::createScaleTranslateB2DHomMatrix(
+ fWidth,
+ fHeight,
+ fPosX,
+ fPosY));
+ }
+ }
+ }
+ }
+ }
}
} // end of namespace texture
} // end of namespace drawinglayer
Modified: incubator/ooo/trunk/main/drawinglayer/source/texture/texture3d.cxx
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/drawinglayer/source/texture/texture3d.cxx?rev=1398711&r1=1398710&r2=1398711&view=diff
==============================================================================
--- incubator/ooo/trunk/main/drawinglayer/source/texture/texture3d.cxx (original)
+++ incubator/ooo/trunk/main/drawinglayer/source/texture/texture3d.cxx Tue Oct 16 09:44:02 2012
@@ -34,7 +34,9 @@ namespace drawinglayer
{
namespace texture
{
- GeoTexSvxMono::GeoTexSvxMono(const basegfx::BColor& rSingleColor, double fOpacity)
+ GeoTexSvxMono::GeoTexSvxMono(
+ const basegfx::BColor& rSingleColor,
+ double fOpacity)
: maSingleColor(rSingleColor),
mfOpacity(fOpacity)
{
@@ -43,7 +45,8 @@ namespace drawinglayer
bool GeoTexSvxMono::operator==(const GeoTexSvx& rGeoTexSvx) const
{
const GeoTexSvxMono* pCompare = dynamic_cast< const GeoTexSvxMono* >(&rGeoTexSvx);
- return (pCompare
+
+ return (pCompare
&& maSingleColor == pCompare->maSingleColor
&& mfOpacity == pCompare->mfOpacity);
}
@@ -66,56 +69,144 @@ namespace drawinglayer
{
namespace texture
{
- GeoTexSvxBitmap::GeoTexSvxBitmap(const Bitmap& rBitmap, const basegfx::B2DPoint& rTopLeft, const basegfx::B2DVector& rSize)
- : maBitmap(rBitmap),
- mpRead(0L),
- maTopLeft(rTopLeft),
- maSize(rSize),
+ GeoTexSvxBitmapEx::GeoTexSvxBitmapEx(
+ const BitmapEx& rBitmapEx,
+ const basegfx::B2DRange& rRange)
+ : maBitmapEx(rBitmapEx),
+ mpReadBitmap(0),
+ maTransparence(),
+ mpReadTransparence(0),
+ maTopLeft(rRange.getMinimum()),
+ maSize(rRange.getRange()),
mfMulX(0.0),
- mfMulY(0.0)
- {
- mpRead = maBitmap.AcquireReadAccess();
- OSL_ENSURE(mpRead, "GeoTexSvxBitmap: Got no read access to Bitmap (!)");
- mfMulX = (double)mpRead->Width() / maSize.getX();
- mfMulY = (double)mpRead->Height() / maSize.getY();
- }
+ mfMulY(0.0),
+ mbIsAlpha(false),
+ mbIsTransparent(maBitmapEx.IsTransparent())
+ {
+ // #121194# Todo: use alpha channel, too (for 3d)
+ mpReadBitmap = maBitmapEx.GetBitmap().AcquireReadAccess();
+ OSL_ENSURE(mpReadBitmap, "GeoTexSvxBitmapEx: Got no read access to Bitmap (!)");
+
+ if(mbIsTransparent)
+ {
+ if(maBitmapEx.IsAlpha())
+ {
+ mbIsAlpha = true;
+ maTransparence = rBitmapEx.GetAlpha().GetBitmap();
+ }
+ else
+ {
+ maTransparence = rBitmapEx.GetMask();
+ }
+
+ mpReadTransparence = maTransparence.AcquireReadAccess();
+ }
+
+ mfMulX = (double)mpReadBitmap->Width() / maSize.getX();
+ mfMulY = (double)mpReadBitmap->Height() / maSize.getY();
+
+ if(maSize.getX() <= 1.0)
+ {
+ maSize.setX(1.0);
+ }
+
+ if(maSize.getY() <= 1.0)
+ {
+ maSize.setY(1.0);
+ }
+ }
+
+ GeoTexSvxBitmapEx::~GeoTexSvxBitmapEx()
+ {
+ delete mpReadTransparence;
+ delete mpReadBitmap;
+ }
+
+ sal_uInt8 GeoTexSvxBitmapEx::impGetTransparence(sal_Int32& rX, sal_Int32& rY) const
+ {
+ switch(maBitmapEx.GetTransparentType())
+ {
+ case TRANSPARENT_NONE:
+ {
+ break;
+ }
+ case TRANSPARENT_COLOR:
+ {
+ const Color aColor(mpReadBitmap->GetColor(rY, rX));
+
+ if(maBitmapEx.GetTransparentColor() == aColor)
+ {
+ return 255;
+ }
+
+ break;
+ }
+ case TRANSPARENT_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;
+ }
+ }
- GeoTexSvxBitmap::~GeoTexSvxBitmap()
- {
- delete mpRead;
- }
+ return 0;
+ }
- bool GeoTexSvxBitmap::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(mpRead)
+ if(mpReadBitmap)
{
rX = (sal_Int32)((rUV.getX() - maTopLeft.getX()) * mfMulX);
- if(rX >= 0L && rX < mpRead->Width())
+ if(rX >= 0L && rX < mpReadBitmap->Width())
{
rY = (sal_Int32)((rUV.getY() - maTopLeft.getY()) * mfMulY);
- return (rY >= 0L && rY < mpRead->Height());
+ return (rY >= 0L && rY < mpReadBitmap->Height());
}
}
return false;
}
- void GeoTexSvxBitmap::modifyBColor(const basegfx::B2DPoint& rUV, basegfx::BColor& rBColor, double& rfOpacity) const
+ void GeoTexSvxBitmapEx::modifyBColor(const basegfx::B2DPoint& rUV, basegfx::BColor& rBColor, double& rfOpacity) const
{
sal_Int32 nX, nY;
if(impIsValid(rUV, nX, nY))
{
const double fConvertColor(1.0 / 255.0);
- const BitmapColor aBMCol(mpRead->GetColor(nY, nX));
+ const BitmapColor aBMCol(mpReadBitmap->GetColor(nY, nX));
const basegfx::BColor aBSource(
(double)aBMCol.GetRed() * fConvertColor,
(double)aBMCol.GetGreen() * fConvertColor,
(double)aBMCol.GetBlue() * fConvertColor);
rBColor = aBSource;
+
+ if(mbIsTransparent)
+ {
+ // when we have a transparence, make use of it
+ const sal_uInt8 aLuminance(impGetTransparence(nX, nY));
+
+ rfOpacity = ((double)(0xff - aLuminance) * (1.0 / 255.0));
+ }
+ else
+ {
+ rfOpacity = 1.0;
+ }
}
else
{
@@ -123,16 +214,28 @@ namespace drawinglayer
}
}
- void GeoTexSvxBitmap::modifyOpacity(const basegfx::B2DPoint& rUV, double& rfOpacity) const
+ void GeoTexSvxBitmapEx::modifyOpacity(const basegfx::B2DPoint& rUV, double& rfOpacity) const
{
sal_Int32 nX, nY;
if(impIsValid(rUV, nX, nY))
{
- const BitmapColor aBMCol(mpRead->GetColor(nY, nX));
- const Color aColor(aBMCol.GetRed(), aBMCol.GetGreen(), aBMCol.GetBlue());
+ if(mbIsTransparent)
+ {
+ // this texture has an alpha part, use it
+ const sal_uInt8 aLuminance(impGetTransparence(nX, nY));
+ const double fNewOpacity((double)(0xff - aLuminance) * (1.0 / 255.0));
+
+ rfOpacity = 1.0 - ((1.0 - fNewOpacity) * (1.0 - rfOpacity));
+ }
+ else
+ {
+ // this texture is a color bitmap used as transparence map
+ const BitmapColor aBMCol(mpReadBitmap->GetColor(nY, nX));
+ const Color aColor(aBMCol.GetRed(), aBMCol.GetGreen(), aBMCol.GetBlue());
- rfOpacity = ((double)(0xff - aColor.GetLuminance()) * (1.0 / 255.0));
+ rfOpacity = ((double)(0xff - aColor.GetLuminance()) * (1.0 / 255.0));
+ }
}
else
{
@@ -148,24 +251,72 @@ namespace drawinglayer
{
namespace texture
{
- GeoTexSvxBitmapTiled::GeoTexSvxBitmapTiled(const Bitmap& rBitmap, const basegfx::B2DPoint& rTopLeft, const basegfx::B2DVector& rSize)
- : GeoTexSvxBitmap(rBitmap, rTopLeft, rSize)
+ basegfx::B2DPoint GeoTexSvxBitmapExTiled::impGetCorrected(const basegfx::B2DPoint& rUV) const
+ {
+ double fX(rUV.getX() - maTopLeft.getX());
+ double fY(rUV.getY() - maTopLeft.getY());
+
+ if(mbUseOffsetX)
+ {
+ const sal_Int32 nCol(static_cast< sal_Int32 >((fY < 0.0 ? maSize.getY() -fY : fY) / maSize.getY()));
+
+ if(nCol % 2)
+ {
+ fX += mfOffsetX * maSize.getX();
+ }
+ }
+ else if(mbUseOffsetY)
+ {
+ const sal_Int32 nRow(static_cast< sal_Int32 >((fX < 0.0 ? maSize.getX() -fX : fX) / maSize.getX()));
+
+ if(nRow % 2)
+ {
+ fY += mfOffsetY * maSize.getY();
+ }
+ }
+
+ fX = fmod(fX, maSize.getX());
+ fY = fmod(fY, maSize.getY());
+
+ if(fX < 0.0)
+ {
+ fX += maSize.getX();
+ }
+
+ if(fY < 0.0)
+ {
+ fY += maSize.getY();
+ }
+
+ return basegfx::B2DPoint(fX + maTopLeft.getX(), fY + maTopLeft.getY());
+ }
+
+ GeoTexSvxBitmapExTiled::GeoTexSvxBitmapExTiled(
+ const BitmapEx& rBitmapEx,
+ const basegfx::B2DRange& rRange,
+ double fOffsetX,
+ double fOffsetY)
+ : GeoTexSvxBitmapEx(rBitmapEx, rRange),
+ mfOffsetX(basegfx::clamp(fOffsetX, 0.0, 1.0)),
+ mfOffsetY(basegfx::clamp(fOffsetY, 0.0, 1.0)),
+ mbUseOffsetX(!basegfx::fTools::equalZero(mfOffsetX)),
+ mbUseOffsetY(!mbUseOffsetX && !basegfx::fTools::equalZero(mfOffsetY))
{
}
- void GeoTexSvxBitmapTiled::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(mpRead)
+ if(mpReadBitmap)
{
- GeoTexSvxBitmap::modifyBColor(impGetCorrected(rUV), rBColor, rfOpacity);
+ GeoTexSvxBitmapEx::modifyBColor(impGetCorrected(rUV), rBColor, rfOpacity);
}
}
- void GeoTexSvxBitmapTiled::modifyOpacity(const basegfx::B2DPoint& rUV, double& rfOpacity) const
+ void GeoTexSvxBitmapExTiled::modifyOpacity(const basegfx::B2DPoint& rUV, double& rfOpacity) const
{
- if(mpRead)
+ if(mpReadBitmap)
{
- GeoTexSvxBitmap::modifyOpacity(impGetCorrected(rUV), rfOpacity);
+ GeoTexSvxBitmapEx::modifyOpacity(impGetCorrected(rUV), rfOpacity);
}
}
} // end of namespace texture
@@ -177,7 +328,9 @@ namespace drawinglayer
{
namespace texture
{
- GeoTexSvxMultiHatch::GeoTexSvxMultiHatch(const primitive3d::HatchTexturePrimitive3D& rPrimitive, double fLogicPixelSize)
+ GeoTexSvxMultiHatch::GeoTexSvxMultiHatch(
+ const primitive3d::HatchTexturePrimitive3D& rPrimitive,
+ double fLogicPixelSize)
: mfLogicPixelSize(fLogicPixelSize),
mp0(0L),
mp1(0L),
Modified: incubator/ooo/trunk/main/svx/inc/svx/sdr/primitive2d/sdrattributecreator.hxx
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/svx/inc/svx/sdr/primitive2d/sdrattributecreator.hxx?rev=1398711&r1=1398710&r2=1398711&view=diff
==============================================================================
--- incubator/ooo/trunk/main/svx/inc/svx/sdr/primitive2d/sdrattributecreator.hxx (original)
+++ incubator/ooo/trunk/main/svx/inc/svx/sdr/primitive2d/sdrattributecreator.hxx Tue Oct 16 09:44:02 2012
@@ -39,7 +39,7 @@ namespace drawinglayer { namespace attri
class SdrFillAttribute;
class SdrTextAttribute;
class FillGradientAttribute;
- class SdrFillBitmapAttribute;
+ class SdrFillGraphicAttribute;
class SdrShadowTextAttribute;
class SdrLineShadowTextAttribute;
class SdrLineFillShadowTextAttribute;
@@ -85,7 +85,7 @@ namespace drawinglayer
attribute::FillGradientAttribute createNewTransparenceGradientAttribute(
const SfxItemSet& rSet);
- attribute::SdrFillBitmapAttribute createNewSdrFillBitmapAttribute(
+ attribute::SdrFillGraphicAttribute createNewSdrFillGraphicAttribute(
const SfxItemSet& rSet);
attribute::SdrShadowTextAttribute createNewSdrShadowTextAttribute(
Modified: incubator/ooo/trunk/main/svx/source/sdr/contact/objectcontacttools.cxx
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/svx/source/sdr/contact/objectcontacttools.cxx?rev=1398711&r1=1398710&r2=1398711&view=diff
==============================================================================
--- incubator/ooo/trunk/main/svx/source/sdr/contact/objectcontacttools.cxx (original)
+++ incubator/ooo/trunk/main/svx/source/sdr/contact/objectcontacttools.cxx Tue Oct 16 09:44:02 2012
@@ -32,7 +32,6 @@
#include <basegfx/tools/canvastools.hxx>
#include <drawinglayer/processor2d/vclmetafileprocessor2d.hxx>
#include <drawinglayer/processor2d/vclpixelprocessor2d.hxx>
-#include <drawinglayer/processor2d/canvasprocessor.hxx>
#include <vcl/window.hxx>
//////////////////////////////////////////////////////////////////////////////
Modified: incubator/ooo/trunk/main/svx/source/sdr/contact/viewobjectcontact.cxx
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/svx/source/sdr/contact/viewobjectcontact.cxx?rev=1398711&r1=1398710&r2=1398711&view=diff
==============================================================================
--- incubator/ooo/trunk/main/svx/source/sdr/contact/viewobjectcontact.cxx (original)
+++ incubator/ooo/trunk/main/svx/source/sdr/contact/viewobjectcontact.cxx Tue Oct 16 09:44:02 2012
@@ -138,6 +138,12 @@ namespace
case PRIMITIVE2D_ID_SDRPATHPRIMITIVE2D :
case PRIMITIVE2D_ID_SDRRECTANGLEPRIMITIVE2D :
+ // #121194# With Graphic as Bitmap FillStyle, also check
+ // for primitives filled with animated graphics
+ case PRIMITIVE2D_ID_POLYPOLYGONGRAPHICPRIMITIVE2D:
+ case PRIMITIVE2D_ID_FILLGRAPHICPRIMITIVE2D:
+ case PRIMITIVE2D_ID_TRANSFORMPRIMITIVE2D:
+
// decompose evtl. animated text contained in MaskPrimitive2D
// or group rimitives
case PRIMITIVE2D_ID_MASKPRIMITIVE2D :
Modified: incubator/ooo/trunk/main/svx/source/sdr/primitive2d/sdrattributecreator.cxx
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/svx/source/sdr/primitive2d/sdrattributecreator.cxx?rev=1398711&r1=1398710&r2=1398711&view=diff
==============================================================================
--- incubator/ooo/trunk/main/svx/source/sdr/primitive2d/sdrattributecreator.cxx (original)
+++ incubator/ooo/trunk/main/svx/source/sdr/primitive2d/sdrattributecreator.cxx Tue Oct 16 09:44:02 2012
@@ -51,10 +51,10 @@
#include <svx/sdsxyitm.hxx>
#include <svx/sdshcitm.hxx>
#include <svx/sdshtitm.hxx>
-#include <drawinglayer/attribute/sdrfillbitmapattribute.hxx>
+#include <drawinglayer/attribute/sdrfillgraphicattribute.hxx>
#include <basegfx/polygon/b2dlinegeometry.hxx>
#include <svx/svdotext.hxx>
-#include <drawinglayer/attribute/fillbitmapattribute.hxx>
+#include <drawinglayer/attribute/fillgraphicattribute.hxx>
#include <svx/sdr/attribute/sdrtextattribute.hxx>
#include <svx/xbtmpit.hxx>
#include <svl/itempool.hxx>
@@ -402,7 +402,7 @@ namespace drawinglayer
const Color aColor(((const XFillColorItem&)(rSet.Get(XATTR_FILLCOLOR))).GetColorValue());
attribute::FillGradientAttribute aGradient;
attribute::FillHatchAttribute aHatch;
- attribute::SdrFillBitmapAttribute aBitmap;
+ attribute::SdrFillGraphicAttribute aFillGraphic;
switch(eStyle)
{
@@ -465,7 +465,7 @@ namespace drawinglayer
}
case XFILL_BITMAP :
{
- aBitmap = createNewSdrFillBitmapAttribute(rSet);
+ aFillGraphic = createNewSdrFillGraphicAttribute(rSet);
break;
}
}
@@ -475,7 +475,7 @@ namespace drawinglayer
aColor.getBColor(),
aGradient,
aHatch,
- aBitmap);
+ aFillGraphic);
}
}
@@ -590,46 +590,59 @@ namespace drawinglayer
return attribute::FillGradientAttribute();
}
- attribute::SdrFillBitmapAttribute createNewSdrFillBitmapAttribute(const SfxItemSet& rSet)
+ attribute::SdrFillGraphicAttribute createNewSdrFillGraphicAttribute(const SfxItemSet& rSet)
{
- BitmapEx aBitmapEx(((const XFillBitmapItem&)(rSet.Get(XATTR_FILLBITMAP))).GetGraphicObject().GetGraphic().GetBitmapEx());
-
- // make sure it's not empty, use default instead
- if(aBitmapEx.IsEmpty())
- {
- // #i118485# Add PrefMapMode and PrefSize to avoid mini-tiling and
- // expensive primitive processing in this case. Use 10x10 cm
- aBitmapEx = Bitmap(Size(4,4), 8);
- aBitmapEx.SetPrefMapMode(MapMode(MAP_100TH_MM));
- aBitmapEx.SetPrefSize(Size(10000.0, 10000.0));
- }
+ Graphic aGraphic(((const XFillBitmapItem&)(rSet.Get(XATTR_FILLBITMAP))).GetGraphicObject().GetGraphic());
- // if there is no logical size, create a size from pixel size and set MapMode accordingly
- if(0L == aBitmapEx.GetPrefSize().Width() || 0L == aBitmapEx.GetPrefSize().Height())
- {
- aBitmapEx.SetPrefSize(aBitmapEx.GetSizePixel());
- aBitmapEx.SetPrefMapMode(MAP_PIXEL);
- }
-
- // convert size and MapMode to destination logical size and MapMode. The created
- // bitmap must have a valid logical size (PrefSize)
- const MapUnit aDestinationMapUnit((MapUnit)rSet.GetPool()->GetMetric(0));
+ if(!(GRAPHIC_BITMAP == aGraphic.GetType() || GRAPHIC_GDIMETAFILE == aGraphic.GetType()))
+ {
+ // no content if not bitmap or metafile
+ OSL_ENSURE(false, "No fill graphic in SfxItemSet (!)");
+ return attribute::SdrFillGraphicAttribute();
+ }
- if(aBitmapEx.GetPrefMapMode() != aDestinationMapUnit)
- {
- // #i100360# for MAP_PIXEL, LogicToLogic will not work properly,
+ Size aPrefSize(aGraphic.GetPrefSize());
+
+ if(!aPrefSize.Width() || !aPrefSize.Height())
+ {
+ // if there is no logical size, create a size from pixel size and set MapMode accordingly
+ if(GRAPHIC_BITMAP == aGraphic.GetType())
+ {
+ aGraphic.SetPrefSize(aGraphic.GetBitmapEx().GetSizePixel());
+ aGraphic.SetPrefMapMode(MAP_PIXEL);
+ }
+ }
+
+ if(!aPrefSize.Width() || !aPrefSize.Height())
+ {
+ // no content if no size
+ OSL_ENSURE(false, "Graphic has no size in SfxItemSet (!)");
+ return attribute::SdrFillGraphicAttribute();
+ }
+
+ // convert size and MapMode to destination logical size and MapMode
+ const MapUnit aDestinationMapUnit((MapUnit)rSet.GetPool()->GetMetric(0));
+
+ if(aGraphic.GetPrefMapMode() != aDestinationMapUnit)
+ {
+ // #i100360# for MAP_PIXEL, LogicToLogic will not work properly,
// so fallback to Application::GetDefaultDevice()
- if(MAP_PIXEL == aBitmapEx.GetPrefMapMode().GetMapUnit())
+ if(MAP_PIXEL == aGraphic.GetPrefMapMode().GetMapUnit())
{
- aBitmapEx.SetPrefSize(Application::GetDefaultDevice()->PixelToLogic(
- aBitmapEx.GetPrefSize(), aDestinationMapUnit));
+ aGraphic.SetPrefSize(
+ Application::GetDefaultDevice()->PixelToLogic(
+ aGraphic.GetPrefSize(),
+ aDestinationMapUnit));
}
else
{
- aBitmapEx.SetPrefSize(OutputDevice::LogicToLogic(
- aBitmapEx.GetPrefSize(), aBitmapEx.GetPrefMapMode(), aDestinationMapUnit));
+ aGraphic.SetPrefSize(
+ OutputDevice::LogicToLogic(
+ aGraphic.GetPrefSize(),
+ aGraphic.GetPrefMapMode(),
+ aDestinationMapUnit));
}
- }
+ }
// get size
const basegfx::B2DVector aSize(
@@ -642,8 +655,8 @@ namespace drawinglayer
(double)((const SfxUInt16Item&) (rSet.Get(XATTR_FILLBMP_POSOFFSETX))).GetValue(),
(double)((const SfxUInt16Item&) (rSet.Get(XATTR_FILLBMP_POSOFFSETY))).GetValue());
- return attribute::SdrFillBitmapAttribute(
- aBitmapEx,
+ return attribute::SdrFillGraphicAttribute(
+ aGraphic,
aSize,
aOffset,
aOffsetPosition,
Modified: incubator/ooo/trunk/main/svx/source/sdr/primitive2d/sdrdecompositiontools.cxx
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/svx/source/sdr/primitive2d/sdrdecompositiontools.cxx?rev=1398711&r1=1398710&r2=1398711&view=diff
==============================================================================
--- incubator/ooo/trunk/main/svx/source/sdr/primitive2d/sdrdecompositiontools.cxx (original)
+++ incubator/ooo/trunk/main/svx/source/sdr/primitive2d/sdrdecompositiontools.cxx Tue Oct 16 09:44:02 2012
@@ -32,7 +32,7 @@
#include <drawinglayer/attribute/strokeattribute.hxx>
#include <drawinglayer/attribute/linestartendattribute.hxx>
#include <drawinglayer/primitive2d/polygonprimitive2d.hxx>
-#include <drawinglayer/attribute/sdrfillbitmapattribute.hxx>
+#include <drawinglayer/attribute/sdrfillgraphicattribute.hxx>
#include <basegfx/matrix/b2dhommatrix.hxx>
#include <drawinglayer/primitive2d/shadowprimitive2d.hxx>
#include <svx/sdr/attribute/sdrtextattribute.hxx>
@@ -79,10 +79,10 @@ namespace drawinglayer
{
pNewFillPrimitive = new PolyPolygonHatchPrimitive2D(aScaledPolyPolygon, rFill.getColor(), rFill.getHatch());
}
- else if(!rFill.getBitmap().isDefault())
+ else if(!rFill.getFillGraphic().isDefault())
{
const basegfx::B2DRange aRange(basegfx::tools::getRange(aScaledPolyPolygon));
- pNewFillPrimitive = new PolyPolygonBitmapPrimitive2D(aScaledPolyPolygon, rFill.getBitmap().getFillBitmapAttribute(aRange));
+ pNewFillPrimitive = new PolyPolygonGraphicPrimitive2D(aScaledPolyPolygon, rFill.getFillGraphic().createFillGraphicAttribute(aRange));
}
else
{
Modified: incubator/ooo/trunk/main/svx/source/xoutdev/xattrbmp.cxx
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/svx/source/xoutdev/xattrbmp.cxx?rev=1398711&r1=1398710&r2=1398711&view=diff
==============================================================================
--- incubator/ooo/trunk/main/svx/source/xoutdev/xattrbmp.cxx (original)
+++ incubator/ooo/trunk/main/svx/source/xoutdev/xattrbmp.cxx Tue Oct 16 09:44:02 2012
@@ -414,6 +414,12 @@ sal_Bool XFillBitmapItem::PutValue( cons
if( bSetURL )
{
maGraphicObject = GraphicObject::CreateGraphicObjectFromURL(aURL);
+
+ // #121194# Prefer GraphicObject over bitmap object if both are provided
+ if(bSetBitmap && GRAPHIC_NONE != maGraphicObject.GetType())
+ {
+ bSetBitmap = false;
+ }
}
if( bSetBitmap )
{
Modified: incubator/ooo/trunk/main/vcl/inc/vcl/graph.hxx
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/vcl/inc/vcl/graph.hxx?rev=1398711&r1=1398710&r2=1398711&view=diff
==============================================================================
--- incubator/ooo/trunk/main/vcl/inc/vcl/graph.hxx (original)
+++ incubator/ooo/trunk/main/vcl/inc/vcl/graph.hxx Tue Oct 16 09:44:02 2012
@@ -56,17 +56,20 @@ private:
unsigned mbUnlimitedSize : 1; // default is false
unsigned mbAntiAliase : 1; // default is false
unsigned mbSnapHorVerLines : 1; // default is false
+ unsigned mbScaleHighQuality : 1; // default is false
public:
GraphicConversionParameters(
const Size& rSizePixel = Size(),
bool bUnlimitedSize = false,
bool bAntiAliase = false,
- bool bSnapHorVerLines = false)
+ bool bSnapHorVerLines = false,
+ bool bScaleHighQuality = false)
: maSizePixel(rSizePixel),
mbUnlimitedSize(bUnlimitedSize),
mbAntiAliase(bAntiAliase),
- mbSnapHorVerLines(bSnapHorVerLines)
+ mbSnapHorVerLines(bSnapHorVerLines),
+ mbScaleHighQuality(bScaleHighQuality)
{
}
@@ -75,6 +78,7 @@ public:
bool getUnlimitedSize() const { return mbUnlimitedSize; }
bool getAntiAliase() const { return mbAntiAliase; }
bool getSnapHorVerLines() const { return mbSnapHorVerLines; }
+ bool getScaleHighQuality() const { return mbScaleHighQuality; }
};
class VCL_DLLPUBLIC Graphic : public SvDataCopyStream
Modified: incubator/ooo/trunk/main/vcl/source/gdi/impgraph.cxx
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/vcl/source/gdi/impgraph.cxx?rev=1398711&r1=1398710&r2=1398711&view=diff
==============================================================================
--- incubator/ooo/trunk/main/vcl/source/gdi/impgraph.cxx (original)
+++ incubator/ooo/trunk/main/vcl/source/gdi/impgraph.cxx Tue Oct 16 09:44:02 2012
@@ -657,7 +657,11 @@ BitmapEx ImpGraphic::ImplGetBitmapEx(con
aRetBmpEx = ( mpAnimation ? mpAnimation->GetBitmapEx() : maEx );
if(rParameters.getSizePixel().Width() || rParameters.getSizePixel().Height())
- aRetBmpEx.Scale(rParameters.getSizePixel());
+ {
+ aRetBmpEx.Scale(
+ rParameters.getSizePixel(),
+ rParameters.getScaleHighQuality() ? BMP_SCALE_INTERPOLATE : BMP_SCALE_FAST);
+ }
}
else if( ( meType != GRAPHIC_DEFAULT ) && ImplIsSupportedGraphic() )
{