xref: /aosp_15_r20/external/deqp/framework/platform/ios/tcuIOSPlatform.hh (revision 35238bce31c2a825756842865a792f8cf7f89930)
1 #ifndef _TCUIOSPLATFORM_HPP
2 #define _TCUIOSPLATFORM_HPP
3 /*-------------------------------------------------------------------------
4  * drawElements Quality Program Tester Core
5  * ----------------------------------------
6  *
7  * Copyright 2014 The Android Open Source Project
8  *
9  * Licensed under the Apache License, Version 2.0 (the "License");
10  * you may not use this file except in compliance with the License.
11  * You may obtain a copy of the License at
12  *
13  *      http://www.apache.org/licenses/LICENSE-2.0
14  *
15  * Unless required by applicable law or agreed to in writing, software
16  * distributed under the License is distributed on an "AS IS" BASIS,
17  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18  * See the License for the specific language governing permissions and
19  * limitations under the License.
20  *
21  *//*!
22  * \file
23  * \brief iOS Platform implementation.
24  *//*--------------------------------------------------------------------*/
25 
26 #include "tcuDefs.hpp"
27 #include "tcuPlatform.hpp"
28 #include "gluPlatform.hpp"
29 #include "gluRenderContext.hpp"
30 #include "gluContextFactory.hpp"
31 #include "gluObjectWrapper.hpp"
32 #include "tcuRenderTarget.hpp"
33 #include "glwFunctions.hpp"
34 #include "deMutex.hpp"
35 
36 #import "tcuEAGLView.h"
37 
38 #import <OpenGLES/EAGL.h>
39 
40 namespace tcu
41 {
42 namespace ios
43 {
44 
45 class ScreenManager
46 {
47 public:
48     ScreenManager(tcuEAGLView *view);
49     ~ScreenManager(void);
50 
51     CAEAGLLayer *acquireScreen(void);
52     void releaseScreen(CAEAGLLayer *layer);
53 
54 private:
55     ScreenManager(const ScreenManager &);
56     ScreenManager &operator=(const ScreenManager &);
57 
58     tcuEAGLView *m_view;
59     de::Mutex m_viewLock;
60 };
61 
62 class ContextFactory : public glu::ContextFactory
63 {
64 public:
65     ContextFactory(ScreenManager *screenManager);
66     ~ContextFactory(void);
67 
68     glu::RenderContext *createContext(const glu::RenderConfig &config, const tcu::CommandLine &cmdLine) const;
69 
70 private:
71     ScreenManager *const m_screenManager;
72 };
73 
74 class Platform : public tcu::Platform, private glu::Platform
75 {
76 public:
77     Platform(ScreenManager *screenManager);
78     virtual ~Platform(void);
79 
getGLPlatform(void) const80     const glu::Platform &getGLPlatform(void) const
81     {
82         return static_cast<const glu::Platform &>(*this);
83     }
84 };
85 
86 //! EAGLContext-backed rendering context. Doesn't have default framebuffer.
87 class RawContext : public glu::RenderContext
88 {
89 public:
90     RawContext(glu::ContextType type);
91     virtual ~RawContext(void);
92 
getType(void) const93     virtual glu::ContextType getType(void) const
94     {
95         return m_type;
96     }
getFunctions(void) const97     virtual const glw::Functions &getFunctions(void) const
98     {
99         return m_functions;
100     }
getRenderTarget(void) const101     virtual const RenderTarget &getRenderTarget(void) const
102     {
103         return m_emptyTarget;
104     }
getDefaultFramebuffer(void) const105     virtual uint32_t getDefaultFramebuffer(void) const
106     {
107         DE_FATAL("No framebuffer");
108         return 0;
109     }
110     virtual void postIterate(void);
111 
112 protected:
getEAGLContext(void) const113     EAGLContext *getEAGLContext(void) const
114     {
115         return m_context;
116     }
117 
118 private:
119     glu::ContextType m_type;
120     EAGLContext *m_context;
121     glw::Functions m_functions;
122     tcu::RenderTarget m_emptyTarget;
123 };
124 
125 class ScreenContext : public RawContext
126 {
127 public:
128     ScreenContext(ScreenManager *screenManager, const glu::RenderConfig &config);
129     ~ScreenContext(void);
130 
getRenderTarget(void) const131     virtual const RenderTarget &getRenderTarget(void) const
132     {
133         return m_renderTarget;
134     }
getDefaultFramebuffer(void) const135     virtual uint32_t getDefaultFramebuffer(void) const
136     {
137         return *m_framebuffer;
138     }
139     virtual void postIterate(void);
140 
141 private:
142     void createFramebuffer(const glu::RenderConfig &config);
143 
144     ScreenManager *m_screenManager;
145     CAEAGLLayer *m_layer;
146 
147     glu::Framebuffer m_framebuffer;
148     glu::Renderbuffer m_colorBuffer;
149     glu::Renderbuffer m_depthStencilBuffer;
150     tcu::RenderTarget m_renderTarget;
151 };
152 
153 } // namespace ios
154 } // namespace tcu
155 
156 #endif // _TCUIOSPLATFORM_H
157