Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : : #ifndef INCLUDED_CANVAS_IRENDERMODULE_HXX
30 : : #define INCLUDED_CANVAS_IRENDERMODULE_HXX
31 : :
32 : : #include <sal/types.h>
33 : :
34 : : #include <boost/shared_ptr.hpp>
35 : : #include <boost/utility.hpp>
36 : :
37 : :
38 : : namespace basegfx
39 : : {
40 : : class B2DRange;
41 : : class B2IRange;
42 : : class B2IVector;
43 : : class B2IPoint;
44 : : }
45 : :
46 : : namespace canvas
47 : : {
48 : : struct ISurface;
49 : :
50 : : struct Vertex
51 : : {
52 : : float r,g,b,a;
53 : : float u,v;
54 : : float x,y,z;
55 : : };
56 : :
57 : : /** Output module interface for backend render implementations.
58 : :
59 : : Implement this interface for each operating system- or
60 : : library-specific rendering backend, which needs coupling with
61 : : the canvas rendering framework (which can be shared between
62 : : all backend implementations).
63 : : */
64 : : struct IRenderModule
65 : : {
66 : : /** Type of primitive passed to the render module via
67 : : pushVertex()
68 : : */
69 : : enum PrimitiveType
70 : : {
71 : : PRIMITIVE_TYPE_UNKNOWN,
72 : : PRIMITIVE_TYPE_TRIANGLE,
73 : : PRIMITIVE_TYPE_QUAD
74 : : };
75 : :
76 [ # # ]: 0 : virtual ~IRenderModule() {}
77 : :
78 : : /// Lock rendermodule against concurrent access
79 : : virtual void lock() const = 0;
80 : :
81 : : /// Unlock rendermodule for concurrent access
82 : : virtual void unlock() const = 0;
83 : :
84 : : /** Maximal size of VRAM pages available
85 : :
86 : : This is typically the maximum texture size of the
87 : : hardware, or some arbitrary limit if the backend is
88 : : software.
89 : : */
90 : : virtual ::basegfx::B2IVector getPageSize() = 0;
91 : :
92 : : /** Create a (possibly hardware-accelerated) surface
93 : :
94 : : @return a pointer to a surface, which is an abstraction of
95 : : a piece of (possibly hardware-accelerated) texture memory.
96 : : */
97 : : virtual ::boost::shared_ptr<ISurface> createSurface( const ::basegfx::B2IVector& surfaceSize ) = 0;
98 : :
99 : : /** Begin rendering the given primitive.
100 : :
101 : : Each beginPrimitive() call must be matched with an
102 : : endPrimitive() call.
103 : : */
104 : : virtual void beginPrimitive( PrimitiveType eType ) = 0;
105 : :
106 : : /** Finish rendering a primitive.
107 : :
108 : : Each beginPrimitive() call must be matched with an
109 : : endPrimitive() call.
110 : : */
111 : : virtual void endPrimitive() = 0;
112 : :
113 : : /** Add given vertex to current primitive
114 : :
115 : : After issuing a beginPrimitive(), each pushVertex() adds a
116 : : vertex to the active primitive.
117 : : */
118 : : virtual void pushVertex( const Vertex& vertex ) = 0;
119 : :
120 : : /** Query error status
121 : :
122 : : @returns true, if an error occurred during primitive
123 : : construction.
124 : : */
125 : : virtual bool isError() = 0;
126 : : };
127 : :
128 : : typedef ::boost::shared_ptr< IRenderModule > IRenderModuleSharedPtr;
129 : :
130 : : /// Little RAII wrapper for guarding access to IRenderModule interface
131 : : class RenderModuleGuard : private ::boost::noncopyable
132 : : {
133 : : public:
134 : 0 : explicit RenderModuleGuard( const IRenderModuleSharedPtr& rRenderModule ) :
135 [ # # ]: 0 : mpRenderModule( rRenderModule )
136 : : {
137 [ # # ]: 0 : mpRenderModule->lock();
138 : 0 : }
139 : :
140 : 0 : ~RenderModuleGuard()
141 [ # # ]: 0 : {
142 [ # # ]: 0 : mpRenderModule->unlock();
143 : 0 : }
144 : :
145 : : private:
146 : : const IRenderModuleSharedPtr mpRenderModule;
147 : : };
148 : : }
149 : :
150 : : #endif /* INCLUDED_CANVAS_IRENDERMODULE_HXX */
151 : :
152 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|