am 9bace916: am dbade9d6: expose runtime changes to gamma

Merge commit '9bace91641df27c5b238fe5fc340e25827382473'

* commit '9bace91641df27c5b238fe5fc340e25827382473':
  expose runtime changes to gamma
This commit is contained in:
Mike Reed
2009-08-25 11:00:36 -07:00
committed by Android Git Automerger
3 changed files with 46 additions and 1 deletions

View File

@@ -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"

View File

@@ -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);

View File

@@ -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);
}