summaryrefslogtreecommitdiff
path: root/drawinglayer/source/primitive2d/graphicprimitive2d.cxx
diff options
context:
space:
mode:
authorArmin Le Grand <alg@apache.org>2012-10-16 08:44:02 +0000
committerCaolán McNamara <caolanm@redhat.com>2013-06-11 20:00:34 +0100
commit37aa7d81aacaae12dfe0fd2ade2779235bbf72f1 (patch)
treebaf84cf5f8fcf62221dd75869d507d2396ae690b /drawinglayer/source/primitive2d/graphicprimitive2d.cxx
parente72e1c110ad42b779afbe74b47ca35c1849e06b2 (diff)
Resolves: #i121194# Better support for graphic fill styles...
which are not bitmaps (svg, metafiles, ..) (cherry picked from commit 7a652a2b2ab5e0d37e32185c8c5fac3af482bb76) Conflicts: drawinglayer/Library_drawinglayer.mk drawinglayer/Package_inc.mk drawinglayer/inc/drawinglayer/attribute/fillgraphicattribute.hxx drawinglayer/inc/drawinglayer/attribute/sdrfillattribute.hxx drawinglayer/inc/drawinglayer/attribute/sdrfillgraphicattribute.hxx drawinglayer/inc/drawinglayer/primitive2d/drawinglayer_primitivetypes2d.hxx drawinglayer/inc/drawinglayer/primitive2d/fillgraphicprimitive2d.hxx drawinglayer/inc/drawinglayer/primitive2d/polypolygonprimitive2d.hxx drawinglayer/inc/drawinglayer/primitive3d/textureprimitive3d.hxx drawinglayer/inc/drawinglayer/processor2d/vclprocessor2d.hxx drawinglayer/inc/drawinglayer/texture/texture.hxx drawinglayer/inc/drawinglayer/texture/texture3d.hxx drawinglayer/source/attribute/fillbitmapattribute.cxx drawinglayer/source/attribute/sdrfillattribute.cxx drawinglayer/source/attribute/sdrfillgraphicattribute.cxx drawinglayer/source/primitive2d/fillbitmapprimitive2d.cxx drawinglayer/source/primitive2d/graphicprimitive2d.cxx drawinglayer/source/primitive2d/polypolygonprimitive2d.cxx drawinglayer/source/processor2d/canvasprocessor.cxx svx/inc/svx/sdr/primitive2d/sdrattributecreator.hxx svx/source/sdr/contact/objectcontacttools.cxx vcl/inc/vcl/graph.hxx unused file _vclmetafileprocessor2d.cxx deleted, was added by error (cherry picked from commit ed0d53f8283cd3ce579a90b599118884d0db6119) Conflicts: drawinglayer/source/processor2d/_vclmetafileprocessor2d.cxx Corrected canvasProcessor usage (cherry picked from commit 7903c33f31c457eb6ff506958c4233f2a5d39bcf) Conflicts: svx/source/sdr/contact/objectcontacttools.cxx Change-Id: I80008050b98dafc92fde043524843c13a75fe22c d2fa667d7c127b4d735334e56093d1d4553b0a5b e20c60c7d6472da1295a162d9a629be998861f62
Diffstat (limited to 'drawinglayer/source/primitive2d/graphicprimitive2d.cxx')
-rw-r--r--drawinglayer/source/primitive2d/graphicprimitive2d.cxx301
1 files changed, 17 insertions, 284 deletions
diff --git a/drawinglayer/source/primitive2d/graphicprimitive2d.cxx b/drawinglayer/source/primitive2d/graphicprimitive2d.cxx
index 00a248525b6c..865d52f0cd86 100644
--- a/drawinglayer/source/primitive2d/graphicprimitive2d.cxx
+++ b/drawinglayer/source/primitive2d/graphicprimitive2d.cxx
@@ -18,178 +18,13 @@
*/
#include <drawinglayer/primitive2d/graphicprimitive2d.hxx>
-#include <drawinglayer/animation/animationtiming.hxx>
-#include <drawinglayer/primitive2d/bitmapprimitive2d.hxx>
-#include <drawinglayer/primitive2d/animatedprimitive2d.hxx>
-#include <drawinglayer/primitive2d/metafileprimitive2d.hxx>
-#include <drawinglayer/primitive2d/transformprimitive2d.hxx>
-#include <basegfx/polygon/b2dpolygon.hxx>
-#include <basegfx/polygon/b2dpolygontools.hxx>
#include <drawinglayer/primitive2d/cropprimitive2d.hxx>
#include <drawinglayer/primitive2d/drawinglayer_primitivetypes2d.hxx>
#include <drawinglayer/primitive2d/maskprimitive2d.hxx>
-
-//////////////////////////////////////////////////////////////////////////////
-// helper class for animated graphics
-
-#include <vcl/animate.hxx>
-#include <vcl/graph.hxx>
-#include <vcl/virdev.hxx>
+#include <drawinglayer/primitive2d/graphicprimitivehelper2d.hxx>
+#include <basegfx/matrix/b2dhommatrixtools.hxx>
#include <vcl/svapp.hxx>
-#include <vcl/metaact.hxx>
-
-//////////////////////////////////////////////////////////////////////////////
-// includes for testing MetafilePrimitive2D::create2DDecomposition
-
-//////////////////////////////////////////////////////////////////////////////
-
-namespace
-{
- struct animationStep
- {
- BitmapEx maBitmapEx;
- sal_uInt32 mnTime;
- };
-
- class animatedBitmapExPreparator
- {
- ::Animation maAnimation;
- ::std::vector< animationStep > maSteps;
-
- sal_uInt32 generateStepTime(sal_uInt32 nIndex) const;
-
- public:
- explicit animatedBitmapExPreparator(const Graphic& rGraphic);
-
- sal_uInt32 count() const { return maSteps.size(); }
- sal_uInt32 loopCount() const { return (sal_uInt32)maAnimation.GetLoopCount(); }
- sal_uInt32 stepTime(sal_uInt32 a) const { return maSteps[a].mnTime; }
- const BitmapEx& stepBitmapEx(sal_uInt32 a) const { return maSteps[a].maBitmapEx; }
- };
-
- sal_uInt32 animatedBitmapExPreparator::generateStepTime(sal_uInt32 nIndex) const
- {
- const AnimationBitmap& rAnimBitmap = maAnimation.Get(sal_uInt16(nIndex));
- sal_uInt32 nWaitTime(rAnimBitmap.nWait * 10);
-
- // #115934#
- // Take care of special value for MultiPage TIFFs. ATM these shall just
- // show their first page. Later we will offer some switching when object
- // is selected.
- if(ANIMATION_TIMEOUT_ON_CLICK == rAnimBitmap.nWait)
- {
- // ATM the huge value would block the timer, so
- // use a long time to show first page (whole day)
- nWaitTime = 100 * 60 * 60 * 24;
- }
-
- // Bad trap: There are animated gifs with no set WaitTime (!).
- // In that case use a default value.
- if(0L == nWaitTime)
- {
- nWaitTime = 100L;
- }
-
- return nWaitTime;
- }
-
- animatedBitmapExPreparator::animatedBitmapExPreparator(const Graphic& rGraphic)
- : maAnimation(rGraphic.GetAnimation())
- {
- OSL_ENSURE(GRAPHIC_BITMAP == rGraphic.GetType() && rGraphic.IsAnimated(), "animatedBitmapExPreparator: graphic is not animated (!)");
-
- // #128539# secure access to Animation, looks like there exist animated GIFs out there
- // with a step count of zero
- if(maAnimation.Count())
- {
- VirtualDevice aVirtualDevice(*Application::GetDefaultDevice());
- VirtualDevice aVirtualDeviceMask(*Application::GetDefaultDevice(), 1L);
-
- // Prepare VirtualDevices and their states
- aVirtualDevice.EnableMapMode(sal_False);
- aVirtualDeviceMask.EnableMapMode(sal_False);
- aVirtualDevice.SetOutputSizePixel(maAnimation.GetDisplaySizePixel());
- aVirtualDeviceMask.SetOutputSizePixel(maAnimation.GetDisplaySizePixel());
- aVirtualDevice.Erase();
- aVirtualDeviceMask.Erase();
-
- for(sal_uInt16 a(0L); a < maAnimation.Count(); a++)
- {
- animationStep aNextStep;
- aNextStep.mnTime = generateStepTime(a);
-
- // prepare step
- const AnimationBitmap& rAnimBitmap = maAnimation.Get(sal_uInt16(a));
-
- switch(rAnimBitmap.eDisposal)
- {
- case DISPOSE_NOT:
- {
- aVirtualDevice.DrawBitmapEx(rAnimBitmap.aPosPix, rAnimBitmap.aBmpEx);
- Bitmap aMask = rAnimBitmap.aBmpEx.GetMask();
-
- if(aMask.IsEmpty())
- {
- const Point aEmpty;
- const Rectangle aRect(aEmpty, aVirtualDeviceMask.GetOutputSizePixel());
- const Wallpaper aWallpaper(COL_BLACK);
- aVirtualDeviceMask.DrawWallpaper(aRect, aWallpaper);
- }
- else
- {
- BitmapEx aExpandVisibilityMask = BitmapEx(aMask, aMask);
- aVirtualDeviceMask.DrawBitmapEx(rAnimBitmap.aPosPix, aExpandVisibilityMask);
- }
-
- break;
- }
- case DISPOSE_BACK:
- {
- // #i70772# react on no mask, for primitives, too.
- const Bitmap aMask(rAnimBitmap.aBmpEx.GetMask());
- const Bitmap aContent(rAnimBitmap.aBmpEx.GetBitmap());
-
- aVirtualDeviceMask.Erase();
- aVirtualDevice.DrawBitmap(rAnimBitmap.aPosPix, aContent);
-
- if(aMask.IsEmpty())
- {
- const Rectangle aRect(rAnimBitmap.aPosPix, aContent.GetSizePixel());
- aVirtualDeviceMask.SetFillColor(COL_BLACK);
- aVirtualDeviceMask.SetLineColor();
- aVirtualDeviceMask.DrawRect(aRect);
- }
- else
- {
- aVirtualDeviceMask.DrawBitmap(rAnimBitmap.aPosPix, aMask);
- }
-
- break;
- }
- case DISPOSE_FULL:
- {
- aVirtualDevice.DrawBitmapEx(rAnimBitmap.aPosPix, rAnimBitmap.aBmpEx);
- break;
- }
- case DISPOSE_PREVIOUS :
- {
- aVirtualDevice.DrawBitmapEx(rAnimBitmap.aPosPix, rAnimBitmap.aBmpEx);
- aVirtualDeviceMask.DrawBitmap(rAnimBitmap.aPosPix, rAnimBitmap.aBmpEx.GetMask());
- break;
- }
- }
-
- // create BitmapEx
- Bitmap aMainBitmap = aVirtualDevice.GetBitmap(Point(), aVirtualDevice.GetOutputSizePixel());
- Bitmap aMaskBitmap = aVirtualDeviceMask.GetBitmap(Point(), aVirtualDeviceMask.GetOutputSizePixel());
- aNextStep.maBitmapEx = BitmapEx(aMainBitmap, aMaskBitmap);
-
- // add to vector
- maSteps.push_back(aNextStep);
- }
- }
- }
-} // end of anonymous namespace
+#include <vcl/outdev.hxx>
//////////////////////////////////////////////////////////////////////////////
@@ -204,8 +39,6 @@ namespace drawinglayer
if(255L != getGraphicAttr().GetTransparency())
{
- Primitive2DReference xPrimitive;
-
// do not apply mirroring from GraphicAttr to the Metafile by calling
// GetTransformedGraphic, this will try to mirror the Metafile using Scale()
// at the Metafile. This again calls Scale at the single MetaFile actions,
@@ -241,111 +74,11 @@ namespace drawinglayer
const GraphicObject& rGraphicObject = getGraphicObject();
const Graphic aTransformedGraphic(rGraphicObject.GetTransformedGraphic(&aSuppressGraphicAttr));
- switch(aTransformedGraphic.GetType())
- {
- case GRAPHIC_BITMAP :
- {
- if(aTransformedGraphic.IsAnimated())
- {
- // prepare animation data
- animatedBitmapExPreparator aData(aTransformedGraphic);
-
- if(aData.count())
- {
- // create sub-primitives for animated bitmap and the needed animation loop
- animation::AnimationEntryLoop aAnimationLoop(aData.loopCount() ? aData.loopCount() : 0xffff);
- Primitive2DSequence aBitmapPrimitives(aData.count());
-
- for(sal_uInt32 a(0L); a < aData.count(); a++)
- {
- animation::AnimationEntryFixed aTime((double)aData.stepTime(a), (double)a / (double)aData.count());
- aAnimationLoop.append(aTime);
- const Primitive2DReference xRef(new BitmapPrimitive2D(aData.stepBitmapEx(a), aTransform));
- aBitmapPrimitives[a] = xRef;
- }
-
- // prepare animation list
- animation::AnimationEntryList aAnimationList;
- aAnimationList.append(aAnimationLoop);
-
- // create and add animated switch primitive
- xPrimitive = Primitive2DReference(new AnimatedSwitchPrimitive2D(aAnimationList, aBitmapPrimitives, false));
- }
- }
- else if(aTransformedGraphic.getSvgData().get())
- {
- // embedded Svg fill, create embed transform
- const basegfx::B2DRange& rSvgRange(aTransformedGraphic.getSvgData()->getRange());
-
- if(basegfx::fTools::more(rSvgRange.getWidth(), 0.0) && basegfx::fTools::more(rSvgRange.getHeight(), 0.0))
- {
- // translate back to origin, scale to unit coordinates
- basegfx::B2DHomMatrix aEmbedSvg(
- basegfx::tools::createTranslateB2DHomMatrix(
- -rSvgRange.getMinX(),
- -rSvgRange.getMinY()));
-
- aEmbedSvg.scale(
- 1.0 / rSvgRange.getWidth(),
- 1.0 / rSvgRange.getHeight());
-
- // apply created object transformation
- aEmbedSvg = aTransform * aEmbedSvg;
-
- // add Svg primitives embedded
- xPrimitive = new TransformPrimitive2D(
- aEmbedSvg,
- aTransformedGraphic.getSvgData()->getPrimitive2DSequence());
- }
- }
- else
- {
- xPrimitive = Primitive2DReference(new BitmapPrimitive2D(aTransformedGraphic.GetBitmapEx(), aTransform));
- }
-
- break;
- }
-
- case GRAPHIC_GDIMETAFILE :
- {
- // create MetafilePrimitive2D
- const GDIMetaFile& rMetafile = aTransformedGraphic.GetGDIMetaFile();
+ aRetval = create2DDecompositionOfGraphic(
+ aTransformedGraphic,
+ aTransform);
- xPrimitive = Primitive2DReference(
- new MetafilePrimitive2D( aTransform, rMetafile ) );
-
- // #i100357# find out if clipping is needed for this primitive. Unfortunately,
- // there exist Metafiles who's content is bigger than the proposed PrefSize set
- // at them. This is an error, but we need to work around this
- const Size aMetaFilePrefSize(rMetafile.GetPrefSize());
- const Size aMetaFileRealSize(
- const_cast< GDIMetaFile& >(rMetafile).GetBoundRect(
- *Application::GetDefaultDevice()).GetSize());
-
- if(aMetaFileRealSize.getWidth() > aMetaFilePrefSize.getWidth()
- || aMetaFileRealSize.getHeight() > aMetaFilePrefSize.getHeight())
- {
- // clipping needed. Embed to MaskPrimitive2D. Create childs and mask polygon
- const primitive2d::Primitive2DSequence aChildContent(&xPrimitive, 1);
- basegfx::B2DPolygon aMaskPolygon(basegfx::tools::createUnitPolygon());
- aMaskPolygon.transform(aTransform);
-
- xPrimitive = Primitive2DReference(
- new MaskPrimitive2D(
- basegfx::B2DPolyPolygon(aMaskPolygon),
- aChildContent));
- }
- break;
- }
-
- default:
- {
- // nothing to create
- break;
- }
- }
-
- if(xPrimitive.is())
+ if(aRetval.getLength())
{
// check for cropping
if(getGraphicAttr().IsCropped())
@@ -385,17 +118,17 @@ namespace drawinglayer
}
// embed content in cropPrimitive
- xPrimitive = new CropPrimitive2D(
- Primitive2DSequence(&xPrimitive, 1),
- aTransform,
- getGraphicAttr().GetLeftCrop() * fFactorX,
- getGraphicAttr().GetTopCrop() * fFactorY,
- getGraphicAttr().GetRightCrop() * fFactorX,
- getGraphicAttr().GetBottomCrop() * fFactorY);
+ Primitive2DReference xPrimitive(
+ new CropPrimitive2D(
+ aRetval,
+ aTransform,
+ getGraphicAttr().GetLeftCrop() * fFactorX,
+ getGraphicAttr().GetTopCrop() * fFactorY,
+ getGraphicAttr().GetRightCrop() * fFactorX,
+ getGraphicAttr().GetBottomCrop() * fFactorY));
+
+ aRetval = Primitive2DSequence(&xPrimitive, 1);
}
-
- // add to decomposition
- appendPrimitive2DReferenceToPrimitive2DSequence(aRetval, xPrimitive);
}
}