| 6 | import io.github.humbleui.types.*; |
| 7 | |
| 8 | public class Image extends RefCnt implements IHasImageInfo { |
| 9 | static { Library.staticLoad(); } |
| 10 | |
| 11 | @ApiStatus.Internal |
| 12 | public ImageInfo _imageInfo = null; |
| 13 | |
| 14 | @ApiStatus.Internal |
| 15 | public Image(long ptr) { |
| 16 | super(ptr); |
| 17 | } |
| 18 | |
| 19 | /** |
| 20 | * @deprecated - use {@link #makeRasterFromBytes(ImageInfo, byte[], long)} |
| 21 | */ |
| 22 | @Deprecated |
| 23 | public static Image makeRaster(ImageInfo imageInfo, byte[] bytes, long rowBytes) { |
| 24 | return makeRasterFromBytes(imageInfo, bytes, rowBytes); |
| 25 | } |
| 26 | |
| 27 | /** |
| 28 | * <p>Creates Image and adopts texture.</p> |
| 29 | * |
| 30 | * <p>Image is returned if the texture is valid.</p> |
| 31 | * |
| 32 | * @param directContext GrDirectContext |
| 33 | * @param backendTexture GrBackendTexture |
| 34 | * @param surfaceOrigin GrSurfaceOrigin |
| 35 | * @param colorType SkColorType |
| 36 | * @return Image |
| 37 | */ |
| 38 | public static Image adoptTextureFrom(DirectContext directContext, BackendTexture backendTexture, SurfaceOrigin surfaceOrigin, ColorType colorType) { |
| 39 | try { |
| 40 | Stats.onNativeCall(); |
| 41 | long ptr = _nAdoptTextureFrom(Native.getPtr(directContext), |
| 42 | Native.getPtr(backendTexture), |
| 43 | surfaceOrigin.ordinal(), |
| 44 | colorType.ordinal()); |
| 45 | if (ptr == 0) |
| 46 | throw new RuntimeException("Failed to adoptTextureFrom " + backendTexture); |
| 47 | return new Image(ptr); |
| 48 | } finally { |
| 49 | ReferenceUtil.reachabilityFence(directContext); |
| 50 | ReferenceUtil.reachabilityFence(backendTexture); |
| 51 | } |
| 52 | } |
| 53 | |
| 54 | /** |
| 55 | * <p>Creates image and borrows texture.</p> |
| 56 | * |
| 57 | * <p>Image is returned if the texture is valid.</p> |
| 58 | * |
| 59 | * @param directContext GrDirectContext |
| 60 | * @param backendTexture GrBackendTexture |
| 61 | * @param surfaceOrigin GrSurfaceOrigin |
| 62 | * @param colorType SkColorType |
| 63 | * @param colorAlphaType SkAlphaType |
| 64 | * @param colorSpace SkColorSpace |
| 65 | * @param releaseProc TextureReleaseProc |
no test coverage detected