LCOV - code coverage report
Current view: top level - include/canvas/rendering - irendermodule.hxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 8 0.0 %
Date: 2014-04-14 Functions: 0 2 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_RENDERING_IRENDERMODULE_HXX
      21             : #define INCLUDED_CANVAS_RENDERING_IRENDERMODULE_HXX
      22             : 
      23             : #include <sal/types.h>
      24             : 
      25             : #include <boost/shared_ptr.hpp>
      26             : #include <boost/utility.hpp>
      27             : 
      28             : 
      29             : namespace basegfx
      30             : {
      31             :     class B2DRange;
      32             :     class B2IRange;
      33             :     class B2IVector;
      34             :     class B2IPoint;
      35             : }
      36             : 
      37             : namespace canvas
      38             : {
      39             :     struct ISurface;
      40             : 
      41             :     struct Vertex
      42             :     {
      43             :         float r,g,b,a;
      44             :         float u,v;
      45             :         float x,y,z;
      46             :     };
      47             : 
      48             :     /** Output module interface for backend render implementations.
      49             : 
      50             :         Implement this interface for each operating system- or
      51             :         library-specific rendering backend, which needs coupling with
      52             :         the canvas rendering framework (which can be shared between
      53             :         all backend implementations).
      54             :      */
      55             :     struct IRenderModule
      56             :     {
      57             :         /** Type of primitive passed to the render module via
      58             :             pushVertex()
      59             :          */
      60             :         enum PrimitiveType
      61             :         {
      62             :             PRIMITIVE_TYPE_UNKNOWN,
      63             :             PRIMITIVE_TYPE_TRIANGLE,
      64             :             PRIMITIVE_TYPE_QUAD
      65             :         };
      66             : 
      67             :         virtual ~IRenderModule() {}
      68             : 
      69             :         /// Lock rendermodule against concurrent access
      70             :         virtual void lock() const = 0;
      71             : 
      72             :         /// Unlock rendermodule for concurrent access
      73             :         virtual void unlock() const = 0;
      74             : 
      75             :         /** Maximal size of VRAM pages available
      76             : 
      77             :             This is typically the maximum texture size of the
      78             :             hardware, or some arbitrary limit if the backend is
      79             :             software.
      80             :          */
      81             :         virtual ::basegfx::B2IVector getPageSize() = 0;
      82             : 
      83             :         /** Create a (possibly hardware-accelerated) surface
      84             : 
      85             :             @return a pointer to a surface, which is an abstraction of
      86             :             a piece of (possibly hardware-accelerated) texture memory.
      87             :          */
      88             :         virtual ::boost::shared_ptr<ISurface> createSurface( const ::basegfx::B2IVector& surfaceSize ) = 0;
      89             : 
      90             :         /** Begin rendering the given primitive.
      91             : 
      92             :             Each beginPrimitive() call must be matched with an
      93             :             endPrimitive() call.
      94             :          */
      95             :         virtual void      beginPrimitive( PrimitiveType eType ) = 0;
      96             : 
      97             :         /** Finish rendering a primitive.
      98             : 
      99             :             Each beginPrimitive() call must be matched with an
     100             :             endPrimitive() call.
     101             :          */
     102             :         virtual void      endPrimitive() = 0;
     103             : 
     104             :         /** Add given vertex to current primitive
     105             : 
     106             :             After issuing a beginPrimitive(), each pushVertex() adds a
     107             :             vertex to the active primitive.
     108             :          */
     109             :         virtual void      pushVertex( const Vertex& vertex ) = 0;
     110             : 
     111             :         /** Query error status
     112             : 
     113             :             @returns true, if an error occurred during primitive
     114             :             construction.
     115             :          */
     116             :         virtual bool      isError() = 0;
     117             :     };
     118             : 
     119             :     typedef ::boost::shared_ptr< IRenderModule > IRenderModuleSharedPtr;
     120             : 
     121             :     /// Little RAII wrapper for guarding access to IRenderModule interface
     122             :     class RenderModuleGuard : private ::boost::noncopyable
     123             :     {
     124             :     public:
     125           0 :         explicit RenderModuleGuard( const IRenderModuleSharedPtr& rRenderModule ) :
     126           0 :             mpRenderModule( rRenderModule )
     127             :         {
     128           0 :             mpRenderModule->lock();
     129           0 :         }
     130             : 
     131           0 :         ~RenderModuleGuard()
     132           0 :         {
     133           0 :             mpRenderModule->unlock();
     134           0 :         }
     135             : 
     136             :     private:
     137             :         const IRenderModuleSharedPtr mpRenderModule;
     138             :     };
     139             : }
     140             : 
     141             : #endif // INCLUDED_CANVAS_RENDERING_IRENDERMODULE_HXX
     142             : 
     143             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10