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 .
22 #include <basegfx/vector/b2isize.hxx>
23 #include <basegfx/vector/b2ivector.hxx>
24 #include <basegfx/range/b2irectangle.hxx>
25 #include <rendering/icolorbuffer.hxx>
26 #include <rendering/irendermodule.hxx>
27 #include <rendering/isurface.hxx>
31 #include "surfacerect.hxx"
37 typedef std::shared_ptr
< PageFragment
> FragmentSharedPtr
;
39 /** One page of IRenderModule-provided texture space
44 explicit Page( const std::shared_ptr
<IRenderModule
>& rRenderModule
);
46 FragmentSharedPtr
allocateSpace( const ::basegfx::B2ISize
& rSize
);
47 bool nakedFragment( const FragmentSharedPtr
& pFragment
);
48 void free( const FragmentSharedPtr
& pFragment
);
49 const std::shared_ptr
<ISurface
>& getSurface() const { return mpSurface
; }
54 typedef std::vector
<FragmentSharedPtr
> FragmentContainer_t
;
56 std::shared_ptr
<IRenderModule
> mpRenderModule
;
57 std::shared_ptr
<ISurface
> mpSurface
;
58 FragmentContainer_t mpFragments
;
60 bool insert( SurfaceRect
& r
);
61 bool isValidLocation( const SurfaceRect
& r
) const;
64 typedef std::shared_ptr
< Page
> PageSharedPtr
;
67 /** A part of a page, which gets allocated to a surface
72 PageFragment( const SurfaceRect
& r
,
81 /// Creates a 'naked' fragment.
82 explicit PageFragment( const ::basegfx::B2ISize
& rSize
) :
90 bool isNaked() const { return (mpPage
== nullptr); }
91 const SurfaceRect
& getRect() const { return maRect
; }
92 const ::basegfx::B2IPoint
& getPos() const { return maRect
.maPos
; }
93 const ::basegfx::B2ISize
& getSize() const { return maRect
.maSize
; }
94 void setColorBuffer( const std::shared_ptr
<IColorBuffer
>& pColorBuffer
) { mpBuffer
=pColorBuffer
; }
95 void setSourceOffset( const ::basegfx::B2IPoint
& rOffset
) { maSourceOffset
=rOffset
; }
96 void setPage( Page
* pPage
) { mpPage
=pPage
; }
98 void free( const FragmentSharedPtr
& pFragment
)
101 mpPage
->free(pFragment
);
106 bool select( bool bRefresh
)
108 // request was made to select this fragment,
109 // but this fragment has not been located on any
110 // of the available pages, we need to hurry now.
114 std::shared_ptr
<ISurface
> pSurface(mpPage
->getSurface());
116 // select this surface before wiping the contents
117 // since a specific implementation could trigger
118 // a rendering operation here...
119 if(!(pSurface
->selectTexture()))
122 // call refresh() if requested, otherwise we're up to date...
123 return !bRefresh
|| refresh();
131 std::shared_ptr
<ISurface
> pSurface(mpPage
->getSurface());
133 return pSurface
->update( maRect
.maPos
,
134 ::basegfx::B2IRectangle(
136 maSourceOffset
+ basegfx::B2IVector(maRect
.maSize
.getWidth(), maRect
.maSize
.getHeight())),
143 std::shared_ptr
<IColorBuffer
> mpBuffer
;
144 ::basegfx::B2IPoint maSourceOffset
;
148 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */