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 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_canvas.hxx"
26 
27 #include <canvas/rendering/isurfaceproxymanager.hxx>
28 #include <canvas/rendering/isurfaceproxy.hxx>
29 #include "surfaceproxy.hxx"
30 
31 namespace canvas
32 {
33 
34 	//////////////////////////////////////////////////////////////////////////////////
35 	// SurfaceProxyManager
36 	//////////////////////////////////////////////////////////////////////////////////
37 
38 	class SurfaceProxyManager : public ISurfaceProxyManager
39 	{
40     public:
41 
SurfaceProxyManager(const IRenderModuleSharedPtr pRenderModule)42         SurfaceProxyManager( const IRenderModuleSharedPtr pRenderModule ) :
43             mpPageManager( new PageManager(pRenderModule) )
44         {
45         }
46 
47         /** the whole idea is build around the concept that you create
48             some arbitrary buffer which contains the image data and
49             tell the texture manager about it.  from there on you can
50             draw this image using any kind of graphics api you want.
51             in the technical sense we allocate some space in local
52             videomemory or AGP memory which will be filled on demand,
53             which means if there exists any rendering operation that
54             needs to read from this memory location.  this method
55             creates a logical hardware surface object which uses the
56             given color buffer as the image source.  internally this
57             texture may be distributed to several real hardware
58             surfaces.
59         */
createSurfaceProxy(const IColorBufferSharedPtr & pBuffer) const60         virtual ISurfaceProxySharedPtr createSurfaceProxy( const IColorBufferSharedPtr& pBuffer ) const
61         {
62             // not much to do for now, simply allocate a new surface
63             // proxy from our internal pool and initialize this thing
64             // properly. we *don't* create a hardware surface for now.
65             return SurfaceProxySharedPtr(new SurfaceProxy(pBuffer,mpPageManager));
66         }
67 
68     private:
69         PageManagerSharedPtr mpPageManager;
70 	};
71 
72 	//////////////////////////////////////////////////////////////////////////////////
73 	// createSurfaceProxyManager
74 	//////////////////////////////////////////////////////////////////////////////////
75 
createSurfaceProxyManager(const IRenderModuleSharedPtr & rRenderModule)76 	ISurfaceProxyManagerSharedPtr createSurfaceProxyManager( const IRenderModuleSharedPtr& rRenderModule )
77     {
78         return ISurfaceProxyManagerSharedPtr(
79 			new SurfaceProxyManager(
80 				rRenderModule));
81 	}
82 }
83