LibreOffice Module canvas (master)  1
irendermodule.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 
22 #include <memory>
23 
24 namespace basegfx
25 {
26  class B2IVector;
27 }
28 
29 namespace canvas
30 {
31  struct ISurface;
32 
33  struct Vertex
34  {
35  float r,g,b,a;
36  float u,v;
37  float x,y,z;
38  };
39 
48  {
52  enum class PrimitiveType
53  {
54  Unknown,
55  Triangle,
56  Quad
57  };
58 
59  virtual ~IRenderModule() {}
60 
62  virtual void lock() const = 0;
63 
65  virtual void unlock() const = 0;
66 
73  virtual ::basegfx::B2IVector getPageSize() = 0;
74 
80  virtual std::shared_ptr<ISurface> createSurface( const ::basegfx::B2IVector& surfaceSize ) = 0;
81 
87  virtual void beginPrimitive( PrimitiveType eType ) = 0;
88 
94  virtual void endPrimitive() = 0;
95 
101  virtual void pushVertex( const Vertex& vertex ) = 0;
102 
108  virtual bool isError() = 0;
109  };
110 
113  {
114  public:
115  explicit RenderModuleGuard( const std::shared_ptr<IRenderModule>& rRenderModule ) :
116  mpRenderModule( rRenderModule )
117  {
118  mpRenderModule->lock();
119  }
120 
122  {
123  mpRenderModule->unlock();
124  }
125 
126  RenderModuleGuard(const RenderModuleGuard&) = delete;
127  RenderModuleGuard& operator=( const RenderModuleGuard& ) = delete;
128  private:
129  const std::shared_ptr<IRenderModule> mpRenderModule;
130  };
131 }
132 
133 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
virtual ::basegfx::B2IVector getPageSize()=0
Maximal size of VRAM pages available.
RenderModuleGuard & operator=(const RenderModuleGuard &)=delete
virtual std::shared_ptr< ISurface > createSurface(const ::basegfx::B2IVector &surfaceSize)=0
Create a (possibly hardware-accelerated) surface.
virtual void pushVertex(const Vertex &vertex)=0
Add given vertex to current primitive.
PrimitiveType
Type of primitive passed to the render module via pushVertex()
virtual bool isError()=0
Query error status.
virtual void lock() const =0
Lock rendermodule against concurrent access.
Little RAII wrapper for guarding access to IRenderModule interface.
virtual void unlock() const =0
Unlock rendermodule for concurrent access.
const std::shared_ptr< IRenderModule > mpRenderModule
virtual void beginPrimitive(PrimitiveType eType)=0
Begin rendering the given primitive.
RenderModuleGuard(const std::shared_ptr< IRenderModule > &rRenderModule)
Output module interface for backend render implementations.
virtual void endPrimitive()=0
Finish rendering a primitive.