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