View.draw(): draw background, content, children in same order as AOSP

This commit is contained in:
Julian Winkler
2024-05-26 15:53:24 +02:00
committed by Mis012
parent e8eabb2027
commit c5e0f8a7fd
8 changed files with 61 additions and 24 deletions

View File

@@ -900,13 +900,16 @@ public class View implements Drawable.Callback {
return null;
}
protected native void native_onDraw(long widget, long snapshot);
public void onDraw(Canvas canvas) {
if (canvas instanceof GskCanvas)
native_onDraw(widget, ((GskCanvas)canvas).snapshot);
native_drawContent(widget, ((GskCanvas)canvas).snapshot);
}
public void draw(Canvas canvas) {
if (canvas instanceof GskCanvas)
native_drawBackground(widget, ((GskCanvas)canvas).snapshot);
onDraw(canvas);
if (canvas instanceof GskCanvas)
native_drawChildren(widget, ((GskCanvas)canvas).snapshot);
}
public View(Context context) {
@@ -982,6 +985,10 @@ public class View implements Drawable.Callback {
protected native void native_setBackgroundDrawable(long widget, long paintable);
protected native void native_queueAllocate(long widget);
protected native void native_drawBackground(long widget, long snapshot);
protected native void native_drawContent(long widget, long snapshot);
protected void native_drawChildren(long widget, long snapshot) {} // override in ViewGroup
// --- stubs
public void setContentDescription(CharSequence contentDescription) {}

View File

@@ -133,6 +133,10 @@ public class ViewGroup extends View implements ViewParent, ViewManager {
protected native void native_addView(long widget, long child, int index, LayoutParams params);
protected native void native_removeView(long widget, long child);
@Override
protected native void native_drawChildren(long widget, long snapshot);
@Override
protected void native_drawContent(long widget, long snapshot) {}
public View getChildAt(int index) {
try {