blob: 5c12e587a8fc06500c8db2be1f78a1b677d71a15 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
#include "cocoa-util.h"
#import <Cocoa/Cocoa.h>
#import <QuartzCore/CAMetalLayer.h>
namespace gfx {
void CocoaUtil::getNSWindowContentSize(void* nswindow, int* widthOut, int* heightOut)
{
NSWindow* window = (NSWindow*)nswindow;
const NSRect contentRect = [window.contentView frame];
*widthOut = contentRect.size.width;
*heightOut = contentRect.size.height;
}
void* CocoaUtil::createMetalLayer(void* nswindow)
{
CAMetalLayer *layer = [CAMetalLayer layer];
NSWindow* window = (NSWindow*)nswindow;
window.contentView.layer = layer;
window.contentView.wantsLayer = YES;
return layer;
}
void* CocoaUtil::nextDrawable(void* metalLayer)
{
CAMetalLayer* layer = (CAMetalLayer*)metalLayer;
return [layer nextDrawable];
}
void CocoaUtil::destroyMetalLayer(void* metalLayer)
{
CAMetalLayer* layer = (CAMetalLayer*)metalLayer;
[layer release];
}
}
|