-
Notifications
You must be signed in to change notification settings - Fork 127
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
m89-19889d74fa, DOM -> SVGDOM, SVGCanvas, DeleteLocalRefs in *.cc (cl…
…oses #93)
- Loading branch information
Showing
24 changed files
with
330 additions
and
27 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
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
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,56 @@ | ||
#include <iostream> | ||
#include <jni.h> | ||
#include "interop.hh" | ||
#include "SkStream.h" | ||
|
||
class OutputWStream: public SkWStream { | ||
public: | ||
OutputWStream(JNIEnv* env, jobject out): fEnv(env) { | ||
fOut = env->NewGlobalRef(out); | ||
} | ||
|
||
~OutputWStream() override { | ||
fEnv->DeleteGlobalRef(fOut); | ||
} | ||
|
||
size_t bytesWritten() const override { | ||
return fBytesWritten; | ||
} | ||
|
||
bool write(const void* buffer, size_t size) override { | ||
jbyteArray arr = fEnv->NewByteArray((jsize) size); | ||
fEnv->SetByteArrayRegion(arr, 0, (jsize) size, static_cast<const jbyte *>(buffer)); | ||
fEnv->CallVoidMethod(fOut, java::io::OutputStream::write, arr, 0, (jint) size); | ||
fEnv->DeleteLocalRef(arr); | ||
if (java::lang::Throwable::exceptionThrown(fEnv)) { | ||
return false; | ||
} else { | ||
fBytesWritten += size; | ||
return true; | ||
} | ||
} | ||
|
||
void flush() override { | ||
fEnv->CallVoidMethod(fOut, java::io::OutputStream::flush); | ||
} | ||
|
||
private: | ||
JNIEnv* fEnv; | ||
jobject fOut; | ||
size_t fBytesWritten = 0; | ||
}; | ||
|
||
static void deleteOutputWStream(OutputWStream* out) { | ||
delete out; | ||
} | ||
|
||
extern "C" JNIEXPORT jlong JNICALL Java_org_jetbrains_skija_OutputWStream__1nGetFinalizer | ||
(JNIEnv* env, jclass jclass) { | ||
return static_cast<jlong>(reinterpret_cast<uintptr_t>(&deleteOutputWStream)); | ||
} | ||
|
||
extern "C" JNIEXPORT jlong JNICALL Java_org_jetbrains_skija_OutputWStream__1nMake | ||
(JNIEnv* env, jclass jclass, jobject outputStream) { | ||
OutputWStream* instance = new OutputWStream(env, outputStream); | ||
return reinterpret_cast<jlong>(instance); | ||
} |
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
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 @@ | ||
#include <jni.h> | ||
#include "SkSVGCanvas.h" | ||
#include "SkStream.h" | ||
|
||
extern "C" JNIEXPORT jlong JNICALL Java_org_jetbrains_skija_svg_SVGCanvas__1nMake | ||
(JNIEnv* env, jclass jclass, jfloat left, jfloat top, jfloat right, jfloat bottom, jlong wstreamPtr, jint flags) { | ||
SkWStream* wstream = reinterpret_cast<SkWStream*>(static_cast<uintptr_t>(wstreamPtr)); | ||
SkRect bounds {left, top, right, bottom}; | ||
SkCanvas* instance = SkSVGCanvas::Make(bounds, wstream, flags).release(); | ||
return reinterpret_cast<jlong>(instance); | ||
} |
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
Oops, something went wrong.