1/*
2 * Copyright (c) 2000, 2005, 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 "AnyInt.h"
27#include "IntArgbPre.h"
28#include "AlphaMacros.h"
29
30#include "IntArgb.h"
31#include "IntRgb.h"
32#include "ThreeByteBgr.h"
33#include "ByteGray.h"
34#include "ByteIndexed.h"
35
36/*
37 * This file declares, registers, and defines the various graphics
38 * primitive loops to manipulate surfaces of type "IntArgbPre".
39 *
40 * See also LoopMacros.h
41 */
42
43RegisterFunc RegisterIntArgbPre;
44
45DECLARE_CONVERT_BLIT(IntArgbPre, IntArgb);
46DECLARE_CONVERT_BLIT(IntArgb, IntArgbPre);
47DECLARE_CONVERT_BLIT(IntRgb, IntArgbPre);
48DECLARE_CONVERT_BLIT(ThreeByteBgr, IntArgbPre);
49DECLARE_CONVERT_BLIT(ByteGray, IntArgbPre);
50DECLARE_CONVERT_BLIT(ByteIndexed, IntArgbPre);
51DECLARE_SCALE_BLIT(IntArgbPre, IntArgb);
52DECLARE_SCALE_BLIT(IntArgb, IntArgbPre);
53DECLARE_SCALE_BLIT(IntRgb, IntArgbPre);
54DECLARE_SCALE_BLIT(ThreeByteBgr, IntArgbPre);
55DECLARE_SCALE_BLIT(ByteGray, IntArgbPre);
56DECLARE_SCALE_BLIT(ByteIndexed, IntArgbPre);
57DECLARE_XPAR_CONVERT_BLIT(ByteIndexedBm, IntArgbPre);
58DECLARE_XPAR_SCALE_BLIT(ByteIndexedBm, IntArgbPre);
59DECLARE_XPAR_BLITBG(ByteIndexedBm, IntArgbPre);
60
61DECLARE_XOR_BLIT(IntArgb, IntArgbPre);
62DECLARE_SRC_MASKFILL(IntArgbPre);
63DECLARE_SRCOVER_MASKFILL(IntArgbPre);
64DECLARE_ALPHA_MASKFILL(IntArgbPre);
65DECLARE_SRCOVER_MASKBLIT(IntArgb, IntArgbPre);
66DECLARE_ALPHA_MASKBLIT(IntArgb, IntArgbPre);
67DECLARE_SRCOVER_MASKBLIT(IntArgbPre, IntArgbPre);
68DECLARE_ALPHA_MASKBLIT(IntArgbPre, IntArgbPre);
69DECLARE_ALPHA_MASKBLIT(IntRgb, IntArgbPre);
70DECLARE_SOLID_DRAWGLYPHLISTAA(IntArgbPre);
71DECLARE_SOLID_DRAWGLYPHLISTLCD(IntArgbPre);
72
73DECLARE_TRANSFORMHELPER_FUNCS(IntArgbPre);
74
75NativePrimitive IntArgbPrePrimitives[] = {
76    REGISTER_ANYINT_ISOCOPY_BLIT(IntArgbPre),
77    REGISTER_ANYINT_ISOSCALE_BLIT(IntArgbPre),
78    REGISTER_CONVERT_BLIT(IntArgbPre, IntArgb),
79    REGISTER_CONVERT_BLIT(IntArgb, IntArgbPre),
80    REGISTER_CONVERT_BLIT(IntRgb, IntArgbPre),
81    REGISTER_CONVERT_BLIT(ThreeByteBgr, IntArgbPre),
82    REGISTER_CONVERT_BLIT(ByteGray, IntArgbPre),
83    REGISTER_CONVERT_BLIT(ByteIndexed, IntArgbPre),
84    REGISTER_SCALE_BLIT(IntArgbPre, IntArgb),
85    REGISTER_SCALE_BLIT(IntArgb, IntArgbPre),
86    REGISTER_SCALE_BLIT(IntRgb, IntArgbPre),
87    REGISTER_SCALE_BLIT(ThreeByteBgr, IntArgbPre),
88    REGISTER_SCALE_BLIT(ByteGray, IntArgbPre),
89    REGISTER_SCALE_BLIT(ByteIndexed, IntArgbPre),
90    REGISTER_XPAR_CONVERT_BLIT(ByteIndexedBm, IntArgbPre),
91    REGISTER_XPAR_SCALE_BLIT(ByteIndexedBm, IntArgbPre),
92    REGISTER_XPAR_BLITBG(ByteIndexedBm, IntArgbPre),
93
94    REGISTER_XOR_BLIT(IntArgb, IntArgbPre),
95    REGISTER_SRC_MASKFILL(IntArgbPre),
96    REGISTER_SRCOVER_MASKFILL(IntArgbPre),
97    REGISTER_ALPHA_MASKFILL(IntArgbPre),
98    REGISTER_SRCOVER_MASKBLIT(IntArgb, IntArgbPre),
99    REGISTER_ALPHA_MASKBLIT(IntArgb, IntArgbPre),
100    REGISTER_SRCOVER_MASKBLIT(IntArgbPre, IntArgbPre),
101    REGISTER_ALPHA_MASKBLIT(IntArgbPre, IntArgbPre),
102    REGISTER_ALPHA_MASKBLIT(IntRgb, IntArgbPre),
103    REGISTER_SOLID_DRAWGLYPHLISTAA(IntArgbPre),
104    REGISTER_SOLID_DRAWGLYPHLISTLCD(IntArgbPre),
105
106    REGISTER_TRANSFORMHELPER_FUNCS(IntArgbPre),
107};
108
109jboolean RegisterIntArgbPre(JNIEnv *env)
110{
111    return RegisterPrimitives(env, IntArgbPrePrimitives,
112                              ArraySize(IntArgbPrePrimitives));
113}
114
115jint PixelForIntArgbPre(SurfaceDataRasInfo *pRasInfo, jint rgb)
116{
117    jint a, r, g, b;
118    if (((rgb >> 24) + 1) == 0) {
119        return rgb;
120    }
121    ExtractIntDcmComponents1234(rgb, a, r, g, b);
122    r = MUL8(a, r);
123    g = MUL8(a, g);
124    b = MUL8(a, b);
125    return ComposeIntDcmComponents1234(a, r, g, b);
126}
127
128DEFINE_CONVERT_BLIT(IntArgbPre, IntArgb, 1IntArgb)
129
130DEFINE_CONVERT_BLIT(IntArgb, IntArgbPre, 1IntArgb)
131
132DEFINE_CONVERT_BLIT(IntRgb, IntArgbPre, 1IntArgb)
133
134DEFINE_CONVERT_BLIT(ThreeByteBgr, IntArgbPre, 1IntArgb)
135
136DEFINE_CONVERT_BLIT(ByteGray, IntArgbPre, 1IntArgb)
137
138DEFINE_CONVERT_BLIT_LUT8(ByteIndexed, IntArgbPre, ConvertOnTheFly)
139
140DEFINE_SCALE_BLIT(IntArgbPre, IntArgb, 1IntArgb)
141
142DEFINE_SCALE_BLIT(IntArgb, IntArgbPre, 1IntArgb)
143
144DEFINE_SCALE_BLIT(IntRgb, IntArgbPre, 1IntArgb)
145
146DEFINE_SCALE_BLIT(ThreeByteBgr, IntArgbPre, 1IntArgb)
147
148DEFINE_SCALE_BLIT(ByteGray, IntArgbPre, 1IntArgb)
149
150DEFINE_SCALE_BLIT_LUT8(ByteIndexed, IntArgbPre, ConvertOnTheFly)
151
152DEFINE_XPAR_CONVERT_BLIT_LUT8(ByteIndexedBm, IntArgbPre, ConvertOnTheFly)
153
154DEFINE_XPAR_SCALE_BLIT_LUT8(ByteIndexedBm, IntArgbPre, ConvertOnTheFly)
155
156DEFINE_XPAR_BLITBG_LUT8(ByteIndexedBm, IntArgbPre, ConvertOnTheFly)
157
158DEFINE_XOR_BLIT(IntArgb, IntArgbPre, AnyInt)
159
160DEFINE_SRC_MASKFILL(IntArgbPre, 4ByteArgb)
161
162DEFINE_SRCOVER_MASKFILL(IntArgbPre, 4ByteArgb)
163
164DEFINE_ALPHA_MASKFILL(IntArgbPre, 4ByteArgb)
165
166DEFINE_SRCOVER_MASKBLIT(IntArgb, IntArgbPre, 4ByteArgb)
167
168DEFINE_ALPHA_MASKBLIT(IntArgb, IntArgbPre, 4ByteArgb)
169
170DEFINE_SRCOVER_MASKBLIT(IntArgbPre, IntArgbPre, 4ByteArgb)
171
172DEFINE_ALPHA_MASKBLIT(IntArgbPre, IntArgbPre, 4ByteArgb)
173
174DEFINE_ALPHA_MASKBLIT(IntRgb, IntArgbPre, 4ByteArgb)
175
176DEFINE_SOLID_DRAWGLYPHLISTAA(IntArgbPre, 4ByteArgb)
177
178DEFINE_SOLID_DRAWGLYPHLISTLCD(IntArgbPre, 4ByteArgb)
179
180DEFINE_TRANSFORMHELPERS(IntArgbPre)
181