Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/src/java.desktop/share/native/libawt/java2d/loops/BlitBg.c
41159 views
1
/*
2
* Copyright (c) 2000, 2013, 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 "GraphicsPrimitiveMgr.h"
27
#include "Region.h"
28
29
#include "sun_java2d_loops_BlitBg.h"
30
31
/*
32
* Class: sun_java2d_loops_BlitBg
33
* Method: BlitBg
34
* Signature: (Lsun/java2d/SurfaceData;Lsun/java2d/SurfaceData;Ljava/awt/Composite;IIIIIII)V
35
*/
36
JNIEXPORT void JNICALL Java_sun_java2d_loops_BlitBg_BlitBg
37
(JNIEnv *env, jobject self,
38
jobject srcData, jobject dstData,
39
jobject comp, jobject clip, jint bgColor,
40
jint srcx, jint srcy, jint dstx, jint dsty, jint width, jint height)
41
{
42
SurfaceDataOps *srcOps;
43
SurfaceDataOps *dstOps;
44
SurfaceDataRasInfo srcInfo;
45
SurfaceDataRasInfo dstInfo;
46
NativePrimitive *pPrim;
47
CompositeInfo compInfo;
48
RegionData clipInfo;
49
jint dstFlags;
50
51
pPrim = GetNativePrim(env, self);
52
if (pPrim == NULL) {
53
return;
54
}
55
if (pPrim->pCompType->getCompInfo != NULL) {
56
(*pPrim->pCompType->getCompInfo)(env, &compInfo, comp);
57
}
58
if (Region_GetInfo(env, clip, &clipInfo)) {
59
return;
60
}
61
62
srcOps = SurfaceData_GetOps(env, srcData);
63
if (srcOps == 0) {
64
return;
65
}
66
dstOps = SurfaceData_GetOps(env, dstData);
67
if (dstOps == 0) {
68
return;
69
}
70
71
srcInfo.bounds.x1 = srcx;
72
srcInfo.bounds.y1 = srcy;
73
srcInfo.bounds.x2 = srcx + width;
74
srcInfo.bounds.y2 = srcy + height;
75
dstInfo.bounds.x1 = dstx;
76
dstInfo.bounds.y1 = dsty;
77
dstInfo.bounds.x2 = dstx + width;
78
dstInfo.bounds.y2 = dsty + height;
79
srcx -= dstx;
80
srcy -= dsty;
81
SurfaceData_IntersectBounds(&dstInfo.bounds, &clipInfo.bounds);
82
if (srcOps->Lock(env, srcOps, &srcInfo, pPrim->srcflags) != SD_SUCCESS) {
83
return;
84
}
85
86
dstFlags = pPrim->dstflags;
87
if (!Region_IsRectangular(&clipInfo)) {
88
dstFlags |= SD_LOCK_PARTIAL_WRITE;
89
}
90
if (dstOps->Lock(env, dstOps, &dstInfo, dstFlags) != SD_SUCCESS) {
91
SurfaceData_InvokeUnlock(env, srcOps, &srcInfo);
92
return;
93
}
94
SurfaceData_IntersectBlitBounds(&dstInfo.bounds, &srcInfo.bounds,
95
srcx, srcy);
96
Region_IntersectBounds(&clipInfo, &dstInfo.bounds);
97
98
if (!Region_IsEmpty(&clipInfo)) {
99
jint bgpixel = bgColor;
100
srcOps->GetRasInfo(env, srcOps, &srcInfo);
101
dstOps->GetRasInfo(env, dstOps, &dstInfo);
102
if (pPrim->pDstType->pixelFor) {
103
bgpixel = (*pPrim->pDstType->pixelFor)(&dstInfo, bgpixel);
104
}
105
if (srcInfo.rasBase && dstInfo.rasBase) {
106
SurfaceDataBounds span;
107
jint savesx = srcInfo.bounds.x1;
108
jint savedx = dstInfo.bounds.x1;
109
Region_StartIteration(env, &clipInfo);
110
while (Region_NextIteration(&clipInfo, &span)) {
111
void *pSrc = PtrCoord(srcInfo.rasBase,
112
srcx + span.x1, srcInfo.pixelStride,
113
srcy + span.y1, srcInfo.scanStride);
114
void *pDst = PtrCoord(dstInfo.rasBase,
115
span.x1, dstInfo.pixelStride,
116
span.y1, dstInfo.scanStride);
117
/*
118
* Fix for 4804375
119
* REMIND: There should probably be a better
120
* way to give the span coordinates to the
121
* inner loop. This is only really needed
122
* for the 1, 2, and 4 bit loops.
123
*/
124
srcInfo.bounds.x1 = srcx + span.x1;
125
dstInfo.bounds.x1 = span.x1;
126
(*pPrim->funcs.blitbg)(pSrc, pDst,
127
span.x2 - span.x1, span.y2 - span.y1,
128
bgpixel,
129
&srcInfo, &dstInfo, pPrim, &compInfo);
130
}
131
Region_EndIteration(env, &clipInfo);
132
srcInfo.bounds.x1 = savesx;
133
dstInfo.bounds.x1 = savedx;
134
}
135
SurfaceData_InvokeRelease(env, dstOps, &dstInfo);
136
SurfaceData_InvokeRelease(env, srcOps, &srcInfo);
137
}
138
SurfaceData_InvokeUnlock(env, dstOps, &dstInfo);
139
SurfaceData_InvokeUnlock(env, srcOps, &srcInfo);
140
}
141
142