diff options
Diffstat (limited to 'canvas/inc/canvas/rendering')
-rw-r--r-- | canvas/inc/canvas/rendering/bitmap.hxx | 323 | ||||
-rw-r--r-- | canvas/inc/canvas/rendering/icachedprimitive.hxx | 69 | ||||
-rw-r--r-- | canvas/inc/canvas/rendering/icolorbuffer.hxx | 97 | ||||
-rw-r--r-- | canvas/inc/canvas/rendering/irendermodule.hxx | 152 | ||||
-rw-r--r-- | canvas/inc/canvas/rendering/isurface.hxx | 91 | ||||
-rw-r--r-- | canvas/inc/canvas/rendering/isurfaceproxy.hxx | 116 | ||||
-rw-r--r-- | canvas/inc/canvas/rendering/isurfaceproxymanager.hxx | 82 |
7 files changed, 930 insertions, 0 deletions
diff --git a/canvas/inc/canvas/rendering/bitmap.hxx b/canvas/inc/canvas/rendering/bitmap.hxx new file mode 100644 index 000000000000..b4e5e143bfd0 --- /dev/null +++ b/canvas/inc/canvas/rendering/bitmap.hxx @@ -0,0 +1,323 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: bitmap.hxx,v $ + * $Revision: 1.3 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef INCLUDED_CANVAS_BITMAP_HXX +#define INCLUDED_CANVAS_BITMAP_HXX + +#include <com/sun/star/uno/Reference.hxx> +#include <com/sun/star/rendering/XCanvas.hpp> +#include <com/sun/star/rendering/IntegerBitmapLayout.hpp> +#include <com/sun/star/geometry/IntegerRectangle2D.hpp> +#include <com/sun/star/geometry/IntegerPoint2D.hpp> +#include <canvas/rendering/icolorbuffer.hxx> +#include <canvas/rendering/icachedprimitive.hxx> +#include <canvas/rendering/isurfaceproxymanager.hxx> + +#include <boost/shared_ptr.hpp> +#include <boost/scoped_ptr.hpp> +#include <vector> + +namespace basegfx +{ + class B2IVector; + class B2DPoint; + class B2DHomMatrix; + class B2DPolyPolygon; +} + +namespace canvas +{ + class ImplBitmap; + + /** Bitmap class, with XCanvas-like render interface. + + This class provides a bitmap, that can be rendered into, + with an interface compatible to XCanvas. Furthermore, the + bitmaps held here can optionally be backed by (possibly + hw-accelerated) textures. + */ + class Bitmap + { + public: + /** Create bitmap with given size + + @param rSize + Size of the bitmap, in pixel + + @param rMgr + SurfaceProxyManager, to use for HW acceleration + + @param bWithAlpha + When true, the created bitmap will have an alpha channel, + false otherwise + */ + Bitmap( const ::basegfx::B2IVector& rSize, + const ISurfaceProxyManagerSharedPtr& rMgr, + bool bWithAlpha ); + ~Bitmap(); + + /// Query whether this bitmap contains alpha channel information + bool hasAlpha() const; + + /// Query size of the bitmap in pixel + ::basegfx::B2IVector getSize() const; + + ::com::sun::star::uno::Sequence< sal_Int8 > getData( + ::com::sun::star::rendering::IntegerBitmapLayout& bitmapLayout, + const ::com::sun::star::geometry::IntegerRectangle2D& rect ); + + void setData( + const ::com::sun::star::uno::Sequence< sal_Int8 >& data, + const ::com::sun::star::rendering::IntegerBitmapLayout& bitmapLayout, + const ::com::sun::star::geometry::IntegerRectangle2D& rect ); + + void setPixel( + const ::com::sun::star::uno::Sequence< sal_Int8 >& color, + const ::com::sun::star::rendering::IntegerBitmapLayout& bitmapLayout, + const ::com::sun::star::geometry::IntegerPoint2D& pos ); + + ::com::sun::star::uno::Sequence< sal_Int8 > getPixel( + ::com::sun::star::rendering::IntegerBitmapLayout& bitmapLayout, + const ::com::sun::star::geometry::IntegerPoint2D& pos ); + + /** Render the bitmap content to associated + SurfaceProxyManager's screen. + + @param fAlpha + Overall alpha for content + + @param rPos + Output position + + @param rTransform + Output transformation (does not affect output position) + */ + bool draw( double fAlpha, + const ::basegfx::B2DPoint& rPos, + const ::basegfx::B2DHomMatrix& rTransform ); + + /** Render the bitmap content to associated + SurfaceProxyManager's screen. + + @param fAlpha + Overall alpha for content + + @param rPos + Output position + + @param rArea + Subset of the surface to render. Coordinate system are + surface area pixel, given area will be clipped to the + surface bounds. + + @param rTransform + Output transformation (does not affect output position) + */ + bool draw( double fAlpha, + const ::basegfx::B2DPoint& rPos, + const ::basegfx::B2DRange& rArea, + const ::basegfx::B2DHomMatrix& rTransform ); + + /** Render the bitmap content to associated + SurfaceProxyManager's screen. + + @param fAlpha + Overall alpha for content + + @param rPos + Output position + + @param rClipPoly + Clip polygon for the surface. The clip polygon is also + subject to the output transformation. + + @param rTransform + Output transformation (does not affect output position) + */ + bool draw( double fAlpha, + const ::basegfx::B2DPoint& rPos, + const ::basegfx::B2DPolyPolygon& rClipPoly, + const ::basegfx::B2DHomMatrix& rTransform ); + + /** Clear whole bitmap with given color. + + This method sets every single pixel of the bitmap to the + specified color value. + */ + void clear( const ::com::sun::star::uno::Sequence< double >& color ); + + void fillB2DPolyPolygon( + const ::basegfx::B2DPolyPolygon& rPolyPolygon, + const ::com::sun::star::rendering::ViewState& viewState, + const ::com::sun::star::rendering::RenderState& renderState ); + + + // High-level drawing operations (from the XCanvas interface) + // ========================================================== + + /// See XCanvas interface + void drawPoint( const ::com::sun::star::geometry::RealPoint2D& aPoint, + const ::com::sun::star::rendering::ViewState& viewState, + const ::com::sun::star::rendering::RenderState& renderState ); + /// See XCanvas interface + void drawLine( const ::com::sun::star::geometry::RealPoint2D& aStartPoint, + const ::com::sun::star::geometry::RealPoint2D& aEndPoint, + const ::com::sun::star::rendering::ViewState& viewState, + const ::com::sun::star::rendering::RenderState& renderState ); + /// See XCanvas interface + void drawBezier( const ::com::sun::star::geometry::RealBezierSegment2D& aBezierSegment, + const ::com::sun::star::geometry::RealPoint2D& aEndPoint, + const ::com::sun::star::rendering::ViewState& viewState, + const ::com::sun::star::rendering::RenderState& renderState ); + /// See XCanvas interface + ICachedPrimitiveSharedPtr drawPolyPolygon( + const ::com::sun::star::uno::Reference< + ::com::sun::star::rendering::XPolyPolygon2D >& xPolyPolygon, + const ::com::sun::star::rendering::ViewState& viewState, + const ::com::sun::star::rendering::RenderState& renderState ); + + /// See XCanvas interface + ICachedPrimitiveSharedPtr strokePolyPolygon( + const ::com::sun::star::uno::Reference< + ::com::sun::star::rendering::XPolyPolygon2D >& xPolyPolygon, + const ::com::sun::star::rendering::ViewState& viewState, + const ::com::sun::star::rendering::RenderState& renderState, + const ::com::sun::star::rendering::StrokeAttributes& strokeAttributes ); + /** See XCanvas interface + + @param textureAnnotations + Vector of shared pointers to bitmap textures, + <em>corresponding</em> in indices to the textures + sequence. This is to decouple this interface from the + client's XBitmap-implementation class. + */ + ICachedPrimitiveSharedPtr strokeTexturedPolyPolygon( + const ::com::sun::star::uno::Reference< + ::com::sun::star::rendering::XPolyPolygon2D >& xPolyPolygon, + const ::com::sun::star::rendering::ViewState& viewState, + const ::com::sun::star::rendering::RenderState& renderState, + const ::com::sun::star::uno::Sequence< + ::com::sun::star::rendering::Texture >& textures, + const ::std::vector< ::boost::shared_ptr<Bitmap> >& textureAnnotations, + const ::com::sun::star::rendering::StrokeAttributes& strokeAttributes ); + /** See XCanvas interface + + @param textureAnnotations + Vector of shared pointers to bitmap textures, + <em>corresponding</em> in indices to the textures + sequence. This is to decouple this interface from the + client's XBitmap-implementation class. + */ + ICachedPrimitiveSharedPtr strokeTextureMappedPolyPolygon( + const ::com::sun::star::uno::Reference< + ::com::sun::star::rendering::XPolyPolygon2D >& xPolyPolygon, + const ::com::sun::star::rendering::ViewState& viewState, + const ::com::sun::star::rendering::RenderState& renderState, + const ::com::sun::star::uno::Sequence< + ::com::sun::star::rendering::Texture >& textures, + const ::std::vector< ::boost::shared_ptr<Bitmap> >& textureAnnotations, + const ::com::sun::star::uno::Reference< + ::com::sun::star::geometry::XMapping2D >& xMapping, + const ::com::sun::star::rendering::StrokeAttributes& strokeAttributes ); + /// See XCanvas interface + ICachedPrimitiveSharedPtr fillPolyPolygon( + const ::com::sun::star::uno::Reference< + ::com::sun::star::rendering::XPolyPolygon2D >& xPolyPolygon, + const ::com::sun::star::rendering::ViewState& viewState, + const ::com::sun::star::rendering::RenderState& renderState ); + /** See XCanvas interface + + @param textureAnnotations + Vector of shared pointers to bitmap textures, + <em>corresponding</em> in indices to the textures + sequence. This is to decouple this interface from the + client's XBitmap-implementation class. + */ + ICachedPrimitiveSharedPtr fillTexturedPolyPolygon( + const ::com::sun::star::uno::Reference< + ::com::sun::star::rendering::XPolyPolygon2D >& xPolyPolygon, + const ::com::sun::star::rendering::ViewState& viewState, + const ::com::sun::star::rendering::RenderState& renderState, + const ::com::sun::star::uno::Sequence< + ::com::sun::star::rendering::Texture >& textures, + const ::std::vector< ::boost::shared_ptr<Bitmap> >& textureAnnotations ); + /** See XCanvas interface + + @param textureAnnotations + Vector of shared pointers to bitmap textures, + <em>corresponding</em> in indices to the textures + sequence. This is to decouple this interface from the + client's XBitmap-implementation class. + */ + ICachedPrimitiveSharedPtr fillTextureMappedPolyPolygon( + const ::com::sun::star::uno::Reference< + ::com::sun::star::rendering::XPolyPolygon2D >& xPolyPolygon, + const ::com::sun::star::rendering::ViewState& viewState, + const ::com::sun::star::rendering::RenderState& renderState, + const ::com::sun::star::uno::Sequence< + ::com::sun::star::rendering::Texture >& textures, + const ::std::vector< ::boost::shared_ptr<Bitmap> >& textureAnnotations, + const ::com::sun::star::uno::Reference< + ::com::sun::star::geometry::XMapping2D >& xMapping ); + + /// See XCanvas interface + ICachedPrimitiveSharedPtr drawBitmap( + const ::com::sun::star::uno::Reference< + ::com::sun::star::rendering::XBitmap >& xBitmap, + const ::com::sun::star::rendering::ViewState& viewState, + const ::com::sun::star::rendering::RenderState& renderState ); + /// See XCanvas interface + ICachedPrimitiveSharedPtr drawBitmap( + const ::boost::shared_ptr<Bitmap>& rImage, + const ::com::sun::star::rendering::ViewState& viewState, + const ::com::sun::star::rendering::RenderState& renderState ); + + /// See XCanvas interface + ICachedPrimitiveSharedPtr drawBitmapModulated( + const ::com::sun::star::uno::Reference< + ::com::sun::star::rendering::XBitmap >& xBitmap, + const ::com::sun::star::rendering::ViewState& viewState, + const ::com::sun::star::rendering::RenderState& renderState ); + /// See XCanvas interface + ICachedPrimitiveSharedPtr drawBitmapModulated( + const ::boost::shared_ptr<Bitmap>& rImage, + const ::com::sun::star::rendering::ViewState& viewState, + const ::com::sun::star::rendering::RenderState& renderState ); + + private: + friend class ImplBitmap; + + const ::boost::scoped_ptr< ImplBitmap > mpImpl; + }; + + typedef ::boost::shared_ptr< Bitmap > BitmapSharedPtr; +} + +#endif /* INCLUDED_CANVAS_BITMAP_HXX */ diff --git a/canvas/inc/canvas/rendering/icachedprimitive.hxx b/canvas/inc/canvas/rendering/icachedprimitive.hxx new file mode 100644 index 000000000000..866322510834 --- /dev/null +++ b/canvas/inc/canvas/rendering/icachedprimitive.hxx @@ -0,0 +1,69 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: icachedprimitive.hxx,v $ + * $Revision: 1.3 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef INCLUDED_CANVAS_ICACHEDPRIMITIVE_HXX +#define INCLUDED_CANVAS_ICACHEDPRIMITIVE_HXX + +#include <sal/types.h> + +#include <boost/shared_ptr.hpp> + + +namespace basegfx +{ + class B2IRange; + class B2IPoint; +} + +namespace canvas +{ + /** Objects with this interface are returned from every Bitmap + render operation. + + These objects can be used to implement the + rendering::XCachedPrimitive interface, which in turn caches + render state and objects to facilitate quick redraws. + */ + struct ICachedPrimitive + { + virtual ~ICachedPrimitive() {} + + /** Redraw the primitive with the given view state + + Note that the primitive will <em>always</em> be redrawn on + the bitmap it was created from. + */ + virtual sal_Int8 redraw( const ::com::sun::star::rendering::ViewState& aState ) const = 0; + }; + + typedef ::boost::shared_ptr< ICachedPrimitive > ICachedPrimitiveSharedPtr; +} + +#endif /* INCLUDED_CANVAS_ICACHEDPRIMITIVE_HXX */ diff --git a/canvas/inc/canvas/rendering/icolorbuffer.hxx b/canvas/inc/canvas/rendering/icolorbuffer.hxx new file mode 100644 index 000000000000..5be6748ab73c --- /dev/null +++ b/canvas/inc/canvas/rendering/icolorbuffer.hxx @@ -0,0 +1,97 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: icolorbuffer.hxx,v $ + * $Revision: 1.3 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef INCLUDED_CANVAS_ICOLORBUFFER_HXX +#define INCLUDED_CANVAS_ICOLORBUFFER_HXX + +#include <sal/types.h> + +#include <boost/shared_ptr.hpp> + + +namespace canvas +{ + /** Interface for a raw memory pixel container + + Use this interface to represent a surface of raw pixel (e.g. a + bitmap) to the canvas rendering framework. + */ + struct IColorBuffer + { + /// The underlying pixel format for this buffer + enum Format + { + // 24-bit RGB pixel format, 8 bits per channel. + FMT_R8G8B8, + + // 32-bit ARGB pixel format with alpha, 8 bits per channel. + FMT_A8R8G8B8, + + // 32-bit RGB pixel format, 8 bits per channel. + FMT_X8R8G8B8, + + // for enum to 32bit + FMT_UNKNOWN = static_cast<sal_uInt32>(-1) + }; + + virtual ~IColorBuffer() {} + + /** Get a pointer to the raw memory bits of the pixel + */ + virtual sal_uInt8* lock() const = 0; + + /** unlock previous locked buffer + */ + virtual void unlock() const = 0; + + /** Get width in pixel + */ + virtual sal_uInt32 getWidth() const = 0; + + /** Get height in pixel + */ + virtual sal_uInt32 getHeight() const = 0; + + /** Offset, in bytes, between consecutive scan lines of the bitmap. + If the stride is positive, the bitmap is top-down. + If the stride is negative, the bitmap is bottom-up. + The returned value is only valid while the buffer is locked. + */ + virtual sal_uInt32 getStride() const = 0; + + /** Get format of the color buffer + */ + virtual Format getFormat() const = 0; + }; + + typedef ::boost::shared_ptr< IColorBuffer > IColorBufferSharedPtr; +} + +#endif /* INCLUDED_CANVAS_ICOLORBUFFER_HXX */ diff --git a/canvas/inc/canvas/rendering/irendermodule.hxx b/canvas/inc/canvas/rendering/irendermodule.hxx new file mode 100644 index 000000000000..70cb784e58cf --- /dev/null +++ b/canvas/inc/canvas/rendering/irendermodule.hxx @@ -0,0 +1,152 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: irendermodule.hxx,v $ + * $Revision: 1.4 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef INCLUDED_CANVAS_IRENDERMODULE_HXX +#define INCLUDED_CANVAS_IRENDERMODULE_HXX + +#include <sal/types.h> + +#include <boost/shared_ptr.hpp> +#include <boost/utility.hpp> + + +namespace basegfx +{ + class B2DRange; + class B2IRange; + class B2IVector; + class B2IPoint; +} + +namespace canvas +{ + struct ISurface; + + struct Vertex + { + float r,g,b,a; + float u,v; + float x,y,z; + }; + + /** Output module interface for backend render implementations. + + Implement this interface for each operating system- or + library-specific rendering backend, which needs coupling with + the canvas rendering framework (which can be shared between + all backend implementations). + */ + struct IRenderModule + { + /** Type of primitive passed to the render module via + pushVertex() + */ + enum PrimitiveType + { + PRIMITIVE_TYPE_UNKNOWN, + PRIMITIVE_TYPE_TRIANGLE, + PRIMITIVE_TYPE_QUAD + }; + + virtual ~IRenderModule() {} + + /// Lock rendermodule against concurrent access + virtual void lock() const = 0; + + /// Unlock rendermodule for concurrent access + virtual void unlock() const = 0; + + /** Maximal size of VRAM pages available + + This is typically the maximum texture size of the + hardware, or some arbitrary limit if the backend is + software. + */ + virtual ::basegfx::B2IVector getPageSize() = 0; + + /** Create a (possibly hardware-accelerated) surface + + @return a pointer to a surface, which is an abstraction of + a piece of (possibly hardware-accelerated) texture memory. + */ + virtual ::boost::shared_ptr<ISurface> createSurface( const ::basegfx::B2IVector& surfaceSize ) = 0; + + /** Begin rendering the given primitive. + + Each beginPrimitive() call must be matched with an + endPrimitive() call. + */ + virtual void beginPrimitive( PrimitiveType eType ) = 0; + + /** Finish rendering a primitive. + + Each beginPrimitive() call must be matched with an + endPrimitive() call. + */ + virtual void endPrimitive() = 0; + + /** Add given vertex to current primitive + + After issuing a beginPrimitive(), each pushVertex() adds a + vertex to the active primitive. + */ + virtual void pushVertex( const Vertex& vertex ) = 0; + + /** Query error status + + @returns true, if an error occured during primitive + construction. + */ + virtual bool isError() = 0; + }; + + typedef ::boost::shared_ptr< IRenderModule > IRenderModuleSharedPtr; + + /// Little RAII wrapper for guarding access to IRenderModule interface + class RenderModuleGuard : private ::boost::noncopyable + { + public: + explicit RenderModuleGuard( const IRenderModuleSharedPtr& rRenderModule ) : + mpRenderModule( rRenderModule ) + { + mpRenderModule->lock(); + } + + ~RenderModuleGuard() + { + mpRenderModule->unlock(); + } + + private: + const IRenderModuleSharedPtr mpRenderModule; + }; +} + +#endif /* INCLUDED_CANVAS_IRENDERMODULE_HXX */ diff --git a/canvas/inc/canvas/rendering/isurface.hxx b/canvas/inc/canvas/rendering/isurface.hxx new file mode 100644 index 000000000000..329279c2bff1 --- /dev/null +++ b/canvas/inc/canvas/rendering/isurface.hxx @@ -0,0 +1,91 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: isurface.hxx,v $ + * $Revision: 1.3 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef INCLUDED_CANVAS_ISURFACE_HXX +#define INCLUDED_CANVAS_ISURFACE_HXX + +#include <sal/types.h> + +#include <boost/shared_ptr.hpp> + + +namespace basegfx +{ + class B2IRange; + class B2IPoint; + class B2IVector; +} + +namespace canvas +{ + struct IColorBuffer; + + struct ISurface + { + virtual ~ISurface() {} + + /** Select texture behind this interface to be the current one + for primitive output. + */ + virtual bool selectTexture() = 0; + + /** Tells wether the surface is valid or not + */ + virtual bool isValid() = 0; + + /** Update surface content from given IColorBuffer + + This method updates the given subarea of the surface from + the given color buffer bits. + + @param rDestPos + Position in the surface, where the subset update should + have its left, top edge + + @param rSourceRect + Size and position of the rectangular subset update in the + source color buffer + + @param rSource + Source bits to use for the update + + @return true, if the update was successful + */ + virtual bool update( const ::basegfx::B2IPoint& rDestPos, + const ::basegfx::B2IRange& rSourceRect, + IColorBuffer& rSource ) = 0; + + virtual ::basegfx::B2IVector getSize() = 0; + }; + + typedef ::boost::shared_ptr< ISurface > ISurfaceSharedPtr; +} + +#endif /* INCLUDED_CANVAS_ISURFACE_HXX */ diff --git a/canvas/inc/canvas/rendering/isurfaceproxy.hxx b/canvas/inc/canvas/rendering/isurfaceproxy.hxx new file mode 100644 index 000000000000..99a30eda7e02 --- /dev/null +++ b/canvas/inc/canvas/rendering/isurfaceproxy.hxx @@ -0,0 +1,116 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: isurfaceproxy.hxx,v $ + * $Revision: 1.3 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef INCLUDED_CANVAS_ISURFACEPROXY_HXX +#define INCLUDED_CANVAS_ISURFACEPROXY_HXX + +#include <canvas/rendering/irendermodule.hxx> + +#include <boost/shared_ptr.hpp> + +namespace basegfx +{ + class B2DRange; + class B2DPoint; + class B2DPolyPolygon; + class B2DHomMatrix; +} + +namespace canvas +{ + struct ISurfaceProxy + { + virtual ~ISurfaceProxy() {} + + /** Notify the proxy that the color buffer has changed + */ + virtual void setColorBufferDirty() = 0; + + /** Render the surface content to screen. + + @param fAlpha + Overall alpha for content + + @param rPos + Output position + + @param rTransform + Output transformation (does not affect output position) + */ + virtual bool draw( double fAlpha, + const ::basegfx::B2DPoint& rPos, + const ::basegfx::B2DHomMatrix& rTransform ) = 0; + + /** Render the surface content to screen. + + @param fAlpha + Overall alpha for content + + @param rPos + Output position + + @param rArea + Subset of the surface to render. Coordinate system are + surface area pixel, given area will be clipped to the + surface bounds. + + @param rTransform + Output transformation (does not affect output position) + */ + virtual bool draw( double fAlpha, + const ::basegfx::B2DPoint& rPos, + const ::basegfx::B2DRange& rArea, + const ::basegfx::B2DHomMatrix& rTransform ) = 0; + + /** Render the surface content to screen. + + @param fAlpha + Overall alpha for content + + @param rPos + Output position + + @param rClipPoly + Clip polygon for the surface. The clip polygon is also + subject to the output transformation. + + @param rTransform + Output transformation (does not affect output position) + */ + virtual bool draw( double fAlpha, + const ::basegfx::B2DPoint& rPos, + const ::basegfx::B2DPolyPolygon& rClipPoly, + const ::basegfx::B2DHomMatrix& rTransform ) = 0; + }; + + typedef ::boost::shared_ptr< ISurfaceProxy > ISurfaceProxySharedPtr; +} + +#endif /* INCLUDED_CANVAS_ISURFACEPROXY_HXX */ diff --git a/canvas/inc/canvas/rendering/isurfaceproxymanager.hxx b/canvas/inc/canvas/rendering/isurfaceproxymanager.hxx new file mode 100644 index 000000000000..4f16c3e19516 --- /dev/null +++ b/canvas/inc/canvas/rendering/isurfaceproxymanager.hxx @@ -0,0 +1,82 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: isurfaceproxymanager.hxx,v $ + * $Revision: 1.3 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef INCLUDED_CANVAS_ISURFACEPROXYMANAGER_HXX +#define INCLUDED_CANVAS_ISURFACEPROXYMANAGER_HXX + +#include <canvas/rendering/irendermodule.hxx> +#include <canvas/rendering/icolorbuffer.hxx> + +#include <boost/shared_ptr.hpp> + + +namespace canvas +{ + struct ISurfaceProxy; + + /** Manager interface, which handles surface proxy objects. + + Typically, each canvas instantiation has one + SurfaceProxyManager object, to handle their surfaces. Surfaces + itself are opaque objects, which encapsulate a framebuffer to + render upon, plus an optional (possibly accelerated) texture. + */ + struct ISurfaceProxyManager + { + virtual ~ISurfaceProxyManager() {} + + /** Create a surface proxy for a color buffer. + + The whole idea is build around the concept that you create + some arbitrary buffer which contains the image data and + tell the texture manager about it. From there on you can + draw into this image using any kind of graphics api you + want. In the technical sense we allocate some space in + local videomemory or AGP memory which will be filled on + demand, which means if there exists any rendering + operation that needs to read from this memory location. + This method creates a logical hardware surface object + which uses the given color buffer as the image source. + Internally this texture may even be distributed to several + real hardware surfaces. + */ + virtual ::boost::shared_ptr< ISurfaceProxy > createSurfaceProxy( + const IColorBufferSharedPtr& pBuffer ) const = 0; + }; + + typedef ::boost::shared_ptr< ISurfaceProxyManager > ISurfaceProxyManagerSharedPtr; + + + /** Create a surface proxy for the given render module. + */ + ISurfaceProxyManagerSharedPtr createSurfaceProxyManager( const IRenderModuleSharedPtr& rRenderModule ); +} + +#endif /* INCLUDED_CANVAS_ISURFACEPROXYMANAGER_HXX */ |