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_PAGE_HXX
21 #define INCLUDED_CANVAS_SOURCE_TOOLS_PAGE_HXX
23 #include <basegfx/vector/b2isize.hxx>
24 #include <basegfx/range/b2irectangle.hxx>
25 #include <canvas/rendering/icolorbuffer.hxx>
26 #include <canvas/rendering/irendermodule.hxx>
27 #include <canvas/rendering/isurface.hxx>
31 #include <boost/shared_ptr.hpp>
32 #include "surfacerect.hxx"
38 typedef ::boost::shared_ptr
< PageFragment
> FragmentSharedPtr
;
40 /** One page of IRenderModule-provided texture space
45 Page( const IRenderModuleSharedPtr
& rRenderModule
);
47 FragmentSharedPtr
allocateSpace( const ::basegfx::B2ISize
& rSize
);
48 bool nakedFragment( const FragmentSharedPtr
& pFragment
);
49 void free( const FragmentSharedPtr
& pFragment
);
50 const ISurfaceSharedPtr
& getSurface() const { return mpSurface
; }
55 typedef std::list
<FragmentSharedPtr
> FragmentContainer_t
;
57 IRenderModuleSharedPtr mpRenderModule
;
58 ISurfaceSharedPtr mpSurface
;
59 FragmentContainer_t mpFragments
;
61 bool insert( SurfaceRect
& r
);
62 bool isValidLocation( const SurfaceRect
& r
) const;
65 typedef ::boost::shared_ptr
< Page
> PageSharedPtr
;
68 /** A part of a page, which gets allocated to a surface
73 PageFragment( const SurfaceRect
& r
,
82 /// Creates a 'naked' fragment.
83 PageFragment( const ::basegfx::B2ISize
& rSize
) :
91 bool isNaked() const { return (mpPage
== NULL
); }
92 const SurfaceRect
& getRect() const { return maRect
; }
93 const ::basegfx::B2IPoint
& getPos() const { return maRect
.maPos
; }
94 const ::basegfx::B2ISize
& getSize() const { return maRect
.maSize
; }
95 void setColorBuffer( const IColorBufferSharedPtr
& pColorBuffer
) { mpBuffer
=pColorBuffer
; }
96 void setSourceOffset( const ::basegfx::B2IPoint
& rOffset
) { maSourceOffset
=rOffset
; }
97 void setPage( Page
* pPage
) { mpPage
=pPage
; }
99 void free( const FragmentSharedPtr
& pFragment
)
102 mpPage
->free(pFragment
);
107 bool select( bool bRefresh
)
109 // request was made to select this fragment,
110 // but this fragment has not been located on any
111 // of the available pages, we need to hurry now.
115 ISurfaceSharedPtr
pSurface(mpPage
->getSurface());
117 // select this surface before wiping the contents
118 // since a specific implementation could trigger
119 // a rendering operation here...
120 if(!(pSurface
->selectTexture()))
123 // call refresh() if requested, otherwise we're up to date...
124 return !bRefresh
|| refresh();
132 ISurfaceSharedPtr
pSurface(mpPage
->getSurface());
134 return pSurface
->update( maRect
.maPos
,
135 ::basegfx::B2IRectangle(
137 maSourceOffset
+ maRect
.maSize
),
144 IColorBufferSharedPtr mpBuffer
;
145 ::basegfx::B2IPoint maSourceOffset
;
151 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */