Skip to content

Commit

Permalink
Fixed compatibility with m116
Browse files Browse the repository at this point in the history
  • Loading branch information
tonsky committed Aug 8, 2023
1 parent 497b0ac commit 395789c
Show file tree
Hide file tree
Showing 31 changed files with 397 additions and 207 deletions.
23 changes: 23 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,26 @@
# 0.116.0 - Aug 8, 2023

Added:

- ARM64 jars thx @Glavo

Fixed:

- Race condition in shared library unpacking #54 #56 thx @dzaima
- NPE in Typeface::makeFromName #49

Changed:

- Skia version m109-664500fa93 -> m116-f44dbc40d8
- [ BREAKING ] `Bitmap::erase(Color4f)` no longer takes ColorSpace
- [ BREAKING ] `Image::encodeToData` has been replaced with `::encodeJPEG`, `::encodePNG`, `::encodeWEBP`, plus the encoding options
- [ BREAKING ] `ImageFilter::MakeMagnifier` required two more arguments: `zoomAmount` and `SamplingMode`

Removed:

- [ BREAKING ] `ImageFilter::MakeAlphaThreshold`
- [ BREAKING ] `ImageFilter::MakePaint`

# 0.109.2 - Feb 27, 2022

- Lombok version updated 1.18.22 -> 1.18.26 #43 via @Glavo
Expand Down
2 changes: 1 addition & 1 deletion examples/scenes/src/BitmapImageScene.java
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public void draw(Canvas canvas, int width, int height, float dpi, int xpos, int

// Bitmap + Image.readPixels(50, 50)
try (var bitmap = new Bitmap();) {
bitmap.allocPixels(new ImageInfo(300, 300, ColorType.GRAY_8, ColorAlphaType.OPAQUE));
bitmap.allocPixels(new ImageInfo(300, 300, ColorType.RGBA_8888, ColorAlphaType.OPAQUE));
image.readPixels(bitmap, 50, 50);
try (var image = Image.makeFromBitmap(bitmap.setImmutable());) {
canvas.drawImageRect(image, Rect.makeXYWH(25, 25, 150, 150));
Expand Down
8 changes: 4 additions & 4 deletions examples/scenes/src/BitmapScene.java
Original file line number Diff line number Diff line change
Expand Up @@ -232,10 +232,10 @@ public void drawErase(Canvas canvas, IRect target, IRect screen, float dpi) {
var w = target.getWidth() / 2;
var h = target.getHeight() / 2;
var srcInfo = ImageInfo.makeS32((int) (w * dpi), (int) (h * dpi), ColorAlphaType.UNPREMUL);
var red = new Color4f(0.93725497f, 0, 0);
var red = new Color4f(1f, 0, 0);
try (var src = new Bitmap();) {
src.allocPixels(srcInfo);
src.erase(red, ColorSpace.getDisplayP3());
src.erase(red);
var color = src.getColor4f((int) (w / 2 * dpi), (int) (h / 2 * dpi));
assert new Color4f(1, 0, 0).equals(color) : "Expected " + new Color4f(1, 0, 0) + ", got " + color;
try (var image = Image.makeFromBitmap(src.setImmutable());) {
Expand All @@ -255,7 +255,7 @@ public void drawErase(Canvas canvas, IRect target, IRect screen, float dpi) {

try (var src = new Bitmap();) {
src.allocPixels(srcInfo);
src.erase(red, ColorSpace.getDisplayP3(), IRect.makeXYWH((int) (w / 4 * dpi), (int) (h / 4 * dpi), (int) (w / 2 * dpi), (int) (h / 2 * dpi)));
src.erase(red, IRect.makeXYWH((int) (w / 4 * dpi), (int) (h / 4 * dpi), (int) (w / 2 * dpi), (int) (h / 2 * dpi)));
var color = src.getColor4f((int) (w / 2 * dpi), (int) (h / 2 * dpi));
assert new Color4f(1, 0, 0).equals(color) : "Expected " + new Color4f(1, 0, 0) + ", got " + color;
try (var image = Image.makeFromBitmap(src.setImmutable());) {
Expand All @@ -265,7 +265,7 @@ public void drawErase(Canvas canvas, IRect target, IRect screen, float dpi) {

try (var src = new Bitmap();) {
src.allocPixels(srcInfo);
src.erase(red, null, IRect.makeXYWH((int) (w / 4 * dpi), (int) (h / 4 * dpi), (int) (w / 2 * dpi), (int) (h / 2 * dpi)));
src.erase(red, IRect.makeXYWH((int) (w / 4 * dpi), (int) (h / 4 * dpi), (int) (w / 2 * dpi), (int) (h / 2 * dpi)));
var color = src.getColor4f((int) (w / 2 * dpi), (int) (h / 2 * dpi));
assert red.equals(color) : "Expected " + red + ", got " + color;
try (var image = Image.makeFromBitmap(src.setImmutable());) {
Expand Down
7 changes: 3 additions & 4 deletions examples/scenes/src/ImageFiltersScene.java
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,10 @@ private void drawImageFilters(Canvas canvas, float width, float dpi) {
IRect bb = IRect.makeXYWH(0, 0, 60, 60);
ImageFilter[] filters = new ImageFilter[] {
ImageFilter.makeOffset(0, 0, null, bb),
ImageFilter.makeMagnifier(Rect.makeXYWH(0 * dpi, 0 * dpi, 60 * dpi, 60 * dpi), 5f, null, bb),
ImageFilter.makeMagnifier(Rect.makeXYWH(0 * dpi, 0 * dpi, 60 * dpi, 60 * dpi), 10f, null, bb),
ImageFilter.makeMagnifier(Rect.makeXYWH(0 * dpi, 0 * dpi, 60 * dpi, 60 * dpi), 20f, null, bb),
ImageFilter.makeMagnifier(Rect.makeXYWH(0 * dpi, 0 * dpi, 60 * dpi, 60 * dpi), 5f, 5f, SamplingMode.MITCHELL, null, bb),
ImageFilter.makeMagnifier(Rect.makeXYWH(0 * dpi, 0 * dpi, 60 * dpi, 60 * dpi), 10f, 10f, SamplingMode.MITCHELL, null, bb),
ImageFilter.makeMagnifier(Rect.makeXYWH(0 * dpi, 0 * dpi, 60 * dpi, 60 * dpi), 20f, 20f, SamplingMode.MITCHELL, null, bb),
ImageFilter.makeOffset(10, 10, null, bb),
ImageFilter.makePaint(fill, bb),
ImageFilter.makeTile(Rect.makeXYWH(10, 10, 40, 40), Rect.makeXYWH(0, 0, 60, 60), null),
ImageFilter.makeDilate(2, 2, null, bb),
ImageFilter.makeErode(2, 2, null, bb),
Expand Down
2 changes: 1 addition & 1 deletion examples/scenes/src/Scenes.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

public class Scenes {
public static TreeMap<String, Scene> scenes;
public static String currentScene = "SVG Scaling";
public static String currentScene = "Bitmap Image";
public static HUD hud = new HUD();
public static boolean stats = true;

Expand Down
1 change: 1 addition & 0 deletions platform/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ add_definitions(-DFT2_BUILD_LIBRARY
-DPNG_INTEL_SSE
-DPNG_SET_OPTION_SUPPORTED
-DSK_GL
-DSK_GANESH
-DSK_SHAPER_HARFBUZZ_AVAILABLE
-DSK_UNICODE_AVAILABLE
# skia/third_party/icu/BUILD.gn
Expand Down
10 changes: 4 additions & 6 deletions platform/cc/Bitmap.cc
Original file line number Diff line number Diff line change
Expand Up @@ -191,17 +191,15 @@ extern "C" JNIEXPORT void JNICALL Java_io_github_humbleui_skija_Bitmap__1nNotify
}

extern "C" JNIEXPORT void JNICALL Java_io_github_humbleui_skija_Bitmap__1nErase4f
(JNIEnv* env, jclass jclass, jlong ptr, jfloat r, jfloat g, jfloat b, jfloat a, jlong colorSpacePtr) {
(JNIEnv* env, jclass jclass, jlong ptr, jfloat r, jfloat g, jfloat b, jfloat a) {
SkBitmap* instance = reinterpret_cast<SkBitmap*>(static_cast<uintptr_t>(ptr));
SkColorSpace* colorSpace = reinterpret_cast<SkColorSpace*>(static_cast<uintptr_t>(colorSpacePtr));
instance->eraseColor({r, g, b, a}, colorSpace);
instance->eraseColor({r, g, b, a});
}

extern "C" JNIEXPORT void JNICALL Java_io_github_humbleui_skija_Bitmap__1nEraseRect4f
(JNIEnv* env, jclass jclass, jlong ptr, jfloat r, jfloat g, jfloat b, jfloat a, jlong colorSpacePtr, jint left, jint top, jint right, jint bottom) {
(JNIEnv* env, jclass jclass, jlong ptr, jfloat r, jfloat g, jfloat b, jfloat a, jint left, jint top, jint right, jint bottom) {
SkBitmap* instance = reinterpret_cast<SkBitmap*>(static_cast<uintptr_t>(ptr));
SkColorSpace* colorSpace = reinterpret_cast<SkColorSpace*>(static_cast<uintptr_t>(colorSpacePtr));
instance->erase({r, g, b, a}, colorSpace, {left, top, right, bottom});
instance->erase({r, g, b, a}, {left, top, right, bottom});
}

extern "C" JNIEXPORT void JNICALL Java_io_github_humbleui_skija_Bitmap__1nErase
Expand Down
9 changes: 4 additions & 5 deletions platform/cc/ColorFilter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
#include "SkHighContrastFilter.h"
#include "SkLumaColorFilter.h"
#include "SkOverdrawColorFilter.h"
#include "SkTableColorFilter.h"
#include "interop.hh"

extern "C" JNIEXPORT jlong JNICALL Java_io_github_humbleui_skija_ColorFilter__1nMakeComposed
Expand Down Expand Up @@ -76,9 +75,9 @@ extern "C" JNIEXPORT jlong JNICALL Java_io_github_humbleui_skija_ColorFilter__1n
extern "C" JNIEXPORT jlong JNICALL Java_io_github_humbleui_skija_ColorFilter__1nMakeTable
(JNIEnv* env, jclass jclass, jbyteArray tableArray) {
jbyte* table = env->GetByteArrayElements(tableArray, 0);
SkColorFilter* ptr = SkTableColorFilter::Make(reinterpret_cast<uint8_t*>(table)).release();
sk_sp<SkColorFilter> ptr = SkColorFilters::Table(reinterpret_cast<uint8_t*>(table));
env->ReleaseByteArrayElements(tableArray, table, 0);
return reinterpret_cast<jlong>(ptr);
return reinterpret_cast<jlong>(ptr.release());
}

extern "C" JNIEXPORT jlong JNICALL Java_io_github_humbleui_skija_ColorFilter__1nMakeTableARGB
Expand All @@ -88,14 +87,14 @@ extern "C" JNIEXPORT jlong JNICALL Java_io_github_humbleui_skija_ColorFilter__1n
jbyte* g = arrayG ? env->GetByteArrayElements(arrayG, 0) : nullptr;
jbyte* b = arrayB ? env->GetByteArrayElements(arrayB, 0) : nullptr;

SkColorFilter* ptr = SkTableColorFilter::MakeARGB(reinterpret_cast<uint8_t*>(a), reinterpret_cast<uint8_t*>(r), reinterpret_cast<uint8_t*>(g), reinterpret_cast<uint8_t*>(b)).release();
sk_sp<SkColorFilter> ptr = SkColorFilters::TableARGB(reinterpret_cast<uint8_t*>(a), reinterpret_cast<uint8_t*>(r), reinterpret_cast<uint8_t*>(g), reinterpret_cast<uint8_t*>(b));

if (arrayA) env->ReleaseByteArrayElements(arrayA, a, 0);
if (arrayR) env->ReleaseByteArrayElements(arrayR, r, 0);
if (arrayG) env->ReleaseByteArrayElements(arrayG, g, 0);
if (arrayB) env->ReleaseByteArrayElements(arrayB, b, 0);

return reinterpret_cast<jlong>(ptr);
return reinterpret_cast<jlong>(ptr.release());
}

extern "C" JNIEXPORT jlong JNICALL Java_io_github_humbleui_skija_ColorFilter__1nMakeOverdraw
Expand Down
4 changes: 3 additions & 1 deletion platform/cc/Drawable.cc
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include <iostream>
#include <jni.h>
#include "SkDrawable.h"
#include "SkPicture.h"
#include "interop.hh"

class SkijaDrawableImpl: public SkDrawable {
Expand Down Expand Up @@ -61,7 +62,8 @@ extern "C" JNIEXPORT void JNICALL Java_io_github_humbleui_skija_Drawable__1nDraw
extern "C" JNIEXPORT jlong JNICALL Java_io_github_humbleui_skija_Drawable__1nMakePictureSnapshot
(JNIEnv* env, jclass jclass, jlong ptr) {
SkijaDrawableImpl* instance = reinterpret_cast<SkijaDrawableImpl*>(static_cast<uintptr_t>(ptr));
return reinterpret_cast<jlong>(instance->newPictureSnapshot());
sk_sp<SkPicture> pic = instance->makePictureSnapshot();
return reinterpret_cast<jlong>(pic.release());
}

extern "C" JNIEXPORT jint JNICALL Java_io_github_humbleui_skija_Drawable__1nGetGenerationId
Expand Down
16 changes: 8 additions & 8 deletions platform/cc/FontMgr.cc
Original file line number Diff line number Diff line change
Expand Up @@ -22,24 +22,24 @@ extern "C" JNIEXPORT jstring JNICALL Java_io_github_humbleui_skija_FontMgr__1nGe
extern "C" JNIEXPORT jlong JNICALL Java_io_github_humbleui_skija_FontMgr__1nMakeStyleSet
(JNIEnv* env, jclass jclass, jlong ptr, jint index) {
SkFontMgr* instance = reinterpret_cast<SkFontMgr*>(static_cast<uintptr_t>(ptr));
SkFontStyleSet* styleSet = instance->createStyleSet(index);
return reinterpret_cast<jlong>(styleSet);
sk_sp<SkFontStyleSet> styleSet = instance->createStyleSet(index);
return reinterpret_cast<jlong>(styleSet.release());
}

extern "C" JNIEXPORT jlong JNICALL Java_io_github_humbleui_skija_FontMgr__1nMatchFamily
(JNIEnv* env, jclass jclass, jlong ptr, jstring familyNameStr) {
SkFontMgr* instance = reinterpret_cast<SkFontMgr*>(static_cast<uintptr_t>(ptr));
SkString familyName = skString(env, familyNameStr);
SkFontStyleSet* styleSet = instance->matchFamily(familyName.c_str());
return reinterpret_cast<jlong>(styleSet);
sk_sp<SkFontStyleSet> styleSet = instance->matchFamily(familyName.c_str());
return reinterpret_cast<jlong>(styleSet.release());
}

extern "C" JNIEXPORT jlong JNICALL Java_io_github_humbleui_skija_FontMgr__1nMatchFamilyStyle
(JNIEnv* env, jclass jclass, jlong ptr, jstring familyNameStr, jint fontStyle) {
SkFontMgr* instance = reinterpret_cast<SkFontMgr*>(static_cast<uintptr_t>(ptr));
SkString familyName = skString(env, familyNameStr);
SkTypeface* typeface = instance->matchFamilyStyle(familyName.c_str(), skija::FontStyle::fromJava(fontStyle));
return reinterpret_cast<jlong>(typeface);
sk_sp<SkTypeface> typeface = instance->matchFamilyStyle(familyName.c_str(), skija::FontStyle::fromJava(fontStyle));
return reinterpret_cast<jlong>(typeface.release());
}

extern "C" JNIEXPORT jlong JNICALL Java_io_github_humbleui_skija_FontMgr__1nMatchFamilyStyleCharacter
Expand All @@ -53,9 +53,9 @@ extern "C" JNIEXPORT jlong JNICALL Java_io_github_humbleui_skija_FontMgr__1nMatc
for (int i = 0; i < bcp47.size(); ++i)
bcp47[i] = bcp47Strings[i].c_str();

SkTypeface* typeface = instance->matchFamilyStyleCharacter(familyName.c_str(), skija::FontStyle::fromJava(fontStyle), bcp47.data(), (int) bcp47.size(), character);
sk_sp<SkTypeface> typeface = instance->matchFamilyStyleCharacter(familyName.c_str(), skija::FontStyle::fromJava(fontStyle), bcp47.data(), (int) bcp47.size(), character);

return reinterpret_cast<jlong>(typeface);
return reinterpret_cast<jlong>(typeface.release());
}

extern "C" JNIEXPORT jlong JNICALL Java_io_github_humbleui_skija_FontMgr__1nMakeFromData
Expand Down
12 changes: 6 additions & 6 deletions platform/cc/FontStyleSet.cc
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@

extern "C" JNIEXPORT jlong JNICALL Java_io_github_humbleui_skija_FontStyleSet__1nMakeEmpty
(JNIEnv* env, jclass jclass) {
SkFontStyleSet* instance = SkFontStyleSet::CreateEmpty();
return reinterpret_cast<jlong>(instance);
sk_sp<SkFontStyleSet> instance = SkFontStyleSet::CreateEmpty();
return reinterpret_cast<jlong>(instance.release());
}

extern "C" JNIEXPORT jint JNICALL Java_io_github_humbleui_skija_FontStyleSet__1nCount
Expand Down Expand Up @@ -35,13 +35,13 @@ extern "C" JNIEXPORT jstring JNICALL Java_io_github_humbleui_skija_FontStyleSet_
extern "C" JNIEXPORT jlong JNICALL Java_io_github_humbleui_skija_FontStyleSet__1nGetTypeface
(JNIEnv* env, jclass jclass, jlong ptr, jint index) {
SkFontStyleSet* instance = reinterpret_cast<SkFontStyleSet*>(static_cast<uintptr_t>(ptr));
SkTypeface* typeface = instance->createTypeface(index);
return reinterpret_cast<jlong>(typeface);
sk_sp<SkTypeface> typeface = instance->createTypeface(index);
return reinterpret_cast<jlong>(typeface.release());
}

extern "C" JNIEXPORT jlong JNICALL Java_io_github_humbleui_skija_FontStyleSet__1nMatchStyle
(JNIEnv* env, jclass jclass, jlong ptr, jint fontStyle) {
SkFontStyleSet* instance = reinterpret_cast<SkFontStyleSet*>(static_cast<uintptr_t>(ptr));
SkTypeface* typeface = instance->matchStyle(skija::FontStyle::fromJava(fontStyle));
return reinterpret_cast<jlong>(typeface);
sk_sp<SkTypeface> typeface = instance->matchStyle(skija::FontStyle::fromJava(fontStyle));
return reinterpret_cast<jlong>(typeface.release());
}
43 changes: 34 additions & 9 deletions platform/cc/Image.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
#include "SkBitmap.h"
#include "SkData.h"
#include "SkImage.h"
#include "SkJpegEncoder.h"
#include "SkPngEncoder.h"
#include "SkWebpEncoder.h"
#include "SkShader.h"
#include "interop.hh"

extern "C" JNIEXPORT jlong JNICALL Java_io_github_humbleui_skija_Image__1nMakeRaster
Expand All @@ -14,7 +18,7 @@ extern "C" JNIEXPORT jlong JNICALL Java_io_github_humbleui_skija_Image__1nMakeRa
static_cast<SkAlphaType>(alphaType),
sk_ref_sp<SkColorSpace>(colorSpace));
void* bytes = env->GetPrimitiveArrayCritical(bytesArr, 0);
sk_sp<SkImage> image = SkImage::MakeRasterCopy(SkPixmap(imageInfo, bytes, rowBytes));
sk_sp<SkImage> image = SkImages::RasterFromPixmapCopy(SkPixmap(imageInfo, bytes, rowBytes));
env->ReleasePrimitiveArrayCritical(bytesArr, bytes, 0);
return reinterpret_cast<jlong>(image.release());
}
Expand All @@ -28,21 +32,21 @@ extern "C" JNIEXPORT jlong JNICALL Java_io_github_humbleui_skija_Image__1nMakeRa
static_cast<SkAlphaType>(alphaType),
sk_ref_sp<SkColorSpace>(colorSpace));
SkData* data = reinterpret_cast<SkData*>(static_cast<uintptr_t>(dataPtr));
sk_sp<SkImage> image = SkImage::MakeRasterData(imageInfo, sk_ref_sp(data), rowBytes);
sk_sp<SkImage> image = SkImages::RasterFromData(imageInfo, sk_ref_sp(data), rowBytes);
return reinterpret_cast<jlong>(image.release());
}

extern "C" JNIEXPORT jlong JNICALL Java_io_github_humbleui_skija_Image__1nMakeFromBitmap
(JNIEnv* env, jclass jclass, jlong bitmapPtr) {
SkBitmap* bitmap = reinterpret_cast<SkBitmap*>(static_cast<uintptr_t>(bitmapPtr));
sk_sp<SkImage> image = SkImage::MakeFromBitmap(*bitmap);
sk_sp<SkImage> image = SkImages::RasterFromBitmap(*bitmap);
return reinterpret_cast<jlong>(image.release());
}

extern "C" JNIEXPORT jlong JNICALL Java_io_github_humbleui_skija_Image__1nMakeFromPixmap
(JNIEnv* env, jclass jclass, jlong pixmapPtr) {
SkPixmap* pixmap = reinterpret_cast<SkPixmap*>(static_cast<uintptr_t>(pixmapPtr));
sk_sp<SkImage> image = SkImage::MakeFromRaster(*pixmap, nullptr, nullptr);
sk_sp<SkImage> image = SkImages::RasterFromPixmap(*pixmap, nullptr, nullptr);
return reinterpret_cast<jlong>(image.release());
}

Expand All @@ -53,7 +57,7 @@ extern "C" JNIEXPORT jlong JNICALL Java_io_github_humbleui_skija_Image__1nMakeFr
sk_sp<SkData> encodedData = SkData::MakeWithCopy(encoded, encodedLen);
env->ReleaseByteArrayElements(encodedArray, encoded, 0);

sk_sp<SkImage> image = SkImage::MakeFromEncoded(encodedData);
sk_sp<SkImage> image = SkImages::DeferredFromEncodedData(encodedData);

return reinterpret_cast<jlong>(image.release());
}
Expand All @@ -64,11 +68,32 @@ extern "C" JNIEXPORT jobject JNICALL Java_io_github_humbleui_skija_Image__1nGetI
return skija::ImageInfo::toJava(env, instance->imageInfo());
}

extern "C" JNIEXPORT jlong JNICALL Java_io_github_humbleui_skija_Image__1nEncodeToData
(JNIEnv* env, jclass jclass, jlong ptr, jint format, jint quality) {
extern "C" JNIEXPORT jlong JNICALL Java_io_github_humbleui_skija_Image__1nEncodePNG
(JNIEnv* env, jclass jclass, jlong ptr, jlong ctxPtr, jint flagsInt, jint zlibLevel) {
SkImage* instance = reinterpret_cast<SkImage*>(static_cast<uintptr_t>(ptr));
SkData* data = instance->encodeToData(static_cast<SkEncodedImageFormat>(format), quality).release();
return reinterpret_cast<jlong>(data);
GrDirectContext* ctx = reinterpret_cast<GrDirectContext*>(static_cast<uintptr_t>(ctxPtr));
SkPngEncoder::FilterFlag flags = static_cast<SkPngEncoder::FilterFlag>(flagsInt);
SkPngEncoder::Options opts {flags, zlibLevel};
sk_sp<SkData> data = SkPngEncoder::Encode(ctx, instance, opts);
return reinterpret_cast<jlong>(data.release());
}

extern "C" JNIEXPORT jlong JNICALL Java_io_github_humbleui_skija_Image__1nEncodeJPEG
(JNIEnv* env, jclass jclass, jlong ptr, jlong ctxPtr, jint quality, jint alphaMode, jint downsampleMode) {
SkImage* instance = reinterpret_cast<SkImage*>(static_cast<uintptr_t>(ptr));
GrDirectContext* ctx = reinterpret_cast<GrDirectContext*>(static_cast<uintptr_t>(ctxPtr));
SkJpegEncoder::Options opts {quality, (SkJpegEncoder::Downsample) downsampleMode, (SkJpegEncoder::AlphaOption) alphaMode};
sk_sp<SkData> data = SkJpegEncoder::Encode(ctx, instance, opts);
return reinterpret_cast<jlong>(data.release());
}

extern "C" JNIEXPORT jlong JNICALL Java_io_github_humbleui_skija_Image__1nEncodeWEBP
(JNIEnv* env, jclass jclass, jlong ptr, jlong ctxPtr, jint compressionMode, jfloat quality) {
SkImage* instance = reinterpret_cast<SkImage*>(static_cast<uintptr_t>(ptr));
GrDirectContext* ctx = reinterpret_cast<GrDirectContext*>(static_cast<uintptr_t>(ctxPtr));
SkWebpEncoder::Options opts {(SkWebpEncoder::Compression) compressionMode, quality};
sk_sp<SkData> data = SkWebpEncoder::Encode(ctx, instance, opts);
return reinterpret_cast<jlong>(data.release());
}

extern "C" JNIEXPORT jlong JNICALL Java_io_github_humbleui_skija_Image__1nMakeShader
Expand Down
Loading

0 comments on commit 395789c

Please sign in to comment.