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;
initialize()24 egl::Error initialize() override { return egl::NoError(); }
getAttribute(const egl::Display * display,EGLint attribute,void ** outValue)25 egl::Error getAttribute(const egl::Display *display, EGLint attribute, void **outValue) override
26 {
27 UNREACHABLE();
28 return egl::EglBadAttribute();
29 }
getType()30 EGLint getType() override
31 {
32 UNREACHABLE();
33 return EGL_NONE;
34 }
generateExtensions(egl::DeviceExtensions * outExtensions) const35 void generateExtensions(egl::DeviceExtensions *outExtensions) const override
36 {
37 *outExtensions = egl::DeviceExtensions();
38 }
39 };
40 } // anonymous namespace
41
DisplayImpl(const egl::DisplayState & state)42 DisplayImpl::DisplayImpl(const egl::DisplayState &state)
43 : mState(state), mExtensionsInitialized(false), mCapsInitialized(false), mBlobCache(nullptr)
44 {}
45
~DisplayImpl()46 DisplayImpl::~DisplayImpl()
47 {
48 ASSERT(mState.surfaceSet.empty());
49 }
50
prepareForCall()51 egl::Error DisplayImpl::prepareForCall()
52 {
53 return egl::NoError();
54 }
55
releaseThread()56 egl::Error DisplayImpl::releaseThread()
57 {
58 return egl::NoError();
59 }
60
getExtensions() const61 const egl::DisplayExtensions &DisplayImpl::getExtensions() const
62 {
63 if (!mExtensionsInitialized)
64 {
65 generateExtensions(&mExtensions);
66 mExtensionsInitialized = true;
67 }
68
69 return mExtensions;
70 }
71
handleGPUSwitch()72 egl::Error DisplayImpl::handleGPUSwitch()
73 {
74 return egl::NoError();
75 }
76
validateClientBuffer(const egl::Config * configuration,EGLenum buftype,EGLClientBuffer clientBuffer,const egl::AttributeMap & attribs) const77 egl::Error DisplayImpl::validateClientBuffer(const egl::Config *configuration,
78 EGLenum buftype,
79 EGLClientBuffer clientBuffer,
80 const egl::AttributeMap &attribs) const
81 {
82 UNREACHABLE();
83 return egl::EglBadDisplay() << "DisplayImpl::validateClientBuffer unimplemented.";
84 }
85
validateImageClientBuffer(const gl::Context * context,EGLenum target,EGLClientBuffer clientBuffer,const egl::AttributeMap & attribs) const86 egl::Error DisplayImpl::validateImageClientBuffer(const gl::Context *context,
87 EGLenum target,
88 EGLClientBuffer clientBuffer,
89 const egl::AttributeMap &attribs) const
90 {
91 UNREACHABLE();
92 return egl::EglBadDisplay() << "DisplayImpl::validateImageClientBuffer unimplemented.";
93 }
94
validatePixmap(const egl::Config * config,EGLNativePixmapType pixmap,const egl::AttributeMap & attributes) const95 egl::Error DisplayImpl::validatePixmap(const egl::Config *config,
96 EGLNativePixmapType pixmap,
97 const egl::AttributeMap &attributes) const
98 {
99 UNREACHABLE();
100 return egl::EglBadDisplay() << "DisplayImpl::valdiatePixmap unimplemented.";
101 }
102
getCaps() const103 const egl::Caps &DisplayImpl::getCaps() const
104 {
105 if (!mCapsInitialized)
106 {
107 generateCaps(&mCaps);
108 mCapsInitialized = true;
109 }
110
111 return mCaps;
112 }
113
createDevice()114 DeviceImpl *DisplayImpl::createDevice()
115 {
116 return new MockDevice();
117 }
118 } // namespace rx
119