You've already forked android_translation_layer
mirror of
https://gitlab.com/android_translation_layer/android_translation_layer.git
synced 2025-10-27 11:48:10 -07:00
View: prevent redundant measuring for performance reasons
No need to remeasure or relayout when nothing has changed
This commit is contained in:
@@ -117,6 +117,7 @@ void set_up_handle_cache(JNIEnv *env)
|
||||
handle_cache.view.getScrollY = _METHOD(handle_cache.view.class, "getScrollY", "()I");
|
||||
handle_cache.view.performClick = _METHOD(handle_cache.view.class, "performClick", "()Z");
|
||||
handle_cache.view.onTouchEvent = _METHOD(handle_cache.view.class, "onTouchEvent", "(Landroid/view/MotionEvent;)Z");
|
||||
handle_cache.view.layoutInternal = _METHOD(handle_cache.view.class, "layoutInternal", "(II)V");
|
||||
|
||||
handle_cache.asset_manager.class = _REF((*env)->FindClass(env, "android/content/res/AssetManager"));
|
||||
handle_cache.asset_manager.extractFromAPK = _STATIC_METHOD(handle_cache.asset_manager.class, "extractFromAPK", "(Ljava/lang/String;Ljava/lang/String;)V");
|
||||
|
||||
@@ -71,6 +71,7 @@ struct handle_cache {
|
||||
jmethodID getScrollY;
|
||||
jmethodID performClick;
|
||||
jmethodID onTouchEvent;
|
||||
jmethodID layoutInternal;
|
||||
} view;
|
||||
struct {
|
||||
jclass class;
|
||||
|
||||
@@ -8,8 +8,6 @@
|
||||
#include "../generated_headers/android_view_ViewGroup.h"
|
||||
#include "../generated_headers/android_view_View.h"
|
||||
|
||||
#define MEASURE_SPEC_EXACTLY (1 << 30)
|
||||
|
||||
#define SOURCE_CLASS_POINTER 0x2
|
||||
|
||||
struct _AndroidLayout {
|
||||
@@ -41,17 +39,7 @@ static void android_layout_allocate(GtkLayoutManager *layout_manager, GtkWidget
|
||||
AndroidLayout *layout = ATL_ANDROID_LAYOUT(layout_manager);
|
||||
JNIEnv *env = get_jni_env();
|
||||
|
||||
(*env)->CallVoidMethod(env, layout->view, handle_cache.view.onMeasure, MEASURE_SPEC_EXACTLY | width, MEASURE_SPEC_EXACTLY | height);
|
||||
if((*env)->ExceptionCheck(env))
|
||||
(*env)->ExceptionDescribe(env);
|
||||
|
||||
(*env)->CallVoidMethod(env, layout->view, handle_cache.view.computeScroll);
|
||||
if((*env)->ExceptionCheck(env))
|
||||
(*env)->ExceptionDescribe(env);
|
||||
int scroll_x = (*env)->CallIntMethod(env, layout->view, handle_cache.view.getScrollX);
|
||||
int scroll_y = (*env)->CallIntMethod(env, layout->view, handle_cache.view.getScrollY);
|
||||
|
||||
(*env)->CallVoidMethod(env, layout->view, handle_cache.view.onLayout, TRUE, scroll_x, scroll_y, width, height);
|
||||
(*env)->CallVoidMethod(env, layout->view, handle_cache.view.layoutInternal, width, height);
|
||||
if((*env)->ExceptionCheck(env))
|
||||
(*env)->ExceptionDescribe(env);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user