xref: /aosp_15_r20/external/angle/src/libANGLE/renderer/gl/SurfaceGL.cpp (revision 8975f5c5ed3d1c378011245431ada316dfb6f244)
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 // SurfaceGL.cpp: OpenGL implementation of egl::Surface
8 
9 #include "libANGLE/renderer/gl/SurfaceGL.h"
10 
11 #include "libANGLE/Context.h"
12 #include "libANGLE/Surface.h"
13 #include "libANGLE/renderer/gl/BlitGL.h"
14 #include "libANGLE/renderer/gl/ContextGL.h"
15 #include "libANGLE/renderer/gl/FramebufferGL.h"
16 #include "libANGLE/renderer/gl/RendererGL.h"
17 
18 namespace rx
19 {
20 
SurfaceGL(const egl::SurfaceState & state)21 SurfaceGL::SurfaceGL(const egl::SurfaceState &state) : SurfaceImpl(state) {}
22 
~SurfaceGL()23 SurfaceGL::~SurfaceGL() {}
24 
getSyncValues(EGLuint64KHR * ust,EGLuint64KHR * msc,EGLuint64KHR * sbc)25 egl::Error SurfaceGL::getSyncValues(EGLuint64KHR *ust, EGLuint64KHR *msc, EGLuint64KHR *sbc)
26 {
27     UNREACHABLE();
28     return egl::EglBadSurface();
29 }
30 
getMscRate(EGLint * numerator,EGLint * denominator)31 egl::Error SurfaceGL::getMscRate(EGLint *numerator, EGLint *denominator)
32 {
33     UNIMPLEMENTED();
34     return egl::EglBadAccess();
35 }
36 
initializeContents(const gl::Context * context,GLenum binding,const gl::ImageIndex & imageIndex)37 angle::Result SurfaceGL::initializeContents(const gl::Context *context,
38                                             GLenum binding,
39                                             const gl::ImageIndex &imageIndex)
40 {
41     FramebufferGL *framebufferGL = GetImplAs<FramebufferGL>(context->getFramebuffer({0}));
42     ASSERT(framebufferGL->isDefault());
43 
44     BlitGL *blitter = GetBlitGL(context);
45 
46     switch (binding)
47     {
48         case GL_BACK:
49         {
50             gl::DrawBufferMask colorAttachments{0};
51             ANGLE_TRY(
52                 blitter->clearFramebuffer(context, colorAttachments, false, false, framebufferGL));
53         }
54         break;
55 
56         case GL_DEPTH:
57         case GL_STENCIL:
58             ANGLE_TRY(blitter->clearFramebuffer(context, gl::DrawBufferMask(), true, true,
59                                                 framebufferGL));
60             break;
61 
62         default:
63             UNREACHABLE();
64             break;
65     }
66 
67     return angle::Result::Continue;
68 }
69 
hasEmulatedAlphaChannel() const70 bool SurfaceGL::hasEmulatedAlphaChannel() const
71 {
72     return false;
73 }
74 
attachToFramebuffer(const gl::Context * context,gl::Framebuffer * framebuffer)75 egl::Error SurfaceGL::attachToFramebuffer(const gl::Context *context, gl::Framebuffer *framebuffer)
76 {
77     return egl::NoError();
78 }
79 
detachFromFramebuffer(const gl::Context * context,gl::Framebuffer * framebuffer)80 egl::Error SurfaceGL::detachFromFramebuffer(const gl::Context *context,
81                                             gl::Framebuffer *framebuffer)
82 {
83     return egl::NoError();
84 }
85 
86 }  // namespace rx
87