xref: /aosp_15_r20/external/angle/util/ios/IOSWindow.mm (revision 8975f5c5ed3d1c378011245431ada316dfb6f244)
1*8975f5c5SAndroid Build Coastguard Worker//
2*8975f5c5SAndroid Build Coastguard Worker// Copyright 2020 The ANGLE Project Authors. All rights reserved.
3*8975f5c5SAndroid Build Coastguard Worker// Use of this source code is governed by a BSD-style license that can be
4*8975f5c5SAndroid Build Coastguard Worker// found in the LICENSE file.
5*8975f5c5SAndroid Build Coastguard Worker//
6*8975f5c5SAndroid Build Coastguard Worker
7*8975f5c5SAndroid Build Coastguard Worker// IOSWindow.mm: Implementation of OSWindow for iOS
8*8975f5c5SAndroid Build Coastguard Worker
9*8975f5c5SAndroid Build Coastguard Worker#include "util/ios/IOSWindow.h"
10*8975f5c5SAndroid Build Coastguard Worker
11*8975f5c5SAndroid Build Coastguard Worker#include <set>
12*8975f5c5SAndroid Build Coastguard Worker
13*8975f5c5SAndroid Build Coastguard Worker#include "anglebase/no_destructor.h"
14*8975f5c5SAndroid Build Coastguard Worker#include "common/debug.h"
15*8975f5c5SAndroid Build Coastguard Worker
16*8975f5c5SAndroid Build Coastguard Worker#import <UIKit/UIKit.h>
17*8975f5c5SAndroid Build Coastguard Worker
18*8975f5c5SAndroid Build Coastguard Workerstatic CALayer *rootLayer()
19*8975f5c5SAndroid Build Coastguard Worker{
20*8975f5c5SAndroid Build Coastguard Worker    return [[[[[UIApplication sharedApplication] delegate] window] rootViewController] view].layer;
21*8975f5c5SAndroid Build Coastguard Worker}
22*8975f5c5SAndroid Build Coastguard Worker
23*8975f5c5SAndroid Build Coastguard Workerbool IOSWindow::initializeImpl(const std::string &name, int width, int height)
24*8975f5c5SAndroid Build Coastguard Worker{
25*8975f5c5SAndroid Build Coastguard Worker    resize(width, height);
26*8975f5c5SAndroid Build Coastguard Worker    return true;
27*8975f5c5SAndroid Build Coastguard Worker}
28*8975f5c5SAndroid Build Coastguard Worker
29*8975f5c5SAndroid Build Coastguard WorkerEGLNativeWindowType IOSWindow::getNativeWindow() const
30*8975f5c5SAndroid Build Coastguard Worker{
31*8975f5c5SAndroid Build Coastguard Worker    return rootLayer();
32*8975f5c5SAndroid Build Coastguard Worker}
33*8975f5c5SAndroid Build Coastguard Worker
34*8975f5c5SAndroid Build Coastguard Workerbool IOSWindow::setOrientation(int width, int height)
35*8975f5c5SAndroid Build Coastguard Worker{
36*8975f5c5SAndroid Build Coastguard Worker    UNIMPLEMENTED();
37*8975f5c5SAndroid Build Coastguard Worker    return false;
38*8975f5c5SAndroid Build Coastguard Worker}
39*8975f5c5SAndroid Build Coastguard Worker
40*8975f5c5SAndroid Build Coastguard Workerbool IOSWindow::resize(int width, int height)
41*8975f5c5SAndroid Build Coastguard Worker{
42*8975f5c5SAndroid Build Coastguard Worker    rootLayer().frame = CGRectMake(0, 0, width, height);
43*8975f5c5SAndroid Build Coastguard Worker    return true;
44*8975f5c5SAndroid Build Coastguard Worker}
45*8975f5c5SAndroid Build Coastguard Worker
46*8975f5c5SAndroid Build Coastguard Worker// static
47*8975f5c5SAndroid Build Coastguard WorkerOSWindow *OSWindow::New()
48*8975f5c5SAndroid Build Coastguard Worker{
49*8975f5c5SAndroid Build Coastguard Worker    return new IOSWindow;
50*8975f5c5SAndroid Build Coastguard Worker}
51