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 | |
parent | 523018f1828884e96b1265f3e347410280577945 (diff) | |
download | frameworks_base-dbade9d6a075b1d5b8ebe10ee8961a5de296c93b.zip frameworks_base-dbade9d6a075b1d5b8ebe10ee8961a5de296c93b.tar.gz frameworks_base-dbade9d6a075b1d5b8ebe10ee8961a5de296c93b.tar.bz2 |
expose runtime changes to gamma
-rw-r--r-- | api/current.xml | 15 | ||||
-rw-r--r-- | core/jni/android/graphics/Typeface.cpp | 22 | ||||
-rw-r--r-- | graphics/java/android/graphics/Typeface.java | 10 |
3 files changed, 46 insertions, 1 deletions
diff --git a/api/current.xml b/api/current.xml index 2d7ee31..3c76361 100644 --- a/api/current.xml +++ b/api/current.xml @@ -60507,6 +60507,21 @@ visibility="public" > </method> +<method name="setGammaForText" + return="void" + abstract="false" + native="true" + synchronized="false" + static="true" + final="false" + deprecated="not deprecated" + visibility="public" +> +<parameter name="blackGamma" type="float"> +</parameter> +<parameter name="whiteGamma" type="float"> +</parameter> +</method> <field name="BOLD" type="int" transient="false" 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); diff --git a/graphics/java/android/graphics/Typeface.java b/graphics/java/android/graphics/Typeface.java index e40e84a..9bcab72 100644 --- a/graphics/java/android/graphics/Typeface.java +++ b/graphics/java/android/graphics/Typeface.java @@ -172,4 +172,14 @@ public class Typeface { private static native int nativeGetStyle(int native_instance); private static native int nativeCreateFromAsset(AssetManager mgr, String path); private static native int nativeCreateFromFile(String path); + + /** + * Set the global gamma coefficients for black and white text. This call is + * usually a no-op in shipping products, and only exists for testing during + * development. + * + * @param blackGamma gamma coefficient for black text + * @param whiteGamma gamma coefficient for white text + */ + public static native void setGammaForText(float blackGamma, float whiteGamma); } |