1 /* 2 * Copyright (C) 2011 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 #ifndef EGL_CONTEXT_H 17 #define EGL_CONTEXT_H 18 19 #include "aemu/base/files/Stream.h" 20 21 #include "EglConfig.h" 22 #include "EglOsApi.h" 23 #include "EglSurface.h" 24 25 #include "GLcommon/GLutils.h" 26 #include "GLcommon/TranslatorIfaces.h" 27 #include "GLcommon/ShareGroup.h" 28 29 #include <EGL/egl.h> 30 31 #include <memory> 32 33 class EglContext; 34 typedef std::shared_ptr<EglContext> ContextPtr; 35 36 class EglDisplay; 37 38 class EglContext { 39 public: 40 EglContext(EglDisplay* dpy, 41 uint64_t shareGroupId, 42 EglConfig* config, 43 GLEScontext* glesCtx, 44 GLESVersion ver, 45 EGLint profile_mask, 46 ObjectNameManager* mngr, 47 android::base::Stream* stream); 48 bool usingSurface(SurfacePtr surface); nativeType()49 EglOS::Context* nativeType() const { return m_native.get(); } 50 bool getAttrib(EGLint attrib, EGLint* value); read()51 const SurfacePtr& read() const { return m_read; }; draw()52 const SurfacePtr& draw() const { return m_draw; }; getShareGroup()53 const ShareGroupPtr& getShareGroup() const { return m_shareGroup; } getConfig()54 EglConfig* getConfig() { return m_config; }; version()55 GLESVersion version() { return m_version; }; getGlesContext()56 GLEScontext* getGlesContext() { return m_glesContext; } 57 void setSurfaces(SurfacePtr read, SurfacePtr draw); getHndl()58 unsigned int getHndl() { return m_hndl; } 59 60 ~EglContext(); 61 void onSave(android::base::Stream* stream); 62 void postSave(android::base::Stream* stream); 63 64 private: 65 static unsigned int s_nextContextHndl; 66 EglDisplay* m_dpy = nullptr; 67 std::shared_ptr<EglOS::Context> m_native = {}; 68 EglConfig* m_config = nullptr; 69 GLEScontext* m_glesContext = nullptr; 70 ShareGroupPtr m_shareGroup; 71 SurfacePtr m_read; 72 SurfacePtr m_draw; 73 GLESVersion m_version; 74 ObjectNameManager* m_mngr = nullptr; 75 unsigned int m_hndl = 0; 76 EGLint m_profileMask = 0; 77 }; 78 79 #endif 80