Unverified Commit 4217f641 authored by Pavel's avatar Pavel Committed by GitHub

Pavel.sergeev/set skia m116 (#808)

* update bindings according to skia-m116

* we don't have `ubuntu` suffix in skia artifacts anymore

* fix compilation on windows

* ignore the test because it was failing before

* fix windows compilation

* avgCharWidth is 0f on windows
parent 5027c138
......@@ -589,6 +589,7 @@ fun skiaHeadersDirs(skiaDir: File): List<File> =
skiaDir.resolve("modules/skottie/include"),
skiaDir.resolve("modules/skparagraph/include"),
skiaDir.resolve("modules/skshaper/include"),
skiaDir.resolve("modules/skunicode/include"),
skiaDir.resolve("modules/sksg/include"),
skiaDir.resolve("modules/svg/include"),
skiaDir.resolve("third_party/externals/harfbuzz/src"),
......@@ -607,6 +608,7 @@ fun skiaPreprocessorFlags(os: OS): Array<String> {
"-DSK_GAMMA_SRGB",
"-DSK_SCALAR_TO_FLOAT_EXCLUDED",
"-DSK_SUPPORT_GPU=1",
"-DSK_GANESH",
"-DSK_GL",
"-DSK_SHAPER_HARFBUZZ_AVAILABLE",
"-DSK_UNICODE_AVAILABLE",
......@@ -657,7 +659,6 @@ fun skiaStaticLibraries(skiaDir: String, targetString: String): List<String> {
val skiaBinSubdir = "$skiaDir/out/${buildType.id}-$targetString"
return listOf(
"libskresources.a",
"libparticles.a",
"libskparagraph.a",
"libskia.a",
"libicu.a",
......
......@@ -140,8 +140,7 @@ class SkikoProperties(private val myProject: Project) {
fun skiaReleaseFor(os: OS, arch: Arch, buildType: SkiaBuildType, isIosSim: Boolean = false): String {
val target = "${os.idWithSuffix(isIosSim = isIosSim)}-${arch.id}"
val tag = myProject.property("dependencies.skia.$target") as String
val suffix = if (os == OS.Linux && arch == Arch.X64) "-ubuntu18" else ""
return "${tag}/Skia-${tag}-${os.idWithSuffix(isIosSim = isIosSim)}-${buildType.id}-${arch.id}$suffix"
return "${tag}/Skia-${tag}-${os.idWithSuffix(isIosSim = isIosSim)}-${buildType.id}-${arch.id}"
}
val releaseGithubVersion: String
......
......@@ -3,19 +3,19 @@ deploy.version=0.0.0
kotlin.mpp.enableGranularSourceSetsMetadata=true
kotlin.native.enableDependencyPropagation=false
dependencies.skia.windows-x64=m110-ad42464-1
dependencies.skia.linux-x64=m110-ad42464-1
dependencies.skia.macos-x64=m110-ad42464-1
dependencies.skia.windows-arm64=m110-ad42464-1
dependencies.skia.linux-arm64=m110-ad42464-1
dependencies.skia.macos-arm64=m110-ad42464-1
dependencies.skia.wasm-wasm=m110-ad42464-1
dependencies.skia.ios-x64=m110-ad42464-1
dependencies.skia.ios-arm64=m110-ad42464-1
dependencies.skia.iosSim-arm64=m110-ad42464-1
dependencies.skia.iosSim-x64=m110-ad42464-1
dependencies.skia.android-x64=m110-ad42464-1
dependencies.skia.android-arm64=m110-ad42464-1
dependencies.skia.windows-x64=m116-51072f3-1
dependencies.skia.linux-x64=m116-51072f3-1
dependencies.skia.macos-x64=m116-51072f3-1
dependencies.skia.windows-arm64=m116-51072f3-1
dependencies.skia.linux-arm64=m116-51072f3-1
dependencies.skia.macos-arm64=m116-51072f3-1
dependencies.skia.wasm-wasm=m116-51072f3-1
dependencies.skia.ios-x64=m116-51072f3-1
dependencies.skia.ios-arm64=m116-51072f3-1
dependencies.skia.iosSim-arm64=m116-51072f3-1
dependencies.skia.iosSim-x64=m116-51072f3-1
dependencies.skia.android-x64=m116-51072f3-1
dependencies.skia.android-arm64=m116-51072f3-1
org.gradle.jvmargs=-Xmx3G -XX:MaxMetaspaceSize=512m
kotlin.native.cacheKind.macosX64=none
......
......@@ -5,7 +5,7 @@
#include "SkColorSpace.h"
#include "SkSurface.h"
#include "src/core/SkAutoMalloc.h"
#include "src/base/SkAutoMalloc.h"
class SoftwareDevice
{
......@@ -64,7 +64,7 @@ extern "C"
SkImageInfo info = SkImageInfo::Make(
width, height, device->colorSpace, kPremul_SkAlphaType,
SkColorSpace::MakeSRGB());
device->surface = SkSurface::MakeRaster(info);
device->surface = SkSurfaces::Raster(info);
return toJavaPointer(device);
}
......@@ -77,7 +77,7 @@ extern "C"
SkImageInfo info = SkImageInfo::Make(
width, height, device->colorSpace, kPremul_SkAlphaType,
SkColorSpace::MakeSRGB());
device->surface = SkSurface::MakeRaster(info);
device->surface = SkSurfaces::Raster(info);
}
JNIEXPORT jlong JNICALL Java_org_jetbrains_skiko_redrawer_AbstractDirectSoftwareRedrawer_acquireSurface(
......
......@@ -6,7 +6,7 @@
#include "SkColorSpace.h"
#include "SkSurface.h"
#include "src/core/SkAutoMalloc.h"
#include "src/base/SkAutoMalloc.h"
#include "../common/interop.hh"
class SoftwareDevice
......@@ -59,7 +59,7 @@ extern "C"
SkImageInfo info = SkImageInfo::Make(
width, height, kBGRA_8888_SkColorType, kPremul_SkAlphaType,
SkColorSpace::MakeSRGB());
device->surface = SkSurface::MakeRasterDirect(info, pixels, sizeof(uint32_t) * width, device->surfaceProps.get());
device->surface = SkSurfaces::WrapPixels(info, pixels, sizeof(uint32_t) * width, device->surfaceProps.get());
GetClientRect(device->window, &device->clientRect);
}
__except(EXCEPTION_EXECUTE_HANDLER) {
......
......@@ -20,7 +20,7 @@ extern "C"
GrDirectContext *context = fromJavaPointer<GrDirectContext *>(contextPtr);
surface->flushAndSubmit(true);
surface->flush(SkSurface::BackendSurfaceAccess::kPresent, GrFlushInfo());
context->flush({});
context->flush();
context->submit(true);
}
__except(EXCEPTION_EXECUTE_HANDLER) {
......
......@@ -10,6 +10,7 @@
#include "GrBackendSurface.h"
#include "GrDirectContext.h"
#include "SkSurface.h"
#include "include/gpu/ganesh/SkSurfaceGanesh.h"
#include "../common/interop.hh"
#include "d3d/GrD3DTypes.h"
......@@ -371,7 +372,7 @@ extern "C"
std::unique_ptr<SkSurfaceProps> surfaceProps = skija::SurfaceProps::toSkSurfaceProps(env, surfacePropsInts);
GrBackendTexture backendTexture((int)d3dDevice->buffers[index]->GetDesc().Width, (int)d3dDevice->buffers[index]->GetDesc().Height, info);
auto result = SkSurface::MakeFromBackendTexture(
auto result = SkSurfaces::WrapBackendTexture(
context, backendTexture, kTopLeft_GrSurfaceOrigin, 0,
kRGBA_8888_SkColorType, SkColorSpace::MakeSRGB(), surfaceProps.get())
.release();
......
......@@ -6,6 +6,7 @@
#import <QuartzCore/CAMetalLayer.h>
#import <Metal/Metal.h>
#import <GrDirectContext.h>
#import <gpu/GrBackendSurface.h>
#import <mtl/GrMtlBackendContext.h>
#import <mtl/GrMtlTypes.h>
......
......@@ -6,6 +6,7 @@
#import <QuartzCore/CAMetalLayer.h>
#import <Metal/Metal.h>
#import <GrDirectContext.h>
#import <gpu/GrBackendSurface.h>
#import <mtl/GrMtlBackendContext.h>
#import <mtl/GrMtlTypes.h>
......
#include "mppinterop.h"
#include "RunRecordClone.hh"
#include "src/utils/SkUTF.h"
#include "src/base/SkUTF.h"
#include <iostream>
namespace skikoMpp {
......
#include "SkShaper.h"
#include "FontRunIterator.hh"
#include "src/utils/SkUTF.h"
#include "src/base/SkUTF.h"
#include "unicode/uchar.h"
#include <iostream>
......
......@@ -60,6 +60,11 @@ enum class ColorType {
*/
BGR_101010X,
/**
* Pixel with 10 bits each for blue, green, red; in 32-bit word, extended range
*/
BGR_101010X_XR,
/**
* Pixel with grayscale level in 8-bit byte
*/
......@@ -130,6 +135,7 @@ enum class ColorType {
RGB_101010X -> 4
BGRA_1010102 -> 4
BGR_101010X -> 4
BGR_101010X_XR -> 4
GRAY_8 -> 1
RGBA_F16NORM -> 8
RGBA_F16 -> 8
......@@ -156,6 +162,7 @@ enum class ColorType {
RGB_101010X -> 2
BGRA_1010102 -> 2
BGR_101010X -> 2
BGR_101010X_XR -> 2
GRAY_8 -> 0
RGBA_F16NORM -> 3
RGBA_F16 -> 3
......@@ -192,7 +199,7 @@ enum class ColorType {
ARGB_4444, RGBA_8888, BGRA_8888, RGBA_1010102, BGRA_1010102, RGBA_F16NORM, RGBA_F16, RGBA_F32, R16G16B16A16_UNORM ->
if (ColorAlphaType.UNKNOWN == alphaType) null
else alphaType
GRAY_8, R8G8_UNORM, R16G16_UNORM, R16G16_FLOAT, RGB_565, RGB_888X, RGB_101010X, BGR_101010X ->
GRAY_8, R8G8_UNORM, R16G16_UNORM, R16G16_FLOAT, RGB_565, RGB_888X, RGB_101010X, BGR_101010X, BGR_101010X_XR ->
ColorAlphaType.OPAQUE
}
}
......
......@@ -5,31 +5,6 @@ import org.jetbrains.skia.impl.*
class ImageFilter internal constructor(ptr: NativePointer) : RefCnt(ptr) {
companion object {
fun makeAlphaThreshold(
r: Region?,
innerMin: Float,
outerMax: Float,
input: ImageFilter?,
crop: IRect?
): ImageFilter {
return try {
Stats.onNativeCall()
interopScope {
ImageFilter(
_nMakeAlphaThreshold(
getPtr(r),
innerMin, outerMax, getPtr(input),
toInterop(crop?.serializeToIntArray())
)
)
}
} finally {
reachabilityBarrier(r)
reachabilityBarrier(input)
}
}
fun makeArithmetic(
k1: Float,
k2: Float,
......@@ -251,7 +226,7 @@ class ImageFilter internal constructor(ptr: NativePointer) : RefCnt(ptr) {
}
}
fun makeMagnifier(r: Rect, inset: Float, input: ImageFilter?, crop: IRect?): ImageFilter {
fun makeMagnifier(r: Rect, zoomAmount: Float, inset: Float, samplingMode: SamplingMode, input: ImageFilter?, crop: IRect?): ImageFilter {
return try {
Stats.onNativeCall()
interopScope {
......@@ -261,7 +236,10 @@ class ImageFilter internal constructor(ptr: NativePointer) : RefCnt(ptr) {
r.top,
r.right,
r.bottom,
zoomAmount,
inset,
samplingMode._packedInt1(),
samplingMode._packedInt2(),
getPtr(input),
toInterop(crop?.serializeToIntArray())
)
......@@ -681,15 +659,6 @@ class ImageFilter internal constructor(ptr: NativePointer) : RefCnt(ptr) {
}
}
@ExternalSymbolName("org_jetbrains_skia_ImageFilter__1nMakeAlphaThreshold")
private external fun _nMakeAlphaThreshold(
regionPtr: NativePointer,
innerMin: Float,
outerMax: Float,
input: NativePointer,
crop: InteropPointer
): NativePointer
@ExternalSymbolName("org_jetbrains_skia_ImageFilter__1nMakeArithmetic")
private external fun _nMakeArithmetic(
k1: Float,
......@@ -763,7 +732,10 @@ private external fun _nMakeMagnifier(
t: Float,
r: Float,
b: Float,
zoomAmount: Float,
inset: Float,
samplingModeVal1: Int,
samplingModeVal2: Int,
input: NativePointer,
crop: InteropPointer
): NativePointer
......
......@@ -4,15 +4,20 @@ import org.jetbrains.skia.impl.use
import org.jetbrains.skia.tests.assertCloseEnough
import org.jetbrains.skia.tests.assertContentCloseEnough
import org.jetbrains.skia.tests.makeFromResource
import org.jetbrains.skiko.KotlinBackend
import org.jetbrains.skiko.OS
import org.jetbrains.skiko.hostOs
import org.jetbrains.skiko.kotlinBackend
import org.jetbrains.skiko.tests.runTest
import kotlin.test.Test
import kotlin.test.assertContentEquals
import kotlin.test.assertEquals
private fun isLinuxOrJs() = (hostOs == OS.Linux) || (hostOs == OS.JS)
private fun isWin() = (hostOs == OS.Windows)
private fun isMac() = (hostOs == OS.MacOS)
private fun isIos() = (hostOs == OS.Ios)
private fun isLinux() = (hostOs == OS.Linux)
private fun isWindows() = (hostOs == OS.Windows)
private fun isJs() = (kotlinBackend == KotlinBackend.JS)
private val COARSE_EPSILON = 2.4f
class FontTests {
......@@ -85,51 +90,30 @@ class FontTests {
assertCloseEnough(expected, actual, COARSE_EPSILON)
}
if (isLinuxOrJs()) {
assertEquals(26, firstGlyphPath.pointsCount)
assertCloseEnough(FontMetrics(
-11.64f,
-11.64f,
3.2400002f,
3.2400002f,
0f,
7.2000003f,
29.460001f,
-20.880001f,
8.58f,
6.6000004f,
8.64f,
0.54f,
1.4399999f,
0.54f,
-3.8999999f
), font.metrics, 10e-3f)
} else {
assertEquals(24, firstGlyphPath.pointsCount)
// TODO: this cross-platform differences look very suspicious and need to be addressed separately
assertCloseEnough(FontMetrics(
-11.64f,
-11.64f,
3.2400002f,
3.2400002f,
0f,
if (isWin()) 0f else 29.460001f,
29.460001f,
-20.880001f,
8.58f,
6.6000004f,
8.64f,
0.54f,
1.4399999f,
if (isWin()) 0.54f else null,
if (isWin()) -3.8999999f else null
), font.metrics, 10e-3f)
}
assertEquals(if (isLinux() || isJs()) 26 else 24, firstGlyphPath.pointsCount)
assertCloseEnough(FontMetrics(
top = -11.64f,
ascent = -11.64f,
descent = 3.2400002f,
bottom = 3.2400002f,
leading = 0f,
avgCharWidth = when {
isJs() -> 7.2f
isIos() || isMac() -> 29.460001f
isWindows() -> 0f
else -> 7.2f
},
maxCharWidth = 29.460001f,
xMin = -20.880001f,
xMax = 8.58f,
xHeight = 6.6000004f,
capHeight = 8.64f,
underlineThickness = 0.54f,
underlinePosition = 1.4399999f,
strikeoutThickness = 0.54f,
strikeoutPosition = -3.8999999f
), font.metrics, 10e-3f)
// assertEquals(Rect(1f, -12f, 21f, 0f), font.measureText("ЕЁЫ"))
......
......@@ -43,19 +43,6 @@ class ImageFilterTest {
)
}
@Test
fun alphaThreshold() = imageFilterTest {
ImageFilter.makeAlphaThreshold(
Region().apply {
setRect(IRect(5, 5, 10, 10))
},
innerMin = 0.9f,
outerMax = 0.2f,
input = null,
crop = null
)
}
@Test
fun arithmetic() = imageFilterTest {
ImageFilter.makeArithmetic(
......@@ -72,7 +59,7 @@ class ImageFilterTest {
ImageFilter.makeBlend(
blendMode = BlendMode.COLOR,
bg = ImageFilter.makeBlur(2f, 2f, mode = FilterTileMode.CLAMP),
fg = ImageFilter.makeAlphaThreshold(r = region, innerMin = 0.5f, outerMax = 0.5f, input = null, crop = null),
fg = ImageFilter.makeBlur(1f, 3f, mode = FilterTileMode.CLAMP),
crop = null
)
}
......@@ -156,7 +143,9 @@ class ImageFilterTest {
r = Rect(0f, 0f, 15f, 15f),
input = null,
crop = null,
inset = 2f
zoomAmount = 2f,
inset = 2f,
samplingMode = SamplingMode.LINEAR
)
}
......@@ -192,7 +181,9 @@ class ImageFilterTest {
r = Rect(0f, 0f, 15f, 15f),
input = null,
crop = null,
inset = 2f
zoomAmount = 2f,
inset = 2f,
samplingMode = SamplingMode.LINEAR
)
val filter2 = ImageFilter.makeColorFilter(
......
......@@ -209,9 +209,9 @@ class PathTests {
assertContentCloseEnough(
arrayOf(
Point(0f, 20f),
Point(3.0940108f, 16.905989f),
Point(8.452994f, 15.119661f),
Point(13.811978f, 13.333334f)
Point(3.0940108f, 16.90599f),
Point(8.4529950f, 15.119661f),
Point(13.811979f, 13.333334f)
),
Path.convertConicToQuads(Point(0f, 20f), Point(20f, 0f), Point(40f, 20f), 0.5f, 2)
)
......
......@@ -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_org_jetbrains_skia_ColorFilterKt__1nMakeComposed
......@@ -76,7 +75,7 @@ extern "C" JNIEXPORT jlong JNICALL Java_org_jetbrains_skia_ColorFilterKt__1nMake
extern "C" JNIEXPORT jlong JNICALL Java_org_jetbrains_skia_ColorFilterKt__1nMakeTable
(JNIEnv* env, jclass jclass, jbyteArray tableArray) {
jbyte* table = env->GetByteArrayElements(tableArray, 0);
SkColorFilter* ptr = SkTableColorFilter::Make(reinterpret_cast<uint8_t*>(table)).release();
SkColorFilter* ptr = SkColorFilters::Table(reinterpret_cast<uint8_t*>(table)).release();
env->ReleaseByteArrayElements(tableArray, table, 0);
return reinterpret_cast<jlong>(ptr);
}
......@@ -93,7 +92,7 @@ extern "C" JNIEXPORT jlong JNICALL Java_org_jetbrains_skia_ColorFilterKt__1nMake
jbyte* g = arrayG ? env->GetByteArrayElements(arrayG, 0) : nullptr;
jbyte* b = arrayB ? env->GetByteArrayElements(arrayB, 0) : nullptr;
SkColorFilter* ptr = SkTableColorFilter::MakeARGB(
SkColorFilter* ptr = SkColorFilters::TableARGB(
reinterpret_cast<uint8_t*>(a),
reinterpret_cast<uint8_t*>(r),
reinterpret_cast<uint8_t*>(g),
......
#include <iostream>
#include <jni.h>
#include "SkPicture.h"
#include "SkDrawable.h"
#include "interop.hh"
......@@ -68,7 +69,7 @@ extern "C" JNIEXPORT void JNICALL Java_org_jetbrains_skia_DrawableKt__1nDraw
extern "C" JNIEXPORT jlong JNICALL Java_org_jetbrains_skia_DrawableKt__1nMakePictureSnapshot
(JNIEnv* env, jclass jclass, jlong ptr) {
SkijaDrawableImpl* instance = reinterpret_cast<SkijaDrawableImpl*>(static_cast<uintptr_t>(ptr));
return reinterpret_cast<jlong>(instance->newPictureSnapshot());
return reinterpret_cast<jlong>(instance->makePictureSnapshot().release());
}
extern "C" JNIEXPORT jint JNICALL Java_org_jetbrains_skia_DrawableKt_Drawable_1nGetGenerationId
......
......@@ -22,7 +22,7 @@ extern "C" JNIEXPORT jlong JNICALL Java_org_jetbrains_skia_FontMgrKt__1nGetFamil
extern "C" JNIEXPORT jlong JNICALL Java_org_jetbrains_skia_FontMgrKt__1nMakeStyleSet
(JNIEnv* env, jclass jclass, jlong ptr, jint index) {
SkFontMgr* instance = reinterpret_cast<SkFontMgr*>(static_cast<uintptr_t>(ptr));
SkFontStyleSet* styleSet = instance->createStyleSet(index);
SkFontStyleSet* styleSet = instance->createStyleSet(index).release();
return reinterpret_cast<jlong>(styleSet);
}
......@@ -30,7 +30,7 @@ extern "C" JNIEXPORT jlong JNICALL Java_org_jetbrains_skia_FontMgrKt__1nMatchFam
(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());
SkFontStyleSet* styleSet = instance->matchFamily(familyName.c_str()).release();
return reinterpret_cast<jlong>(styleSet);
}
......@@ -38,7 +38,7 @@ extern "C" JNIEXPORT jlong JNICALL Java_org_jetbrains_skia_FontMgrKt__1nMatchFam
(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));
SkTypeface* typeface = instance->matchFamilyStyle(familyName.c_str(), skija::FontStyle::fromJava(fontStyle)).release();
return reinterpret_cast<jlong>(typeface);
}
......@@ -53,7 +53,7 @@ extern "C" JNIEXPORT jlong JNICALL Java_org_jetbrains_skia_FontMgrKt__1nMatchFam
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);
SkTypeface* typeface = instance->matchFamilyStyleCharacter(familyName.c_str(), skija::FontStyle::fromJava(fontStyle), bcp47.data(), (int) bcp47.size(), character).release();
return reinterpret_cast<jlong>(typeface);
}
......
......@@ -6,7 +6,7 @@
extern "C" JNIEXPORT jlong JNICALL Java_org_jetbrains_skia_FontStyleSetKt_FontStyleSet_1nMakeEmpty
(JNIEnv* env, jclass jclass) {
SkFontStyleSet* instance = SkFontStyleSet::CreateEmpty();
SkFontStyleSet* instance = SkFontStyleSet::CreateEmpty().release();
return reinterpret_cast<jlong>(instance);
}
......@@ -35,13 +35,13 @@ extern "C" JNIEXPORT jlong JNICALL Java_org_jetbrains_skia_FontStyleSetKt__1nGet
extern "C" JNIEXPORT jlong JNICALL Java_org_jetbrains_skia_FontStyleSetKt__1nGetTypeface
(JNIEnv* env, jclass jclass, jlong ptr, jint index) {
SkFontStyleSet* instance = reinterpret_cast<SkFontStyleSet*>(static_cast<uintptr_t>(ptr));
SkTypeface* typeface = instance->createTypeface(index);
SkTypeface* typeface = instance->createTypeface(index).release();
return reinterpret_cast<jlong>(typeface);
}
extern "C" JNIEXPORT jlong JNICALL Java_org_jetbrains_skia_FontStyleSetKt__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));
SkTypeface* typeface = instance->matchStyle(skija::FontStyle::fromJava(fontStyle)).release();
return reinterpret_cast<jlong>(typeface);
}
\ No newline at end of file
......@@ -3,6 +3,11 @@
#include "SkData.h"
#include "SkImage.h"
#include "SkBitmap.h"
#include "SkShader.h"
#include "SkEncodedImageFormat.h"
#include "encode/SkPngEncoder.h"
#include "encode/SkJpegEncoder.h"
#include "encode/SkWebpEncoder.h"
#include "interop.hh"
extern "C" JNIEXPORT jlong JNICALL Java_org_jetbrains_skia_ImageKt__1nMakeRaster
......@@ -14,7 +19,7 @@ extern "C" JNIEXPORT jlong JNICALL Java_org_jetbrains_skia_ImageKt__1nMakeRaster
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());
}
......@@ -28,21 +33,21 @@ extern "C" JNIEXPORT jlong JNICALL Java_org_jetbrains_skia_ImageKt__1nMakeRaster
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_org_jetbrains_skia_ImageKt__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_org_jetbrains_skia_ImageKt__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());
}
......@@ -52,7 +57,7 @@ extern "C" JNIEXPORT jlong JNICALL Java_org_jetbrains_skia_ImageKt__1nMakeFromEn
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());
}
......@@ -70,8 +75,35 @@ extern "C" JNIEXPORT void JNICALL Java_org_jetbrains_skia_ImageKt_Image_1nGetIma
extern "C" JNIEXPORT jlong JNICALL Java_org_jetbrains_skia_ImageKt__1nEncodeToData
(JNIEnv* env, jclass jclass, jlong ptr, jint format, jint quality) {
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);
SkEncodedImageFormat skFormat = static_cast<SkEncodedImageFormat>(format);
if (!instance->isTextureBacked()) {
switch (skFormat) {
case SkEncodedImageFormat::kPNG: {
SkPngEncoder::Options options = SkPngEncoder::Options();
options.fZLibLevel = std::max((int)(quality / 10), 9);
SkData* data = SkPngEncoder::Encode(nullptr, instance, options).release();
return reinterpret_cast<jlong>(data);
}
case SkEncodedImageFormat::kJPEG: {
SkJpegEncoder::Options options = SkJpegEncoder::Options();
options.fQuality = quality;
SkData* data = SkJpegEncoder::Encode(nullptr, instance, options).release();
return reinterpret_cast<jlong>(data);
}
case SkEncodedImageFormat::kWEBP: {
SkWebpEncoder::Options options = SkWebpEncoder::Options();
options.fQuality = quality;
SkData* data = SkWebpEncoder::Encode(nullptr, instance, options).release();
return reinterpret_cast<jlong>(data);
}
default:
env->ThrowNew(java::lang::RuntimeException::cls, "Only PNG, JPEG and WEBP formats are supported");
break;
}
} else {
env->ThrowNew(java::lang::RuntimeException::cls, "Textture backed images is not supported yet");
}
return 0;
}
extern "C" JNIEXPORT jlong JNICALL Java_org_jetbrains_skia_ImageKt_Image_1nMakeShader
......
#include <iostream>
#include <jni.h>
#include "SkSamplingOptions.h"
#include "interop.hh"
#include "SkColorFilter.h"
#include "SkImageFilter.h"
......@@ -8,15 +9,6 @@
#include "SkRect.h"
#include "interop.hh"
extern "C" JNIEXPORT jlong JNICALL Java_org_jetbrains_skia_ImageFilterKt__1nMakeAlphaThreshold
(JNIEnv* env, jclass jclass, jlong regionPtr, jfloat innerMin, jfloat outerMax, jlong inputPtr, jintArray cropInts) {
SkRegion* region = reinterpret_cast<SkRegion*>(static_cast<uintptr_t>(regionPtr));
SkImageFilter* input = reinterpret_cast<SkImageFilter*>(static_cast<uintptr_t>(inputPtr));
std::unique_ptr<SkIRect> crop = skija::IRect::toSkIRect(env, cropInts);
SkImageFilter* ptr = SkImageFilters::AlphaThreshold(*region, innerMin, outerMax, sk_ref_sp(input), crop.get()).release();
return reinterpret_cast<jlong>(ptr);
}
extern "C" JNIEXPORT jlong JNICALL Java_org_jetbrains_skia_ImageFilterKt__1nMakeArithmetic
(JNIEnv* env, jclass jclass, jfloat k1, jfloat k2, jfloat k3, jfloat k4, jboolean enforcePMColor, jlong bgPtr, jlong fgPtr, jintArray cropInts) {
SkImageFilter* bg = reinterpret_cast<SkImageFilter*>(static_cast<uintptr_t>(bgPtr));
......@@ -97,10 +89,11 @@ extern "C" JNIEXPORT jlong JNICALL Java_org_jetbrains_skia_ImageFilterKt__1nMake
}
extern "C" JNIEXPORT jlong JNICALL Java_org_jetbrains_skia_ImageFilterKt__1nMakeMagnifier
(JNIEnv* env, jclass jclass, jfloat l, jfloat t, jfloat r, jfloat b, jfloat inset, jlong inputPtr, jintArray cropInts) {
(JNIEnv* env, jclass jclass, jfloat l, jfloat t, jfloat r, jfloat b, jfloat zoomAmount, jfloat inset, jint samplingModeVal1, jint samplingModeVal2, jlong inputPtr, jintArray cropInts) {
SkImageFilter* input = reinterpret_cast<SkImageFilter*>(static_cast<uintptr_t>(inputPtr));
std::unique_ptr<SkIRect> crop = skija::IRect::toSkIRect(env, cropInts);
SkImageFilter* ptr = SkImageFilters::Magnifier(SkRect{l, t, r, b}, inset, sk_ref_sp(input), crop.get()).release();
SkSamplingOptions sampling = skija::SamplingMode::unpackFrom2Ints(env, samplingModeVal1, samplingModeVal2);
SkImageFilter* ptr = SkImageFilters::Magnifier(SkRect{l, t, r, b}, zoomAmount, inset, sampling, sk_ref_sp(input), crop.get()).release();
return reinterpret_cast<jlong>(ptr);
}
......
......@@ -6,6 +6,7 @@
#include "SkPaint.h"
#include "SkPathEffect.h"
#include "SkShader.h"
#include "SkBlendMode.h"
#include "interop.hh"
static void deletePaint(SkPaint* paint) {
......
......@@ -153,13 +153,13 @@ extern "C" JNIEXPORT jlong JNICALL Java_org_jetbrains_skia_ShaderKt__1nMakeBlend
extern "C" JNIEXPORT jlong JNICALL Java_org_jetbrains_skia_ShaderKt__1nMakeFractalNoise
(JNIEnv* env, jclass jclass, jfloat baseFrequencyX, jfloat baseFrequencyY, jint numOctaves, jfloat seed, jint tileW, jint tileH) {
const SkISize tileSize = SkISize::Make(tileW, tileH);
SkShader* ptr = SkPerlinNoiseShader::MakeFractalNoise(baseFrequencyX, baseFrequencyY, numOctaves, seed, &tileSize).release();
SkShader* ptr = SkShaders::MakeFractalNoise(baseFrequencyX, baseFrequencyY, numOctaves, seed, &tileSize).release();
return reinterpret_cast<jlong>(ptr);
}
extern "C" JNIEXPORT jlong JNICALL Java_org_jetbrains_skia_ShaderKt__1nMakeTurbulence
(JNIEnv* env, jclass jclass, jfloat baseFrequencyX, jfloat baseFrequencyY, jint numOctaves, jfloat seed, jint tileW, jint tileH) {
const SkISize tileSize = SkISize::Make(tileW, tileH);
SkShader* ptr = SkPerlinNoiseShader::MakeTurbulence(baseFrequencyX, baseFrequencyY, numOctaves, seed, &tileSize).release();
SkShader* ptr = SkShaders::MakeTurbulence(baseFrequencyX, baseFrequencyY, numOctaves, seed, &tileSize).release();
return reinterpret_cast<jlong>(ptr);
}
......@@ -4,6 +4,13 @@
#include "SkSurface.h"
#include "interop.hh"
#include "include/gpu/ganesh/SkSurfaceGanesh.h"
#ifdef SK_METAL
#include "include/gpu/ganesh/mtl/SkSurfaceMetal.h"
#include "include/gpu/mtl/GrMtlTypes.h"
#endif
extern "C" JNIEXPORT jlong JNICALL Java_org_jetbrains_skia_SurfaceKt__1nMakeRasterDirect
(JNIEnv* env, jclass jclass,
jint width, jint height, jint colorType, jint alphaType, jlong colorSpacePtr,
......@@ -18,7 +25,7 @@ extern "C" JNIEXPORT jlong JNICALL Java_org_jetbrains_skia_SurfaceKt__1nMakeRast
sk_ref_sp<SkColorSpace>(colorSpace));
std::unique_ptr<SkSurfaceProps> surfaceProps = skija::SurfaceProps::toSkSurfaceProps(env, surfacePropsInts);
sk_sp<SkSurface> instance = SkSurface::MakeRasterDirect(
sk_sp<SkSurface> instance = SkSurfaces::WrapPixels(
imageInfo,
reinterpret_cast<void*>(static_cast<uintptr_t>(pixelsPtr)),
rowBytes,
......@@ -33,7 +40,7 @@ extern "C" JNIEXPORT jlong JNICALL Java_org_jetbrains_skia_SurfaceKt__1nMakeRast
SkPixmap* pixmap = reinterpret_cast<SkPixmap*>(static_cast<uintptr_t>(pixmapPtr));
std::unique_ptr<SkSurfaceProps> surfaceProps = skija::SurfaceProps::toSkSurfaceProps(env, surfacePropsInts);
sk_sp<SkSurface> instance = SkSurface::MakeRasterDirect(*pixmap, surfaceProps.get());
sk_sp<SkSurface> instance = SkSurfaces::WrapPixels(*pixmap, surfaceProps.get());
return reinterpret_cast<jlong>(instance.release());
}
......@@ -51,7 +58,7 @@ extern "C" JNIEXPORT jlong JNICALL Java_org_jetbrains_skia_SurfaceKt__1nMakeRast
sk_ref_sp<SkColorSpace>(colorSpace));
std::unique_ptr<SkSurfaceProps> surfaceProps = skija::SurfaceProps::toSkSurfaceProps(env, surfacePropsInts);
sk_sp<SkSurface> instance = SkSurface::MakeRaster(
sk_sp<SkSurface> instance = SkSurfaces::Raster(
imageInfo,
rowBytes,
surfaceProps.get());
......@@ -60,10 +67,9 @@ extern "C" JNIEXPORT jlong JNICALL Java_org_jetbrains_skia_SurfaceKt__1nMakeRast
extern "C" JNIEXPORT jlong JNICALL Java_org_jetbrains_skia_SurfaceKt__1nMakeRasterN32Premul
(JNIEnv* env, jclass jclass, jint width, jint height) {
sk_sp<SkSurface> surface = SkSurface::MakeRasterN32Premul(
width, height,
/* const SkSurfaceProps* */ nullptr
);
// todo rename kotlin methods accordingly
SkImageInfo imageInfo = SkImageInfo::MakeN32Premul(width, height);
sk_sp<SkSurface> surface = SkSurfaces::Raster(imageInfo);
return reinterpret_cast<jlong>(surface.release());
}
......@@ -76,7 +82,7 @@ extern "C" JNIEXPORT jlong JNICALL Java_org_jetbrains_skia_SurfaceKt__1nMakeFrom
sk_sp<SkColorSpace> colorSpace = sk_ref_sp<SkColorSpace>(reinterpret_cast<SkColorSpace*>(static_cast<uintptr_t>(colorSpacePtr)));
std::unique_ptr<SkSurfaceProps> surfaceProps = skija::SurfaceProps::toSkSurfaceProps(env, surfacePropsInts);
sk_sp<SkSurface> surface = SkSurface::MakeFromBackendRenderTarget(
sk_sp<SkSurface> surface = SkSurfaces::WrapBackendRenderTarget(
static_cast<GrRecordingContext*>(context),
*backendRenderTarget,
grSurfaceOrigin,
......@@ -99,7 +105,7 @@ extern "C" JNIEXPORT jlong JNICALL Java_org_jetbrains_skia_SurfaceKt__1nMakeFrom
sk_sp<SkColorSpace> colorSpace = sk_ref_sp<SkColorSpace>(reinterpret_cast<SkColorSpace*>(static_cast<uintptr_t>(colorSpacePtr)));
std::unique_ptr<SkSurfaceProps> surfaceProps = skija::SurfaceProps::toSkSurfaceProps(env, surfacePropsInts);
sk_sp<SkSurface> surface = SkSurface::MakeFromMTKView(
sk_sp<SkSurface> surface = SkSurfaces::WrapMTKView(
static_cast<GrRecordingContext*>(context),
mtkView,
grSurfaceOrigin,
......@@ -127,8 +133,8 @@ extern "C" JNIEXPORT jlong JNICALL Java_org_jetbrains_skia_SurfaceKt__1nMakeRend
sk_ref_sp<SkColorSpace>(colorSpace));
std::unique_ptr<SkSurfaceProps> surfaceProps = skija::SurfaceProps::toSkSurfaceProps(env, surfacePropsInts);
sk_sp<SkSurface> instance = SkSurface::MakeRenderTarget(
context, budgeted ? SkBudgeted::kYes : SkBudgeted::kNo,
sk_sp<SkSurface> instance = SkSurfaces::RenderTarget(
context, budgeted ? skgpu::Budgeted::kYes : skgpu::Budgeted::kNo,
imageInfo,
sampleCount, static_cast<GrSurfaceOrigin>(surfaceOrigin),
surfaceProps.get(),
......@@ -138,7 +144,7 @@ extern "C" JNIEXPORT jlong JNICALL Java_org_jetbrains_skia_SurfaceKt__1nMakeRend
extern "C" JNIEXPORT jlong JNICALL Java_org_jetbrains_skia_SurfaceKt__1nMakeNull
(JNIEnv* env, jclass jclass, jint width, jint height) {
sk_sp<SkSurface> instance = SkSurface::MakeNull(width, height);
sk_sp<SkSurface> instance = SkSurfaces::Null(width, height);
return reinterpret_cast<jlong>(instance.release());
}
......
......@@ -5,10 +5,11 @@
#include <jni.h>
#include <memory>
#include "shaper/interop.hh"
#include "src/utils/SkUTF.h"
#include "src/base/SkUTF.h"
#include "paragraph/interop.hh"
#include "TextStyle.h"
#include "include/core/SkBlendMode.h"
#include "include/codec/SkCodecAnimation.h"
namespace java {
namespace io {
......
......@@ -4,7 +4,8 @@
#include "interop.hh"
#include "FontRunIterator.hh"
#include "SkShaper.h"
#include "src/utils/SkUTF.h"
#include "SkUnicode.h"
#include "src/base/SkUTF.h"
#include "TextLineRunHandler.hh"
#include "unicode/ubidi.h"
......@@ -37,7 +38,7 @@ extern "C" JNIEXPORT jlong JNICALL Java_org_jetbrains_skia_shaper_ShaperKt__1nMa
extern "C" JNIEXPORT jlong JNICALL Java_org_jetbrains_skia_shaper_ShaperKt__1nMakeShapeDontWrapOrReorder
(JNIEnv* env, jclass jclass, jlong fontMgrPtr) {
SkFontMgr* fontMgr = reinterpret_cast<SkFontMgr*>(static_cast<uintptr_t>(fontMgrPtr));
return reinterpret_cast<jlong>(SkShaper::MakeShapeDontWrapOrReorder(sk_ref_sp(fontMgr)).release());
return reinterpret_cast<jlong>(SkShaper::MakeShapeDontWrapOrReorder(SkUnicode::Make(), sk_ref_sp(fontMgr)).release());
}
extern "C" JNIEXPORT jlong JNICALL Java_org_jetbrains_skia_shaper_ShaperKt__1nMakeCoreText
......
......@@ -4,7 +4,6 @@
#include "SkHighContrastFilter.h"
#include "SkLumaColorFilter.h"
#include "SkOverdrawColorFilter.h"
#include "SkTableColorFilter.h"
#include "common.h"
SKIKO_EXPORT KNativePointer org_jetbrains_skia_ColorFilter__1nMakeComposed
......@@ -73,7 +72,7 @@ SKIKO_EXPORT KNativePointer org_jetbrains_skia_ColorFilter__1nMakeHighContrast
SKIKO_EXPORT KNativePointer org_jetbrains_skia_ColorFilter__1nMakeTable
(KByte* table) {
SkColorFilter* ptr = SkTableColorFilter::Make(reinterpret_cast<uint8_t*>(table)).release();
SkColorFilter* ptr = SkColorFilters::Table(reinterpret_cast<uint8_t*>(table)).release();
return reinterpret_cast<KNativePointer>(ptr);
}
......@@ -82,7 +81,7 @@ typedef void* KInteropPointer;
SKIKO_EXPORT KNativePointer org_jetbrains_skia_ColorFilter__1nMakeTableARGB
(KByte* a, KByte* r, KByte* g, KByte* b) {
SkColorFilter* ptr = SkTableColorFilter::MakeARGB(
SkColorFilter* ptr = SkColorFilters::TableARGB(
reinterpret_cast<uint8_t*>(a),
reinterpret_cast<uint8_t*>(r),
reinterpret_cast<uint8_t*>(g),
......
#include <iostream>
#include "SkPicture.h"
#include "SkDrawable.h"
#include "common.h"
......@@ -80,7 +81,7 @@ SKIKO_EXPORT void org_jetbrains_skia_Drawable__1nDraw
SKIKO_EXPORT KNativePointer org_jetbrains_skia_Drawable__1nMakePictureSnapshot
(KNativePointer ptr) {
SkikoDrawable* instance = reinterpret_cast<SkikoDrawable*>((ptr));
return reinterpret_cast<KNativePointer>(instance->newPictureSnapshot());
return reinterpret_cast<KNativePointer>(instance->makePictureSnapshot().release());
}
SKIKO_EXPORT KInt org_jetbrains_skia_Drawable__1nGetGenerationId
......
......@@ -22,7 +22,7 @@ SKIKO_EXPORT KInteropPointer org_jetbrains_skia_FontMgr__1nGetFamilyName
SKIKO_EXPORT KNativePointer org_jetbrains_skia_FontMgr__1nMakeStyleSet
(KNativePointer ptr, KInt index) {
SkFontMgr* instance = reinterpret_cast<SkFontMgr*>(ptr);
SkFontStyleSet* styleSet = instance->createStyleSet(index);
SkFontStyleSet* styleSet = instance->createStyleSet(index).release();
return reinterpret_cast<KNativePointer>(styleSet);
}
......@@ -31,7 +31,7 @@ SKIKO_EXPORT KNativePointer org_jetbrains_skia_FontMgr__1nMakeStyleSet
SKIKO_EXPORT KNativePointer org_jetbrains_skia_FontMgr__1nMatchFamily
(KNativePointer ptr, KInteropPointer familyNameStr) {
SkFontMgr* instance = reinterpret_cast<SkFontMgr*>(ptr);
SkFontStyleSet* styleSet = instance->matchFamily(reinterpret_cast<char *>(familyNameStr));
SkFontStyleSet* styleSet = instance->matchFamily(reinterpret_cast<char *>(familyNameStr)).release();
return reinterpret_cast<KNativePointer>(styleSet);
}
......@@ -39,7 +39,7 @@ SKIKO_EXPORT KNativePointer org_jetbrains_skia_FontMgr__1nMatchFamilyStyle
(KNativePointer ptr, KInteropPointer familyNameStr, KInt fontStyle) {
SkFontMgr* instance = reinterpret_cast<SkFontMgr*>(ptr);
SkString familyName = skString(familyNameStr);
SkTypeface* typeface = instance->matchFamilyStyle(familyName.c_str(), skija::FontStyle::fromKotlin(fontStyle));
SkTypeface* typeface = instance->matchFamilyStyle(familyName.c_str(), skija::FontStyle::fromKotlin(fontStyle)).release();
return reinterpret_cast<KNativePointer>(typeface);
}
......@@ -54,7 +54,7 @@ SKIKO_EXPORT KNativePointer org_jetbrains_skia_FontMgr__1nMatchFamilyStyleCharac
for (int i = 0; i < bcp47.size(); ++i)
bcp47[i] = bcp47Strings[i].c_str();
SkTypeface* typeface = instance->matchFamilyStyleCharacter(familyName.c_str(), skija::FontStyle::fromKotlin(fontStyle), bcp47.data(), (int) bcp47.size(), character);
SkTypeface* typeface = instance->matchFamilyStyleCharacter(familyName.c_str(), skija::FontStyle::fromKotlin(fontStyle), bcp47.data(), (int) bcp47.size(), character).release();
return reinterpret_cast<KNativePointer>(typeface);
}
......
......@@ -5,7 +5,7 @@
SKIKO_EXPORT KNativePointer org_jetbrains_skia_FontStyleSet__1nMakeEmpty
() {
SkFontStyleSet* instance = SkFontStyleSet::CreateEmpty();
SkFontStyleSet* instance = SkFontStyleSet::CreateEmpty().release();
return reinterpret_cast<KNativePointer>(instance);
}
......@@ -35,13 +35,13 @@ SKIKO_EXPORT KInteropPointer org_jetbrains_skia_FontStyleSet__1nGetStyleName
SKIKO_EXPORT KNativePointer org_jetbrains_skia_FontStyleSet__1nGetTypeface
(KNativePointer ptr, KInt index) {
SkFontStyleSet* instance = reinterpret_cast<SkFontStyleSet*>((ptr));
SkTypeface* typeface = instance->createTypeface(index);
SkTypeface* typeface = instance->createTypeface(index).release();
return reinterpret_cast<KNativePointer>(typeface);
}
SKIKO_EXPORT KNativePointer org_jetbrains_skia_FontStyleSet__1nMatchStyle
(KNativePointer ptr, KInt fontStyle) {
SkFontStyleSet* instance = reinterpret_cast<SkFontStyleSet*>((ptr));
SkTypeface* typeface = instance->matchStyle(skija::FontStyle::fromKotlin(fontStyle));
SkTypeface* typeface = instance->matchStyle(skija::FontStyle::fromKotlin(fontStyle)).release();
return reinterpret_cast<KNativePointer>(typeface);
}
......@@ -2,6 +2,11 @@
#include "SkData.h"
#include "SkImage.h"
#include "SkBitmap.h"
#include "SkShader.h"
#include "SkEncodedImageFormat.h"
#include "encode/SkPngEncoder.h"
#include "encode/SkJpegEncoder.h"
#include "encode/SkWebpEncoder.h"
#include "common.h"
......@@ -13,7 +18,7 @@ SKIKO_EXPORT KNativePointer org_jetbrains_skia_Image__1nMakeRaster
static_cast<SkColorType>(colorType),
static_cast<SkAlphaType>(alphaType),
sk_ref_sp<SkColorSpace>(colorSpace));
sk_sp<SkImage> image = SkImage::MakeRasterCopy(SkPixmap(imageInfo, bytesArr, rowBytes));
sk_sp<SkImage> image = SkImages::RasterFromPixmapCopy(SkPixmap(imageInfo, bytesArr, rowBytes));
return reinterpret_cast<KNativePointer>(image.release());
}
......@@ -27,21 +32,21 @@ SKIKO_EXPORT KNativePointer org_jetbrains_skia_Image__1nMakeRasterData
static_cast<SkAlphaType>(alphaType),
sk_ref_sp<SkColorSpace>(colorSpace));
SkData* data = reinterpret_cast<SkData*>((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<KNativePointer>(image.release());
}
SKIKO_EXPORT KNativePointer org_jetbrains_skia_Image__1nMakeFromBitmap
(KNativePointer bitmapPtr) {
SkBitmap* bitmap = reinterpret_cast<SkBitmap*>((bitmapPtr));
sk_sp<SkImage> image = SkImage::MakeFromBitmap(*bitmap);
sk_sp<SkImage> image = SkImages::RasterFromBitmap(*bitmap);
return reinterpret_cast<KNativePointer>(image.release());
}
SKIKO_EXPORT KNativePointer org_jetbrains_skia_Image__1nMakeFromPixmap
(KNativePointer pixmapPtr) {
SkPixmap* pixmap = reinterpret_cast<SkPixmap*>((pixmapPtr));
sk_sp<SkImage> image = SkImage::MakeFromRaster(*pixmap, nullptr, nullptr);
sk_sp<SkImage> image = SkImages::RasterFromPixmap(*pixmap, nullptr, nullptr);
return reinterpret_cast<KNativePointer>(image.release());
}
......@@ -49,7 +54,7 @@ SKIKO_EXPORT KNativePointer org_jetbrains_skia_Image__1nMakeFromPixmap
SKIKO_EXPORT KNativePointer org_jetbrains_skia_Image__1nMakeFromEncoded
(KByte* encodedArray, KInt encodedLen) {
sk_sp<SkData> encodedData = SkData::MakeWithCopy(encodedArray, encodedLen);
sk_sp<SkImage> image = SkImage::MakeFromEncoded(encodedData);
sk_sp<SkImage> image = SkImages::DeferredFromEncodedData(encodedData);
return reinterpret_cast<KNativePointer>(image.release());
}
......@@ -64,8 +69,32 @@ SKIKO_EXPORT void org_jetbrains_skia_Image__1nGetImageInfo
SKIKO_EXPORT KNativePointer org_jetbrains_skia_Image__1nEncodeToData
(KNativePointer ptr, KInt format, KInt quality) {
SkImage* instance = reinterpret_cast<SkImage*>((ptr));
SkData* data = instance->encodeToData(static_cast<SkEncodedImageFormat>(format), quality).release();
return reinterpret_cast<KNativePointer>(data);
SkEncodedImageFormat skFormat = static_cast<SkEncodedImageFormat>(format);
if (!instance->isTextureBacked()) {
switch (skFormat) {
case SkEncodedImageFormat::kPNG: {
SkPngEncoder::Options options = SkPngEncoder::Options();
options.fZLibLevel = std::max(quality / 10, 9);
SkData* data = SkPngEncoder::Encode(nullptr, instance, options).release();
return reinterpret_cast<KNativePointer>(data);
}
case SkEncodedImageFormat::kJPEG: {
SkJpegEncoder::Options options = SkJpegEncoder::Options();
options.fQuality = quality;
SkData* data = SkJpegEncoder::Encode(nullptr, instance, options).release();
return reinterpret_cast<KNativePointer>(data);
}
case SkEncodedImageFormat::kWEBP: {
SkWebpEncoder::Options options = SkWebpEncoder::Options();
options.fQuality = quality;
SkData* data = SkWebpEncoder::Encode(nullptr, instance, options).release();
return reinterpret_cast<KNativePointer>(data);
}
default:
break;
}
}
return reinterpret_cast<KNativePointer>(0);
}
......
......@@ -6,16 +6,6 @@
#include "SkRect.h"
#include "common.h"
SKIKO_EXPORT KNativePointer org_jetbrains_skia_ImageFilter__1nMakeAlphaThreshold
(KNativePointer regionPtr, KFloat innerMin, KFloat outerMax, KNativePointer inputPtr, KInt* cropInts) {
SkRegion* region = reinterpret_cast<SkRegion*>((regionPtr));
SkImageFilter* input = reinterpret_cast<SkImageFilter*>((inputPtr));
std::unique_ptr<SkIRect> crop = skija::IRect::toSkIRect(cropInts);
SkImageFilter* ptr = SkImageFilters::AlphaThreshold(*region, innerMin, outerMax, sk_ref_sp(input), crop.get()).release();
return reinterpret_cast<KNativePointer>(ptr);
}
SKIKO_EXPORT KNativePointer org_jetbrains_skia_ImageFilter__1nMakeArithmetic
(KFloat k1, KFloat k2, KFloat k3, KFloat k4, KBoolean enforcePMColor, KNativePointer bgPtr, KNativePointer fgPtr, KInt* cropInts) {
SkImageFilter* bg = reinterpret_cast<SkImageFilter*>((bgPtr));
......@@ -97,10 +87,11 @@ SKIKO_EXPORT KNativePointer org_jetbrains_skia_ImageFilter__1nMakeImage
}
SKIKO_EXPORT KNativePointer org_jetbrains_skia_ImageFilter__1nMakeMagnifier
(KFloat l, KFloat t, KFloat r, KFloat b, KFloat inset, KNativePointer inputPtr, KInt* cropRectInts) {
(KFloat l, KFloat t, KFloat r, KFloat b, KFloat zoomAmount, KFloat inset, KInt samplingModeVal1, KInt samplingModeVal2, KNativePointer inputPtr, KInt* cropRectInts) {
SkImageFilter* input = reinterpret_cast<SkImageFilter*>((inputPtr));
std::unique_ptr<SkIRect> crop = skija::IRect::toSkIRect(cropRectInts);
SkImageFilter* ptr = SkImageFilters::Magnifier(SkRect{l, t, r, b}, inset, sk_ref_sp(input), crop.get()).release();
SkSamplingOptions sampling = skija::SamplingMode::unpackFrom2Ints(samplingModeVal1, samplingModeVal2);
SkImageFilter* ptr = SkImageFilters::Magnifier(SkRect{l, t, r, b}, zoomAmount, inset, sampling, sk_ref_sp(input), crop.get()).release();
return reinterpret_cast<KNativePointer>(ptr);
}
......
......@@ -5,6 +5,7 @@
#include "SkPaint.h"
#include "SkPathEffect.h"
#include "SkShader.h"
#include "SkBlendMode.h"
#include "common.h"
void deletePaint(SkPaint* paint) {
......
......@@ -135,13 +135,13 @@ SKIKO_EXPORT KNativePointer org_jetbrains_skia_Shader__1nMakeBlend(KInt blendMod
SKIKO_EXPORT KNativePointer org_jetbrains_skia_Shader__1nMakeFractalNoise
(KFloat baseFrequencyX, KFloat baseFrequencyY, KInt numOctaves, KFloat seed, KInt tileW, KInt tileH) {
const SkISize tileSize = SkISize::Make(tileW, tileH);
SkShader* ptr = SkPerlinNoiseShader::MakeFractalNoise(baseFrequencyX, baseFrequencyY, numOctaves, seed, &tileSize).release();
SkShader* ptr = SkShaders::MakeFractalNoise(baseFrequencyX, baseFrequencyY, numOctaves, seed, &tileSize).release();
return reinterpret_cast<KNativePointer>(ptr);
}
SKIKO_EXPORT KNativePointer org_jetbrains_skia_Shader__1nMakeTurbulence
(KFloat baseFrequencyX, KFloat baseFrequencyY, KInt numOctaves, KFloat seed, KInt tileW, KInt tileH) {
const SkISize tileSize = SkISize::Make(tileW, tileH);
SkShader* ptr = SkPerlinNoiseShader::MakeTurbulence(baseFrequencyX, baseFrequencyY, numOctaves, seed, &tileSize).release();
SkShader* ptr = SkShaders::MakeTurbulence(baseFrequencyX, baseFrequencyY, numOctaves, seed, &tileSize).release();
return reinterpret_cast<KNativePointer>(ptr);
}
#include <iostream>
#include "GrDirectContext.h"
#include "SkSurface.h"
#include "include/gpu/ganesh/SkSurfaceGanesh.h"
#include "common.h"
#ifdef SK_METAL
#include "include/gpu/ganesh/mtl/SkSurfaceMetal.h"
#include "include/gpu/mtl/GrMtlTypes.h"
#endif
......@@ -21,7 +23,7 @@ SKIKO_EXPORT KNativePointer org_jetbrains_skia_Surface__1nMakeRasterDirect
sk_ref_sp<SkColorSpace>(colorSpace));
std::unique_ptr<SkSurfaceProps> surfaceProps = skija::SurfaceProps::toSkSurfaceProps(surfacePropsInts);
sk_sp<SkSurface> instance = SkSurface::MakeRasterDirect(
sk_sp<SkSurface> instance = SkSurfaces::WrapPixels(
imageInfo,
reinterpret_cast<void*>(pixelsPtr),
rowBytes,
......@@ -37,7 +39,7 @@ SKIKO_EXPORT KNativePointer org_jetbrains_skia_Surface__1nMakeRasterDirectWithPi
SkPixmap* pixmap = reinterpret_cast<SkPixmap*>(pixmapPtr);
std::unique_ptr<SkSurfaceProps> surfaceProps = skija::SurfaceProps::toSkSurfaceProps(surfacePropsInts);
sk_sp<SkSurface> instance = SkSurface::MakeRasterDirect(*pixmap, surfaceProps.get());
sk_sp<SkSurface> instance = SkSurfaces::WrapPixels(*pixmap, surfaceProps.get());
return reinterpret_cast<KNativePointer>(instance.release());
}
......@@ -56,7 +58,7 @@ SKIKO_EXPORT KNativePointer org_jetbrains_skia_Surface__1nMakeRaster
sk_ref_sp<SkColorSpace>(colorSpace));
std::unique_ptr<SkSurfaceProps> surfaceProps = skija::SurfaceProps::toSkSurfaceProps(surfacePropsInts);
sk_sp<SkSurface> instance = SkSurface::MakeRaster(
sk_sp<SkSurface> instance = SkSurfaces::Raster(
imageInfo,
rowBytes,
surfaceProps.get());
......@@ -66,10 +68,8 @@ SKIKO_EXPORT KNativePointer org_jetbrains_skia_Surface__1nMakeRaster
SKIKO_EXPORT KNativePointer org_jetbrains_skia_Surface__1nMakeRasterN32Premul
(KInt width, KInt height) {
sk_sp<SkSurface> surface = SkSurface::MakeRasterN32Premul(
width, height,
/* const SkSurfaceProps* */ nullptr
);
SkImageInfo imageInfo = SkImageInfo::MakeN32Premul(width, height);
sk_sp<SkSurface> surface = SkSurfaces::Raster(imageInfo);
return reinterpret_cast<KNativePointer>(surface.release());
}
......@@ -84,7 +84,7 @@ SKIKO_EXPORT KNativePointer org_jetbrains_skia_Surface__1nMakeFromBackendRenderT
std::unique_ptr<SkSurfaceProps> surfaceProps = skija::SurfaceProps::toSkSurfaceProps(surfacePropsInts);
sk_sp<SkSurface> surface = SkSurface::MakeFromBackendRenderTarget(
sk_sp<SkSurface> surface = SkSurfaces::WrapBackendRenderTarget(
static_cast<GrRecordingContext*>(context),
*backendRenderTarget,
grSurfaceOrigin,
......@@ -107,7 +107,7 @@ SKIKO_EXPORT KNativePointer org_jetbrains_skia_Surface__1nMakeFromMTKView
sk_sp<SkColorSpace> colorSpace = sk_ref_sp<SkColorSpace>(reinterpret_cast<SkColorSpace*>((colorSpacePtr)));
std::unique_ptr<SkSurfaceProps> surfaceProps = skija::SurfaceProps::toSkSurfaceProps(surfacePropsInts);
sk_sp<SkSurface> surface = SkSurface::MakeFromMTKView(
sk_sp<SkSurface> surface = SkSurfaces::WrapMTKView(
static_cast<GrRecordingContext*>(context),
mtkView,
grSurfaceOrigin,
......@@ -137,8 +137,8 @@ SKIKO_EXPORT KNativePointer org_jetbrains_skia_Surface__1nMakeRenderTarget
sk_ref_sp<SkColorSpace>(colorSpace));
std::unique_ptr<SkSurfaceProps> surfaceProps = skija::SurfaceProps::toSkSurfaceProps(surfacePropsInts);
sk_sp<SkSurface> instance = SkSurface::MakeRenderTarget(
context, budgeted ? SkBudgeted::kYes : SkBudgeted::kNo,
sk_sp<SkSurface> instance = SkSurfaces::RenderTarget(
context, budgeted ? skgpu::Budgeted::kYes : skgpu::Budgeted::kNo,
imageInfo,
sampleCount, static_cast<GrSurfaceOrigin>(surfaceOrigin),
surfaceProps.get(),
......@@ -148,7 +148,7 @@ SKIKO_EXPORT KNativePointer org_jetbrains_skia_Surface__1nMakeRenderTarget
SKIKO_EXPORT KNativePointer org_jetbrains_skia_Surface__1nMakeNull
(KInt width, KInt height) {
sk_sp<SkSurface> instance = SkSurface::MakeNull(width, height);
sk_sp<SkSurface> instance = SkSurfaces::Null(width, height);
return reinterpret_cast<KNativePointer>(instance.release());
}
......
#include "common.h"
#include "src/utils/SkUTF.h"
#include "src/base/SkUTF.h"
#include "include/core/SkImageInfo.h"
#include "TextStyle.h"
#include <stdio.h>
......
#include <iostream>
#include "SkShaper.h"
#include "src/utils/SkUTF.h"
#include "SkUnicode.h"
#include "src/base/SkUTF.h"
#include "unicode/ubidi.h"
#include "common.h"
#include "FontRunIterator.hh"
#include "src/utils/SkUTF.h"
#include "TextLineRunHandler.hh"
static void deleteShaper(SkShaper* instance) {
......@@ -36,7 +36,7 @@ SKIKO_EXPORT KNativePointer org_jetbrains_skia_shaper_Shaper__1nMakeShapeThenWra
SKIKO_EXPORT KNativePointer org_jetbrains_skia_shaper_Shaper__1nMakeShapeDontWrapOrReorder
(KNativePointer fontMgrPtr) {
SkFontMgr* fontMgr = reinterpret_cast<SkFontMgr*>((fontMgrPtr));
return reinterpret_cast<KNativePointer>(SkShaper::MakeShapeDontWrapOrReorder(sk_ref_sp(fontMgr)).release());
return reinterpret_cast<KNativePointer>(SkShaper::MakeShapeDontWrapOrReorder(SkUnicode::Make(), sk_ref_sp(fontMgr)).release());
}
SKIKO_EXPORT KNativePointer org_jetbrains_skia_shaper_Shaper__1nMakeCoreText() {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment