Add PencilGraphics forwards for drawRect() and fillTriangle().
[SquirrelJME.git] / modules / cldc-compact / src / main / java / cc / squirreljme / jvm / mle / PencilShelf.java
blobef5430dd4cc3d930f3ee81b4ee5a6461a79e325c
1 // -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
2 // ---------------------------------------------------------------------------
3 // SquirrelJME
4 // Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
5 // ---------------------------------------------------------------------------
6 // SquirrelJME is under the GNU General Public License v3+, or later.
7 // See license.mkd for licensing and copyright information.
8 // ---------------------------------------------------------------------------
10 package cc.squirreljme.jvm.mle;
12 import cc.squirreljme.jvm.mle.brackets.PencilBracket;
13 import cc.squirreljme.jvm.mle.constants.NativeImageLoadParameter;
14 import cc.squirreljme.jvm.mle.constants.NativeImageLoadType;
15 import cc.squirreljme.jvm.mle.constants.PencilCapabilities;
16 import cc.squirreljme.jvm.mle.constants.UIPixelFormat;
17 import cc.squirreljme.jvm.mle.exceptions.MLECallError;
18 import cc.squirreljme.runtime.cldc.annotation.Api;
19 import cc.squirreljme.runtime.cldc.annotation.SquirrelJMEVendorApi;
21 /**
22 * This shelf is responsible for accelerated graphics drawing.
24 * @see PencilBracket
25 * @since 2020/09/25
27 @SquirrelJMEVendorApi
28 public final class PencilShelf
30 /**
31 * Not used.
33 * @since 2020/09/25
35 @SquirrelJMEVendorApi
36 private PencilShelf()
40 /**
41 * Returns the capabilities of the native possibly hardware accelerated
42 * pencil graphics drawing for the given pixel format.
44 * @param __pf The {@link UIPixelFormat} being used for drawing.
45 * @throws MLECallError If the pixel format is not valid.
46 * @return The capabilities, will be the bit-field of
47 * {@link PencilCapabilities}. If there is not capability for this format
48 * then {@code 0} will be returned.
49 * @since 2020/09/25
51 @SquirrelJMEVendorApi
52 public static native int capabilities(int __pf)
53 throws MLECallError;
55 /**
56 * Draws a line in hardware.
58 * @param __g The hardware graphics to draw with.
59 * @param __x1 The starting X coordinate.
60 * @param __y1 The starting Y coordinate.
61 * @param __x2 The ending X coordinate.
62 * @param __y2 The ending Y coordinate.
63 * @throws MLECallError On null arguments.
64 * @since 2021/12/05
66 @SquirrelJMEVendorApi
67 public static native void hardwareDrawLine(PencilBracket __g,
68 int __x1, int __y1, int __x2, int __y2)
69 throws MLECallError;
71 /**
72 * Draws the outline of the given rectangle using the current color and
73 * stroke style. The rectangle will cover an area that is
74 * {@code [width + 1, height + 1]}.
76 * Nothing is drawn if the width and/or height are zero.
78 * @param __g The hardware graphics to draw with.
79 * @param __x The X coordinate.
80 * @param __y The Y coordinate.
81 * @param __w The width.
82 * @param __h The height.
83 * @throws MLECallError If the graphics is not valid or does not support
84 * the given operation.
85 * @since 2023/02/16
87 @SquirrelJMEVendorApi
88 public static native void hardwareDrawRect(PencilBracket __g,
89 int __x, int __y, int __w, int __h)
90 throws MLECallError;
92 /**
93 * Draws a region of 32-bit RGB data into the target.
95 * @param __data The source buffer.
96 * @param __off The offset into the buffer.
97 * @param __scanLen The scanline length.
98 * @param __alpha Drawing with the alpha channel?
99 * @param __xSrc The source X position.
100 * @param __ySrc The source Y position.
101 * @param __wSrc The width of the source region.
102 * @param __hSrc The height of the source region.
103 * @param __trans Sprite translation and/or rotation, see
104 * {@code javax.microedition.lcdui.game.Sprite}.
105 * @param __xDest The destination X position, is translated.
106 * @param __yDest The destination Y position, is translated.
107 * @param __anch The anchor point.
108 * @param __wDest The destination width.
109 * @param __hDest The destination height.
110 * @param __origImgWidth Original image width.
111 * @param __origImgHeight Original image height.
112 * @throws MLECallError On null arguments.
113 * @since 2022/01/26
115 @SquirrelJMEVendorApi
116 public static native void hardwareDrawXRGB32Region(
117 PencilBracket __hardware, int[] __data, int __off, int __scanLen,
118 boolean __alpha, int __xSrc, int __ySrc, int __wSrc, int __hSrc,
119 int __trans, int __xDest, int __yDest, int __anch, int __wDest,
120 int __hDest, int __origImgWidth, int __origImgHeight)
121 throws MLECallError;
124 * Performs rectangular fill in hardware.
126 * @param __g The hardware graphics to draw with.
127 * @param __x The X coordinate.
128 * @param __y The Y coordinate.
129 * @param __w The width.
130 * @param __h The height.
131 * @throws MLECallError On {@code null} arguments.
132 * @since 2021/12/05
134 @SquirrelJMEVendorApi
135 public static native void hardwareFillRect(PencilBracket __g,
136 int __x, int __y, int __w, int __h)
137 throws MLECallError;
140 * Draws a filled triangle using the current color, the lines which make
141 * up the triangle are included in the filled area.
143 * @param __g The graphics to use for drawing.
144 * @param __x1 First X coordinate.
145 * @param __y1 First Y coordinate.
146 * @param __x2 Second X coordinate.
147 * @param __y2 Second Y coordinate.
148 * @param __x3 Third X coordinate.
149 * @param __y3 Third Y coordinate.
150 * @throws MLECallError If no graphics were specified or the graphics does
151 * not actually support the given operation.
152 * @since 2023/02/16
154 @SquirrelJMEVendorApi
155 public static native void hardwareFillTriangle(PencilBracket __g,
156 int __x1, int __y1, int __x2, int __y2, int __x3, int __y3)
157 throws MLECallError;
160 * Creates a hardware reference bracket to the native hardware graphics.
162 * @param __pf The {@link UIPixelFormat} used for the draw.
163 * @param __bw The buffer width, this is the scanline width of the buffer.
164 * @param __bh The buffer height.
165 * @param __buf The target buffer to draw to, this is cast to the correct
166 * buffer format.
167 * @param __offset The offset to the start of the buffer.
168 * @param __pal The color palette, may be {@code null}.
169 * @param __sx Starting surface X coordinate.
170 * @param __sy Starting surface Y coordinate.
171 * @param __sw Surface width.
172 * @param __sh Surface height.
173 * @throws MLECallError If the requested graphics are not valid.
174 * @since 2020/09/25
176 @SquirrelJMEVendorApi
177 public static native PencilBracket hardwareGraphics(int __pf, int __bw,
178 int __bh, Object __buf, int __offset, int[] __pal, int __sx, int __sy,
179 int __sw, int __sh)
180 throws MLECallError;
183 * Sets the alpha color for graphics.
185 * @param __g The hardware graphics to draw with.
186 * @param __argb The color to set.
187 * @throws MLECallError On {@code null} arguments.
188 * @since 2021/12/05
190 @SquirrelJMEVendorApi
191 public static native void hardwareSetAlphaColor(PencilBracket __g,
192 int __argb)
193 throws MLECallError;
196 * Sets the blending mode to use.
198 * @param __g The hardware graphics to draw with.
199 * @param __mode The blending mode to use.
200 * @throws MLECallError On {@code null} arguments.
201 * @since 2021/12/05
203 @SquirrelJMEVendorApi
204 public static native void hardwareSetBlendingMode(PencilBracket __g,
205 int __mode)
206 throws MLECallError;
209 * Sets the clipping rectangle position.
211 * @param __g The hardware graphics to draw with.
212 * @param __x The X coordinate.
213 * @param __y The Y coordinate.
214 * @param __w The width.
215 * @param __h The height.
216 * @throws MLECallError On {@code null} arguments.
217 * @since 2021/12/05
219 @SquirrelJMEVendorApi
220 public static native void hardwareSetClip(PencilBracket __g,
221 int __x, int __y, int __w, int __h)
222 throws MLECallError;
225 * Sets the stroke style for the hardware graphics.
227 * @param __g The hardware graphics to draw with.
228 * @param __style The stroke type to set.
229 * @throws MLECallError On {@code null} arguments.
230 * @since 2021/12/05
232 @SquirrelJMEVendorApi
233 public static native void hardwareSetStrokeStyle(PencilBracket __g,
234 int __style)
235 throws MLECallError;
238 * Translates drawing operations.
240 * @param __g The hardware graphics to draw with.
241 * @param __x The X translation.
242 * @param __y The Y translation.
243 * @throws MLECallError On {@code null} arguments.
244 * @since 2021/12/05
246 @SquirrelJMEVendorApi
247 public static native void hardwareTranslate(PencilBracket __g, int __x,
248 int __y)
249 throws MLECallError;
252 * Performs native image loading and returns a semi-modified RGB buffer
253 * where the first values according to {@link NativeImageLoadParameter}
254 * represent information about the image.
256 * @param __type The {@link NativeImageLoadType} to load.
257 * @param __b The buffer.
258 * @param __o The offset.
259 * @param __l The length.
260 * @return The raw RGB for the image with starting parameters.
261 * @throws MLECallError If the image could not be loaded.
262 * @since 2021/12/05
264 @SquirrelJMEVendorApi
265 public static native int[] nativeImageLoadRGBA(int __type,
266 byte[] __b, int __o, int __l)
267 throws MLECallError;
270 * Returns a bit field of {@link NativeImageLoadType} which indicates which
271 * types of images are capable of being natively loaded on a platform
272 * which requiring byte code to be executed for it.
274 * @return The bit field of {@link NativeImageLoadType} that can be
275 * natively loaded.
276 * @since 2021/12/05
278 @SquirrelJMEVendorApi
279 public static native int nativeImageLoadTypes();