TYPE3
[iec.git] / src / type3_AndroidCloud / anbox-master / src / anbox / graphics / emugl / RenderContext.h
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
17 #ifndef _LIBRENDER_RENDER_CONTEXT_H
18 #define _LIBRENDER_RENDER_CONTEXT_H
19
20 #include "external/android-emugl/shared/OpenglCodecCommon/GLDecoderContextData.h"
21
22 #include <EGL/egl.h>
23
24 #include <memory>
25
26 // A class used to model a guest EGLContext. This simply wraps a host
27 // EGLContext, associated with an GLDecoderContextData instance that is
28 // used to store copies of guest-side arrays.
29 class RenderContext {
30  public:
31   // Create a new RenderContext instance.
32   // |display| is the host EGLDisplay handle.
33   // |config| is the host EGLConfig to use.
34   // |sharedContext| is either EGL_NO_CONTEXT of a host EGLContext handle.
35   // |isGl2| is true iff the new context will be used with GLESv2, or
36   // GLESv1 otherwise.
37   static RenderContext* create(EGLDisplay display, EGLConfig config,
38                                EGLContext sharedContext, bool isGL2 = false);
39
40   // Destructor.
41   ~RenderContext();
42
43   // Retrieve host EGLContext value.
44   EGLContext getEGLContext() const { return mContext; }
45
46   // Return true iff this is a GLESv2 context.
47   bool isGL2() const { return mIsGl2; }
48
49   // Retrieve GLDecoderContextData instance reference for this
50   // RenderContext instance.
51   GLDecoderContextData& decoderContextData() { return mContextData; }
52
53  private:
54   RenderContext();
55
56   RenderContext(EGLDisplay display, EGLContext context, bool isGl2);
57
58  private:
59   EGLDisplay mDisplay;
60   EGLContext mContext;
61   bool mIsGl2;
62   GLDecoderContextData mContextData;
63 };
64
65 typedef std::shared_ptr<RenderContext> RenderContextPtr;
66
67 #endif  // _LIBRENDER_RENDER_CONTEXT_H