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 // IOSurfaceSurfaceVkMac.h:
7 //    Subclasses SurfaceVk for the Mac platform to implement PBuffers using an IOSurface
8 //
9 
10 #ifndef LIBANGLE_RENDERER_VULKAN_MAC_IOSURFACESURFACEVKMAC_H_
11 #define LIBANGLE_RENDERER_VULKAN_MAC_IOSURFACESURFACEVKMAC_H_
12 
13 #include "libANGLE/renderer/vulkan/SurfaceVk.h"
14 
15 struct __IOSurface;
16 typedef __IOSurface *IOSurfaceRef;
17 
18 namespace egl
19 {
20 class AttributeMap;
21 }  // namespace egl
22 
23 namespace rx
24 {
25 
26 class IOSurfaceSurfaceVkMac : public OffscreenSurfaceVk
27 {
28   public:
29     IOSurfaceSurfaceVkMac(const egl::SurfaceState &state,
30                           EGLClientBuffer buffer,
31                           const egl::AttributeMap &attribs,
32                           RendererVk *renderer);
33     ~IOSurfaceSurfaceVkMac() override;
34 
35     egl::Error initialize(const egl::Display *display) override;
36 
37     egl::Error unMakeCurrent(const gl::Context *context) override;
38 
39     egl::Error bindTexImage(const gl::Context *context,
40                             gl::Texture *texture,
41                             EGLint buffer) override;
42     egl::Error releaseTexImage(const gl::Context *context, EGLint buffer) override;
43 
44     static bool ValidateAttributes(const DisplayVk *displayVk,
45                                    EGLClientBuffer buffer,
46                                    const egl::AttributeMap &attribs);
47 
48   protected:
49     angle::Result initializeImpl(DisplayVk *displayVk) override;
50 
51   private:
52     IOSurfaceRef mIOSurface;
53 
54     int mPlane;
55     int mFormatIndex;
56 };
57 
58 }  // namespace rx
59 
60 #endif  // LIBANGLE_RENDERER_VULKAN_MAC_IOSURFACESURFACEVKMAC_H_
61