update dev300-m58
[ooovba.git] / canvas / source / tools / surface.hxx
blob1eaa0b8a377f7388d6d88168c83684d5485a68a9
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: surface.hxx,v $
10 * $Revision: 1.3 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #ifndef INCLUDED_CANVAS_SURFACE_HXX
32 #define INCLUDED_CANVAS_SURFACE_HXX
34 #include <basegfx/point/b2ipoint.hxx>
35 #include <basegfx/point/b2dpoint.hxx>
36 #include <basegfx/polygon/b2dpolygon.hxx>
37 #include <basegfx/range/b2drectangle.hxx>
38 #include <basegfx/vector/b2isize.hxx>
39 #include <basegfx/matrix/b2dhommatrix.hxx>
40 #include <canvas/rendering/irendermodule.hxx>
41 #include <canvas/rendering/icolorbuffer.hxx>
42 #include <canvas/rendering/isurface.hxx>
44 #include "surfacerect.hxx"
45 #include "pagemanager.hxx"
47 namespace canvas
49 //////////////////////////////////////////////////////////////////////////////////
50 // Surface
51 //////////////////////////////////////////////////////////////////////////////////
53 /** surfaces denote occupied areas withing pages.
55 pages encapsulate the hardware buffers that
56 contain image data which can be used for texturing.
57 surfaces are areas within those pages.
59 class Surface
61 public:
63 Surface( const PageManagerSharedPtr& rPageManager,
64 const IColorBufferSharedPtr& rColorBuffer,
65 const ::basegfx::B2IPoint& rPos,
66 const ::basegfx::B2ISize& rSize );
67 ~Surface();
69 void setColorBufferDirty();
71 /** Render the surface content to screen.
73 @param fAlpha
74 Overall alpha for content
76 @param rPos
77 Output position
79 @param rTransform
80 Output transformation (does not affect output position)
82 bool draw( double fAlpha,
83 const ::basegfx::B2DPoint& rPos,
84 const ::basegfx::B2DHomMatrix& rTransform );
86 /** Render the surface content to screen.
88 @param fAlpha
89 Overall alpha for content
91 @param rPos
92 Output position
94 @param rArea
95 Subset of the surface to render. Coordinate system are
96 surface area pixel, given area will be clipped to the
97 surface bounds.
99 @param rTransform
100 Output transformation (does not affect output position)
102 bool drawRectangularArea(
103 double fAlpha,
104 const ::basegfx::B2DPoint& rPos,
105 const ::basegfx::B2DRange& rArea,
106 const ::basegfx::B2DHomMatrix& rTransform );
108 /** Render the surface content to screen.
110 @param fAlpha
111 Overall alpha for content
113 @param rPos
114 Output position
116 @param rClipPoly
117 Clip polygon for the surface. The clip polygon is also
118 subject to the output transformation.
120 @param rTransform
121 Output transformation (does not affect output position)
123 bool drawWithClip( double fAlpha,
124 const ::basegfx::B2DPoint& rPos,
125 const ::basegfx::B2DPolygon& rClipPoly,
126 const ::basegfx::B2DHomMatrix& rTransform );
128 // private attributes
129 private:
130 IColorBufferSharedPtr mpColorBuffer;
132 // invoking any of the above defined 'draw' methods
133 // will forward primitive commands to the rendermodule.
134 PageManagerSharedPtr mpPageManager;
136 FragmentSharedPtr mpFragment;
138 // the offset of this surface with regard to the source
139 // image. if the source image had to be tiled into multiple
140 // surfaces, this offset denotes the relative pixel distance
141 // from the source image's upper, left corner
142 ::basegfx::B2IPoint maSourceOffset;
144 // the size in pixels of this surface. please note that
145 // this size is likely to be smaller than the size of
146 // the colorbuffer we're associated with since we
147 // maybe represent only a part of it.
148 ::basegfx::B2ISize maSize;
150 bool mbIsDirty;
152 // private methods
153 private:
154 bool refresh( canvas::IColorBuffer& rBuffer ) const;
155 void prepareRendering();
157 basegfx::B2DRectangle getUVCoords() const;
158 basegfx::B2DRectangle getUVCoords( const ::basegfx::B2IPoint& rPos,
159 const ::basegfx::B2ISize& rSize ) const;
162 typedef ::boost::shared_ptr< Surface > SurfaceSharedPtr;
165 #endif