Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/src/java.desktop/macosx/native/libawt_lwawt/java2d/metal/MTLStencilManager.m
41159 views
1
/*
2
* Copyright (c) 2019, 2021, Oracle and/or its affiliates. All rights reserved.
3
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4
*
5
* This code is free software; you can redistribute it and/or modify it
6
* under the terms of the GNU General Public License version 2 only, as
7
* published by the Free Software Foundation. Oracle designates this
8
* particular file as subject to the "Classpath" exception as provided
9
* by Oracle in the LICENSE file that accompanied this code.
10
*
11
* This code is distributed in the hope that it will be useful, but WITHOUT
12
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14
* version 2 for more details (a copy is included in the LICENSE file that
15
* accompanied this code).
16
*
17
* You should have received a copy of the GNU General Public License version
18
* 2 along with this work; if not, write to the Free Software Foundation,
19
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20
*
21
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22
* or visit www.oracle.com if you need additional information or have any
23
* questions.
24
*/
25
26
#include "MTLStencilManager.h"
27
//#include "MTLContext.h"
28
//#include "sun_java2d_SunGraphics2D.h"
29
//#import "common.h"
30
31
@implementation MTLStencilManager {
32
id<MTLDepthStencilState> _stencilState;
33
id<MTLDepthStencilState> _genStencilState;
34
}
35
36
@synthesize stencilState = _stencilState;
37
@synthesize genStencilState = _genStencilState;
38
39
- (id _Nonnull)initWithDevice:(id<MTLDevice>) device {
40
self = [super init];
41
if (self) {
42
MTLDepthStencilDescriptor* stencilDescriptor;
43
stencilDescriptor = [[MTLDepthStencilDescriptor new] autorelease];
44
stencilDescriptor.frontFaceStencil.stencilCompareFunction = MTLCompareFunctionEqual;
45
stencilDescriptor.frontFaceStencil.stencilFailureOperation = MTLStencilOperationKeep;
46
47
// TODO : backFaceStencil can be set to nil if all primitives are drawn as front-facing primitives
48
// currently, fill parallelogram uses back-facing primitive drawing - that needs to be changed.
49
// Once that part is changed, set backFaceStencil to nil
50
//stencilDescriptor.backFaceStencil = nil;
51
52
stencilDescriptor.backFaceStencil.stencilCompareFunction = MTLCompareFunctionEqual;
53
stencilDescriptor.backFaceStencil.stencilFailureOperation = MTLStencilOperationKeep;
54
_stencilState = [device newDepthStencilStateWithDescriptor:stencilDescriptor];
55
56
MTLDepthStencilDescriptor* genStencilDescriptor;
57
genStencilDescriptor = [[MTLDepthStencilDescriptor new] autorelease];
58
genStencilDescriptor.backFaceStencil.stencilCompareFunction = MTLCompareFunctionAlways;
59
genStencilDescriptor.backFaceStencil.depthStencilPassOperation = MTLStencilOperationReplace;
60
genStencilDescriptor.frontFaceStencil.stencilCompareFunction = MTLCompareFunctionAlways;
61
genStencilDescriptor.frontFaceStencil.depthStencilPassOperation = MTLStencilOperationReplace;
62
_genStencilState = [device newDepthStencilStateWithDescriptor:genStencilDescriptor];
63
}
64
return self;
65
}
66
67
- (void)dealloc {
68
[_stencilState release];
69
[super dealloc];
70
}
71
72
@end
73
74