blob: 6642fa92c476309197d53fff3c36b3a6252db15f [file] [log] [blame]
Geoff Langd08f3b32016-09-23 15:56:30 -04001//
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
Geoff Lang76cdbd52016-09-23 16:51:04 -040014#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
Geoff Langd08f3b32016-09-23 15:56:30 -040019namespace rx
20{
21
Jamie Madill3311d472017-01-02 17:55:02 -050022DisplayNULL::DisplayNULL(const egl::DisplayState &state) : DisplayImpl(state), mDevice(nullptr)
Geoff Langd08f3b32016-09-23 15:56:30 -040023{
24}
25
26DisplayNULL::~DisplayNULL()
27{
28}
29
30egl::Error DisplayNULL::initialize(egl::Display *display)
31{
Geoff Lang76cdbd52016-09-23 16:51:04 -040032 mDevice = new DeviceNULL();
Geoff Lang1b60d8d2017-02-10 14:56:55 -050033
34 constexpr size_t kMaxTotalAllocationSize = 1 << 28; // 256MB
35 mAllocationTracker.reset(new AllocationTrackerNULL(kMaxTotalAllocationSize));
36
Geoff Lang76cdbd52016-09-23 16:51:04 -040037 return egl::NoError();
Geoff Langd08f3b32016-09-23 15:56:30 -040038}
39
40void DisplayNULL::terminate()
41{
Geoff Lang1b60d8d2017-02-10 14:56:55 -050042 mAllocationTracker.reset();
Geoff Lang76cdbd52016-09-23 16:51:04 -040043 SafeDelete(mDevice);
Geoff Langd08f3b32016-09-23 15:56:30 -040044}
45
46egl::Error DisplayNULL::makeCurrent(egl::Surface *drawSurface,
47 egl::Surface *readSurface,
48 gl::Context *context)
49{
Geoff Lang76cdbd52016-09-23 16:51:04 -040050 return egl::NoError();
Geoff Langd08f3b32016-09-23 15:56:30 -040051}
52
53egl::ConfigSet DisplayNULL::generateConfigs()
54{
Geoff Lang76cdbd52016-09-23 16:51:04 -040055 egl::Config config;
56 config.renderTargetFormat = GL_RGBA8;
57 config.depthStencilFormat = GL_DEPTH24_STENCIL8;
58 config.bufferSize = 32;
59 config.redSize = 8;
60 config.greenSize = 8;
61 config.blueSize = 8;
62 config.alphaSize = 8;
63 config.alphaMaskSize = 0;
64 config.bindToTextureRGB = EGL_TRUE;
65 config.bindToTextureRGBA = EGL_TRUE;
66 config.colorBufferType = EGL_RGB_BUFFER;
67 config.configCaveat = EGL_NONE;
68 config.conformant = EGL_OPENGL_ES2_BIT | EGL_OPENGL_ES3_BIT;
69 config.depthSize = 24;
70 config.level = 0;
71 config.matchNativePixmap = EGL_NONE;
72 config.maxPBufferWidth = 0;
73 config.maxPBufferHeight = 0;
74 config.maxPBufferPixels = 0;
75 config.maxSwapInterval = 1;
76 config.minSwapInterval = 1;
77 config.nativeRenderable = EGL_TRUE;
78 config.nativeVisualID = 0;
79 config.nativeVisualType = EGL_NONE;
80 config.renderableType = EGL_OPENGL_ES2_BIT | EGL_OPENGL_ES3_BIT;
81 config.sampleBuffers = 0;
82 config.samples = 0;
83 config.stencilSize = 8;
84 config.surfaceType = EGL_WINDOW_BIT | EGL_PBUFFER_BIT;
85 config.optimalOrientation = 0;
86 config.transparentType = EGL_NONE;
87 config.transparentRedValue = 0;
88 config.transparentGreenValue = 0;
89 config.transparentBlueValue = 0;
90
91 egl::ConfigSet configSet;
92 configSet.add(config);
93 return configSet;
Geoff Langd08f3b32016-09-23 15:56:30 -040094}
95
96bool DisplayNULL::testDeviceLost()
97{
Geoff Lang76cdbd52016-09-23 16:51:04 -040098 return false;
Geoff Langd08f3b32016-09-23 15:56:30 -040099}
100
101egl::Error DisplayNULL::restoreLostDevice()
102{
Geoff Lang76cdbd52016-09-23 16:51:04 -0400103 return egl::NoError();
Geoff Langd08f3b32016-09-23 15:56:30 -0400104}
105
106bool DisplayNULL::isValidNativeWindow(EGLNativeWindowType window) const
107{
Geoff Lang76cdbd52016-09-23 16:51:04 -0400108 return true;
Geoff Langd08f3b32016-09-23 15:56:30 -0400109}
110
111std::string DisplayNULL::getVendorString() const
112{
Geoff Lang76cdbd52016-09-23 16:51:04 -0400113 return "NULL";
Geoff Langd08f3b32016-09-23 15:56:30 -0400114}
115
116egl::Error DisplayNULL::getDevice(DeviceImpl **device)
117{
Geoff Lang76cdbd52016-09-23 16:51:04 -0400118 *device = mDevice;
119 return egl::NoError();
Geoff Langd08f3b32016-09-23 15:56:30 -0400120}
121
122egl::Error DisplayNULL::waitClient() const
123{
Geoff Lang76cdbd52016-09-23 16:51:04 -0400124 return egl::NoError();
Geoff Langd08f3b32016-09-23 15:56:30 -0400125}
126
127egl::Error DisplayNULL::waitNative(EGLint engine,
128 egl::Surface *drawSurface,
129 egl::Surface *readSurface) const
130{
Geoff Lang76cdbd52016-09-23 16:51:04 -0400131 return egl::NoError();
Geoff Langd08f3b32016-09-23 15:56:30 -0400132}
133
134gl::Version DisplayNULL::getMaxSupportedESVersion() const
135{
Geoff Lang76cdbd52016-09-23 16:51:04 -0400136 return gl::Version(3, 2);
Geoff Langd08f3b32016-09-23 15:56:30 -0400137}
138
139SurfaceImpl *DisplayNULL::createWindowSurface(const egl::SurfaceState &state,
Geoff Langd08f3b32016-09-23 15:56:30 -0400140 EGLNativeWindowType window,
141 const egl::AttributeMap &attribs)
142{
Geoff Lang76cdbd52016-09-23 16:51:04 -0400143 return new SurfaceNULL(state);
Geoff Langd08f3b32016-09-23 15:56:30 -0400144}
145
146SurfaceImpl *DisplayNULL::createPbufferSurface(const egl::SurfaceState &state,
Geoff Langd08f3b32016-09-23 15:56:30 -0400147 const egl::AttributeMap &attribs)
148{
Geoff Lang76cdbd52016-09-23 16:51:04 -0400149 return new SurfaceNULL(state);
Geoff Langd08f3b32016-09-23 15:56:30 -0400150}
151
152SurfaceImpl *DisplayNULL::createPbufferFromClientBuffer(const egl::SurfaceState &state,
Geoff Lang2018c0b2015-12-08 11:48:51 -0500153 EGLenum buftype,
154 EGLClientBuffer buffer,
Geoff Langd08f3b32016-09-23 15:56:30 -0400155 const egl::AttributeMap &attribs)
156{
Geoff Lang76cdbd52016-09-23 16:51:04 -0400157 return new SurfaceNULL(state);
Geoff Langd08f3b32016-09-23 15:56:30 -0400158}
159
160SurfaceImpl *DisplayNULL::createPixmapSurface(const egl::SurfaceState &state,
Geoff Langd08f3b32016-09-23 15:56:30 -0400161 NativePixmapType nativePixmap,
162 const egl::AttributeMap &attribs)
163{
Geoff Lang76cdbd52016-09-23 16:51:04 -0400164 return new SurfaceNULL(state);
Geoff Langd08f3b32016-09-23 15:56:30 -0400165}
166
Jamie Madill76b8f462017-04-21 12:23:40 -0400167ImageImpl *DisplayNULL::createImage(const egl::ImageState &state,
168 EGLenum target,
Geoff Langd08f3b32016-09-23 15:56:30 -0400169 const egl::AttributeMap &attribs)
170{
Jamie Madill76b8f462017-04-21 12:23:40 -0400171 return new ImageNULL(state);
Geoff Langd08f3b32016-09-23 15:56:30 -0400172}
173
174ContextImpl *DisplayNULL::createContext(const gl::ContextState &state)
175{
Geoff Lang1b60d8d2017-02-10 14:56:55 -0500176 return new ContextNULL(state, mAllocationTracker.get());
Geoff Langd08f3b32016-09-23 15:56:30 -0400177}
178
179StreamProducerImpl *DisplayNULL::createStreamProducerD3DTextureNV12(
180 egl::Stream::ConsumerType consumerType,
181 const egl::AttributeMap &attribs)
182{
183 UNIMPLEMENTED();
Geoff Lang76cdbd52016-09-23 16:51:04 -0400184 return nullptr;
Geoff Langd08f3b32016-09-23 15:56:30 -0400185}
186
187void DisplayNULL::generateExtensions(egl::DisplayExtensions *outExtensions) const
188{
Geoff Lang76cdbd52016-09-23 16:51:04 -0400189 outExtensions->createContextRobustness = true;
190 outExtensions->postSubBuffer = true;
191 outExtensions->createContext = true;
192 outExtensions->deviceQuery = true;
193 outExtensions->image = true;
194 outExtensions->imageBase = true;
195 outExtensions->glTexture2DImage = true;
196 outExtensions->glTextureCubemapImage = true;
197 outExtensions->glTexture3DImage = true;
198 outExtensions->glRenderbufferImage = true;
199 outExtensions->getAllProcAddresses = true;
200 outExtensions->flexibleSurfaceCompatibility = true;
201 outExtensions->directComposition = true;
202 outExtensions->createContextNoError = true;
203 outExtensions->createContextWebGLCompatibility = true;
204 outExtensions->createContextBindGeneratesResource = true;
205 outExtensions->swapBuffersWithDamage = true;
Geoff Lang638c7272017-06-13 15:50:26 -0400206 outExtensions->surfacelessContext = true;
Geoff Langd08f3b32016-09-23 15:56:30 -0400207}
208
209void DisplayNULL::generateCaps(egl::Caps *outCaps) const
210{
Geoff Lang76cdbd52016-09-23 16:51:04 -0400211 outCaps->textureNPOT = true;
Geoff Langd08f3b32016-09-23 15:56:30 -0400212}
213
214} // namespace rx