1 //
2 // Copyright (c) 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/renderer/EGLImplFactory.h"
17 #include "libANGLE/Stream.h"
18 #include "libANGLE/Version.h"
19 
20 #include <set>
21 #include <vector>
22 
23 namespace egl
24 {
25 class AttributeMap;
26 class Display;
27 struct DisplayState;
28 struct Config;
29 class Surface;
30 class ImageSibling;
31 class Thread;
32 }
33 
34 namespace gl
35 {
36 class Context;
37 }
38 
39 namespace rx
40 {
41 class SurfaceImpl;
42 class ImageImpl;
43 struct ConfigDesc;
44 class DeviceImpl;
45 class StreamProducerImpl;
46 
47 class DisplayImpl : public EGLImplFactory
48 {
49   public:
50     DisplayImpl(const egl::DisplayState &state);
51     ~DisplayImpl() override;
52 
53     virtual egl::Error initialize(egl::Display *display) = 0;
54     virtual void terminate() = 0;
55 
56     virtual egl::Error makeCurrent(egl::Surface *drawSurface, egl::Surface *readSurface, gl::Context *context) = 0;
57 
58     virtual egl::ConfigSet generateConfigs() = 0;
59 
60     virtual bool testDeviceLost() = 0;
61     virtual egl::Error restoreLostDevice(const egl::Display *display) = 0;
62 
63     virtual bool isValidNativeWindow(EGLNativeWindowType window) const = 0;
64     virtual egl::Error validateClientBuffer(const egl::Config *configuration,
65                                             EGLenum buftype,
66                                             EGLClientBuffer clientBuffer,
67                                             const egl::AttributeMap &attribs) const;
68 
69     virtual std::string getVendorString() const = 0;
70 
71     virtual egl::Error getDevice(DeviceImpl **device) = 0;
72 
73     virtual egl::Error waitClient(const gl::Context *context) const = 0;
74     virtual egl::Error waitNative(const gl::Context *context, EGLint engine) const = 0;
75     virtual gl::Version getMaxSupportedESVersion() const           = 0;
76     const egl::Caps &getCaps() const;
77 
78     const egl::DisplayExtensions &getExtensions() const;
79 
80   protected:
81     const egl::DisplayState &mState;
82 
83   private:
84     virtual void generateExtensions(egl::DisplayExtensions *outExtensions) const = 0;
85     virtual void generateCaps(egl::Caps *outCaps) const = 0;
86 
87     mutable bool mExtensionsInitialized;
88     mutable egl::DisplayExtensions mExtensions;
89 
90     mutable bool mCapsInitialized;
91     mutable egl::Caps mCaps;
92 };
93 
94 }
95 
96 #endif // LIBANGLE_RENDERER_DISPLAYIMPL_H_
97