• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 //
2 // Copyright 2016 The ANGLE Project Authors. All rights reserved.
3 // Use of this source code is governed by a BSD-style license that can be
4 // found in the LICENSE file.
5 //
6 
7 // DisplayAndroid.h: Android implementation of egl::Display
8 
9 #ifndef LIBANGLE_RENDERER_GL_EGL_ANDROID_DISPLAYANDROID_H_
10 #define LIBANGLE_RENDERER_GL_EGL_ANDROID_DISPLAYANDROID_H_
11 
12 #include <map>
13 #include <string>
14 #include <thread>
15 #include <vector>
16 
17 #include "libANGLE/renderer/gl/egl/DisplayEGL.h"
18 
19 namespace rx
20 {
21 
22 class RendererEGL;
23 
24 class DisplayAndroid : public DisplayEGL
25 {
26   public:
27     DisplayAndroid(const egl::DisplayState &state);
28     ~DisplayAndroid() override;
29 
30     egl::Error initialize(egl::Display *display) override;
31     void terminate() override;
32 
33     ContextImpl *createContext(const gl::State &state,
34                                gl::ErrorSet *errorSet,
35                                const egl::Config *configuration,
36                                const gl::Context *shareContext,
37                                const egl::AttributeMap &attribs) override;
38 
39     bool isValidNativeWindow(EGLNativeWindowType window) const override;
40     egl::Error validateImageClientBuffer(const gl::Context *context,
41                                          EGLenum target,
42                                          EGLClientBuffer clientBuffer,
43                                          const egl::AttributeMap &attribs) const override;
44 
45     ExternalImageSiblingImpl *createExternalImageSibling(const gl::Context *context,
46                                                          EGLenum target,
47                                                          EGLClientBuffer buffer,
48                                                          const egl::AttributeMap &attribs) override;
49 
50     egl::Error makeCurrent(egl::Surface *drawSurface,
51                            egl::Surface *readSurface,
52                            gl::Context *context) override;
53 
54     void destroyNativeContext(EGLContext context) override;
55 
56     WorkerContext *createWorkerContext(std::string *infoLog,
57                                        EGLContext sharedContext,
58                                        const native_egl::AttributeVector workerAttribs) override;
59 
60   private:
61     void generateExtensions(egl::DisplayExtensions *outExtensions) const override;
62 
63     egl::Error createRenderer(EGLContext shareContext,
64                               bool makeNewContextCurrent,
65                               std::shared_ptr<RendererEGL> *outRenderer);
66 
67     bool mVirtualizedContexts;
68 
69     bool mSupportsSurfaceless;
70 
71     EGLSurface mDummyPbuffer;
72 
73     struct CurrentNativeContext
74     {
75         EGLSurface surface = EGL_NO_SURFACE;
76         EGLContext context = EGL_NO_CONTEXT;
77     };
78     std::unordered_map<std::thread::id, CurrentNativeContext> mCurrentNativeContext;
79 };
80 
81 }  // namespace rx
82 
83 #endif  // LIBANGLE_RENDERER_GL_EGL_ANDROID_DISPLAYANDROID_H_
84