diff options
author | Leandro Gracia Gil <leandrogracia@google.com> | 2013-01-09 15:28:46 +0000 |
---|---|---|
committer | Leandro Gracia Gil <leandrogracia@google.com> | 2013-02-05 19:50:45 +0000 |
commit | f15e28c8d30c2ccea58871c9d22f8b47e53d6ea4 (patch) | |
tree | 8409dc6c3ea245431f1608276fc1abd8cb688f46 /chromium/plat_support | |
parent | a611c7e365068e2130b6de87b2b14e3b75ae1d4e (diff) | |
download | webview-f15e28c8d30c2ccea58871c9d22f8b47e53d6ea4.tar.gz |
Update the onNewPicture callback to support external native SkPictures.
Needs to be landed after https://codereview.chromium.org/11823027/ .
Change-Id: I1febd5330e61e84733d11b835142cb05cf21795e
Diffstat (limited to 'chromium/plat_support')
-rw-r--r-- | chromium/plat_support/graphics_utils.cpp | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/chromium/plat_support/graphics_utils.cpp b/chromium/plat_support/graphics_utils.cpp index c9e519b..8bd8254 100644 --- a/chromium/plat_support/graphics_utils.cpp +++ b/chromium/plat_support/graphics_utils.cpp @@ -25,6 +25,8 @@ #include <jni.h> #include <utils/Log.h> #include "GraphicsJNI.h" +#include "SkGraphics.h" +#include "SkPicture.h" #define NELEM(x) ((int) (sizeof(x) / sizeof((x)[0]))) @@ -84,10 +86,36 @@ void ReleasePixels(AwPixelInfo* pixels) { delete static_cast<PixelInfo*>(pixels); } +jobject CreatePicture(JNIEnv* env, SkPicture* picture) { + jclass clazz = env->FindClass("android/graphics/Picture"); + jmethodID constructor = env->GetMethodID(clazz, "<init>", "(IZ)V"); + ALOG_ASSERT(clazz); + ALOG_ASSERT(constructor); + return env->NewObject(clazz, constructor, picture, false); +} + +bool IsSkiaVersionCompatible(SkiaVersionFunction function) { + bool compatible = false; + if (function && function == &SkGraphics::GetVersion) { + int android_major, android_minor, android_patch; + SkGraphics::GetVersion(&android_major, &android_minor, &android_patch); + + int chromium_major, chromium_minor, chromium_patch; + (*function)(&chromium_major, &chromium_minor, &chromium_patch); + + compatible = android_major == chromium_major && + android_minor == chromium_minor && + android_patch == chromium_patch; + } + return compatible; +} + jint GetDrawSWFunctionTable(JNIEnv* env, jclass) { static const AwDrawSWFunctionTable function_table = { &GetPixels, &ReleasePixels, + &CreatePicture, + &IsSkiaVersionCompatible, }; return reinterpret_cast<jint>(&function_table); } |