1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 #ifndef INCLUDED_DRAWINGLAYER_PROCESSOR3D_DEFAULTPROCESSOR3D_HXX
25 #define INCLUDED_DRAWINGLAYER_PROCESSOR3D_DEFAULTPROCESSOR3D_HXX
26 
27 #include <drawinglayer/drawinglayerdllapi.h>
28 #include <drawinglayer/processor3d/baseprocessor3d.hxx>
29 #include <basegfx/matrix/b3dhommatrix.hxx>
30 #include <basegfx/range/b2drange.hxx>
31 #include <basegfx/color/bcolormodifier.hxx>
32 #include <svtools/optionsdrawinglayer.hxx>
33 #include <boost/shared_ptr.hpp>
34 
35 //////////////////////////////////////////////////////////////////////////////
36 // predefines
37 
38 namespace basegfx {
39 	class BZPixelRaster;
40 	class B3DPolygon;
41 	class B3DPolyPolygon;
42 }
43 
44 namespace drawinglayer { namespace attribute {
45 	class SdrSceneAttribute;
46 	class SdrLightingAttribute;
47 	class MaterialAttribute3D;
48 }}
49 
50 namespace drawinglayer { namespace primitive3d {
51 	class PolygonHairlinePrimitive3D;
52 	class PolyPolygonMaterialPrimitive3D;
53 	class GradientTexturePrimitive3D;
54 	class HatchTexturePrimitive3D;
55 	class BitmapTexturePrimitive3D;
56 	class TransformPrimitive3D;
57 	class ModifiedColorPrimitive3D;
58 }}
59 
60 namespace drawinglayer { namespace texture {
61 	class GeoTexSvx;
62 }}
63 
64 //////////////////////////////////////////////////////////////////////////////
65 
66 namespace drawinglayer
67 {
68 	namespace processor3d
69 	{
70         /** DefaultProcessor3D class
71 
72             This processor renders all feeded primitives to a 2D raster where for all
73             primitives the two basic methods rasterconvertB3DPolygon for hairlines and
74             rasterconvertB3DPolyPolygon for filled geometry is called. It is a beseclass to
75             e.g. base a Z-Buffer supported renderer on the 3D primitive processing.
76          */
77 		class DefaultProcessor3D : public BaseProcessor3D
78 		{
79 		protected:
80             /// read-only scene infos (normal handling, etc...)
81 			const attribute::SdrSceneAttribute&					mrSdrSceneAttribute;
82 
83             /// read-only light infos (lights, etc...)
84 			const attribute::SdrLightingAttribute&				mrSdrLightingAttribute;
85 
86 			/// renderer range. Need to be correctly set by the derived implementations
87             /// normally the (0, 0, W, H) range from mpBZPixelRaster
88 			basegfx::B2DRange									maRasterRange;
89 
90 			/// the modifiedColorPrimitive stack
91 			basegfx::BColorModifierStack						maBColorModifierStack;
92 
93 			/// the current active texture
94             boost::shared_ptr< texture::GeoTexSvx >				mpGeoTexSvx;
95 
96 			/// the current active transparence texture
97 			boost::shared_ptr< texture::GeoTexSvx >				mpTransparenceGeoTexSvx;
98 
99 			/// SvtOptionsDrawinglayer incarnation to react on diverse settings
100             const SvtOptionsDrawinglayer						maDrawinglayerOpt;
101 
102             /// counter for entered transparence textures
103             sal_uInt32                                          mnTransparenceCounter;
104 
105 			/// bitfield
106 			unsigned											mbModulate : 1;
107 			unsigned											mbFilter : 1;
108 			unsigned											mbSimpleTextureActive : 1;
109 
110 			//////////////////////////////////////////////////////////////////////////////
111 			// rendering support
112 
113             void impRenderGradientTexturePrimitive3D(const primitive3d::GradientTexturePrimitive3D& rPrimitive, bool bTransparence);
114 			void impRenderHatchTexturePrimitive3D(const primitive3d::HatchTexturePrimitive3D& rPrimitive);
115 			void impRenderBitmapTexturePrimitive3D(const primitive3d::BitmapTexturePrimitive3D& rPrimitive);
116 			void impRenderModifiedColorPrimitive3D(const primitive3d::ModifiedColorPrimitive3D& rModifiedCandidate);
117 			void impRenderPolygonHairlinePrimitive3D(const primitive3d::PolygonHairlinePrimitive3D& rPrimitive);
118 			void impRenderPolyPolygonMaterialPrimitive3D(const primitive3d::PolyPolygonMaterialPrimitive3D& rPrimitive);
119 			void impRenderTransformPrimitive3D(const primitive3d::TransformPrimitive3D& rTransformCandidate);
120 
121 			//////////////////////////////////////////////////////////////////////////////
122 			// rasterconversions for filled and non-filled polygons. These NEED to be
123 			// implemented from derivations
124 
125             virtual void rasterconvertB3DPolygon(const attribute::MaterialAttribute3D& rMaterial, const basegfx::B3DPolygon& rHairline) const = 0;
126 			virtual void rasterconvertB3DPolyPolygon(const attribute::MaterialAttribute3D& rMaterial, const basegfx::B3DPolyPolygon& rFill) const = 0;
127 
128 			// the processing method for a single, known primitive
129 			virtual void processBasePrimitive3D(const primitive3d::BasePrimitive3D& rBasePrimitive);
130 
131 		public:
132 			DefaultProcessor3D(
133 				const geometry::ViewInformation3D& rViewInformation,
134 				const attribute::SdrSceneAttribute& rSdrSceneAttribute,
135 				const attribute::SdrLightingAttribute& rSdrLightingAttribute);
136 			virtual ~DefaultProcessor3D();
137 
138 			/// data read access
getSdrSceneAttribute() const139 			const attribute::SdrSceneAttribute& getSdrSceneAttribute() const { return mrSdrSceneAttribute; }
getSdrLightingAttribute() const140 			const attribute::SdrLightingAttribute& getSdrLightingAttribute() const { return mrSdrLightingAttribute; }
141 
142 			/// data read access renderer stuff
getBColorModifierStack() const143 			const basegfx::BColorModifierStack& getBColorModifierStack() const { return maBColorModifierStack; }
getGeoTexSvx() const144 			const boost::shared_ptr< texture::GeoTexSvx >& getGeoTexSvx() const { return mpGeoTexSvx; }
getTransparenceGeoTexSvx() const145 			const boost::shared_ptr< texture::GeoTexSvx >& getTransparenceGeoTexSvx() const { return mpTransparenceGeoTexSvx; }
getTransparenceCounter() const146             sal_uInt32 getTransparenceCounter() const { return mnTransparenceCounter; }
getModulate() const147 			bool getModulate() const { return mbModulate; }
getFilter() const148 			bool getFilter() const { return mbFilter; }
getSimpleTextureActive() const149 			bool getSimpleTextureActive() const { return mbSimpleTextureActive; }
150 
151 			/// access to Drawinglayer configuration options
getOptionsDrawinglayer() const152 			const SvtOptionsDrawinglayer& getOptionsDrawinglayer() const { return maDrawinglayerOpt; }
153 		};
154 	} // end of namespace processor3d
155 } // end of namespace drawinglayer
156 
157 //////////////////////////////////////////////////////////////////////////////
158 
159 #endif // INCLUDED_DRAWINGLAYER_PROCESSOR3D_DEFAULTPROCESSOR3D_HXX
160 
161 // eof
162