1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: page.hxx,v $
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_PAGE_HXX
32 #define INCLUDED_CANVAS_PAGE_HXX
34 #include <basegfx/vector/b2isize.hxx>
35 #include <basegfx/range/b2irectangle.hxx>
36 #include <canvas/rendering/icolorbuffer.hxx>
37 #include <canvas/rendering/irendermodule.hxx>
38 #include <canvas/rendering/isurface.hxx>
42 #include <boost/shared_ptr.hpp>
43 #include "surfacerect.hxx"
49 typedef ::boost::shared_ptr
< PageFragment
> FragmentSharedPtr
;
51 /** One page of IRenderModule-provided texture space
56 Page( const IRenderModuleSharedPtr
& rRenderModule
);
58 FragmentSharedPtr
allocateSpace( const ::basegfx::B2ISize
& rSize
);
59 bool nakedFragment( const FragmentSharedPtr
& pFragment
);
60 void free( const FragmentSharedPtr
& pFragment
);
61 const ISurfaceSharedPtr
& getSurface() const { return mpSurface
; }
66 typedef std::list
<FragmentSharedPtr
> FragmentContainer_t
;
68 IRenderModuleSharedPtr mpRenderModule
;
69 ISurfaceSharedPtr mpSurface
;
70 FragmentContainer_t mpFragments
;
72 bool insert( SurfaceRect
& r
);
73 bool isValidLocation( const SurfaceRect
& r
) const;
76 typedef ::boost::shared_ptr
< Page
> PageSharedPtr
;
79 /** A part of a page, which gets allocated to a surface
84 PageFragment( const SurfaceRect
& r
,
93 /// Creates a 'naked' fragment.
94 PageFragment( const ::basegfx::B2ISize
& rSize
) :
102 bool isNaked() const { return (mpPage
== NULL
); }
103 const SurfaceRect
& getRect() const { return maRect
; }
104 const ::basegfx::B2IPoint
& getPos() const { return maRect
.maPos
; }
105 const ::basegfx::B2ISize
& getSize() const { return maRect
.maSize
; }
106 void setColorBuffer( const IColorBufferSharedPtr
& pColorBuffer
) { mpBuffer
=pColorBuffer
; }
107 void setSourceOffset( const ::basegfx::B2IPoint
& rOffset
) { maSourceOffset
=rOffset
; }
108 void setPage( Page
* pPage
) { mpPage
=pPage
; }
110 void free( const FragmentSharedPtr
& pFragment
)
113 mpPage
->free(pFragment
);
118 bool select( bool bRefresh
)
120 // request was made to select this fragment,
121 // but this fragment has not been located on any
122 // of the available pages, we need to hurry now.
126 ISurfaceSharedPtr
pSurface(mpPage
->getSurface());
128 // select this surface before wiping the contents
129 // since a specific implementation could trigger
130 // a rendering operation here...
131 if(!(pSurface
->selectTexture()))
134 // call refresh() if requested, otherwise we're up to date...
135 return bRefresh
? refresh() : true;
143 ISurfaceSharedPtr
pSurface(mpPage
->getSurface());
145 return pSurface
->update( maRect
.maPos
,
146 ::basegfx::B2IRectangle(
148 maSourceOffset
+ maRect
.maSize
),
155 IColorBufferSharedPtr mpBuffer
;
156 ::basegfx::B2IPoint maSourceOffset
;