diff options
author | Mike Reed <reed@google.com> | 2009-08-25 13:20:19 -0400 |
---|---|---|
committer | Mike Reed <reed@google.com> | 2009-08-25 13:47:47 -0400 |
commit | dbade9d6a075b1d5b8ebe10ee8961a5de296c93b (patch) | |
tree | ba87f0dbb1f4ca2521a7282a65faa6ed0963eb9e /core/jni/android | |
parent | 523018f1828884e96b1265f3e347410280577945 (diff) | |
download | frameworks_base-dbade9d6a075b1d5b8ebe10ee8961a5de296c93b.zip frameworks_base-dbade9d6a075b1d5b8ebe10ee8961a5de296c93b.tar.gz frameworks_base-dbade9d6a075b1d5b8ebe10ee8961a5de296c93b.tar.bz2 |
expose runtime changes to gamma
Diffstat (limited to 'core/jni/android')
-rw-r--r-- | core/jni/android/graphics/Typeface.cpp | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/core/jni/android/graphics/Typeface.cpp b/core/jni/android/graphics/Typeface.cpp index 21dde63..238ece1 100644 --- a/core/jni/android/graphics/Typeface.cpp +++ b/core/jni/android/graphics/Typeface.cpp @@ -141,6 +141,25 @@ static SkTypeface* Typeface_createFromFile(JNIEnv* env, jobject, jstring jpath) return SkTypeface::CreateFromFile(str.c_str()); } +#define MIN_GAMMA (0.1f) +#define MAX_GAMMA (10.0f) +static float pinGamma(float gamma) { + if (gamma < MIN_GAMMA) { + gamma = MIN_GAMMA; + } else if (gamma > MAX_GAMMA) { + gamma = MAX_GAMMA; + } + return gamma; +} + +extern void skia_set_text_gamma(float, float); + +static void Typeface_setGammaForText(JNIEnv* env, jobject, jfloat blackGamma, + jfloat whiteGamma) { + // Comment this out for release builds. This is only used during development + skia_set_text_gamma(pinGamma(blackGamma), pinGamma(whiteGamma)); +} + /////////////////////////////////////////////////////////////////////////////// static JNINativeMethod gTypefaceMethods[] = { @@ -151,7 +170,8 @@ static JNINativeMethod gTypefaceMethods[] = { { "nativeCreateFromAsset", "(Landroid/content/res/AssetManager;Ljava/lang/String;)I", (void*)Typeface_createFromAsset }, { "nativeCreateFromFile", "(Ljava/lang/String;)I", - (void*)Typeface_createFromFile } + (void*)Typeface_createFromFile }, + { "setGammaForText", "(FF)V", (void*)Typeface_setGammaForText }, }; int register_android_graphics_Typeface(JNIEnv* env); |