1 //
2 // Copyright 2015 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 // DisplayGL.h: GL implementation of egl::Display
8
9 #include "libANGLE/renderer/gl/DisplayGL.h"
10
11 #include "libANGLE/AttributeMap.h"
12 #include "libANGLE/Context.h"
13 #include "libANGLE/Display.h"
14 #include "libANGLE/Surface.h"
15 #include "libANGLE/renderer/gl/ContextGL.h"
16 #include "libANGLE/renderer/gl/RendererGL.h"
17 #include "libANGLE/renderer/gl/StateManagerGL.h"
18 #include "libANGLE/renderer/gl/SurfaceGL.h"
19
20 #include <EGL/eglext.h>
21
22 namespace rx
23 {
24
DisplayGL(const egl::DisplayState & state)25 DisplayGL::DisplayGL(const egl::DisplayState &state) : DisplayImpl(state) {}
26
~DisplayGL()27 DisplayGL::~DisplayGL() {}
28
initialize(egl::Display * display)29 egl::Error DisplayGL::initialize(egl::Display *display)
30 {
31 return egl::NoError();
32 }
33
terminate()34 void DisplayGL::terminate() {}
35
createImage(const egl::ImageState & state,const gl::Context * context,EGLenum target,const egl::AttributeMap & attribs)36 ImageImpl *DisplayGL::createImage(const egl::ImageState &state,
37 const gl::Context *context,
38 EGLenum target,
39 const egl::AttributeMap &attribs)
40 {
41 UNIMPLEMENTED();
42 return nullptr;
43 }
44
createStreamProducerD3DTexture(egl::Stream::ConsumerType consumerType,const egl::AttributeMap & attribs)45 StreamProducerImpl *DisplayGL::createStreamProducerD3DTexture(
46 egl::Stream::ConsumerType consumerType,
47 const egl::AttributeMap &attribs)
48 {
49 UNIMPLEMENTED();
50 return nullptr;
51 }
52
createShareGroup()53 ShareGroupImpl *DisplayGL::createShareGroup()
54 {
55 return new ShareGroupGL();
56 }
57
makeCurrent(egl::Surface * drawSurface,egl::Surface * readSurface,gl::Context * context)58 egl::Error DisplayGL::makeCurrent(egl::Surface *drawSurface,
59 egl::Surface *readSurface,
60 gl::Context *context)
61 {
62 if (!context)
63 {
64 return egl::NoError();
65 }
66
67 // Pause transform feedback before making a new surface current, to workaround anglebug.com/1426
68 ContextGL *glContext = GetImplAs<ContextGL>(context);
69 glContext->getStateManager()->pauseTransformFeedback();
70
71 if (drawSurface == nullptr)
72 {
73 ANGLE_TRY(makeCurrentSurfaceless(context));
74 }
75
76 return egl::NoError();
77 }
78
getMaxConformantESVersion() const79 gl::Version DisplayGL::getMaxConformantESVersion() const
80 {
81 // 3.1 support is in progress.
82 return std::min(getMaxSupportedESVersion(), gl::Version(3, 0));
83 }
84
generateExtensions(egl::DisplayExtensions * outExtensions) const85 void DisplayGL::generateExtensions(egl::DisplayExtensions *outExtensions) const
86 {
87 // Advertise robust resource initialization on all OpenGL backends for testing even though it is
88 // not fully implemented.
89 outExtensions->robustResourceInitialization = true;
90 }
91
makeCurrentSurfaceless(gl::Context * context)92 egl::Error DisplayGL::makeCurrentSurfaceless(gl::Context *context)
93 {
94 UNIMPLEMENTED();
95 return egl::NoError();
96 }
97 } // namespace rx
98