summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Meeks <michael.meeks@collabora.com>2015-06-19 17:42:03 +0100
committerMichael Meeks <michael.meeks@collabora.com>2015-06-20 12:18:51 +0100
commit88b77c0b1866db0d729cc2c15b5d8d4f01e9630d (patch)
treed4e3e5e20b115775610d7cbdd30f19ed5ae639b6
parentec2549026ddf5ff8b5e1f5949a9adc537df23cdf (diff)
tdf#92194 - fix headless masking operations in vcl.
These were causing horrible rendering artifacts for all manner of headless rendering across Android & Online. A very simple fix in vcl, plus a set of tests. Change-Id: Ib261c0ea29d79ee6415e164c0b9b098efb52458b
-rw-r--r--basebmp/test/bmpmasktest.cxx66
-rw-r--r--vcl/headless/svpvd.cxx4
2 files changed, 66 insertions, 4 deletions
diff --git a/basebmp/test/bmpmasktest.cxx b/basebmp/test/bmpmasktest.cxx
index c9df8b20977d..46ec462cef5c 100644
--- a/basebmp/test/bmpmasktest.cxx
+++ b/basebmp/test/bmpmasktest.cxx
@@ -17,8 +17,6 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
-// autogenerated file with codegen.pl
-
#include <cppunit/TestAssert.h>
#include <cppunit/TestFixture.h>
#include <cppunit/extensions/HelperMacros.h>
@@ -142,6 +140,7 @@ public:
void testBmpBasics()
{
+ // mpDevice1bpp has a black rect. 0x0 -> 6x10
implTestBmpBasics( mpDevice1bpp, mpBmp1bpp );
implTestBmpBasics( mpDevice32bpp, mpBmp32bpp );
}
@@ -152,11 +151,74 @@ public:
implTestBmpScaledClip( mpDevice32bpp, mpBmp32bpp );
}
+ void testMasking()
+ {
+ BitmapDeviceSharedPtr xOutput;
+ BitmapDeviceSharedPtr xBitmap;
+ BitmapDeviceSharedPtr xMask;
+
+ { // mpMask & mpBitmap
+ const basegfx::B2ISize aSize(5, 5);
+ std::vector< basebmp::Color > aDevPal;
+ aDevPal.push_back( basebmp::Color( 0, 0, 0 ) );
+ aDevPal.push_back( basebmp::Color( 0xff, 0xff, 0xff ) );
+
+ basebmp::Format nFormat;
+
+ nFormat = Format::OneBitMsbPal;
+// nFormat = Format::OneBitMsbGrey; // FIXME - un-comment me to crash hard.
+ xMask = createBitmapDevice( aSize, false /* bTopDown */,
+ nFormat,
+ basebmp::getBitmapDeviceStrideForWidth( nFormat, aSize.getX()),
+ PaletteMemorySharedVector(
+ new std::vector< basebmp::Color >(aDevPal) ) );
+ // wipe to copy everything.
+ xMask->clear( basebmp::Color( 0x00, 0x00, 0x00 ) );
+
+ // punch out another piece not to copy
+ basegfx::B2DPolyPolygon aPoly;
+ basegfx::tools::importFromSvgD( aPoly, "m 2 2 h4 v8 h-4z",
+ false, NULL );
+ xMask->fillPolyPolygon( aPoly, basebmp::Color( 0xff, 0xff, 0xff ),
+ DrawMode::Paint );
+
+ xBitmap = createBitmapDevice( aSize, false,
+ Format::ThirtyTwoBitTcMaskBGRX,
+ basebmp::getBitmapDeviceStrideForWidth(
+ Format::ThirtyTwoBitTcMaskBGRX, aSize.getX()) );
+ xBitmap->clear(Color(0x80808080));
+ }
+ { // mpOutput & mpBitmap
+ const basegfx::B2ISize aSize(9, 9);
+ xOutput = createBitmapDevice( aSize, false,
+ Format::ThirtyTwoBitTcMaskBGRX,
+ basebmp::getBitmapDeviceStrideForWidth(
+ Format::ThirtyTwoBitTcMaskBGRX, aSize.getX()) );
+ xOutput->clear(Color(0xffffffff));
+ }
+
+ const basegfx::B2IBox aSourceRect(0,0,4,4);
+ const basegfx::B2IBox aDestAll(2,2,7,7);
+
+ xOutput->drawMaskedBitmap(
+ xBitmap, xMask,
+ aSourceRect, aDestAll,
+ DrawMode::Paint );
+
+ CPPUNIT_ASSERT_MESSAGE( "output not cleared to white",
+ xOutput->getPixelData( basegfx::B2IPoint( 0, 0 ) ) == 0xffffff );
+ CPPUNIT_ASSERT_MESSAGE( "bitmap not drawn",
+ xOutput->getPixelData( basegfx::B2IPoint( 2, 2 ) ) == 0x808080 );
+ CPPUNIT_ASSERT_MESSAGE( "mask not applied",
+ xOutput->getPixelData( basegfx::B2IPoint( 6, 6 ) ) == 0xffffff );
+ }
+
// Change the following lines only, if you add, remove or rename
// member functions of the current class,
// because these macros are need by auto register mechanism.
CPPUNIT_TEST_SUITE(BmpMaskTest);
+ CPPUNIT_TEST(testMasking);
CPPUNIT_TEST(testBmpBasics);
CPPUNIT_TEST(testBmpClip);
CPPUNIT_TEST_SUITE_END();
diff --git a/vcl/headless/svpvd.cxx b/vcl/headless/svpvd.cxx
index f720d18f613c..1e4050a639cf 100644
--- a/vcl/headless/svpvd.cxx
+++ b/vcl/headless/svpvd.cxx
@@ -76,8 +76,8 @@ bool SvpSalVirtualDevice::SetSizeUsingBuffer( long nNewDX, long nNewDY,
if ( m_nBitCount == 1 )
{
std::vector< basebmp::Color > aDevPal(2);
- aDevPal.push_back( basebmp::Color( 0, 0, 0 ) );
- aDevPal.push_back( basebmp::Color( 0xff, 0xff, 0xff ) );
+ aDevPal[0] = basebmp::Color( 0, 0, 0 );
+ aDevPal[1] = basebmp::Color( 0xff, 0xff, 0xff );
m_aDevice = createBitmapDevice( aDevSize, bTopDown, nFormat, nStride,
PaletteMemorySharedVector( new std::vector< basebmp::Color >(aDevPal) ) );
}