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#include <utility>
24
25namespace basegfx
26{
27 class B2IVector;
28}
29
30namespace canvas
31{
32 struct ISurface;
33
34 struct Vertex
35 {
36 float r,g,b,a;
37 float u,v;
38 float x,y,z;
39 };
40
49 {
53 enum class PrimitiveType
54 {
55 Unknown,
56 Triangle,
57 Quad
58 };
59
60 virtual ~IRenderModule() {}
61
63 virtual void lock() const = 0;
64
66 virtual void unlock() const = 0;
67
74 virtual ::basegfx::B2IVector getPageSize() = 0;
75
81 virtual std::shared_ptr<ISurface> createSurface( const ::basegfx::B2IVector& surfaceSize ) = 0;
82
88 virtual void beginPrimitive( PrimitiveType eType ) = 0;
89
95 virtual void endPrimitive() = 0;
96
102 virtual void pushVertex( const Vertex& vertex ) = 0;
103
109 virtual bool isError() = 0;
110 };
111
114 {
115 public:
116 explicit RenderModuleGuard( std::shared_ptr<IRenderModule> xRenderModule ) :
117 mpRenderModule(std::move( xRenderModule ))
118 {
119 mpRenderModule->lock();
120 }
121
123 {
124 mpRenderModule->unlock();
125 }
126
129 private:
130 const std::shared_ptr<IRenderModule> mpRenderModule;
131 };
132}
133
134/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Little RAII wrapper for guarding access to IRenderModule interface.
const std::shared_ptr< IRenderModule > mpRenderModule
RenderModuleGuard(const RenderModuleGuard &)=delete
RenderModuleGuard & operator=(const RenderModuleGuard &)=delete
RenderModuleGuard(std::shared_ptr< IRenderModule > xRenderModule)
Unknown
Output module interface for backend render implementations.
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.
virtual ::basegfx::B2IVector getPageSize()=0
Maximal size of VRAM pages available.
PrimitiveType
Type of primitive passed to the render module via pushVertex()
virtual void endPrimitive()=0
Finish rendering a primitive.
virtual void unlock() const =0
Unlock rendermodule for concurrent access.
virtual void beginPrimitive(PrimitiveType eType)=0
Begin rendering the given primitive.
virtual bool isError()=0
Query error status.
virtual void lock() const =0
Lock rendermodule against concurrent access.