diff options
author | Rüdiger Timm <rt@openoffice.org> | 2008-12-09 13:22:21 +0000 |
---|---|---|
committer | Rüdiger Timm <rt@openoffice.org> | 2008-12-09 13:22:21 +0000 |
commit | 08dd93a4b70962aed0d2b1923b1a73d1d33e0bf3 (patch) | |
tree | 71741e6246bc9e4115770a4872a2f01906461feb /canvas | |
parent | 3a91fde276caa644d90f02da0e102dd4915fc460 (diff) |
CWS-TOOLING: integrate CWS canvas06
2008-11-14 18:59:03 +0100 thb r263697 : Reverted fAlpha setup to previous state, as this was bogus as well - code path is apparently not taken for test, but anyway
2008-11-13 21:32:45 +0100 thb r263663 : WaE fix (and a bad bug as well - int color would have overflown)
2008-11-13 16:51:37 +0100 pl r263654 : remove warnings
2008-11-13 09:46:28 +0100 thb r263623 : #i95317# Fixed typo (thx WaE for finding)
2008-11-12 21:25:19 +0100 thb r263617 : #i96047# call update() on hidden sprite shape as well, to force actual hiding
2008-11-12 21:23:31 +0100 thb r263616 : #i95209# Merge from CWS thb11 - revives canvasbitmap unit tests, fixes nasty corner case in x11 salbmp (for 16bpp)
2008-11-12 21:21:46 +0100 thb r263615 : #i95197# Shuffled code to make valgrind quiet during bmp loading
2008-11-12 21:18:06 +0100 thb r263614 : #i93382# Make --disable-moz build work
2008-11-12 21:16:55 +0100 thb r263613 : #i95317# Fixed mis-named traits methods for min and max numbers
2008-11-12 20:59:01 +0100 thb r263612 : #i95317#, #i92902#: migrate CWS canvas06 to SVN.
Diffstat (limited to 'canvas')
-rw-r--r-- | canvas/source/cairo/cairo_canvashelper.cxx | 388 | ||||
-rwxr-xr-x | canvas/source/directx/dx_bitmapcanvashelper.cxx | 2 | ||||
-rw-r--r-- | canvas/source/tools/canvastools.cxx | 75 | ||||
-rw-r--r-- | canvas/source/vcl/canvashelper.cxx | 49 |
4 files changed, 493 insertions, 21 deletions
diff --git a/canvas/source/cairo/cairo_canvashelper.cxx b/canvas/source/cairo/cairo_canvashelper.cxx index d7483fbf4b20..f1c54e9b4ab7 100644 --- a/canvas/source/cairo/cairo_canvashelper.cxx +++ b/canvas/source/cairo/cairo_canvashelper.cxx @@ -36,12 +36,19 @@ #include <rtl/logfile.hxx> #include <rtl/math.hxx> +#include <rtl/instance.hxx> +#include <com/sun/star/util/Endianness.hpp> #include <com/sun/star/rendering/TexturingMode.hpp> #include <com/sun/star/rendering/CompositeOperation.hpp> #include <com/sun/star/rendering/RepaintResult.hpp> #include <com/sun/star/rendering/PathCapType.hpp> #include <com/sun/star/rendering/PathJoinType.hpp> +#include <com/sun/star/rendering/XIntegerBitmapColorSpace.hpp> +#include <com/sun/star/rendering/IntegerBitmapLayout.hpp> +#include <com/sun/star/rendering/ColorSpaceType.hpp> +#include <com/sun/star/rendering/ColorComponentTag.hpp> +#include <com/sun/star/rendering/RenderingIntent.hpp> #include <basegfx/matrix/b2dhommatrix.hxx> #include <basegfx/point/b2dpoint.hxx> @@ -51,6 +58,7 @@ #include <basegfx/tools/canvastools.hxx> #include <comphelper/sequence.hxx> +#include <cppuhelper/compbase1.hxx> #include <canvas/canvastools.hxx> #include <canvas/parametricpolypolygon.hxx> @@ -856,6 +864,10 @@ namespace cairocanvas cairo_matrix_init_identity( &aIdentityMatrix ); cairo_set_matrix( pCairo, &aIdentityMatrix ); + cairo_set_fill_rule( pCairo, + eFillrule == rendering::FillRule_EVEN_ODD ? + CAIRO_FILL_RULE_EVEN_ODD : CAIRO_FILL_RULE_WINDING ); + for( sal_uInt32 nPolygonIndex = 0; nPolygonIndex < aPolyPolygon.count(); nPolygonIndex++ ) { ::basegfx::B2DPolygon aPolygon( aPolyPolygon.getB2DPolygon( nPolygonIndex ) ); const sal_uInt32 nPointCount( aPolygon.count() ); @@ -1408,12 +1420,386 @@ namespace cairocanvas return uno::Reference< rendering::XBitmapPalette >(); } + namespace + { + class CairoColorSpace : public cppu::WeakImplHelper1< com::sun::star::rendering::XIntegerBitmapColorSpace > + { + private: + uno::Sequence< sal_Int8 > maComponentTags; + uno::Sequence< sal_Int32 > maBitCounts; + + virtual ::sal_Int8 SAL_CALL getType( ) throw (uno::RuntimeException) + { + return rendering::ColorSpaceType::RGB; + } + virtual uno::Sequence< ::sal_Int8 > SAL_CALL getComponentTags( ) throw (uno::RuntimeException) + { + return maComponentTags; + } + virtual ::sal_Int8 SAL_CALL getRenderingIntent( ) throw (uno::RuntimeException) + { + return rendering::RenderingIntent::PERCEPTUAL; + } + virtual uno::Sequence< beans::PropertyValue > SAL_CALL getProperties( ) throw (uno::RuntimeException) + { + return uno::Sequence< beans::PropertyValue >(); + } + virtual uno::Sequence< double > SAL_CALL convertColorSpace( const uno::Sequence< double >& deviceColor, + const uno::Reference< rendering::XColorSpace >& targetColorSpace ) throw (lang::IllegalArgumentException, + uno::RuntimeException) + { + // TODO(P3): if we know anything about target + // colorspace, this can be greatly sped up + uno::Sequence<rendering::ARGBColor> aIntermediate( + convertToARGB(deviceColor)); + return targetColorSpace->convertFromARGB(aIntermediate); + } + virtual uno::Sequence< rendering::RGBColor > SAL_CALL convertToRGB( const uno::Sequence< double >& deviceColor ) throw (lang::IllegalArgumentException, uno::RuntimeException) + { + const double* pIn( deviceColor.getConstArray() ); + const sal_Size nLen( deviceColor.getLength() ); + ENSURE_ARG_OR_THROW2(nLen%4==0, + "number of channels no multiple of 4", + static_cast<rendering::XColorSpace*>(this), 0); + + uno::Sequence< rendering::RGBColor > aRes(nLen/4); + rendering::RGBColor* pOut( aRes.getArray() ); + for( sal_Size i=0; i<nLen; i+=4 ) + { + const double fAlpha(pIn[3]); + if( fAlpha == 0.0 ) + *pOut++ = rendering::RGBColor(0.0, 0.0, 0.0); + else + *pOut++ = rendering::RGBColor(pIn[2]/fAlpha,pIn[1]/fAlpha,pIn[0]/fAlpha); + pIn += 4; + } + return aRes; + } + virtual uno::Sequence< rendering::ARGBColor > SAL_CALL convertToARGB( const uno::Sequence< double >& deviceColor ) throw (lang::IllegalArgumentException, uno::RuntimeException) + { + const double* pIn( deviceColor.getConstArray() ); + const sal_Size nLen( deviceColor.getLength() ); + ENSURE_ARG_OR_THROW2(nLen%4==0, + "number of channels no multiple of 4", + static_cast<rendering::XColorSpace*>(this), 0); + + uno::Sequence< rendering::ARGBColor > aRes(nLen/4); + rendering::ARGBColor* pOut( aRes.getArray() ); + for( sal_Size i=0; i<nLen; i+=4 ) + { + const double fAlpha(pIn[3]); + if( fAlpha == 0.0 ) + *pOut++ = rendering::ARGBColor(0.0, 0.0, 0.0, 0.0); + else + *pOut++ = rendering::ARGBColor(fAlpha,pIn[2]/fAlpha,pIn[1]/fAlpha,pIn[0]/fAlpha); + pIn += 4; + } + return aRes; + } + virtual uno::Sequence< rendering::ARGBColor > SAL_CALL convertToPARGB( const uno::Sequence< double >& deviceColor ) throw (lang::IllegalArgumentException, uno::RuntimeException) + { + const double* pIn( deviceColor.getConstArray() ); + const sal_Size nLen( deviceColor.getLength() ); + ENSURE_ARG_OR_THROW2(nLen%4==0, + "number of channels no multiple of 4", + static_cast<rendering::XColorSpace*>(this), 0); + + uno::Sequence< rendering::ARGBColor > aRes(nLen/4); + rendering::ARGBColor* pOut( aRes.getArray() ); + for( sal_Size i=0; i<nLen; i+=4 ) + { + *pOut++ = rendering::ARGBColor(pIn[3],pIn[2],pIn[1],pIn[1]); + pIn += 4; + } + return aRes; + } + virtual uno::Sequence< double > SAL_CALL convertFromRGB( const uno::Sequence< rendering::RGBColor >& rgbColor ) throw (lang::IllegalArgumentException, uno::RuntimeException) + { + const rendering::RGBColor* pIn( rgbColor.getConstArray() ); + const sal_Size nLen( rgbColor.getLength() ); + + uno::Sequence< double > aRes(nLen*4); + double* pColors=aRes.getArray(); + for( sal_Size i=0; i<nLen; ++i ) + { + *pColors++ = pIn->Blue; + *pColors++ = pIn->Green; + *pColors++ = pIn->Red; + *pColors++ = 1.0; + ++pIn; + } + return aRes; + } + virtual uno::Sequence< double > SAL_CALL convertFromARGB( const uno::Sequence< rendering::ARGBColor >& rgbColor ) throw (lang::IllegalArgumentException, uno::RuntimeException) + { + const rendering::ARGBColor* pIn( rgbColor.getConstArray() ); + const sal_Size nLen( rgbColor.getLength() ); + + uno::Sequence< double > aRes(nLen*4); + double* pColors=aRes.getArray(); + for( sal_Size i=0; i<nLen; ++i ) + { + *pColors++ = pIn->Alpha*pIn->Blue; + *pColors++ = pIn->Alpha*pIn->Green; + *pColors++ = pIn->Alpha*pIn->Red; + *pColors++ = pIn->Alpha; + ++pIn; + } + return aRes; + } + virtual uno::Sequence< double > SAL_CALL convertFromPARGB( const uno::Sequence< rendering::ARGBColor >& rgbColor ) throw (lang::IllegalArgumentException, uno::RuntimeException) + { + const rendering::ARGBColor* pIn( rgbColor.getConstArray() ); + const sal_Size nLen( rgbColor.getLength() ); + + uno::Sequence< double > aRes(nLen*4); + double* pColors=aRes.getArray(); + for( sal_Size i=0; i<nLen; ++i ) + { + *pColors++ = pIn->Blue; + *pColors++ = pIn->Green; + *pColors++ = pIn->Red; + *pColors++ = pIn->Alpha; + ++pIn; + } + return aRes; + } + + // XIntegerBitmapColorSpace + virtual ::sal_Int32 SAL_CALL getBitsPerPixel( ) throw (uno::RuntimeException) + { + return 32; + } + virtual uno::Sequence< ::sal_Int32 > SAL_CALL getComponentBitCounts( ) throw (uno::RuntimeException) + { + return maBitCounts; + } + virtual ::sal_Int8 SAL_CALL getEndianness( ) throw (uno::RuntimeException) + { + return util::Endianness::LITTLE; + } + virtual uno::Sequence<double> SAL_CALL convertFromIntegerColorSpace( const uno::Sequence< ::sal_Int8 >& deviceColor, + const uno::Reference< rendering::XColorSpace >& targetColorSpace ) throw (lang::IllegalArgumentException, + uno::RuntimeException) + { + if( dynamic_cast<CairoColorSpace*>(targetColorSpace.get()) ) + { + const sal_Int8* pIn( deviceColor.getConstArray() ); + const sal_Size nLen( deviceColor.getLength() ); + ENSURE_ARG_OR_THROW2(nLen%4==0, + "number of channels no multiple of 4", + static_cast<rendering::XColorSpace*>(this), 0); + + uno::Sequence<double> aRes(nLen); + double* pOut( aRes.getArray() ); + for( sal_Size i=0; i<nLen; i+=4 ) + { + *pOut++ = vcl::unotools::toDoubleColor(*pIn++); + *pOut++ = vcl::unotools::toDoubleColor(*pIn++); + *pOut++ = vcl::unotools::toDoubleColor(*pIn++); + *pOut++ = vcl::unotools::toDoubleColor(*pIn++); + } + return aRes; + } + else + { + // TODO(P3): if we know anything about target + // colorspace, this can be greatly sped up + uno::Sequence<rendering::ARGBColor> aIntermediate( + convertIntegerToARGB(deviceColor)); + return targetColorSpace->convertFromARGB(aIntermediate); + } + } + virtual uno::Sequence< ::sal_Int8 > SAL_CALL convertToIntegerColorSpace( const uno::Sequence< ::sal_Int8 >& deviceColor, + const uno::Reference< rendering::XIntegerBitmapColorSpace >& targetColorSpace ) throw (lang::IllegalArgumentException, + uno::RuntimeException) + { + if( dynamic_cast<CairoColorSpace*>(targetColorSpace.get()) ) + { + // it's us, so simply pass-through the data + return deviceColor; + } + else + { + // TODO(P3): if we know anything about target + // colorspace, this can be greatly sped up + uno::Sequence<rendering::ARGBColor> aIntermediate( + convertIntegerToARGB(deviceColor)); + return targetColorSpace->convertIntegerFromARGB(aIntermediate); + } + } + virtual uno::Sequence< rendering::RGBColor > SAL_CALL convertIntegerToRGB( const uno::Sequence< ::sal_Int8 >& deviceColor ) throw (lang::IllegalArgumentException, uno::RuntimeException) + { + const sal_Int8* pIn( deviceColor.getConstArray() ); + const sal_Size nLen( deviceColor.getLength() ); + ENSURE_ARG_OR_THROW2(nLen%4==0, + "number of channels no multiple of 4", + static_cast<rendering::XColorSpace*>(this), 0); + + uno::Sequence< rendering::RGBColor > aRes(nLen/4); + rendering::RGBColor* pOut( aRes.getArray() ); + for( sal_Size i=0; i<nLen; i+=4 ) + { + const sal_Int8 nAlpha(pIn[3]); + if( nAlpha ) + *pOut++ = rendering::RGBColor( + vcl::unotools::toDoubleColor(pIn[2]/nAlpha), + vcl::unotools::toDoubleColor(pIn[1]/nAlpha), + vcl::unotools::toDoubleColor(pIn[0]/nAlpha)); + else + *pOut++ = rendering::RGBColor(0,0,0); + pIn += 4; + } + return aRes; + } + + virtual uno::Sequence< rendering::ARGBColor > SAL_CALL convertIntegerToARGB( const uno::Sequence< ::sal_Int8 >& deviceColor ) throw (lang::IllegalArgumentException, uno::RuntimeException) + { + const sal_Int8* pIn( deviceColor.getConstArray() ); + const sal_Size nLen( deviceColor.getLength() ); + ENSURE_ARG_OR_THROW2(nLen%4==0, + "number of channels no multiple of 4", + static_cast<rendering::XColorSpace*>(this), 0); + + uno::Sequence< rendering::ARGBColor > aRes(nLen/4); + rendering::ARGBColor* pOut( aRes.getArray() ); + for( sal_Size i=0; i<nLen; i+=4 ) + { + const sal_Int8 nAlpha(pIn[3]); + if( nAlpha ) + *pOut++ = rendering::ARGBColor( + vcl::unotools::toDoubleColor(nAlpha), + vcl::unotools::toDoubleColor(pIn[2]/nAlpha), + vcl::unotools::toDoubleColor(pIn[1]/nAlpha), + vcl::unotools::toDoubleColor(pIn[0]/nAlpha)); + else + *pOut++ = rendering::ARGBColor(0,0,0,0); + pIn += 4; + } + return aRes; + } + virtual uno::Sequence< rendering::ARGBColor > SAL_CALL convertIntegerToPARGB( const uno::Sequence< ::sal_Int8 >& deviceColor ) throw (lang::IllegalArgumentException, uno::RuntimeException) + { + const sal_Int8* pIn( deviceColor.getConstArray() ); + const sal_Size nLen( deviceColor.getLength() ); + ENSURE_ARG_OR_THROW2(nLen%4==0, + "number of channels no multiple of 4", + static_cast<rendering::XColorSpace*>(this), 0); + + uno::Sequence< rendering::ARGBColor > aRes(nLen/4); + rendering::ARGBColor* pOut( aRes.getArray() ); + for( sal_Size i=0; i<nLen; i+=4 ) + { + *pOut++ = rendering::ARGBColor( + vcl::unotools::toDoubleColor(pIn[3]), + vcl::unotools::toDoubleColor(pIn[2]), + vcl::unotools::toDoubleColor(pIn[1]), + vcl::unotools::toDoubleColor(pIn[0])); + pIn += 4; + } + return aRes; + } + + virtual uno::Sequence< ::sal_Int8 > SAL_CALL convertIntegerFromRGB( const uno::Sequence< rendering::RGBColor >& rgbColor ) throw (lang::IllegalArgumentException, uno::RuntimeException) + { + const rendering::RGBColor* pIn( rgbColor.getConstArray() ); + const sal_Size nLen( rgbColor.getLength() ); + + uno::Sequence< sal_Int8 > aRes(nLen*4); + sal_Int8* pColors=aRes.getArray(); + for( sal_Size i=0; i<nLen; ++i ) + { + *pColors++ = vcl::unotools::toByteColor(pIn->Blue); + *pColors++ = vcl::unotools::toByteColor(pIn->Green); + *pColors++ = vcl::unotools::toByteColor(pIn->Red); + *pColors++ = 255; + ++pIn; + } + return aRes; + } + + virtual uno::Sequence< ::sal_Int8 > SAL_CALL convertIntegerFromARGB( const uno::Sequence< rendering::ARGBColor >& rgbColor ) throw (lang::IllegalArgumentException, uno::RuntimeException) + { + const rendering::ARGBColor* pIn( rgbColor.getConstArray() ); + const sal_Size nLen( rgbColor.getLength() ); + + uno::Sequence< sal_Int8 > aRes(nLen*4); + sal_Int8* pColors=aRes.getArray(); + for( sal_Size i=0; i<nLen; ++i ) + { + const double fAlpha(pIn->Alpha); + *pColors++ = vcl::unotools::toByteColor(fAlpha*pIn->Blue); + *pColors++ = vcl::unotools::toByteColor(fAlpha*pIn->Green); + *pColors++ = vcl::unotools::toByteColor(fAlpha*pIn->Red); + *pColors++ = vcl::unotools::toByteColor(fAlpha); + ++pIn; + } + return aRes; + } + virtual uno::Sequence< ::sal_Int8 > SAL_CALL convertIntegerFromPARGB( const uno::Sequence< rendering::ARGBColor >& rgbColor ) throw (lang::IllegalArgumentException, uno::RuntimeException) + { + const rendering::ARGBColor* pIn( rgbColor.getConstArray() ); + const sal_Size nLen( rgbColor.getLength() ); + + uno::Sequence< sal_Int8 > aRes(nLen*4); + sal_Int8* pColors=aRes.getArray(); + for( sal_Size i=0; i<nLen; ++i ) + { + *pColors++ = vcl::unotools::toByteColor(pIn->Blue); + *pColors++ = vcl::unotools::toByteColor(pIn->Green); + *pColors++ = vcl::unotools::toByteColor(pIn->Red); + *pColors++ = vcl::unotools::toByteColor(pIn->Alpha); + ++pIn; + } + return aRes; + } + + public: + CairoColorSpace() : + maComponentTags(4), + maBitCounts(4) + { + sal_Int8* pTags = maComponentTags.getArray(); + sal_Int32* pBitCounts = maBitCounts.getArray(); + pTags[0] = rendering::ColorComponentTag::RGB_BLUE; + pTags[1] = rendering::ColorComponentTag::RGB_GREEN; + pTags[2] = rendering::ColorComponentTag::RGB_RED; + pTags[3] = rendering::ColorComponentTag::PREMULTIPLIED_ALPHA; + + pBitCounts[0] = + pBitCounts[1] = + pBitCounts[2] = + pBitCounts[3] = 8; + } + }; + + struct CairoColorSpaceHolder : public rtl::StaticWithInit<uno::Reference<rendering::XIntegerBitmapColorSpace>, + CairoColorSpaceHolder> + { + uno::Reference<rendering::XIntegerBitmapColorSpace> operator()() + { + return new CairoColorSpace(); + } + }; + } + rendering::IntegerBitmapLayout CanvasHelper::getMemoryLayout() { if( !mpCairo ) return rendering::IntegerBitmapLayout(); // we're disposed - return ::canvas::tools::getStdMemoryLayout(getSize()); + const geometry::IntegerSize2D aSize(getSize()); + rendering::IntegerBitmapLayout aLayout; + + aLayout.ScanLines = aSize.Height; + aLayout.ScanLineBytes = aSize.Width*4; + aLayout.ScanLineStride = aLayout.ScanLineBytes; + aLayout.PlaneStride = 0; + aLayout.ColorSpace = CairoColorSpaceHolder::get(); + aLayout.Palette.clear(); + aLayout.IsMsbFirst = sal_False; + + return aLayout; } void CanvasHelper::flush() const diff --git a/canvas/source/directx/dx_bitmapcanvashelper.cxx b/canvas/source/directx/dx_bitmapcanvashelper.cxx index 83a85762cf35..467b91dec1d7 100755 --- a/canvas/source/directx/dx_bitmapcanvashelper.cxx +++ b/canvas/source/directx/dx_bitmapcanvashelper.cxx @@ -180,6 +180,7 @@ namespace dxcanvas if( !mpTarget ) return uno::Sequence< sal_Int8 >(); + bitmapLayout = getMemoryLayout(); return mpTarget->getData(bitmapLayout,rect); } @@ -224,6 +225,7 @@ namespace dxcanvas if( !mpTarget ) return uno::Sequence< sal_Int8 >(); + bitmapLayout = getMemoryLayout(); return mpTarget->getPixel(bitmapLayout,pos); } diff --git a/canvas/source/tools/canvastools.cxx b/canvas/source/tools/canvastools.cxx index 81dbd0498df6..23d6124e4cb8 100644 --- a/canvas/source/tools/canvastools.cxx +++ b/canvas/source/tools/canvastools.cxx @@ -333,6 +333,23 @@ namespace canvas } return aRes; } + virtual uno::Sequence< rendering::ARGBColor > SAL_CALL convertToPARGB( const uno::Sequence< double >& deviceColor ) throw (lang::IllegalArgumentException, uno::RuntimeException) + { + const double* pIn( deviceColor.getConstArray() ); + const sal_Size nLen( deviceColor.getLength() ); + ENSURE_ARG_OR_THROW2(nLen%4==0, + "number of channels no multiple of 4", + static_cast<rendering::XColorSpace*>(this), 0); + + uno::Sequence< rendering::ARGBColor > aRes(nLen/4); + rendering::ARGBColor* pOut( aRes.getArray() ); + for( sal_Size i=0; i<nLen; i+=4 ) + { + *pOut++ = rendering::ARGBColor(pIn[3],pIn[3]*pIn[0],pIn[3]*pIn[1],pIn[3]*pIn[2]); + pIn += 4; + } + return aRes; + } virtual uno::Sequence< double > SAL_CALL convertFromRGB( const uno::Sequence< rendering::RGBColor >& rgbColor ) throw (lang::IllegalArgumentException, uno::RuntimeException) { const rendering::RGBColor* pIn( rgbColor.getConstArray() ); @@ -367,6 +384,23 @@ namespace canvas } return aRes; } + virtual uno::Sequence< double > SAL_CALL convertFromPARGB( const uno::Sequence< rendering::ARGBColor >& rgbColor ) throw (lang::IllegalArgumentException, uno::RuntimeException) + { + const rendering::ARGBColor* pIn( rgbColor.getConstArray() ); + const sal_Size nLen( rgbColor.getLength() ); + + uno::Sequence< double > aRes(nLen*4); + double* pColors=aRes.getArray(); + for( sal_Size i=0; i<nLen; ++i ) + { + *pColors++ = pIn->Red/pIn->Alpha; + *pColors++ = pIn->Green/pIn->Alpha; + *pColors++ = pIn->Blue/pIn->Alpha; + *pColors++ = pIn->Alpha; + ++pIn; + } + return aRes; + } // XIntegerBitmapColorSpace virtual ::sal_Int32 SAL_CALL getBitsPerPixel( ) throw (uno::RuntimeException) @@ -474,6 +508,29 @@ namespace canvas return aRes; } + virtual uno::Sequence< rendering::ARGBColor > SAL_CALL convertIntegerToPARGB( const uno::Sequence< ::sal_Int8 >& deviceColor ) throw (lang::IllegalArgumentException, uno::RuntimeException) + { + const sal_Int8* pIn( deviceColor.getConstArray() ); + const sal_Size nLen( deviceColor.getLength() ); + ENSURE_ARG_OR_THROW2(nLen%4==0, + "number of channels no multiple of 4", + static_cast<rendering::XColorSpace*>(this), 0); + + uno::Sequence< rendering::ARGBColor > aRes(nLen/4); + rendering::ARGBColor* pOut( aRes.getArray() ); + for( sal_Size i=0; i<nLen; i+=4 ) + { + const sal_Int8 nAlpha( 255-pIn[3] ); + *pOut++ = rendering::ARGBColor( + vcl::unotools::toDoubleColor(nAlpha), + vcl::unotools::toDoubleColor(nAlpha*pIn[0]), + vcl::unotools::toDoubleColor(nAlpha*pIn[1]), + vcl::unotools::toDoubleColor(nAlpha*pIn[2])); + pIn += 4; + } + return aRes; + } + virtual uno::Sequence< ::sal_Int8 > SAL_CALL convertIntegerFromRGB( const uno::Sequence< rendering::RGBColor >& rgbColor ) throw (lang::IllegalArgumentException, uno::RuntimeException) { const rendering::RGBColor* pIn( rgbColor.getConstArray() ); @@ -510,6 +567,24 @@ namespace canvas return aRes; } + virtual uno::Sequence< ::sal_Int8 > SAL_CALL convertIntegerFromPARGB( const uno::Sequence< rendering::ARGBColor >& rgbColor ) throw (lang::IllegalArgumentException, uno::RuntimeException) + { + const rendering::ARGBColor* pIn( rgbColor.getConstArray() ); + const sal_Size nLen( rgbColor.getLength() ); + + uno::Sequence< sal_Int8 > aRes(nLen*4); + sal_Int8* pColors=aRes.getArray(); + for( sal_Size i=0; i<nLen; ++i ) + { + *pColors++ = vcl::unotools::toByteColor(pIn->Red/pIn->Alpha); + *pColors++ = vcl::unotools::toByteColor(pIn->Green/pIn->Alpha); + *pColors++ = vcl::unotools::toByteColor(pIn->Blue/pIn->Alpha); + *pColors++ = 255-vcl::unotools::toByteColor(pIn->Alpha); + ++pIn; + } + return aRes; + } + public: StandardColorSpace() : maComponentTags(4), diff --git a/canvas/source/vcl/canvashelper.cxx b/canvas/source/vcl/canvashelper.cxx index 8f634d99bf7f..20b489144d0e 100644 --- a/canvas/source/vcl/canvashelper.cxx +++ b/canvas/source/vcl/canvashelper.cxx @@ -147,6 +147,7 @@ namespace vclcanvas void CanvasHelper::setBackgroundOutDev( const OutDevProviderSharedPtr& rOutDev ) { mp2ndOutDev = rOutDev; + mp2ndOutDev->getOutDev().EnableMapMode( FALSE ); } void CanvasHelper::clear() @@ -155,6 +156,7 @@ namespace vclcanvas if( mpOutDev ) { OutputDevice& rOutDev( mpOutDev->getOutDev() ); + tools::OutDevStateKeeper aStateKeeper( mpProtectedOutDev ); rOutDev.EnableMapMode( FALSE ); rOutDev.SetLineColor( COL_WHITE ); @@ -188,7 +190,6 @@ namespace vclcanvas { // nope, render tools::OutDevStateKeeper aStateKeeper( mpProtectedOutDev ); - setupOutDevState( viewState, renderState, LINE_COLOR ); const Point aOutPoint( tools::mapRealPoint2D( aPoint, @@ -212,7 +213,6 @@ namespace vclcanvas { // nope, render tools::OutDevStateKeeper aStateKeeper( mpProtectedOutDev ); - setupOutDevState( viewState, renderState, LINE_COLOR ); const Point aStartPoint( tools::mapRealPoint2D( aStartRealPoint2D, @@ -236,7 +236,6 @@ namespace vclcanvas if( mpOutDev ) { tools::OutDevStateKeeper aStateKeeper( mpProtectedOutDev ); - setupOutDevState( viewState, renderState, LINE_COLOR ); const Point& rStartPoint( tools::mapRealPoint2D( geometry::RealPoint2D(aBezierSegment.Px, @@ -279,7 +278,6 @@ namespace vclcanvas if( mpOutDev ) { tools::OutDevStateKeeper aStateKeeper( mpProtectedOutDev ); - setupOutDevState( viewState, renderState, LINE_COLOR ); const ::basegfx::B2DPolyPolygon& rPolyPoly( @@ -688,7 +686,6 @@ namespace vclcanvas if( mpOutDev ) { tools::OutDevStateKeeper aStateKeeper( mpProtectedOutDev ); - setupOutDevState( viewState, renderState, IGNORE_COLOR ); ::basegfx::B2DHomMatrix aMatrix; @@ -916,11 +913,16 @@ namespace vclcanvas if( !mpOutDev.get() || !mpDevice ) return uno::Reference< rendering::XBitmap >(); // we're disposed + OutputDevice& rOutDev( mpOutDev->getOutDev() ); + + tools::OutDevStateKeeper aStateKeeper( mpProtectedOutDev ); + rOutDev.EnableMapMode( FALSE ); + // TODO(F2): Support alpha vdev canvas here const Point aEmptyPoint(0,0); - const Size aBmpSize( mpOutDev->getOutDev().GetOutputSizePixel() ); + const Size aBmpSize( rOutDev.GetOutputSizePixel() ); - Bitmap aBitmap( mpOutDev->getOutDev().GetBitmap(aEmptyPoint, aBmpSize) ); + Bitmap aBitmap( rOutDev.GetBitmap(aEmptyPoint, aBmpSize) ); aBitmap.Scale( ::vcl::unotools::sizeFromRealSize2D(newSize), beFast ? BMP_SCALE_FAST : BMP_SCALE_INTERPOLATE ); @@ -940,8 +942,13 @@ namespace vclcanvas // TODO(F2): Support alpha canvas here const Rectangle aRect( ::vcl::unotools::rectangleFromIntegerRectangle2D(rect) ); - Bitmap aBitmap( mpOutDev->getOutDev().GetBitmap(aRect.TopLeft(), - aRect.GetSize()) ); + OutputDevice& rOutDev( mpOutDev->getOutDev() ); + + tools::OutDevStateKeeper aStateKeeper( mpProtectedOutDev ); + rOutDev.EnableMapMode( FALSE ); + + Bitmap aBitmap( rOutDev.GetBitmap(aRect.TopLeft(), + aRect.GetSize()) ); ScopedBitmapReadAccess pReadAccess( aBitmap.AcquireReadAccess(), aBitmap ); @@ -990,6 +997,9 @@ namespace vclcanvas OutputDevice& rOutDev( mpOutDev->getOutDev() ); + tools::OutDevStateKeeper aStateKeeper( mpProtectedOutDev ); + rOutDev.EnableMapMode( FALSE ); + const Rectangle aRect( ::vcl::unotools::rectangleFromIntegerRectangle2D(rect) ); const USHORT nBitCount( ::std::min( (USHORT)24U, (USHORT)rOutDev.GetBitCount() ) ); @@ -1099,10 +1109,7 @@ namespace vclcanvas // destroyed beforehand if( bCopyBack ) { - tools::OutDevStateKeeper aStateKeeper( mpProtectedOutDev ); - // TODO(F2): Support alpha canvas here - rOutDev.EnableMapMode( FALSE ); rOutDev.DrawBitmap(aRect.TopLeft(), aBitmap); } } @@ -1115,6 +1122,10 @@ namespace vclcanvas return; // we're disposed OutputDevice& rOutDev( mpOutDev->getOutDev() ); + + tools::OutDevStateKeeper aStateKeeper( mpProtectedOutDev ); + rOutDev.EnableMapMode( FALSE ); + const Size aBmpSize( rOutDev.GetOutputSizePixel() ); ENSURE_ARG_OR_THROW( pos.X >= 0 && pos.X < aBmpSize.Width(), @@ -1131,10 +1142,6 @@ namespace vclcanvas aRefLayout.IsMsbFirst != rLayout.IsMsbFirst, "Mismatching memory layout" ); - tools::OutDevStateKeeper aStateKeeper( mpProtectedOutDev ); - - rOutDev.EnableMapMode( FALSE ); - // TODO(F2): Support alpha canvas here rOutDev.DrawPixel( ::vcl::unotools::pointFromIntegerPoint2D( pos ), ::canvas::tools::stdIntSequenceToColor( color )); @@ -1153,6 +1160,9 @@ namespace vclcanvas OutputDevice& rOutDev( mpOutDev->getOutDev() ); + tools::OutDevStateKeeper aStateKeeper( mpProtectedOutDev ); + rOutDev.EnableMapMode( FALSE ); + const Size aBmpSize( rOutDev.GetOutputSizePixel() ); ENSURE_ARG_OR_THROW( pos.X >= 0 && pos.X < aBmpSize.Width(), @@ -1160,10 +1170,6 @@ namespace vclcanvas ENSURE_ARG_OR_THROW( pos.Y >= 0 && pos.Y < aBmpSize.Height(), "Y coordinate out of bounds" ); - tools::OutDevStateKeeper aStateKeeper( mpProtectedOutDev ); - - rOutDev.EnableMapMode( FALSE ); - // TODO(F2): Support alpha canvas here return ::canvas::tools::colorToStdIntSequence( rOutDev.GetPixel( @@ -1194,6 +1200,8 @@ namespace vclcanvas OutputDevice& rOutDev( mpOutDev->getOutDev() ); OutputDevice* p2ndOutDev = NULL; + rOutDev.EnableMapMode( FALSE ); + if( mp2ndOutDev ) p2ndOutDev = &mp2ndOutDev->getOutDev(); @@ -1389,6 +1397,7 @@ namespace vclcanvas return false; // disposed else { + tools::OutDevStateKeeper aStateKeeper( mpProtectedOutDev ); setupOutDevState( viewState, renderState, IGNORE_COLOR ); if( !rGrf->Draw( &mpOutDev->getOutDev(), rPt, rSz, &rAttr ) ) |