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_CANVAS_SURFACEPROXY_HXX
25 #define INCLUDED_CANVAS_SURFACEPROXY_HXX
26 
27 #include <canvas/rendering/isurfaceproxy.hxx>
28 #include <canvas/rendering/icolorbuffer.hxx>
29 
30 #include "pagemanager.hxx"
31 #include "surface.hxx"
32 
33 namespace canvas
34 {
35 
36 	//////////////////////////////////////////////////////////////////////////////////
37 	// SurfaceProxy
38 	//////////////////////////////////////////////////////////////////////////////////
39 
40 	/** Definition of the surface proxy class.
41 
42 	    Surface proxies are the connection between *one* source image
43 	    and *one or more* hardware surfaces (or textures).  in a
44 	    logical structure surface proxies represent solely this
45 	    dependeny plus some simple cache management.
46     */
47     class SurfaceProxy : public ISurfaceProxy
48 	{
49     public:
50 
51         SurfaceProxy( const canvas::IColorBufferSharedPtr& pBuffer,
52                       const PageManagerSharedPtr &pPageManager );
53 
54         // ISurfaceProxy interface
55         virtual void setColorBufferDirty();
56 
57         /** Render the surface content to screen.
58 
59             @param fAlpha
60             Overall alpha for content
61 
62             @param rPos
63             Output position
64 
65             @param rTransform
66             Output transformation (does not affect output position)
67         */
68         virtual bool draw( double                         fAlpha,
69                            const ::basegfx::B2DPoint&     rPos,
70                            const ::basegfx::B2DHomMatrix& rTransform );
71 
72         /** Render the surface content to screen.
73 
74             @param fAlpha
75             Overall alpha for content
76 
77             @param rPos
78             Output position
79 
80             @param rArea
81             Subset of the surface to render. Coordinate system are
82             surface area pixel, given area will be clipped to the
83             surface bounds.
84 
85             @param rTransform
86             Output transformation (does not affect output position)
87         */
88         virtual bool draw( double                         fAlpha,
89                            const ::basegfx::B2DPoint&     rPos,
90                            const ::basegfx::B2DRange&     rArea,
91                            const ::basegfx::B2DHomMatrix& rTransform );
92 
93         /** Render the surface content to screen.
94 
95             @param fAlpha
96             Overall alpha for content
97 
98             @param rPos
99             Output position
100 
101             @param rClipPoly
102             Clip polygon for the surface. The clip polygon is also
103             subject to the output transformation.
104 
105             @param rTransform
106             Output transformation (does not affect output position)
107         */
108         virtual bool draw( double                           fAlpha,
109                            const ::basegfx::B2DPoint&       rPos,
110                            const ::basegfx::B2DPolyPolygon& rClipPoly,
111                            const ::basegfx::B2DHomMatrix&   rTransform );
112 
113     private:
114         PageManagerSharedPtr          mpPageManager;
115 
116         // the pagemanager will distribute the image
117         // to one or more surfaces, this is why we
118         // need a list here.
119         std::vector<SurfaceSharedPtr> maSurfaceList;
120 
121         // pointer to the source of image data
122         // which always is stored in system memory,
123         // 32bit rgba and can have any size.
124         canvas::IColorBufferSharedPtr mpBuffer;
125 	};
126 
127     typedef ::boost::shared_ptr< SurfaceProxy > SurfaceProxySharedPtr;
128 }
129 
130 #endif
131