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/MTLMaskBlit.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 <stdlib.h>
27
#include <jlong.h>
28
29
#include "MTLMaskBlit.h"
30
#include "MTLRenderQueue.h"
31
#include "MTLBlitLoops.h"
32
33
/**
34
* REMIND: This method assumes that the dimensions of the incoming pixel
35
* array are less than or equal to the cached blit texture tile;
36
* these are rather fragile assumptions, and should be cleaned up...
37
*/
38
void
39
MTLMaskBlit_MaskBlit(JNIEnv *env, MTLContext *mtlc, BMTLSDOps * dstOps,
40
jint dstx, jint dsty,
41
jint width, jint height,
42
void *pPixels)
43
{
44
J2dTraceLn(J2D_TRACE_INFO, "MTLMaskBlit_MaskBlit");
45
46
if (width <= 0 || height <= 0) {
47
J2dTraceLn(J2D_TRACE_WARNING, "MTLMaskBlit_MaskBlit: invalid dimensions");
48
return;
49
}
50
51
RETURN_IF_NULL(pPixels);
52
RETURN_IF_NULL(mtlc);
53
54
MTLPooledTextureHandle * texHandle = [mtlc.texturePool
55
getTexture:width
56
height:height
57
format:MTLPixelFormatBGRA8Unorm];
58
if (texHandle == nil) {
59
J2dTraceLn(J2D_TRACE_ERROR, "MTLMaskBlit_MaskBlit: can't obtain temporary texture object from pool");
60
return;
61
}
62
[[mtlc getCommandBufferWrapper] registerPooledTexture:texHandle];
63
64
id<MTLTexture> texBuff = texHandle.texture;
65
MTLRegion region = MTLRegionMake2D(0, 0, width, height);
66
[texBuff replaceRegion:region mipmapLevel:0 withBytes:pPixels bytesPerRow:4*width];
67
68
drawTex2Tex(mtlc, texBuff, dstOps->pTexture, JNI_FALSE, dstOps->isOpaque, 0,
69
0, 0, width, height, dstx, dsty, dstx + width, dsty + height);
70
}
71
72