diff options
author | Kurt Zenker <kz@openoffice.org> | 2005-11-02 11:45:24 +0000 |
---|---|---|
committer | Kurt Zenker <kz@openoffice.org> | 2005-11-02 11:45:24 +0000 |
commit | 015751c4872dff8d0015f45e5791bc86bf1ec0c4 (patch) | |
tree | 475ebfea1770808ff703dc9f781097bf7248f12b /canvas/inc/canvas/rendering | |
parent | 5c5e584c8f22c09cb999d7543a9415349910fa06 (diff) |
INTEGRATION: CWS canvas02 (1.1.2); FILE ADDED
2005/10/11 15:40:46 thb 1.1.2.4: #i54170# Corrected license headers
2005/08/03 20:48:51 thb 1.1.2.3: #i48939# Removed getPixelSize() from IRenderModule, the vertices passed to the renderer are now simply in device pixel coordinate system
2005/08/03 12:03:14 thb 1.1.2.2: #i48939# Added locking to IRenderModule interface (might contain global objects, like the OpenGL state)
2005/08/02 13:59:47 thb 1.1.2.1: Initial revision
Diffstat (limited to 'canvas/inc/canvas/rendering')
-rw-r--r-- | canvas/inc/canvas/rendering/irendermodule.hxx | 159 |
1 files changed, 159 insertions, 0 deletions
diff --git a/canvas/inc/canvas/rendering/irendermodule.hxx b/canvas/inc/canvas/rendering/irendermodule.hxx new file mode 100644 index 000000000000..821e72bb4417 --- /dev/null +++ b/canvas/inc/canvas/rendering/irendermodule.hxx @@ -0,0 +1,159 @@ +/************************************************************************* + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: irendermodule.hxx,v $ + * + * $Revision: 1.2 $ + * + * last change: $Author: kz $ $Date: 2005-11-02 12:45:24 $ + * + * The Contents of this file are made available subject to + * the terms of GNU Lesser General Public License Version 2.1. + * + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2005 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library 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 for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + ************************************************************************/ + +#ifndef INCLUDED_CANVAS_IRENDERMODULE_HXX +#define INCLUDED_CANVAS_IRENDERMODULE_HXX + +#ifndef _SAL_TYPES_H_ +#include <sal/types.h> +#endif + +#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_UNKNONWN, + 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 */ |