1 #ifndef _TCUIOSPLATFORM_HPP
2 #define _TCUIOSPLATFORM_HPP
3 /*-------------------------------------------------------------------------
4 * drawElements Quality Program Tester Core
5 * ----------------------------------------
7 * Copyright 2014 The Android Open Source Project
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
13 * http://www.apache.org/licenses/LICENSE-2.0
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.
23 * \brief iOS Platform implementation.
24 *//*--------------------------------------------------------------------*/
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"
36 #import "tcuEAGLView.h"
38 #import <OpenGLES/EAGL.h>
48 ScreenManager (tcuEAGLView* view);
49 ~ScreenManager (void);
51 CAEAGLLayer* acquireScreen (void);
52 void releaseScreen (CAEAGLLayer* layer);
55 ScreenManager (const ScreenManager&);
56 ScreenManager& operator= (const ScreenManager&);
62 class ContextFactory : public glu::ContextFactory
65 ContextFactory (ScreenManager* screenManager);
66 ~ContextFactory (void);
68 glu::RenderContext* createContext (const glu::RenderConfig& config, const tcu::CommandLine& cmdLine) const;
71 ScreenManager* const m_screenManager;
74 class Platform : public tcu::Platform, private glu::Platform
77 Platform (ScreenManager* screenManager);
78 virtual ~Platform (void);
80 const glu::Platform& getGLPlatform (void) const { return static_cast<const glu::Platform&>(*this); }
83 //! EAGLContext-backed rendering context. Doesn't have default framebuffer.
84 class RawContext : public glu::RenderContext
87 RawContext (glu::ContextType type);
88 virtual ~RawContext (void);
90 virtual glu::ContextType getType (void) const { return m_type; }
91 virtual const glw::Functions& getFunctions (void) const { return m_functions; }
92 virtual const RenderTarget& getRenderTarget (void) const { return m_emptyTarget; }
93 virtual deUint32 getDefaultFramebuffer (void) const { DE_FATAL("No framebuffer"); return 0; }
94 virtual void postIterate (void);
97 EAGLContext* getEAGLContext (void) const { return m_context; }
100 glu::ContextType m_type;
101 EAGLContext* m_context;
102 glw::Functions m_functions;
103 tcu::RenderTarget m_emptyTarget;
106 class ScreenContext : public RawContext
109 ScreenContext (ScreenManager* screenManager, const glu::RenderConfig& config);
110 ~ScreenContext (void);
112 virtual const RenderTarget& getRenderTarget (void) const { return m_renderTarget; }
113 virtual deUint32 getDefaultFramebuffer (void) const { return *m_framebuffer; }
114 virtual void postIterate (void);
117 void createFramebuffer (const glu::RenderConfig& config);
119 ScreenManager* m_screenManager;
120 CAEAGLLayer* m_layer;
122 glu::Framebuffer m_framebuffer;
123 glu::Renderbuffer m_colorBuffer;
124 glu::Renderbuffer m_depthStencilBuffer;
125 tcu::RenderTarget m_renderTarget;
131 #endif // _TCUIOSPLATFORM_H