expose runtime changes to gamma
This commit is contained in:
@@ -60507,6 +60507,21 @@
|
|||||||
visibility="public"
|
visibility="public"
|
||||||
>
|
>
|
||||||
</method>
|
</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"
|
<field name="BOLD"
|
||||||
type="int"
|
type="int"
|
||||||
transient="false"
|
transient="false"
|
||||||
|
|||||||
@@ -141,6 +141,25 @@ static SkTypeface* Typeface_createFromFile(JNIEnv* env, jobject, jstring jpath)
|
|||||||
return SkTypeface::CreateFromFile(str.c_str());
|
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[] = {
|
static JNINativeMethod gTypefaceMethods[] = {
|
||||||
@@ -151,7 +170,8 @@ static JNINativeMethod gTypefaceMethods[] = {
|
|||||||
{ "nativeCreateFromAsset", "(Landroid/content/res/AssetManager;Ljava/lang/String;)I",
|
{ "nativeCreateFromAsset", "(Landroid/content/res/AssetManager;Ljava/lang/String;)I",
|
||||||
(void*)Typeface_createFromAsset },
|
(void*)Typeface_createFromAsset },
|
||||||
{ "nativeCreateFromFile", "(Ljava/lang/String;)I",
|
{ "nativeCreateFromFile", "(Ljava/lang/String;)I",
|
||||||
(void*)Typeface_createFromFile }
|
(void*)Typeface_createFromFile },
|
||||||
|
{ "setGammaForText", "(FF)V", (void*)Typeface_setGammaForText },
|
||||||
};
|
};
|
||||||
|
|
||||||
int register_android_graphics_Typeface(JNIEnv* env);
|
int register_android_graphics_Typeface(JNIEnv* env);
|
||||||
|
|||||||
@@ -172,4 +172,14 @@ public class Typeface {
|
|||||||
private static native int nativeGetStyle(int native_instance);
|
private static native int nativeGetStyle(int native_instance);
|
||||||
private static native int nativeCreateFromAsset(AssetManager mgr, String path);
|
private static native int nativeCreateFromAsset(AssetManager mgr, String path);
|
||||||
private static native int nativeCreateFromFile(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);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user