[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: playground/graphics/okular/emf/emf
From: Brad Hards <bradh () frogmouth ! net>
Date: 2008-10-06 10:49:49
Message-ID: 1223290189.114510.31983.nullmailer () svn ! kde ! org
[Download RAW message or body]
SVN commit 868480 by bhards:
Add pyemf-selectclippath1.emf unit test examples, and
link into test suite and build system
Implement EMR_SAVEDC, EMR_RESTOREDC and EMR_SETCLIPPATH
record types, all required to render that test case.
The font positioning still isn't quite right.
M +13 -0 EnhEnums.h
M +18 -6 EnhMetaFile.cpp
M +53 -0 EnhOutput.cpp
M +27 -0 EnhOutput.h
M +1 -0 tests/CMakeLists.txt
AM tests/pyemf-selectclippath1.emf
M +11 -0 tests/pyemf_tests.cpp
M +1 -0 tests/pyemf_tests.h
--- trunk/playground/graphics/okular/emf/emf/EnhEnums.h #868479:868480
@@ -139,5 +139,18 @@
TRANSPARENT = 0x01, ///< Equivalent to Qt::TransparentMode
OPAQUE = 0x2 ///< Equivalent to Qt::OpaqueMode
};
+
+ /**
+ Clipping region mode
+
+ See [MS-EMF] Section 2.1.29
+ */
+ enum RegionMode {
+ RGN_AND = 0x01, ///< Equivalent to Qt::IntersectClip
+ RGN_OR = 0x02, ///< Equivalent to Qt::UniteClip
+ RGN_XOR = 0x03,
+ RGN_DIFF = 0x04,
+ RGN_COPY = 0x05 ///< Equivalent to Qt::ReplaceClip
+ };
}
#endif
--- trunk/playground/graphics/okular/emf/emf/EnhMetaFile.cpp #868479:868480
@@ -147,6 +147,7 @@
EMR_FILLPATH = 0x0000003E,
EMR_STROKEANDFILLPATH = 0x0000003F,
EMR_STROKEPATH = 0x00000040,
+ EMR_SETCLIPPATH = 0x00000043,
EMR_COMMENT = 0x00000046,
EMR_EXTSELECTCLIPRGN = 0x0000004B,
EMR_BITBLT = 0x0000004C,
@@ -291,13 +292,17 @@
soakBytes( stream, size-8 ); // because we already took 8.
break;
case EMR_SAVEDC:
- qDebug() << "EMR_SAVEDC";
- soakBytes( stream, size-8 ); // because we already took 8.
- break;
+ {
+ mOutput->saveDC();
+ }
+ break;
case EMR_RESTOREDC:
- qDebug() << "EMR_RESTOREDC";
- soakBytes( stream, size-8 ); // because we already took 8.
- break;
+ {
+ qint32 savedDC;
+ stream >> savedDC;
+ mOutput->restoreDC( savedDC );
+ }
+ break;
case EMR_SETWORLDTRANSFORM:
{
float M11, M12, M21, M22, Dx, Dy;
@@ -458,6 +463,13 @@
mOutput->strokePath( bounds );
}
break;
+ case EMR_SETCLIPPATH:
+ {
+ quint32 regionMode;
+ stream >> regionMode;
+ mOutput->setClipPath( regionMode );
+ }
+ break;
case EMR_LINETO:
{
quint32 x, y;
--- trunk/playground/graphics/okular/emf/emf/EnhOutput.cpp #868479:868480
@@ -65,6 +65,16 @@
qDebug() << "EMR_ENDPATH";
}
+void DebugOutput::saveDC()
+{
+ qDebug() << "EMR_SAVEDC";
+}
+
+void DebugOutput::restoreDC( qint32 savedDC )
+{
+ qDebug() << "EMR_RESTOREDC" << savedDC;
+}
+
void DebugOutput::setWindowExtEx( const QSize &size )
{
qDebug() << "EMR_SETWINDOWEXTEX" << size;
@@ -290,6 +300,11 @@
qDebug() << "EMR_STROKEPATH" << bounds;
}
+void DebugOutput::setClipPath( quint32 regionMode )
+{
+ qDebug() << "EMR_SETCLIPPATH:" << regionMode;
+}
+
void DebugOutput::bitBlt( const BitBltRecord bitBltRecord )
{
qDebug() << "EMR_BITBLT:" << bitBltRecord.destinationRectangle();
@@ -364,6 +379,18 @@
m_currentlyBuildingPath = false;
}
+void PainterOutput::saveDC()
+{
+ m_painter->save();
+}
+
+void PainterOutput::restoreDC( qint32 savedDC )
+{
+ for (int i = -1; i >= savedDC; --i) {
+ m_painter->restore();
+ }
+}
+
void PainterOutput:: setWindowExtEx( const QSize &size )
{
m_painter->setWindow( QRect( QPoint(0, 0), size ) );
@@ -888,6 +915,32 @@
m_painter->strokePath( *m_path, m_painter->pen() );
}
+void PainterOutput::setClipPath( quint32 regionMode )
+{
+ switch ( regionMode ) {
+ case RGN_AND:
+ {
+ m_painter->setClipPath( *m_path, Qt::IntersectClip );
+ }
+ break;
+ case RGN_OR:
+ {
+ m_painter->setClipPath( *m_path, Qt::UniteClip );
+ }
+ break;
+ case RGN_COPY:
+ {
+ m_painter->setClipPath( *m_path, Qt::ReplaceClip );
+ }
+ break;
+ default:
+ {
+ qWarning() << "Unexpected / unsupported clip region mode:" << \
regionMode; + Q_ASSERT( 0 );
+ }
+ }
+}
+
bool PainterOutput::currentlyBuildingPath() const
{
return ( m_currentlyBuildingPath );
--- trunk/playground/graphics/okular/emf/emf/EnhOutput.h #868479:868480
@@ -323,6 +323,18 @@
virtual void moveToEx( const quint32 x, const quint32 y ) = 0;
/**
+ Handler for the EMR_SAVEDC record type
+ */
+ virtual void saveDC() = 0;
+
+ /**
+ Handler for the EMR_RESTOREDC record type
+
+ \param savedDC the device context to restore to (always negative)
+ */
+ virtual void restoreDC( qint32 savedDC ) = 0;
+
+ /**
Handler for the EMR_LINETO record type
\param finishPoint the point to draw to
@@ -466,6 +478,15 @@
virtual void strokePath( const QRect &bounds ) = 0;
/**
+ Handler for the EMR_SETCLIPPATH record type.
+
+ See [MS-EMF] Section 2.1.29 for valid ways to set the path.
+
+ \param regionMode how to set the clipping path.
+ */
+ virtual void setClipPath( quint32 regionMode ) = 0;
+
+ /**
Handler for the EMR_BITBLT record type
\param bitBltRecord contents of the record type
@@ -525,6 +546,8 @@
void extTextOutA( const ExtTextOutARecord &extTextOutA );
void extTextOutW( const QPoint &referencePoint, const QString textString );
void moveToEx( const quint32 x, const quint32 y );
+ void saveDC();
+ void restoreDC( qint32 savedDC );
void lineTo( const QPoint &finishPoint );
void arcTo( const QRect &box, const QPoint &start, const QPoint &end );
void polygon16( const QRect &bounds, const QList<QPoint> points );
@@ -538,6 +561,7 @@
void fillPath( const QRect &bounds );
void strokeAndFillPath( const QRect &bounds );
void strokePath( const QRect &bounds );
+ void setClipPath( quint32 regionMode );
void bitBlt( BitBltRecord bitBltRecord );
void stretchDiBits( StretchDiBitsRecord stretchDiBitsRecord );
};
@@ -601,6 +625,8 @@
void extTextOutA( const ExtTextOutARecord &extTextOutA );
void extTextOutW( const QPoint &referencePoint, const QString textString );
void moveToEx( const quint32 x, const quint32 y );
+ void saveDC();
+ void restoreDC( qint32 savedDC );
void lineTo( const QPoint &finishPoint );
void arcTo( const QRect &box, const QPoint &start, const QPoint &end );
void polygon16( const QRect &bounds, const QList<QPoint> points );
@@ -614,6 +640,7 @@
void fillPath( const QRect &bounds );
void strokeAndFillPath( const QRect &bounds );
void strokePath( const QRect &bounds );
+ void setClipPath( quint32 regionMode );
void bitBlt( BitBltRecord bitBltRecord );
void stretchDiBits( StretchDiBitsRecord stretchDiBitsRecord );
--- trunk/playground/graphics/okular/emf/emf/tests/CMakeLists.txt #868479:868480
@@ -42,6 +42,7 @@
CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/pyemf-paths1.emf \
${CMAKE_CURRENT_BINARY_DIR}/pyemf-paths1.emf COPYONLY) \
CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/pyemf-poly1.emf \
${CMAKE_CURRENT_BINARY_DIR}/pyemf-poly1.emf COPYONLY) \
CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/pyemf-poly2.emf \
${CMAKE_CURRENT_BINARY_DIR}/pyemf-poly2.emf COPYONLY) \
+CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/pyemf-selectclippath1.emf \
${CMAKE_CURRENT_BINARY_DIR}/pyemf-selectclippath1.emf COPYONLY) \
CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/pyemf-setpixel.emf \
${CMAKE_CURRENT_BINARY_DIR}/pyemf-setpixel.emf COPYONLY)
SET( visio_tests_bin_SRCS visio_tests.cpp )
** trunk/playground/graphics/okular/emf/emf/tests/pyemf-selectclippath1.emf #property \
svn:mime-type + application/octet-stream
--- trunk/playground/graphics/okular/emf/emf/tests/pyemf_tests.cpp #868479:868480
@@ -671,5 +671,16 @@
QVERIFY( parser.load( QString("pyemf-poly2.emf") ) );
}
+void PyEmfTests::testSetClipPath()
+{
+ QTest::ignoreMessage( QtDebugMsg, "Initialising DebugOutput " );
+ QTest::ignoreMessage( QtDebugMsg, "image size: QSize(901, 601) " );
+ QTest::ignoreMessage( QtDebugMsg, "EMR_EOF " );
+ Parser parser;
+ DebugOutput output;
+ parser.setOutput( &output );
+ QVERIFY( parser.load( QString("pyemf-selectclippath1.emf") ) );
+}
+
QTEST_MAIN( PyEmfTests )
#include "pyemf_tests.moc"
--- trunk/playground/graphics/okular/emf/emf/tests/pyemf_tests.h #868479:868480
@@ -33,6 +33,7 @@
void testPaths1();
void testPoly1();
void testPoly2();
+ void testSetClipPath();
void testSetPixel();
};
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic