summaryrefslogtreecommitdiff
path: root/cppcanvas
diff options
context:
space:
mode:
authorRüdiger Timm <rt@openoffice.org>2005-03-30 07:25:50 +0000
committerRüdiger Timm <rt@openoffice.org>2005-03-30 07:25:50 +0000
commit8bc08eb8ed791267f0e082dd88fe3a2a85587a3d (patch)
tree5aab59b65e591f9a74e67189ee020d781956812c /cppcanvas
parentd72a92b8860221a33e11712489e658f2929c9cf9 (diff)
INTEGRATION: CWS presfixes02 (1.4.2); FILE MERGED
2005/03/14 16:04:51 thb 1.4.2.1: #i35136# #i36914# #i41113# #i44100# #i40115# #i41839# #i44404# Merge from presfixes01 patches
Diffstat (limited to 'cppcanvas')
-rw-r--r--cppcanvas/source/mtfrenderer/bitmapaction.cxx245
-rw-r--r--cppcanvas/source/mtfrenderer/bitmapaction.hxx70
2 files changed, 170 insertions, 145 deletions
diff --git a/cppcanvas/source/mtfrenderer/bitmapaction.cxx b/cppcanvas/source/mtfrenderer/bitmapaction.cxx
index 5f79bec138c4..fbfece7fad8e 100644
--- a/cppcanvas/source/mtfrenderer/bitmapaction.cxx
+++ b/cppcanvas/source/mtfrenderer/bitmapaction.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: bitmapaction.cxx,v $
*
- * $Revision: 1.4 $
+ * $Revision: 1.5 $
*
- * last change: $Author: vg $ $Date: 2005-03-10 13:23:37 $
+ * last change: $Author: rt $ $Date: 2005-03-30 08:25:13 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -68,6 +68,12 @@
#ifndef _COM_SUN_STAR_RENDERING_XBITMAP_HPP__
#include <com/sun/star/rendering/XBitmap.hpp>
#endif
+#ifndef _COM_SUN_STAR_RENDERING_REPAINTRESULT_HPP_
+#include <com/sun/star/rendering/RepaintResult.hpp>
+#endif
+#ifndef _COM_SUN_STAR_RENDERING_XCACHEDPRIMITIVE_HPP_
+#include <com/sun/star/rendering/XCachedPrimitive.hpp>
+#endif
#ifndef _SV_BITMAPEX_HXX
#include <vcl/bitmapex.hxx>
@@ -86,10 +92,15 @@
#ifndef _BGFX_MATRIX_B2DHOMMATRIX_HXX
#include <basegfx/matrix/b2dhommatrix.hxx>
#endif
+#ifndef _BGFX_VECTOR_B2DSIZE_HXX
+#include <basegfx/vector/b2dsize.hxx>
+#endif
#ifndef _BGFX_TOOLS_CANVASTOOLS_HXX
#include <basegfx/tools/canvastools.hxx>
#endif
+#include <boost/utility.hpp>
+
#include <mtftools.hxx>
@@ -99,127 +110,165 @@ namespace cppcanvas
{
namespace internal
{
- // free support functions
- // ======================
namespace
{
- /** Setup transformation such that the next render call is
- moved rPoint away.
- */
- void implSetupTransform( rendering::RenderState& rRenderState,
- const Point& rPoint )
+
+ class BitmapAction : public Action, private ::boost::noncopyable
{
- ::basegfx::B2DHomMatrix aLocalTransformation;
+ public:
+ BitmapAction( const ::BitmapEx&,
+ const ::Point& rDstPoint,
+ const CanvasSharedPtr&,
+ const OutDevState& );
+ BitmapAction( const ::BitmapEx&,
+ const ::Point& rDstPoint,
+ const ::Size& rDstSize,
+ const CanvasSharedPtr&,
+ const OutDevState& );
- aLocalTransformation.translate( rPoint.X(),
- rPoint.Y() );
- ::canvas::tools::appendToRenderState( rRenderState,
- aLocalTransformation );
- }
+ virtual bool render( const ::basegfx::B2DHomMatrix& rTransformation ) const;
+ virtual bool render( const ::basegfx::B2DHomMatrix& rTransformation,
+ const Subset& rSubset ) const;
+
+ virtual sal_Int32 getActionCount() const;
+
+ private:
+ uno::Reference< rendering::XBitmap > mxBitmap;
+ mutable uno::Reference< rendering::XCachedPrimitive > mxCachedBitmap;
+ mutable ::basegfx::B2DHomMatrix maLastTransformation;
+ CanvasSharedPtr mpCanvas;
+ rendering::RenderState maState;
+ };
- /** Setup transformation such that the next render call is
- moved rPoint away, and scaled according to the ratio
- given by src and dst size.
- */
- void implSetupTransform( rendering::RenderState& rRenderState,
- const Point& rPoint,
- const Size& rSrcSize,
- const Size& rDstSize )
+
+ BitmapAction::BitmapAction( const ::BitmapEx& rBmpEx,
+ const ::Point& rDstPoint,
+ const CanvasSharedPtr& rCanvas,
+ const OutDevState& rState ) :
+ mxBitmap( ::vcl::unotools::xBitmapFromBitmapEx( rCanvas->getUNOCanvas()->getDevice(),
+ rBmpEx ) ),
+ mxCachedBitmap(),
+ maLastTransformation(),
+ mpCanvas( rCanvas ),
+ maState()
{
- ::basegfx::B2DHomMatrix aLocalTransformation;
+ tools::initRenderState(maState,rState);
- aLocalTransformation.scale( static_cast<double>(rDstSize.Width()) / rSrcSize.Width(),
- static_cast<double>(rDstSize.Height()) / rSrcSize.Height() );
- aLocalTransformation.translate( rPoint.X(),
- rPoint.Y() );
- ::canvas::tools::appendToRenderState( rRenderState,
+ // Setup transformation such that the next render call is
+ // moved rPoint away.
+ ::basegfx::B2DHomMatrix aLocalTransformation;
+ aLocalTransformation.translate( rDstPoint.X(),
+ rDstPoint.Y() );
+ ::canvas::tools::appendToRenderState( maState,
aLocalTransformation );
+
+ // correct clip (which is relative to original transform)
+ tools::modifyClip( maState, rState, rCanvas, rDstPoint, NULL );
}
- /** Setup transformation such that the next render call
- paints the content given by the src area into the dst
- area. No clipping is set whatsoever.
- */
- void implSetupTransform( rendering::RenderState& rRenderState,
- const Point& rSrcPoint,
- const Size& rSrcSize,
- const Point& rDstPoint,
- const Size& rDstSize )
+ BitmapAction::BitmapAction( const ::BitmapEx& rBmpEx,
+ const ::Point& rDstPoint,
+ const ::Size& rDstSize,
+ const CanvasSharedPtr& rCanvas,
+ const OutDevState& rState ) :
+ mxBitmap( ::vcl::unotools::xBitmapFromBitmapEx( rCanvas->getUNOCanvas()->getDevice(),
+ rBmpEx ) ),
+ mxCachedBitmap(),
+ maLastTransformation(),
+ mpCanvas( rCanvas ),
+ maState()
{
+ tools::initRenderState(maState,rState);
+
+ // Setup transformation such that the next render call is
+ // moved rPoint away, and scaled according to the ratio
+ // given by src and dst size.
+ const ::Size aBmpSize( rBmpEx.GetSizePixel() );
::basegfx::B2DHomMatrix aLocalTransformation;
- aLocalTransformation.scale( static_cast<double>(rDstSize.Width()) / rSrcSize.Width(),
- static_cast<double>(rDstSize.Height()) / rSrcSize.Height() );
- aLocalTransformation.translate( rDstPoint.X() - rSrcPoint.X(),
- rDstPoint.Y() - rSrcPoint.Y() );
- ::canvas::tools::appendToRenderState( rRenderState,
+ const ::basegfx::B2DSize aScale( static_cast<double>(rDstSize.Width()) / aBmpSize.Width(),
+ static_cast<double>(rDstSize.Height()) / aBmpSize.Height() );
+ aLocalTransformation.scale( aScale.getX(), aScale.getY() );
+ aLocalTransformation.translate( rDstPoint.X(),
+ rDstPoint.Y() );
+ ::canvas::tools::appendToRenderState( maState,
aLocalTransformation );
+
+ // correct clip (which is relative to original transform)
+ tools::modifyClip( maState, rState, rCanvas, rDstPoint, &aScale );
}
- }
- BitmapAction::BitmapAction( const ::BitmapEx& rBmpEx,
- const ::Point& rDstPoint,
- const CanvasSharedPtr& rCanvas,
- const OutDevState& rState ) :
- mxBitmap( ::vcl::unotools::xBitmapFromBitmapEx( rCanvas->getUNOCanvas()->getDevice(),
- rBmpEx ) ),
- mpCanvas( rCanvas ),
- maState()
- {
- tools::initRenderState(maState,rState);
- implSetupTransform( maState, rDstPoint );
- }
+ bool BitmapAction::render( const ::basegfx::B2DHomMatrix& rTransformation ) const
+ {
+ RTL_LOGFILE_CONTEXT( aLog, "::cppcanvas::internal::BitmapAction::render()" );
+ RTL_LOGFILE_CONTEXT_TRACE1( aLog, "::cppcanvas::internal::BitmapAction: 0x%X", this );
- BitmapAction::BitmapAction( const ::BitmapEx& rBmpEx,
- const ::Point& rDstPoint,
- const ::Size& rDstSize,
- const CanvasSharedPtr& rCanvas,
- const OutDevState& rState ) :
- mxBitmap( ::vcl::unotools::xBitmapFromBitmapEx( rCanvas->getUNOCanvas()->getDevice(),
- rBmpEx ) ),
- mpCanvas( rCanvas ),
- maState()
- {
- tools::initRenderState(maState,rState);
- implSetupTransform( maState, rDstPoint, rBmpEx.GetSizePixel(), rDstSize );
- }
+ rendering::RenderState aLocalState( maState );
+ ::canvas::tools::prependToRenderState(aLocalState, rTransformation);
- BitmapAction::BitmapAction( const ::BitmapEx& rBmpEx,
- const ::Point& rSrcPoint,
- const ::Size& rSrcSize,
- const ::Point& rDstPoint,
- const ::Size& rDstSize,
- const CanvasSharedPtr& rCanvas,
- const OutDevState& rState ) :
- mxBitmap( ::vcl::unotools::xBitmapFromBitmapEx( rCanvas->getUNOCanvas()->getDevice(),
- rBmpEx ) ),
- mpCanvas( rCanvas ),
- maState()
- {
- tools::initRenderState(maState,rState);
+ const rendering::ViewState& rViewState( mpCanvas->getViewState() );
- // TODO(F2): setup clipping/extract only part of the bitmap
- implSetupTransform( maState, rSrcPoint, rSrcSize, rDstPoint, rDstSize );
- }
+ // can we use the cached bitmap?
+ if( mxCachedBitmap.is() &&
+ maLastTransformation == rTransformation )
+ {
+ if( mxCachedBitmap->redraw( rViewState ) ==
+ rendering::RepaintResult::REDRAWN )
+ {
+ // cached repaint succeeded, done.
+ return true;
+ }
+ }
- BitmapAction::~BitmapAction()
- {
- }
+ maLastTransformation = rTransformation;
- bool BitmapAction::render( const ::basegfx::B2DHomMatrix& rTransformation ) const
- {
- RTL_LOGFILE_CONTEXT( aLog, "::cppcanvas::internal::BitmapAction::render()" );
- RTL_LOGFILE_CONTEXT_TRACE1( aLog, "::cppcanvas::internal::BitmapAction: 0x%X", this );
+ mxCachedBitmap = mpCanvas->getUNOCanvas()->drawBitmap( mxBitmap,
+ rViewState,
+ aLocalState );
- rendering::RenderState aLocalState( maState );
- ::canvas::tools::prependToRenderState(aLocalState, rTransformation);
+ return true;
+ }
- mpCanvas->getUNOCanvas()->drawBitmap( mxBitmap,
- mpCanvas->getViewState(),
- aLocalState );
+ bool BitmapAction::render( const ::basegfx::B2DHomMatrix& rTransformation,
+ const Subset& rSubset ) const
+ {
+ // bitmap only contains a single action, fail if subset
+ // requests different range
+ if( rSubset.mnSubsetBegin != 0 ||
+ rSubset.mnSubsetEnd != 1 )
+ return false;
- return true;
+ return render( rTransformation );
+ }
+
+ sal_Int32 BitmapAction::getActionCount() const
+ {
+ return 1;
+ }
}
+ ActionSharedPtr BitmapActionFactory::createBitmapAction( const ::BitmapEx& rBmpEx,
+ const ::Point& rDstPoint,
+ const CanvasSharedPtr& rCanvas,
+ const OutDevState& rState )
+ {
+ return ActionSharedPtr( new BitmapAction(rBmpEx,
+ rDstPoint,
+ rCanvas,
+ rState ) );
+ }
+
+ ActionSharedPtr BitmapActionFactory::createBitmapAction( const ::BitmapEx& rBmpEx,
+ const ::Point& rDstPoint,
+ const ::Size& rDstSize,
+ const CanvasSharedPtr& rCanvas,
+ const OutDevState& rState )
+ {
+ return ActionSharedPtr( new BitmapAction(rBmpEx,
+ rDstPoint,
+ rDstSize,
+ rCanvas,
+ rState ) );
+ }
}
}
diff --git a/cppcanvas/source/mtfrenderer/bitmapaction.hxx b/cppcanvas/source/mtfrenderer/bitmapaction.hxx
index 45fbc5860e4c..794192f8e956 100644
--- a/cppcanvas/source/mtfrenderer/bitmapaction.hxx
+++ b/cppcanvas/source/mtfrenderer/bitmapaction.hxx
@@ -2,9 +2,9 @@
*
* $RCSfile: bitmapaction.hxx,v $
*
- * $Revision: 1.4 $
+ * $Revision: 1.5 $
*
- * last change: $Author: vg $ $Date: 2005-03-10 13:23:58 $
+ * last change: $Author: rt $ $Date: 2005-03-30 08:25:50 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -62,28 +62,14 @@
#ifndef _CPPCANVAS_BITMAPACTION_HXX
#define _CPPCANVAS_BITMAPACTION_HXX
-#ifndef _COM_SUN_STAR_UNO_REFERENCE_HXX_
-#include <com/sun/star/uno/Reference.hxx>
-#endif
-
-#ifndef _COM_SUN_STAR_RENDERING_RENDERSTATE_HPP__
-#include <com/sun/star/rendering/RenderState.hpp>
-#endif
-
#include <cppcanvas/canvas.hxx>
#include <action.hxx>
class Point;
class Size;
class BitmapEx;
-class Color;
-namespace com { namespace sun { namespace star { namespace rendering
-{
- class XBitmap;
-} } } }
-
-/* Definition of internal::BitmapAction class */
+/* Definition of internal::BitmapActionFactory class */
namespace cppcanvas
{
@@ -91,45 +77,35 @@ namespace cppcanvas
{
struct OutDevState;
- /** Encapsulated converter between GDIMetaFile and
+ /** Creates encapsulated converters between GDIMetaFile and
XCanvas. The Canvas argument is deliberately placed at the
constructor, to force reconstruction of this object for a
new canvas. This considerably eases internal state
- handling, since a lot of the internal state
- (e.g. deviceColor) is Canvas-dependent.
+ handling, since a lot of the internal state (e.g. fonts,
+ text layout) is Canvas-dependent.
*/
- class BitmapAction : public Action
+ class BitmapActionFactory
{
public:
- BitmapAction( const ::BitmapEx&,
- const ::Point& rDstPoint,
- const CanvasSharedPtr&,
- const OutDevState& );
- BitmapAction( const ::BitmapEx&,
- const ::Point& rDstPoint,
- const ::Size& rDstSize,
- const CanvasSharedPtr&,
- const OutDevState& );
- BitmapAction( const ::BitmapEx&,
- const ::Point& rSrcPoint,
- const ::Size& rSrcSize,
- const ::Point& rDstPoint,
- const ::Size& rDstSize,
- const CanvasSharedPtr&,
- const OutDevState& );
- virtual ~BitmapAction();
+ /// Unscaled bitmap action, only references destination point
+ static ActionSharedPtr createBitmapAction( const ::BitmapEx&,
+ const ::Point& rDstPoint,
+ const CanvasSharedPtr&,
+ const OutDevState& );
- virtual bool render( const ::basegfx::B2DHomMatrix& rTransformation ) const;
+ /// Scaled bitmap action, dest point and dest size
+ static ActionSharedPtr createBitmapAction( const ::BitmapEx&,
+ const ::Point& rDstPoint,
+ const ::Size& rDstSize,
+ const CanvasSharedPtr&,
+ const OutDevState& );
private:
- // default: disabled copy/assignment
- BitmapAction(const BitmapAction&);
- BitmapAction& operator = ( const BitmapAction& );
-
- ::com::sun::star::uno::Reference<
- ::com::sun::star::rendering::XBitmap > mxBitmap;
- CanvasSharedPtr mpCanvas;
- ::com::sun::star::rendering::RenderState maState;
+ // static factory, disable big four
+ BitmapActionFactory();
+ ~BitmapActionFactory();
+ BitmapActionFactory(const BitmapActionFactory&);
+ BitmapActionFactory& operator=( const BitmapActionFactory& );
};
}
}