Skip to content

Commit

Permalink
PR review fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
eymar committed Aug 7, 2024
1 parent 4ec6bf8 commit 9102e5b
Show file tree
Hide file tree
Showing 12 changed files with 45 additions and 41 deletions.
12 changes: 6 additions & 6 deletions skiko/src/awtMain/objectiveC/macos/MetalApi.mm
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@
#import <Metal/Metal.h>
#import <QuartzCore/CAMetalLayer.h>

#import <GrBackendSurface.h>
#import <GrDirectContext.h>
#include "ganesh/mtl/GrMtlBackendContext.h"
#include "ganesh/mtl/GrMtlDirectContext.h"
#include "ganesh/mtl/GrMtlBackendSurface.h"
#include "ganesh/mtl/GrMtlTypes.h"
#import "GrBackendSurface.h"
#import "GrDirectContext.h"
#import "ganesh/mtl/GrMtlBackendContext.h"
#import "ganesh/mtl/GrMtlDirectContext.h"
#import "ganesh/mtl/GrMtlBackendSurface.h"
#import "ganesh/mtl/GrMtlTypes.h"

#import "MetalDevice.h"

Expand Down
12 changes: 6 additions & 6 deletions skiko/src/awtMain/objectiveC/macos/MetalContextHandler.mm
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@

#import <QuartzCore/CAMetalLayer.h>
#import <Metal/Metal.h>
#import <GrDirectContext.h>
#import <gpu/GrBackendSurface.h>
#include "ganesh/mtl/GrMtlBackendContext.h"
#include "ganesh/mtl/GrMtlDirectContext.h"
#include "ganesh/mtl/GrMtlBackendSurface.h"
#include "ganesh/mtl/GrMtlTypes.h"
#import "GrDirectContext.h"
#import "gpu/GrBackendSurface.h"
#import "ganesh/mtl/GrMtlBackendContext.h"
#import "ganesh/mtl/GrMtlDirectContext.h"
#import "ganesh/mtl/GrMtlBackendSurface.h"
#import "ganesh/mtl/GrMtlTypes.h"

#import "MetalDevice.h"

Expand Down
10 changes: 5 additions & 5 deletions skiko/src/awtMain/objectiveC/macos/MetalRedrawer.mm
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@
#import <Metal/Metal.h>
#import <QuartzCore/CAMetalLayer.h>

#import <GrBackendSurface.h>
#import <GrDirectContext.h>
#include "ganesh/mtl/GrMtlBackendContext.h"
#include "ganesh/mtl/GrMtlDirectContext.h"
#include "ganesh/mtl/GrMtlTypes.h"
#import "GrBackendSurface.h"
#import "GrDirectContext.h"
#import "ganesh/mtl/GrMtlBackendContext.h"
#import "ganesh/mtl/GrMtlDirectContext.h"
#import "ganesh/mtl/GrMtlTypes.h"

#import "MetalDevice.h"

Expand Down
12 changes: 6 additions & 6 deletions skiko/src/awtMain/objectiveC/macos/MetalSwingRedrawer.mm
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@

#import <QuartzCore/CAMetalLayer.h>
#import <Metal/Metal.h>
#import <GrDirectContext.h>
#import <gpu/GrBackendSurface.h>
#include "ganesh/mtl/GrMtlBackendContext.h"
#include "ganesh/mtl/GrMtlDirectContext.h"
#include "ganesh/mtl/GrMtlBackendSurface.h"
#include "ganesh/mtl/GrMtlTypes.h"
#import "GrDirectContext.h"
#import "gpu/GrBackendSurface.h"
#import "ganesh/mtl/GrMtlBackendContext.h"
#import "ganesh/mtl/GrMtlDirectContext.h"
#import "ganesh/mtl/GrMtlBackendSurface.h"
#import "ganesh/mtl/GrMtlTypes.h"

#import "MetalDevice.h"

Expand Down
4 changes: 2 additions & 2 deletions skiko/src/jvmMain/cpp/common/BackendRenderTarget.cc
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ extern "C" JNIEXPORT jlong JNICALL Java_org_jetbrains_skia_BackendRenderTargetKt
extern "C" JNIEXPORT jlong JNICALL Java_org_jetbrains_skia_BackendRenderTargetKt__1nMakeGL
(JNIEnv* env, jclass jclass, jint width, jint height, jint sampleCnt, jint stencilBits, jint fbId, jint fbFormat) {
GrGLFramebufferInfo glInfo = { static_cast<unsigned int>(fbId), static_cast<unsigned int>(fbFormat) };
auto obj = GrBackendRenderTargets::MakeGL(width, height, sampleCnt, stencilBits, glInfo);
GrBackendRenderTarget obj = GrBackendRenderTargets::MakeGL(width, height, sampleCnt, stencilBits, glInfo);
GrBackendRenderTarget* instance = new GrBackendRenderTarget(obj);
return reinterpret_cast<jlong>(instance);
}
Expand All @@ -32,7 +32,7 @@ extern "C" JNIEXPORT jlong JNICALL Java_org_jetbrains_skia_BackendRenderTargetKt
GrMtlTextureInfo fbInfo;
fbInfo.fTexture.retain(texture);
GrBackendRenderTarget obj = GrBackendRenderTargets::MakeMtl(width, height, fbInfo);
auto instance = new GrBackendRenderTarget(obj);
GrBackendRenderTarget* instance = new GrBackendRenderTarget(obj);
return reinterpret_cast<jlong>(instance);
}
#endif
Expand Down
2 changes: 1 addition & 1 deletion skiko/src/jvmMain/cpp/common/Typeface.cc
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,6 @@ extern "C" JNIEXPORT void JNICALL Java_org_jetbrains_skia_TypefaceKt_Typeface_1n
extern "C" JNIEXPORT jlong JNICALL Java_org_jetbrains_skia_TypefaceKt__1nMakeEmptyTypeface
(JNIEnv* env, jclass jclass) {

auto res = SkTypeface::MakeEmpty().release();
SkTypeface* res = SkTypeface::MakeEmpty().release();
return reinterpret_cast<jlong>(res);
}
4 changes: 2 additions & 2 deletions skiko/src/jvmMain/cpp/common/render.cc
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ JNIEXPORT jlong JNICALL Java_org_jetbrains_skiko_RenderTargetsKt_makeGLRenderTar
jint fbId, jint fbFormat
) {
GrGLFramebufferInfo glInfo = { static_cast<unsigned int>(fbId), static_cast<unsigned int>(fbFormat) };
auto obj = GrBackendRenderTargets::MakeGL(width, height, sampleCnt, stencilBits, glInfo);
GrBackendRenderTarget obj = GrBackendRenderTargets::MakeGL(width, height, sampleCnt, stencilBits, glInfo);
GrBackendRenderTarget* target = new GrBackendRenderTarget(obj);
return reinterpret_cast<jlong>(target);
}
Expand All @@ -42,7 +42,7 @@ JNIEXPORT jlong JNICALL Java_org_jetbrains_skiko_RenderTargetsKt_makeMetalRender
// TODO: create properly.
GrMtlTextureInfo mtlInfo;
GrBackendRenderTarget obj = GrBackendRenderTargets::MakeMtl(width, height, mtlInfo);
auto instance = new GrBackendRenderTarget(obj);
GrBackendRenderTarget* instance = new GrBackendRenderTarget(obj);
return reinterpret_cast<jlong>(instance);
#else
return 0;
Expand Down
10 changes: 6 additions & 4 deletions skiko/src/jvmMain/cpp/common/shaper/Shaper.cc
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@
#include "unicode/ubidi.h"
#include "SkUnicode_icu.h"

#ifdef SK_SHAPER_CORETEXT_AVAILABLE
#include "SkShaper_coretext.h"
#endif

static void deleteShaper(SkShaper* instance) {
// std::cout << "Deleting [SkShaper " << instance << "]" << std::endl;
delete instance;
Expand Down Expand Up @@ -42,16 +46,14 @@ extern "C" JNIEXPORT jlong JNICALL Java_org_jetbrains_skia_shaper_ShaperKt__1nMa
(JNIEnv* env, jclass jclass, jlong fontMgrPtr) {
SkFontMgr* fontMgr = reinterpret_cast<SkFontMgr*>(static_cast<uintptr_t>(fontMgrPtr));
// TODO: consider if we need/want to use ICU4X or Libgrapheme (skuincode/include has those implementations too)
auto unicode = SkUnicodes::ICU::Make();
sk_sp<SkUnicode> unicode = SkUnicodes::ICU::Make();
return reinterpret_cast<jlong>(SkShapers::HB::ShapeDontWrapOrReorder(unicode, sk_ref_sp(fontMgr)).release());
}

extern "C" JNIEXPORT jlong JNICALL Java_org_jetbrains_skia_shaper_ShaperKt__1nMakeCoreText
(JNIEnv* env, jclass jclass) {
#ifdef SK_SHAPER_CORETEXT_AVAILABLE
return 0;
// TODO: build skia with `skia_use_fonthost_mac=true` to have SkShaper::MakeCoreText
// return reinterpret_cast<jlong>(SkShaper::MakeCoreText().release());
return reinterpret_cast<jlong>(SkShapers::CT::CoreText().release());
#else
return 0;
#endif
Expand Down
4 changes: 2 additions & 2 deletions skiko/src/nativeJsMain/cpp/BackendRenderTarget.cc
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ SKIKO_EXPORT KNativePointer org_jetbrains_skia_BackendRenderTarget__1nGetFinaliz
SKIKO_EXPORT KNativePointer org_jetbrains_skia_BackendRenderTarget__1nMakeGL
(KInt width, KInt height, KInt sampleCnt, KInt stencilBits, KInt fbId, KInt fbFormat) {
GrGLFramebufferInfo glInfo = { static_cast<unsigned int>(fbId), static_cast<unsigned int>(fbFormat) };
auto obj = GrBackendRenderTargets::MakeGL(width, height, sampleCnt, stencilBits, glInfo);
GrBackendRenderTarget obj = GrBackendRenderTargets::MakeGL(width, height, sampleCnt, stencilBits, glInfo);
GrBackendRenderTarget* instance = new GrBackendRenderTarget(obj);
return instance;
}
Expand All @@ -31,7 +31,7 @@ SKIKO_EXPORT KNativePointer BackendRenderTarget_nMakeMetal
GrMtlTextureInfo fbInfo;
fbInfo.fTexture.retain(texture);
GrBackendRenderTarget obj = GrBackendRenderTargets::MakeMtl(width, height, fbInfo);
auto instance = new GrBackendRenderTarget(obj);
GrBackendRenderTarget* instance = new GrBackendRenderTarget(obj);
return instance;
#else
return 0;
Expand Down
2 changes: 1 addition & 1 deletion skiko/src/nativeJsMain/cpp/Typeface.cc
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,6 @@ SKIKO_EXPORT void org_jetbrains_skia_Typeface__1nGetBounds
SKIKO_EXPORT KInteropPointer org_jetbrains_skia_Typeface__1nMakeEmptyTypeface
() {

auto res = SkTypeface::MakeEmpty().release();
SkTypeface* res = SkTypeface::MakeEmpty().release();
return reinterpret_cast<KInteropPointer>(res);
}
4 changes: 2 additions & 2 deletions skiko/src/nativeJsMain/cpp/render.cc
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
SKIKO_EXPORT KNativePointer org_jetbrains_skiko_RenderTargetsKt_makeGLRenderTargetNative
(KInt width, KInt height, KInt sampleCnt, KInt stencilBits, KInt fbId, KInt fbFormat) {
GrGLFramebufferInfo glInfo = { static_cast<unsigned int>(fbId), static_cast<unsigned int>(fbFormat) };
auto obj = GrBackendRenderTargets::MakeGL(width, height, sampleCnt, stencilBits, glInfo);
GrBackendRenderTarget obj = GrBackendRenderTargets::MakeGL(width, height, sampleCnt, stencilBits, glInfo);
GrBackendRenderTarget* target = new GrBackendRenderTarget(obj);
return reinterpret_cast<KNativePointer>(target);
}
Expand All @@ -27,7 +27,7 @@ SKIKO_EXPORT KNativePointer org_jetbrains_skiko_RenderTargetsKt_makeMetalRenderT
// TODO: create properly.
GrMtlTextureInfo mtlInfo;
GrBackendRenderTarget obj = GrBackendRenderTargets::MakeMtl(width, height, mtlInfo);
auto instance = new GrBackendRenderTarget(obj);
GrBackendRenderTarget* instance = new GrBackendRenderTarget(obj);
return reinterpret_cast<KNativePointer>(instance);
#else
return 0;
Expand Down
10 changes: 6 additions & 4 deletions skiko/src/nativeJsMain/cpp/shaper/Shaper.cc
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@
#include "FontMgrDefaultFactory.hh"
#include "SkUnicode_icu.h"

#ifdef SK_SHAPER_CORETEXT_AVAILABLE
#include "SkShaper_coretext.h"
#endif

static void deleteShaper(SkShaper* instance) {
// std::cout << "Deleting [SkShaper " << instance << "]" << std::endl;
delete instance;
Expand Down Expand Up @@ -40,15 +44,13 @@ SKIKO_EXPORT KNativePointer org_jetbrains_skia_shaper_Shaper__1nMakeShapeDontWra
(KNativePointer fontMgrPtr) {
SkFontMgr* fontMgr = reinterpret_cast<SkFontMgr*>((fontMgrPtr));
// TODO: consider if we need/want to use ICU4X or Libgrapheme (skuincode/include has those implementations too)
auto unicode = SkUnicodes::ICU::Make();
sk_sp<SkUnicode> unicode = SkUnicodes::ICU::Make();
return reinterpret_cast<KNativePointer>(SkShapers::HB::ShapeDontWrapOrReorder(unicode, sk_ref_sp(fontMgr)).release());
}

SKIKO_EXPORT KNativePointer org_jetbrains_skia_shaper_Shaper__1nMakeCoreText() {
#ifdef SK_SHAPER_CORETEXT_AVAILABLE
return nullptr;
// TODO: build skia with `skia_use_fonthost_mac=true` to have SkShaper::MakeCoreText
// return reinterpret_cast<KNativePointer>(SkShaper::MakeCoreText().release());
return reinterpret_cast<KNativePointer>(SkShapers::CT::CoreText().release());
#else
return nullptr;
#endif
Expand Down

0 comments on commit 9102e5b

Please sign in to comment.