nss: upgrade to release 3.73
[LibreOffice.git] / canvas / inc / rendering / irendermodule.hxx
blob527eedc9fd94f8c8df5aa17e57d342e0fbc4202a
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #pragma once
22 #include <memory>
24 namespace basegfx
26 class B2IVector;
29 namespace canvas
31 struct ISurface;
33 struct Vertex
35 float r,g,b,a;
36 float u,v;
37 float x,y,z;
40 /** Output module interface for backend render implementations.
42 Implement this interface for each operating system- or
43 library-specific rendering backend, which needs coupling with
44 the canvas rendering framework (which can be shared between
45 all backend implementations).
47 struct IRenderModule
49 /** Type of primitive passed to the render module via
50 pushVertex()
52 enum class PrimitiveType
54 Unknown,
55 Triangle,
56 Quad
59 virtual ~IRenderModule() {}
61 /// Lock rendermodule against concurrent access
62 virtual void lock() const = 0;
64 /// Unlock rendermodule for concurrent access
65 virtual void unlock() const = 0;
67 /** Maximal size of VRAM pages available
69 This is typically the maximum texture size of the
70 hardware, or some arbitrary limit if the backend is
71 software.
73 virtual ::basegfx::B2IVector getPageSize() = 0;
75 /** Create a (possibly hardware-accelerated) surface
77 @return a pointer to a surface, which is an abstraction of
78 a piece of (possibly hardware-accelerated) texture memory.
80 virtual std::shared_ptr<ISurface> createSurface( const ::basegfx::B2IVector& surfaceSize ) = 0;
82 /** Begin rendering the given primitive.
84 Each beginPrimitive() call must be matched with an
85 endPrimitive() call.
87 virtual void beginPrimitive( PrimitiveType eType ) = 0;
89 /** Finish rendering a primitive.
91 Each beginPrimitive() call must be matched with an
92 endPrimitive() call.
94 virtual void endPrimitive() = 0;
96 /** Add given vertex to current primitive
98 After issuing a beginPrimitive(), each pushVertex() adds a
99 vertex to the active primitive.
101 virtual void pushVertex( const Vertex& vertex ) = 0;
103 /** Query error status
105 @returns true, if an error occurred during primitive
106 construction.
108 virtual bool isError() = 0;
111 /// Little RAII wrapper for guarding access to IRenderModule interface
112 class RenderModuleGuard
114 public:
115 explicit RenderModuleGuard( const std::shared_ptr<IRenderModule>& rRenderModule ) :
116 mpRenderModule( rRenderModule )
118 mpRenderModule->lock();
121 ~RenderModuleGuard()
123 mpRenderModule->unlock();
126 RenderModuleGuard(const RenderModuleGuard&) = delete;
127 RenderModuleGuard& operator=( const RenderModuleGuard& ) = delete;
128 private:
129 const std::shared_ptr<IRenderModule> mpRenderModule;
133 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */