Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(120)

Unified Diff: platform_tools/android/apps/canvasproof/src/main/jni/org_skia_canvasproof_CreateSkiaPicture.cpp

Issue 1258123004: android/apps: Add CanvasProof App; (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: 2015-09-04 (Friday) 13:29:02 EDT Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: platform_tools/android/apps/canvasproof/src/main/jni/org_skia_canvasproof_CreateSkiaPicture.cpp
diff --git a/platform_tools/android/apps/canvasproof/src/main/jni/org_skia_canvasproof_CreateSkiaPicture.cpp b/platform_tools/android/apps/canvasproof/src/main/jni/org_skia_canvasproof_CreateSkiaPicture.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..c5d9759e54b64430cb5c9bf7ddbdd6bef1a4418b
--- /dev/null
+++ b/platform_tools/android/apps/canvasproof/src/main/jni/org_skia_canvasproof_CreateSkiaPicture.cpp
@@ -0,0 +1,42 @@
+/*
+ * Copyright 2015 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include "org_skia_canvasproof_CreateSkiaPicture.h"
+#include "JavaInputStream.h"
+#include "SkPicture.h"
+#include "SkPictureRecorder.h"
+
+/*
+ * Class: org_skia_canvasproof_CreateSkiaPicture
+ * Method: delete
+ * Signature: (J)V
+ */
+JNIEXPORT void JNICALL Java_org_skia_canvasproof_CreateSkiaPicture_deleteImpl(
+ JNIEnv* env, jclass clazz, jlong ptr) {
+ SkSafeUnref(reinterpret_cast<SkPicture*>(ptr));
+}
+
+/*
+ * Class: org_skia_canvasproof_CreateSkiaPicture
+ * Method: createImpl
+ * Signature: (Ljava/io/InputStream;[B)J
+ */
+JNIEXPORT jlong JNICALL Java_org_skia_canvasproof_CreateSkiaPicture_createImpl
+ (JNIEnv* env, jclass clazz, jobject inputStream, jbyteArray buffer) {
+ JavaInputStream stream(env, buffer, inputStream);
+ #if 0
+ SkAutoTUnref<SkPicture> p(SkPicture::CreateFromStream(&stream));
+ if (!p) { return 0; }
+ SkPictureRecorder recorder;
+ SkRect bounds = p->cullRect();
+ SkRTreeFactory bbh;
+ recorder.beginRecording(bounds, &bbh)->drawPicture(p);
+ return reinterpret_cast<long>(recorder.endRecordingAsPicture());
+ #else
+ return reinterpret_cast<long>(SkPicture::CreateFromStream(&stream));
+ #endif
+}

Powered by Google App Engine
This is Rietveld 408576698