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/MTLUtils.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 "MTLUtils.h"
27
28
#include <jni.h>
29
#include <simd/simd.h>
30
#import <ThreadUtilities.h>
31
#import <PropertiesUtilities.h>
32
#include "common.h"
33
#include "Trace.h"
34
35
extern void J2dTraceImpl(int level, jboolean cr, const char *string, ...);
36
void J2dTraceTraceVector(simd_float4 pt) {
37
J2dTraceImpl(J2D_TRACE_VERBOSE, JNI_FALSE, "[%lf %lf %lf %lf]", pt.x, pt.y, pt.z, pt.w);
38
}
39
40
void checkTransform(float * position, simd_float4x4 transform4x4) {
41
J2dTraceImpl(J2D_TRACE_VERBOSE, JNI_FALSE, "check transform: ");
42
43
simd_float4 fpt = simd_make_float4(position[0], position[1], position[2], 1.f);
44
simd_float4 fpt_trans = simd_mul(transform4x4, fpt);
45
J2dTraceTraceVector(fpt);
46
J2dTraceImpl(J2D_TRACE_VERBOSE, JNI_FALSE, " ===>>> ");
47
J2dTraceTraceVector(fpt_trans);
48
J2dTraceImpl(J2D_TRACE_VERBOSE, JNI_TRUE, " ");
49
}
50
51
static void traceMatrix(simd_float4x4 * mtx) {
52
for (int row = 0; row < 4; ++row) {
53
J2dTraceImpl(J2D_TRACE_VERBOSE, JNI_FALSE, " [%lf %lf %lf %lf]",
54
mtx->columns[0][row], mtx->columns[1][row], mtx->columns[2][row], mtx->columns[3][row]);
55
}
56
}
57
58
void traceRaster(char * p, int width, int height, int stride) {
59
for (int y = 0; y < height; ++y) {
60
for (int x = 0; x < width; ++x) {
61
unsigned char pix0 = p[y*stride + x*4];
62
unsigned char pix1 = p[y*stride + x*4 + 1];
63
unsigned char pix2 = p[y*stride + x*4 + 2];
64
unsigned char pix3 = p[y*stride + x*4 + 3];
65
J2dTraceImpl(J2D_TRACE_INFO, JNI_FALSE,"[%u,%u,%u,%u], ", pix0, pix1, pix2, pix3);
66
}
67
J2dTraceImpl(J2D_TRACE_INFO, JNI_TRUE, "");
68
}
69
}
70
71
void tracePoints(jint nPoints, jint *xPoints, jint *yPoints) {
72
for (int i = 0; i < nPoints; i++)
73
J2dTraceImpl(J2D_TRACE_INFO, JNI_TRUE, "\t(%d, %d)", *(xPoints++), *(yPoints++));
74
}
75
76
77
jboolean isOptionEnabled(const char * option) {
78
JNIEnv *env = [ThreadUtilities getJNIEnvUncached];
79
80
NSString * optionProp = [PropertiesUtilities
81
javaSystemPropertyForKey:[NSString stringWithUTF8String:option] withEnv:env];
82
NSString * lowerCaseProp = [optionProp localizedLowercaseString];
83
return [@"true" isEqual:lowerCaseProp];
84
}
85
86