Argus Camera Sample Argus Camera Sample

- Main Page
- Related Pages
- Namespaces
- Classes
- Files

- File List
- File Members

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Renderer.h
Go to the documentation of this file.
1 /*
2 * Copyright (c) 2016, NVIDIA CORPORATION. All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
6 * are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of NVIDIA CORPORATION nor the names of its
13 * contributors may be used to endorse or promote products derived
14 * from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
19 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
20 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
21 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
22 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
23 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
24 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 */
28
29 #ifndef RENDERER_H
30 #define RENDERER_H
31
32 #include "Composer.h"
33 #include "EGLGlobal.h"
34
35 namespace ArgusSamples
36 {
37
38 /**
39 * Renderer. Provide functions to create/destroy EGL streams and display them.
40 */
41 class Renderer
42 {
43 public:
44 /**
45 * Get the window instance.
46 */
47 static Renderer &getInstance();
48
49 /**
50 * Shutdown, free all resources
51 */
52 bool shutdown();
53
54 /**
55 * Bind an EGL stream
56 *
57 * @param eglStream [in]
58 */
59 bool bindStream(EGLStreamKHR eglStream);
60
61 /**
62 * Unbind a bound EGL stream
63 *
64 * @param eglStream [in]
65 */
66 bool unbindStream(EGLStreamKHR eglStream);
67
68 /**
69 * Set the active state of the stream, only active streams are rendered
70 *
71 * @param eglStream [in]
72 * @param active [in]
73 */
74 bool setStreamActive(EGLStreamKHR eglStream, bool active);
75
76 /**
77 * Set the stream aspect ratio
78 *
79 * @param eglStream [in]
80 * @param aspectRatio [in] aspect ration of the images transported by the stream
81 */
82 bool setStreamAspectRatio(EGLStreamKHR eglStream, float aspectRatio);
83
84 /**
85 * Get the EGL display
86 */
87 EGLDisplay getEGLDisplay()
88 {
89 if (initialize())
90 return m_display.get();
91
92 return EGL_NO_DISPLAY;
93 }
94
95 /**
96 * Get the composer EGL context
97 */
98 const GLContext& getComposerContext() const
99 {
100 return m_composer.getContext();
101 }
102
103 /**
104 * Trigger a re-compose. Called when new images arrived in a stream.
105 */
106 bool reCompose();
107
108 private:
109 Renderer();
110 ~Renderer();
111
112 // this is a singleton, hide copy constructor etc.
113 Renderer(const Renderer&);
114 Renderer& operator=(const Renderer&);
115
116 bool initialize();
117
118 bool m_initialized; ///< set if initialized
119
120 EGLDisplayHolder m_display; ///< EGL display
121
122 Composer m_composer; ///< the composer renders streams
123 };
124
125 }; // namespace ArgusSamples
126
127 #endif // RENDERER_H