diff options
author | Svetoslav <svetoslavganov@google.com> | 2013-09-20 01:14:02 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2013-09-20 01:14:02 +0000 |
commit | facc08c7757cef56da6d10e78ce99ef7949700e3 (patch) | |
tree | e3f2cb7c8f0a337b22bb9ddcaaf370e617420e0f /core/jni | |
parent | 12946530cfba2024fa45c06b0060fe5c91252aab (diff) | |
parent | 6811f4e92cbb64e72a0d13eb9b99b5894bd59c76 (diff) | |
download | frameworks_base-facc08c7757cef56da6d10e78ce99ef7949700e3.zip frameworks_base-facc08c7757cef56da6d10e78ce99ef7949700e3.tar.gz frameworks_base-facc08c7757cef56da6d10e78ce99ef7949700e3.tar.bz2 |
Merge "Move PdfDocument to android.graphics.pdf" into klp-dev
Diffstat (limited to 'core/jni')
-rw-r--r-- | core/jni/Android.mk | 2 | ||||
-rw-r--r-- | core/jni/AndroidRuntime.cpp | 4 | ||||
-rw-r--r-- | core/jni/android/graphics/pdf/PdfDocument.cpp (renamed from core/jni/android/print/android_print_pdf_PdfDocument.cpp) | 27 |
3 files changed, 15 insertions, 18 deletions
diff --git a/core/jni/Android.mk b/core/jni/Android.mk index d5d746a..f78d807 100644 --- a/core/jni/Android.mk +++ b/core/jni/Android.mk @@ -118,6 +118,7 @@ LOCAL_SRC_FILES:= \ android/graphics/Utils.cpp \ android/graphics/Xfermode.cpp \ android/graphics/YuvToJpegEncoder.cpp \ + android/graphics/pdf/PdfDocument.cpp \ android_media_AudioRecord.cpp \ android_media_AudioSystem.cpp \ android_media_AudioTrack.cpp \ @@ -135,7 +136,6 @@ LOCAL_SRC_FILES:= \ android_util_FileObserver.cpp \ android/opengl/poly_clip.cpp.arm \ android/opengl/util.cpp.arm \ - android/print/android_print_pdf_PdfDocument.cpp \ android_server_NetworkManagementSocketTagger.cpp \ android_server_Watchdog.cpp \ android_ddm_DdmHandleNativeHeap.cpp \ diff --git a/core/jni/AndroidRuntime.cpp b/core/jni/AndroidRuntime.cpp index 490d85c..8518101 100644 --- a/core/jni/AndroidRuntime.cpp +++ b/core/jni/AndroidRuntime.cpp @@ -117,6 +117,7 @@ extern int register_android_graphics_Rasterizer(JNIEnv* env); extern int register_android_graphics_Region(JNIEnv* env); extern int register_android_graphics_SurfaceTexture(JNIEnv* env); extern int register_android_graphics_Xfermode(JNIEnv* env); +extern int register_android_graphics_pdf_PdfDocument(JNIEnv* env); extern int register_android_view_DisplayEventReceiver(JNIEnv* env); extern int register_android_view_GraphicBuffer(JNIEnv* env); extern int register_android_view_GLES20DisplayList(JNIEnv* env); @@ -144,7 +145,6 @@ extern int register_android_os_FileObserver(JNIEnv *env); extern int register_android_os_FileUtils(JNIEnv *env); extern int register_android_os_UEventObserver(JNIEnv* env); extern int register_android_os_MemoryFile(JNIEnv* env); -extern int register_android_print_pdf_PdfDocument(JNIEnv* env); extern int register_android_net_LocalSocketImpl(JNIEnv* env); extern int register_android_net_NetworkUtils(JNIEnv* env); extern int register_android_net_TrafficStats(JNIEnv* env); @@ -1161,6 +1161,7 @@ static const RegJNIRec gRegJNI[] = { REG_JNI(register_android_graphics_Typeface), REG_JNI(register_android_graphics_Xfermode), REG_JNI(register_android_graphics_YuvImage), + REG_JNI(register_android_graphics_pdf_PdfDocument), REG_JNI(register_android_database_CursorWindow), REG_JNI(register_android_database_SQLiteConnection), @@ -1173,7 +1174,6 @@ static const RegJNIRec gRegJNI[] = { REG_JNI(register_android_os_SELinux), REG_JNI(register_android_os_Trace), REG_JNI(register_android_os_UEventObserver), - REG_JNI(register_android_print_pdf_PdfDocument), REG_JNI(register_android_net_LocalSocketImpl), REG_JNI(register_android_net_NetworkUtils), REG_JNI(register_android_net_TrafficStats), diff --git a/core/jni/android/print/android_print_pdf_PdfDocument.cpp b/core/jni/android/graphics/pdf/PdfDocument.cpp index 3daad5c..b57a0fe 100644 --- a/core/jni/android/print/android_print_pdf_PdfDocument.cpp +++ b/core/jni/android/graphics/pdf/PdfDocument.cpp @@ -28,6 +28,8 @@ namespace android { +#define LOGD(x...) do { Log::Instance()->printf(Log::ELogD, x); } while(0) + static jint nativeCreateDocument(JNIEnv* env, jobject clazz) { return reinterpret_cast<jint>(new SkPDFDocument()); } @@ -36,21 +38,16 @@ static void nativeFinalize(JNIEnv* env, jobject thiz, jint documentPtr) { delete reinterpret_cast<SkPDFDocument*>(documentPtr); } -static jint nativeCreatePage(JNIEnv* env, jobject thiz, - jobject pageSize, jobject contentSize, jint initialTransformation) { - SkIRect skPageSizeRect; - GraphicsJNI::jrect_to_irect(env, pageSize, &skPageSizeRect); - SkISize skPageSize = SkISize::Make(skPageSizeRect.width(), - skPageSizeRect.height()); +static jint nativeCreatePage(JNIEnv* env, jobject thiz, jint pageWidth, jint pageHeight, + jint contentLeft, jint contentTop, jint contentRight, jint contentBottom) { - SkIRect skContentRect; - GraphicsJNI::jrect_to_irect(env, contentSize, &skContentRect); - SkISize skContentSize = SkISize::Make(skContentRect.width(), - skContentRect.height()); + SkMatrix transformation; + transformation.setTranslate(contentLeft, contentTop); - SkMatrix* transformation = reinterpret_cast<SkMatrix*>(initialTransformation); - SkPDFDevice* skPdfDevice = new SkPDFDevice(skPageSize, skContentSize, *transformation); + SkISize skPageSize = SkISize::Make(pageWidth, pageHeight); + SkISize skContentSize = SkISize::Make(contentRight - contentLeft, contentBottom - contentTop); + SkPDFDevice* skPdfDevice = new SkPDFDevice(skPageSize, skContentSize, transformation); return reinterpret_cast<jint>(new SkCanvas(skPdfDevice)); } @@ -72,15 +69,15 @@ static void nativeWriteTo(JNIEnv* env, jobject clazz, jint documentPtr, static JNINativeMethod gPdfDocument_Methods[] = { {"nativeCreateDocument", "()I", (void*) nativeCreateDocument}, {"nativeFinalize", "(I)V", (void*) nativeFinalize}, - {"nativeCreatePage", "(Landroid/graphics/Rect;Landroid/graphics/Rect;I)I", + {"nativeCreatePage", "(IIIIII)I", (void*) nativeCreatePage}, {"nativeAppendPage", "(II)V", (void*) nativeAppendPage}, {"nativeWriteTo", "(ILjava/io/OutputStream;[B)V", (void*) nativeWriteTo} }; -int register_android_print_pdf_PdfDocument(JNIEnv* env) { +int register_android_graphics_pdf_PdfDocument(JNIEnv* env) { int result = android::AndroidRuntime::registerNativeMethods( - env, "android/print/pdf/PdfDocument", gPdfDocument_Methods, + env, "android/graphics/pdf/PdfDocument", gPdfDocument_Methods, NELEM(gPdfDocument_Methods)); return result; } |