• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 //
2 // Copyright 2014 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 // DisplayImpl.h: Implementation methods of egl::Display
8 
9 #ifndef LIBANGLE_RENDERER_DISPLAYIMPL_H_
10 #define LIBANGLE_RENDERER_DISPLAYIMPL_H_
11 
12 #include "common/angleutils.h"
13 #include "libANGLE/Caps.h"
14 #include "libANGLE/Config.h"
15 #include "libANGLE/Error.h"
16 #include "libANGLE/Observer.h"
17 #include "libANGLE/Stream.h"
18 #include "libANGLE/Version.h"
19 #include "libANGLE/renderer/EGLImplFactory.h"
20 #include "platform/Feature.h"
21 
22 #include <set>
23 #include <vector>
24 
25 namespace angle
26 {
27 struct FrontendFeatures;
28 }  // namespace angle
29 
30 namespace egl
31 {
32 class AttributeMap;
33 class BlobCache;
34 class Display;
35 struct DisplayState;
36 struct Config;
37 class Surface;
38 class ImageSibling;
39 class Thread;
40 }  // namespace egl
41 
42 namespace gl
43 {
44 class Context;
45 }  // namespace gl
46 
47 namespace rx
48 {
49 class SurfaceImpl;
50 class ImageImpl;
51 struct ConfigDesc;
52 class DeviceImpl;
53 class StreamProducerImpl;
54 
55 class ShareGroupImpl : angle::NonCopyable
56 {
57   public:
ShareGroupImpl()58     ShareGroupImpl() {}
~ShareGroupImpl()59     virtual ~ShareGroupImpl() {}
onDestroy(const egl::Display * display)60     virtual void onDestroy(const egl::Display *display) {}
61 };
62 
63 class DisplayImpl : public EGLImplFactory, public angle::Subject
64 {
65   public:
66     DisplayImpl(const egl::DisplayState &state);
67     ~DisplayImpl() override;
68 
69     virtual egl::Error initialize(egl::Display *display) = 0;
70     virtual void terminate()                             = 0;
71     virtual egl::Error prepareForCall();
72     virtual egl::Error releaseThread();
73 
74     virtual egl::Error makeCurrent(egl::Display *display,
75                                    egl::Surface *drawSurface,
76                                    egl::Surface *readSurface,
77                                    gl::Context *context) = 0;
78 
79     virtual egl::ConfigSet generateConfigs() = 0;
80 
81     virtual bool testDeviceLost()                                     = 0;
82     virtual egl::Error restoreLostDevice(const egl::Display *display) = 0;
83 
84     virtual bool isValidNativeWindow(EGLNativeWindowType window) const = 0;
85     virtual egl::Error validateClientBuffer(const egl::Config *configuration,
86                                             EGLenum buftype,
87                                             EGLClientBuffer clientBuffer,
88                                             const egl::AttributeMap &attribs) const;
89     virtual egl::Error validateImageClientBuffer(const gl::Context *context,
90                                                  EGLenum target,
91                                                  EGLClientBuffer clientBuffer,
92                                                  const egl::AttributeMap &attribs) const;
93     virtual egl::Error validatePixmap(const egl::Config *config,
94                                       EGLNativePixmapType pixmap,
95                                       const egl::AttributeMap &attributes) const;
96 
97     virtual std::string getRendererDescription() = 0;
98     virtual std::string getVendorString()        = 0;
99     virtual std::string getVersionString()       = 0;
100 
101     virtual DeviceImpl *createDevice();
102 
103     virtual egl::Error waitClient(const gl::Context *context)                = 0;
104     virtual egl::Error waitNative(const gl::Context *context, EGLint engine) = 0;
105     virtual gl::Version getMaxSupportedESVersion() const                     = 0;
106     virtual gl::Version getMaxConformantESVersion() const                    = 0;
107     const egl::Caps &getCaps() const;
108 
setBlobCacheFuncs(EGLSetBlobFuncANDROID set,EGLGetBlobFuncANDROID get)109     virtual void setBlobCacheFuncs(EGLSetBlobFuncANDROID set, EGLGetBlobFuncANDROID get) {}
110 
111     const egl::DisplayExtensions &getExtensions() const;
112 
setBlobCache(egl::BlobCache * blobCache)113     void setBlobCache(egl::BlobCache *blobCache) { mBlobCache = blobCache; }
getBlobCache()114     egl::BlobCache *getBlobCache() const { return mBlobCache; }
115 
initializeFrontendFeatures(angle::FrontendFeatures * features)116     virtual void initializeFrontendFeatures(angle::FrontendFeatures *features) const {}
117 
118     virtual void populateFeatureList(angle::FeatureList *features) = 0;
119 
getState()120     const egl::DisplayState &getState() const { return mState; }
121 
122     virtual egl::Error handleGPUSwitch();
123 
124   protected:
125     const egl::DisplayState &mState;
126 
127   private:
128     virtual void generateExtensions(egl::DisplayExtensions *outExtensions) const = 0;
129     virtual void generateCaps(egl::Caps *outCaps) const                          = 0;
130 
131     mutable bool mExtensionsInitialized;
132     mutable egl::DisplayExtensions mExtensions;
133 
134     mutable bool mCapsInitialized;
135     mutable egl::Caps mCaps;
136 
137     egl::BlobCache *mBlobCache;
138 };
139 
140 }  // namespace rx
141 
142 #endif  // LIBANGLE_RENDERER_DISPLAYIMPL_H_
143