| 9 | import io.github.humbleui.types.*; |
| 10 | |
| 11 | public class Pixmap extends Managed implements IHasImageInfo { |
| 12 | static { Library.staticLoad(); } |
| 13 | |
| 14 | @ApiStatus.Internal |
| 15 | public Pixmap(long ptr, boolean managed) { |
| 16 | super(ptr, _FinalizerHolder.PTR, managed); |
| 17 | } |
| 18 | |
| 19 | @ApiStatus.Internal |
| 20 | public ImageInfo _imageInfo = null; |
| 21 | |
| 22 | public Pixmap() { |
| 23 | this(_nMakeNull(), true); |
| 24 | Stats.onNativeCall(); |
| 25 | } |
| 26 | |
| 27 | @Override @NotNull |
| 28 | public ImageInfo getImageInfo() { |
| 29 | try { |
| 30 | if (_imageInfo == null) { |
| 31 | Stats.onNativeCall(); |
| 32 | _imageInfo = _nGetImageInfo(_ptr); |
| 33 | } |
| 34 | return _imageInfo; |
| 35 | } finally { |
| 36 | ReferenceUtil.reachabilityFence(this); |
| 37 | } |
| 38 | } |
| 39 | |
| 40 | public static Pixmap make(ImageInfo info, ByteBuffer buffer, int rowBytes) { |
| 41 | return make(info, BufferUtil.getPointerFromByteBuffer(buffer), rowBytes); |
| 42 | } |
| 43 | |
| 44 | public static Pixmap make(ImageInfo info, long addr, int rowBytes) { |
| 45 | try { |
| 46 | long ptr = _nMake( |
| 47 | info._width, info._height, |
| 48 | info._colorInfo._colorType.ordinal(), |
| 49 | info._colorInfo._alphaType.ordinal(), |
| 50 | Native.getPtr(info._colorInfo._colorSpace), addr, rowBytes); |
| 51 | if (ptr == 0) |
| 52 | throw new IllegalArgumentException("Failed to create Pixmap."); |
| 53 | return new Pixmap(ptr, true); |
| 54 | } finally { |
| 55 | ReferenceUtil.reachabilityFence(info._colorInfo._colorSpace); |
| 56 | } |
| 57 | } |
| 58 | |
| 59 | public void reset() { |
| 60 | Stats.onNativeCall(); |
| 61 | _nReset(_ptr); |
| 62 | _imageInfo = null; |
| 63 | ReferenceUtil.reachabilityFence(this); |
| 64 | } |
| 65 | |
| 66 | public void reset(ImageInfo info, long addr, int rowBytes) { |
| 67 | Stats.onNativeCall(); |
| 68 | _nResetWithInfo(_ptr, |
nothing calls this directly
no test coverage detected