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{ 35 if (self = [super initWithFrame:frame]) 36 { 37 // Make this a layer-backed view 38 self.wantsLayer = YES; 39 } 40 return self; 41} 42 43// Callback to create the backing metal layer 44- (CALayer *)makeBackingLayer 45{ 46 return [CAMetalLayer layer]; 47} 48@end 49 50namespace tcu 51{ 52namespace osx 53{ 54MetalView::MetalView(int width, int height) 55 : m_view([[NativeMetalView alloc] 56 initWithFrame:NSMakeRect(0, 0, width, height)]) 57{ 58} 59 60void MetalView::setSize(int width, int height) 61{ 62 [(NativeMetalView *)m_view setFrame:NSMakeRect(0, 0, width, height)]; 63} 64 65MetalView::~MetalView() { [(NativeMetalView *)m_view release]; } 66} // namespace osx 67} // namespace tcu 68