LCOV - code coverage report
Current view: top level - canvas/source/tools - page.hxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 0 35 0.0 %
Date: 2015-06-13 12:38:46 Functions: 0 15 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       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             : #ifndef INCLUDED_CANVAS_SOURCE_TOOLS_PAGE_HXX
      21             : #define INCLUDED_CANVAS_SOURCE_TOOLS_PAGE_HXX
      22             : 
      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>
      28             : 
      29             : #include <list>
      30             : #include <vector>
      31             : #include <boost/shared_ptr.hpp>
      32             : #include "surfacerect.hxx"
      33             : 
      34             : namespace canvas
      35             : {
      36             :     class PageFragment;
      37             : 
      38             :     typedef ::boost::shared_ptr< PageFragment > FragmentSharedPtr;
      39             : 
      40             :     /** One page of IRenderModule-provided texture space
      41             :      */
      42           0 :     class Page
      43             :     {
      44             :     public:
      45             :         explicit Page( const IRenderModuleSharedPtr& rRenderModule );
      46             : 
      47             :         FragmentSharedPtr        allocateSpace( const ::basegfx::B2ISize& rSize );
      48             :         bool                     nakedFragment( const FragmentSharedPtr& pFragment );
      49             :         void                     free( const FragmentSharedPtr& pFragment );
      50           0 :         const ISurfaceSharedPtr& getSurface() const { return mpSurface; }
      51             :         bool                     isValid() const;
      52             :         void                     validate();
      53             : 
      54             :     private:
      55             :         typedef std::list<FragmentSharedPtr> FragmentContainer_t;
      56             : 
      57             :         IRenderModuleSharedPtr  mpRenderModule;
      58             :         ISurfaceSharedPtr       mpSurface;
      59             :         FragmentContainer_t     mpFragments;
      60             : 
      61             :         bool insert( SurfaceRect& r );
      62             :         bool isValidLocation( const SurfaceRect& r ) const;
      63             :     };
      64             : 
      65             :     typedef ::boost::shared_ptr< Page > PageSharedPtr;
      66             : 
      67             : 
      68             :     /** A part of a page, which gets allocated to a surface
      69             :      */
      70           0 :     class PageFragment
      71             :     {
      72             :     public:
      73           0 :         PageFragment( const SurfaceRect& r,
      74             :                       Page*              pPage ) :
      75             :             mpPage(pPage),
      76             :             maRect(r),
      77             :             mpBuffer(),
      78           0 :             maSourceOffset()
      79             :         {
      80           0 :         }
      81             : 
      82             :         /// Creates a 'naked' fragment.
      83           0 :         explicit PageFragment( const ::basegfx::B2ISize& rSize ) :
      84             :             mpPage(NULL),
      85             :             maRect(rSize),
      86             :             mpBuffer(),
      87           0 :             maSourceOffset()
      88             :         {
      89           0 :         }
      90             : 
      91           0 :         bool                        isNaked() const { return (mpPage == NULL); }
      92           0 :         const SurfaceRect&          getRect() const { return maRect; }
      93           0 :         const ::basegfx::B2IPoint&  getPos() const { return maRect.maPos; }
      94           0 :         const ::basegfx::B2ISize&   getSize() const { return maRect.maSize; }
      95           0 :         void                        setColorBuffer( const IColorBufferSharedPtr& pColorBuffer ) { mpBuffer=pColorBuffer; }
      96           0 :         void                        setSourceOffset( const ::basegfx::B2IPoint& rOffset ) { maSourceOffset=rOffset; }
      97           0 :         void                        setPage( Page* pPage ) { mpPage=pPage; }
      98             : 
      99           0 :         void free( const FragmentSharedPtr& pFragment )
     100             :         {
     101           0 :             if(mpPage)
     102           0 :                 mpPage->free(pFragment);
     103             : 
     104           0 :             mpPage=NULL;
     105           0 :         }
     106             : 
     107           0 :         bool select( bool bRefresh )
     108             :         {
     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.
     112           0 :             if(!(mpPage))
     113           0 :                 return false;
     114             : 
     115           0 :             ISurfaceSharedPtr pSurface(mpPage->getSurface());
     116             : 
     117             :             // select this surface before wiping the contents
     118             :             // since a specific implementation could trigger
     119             :             // a rendering operation here...
     120           0 :             if(!(pSurface->selectTexture()))
     121           0 :                 return false;
     122             : 
     123             :             // call refresh() if requested, otherwise we're up to date...
     124           0 :             return !bRefresh || refresh();
     125             :         }
     126             : 
     127           0 :         bool refresh()
     128             :         {
     129           0 :             if(!(mpPage))
     130           0 :                 return false;
     131             : 
     132           0 :             ISurfaceSharedPtr pSurface(mpPage->getSurface());
     133             : 
     134           0 :             return pSurface->update( maRect.maPos,
     135             :                                      ::basegfx::B2IRectangle(
     136             :                                          maSourceOffset,
     137           0 :                                          maSourceOffset + maRect.maSize ),
     138           0 :                                      *mpBuffer );
     139             :         }
     140             : 
     141             :     private:
     142             :         Page*                 mpPage;
     143             :         SurfaceRect           maRect;
     144             :         IColorBufferSharedPtr mpBuffer;
     145             :         ::basegfx::B2IPoint   maSourceOffset;
     146             :     };
     147             : }
     148             : 
     149             : #endif
     150             : 
     151             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11