LibreOffice Module canvas (master)  1
pagemanager.hxx
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3  * This file is part of the LibreOffice project.
4  *
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/.
8  *
9  * This file incorporates work covered by the following license notice:
10  *
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 .
18  */
19 
20 #pragma once
21 
24 
25 #include "page.hxx"
26 
27 namespace canvas
28 {
29  // PageManager
31  {
32  public:
33  explicit PageManager(const std::shared_ptr<canvas::IRenderModule>& rRenderModule)
34  : mpRenderModule(rRenderModule)
35  {
36  }
37 
38  // returns the maximum size of a hardware
39  // accelerated page, e.g. OpenGL texture.
41 
42  const std::shared_ptr<canvas::IRenderModule>& getRenderModule() const { return mpRenderModule; }
43 
44  FragmentSharedPtr allocateSpace( const ::basegfx::B2ISize& rSize );
45  void free( const FragmentSharedPtr& pFragment );
46 
47  void nakedFragment( const FragmentSharedPtr& pFragment );
48 
49  void validatePages();
50 
51  private:
52  // the pagemanager needs access to the rendermodule
53  // since we query for system resources from it.
54  std::shared_ptr<canvas::IRenderModule> mpRenderModule;
55 
56  // here we collect all fragments that will be created
57  // since we need them for relocation purposes.
58  typedef std::vector<FragmentSharedPtr> FragmentContainer_t;
59  FragmentContainer_t maFragments;
60 
61  // this is the container holding all created pages,
62  // behind the scenes these are real hardware surfaces.
63  std::vector<PageSharedPtr> maPages;
64 
65  bool relocate( const FragmentSharedPtr& pFragment );
66  };
67 
68 
69  // PageManagerSharedPtr
70 
71 
72  typedef std::shared_ptr< PageManager > PageManagerSharedPtr;
73 }
74 
75 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
bool relocate(const FragmentSharedPtr &pFragment)
void free(const FragmentSharedPtr &pFragment)
Definition: pagemanager.cxx:64
std::shared_ptr< PageManager > PageManagerSharedPtr
Definition: pagemanager.hxx:72
PageManager(const std::shared_ptr< canvas::IRenderModule > &rRenderModule)
Definition: pagemanager.hxx:33
FragmentSharedPtr allocateSpace(const ::basegfx::B2ISize &rSize)
Definition: pagemanager.cxx:26
FragmentContainer_t maFragments
Definition: pagemanager.hxx:59
std::vector< FragmentSharedPtr > FragmentContainer_t
Definition: pagemanager.hxx:58
void nakedFragment(const FragmentSharedPtr &pFragment)
Definition: pagemanager.cxx:80
::basegfx::B2ISize getPageSize() const
std::shared_ptr< canvas::IRenderModule > mpRenderModule
Definition: pagemanager.hxx:54
std::vector< PageSharedPtr > maPages
Definition: pagemanager.hxx:63
const std::shared_ptr< canvas::IRenderModule > & getRenderModule() const
Definition: pagemanager.hxx:42
std::shared_ptr< PageFragment > FragmentSharedPtr
Definition: page.hxx:34