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 // DisplayNULL.cpp:
7 // Implements the class methods for DisplayNULL.
8 //
9
10 #include "libANGLE/renderer/null/DisplayNULL.h"
11
12 #include "common/debug.h"
13
14 #include "libANGLE/Display.h"
15 #include "libANGLE/renderer/null/ContextNULL.h"
16 #include "libANGLE/renderer/null/DeviceNULL.h"
17 #include "libANGLE/renderer/null/ImageNULL.h"
18 #include "libANGLE/renderer/null/SurfaceNULL.h"
19
20 namespace rx
21 {
22
DisplayNULL(const egl::DisplayState & state)23 DisplayNULL::DisplayNULL(const egl::DisplayState &state) : DisplayImpl(state) {}
24
~DisplayNULL()25 DisplayNULL::~DisplayNULL() {}
26
initialize(egl::Display * display)27 egl::Error DisplayNULL::initialize(egl::Display *display)
28 {
29 constexpr size_t kMaxTotalAllocationSize = 1 << 28; // 256MB
30 mAllocationTracker.reset(new AllocationTrackerNULL(kMaxTotalAllocationSize));
31
32 return egl::NoError();
33 }
34
terminate()35 void DisplayNULL::terminate()
36 {
37 mAllocationTracker.reset();
38 }
39
makeCurrent(egl::Display * display,egl::Surface * drawSurface,egl::Surface * readSurface,gl::Context * context)40 egl::Error DisplayNULL::makeCurrent(egl::Display *display,
41 egl::Surface *drawSurface,
42 egl::Surface *readSurface,
43 gl::Context *context)
44 {
45 // Ensure that the correct global DebugAnnotator is installed when the end2end tests change
46 // the ANGLE back-end (done frequently).
47 display->setGlobalDebugAnnotator();
48
49 return egl::NoError();
50 }
51
generateConfigs()52 egl::ConfigSet DisplayNULL::generateConfigs()
53 {
54 egl::Config config;
55 config.renderTargetFormat = GL_RGBA8;
56 config.depthStencilFormat = GL_DEPTH24_STENCIL8;
57 config.bufferSize = 32;
58 config.redSize = 8;
59 config.greenSize = 8;
60 config.blueSize = 8;
61 config.alphaSize = 8;
62 config.alphaMaskSize = 0;
63 config.bindToTextureRGB = EGL_TRUE;
64 config.bindToTextureRGBA = EGL_TRUE;
65 config.colorBufferType = EGL_RGB_BUFFER;
66 config.configCaveat = EGL_NONE;
67 config.conformant = EGL_OPENGL_ES2_BIT | EGL_OPENGL_ES3_BIT;
68 config.depthSize = 24;
69 config.level = 0;
70 config.matchNativePixmap = EGL_NONE;
71 config.maxPBufferWidth = 0;
72 config.maxPBufferHeight = 0;
73 config.maxPBufferPixels = 0;
74 config.maxSwapInterval = 1;
75 config.minSwapInterval = 1;
76 config.nativeRenderable = EGL_TRUE;
77 config.nativeVisualID = 0;
78 config.nativeVisualType = EGL_NONE;
79 config.renderableType = EGL_OPENGL_ES2_BIT | EGL_OPENGL_ES3_BIT;
80 config.sampleBuffers = 0;
81 config.samples = 0;
82 config.stencilSize = 8;
83 config.surfaceType = EGL_WINDOW_BIT | EGL_PBUFFER_BIT;
84 config.optimalOrientation = 0;
85 config.transparentType = EGL_NONE;
86 config.transparentRedValue = 0;
87 config.transparentGreenValue = 0;
88 config.transparentBlueValue = 0;
89
90 egl::ConfigSet configSet;
91 configSet.add(config);
92 return configSet;
93 }
94
testDeviceLost()95 bool DisplayNULL::testDeviceLost()
96 {
97 return false;
98 }
99
restoreLostDevice(const egl::Display * display)100 egl::Error DisplayNULL::restoreLostDevice(const egl::Display *display)
101 {
102 return egl::NoError();
103 }
104
isValidNativeWindow(EGLNativeWindowType window) const105 bool DisplayNULL::isValidNativeWindow(EGLNativeWindowType window) const
106 {
107 return true;
108 }
109
getRendererDescription()110 std::string DisplayNULL::getRendererDescription()
111 {
112 return "NULL";
113 }
114
getVendorString()115 std::string DisplayNULL::getVendorString()
116 {
117 return "NULL";
118 }
119
getVersionString(bool includeFullVersion)120 std::string DisplayNULL::getVersionString(bool includeFullVersion)
121 {
122 return std::string();
123 }
124
createDevice()125 DeviceImpl *DisplayNULL::createDevice()
126 {
127 return new DeviceNULL();
128 }
129
waitClient(const gl::Context * context)130 egl::Error DisplayNULL::waitClient(const gl::Context *context)
131 {
132 return egl::NoError();
133 }
134
waitNative(const gl::Context * context,EGLint engine)135 egl::Error DisplayNULL::waitNative(const gl::Context *context, EGLint engine)
136 {
137 return egl::NoError();
138 }
139
getMaxSupportedESVersion() const140 gl::Version DisplayNULL::getMaxSupportedESVersion() const
141 {
142 return gl::Version(3, 2);
143 }
144
getMaxConformantESVersion() const145 gl::Version DisplayNULL::getMaxConformantESVersion() const
146 {
147 return getMaxSupportedESVersion();
148 }
149
createWindowSurface(const egl::SurfaceState & state,EGLNativeWindowType window,const egl::AttributeMap & attribs)150 SurfaceImpl *DisplayNULL::createWindowSurface(const egl::SurfaceState &state,
151 EGLNativeWindowType window,
152 const egl::AttributeMap &attribs)
153 {
154 return new SurfaceNULL(state);
155 }
156
createPbufferSurface(const egl::SurfaceState & state,const egl::AttributeMap & attribs)157 SurfaceImpl *DisplayNULL::createPbufferSurface(const egl::SurfaceState &state,
158 const egl::AttributeMap &attribs)
159 {
160 return new SurfaceNULL(state);
161 }
162
createPbufferFromClientBuffer(const egl::SurfaceState & state,EGLenum buftype,EGLClientBuffer buffer,const egl::AttributeMap & attribs)163 SurfaceImpl *DisplayNULL::createPbufferFromClientBuffer(const egl::SurfaceState &state,
164 EGLenum buftype,
165 EGLClientBuffer buffer,
166 const egl::AttributeMap &attribs)
167 {
168 return new SurfaceNULL(state);
169 }
170
createPixmapSurface(const egl::SurfaceState & state,NativePixmapType nativePixmap,const egl::AttributeMap & attribs)171 SurfaceImpl *DisplayNULL::createPixmapSurface(const egl::SurfaceState &state,
172 NativePixmapType nativePixmap,
173 const egl::AttributeMap &attribs)
174 {
175 return new SurfaceNULL(state);
176 }
177
createImage(const egl::ImageState & state,const gl::Context * context,EGLenum target,const egl::AttributeMap & attribs)178 ImageImpl *DisplayNULL::createImage(const egl::ImageState &state,
179 const gl::Context *context,
180 EGLenum target,
181 const egl::AttributeMap &attribs)
182 {
183 return new ImageNULL(state);
184 }
185
createContext(const gl::State & state,gl::ErrorSet * errorSet,const egl::Config * configuration,const gl::Context * shareContext,const egl::AttributeMap & attribs)186 rx::ContextImpl *DisplayNULL::createContext(const gl::State &state,
187 gl::ErrorSet *errorSet,
188 const egl::Config *configuration,
189 const gl::Context *shareContext,
190 const egl::AttributeMap &attribs)
191 {
192 return new ContextNULL(state, errorSet, mAllocationTracker.get());
193 }
194
createStreamProducerD3DTexture(egl::Stream::ConsumerType consumerType,const egl::AttributeMap & attribs)195 StreamProducerImpl *DisplayNULL::createStreamProducerD3DTexture(
196 egl::Stream::ConsumerType consumerType,
197 const egl::AttributeMap &attribs)
198 {
199 UNIMPLEMENTED();
200 return nullptr;
201 }
202
createShareGroup(const egl::ShareGroupState & state)203 ShareGroupImpl *DisplayNULL::createShareGroup(const egl::ShareGroupState &state)
204 {
205 return new ShareGroupNULL(state);
206 }
207
generateExtensions(egl::DisplayExtensions * outExtensions) const208 void DisplayNULL::generateExtensions(egl::DisplayExtensions *outExtensions) const
209 {
210 outExtensions->createContextRobustness = true;
211 outExtensions->postSubBuffer = true;
212 outExtensions->createContext = true;
213 outExtensions->image = true;
214 outExtensions->imageBase = true;
215 outExtensions->glTexture2DImage = true;
216 outExtensions->glTextureCubemapImage = true;
217 outExtensions->glTexture3DImage = true;
218 outExtensions->glRenderbufferImage = true;
219 outExtensions->getAllProcAddresses = true;
220 outExtensions->noConfigContext = true;
221 outExtensions->directComposition = true;
222 outExtensions->createContextNoError = true;
223 outExtensions->createContextWebGLCompatibility = true;
224 outExtensions->createContextBindGeneratesResource = true;
225 outExtensions->swapBuffersWithDamage = true;
226 outExtensions->pixelFormatFloat = true;
227 outExtensions->surfacelessContext = true;
228 outExtensions->displayTextureShareGroup = true;
229 outExtensions->displaySemaphoreShareGroup = true;
230 outExtensions->createContextClientArrays = true;
231 outExtensions->programCacheControlANGLE = true;
232 outExtensions->robustResourceInitializationANGLE = true;
233 }
234
generateCaps(egl::Caps * outCaps) const235 void DisplayNULL::generateCaps(egl::Caps *outCaps) const
236 {
237 outCaps->textureNPOT = true;
238 }
239
240 } // namespace rx
241