Geoff Lang | d08f3b3 | 2016-09-23 15:56:30 -0400 | [diff] [blame] | 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 | |
Geoff Lang | 76cdbd5 | 2016-09-23 16:51:04 -0400 | [diff] [blame] | 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 | |
Geoff Lang | d08f3b3 | 2016-09-23 15:56:30 -0400 | [diff] [blame] | 19 | namespace rx |
| 20 | { |
| 21 | |
Jamie Madill | 3311d47 | 2017-01-02 17:55:02 -0500 | [diff] [blame] | 22 | DisplayNULL::DisplayNULL(const egl::DisplayState &state) : DisplayImpl(state), mDevice(nullptr) |
Geoff Lang | d08f3b3 | 2016-09-23 15:56:30 -0400 | [diff] [blame] | 23 | { |
| 24 | } |
| 25 | |
| 26 | DisplayNULL::~DisplayNULL() |
| 27 | { |
| 28 | } |
| 29 | |
| 30 | egl::Error DisplayNULL::initialize(egl::Display *display) |
| 31 | { |
Geoff Lang | 76cdbd5 | 2016-09-23 16:51:04 -0400 | [diff] [blame] | 32 | mDevice = new DeviceNULL(); |
Geoff Lang | 1b60d8d | 2017-02-10 14:56:55 -0500 | [diff] [blame^] | 33 | |
| 34 | constexpr size_t kMaxTotalAllocationSize = 1 << 28; // 256MB |
| 35 | mAllocationTracker.reset(new AllocationTrackerNULL(kMaxTotalAllocationSize)); |
| 36 | |
Geoff Lang | 76cdbd5 | 2016-09-23 16:51:04 -0400 | [diff] [blame] | 37 | return egl::NoError(); |
Geoff Lang | d08f3b3 | 2016-09-23 15:56:30 -0400 | [diff] [blame] | 38 | } |
| 39 | |
| 40 | void DisplayNULL::terminate() |
| 41 | { |
Geoff Lang | 1b60d8d | 2017-02-10 14:56:55 -0500 | [diff] [blame^] | 42 | mAllocationTracker.reset(); |
Geoff Lang | 76cdbd5 | 2016-09-23 16:51:04 -0400 | [diff] [blame] | 43 | SafeDelete(mDevice); |
Geoff Lang | d08f3b3 | 2016-09-23 15:56:30 -0400 | [diff] [blame] | 44 | } |
| 45 | |
| 46 | egl::Error DisplayNULL::makeCurrent(egl::Surface *drawSurface, |
| 47 | egl::Surface *readSurface, |
| 48 | gl::Context *context) |
| 49 | { |
Geoff Lang | 76cdbd5 | 2016-09-23 16:51:04 -0400 | [diff] [blame] | 50 | return egl::NoError(); |
Geoff Lang | d08f3b3 | 2016-09-23 15:56:30 -0400 | [diff] [blame] | 51 | } |
| 52 | |
| 53 | egl::ConfigSet DisplayNULL::generateConfigs() |
| 54 | { |
Geoff Lang | 76cdbd5 | 2016-09-23 16:51:04 -0400 | [diff] [blame] | 55 | 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 Lang | d08f3b3 | 2016-09-23 15:56:30 -0400 | [diff] [blame] | 94 | } |
| 95 | |
| 96 | bool DisplayNULL::testDeviceLost() |
| 97 | { |
Geoff Lang | 76cdbd5 | 2016-09-23 16:51:04 -0400 | [diff] [blame] | 98 | return false; |
Geoff Lang | d08f3b3 | 2016-09-23 15:56:30 -0400 | [diff] [blame] | 99 | } |
| 100 | |
| 101 | egl::Error DisplayNULL::restoreLostDevice() |
| 102 | { |
Geoff Lang | 76cdbd5 | 2016-09-23 16:51:04 -0400 | [diff] [blame] | 103 | return egl::NoError(); |
Geoff Lang | d08f3b3 | 2016-09-23 15:56:30 -0400 | [diff] [blame] | 104 | } |
| 105 | |
| 106 | bool DisplayNULL::isValidNativeWindow(EGLNativeWindowType window) const |
| 107 | { |
Geoff Lang | 76cdbd5 | 2016-09-23 16:51:04 -0400 | [diff] [blame] | 108 | return true; |
Geoff Lang | d08f3b3 | 2016-09-23 15:56:30 -0400 | [diff] [blame] | 109 | } |
| 110 | |
| 111 | std::string DisplayNULL::getVendorString() const |
| 112 | { |
Geoff Lang | 76cdbd5 | 2016-09-23 16:51:04 -0400 | [diff] [blame] | 113 | return "NULL"; |
Geoff Lang | d08f3b3 | 2016-09-23 15:56:30 -0400 | [diff] [blame] | 114 | } |
| 115 | |
| 116 | egl::Error DisplayNULL::getDevice(DeviceImpl **device) |
| 117 | { |
Geoff Lang | 76cdbd5 | 2016-09-23 16:51:04 -0400 | [diff] [blame] | 118 | *device = mDevice; |
| 119 | return egl::NoError(); |
Geoff Lang | d08f3b3 | 2016-09-23 15:56:30 -0400 | [diff] [blame] | 120 | } |
| 121 | |
| 122 | egl::Error DisplayNULL::waitClient() const |
| 123 | { |
Geoff Lang | 76cdbd5 | 2016-09-23 16:51:04 -0400 | [diff] [blame] | 124 | return egl::NoError(); |
Geoff Lang | d08f3b3 | 2016-09-23 15:56:30 -0400 | [diff] [blame] | 125 | } |
| 126 | |
| 127 | egl::Error DisplayNULL::waitNative(EGLint engine, |
| 128 | egl::Surface *drawSurface, |
| 129 | egl::Surface *readSurface) const |
| 130 | { |
Geoff Lang | 76cdbd5 | 2016-09-23 16:51:04 -0400 | [diff] [blame] | 131 | return egl::NoError(); |
Geoff Lang | d08f3b3 | 2016-09-23 15:56:30 -0400 | [diff] [blame] | 132 | } |
| 133 | |
| 134 | gl::Version DisplayNULL::getMaxSupportedESVersion() const |
| 135 | { |
Geoff Lang | 76cdbd5 | 2016-09-23 16:51:04 -0400 | [diff] [blame] | 136 | return gl::Version(3, 2); |
Geoff Lang | d08f3b3 | 2016-09-23 15:56:30 -0400 | [diff] [blame] | 137 | } |
| 138 | |
| 139 | SurfaceImpl *DisplayNULL::createWindowSurface(const egl::SurfaceState &state, |
Geoff Lang | d08f3b3 | 2016-09-23 15:56:30 -0400 | [diff] [blame] | 140 | EGLNativeWindowType window, |
| 141 | const egl::AttributeMap &attribs) |
| 142 | { |
Geoff Lang | 76cdbd5 | 2016-09-23 16:51:04 -0400 | [diff] [blame] | 143 | return new SurfaceNULL(state); |
Geoff Lang | d08f3b3 | 2016-09-23 15:56:30 -0400 | [diff] [blame] | 144 | } |
| 145 | |
| 146 | SurfaceImpl *DisplayNULL::createPbufferSurface(const egl::SurfaceState &state, |
Geoff Lang | d08f3b3 | 2016-09-23 15:56:30 -0400 | [diff] [blame] | 147 | const egl::AttributeMap &attribs) |
| 148 | { |
Geoff Lang | 76cdbd5 | 2016-09-23 16:51:04 -0400 | [diff] [blame] | 149 | return new SurfaceNULL(state); |
Geoff Lang | d08f3b3 | 2016-09-23 15:56:30 -0400 | [diff] [blame] | 150 | } |
| 151 | |
| 152 | SurfaceImpl *DisplayNULL::createPbufferFromClientBuffer(const egl::SurfaceState &state, |
Geoff Lang | 2018c0b | 2015-12-08 11:48:51 -0500 | [diff] [blame] | 153 | EGLenum buftype, |
| 154 | EGLClientBuffer buffer, |
Geoff Lang | d08f3b3 | 2016-09-23 15:56:30 -0400 | [diff] [blame] | 155 | const egl::AttributeMap &attribs) |
| 156 | { |
Geoff Lang | 76cdbd5 | 2016-09-23 16:51:04 -0400 | [diff] [blame] | 157 | return new SurfaceNULL(state); |
Geoff Lang | d08f3b3 | 2016-09-23 15:56:30 -0400 | [diff] [blame] | 158 | } |
| 159 | |
| 160 | SurfaceImpl *DisplayNULL::createPixmapSurface(const egl::SurfaceState &state, |
Geoff Lang | d08f3b3 | 2016-09-23 15:56:30 -0400 | [diff] [blame] | 161 | NativePixmapType nativePixmap, |
| 162 | const egl::AttributeMap &attribs) |
| 163 | { |
Geoff Lang | 76cdbd5 | 2016-09-23 16:51:04 -0400 | [diff] [blame] | 164 | return new SurfaceNULL(state); |
Geoff Lang | d08f3b3 | 2016-09-23 15:56:30 -0400 | [diff] [blame] | 165 | } |
| 166 | |
| 167 | ImageImpl *DisplayNULL::createImage(EGLenum target, |
| 168 | egl::ImageSibling *buffer, |
| 169 | const egl::AttributeMap &attribs) |
| 170 | { |
Geoff Lang | 76cdbd5 | 2016-09-23 16:51:04 -0400 | [diff] [blame] | 171 | return new ImageNULL(); |
Geoff Lang | d08f3b3 | 2016-09-23 15:56:30 -0400 | [diff] [blame] | 172 | } |
| 173 | |
| 174 | ContextImpl *DisplayNULL::createContext(const gl::ContextState &state) |
| 175 | { |
Geoff Lang | 1b60d8d | 2017-02-10 14:56:55 -0500 | [diff] [blame^] | 176 | return new ContextNULL(state, mAllocationTracker.get()); |
Geoff Lang | d08f3b3 | 2016-09-23 15:56:30 -0400 | [diff] [blame] | 177 | } |
| 178 | |
| 179 | StreamProducerImpl *DisplayNULL::createStreamProducerD3DTextureNV12( |
| 180 | egl::Stream::ConsumerType consumerType, |
| 181 | const egl::AttributeMap &attribs) |
| 182 | { |
| 183 | UNIMPLEMENTED(); |
Geoff Lang | 76cdbd5 | 2016-09-23 16:51:04 -0400 | [diff] [blame] | 184 | return nullptr; |
Geoff Lang | d08f3b3 | 2016-09-23 15:56:30 -0400 | [diff] [blame] | 185 | } |
| 186 | |
| 187 | void DisplayNULL::generateExtensions(egl::DisplayExtensions *outExtensions) const |
| 188 | { |
Geoff Lang | 76cdbd5 | 2016-09-23 16:51:04 -0400 | [diff] [blame] | 189 | 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 Lang | d08f3b3 | 2016-09-23 15:56:30 -0400 | [diff] [blame] | 206 | } |
| 207 | |
| 208 | void DisplayNULL::generateCaps(egl::Caps *outCaps) const |
| 209 | { |
Geoff Lang | 76cdbd5 | 2016-09-23 16:51:04 -0400 | [diff] [blame] | 210 | outCaps->textureNPOT = true; |
Geoff Lang | d08f3b3 | 2016-09-23 15:56:30 -0400 | [diff] [blame] | 211 | } |
| 212 | |
| 213 | } // namespace rx |