DisplayImpl.cpp (4222B)
1 // 2 // Copyright 2014 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 7 // DisplayImpl.cpp: Implementation methods of egl::Display 8 9 #include "libANGLE/renderer/DisplayImpl.h" 10 11 #include "libANGLE/Display.h" 12 #include "libANGLE/Surface.h" 13 #include "libANGLE/renderer/DeviceImpl.h" 14 15 namespace rx 16 { 17 namespace 18 { 19 // For back-ends that do not implement EGLDevice. 20 class MockDevice : public DeviceImpl 21 { 22 public: 23 MockDevice() = default; 24 egl::Error initialize() override { return egl::NoError(); } 25 egl::Error getAttribute(const egl::Display *display, EGLint attribute, void **outValue) override 26 { 27 UNREACHABLE(); 28 return egl::EglBadAttribute(); 29 } 30 EGLint getType() override 31 { 32 UNREACHABLE(); 33 return EGL_NONE; 34 } 35 void generateExtensions(egl::DeviceExtensions *outExtensions) const override 36 { 37 *outExtensions = egl::DeviceExtensions(); 38 } 39 }; 40 } // anonymous namespace 41 42 DisplayImpl::DisplayImpl(const egl::DisplayState &state) 43 : mState(state), mExtensionsInitialized(false), mCapsInitialized(false), mBlobCache(nullptr) 44 {} 45 46 DisplayImpl::~DisplayImpl() 47 { 48 ASSERT(mState.surfaceSet.empty()); 49 } 50 51 egl::Error DisplayImpl::prepareForCall() 52 { 53 return egl::NoError(); 54 } 55 56 egl::Error DisplayImpl::releaseThread() 57 { 58 return egl::NoError(); 59 } 60 61 const egl::DisplayExtensions &DisplayImpl::getExtensions() const 62 { 63 if (!mExtensionsInitialized) 64 { 65 generateExtensions(&mExtensions); 66 mExtensionsInitialized = true; 67 } 68 69 return mExtensions; 70 } 71 72 egl::Error DisplayImpl::handleGPUSwitch() 73 { 74 return egl::NoError(); 75 } 76 77 egl::Error DisplayImpl::forceGPUSwitch(EGLint gpuIDHigh, EGLint gpuIDLow) 78 { 79 return egl::NoError(); 80 } 81 82 egl::Error DisplayImpl::validateClientBuffer(const egl::Config *configuration, 83 EGLenum buftype, 84 EGLClientBuffer clientBuffer, 85 const egl::AttributeMap &attribs) const 86 { 87 UNREACHABLE(); 88 return egl::EglBadDisplay() << "DisplayImpl::validateClientBuffer unimplemented."; 89 } 90 91 egl::Error DisplayImpl::validateImageClientBuffer(const gl::Context *context, 92 EGLenum target, 93 EGLClientBuffer clientBuffer, 94 const egl::AttributeMap &attribs) const 95 { 96 UNREACHABLE(); 97 return egl::EglBadDisplay() << "DisplayImpl::validateImageClientBuffer unimplemented."; 98 } 99 100 egl::Error DisplayImpl::validatePixmap(const egl::Config *config, 101 EGLNativePixmapType pixmap, 102 const egl::AttributeMap &attributes) const 103 { 104 UNREACHABLE(); 105 return egl::EglBadDisplay() << "DisplayImpl::valdiatePixmap unimplemented."; 106 } 107 108 const egl::Caps &DisplayImpl::getCaps() const 109 { 110 if (!mCapsInitialized) 111 { 112 generateCaps(&mCaps); 113 mCapsInitialized = true; 114 } 115 116 return mCaps; 117 } 118 119 DeviceImpl *DisplayImpl::createDevice() 120 { 121 return new MockDevice(); 122 } 123 124 bool DisplayImpl::isX11() const 125 { 126 return false; 127 } 128 129 bool DisplayImpl::isWayland() const 130 { 131 return false; 132 } 133 134 bool DisplayImpl::isGBM() const 135 { 136 return false; 137 } 138 139 bool DisplayImpl::supportsDmaBufFormat(EGLint format) const 140 { 141 UNREACHABLE(); 142 return false; 143 } 144 145 egl::Error DisplayImpl::queryDmaBufFormats(EGLint max_formats, EGLint *formats, EGLint *num_formats) 146 { 147 UNREACHABLE(); 148 return egl::NoError(); 149 } 150 151 egl::Error DisplayImpl::queryDmaBufModifiers(EGLint format, 152 EGLint max_modifiers, 153 EGLuint64KHR *modifiers, 154 EGLBoolean *external_only, 155 EGLint *num_modifiers) 156 { 157 UNREACHABLE(); 158 return egl::NoError(); 159 } 160 161 GLuint DisplayImpl::getNextSurfaceID() 162 { 163 uint64_t id = mNextSurfaceID.generate().getValue(); 164 ASSERT(id <= 0xfffffffful); 165 return static_cast<GLuint>(id); 166 } 167 168 } // namespace rx