svggradientprimitive2d.cxx (6669cde1) svggradientprimitive2d.cxx (01e92ad6)
1/**************************************************************
2 *
3 * Licensed to the Apache Software Foundation (ASF) under one
4 * or more contributor license agreements. See the NOTICE file
5 * distributed with this work for additional information
6 * regarding copyright ownership. The ASF licenses this file
7 * to you under the Apache License, Version 2.0 (the
8 * "License"); you may not use this file except in compliance

--- 271 unchanged lines hidden (view full) ---

280
281 xRetval = Primitive2DSequence(&xRefContent, 1);
282 }
283
284 return xRetval;
285 }
286
287 SvgGradientHelper::SvgGradientHelper(
1/**************************************************************
2 *
3 * Licensed to the Apache Software Foundation (ASF) under one
4 * or more contributor license agreements. See the NOTICE file
5 * distributed with this work for additional information
6 * regarding copyright ownership. The ASF licenses this file
7 * to you under the Apache License, Version 2.0 (the
8 * "License"); you may not use this file except in compliance

--- 271 unchanged lines hidden (view full) ---

280
281 xRetval = Primitive2DSequence(&xRefContent, 1);
282 }
283
284 return xRetval;
285 }
286
287 SvgGradientHelper::SvgGradientHelper(
288 const basegfx::B2DHomMatrix& rGradientTransform,
288 const basegfx::B2DPolyPolygon& rPolyPolygon,
289 const SvgGradientEntryVector& rGradientEntries,
290 const basegfx::B2DPoint& rStart,
291 bool bUseUnitCoordinates,
292 SpreadMethod aSpreadMethod)
289 const basegfx::B2DPolyPolygon& rPolyPolygon,
290 const SvgGradientEntryVector& rGradientEntries,
291 const basegfx::B2DPoint& rStart,
292 bool bUseUnitCoordinates,
293 SpreadMethod aSpreadMethod)
293 : maPolyPolygon(rPolyPolygon),
294 : maGradientTransform(rGradientTransform),
295 maPolyPolygon(rPolyPolygon),
294 maGradientEntries(rGradientEntries),
295 maStart(rStart),
296 maSpreadMethod(aSpreadMethod),
297 mbPreconditionsChecked(false),
298 mbCreatesContent(false),
299 mbSingleEntry(false),
300 mbFullyOpaque(true),
301 mbUseUnitCoordinates(bUseUnitCoordinates)
302 {
303 }
304
305 bool SvgGradientHelper::operator==(const SvgGradientHelper& rSvgGradientHelper) const
306 {
307 const SvgGradientHelper& rCompare = static_cast< const SvgGradientHelper& >(rSvgGradientHelper);
308
296 maGradientEntries(rGradientEntries),
297 maStart(rStart),
298 maSpreadMethod(aSpreadMethod),
299 mbPreconditionsChecked(false),
300 mbCreatesContent(false),
301 mbSingleEntry(false),
302 mbFullyOpaque(true),
303 mbUseUnitCoordinates(bUseUnitCoordinates)
304 {
305 }
306
307 bool SvgGradientHelper::operator==(const SvgGradientHelper& rSvgGradientHelper) const
308 {
309 const SvgGradientHelper& rCompare = static_cast< const SvgGradientHelper& >(rSvgGradientHelper);
310
309 return (getPolyPolygon() == rCompare.getPolyPolygon()
311 return (getGradientTransform() == rCompare.getGradientTransform()
312 && getPolyPolygon() == rCompare.getPolyPolygon()
310 && getGradientEntries() == rCompare.getGradientEntries()
311 && getStart() == rCompare.getStart()
312 && getUseUnitCoordinates() == rCompare.getUseUnitCoordinates()
313 && getSpreadMethod() == rCompare.getSpreadMethod());
314 }
315
316 } // end of namespace primitive2d
317} // end of namespace drawinglayer

--- 109 unchanged lines hidden (view full) ---

427 const basegfx::B2DPoint aEnd(aObjectTransform * getEnd());
428 const basegfx::B2DVector aVector(aEnd - aStart);
429
430 aUnitGradientToObject.scale(aVector.getLength(), 1.0);
431 aUnitGradientToObject.rotate(atan2(aVector.getY(), aVector.getX()));
432 aUnitGradientToObject.translate(aStart.getX(), aStart.getY());
433 }
434
313 && getGradientEntries() == rCompare.getGradientEntries()
314 && getStart() == rCompare.getStart()
315 && getUseUnitCoordinates() == rCompare.getUseUnitCoordinates()
316 && getSpreadMethod() == rCompare.getSpreadMethod());
317 }
318
319 } // end of namespace primitive2d
320} // end of namespace drawinglayer

--- 109 unchanged lines hidden (view full) ---

430 const basegfx::B2DPoint aEnd(aObjectTransform * getEnd());
431 const basegfx::B2DVector aVector(aEnd - aStart);
432
433 aUnitGradientToObject.scale(aVector.getLength(), 1.0);
434 aUnitGradientToObject.rotate(atan2(aVector.getY(), aVector.getX()));
435 aUnitGradientToObject.translate(aStart.getX(), aStart.getY());
436 }
437
438 if(!getGradientTransform().isIdentity())
439 {
440 aUnitGradientToObject = getGradientTransform() * aUnitGradientToObject;
441 }
442
435 // create inverse from it
436 basegfx::B2DHomMatrix aObjectToUnitGradient(aUnitGradientToObject);
437 aObjectToUnitGradient.invert();
438
439 // back-transform polygon to unit gradient coordinates and get
440 // UnitRage. This is the range the gradient has to cover
441 basegfx::B2DPolyPolygon aUnitPoly(getPolyPolygon());
442 aUnitPoly.transform(aObjectToUnitGradient);

--- 102 unchanged lines hidden (view full) ---

545
546 xRetval = createResult(aTargetColor, aTargetOpacity, aUnitGradientToObject);
547 }
548
549 return xRetval;
550 }
551
552 SvgLinearGradientPrimitive2D::SvgLinearGradientPrimitive2D(
443 // create inverse from it
444 basegfx::B2DHomMatrix aObjectToUnitGradient(aUnitGradientToObject);
445 aObjectToUnitGradient.invert();
446
447 // back-transform polygon to unit gradient coordinates and get
448 // UnitRage. This is the range the gradient has to cover
449 basegfx::B2DPolyPolygon aUnitPoly(getPolyPolygon());
450 aUnitPoly.transform(aObjectToUnitGradient);

--- 102 unchanged lines hidden (view full) ---

553
554 xRetval = createResult(aTargetColor, aTargetOpacity, aUnitGradientToObject);
555 }
556
557 return xRetval;
558 }
559
560 SvgLinearGradientPrimitive2D::SvgLinearGradientPrimitive2D(
561 const basegfx::B2DHomMatrix& rGradientTransform,
553 const basegfx::B2DPolyPolygon& rPolyPolygon,
554 const SvgGradientEntryVector& rGradientEntries,
555 const basegfx::B2DPoint& rStart,
556 const basegfx::B2DPoint& rEnd,
557 bool bUseUnitCoordinates,
558 SpreadMethod aSpreadMethod)
559 : BufferedDecompositionPrimitive2D(),
562 const basegfx::B2DPolyPolygon& rPolyPolygon,
563 const SvgGradientEntryVector& rGradientEntries,
564 const basegfx::B2DPoint& rStart,
565 const basegfx::B2DPoint& rEnd,
566 bool bUseUnitCoordinates,
567 SpreadMethod aSpreadMethod)
568 : BufferedDecompositionPrimitive2D(),
560 SvgGradientHelper(rPolyPolygon, rGradientEntries, rStart, bUseUnitCoordinates, aSpreadMethod),
569 SvgGradientHelper(rGradientTransform, rPolyPolygon, rGradientEntries, rStart, bUseUnitCoordinates, aSpreadMethod),
561 maEnd(rEnd)
562 {
563 }
564
565 SvgLinearGradientPrimitive2D::~SvgLinearGradientPrimitive2D()
566 {
567 }
568

--- 179 unchanged lines hidden (view full) ---

748
749 // create full transform from unit gradient coordinates to object coordinates
750 // including the SvgGradient transformation
751 aUnitGradientToObject = aObjectTransform * aUnitGradientToGradient;
752 }
753 else
754 {
755 // interpret in object coordinate system -> object aspect ratio will not scale result
570 maEnd(rEnd)
571 {
572 }
573
574 SvgLinearGradientPrimitive2D::~SvgLinearGradientPrimitive2D()
575 {
576 }
577

--- 179 unchanged lines hidden (view full) ---

757
758 // create full transform from unit gradient coordinates to object coordinates
759 // including the SvgGradient transformation
760 aUnitGradientToObject = aObjectTransform * aUnitGradientToGradient;
761 }
762 else
763 {
764 // interpret in object coordinate system -> object aspect ratio will not scale result
765 // use X-Axis with radius, it was already made relative to object width when coming from
766 // SVG import
756 const double fRadius((aObjectTransform * basegfx::B2DVector(getRadius(), 0.0)).getLength());
757 const basegfx::B2DPoint aStart(aObjectTransform * getStart());
758
759 aUnitGradientToObject.scale(fRadius, fRadius);
760 aUnitGradientToObject.translate(aStart.getX(), aStart.getY());
761 }
762
767 const double fRadius((aObjectTransform * basegfx::B2DVector(getRadius(), 0.0)).getLength());
768 const basegfx::B2DPoint aStart(aObjectTransform * getStart());
769
770 aUnitGradientToObject.scale(fRadius, fRadius);
771 aUnitGradientToObject.translate(aStart.getX(), aStart.getY());
772 }
773
774 if(!getGradientTransform().isIdentity())
775 {
776 aUnitGradientToObject = getGradientTransform() * aUnitGradientToObject;
777 }
778
763 // create inverse from it
764 basegfx::B2DHomMatrix aObjectToUnitGradient(aUnitGradientToObject);
765 aObjectToUnitGradient.invert();
766
767 // back-transform polygon to unit gradient coordinates and get
768 // UnitRage. This is the range the gradient has to cover
769 basegfx::B2DPolyPolygon aUnitPoly(getPolyPolygon());
770 aUnitPoly.transform(aObjectToUnitGradient);

--- 51 unchanged lines hidden (view full) ---

822
823 xRetval = createResult(aTargetColor, aTargetOpacity, aUnitGradientToObject, true);
824 }
825
826 return xRetval;
827 }
828
829 SvgRadialGradientPrimitive2D::SvgRadialGradientPrimitive2D(
779 // create inverse from it
780 basegfx::B2DHomMatrix aObjectToUnitGradient(aUnitGradientToObject);
781 aObjectToUnitGradient.invert();
782
783 // back-transform polygon to unit gradient coordinates and get
784 // UnitRage. This is the range the gradient has to cover
785 basegfx::B2DPolyPolygon aUnitPoly(getPolyPolygon());
786 aUnitPoly.transform(aObjectToUnitGradient);

--- 51 unchanged lines hidden (view full) ---

838
839 xRetval = createResult(aTargetColor, aTargetOpacity, aUnitGradientToObject, true);
840 }
841
842 return xRetval;
843 }
844
845 SvgRadialGradientPrimitive2D::SvgRadialGradientPrimitive2D(
846 const basegfx::B2DHomMatrix& rGradientTransform,
830 const basegfx::B2DPolyPolygon& rPolyPolygon,
831 const SvgGradientEntryVector& rGradientEntries,
832 const basegfx::B2DPoint& rStart,
833 double fRadius,
834 bool bUseUnitCoordinates,
835 SpreadMethod aSpreadMethod,
836 const basegfx::B2DPoint* pFocal)
837 : BufferedDecompositionPrimitive2D(),
847 const basegfx::B2DPolyPolygon& rPolyPolygon,
848 const SvgGradientEntryVector& rGradientEntries,
849 const basegfx::B2DPoint& rStart,
850 double fRadius,
851 bool bUseUnitCoordinates,
852 SpreadMethod aSpreadMethod,
853 const basegfx::B2DPoint* pFocal)
854 : BufferedDecompositionPrimitive2D(),
838 SvgGradientHelper(rPolyPolygon, rGradientEntries, rStart, bUseUnitCoordinates, aSpreadMethod),
855 SvgGradientHelper(rGradientTransform, rPolyPolygon, rGradientEntries, rStart, bUseUnitCoordinates, aSpreadMethod),
839 mfRadius(fRadius),
840 maFocal(rStart),
841 maFocalVector(0.0, 0.0),
842 maFocalLength(0.0),
843 maMirroredGradientEntries(),
844 mbFocalSet(false)
845 {
846 if(pFocal && !pFocal->equal(getStart()))

--- 300 unchanged lines hidden ---
856 mfRadius(fRadius),
857 maFocal(rStart),
858 maFocalVector(0.0, 0.0),
859 maFocalLength(0.0),
860 maMirroredGradientEntries(),
861 mbFocalSet(false)
862 {
863 if(pFocal && !pFocal->equal(getStart()))

--- 300 unchanged lines hidden ---