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