• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*-------------------------------------------------------------------------
2 * drawElements Quality Program Tester Core
3 * ----------------------------------------
4 *
5 * Copyright 2018 The Android Open Source Project
6 *
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
10 *
11 *      http://www.apache.org/licenses/LICENSE-2.0
12 *
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 *
19 *//*!
20 * \file
21 * \brief VK_MVK_macos_surface compatible view
22 *//*--------------------------------------------------------------------*/
23
24#include "tcuOSXMetalView.hpp"
25
26#import <AppKit/AppKit.h>
27#import <QuartzCore/QuartzCore.h>
28
29@interface NativeMetalView : NSView
30@end
31
32@implementation NativeMetalView
33- (id)initWithFrame:(NSRect) frame {
34	if(self = [super initWithFrame: frame]) {
35		// Make this a layer-backed view
36		self.wantsLayer = YES;
37	}
38	return self;
39}
40
41// Callback to create the backing metal layer
42- (CALayer*)makeBackingLayer {
43	return [CAMetalLayer layer];
44}
45@end
46
47namespace tcu
48{
49namespace osx
50{
51	MetalView::MetalView (int width, int height)
52	: m_view([[NativeMetalView alloc] initWithFrame:NSMakeRect(0, 0, width, height)])
53	{
54	}
55
56	void MetalView::setSize(int width, int height)
57	{
58		[(NativeMetalView*)m_view setFrame:NSMakeRect(0, 0, width, height)];
59	}
60
61	MetalView::~MetalView ()
62	{
63		[(NativeMetalView*)m_view dealloc];
64	}
65} // osx
66} // tcu
67