c0a582ff4f42b46e56d6acb0e90f401a6c4a8b8d
[platform/upstream/SDL.git] / src / video / cocoa / SDL_cocoametalview.h
1 /*
2   Simple DirectMedia Layer
3   Copyright (C) 1997-2018 Sam Lantinga <slouken@libsdl.org>
4
5   This software is provided 'as-is', without any express or implied
6   warranty.  In no event will the authors be held liable for any damages
7   arising from the use of this software.
8
9   Permission is granted to anyone to use this software for any purpose,
10   including commercial applications, and to alter it and redistribute it
11   freely, subject to the following restrictions:
12
13   1. The origin of this software must not be misrepresented; you must not
14      claim that you wrote the original software. If you use this software
15      in a product, an acknowledgment in the product documentation would be
16      appreciated but is not required.
17   2. Altered source versions must be plainly marked as such, and must not be
18      misrepresented as being the original software.
19   3. This notice may not be removed or altered from any source distribution.
20 */
21 /*
22  * @author Mark Callow, www.edgewise-consulting.com.
23  *
24  * Thanks to Alex Szpakowski, @slime73 on GitHub, for his gist showing
25  * how to add a CAMetalLayer backed view.
26  */
27
28 #ifndef SDL_cocoametalview_h_
29 #define SDL_cocoametalview_h_
30
31 #import "../SDL_sysvideo.h"
32 #import "SDL_cocoawindow.h"
33
34 #if SDL_VIDEO_DRIVER_COCOA && (SDL_VIDEO_VULKAN || SDL_VIDEO_RENDER_METAL)
35
36 #import <Cocoa/Cocoa.h>
37 #import <Metal/Metal.h>
38 #import <QuartzCore/CAMetalLayer.h>
39
40 #define METALVIEW_TAG 255
41
42 @interface SDL_cocoametalview : NSView {
43     NSInteger _tag;
44 }
45
46 - (instancetype)initWithFrame:(NSRect)frame
47                         scale:(CGFloat)scale;
48
49 /* Override superclass tag so this class can set it. */
50 @property (assign, readonly) NSInteger tag;
51
52 @end
53
54 SDL_cocoametalview* Cocoa_Mtl_AddMetalView(SDL_Window* window);
55
56 void Cocoa_Mtl_GetDrawableSize(SDL_Window * window, int * w, int * h);
57
58 #endif /* SDL_VIDEO_DRIVER_COCOA && (SDL_VIDEO_VULKAN || SDL_VIDEO_RENDER_METAL) */
59
60 #endif /* SDL_cocoametalview_h_ */
61
62 /* vi: set ts=4 sw=4 expandtab: */
63