• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 //
2 // Copyright 2020 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 #ifndef LIBANGLE_RENDERER_METAL_IOSURFACESURFACEMTL_H_
8 #define LIBANGLE_RENDERER_METAL_IOSURFACESURFACEMTL_H_
9 
10 #include <IOSurface/IOSurfaceRef.h>
11 #include "libANGLE/renderer/SurfaceImpl.h"
12 #include "libANGLE/renderer/metal/DisplayMtl.h"
13 #include "libANGLE/renderer/metal/SurfaceMtl.h"
14 
15 namespace metal
16 {
17 class AttributeMap;
18 }  // namespace metal
19 
20 namespace rx
21 {
22 
23 class DisplayMTL;
24 
25 // Offscreen created from IOSurface
26 class IOSurfaceSurfaceMtl : public OffscreenSurfaceMtl
27 {
28   public:
29     IOSurfaceSurfaceMtl(DisplayMtl *display,
30                         const egl::SurfaceState &state,
31                         EGLClientBuffer buffer,
32                         const egl::AttributeMap &attribs);
33     ~IOSurfaceSurfaceMtl() override;
34 
35     egl::Error bindTexImage(const gl::Context *context,
36                             gl::Texture *texture,
37                             EGLint buffer) override;
38     egl::Error releaseTexImage(const gl::Context *context, EGLint buffer) override;
39 
40     angle::Result getAttachmentRenderTarget(const gl::Context *context,
41                                             GLenum binding,
42                                             const gl::ImageIndex &imageIndex,
43                                             GLsizei samples,
44                                             FramebufferAttachmentRenderTarget **rtOut) override;
45 
46     static bool ValidateAttributes(EGLClientBuffer buffer, const egl::AttributeMap &attribs);
47 
48   private:
49     angle::Result ensureColorTextureCreated(const gl::Context *context);
50 
51     IOSurfaceRef mIOSurface;
52     NSUInteger mIOSurfacePlane;
53     int mIOSurfaceFormatIdx;
54 };
55 
56 }  // namespace rx
57 
58 #endif  // LIBANGLE_RENDERER_GL_EAGL_IOSURFACESURFACEEAGL_H_
59