-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added skresources module and ResourceProviders (closes #129)
- Loading branch information
Showing
18 changed files
with
196 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
#include <jni.h> | ||
#include "../interop.hh" | ||
#include "SkResources.h" | ||
|
||
extern "C" JNIEXPORT jlong JNICALL Java_org_jetbrains_skija_resources_CachingResourceProvider__1nMake | ||
(JNIEnv* env, jclass jclass, jlong resourceProviderPtr) { | ||
skresources::ResourceProvider* resourceProvider = reinterpret_cast<skresources::ResourceProvider*>(static_cast<uintptr_t>(resourceProviderPtr)); | ||
auto instance = skresources::CachingResourceProvider::Make(sk_ref_sp(resourceProvider)); | ||
return ptrToJlong(instance.release()); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
#include <jni.h> | ||
#include "../interop.hh" | ||
#include "SkResources.h" | ||
|
||
extern "C" JNIEXPORT jlong JNICALL Java_org_jetbrains_skija_resources_DataURIResourceProviderProxy__1nMake | ||
(JNIEnv* env, jclass jclass, jlong resourceProviderPtr, jboolean predecode) { | ||
skresources::ResourceProvider* resourceProvider = reinterpret_cast<skresources::ResourceProvider*>(static_cast<uintptr_t>(resourceProviderPtr)); | ||
auto instance = skresources::DataURIResourceProviderProxy::Make(sk_ref_sp(resourceProvider), predecode); | ||
return ptrToJlong(instance.release()); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
#include <jni.h> | ||
#include "../interop.hh" | ||
#include "SkResources.h" | ||
|
||
extern "C" JNIEXPORT jlong JNICALL Java_org_jetbrains_skija_resources_FileResourceProvider__1nMake | ||
(JNIEnv* env, jclass jclass, jstring basePathStr, jboolean predecode) { | ||
SkString basePath = skString(env, basePathStr); | ||
auto instance = skresources::FileResourceProvider::Make(basePath, predecode); | ||
return ptrToJlong(instance.release()); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package org.jetbrains.skija.resources; | ||
|
||
import java.lang.ref.*; | ||
import org.jetbrains.annotations.*; | ||
import org.jetbrains.skija.*; | ||
import org.jetbrains.skija.impl.*; | ||
|
||
public class CachingResourceProvider extends ResourceProvider { | ||
static { Library.staticLoad(); } | ||
|
||
@ApiStatus.Internal | ||
public CachingResourceProvider(long ptr) { | ||
super(ptr); | ||
} | ||
|
||
@NotNull @Contract("_ -> new") | ||
public static CachingResourceProvider make(@NotNull ResourceProvider resourceProvider) { | ||
assert resourceProvider != null : "Can’t CachingResourceProvider::make with resourceProvider == null"; | ||
Stats.onNativeCall(); | ||
return new CachingResourceProvider(_nMake(Native.getPtr(resourceProvider))); | ||
} | ||
|
||
@ApiStatus.Internal public static native long _nMake(long resourceProviderPtr); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package org.jetbrains.skija.resources; | ||
|
||
import java.lang.ref.*; | ||
import org.jetbrains.annotations.*; | ||
import org.jetbrains.skija.*; | ||
import org.jetbrains.skija.impl.*; | ||
|
||
public class DataURIResourceProviderProxy extends ResourceProvider { | ||
static { Library.staticLoad(); } | ||
|
||
@ApiStatus.Internal | ||
public DataURIResourceProviderProxy(long ptr) { | ||
super(ptr); | ||
} | ||
|
||
@NotNull @Contract("_ -> new") | ||
public static DataURIResourceProviderProxy make(@NotNull ResourceProvider resourceProvider) { | ||
return make(resourceProvider, false); | ||
} | ||
|
||
@NotNull @Contract("_, _ -> new") | ||
public static DataURIResourceProviderProxy make(@NotNull ResourceProvider resourceProvider, boolean predecode) { | ||
assert resourceProvider != null : "Can’t DataURIResourceProviderProxy::make with resourceProvider == null"; | ||
Stats.onNativeCall(); | ||
return new DataURIResourceProviderProxy(_nMake(Native.getPtr(resourceProvider), predecode)); | ||
} | ||
|
||
@ApiStatus.Internal public static native long _nMake(long resourceProviderPtr, boolean predecode); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package org.jetbrains.skija.resources; | ||
|
||
import java.lang.ref.*; | ||
import org.jetbrains.annotations.*; | ||
import org.jetbrains.skija.*; | ||
import org.jetbrains.skija.impl.*; | ||
|
||
public class FileResourceProvider extends ResourceProvider { | ||
static { Library.staticLoad(); } | ||
|
||
@ApiStatus.Internal | ||
public FileResourceProvider(long ptr) { | ||
super(ptr); | ||
} | ||
|
||
@NotNull @Contract("_ -> new") | ||
public static FileResourceProvider make(@NotNull String baseDir) { | ||
return make(baseDir, false); | ||
} | ||
|
||
@NotNull @Contract("_, _ -> new") | ||
public static FileResourceProvider make(@NotNull String baseDir, boolean predecode) { | ||
assert baseDir != null : "Can’t FileResourceProvider::make with baseDir == null"; | ||
Stats.onNativeCall(); | ||
return new FileResourceProvider(_nMake(baseDir, predecode)); | ||
} | ||
|
||
@ApiStatus.Internal public static native long _nMake(String baseDir, boolean predecode); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package org.jetbrains.skija.resources; | ||
|
||
import org.jetbrains.annotations.*; | ||
import org.jetbrains.skija.impl.*; | ||
|
||
public abstract class ResourceProvider extends RefCnt { | ||
@ApiStatus.Internal | ||
public ResourceProvider(long ptr) { | ||
super(ptr); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters