1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #ifndef INCLUDED_CANVAS_SOURCE_TOOLS_SURFACE_HXX
21 #define INCLUDED_CANVAS_SOURCE_TOOLS_SURFACE_HXX
23 #include <basegfx/point/b2ipoint.hxx>
24 #include <basegfx/point/b2dpoint.hxx>
25 #include <basegfx/polygon/b2dpolygon.hxx>
26 #include <basegfx/range/b2drectangle.hxx>
27 #include <basegfx/vector/b2isize.hxx>
28 #include <basegfx/matrix/b2dhommatrix.hxx>
29 #include <canvas/rendering/irendermodule.hxx>
30 #include <canvas/rendering/icolorbuffer.hxx>
31 #include <canvas/rendering/isurface.hxx>
33 #include "surfacerect.hxx"
34 #include "pagemanager.hxx"
42 /** surfaces denote occupied areas within pages.
44 pages encapsulate the hardware buffers that
45 contain image data which can be used for texturing.
46 surfaces are areas within those pages.
52 Surface( const PageManagerSharedPtr
& rPageManager
,
53 const IColorBufferSharedPtr
& rColorBuffer
,
54 const ::basegfx::B2IPoint
& rPos
,
55 const ::basegfx::B2ISize
& rSize
);
58 void setColorBufferDirty();
60 /** Render the surface content to screen.
63 Overall alpha for content
69 Output transformation (does not affect output position)
71 bool draw( double fAlpha
,
72 const ::basegfx::B2DPoint
& rPos
,
73 const ::basegfx::B2DHomMatrix
& rTransform
);
75 /** Render the surface content to screen.
78 Overall alpha for content
84 Subset of the surface to render. Coordinate system are
85 surface area pixel, given area will be clipped to the
89 Output transformation (does not affect output position)
91 bool drawRectangularArea(
93 const ::basegfx::B2DPoint
& rPos
,
94 const ::basegfx::B2DRange
& rArea
,
95 const ::basegfx::B2DHomMatrix
& rTransform
);
97 /** Render the surface content to screen.
100 Overall alpha for content
106 Clip polygon for the surface. The clip polygon is also
107 subject to the output transformation.
110 Output transformation (does not affect output position)
112 bool drawWithClip( double fAlpha
,
113 const ::basegfx::B2DPoint
& rPos
,
114 const ::basegfx::B2DPolygon
& rClipPoly
,
115 const ::basegfx::B2DHomMatrix
& rTransform
);
117 // private attributes
119 IColorBufferSharedPtr mpColorBuffer
;
121 // invoking any of the above defined 'draw' methods
122 // will forward primitive commands to the rendermodule.
123 PageManagerSharedPtr mpPageManager
;
125 FragmentSharedPtr mpFragment
;
127 // the offset of this surface with regard to the source
128 // image. if the source image had to be tiled into multiple
129 // surfaces, this offset denotes the relative pixel distance
130 // from the source image's upper, left corner
131 ::basegfx::B2IPoint maSourceOffset
;
133 // the size in pixels of this surface. please note that
134 // this size is likely to be smaller than the size of
135 // the colorbuffer we're associated with since we
136 // maybe represent only a part of it.
137 ::basegfx::B2ISize maSize
;
143 bool refresh( canvas::IColorBuffer
& rBuffer
) const;
144 void prepareRendering();
146 basegfx::B2DRectangle
getUVCoords() const;
147 basegfx::B2DRectangle
getUVCoords( const ::basegfx::B2IPoint
& rPos
,
148 const ::basegfx::B2ISize
& rSize
) const;
151 typedef ::boost::shared_ptr
< Surface
> SurfaceSharedPtr
;
156 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */