Skip to content

Commit

Permalink
Avoid re-layout on window minimized, since framebuffer is destroyed a…
Browse files Browse the repository at this point in the history
…nd size is 0

Deprecate Canvas.saveLayer() for future layer compositor and render tree
  • Loading branch information
BloCamLimb committed Apr 26, 2024
1 parent a262d81 commit c225f79
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
7 changes: 6 additions & 1 deletion core/src/main/java/icyllis/modernui/core/ActivityWindow.java
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,12 @@ private void onFramebufferSizeCallback(long w, int width, int height) {
mWidth = width;
mHeight = height;
if (mRoot != null) {
mRoot.mHandler.post(() -> mRoot.setFrame(mWidth, mHeight));
mRoot.mHandler.post(() -> {
// on minimized, window size is 0
if (mWidth != 0 && mHeight != 0) {
mRoot.setFrame(mWidth, mHeight);
}
});
}
}

Expand Down
6 changes: 6 additions & 0 deletions core/src/main/java/icyllis/modernui/graphics/Canvas.java
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,10 @@ protected Canvas() {
* @param alpha The alpha to apply to the offscreen when it is
* drawn during restore()
* @return value to pass to restoreToCount() to balance this call
* @deprecated this method does nothing, you should manually create a layer, or possibly manage a
* pool of layers, or use {@link icyllis.modernui.view.View#LAYER_TYPE_HARDWARE}.
*/
@Deprecated
public final int saveLayer(@Nullable RectF bounds, int alpha) {
if (bounds == null) {
// ok, it's big enough
Expand All @@ -134,7 +137,10 @@ public final int saveLayer(@Nullable RectF bounds, int alpha) {
* bounds' rectangle.
*
* @see #saveLayer(RectF, int)
* @deprecated this method does nothing, you should manually create a layer, or possibly manage a
* pool of layers, or use {@link icyllis.modernui.view.View#LAYER_TYPE_HARDWARE}.
*/
@Deprecated
public abstract int saveLayer(float left, float top, float right, float bottom, int alpha);

/**
Expand Down

0 comments on commit c225f79

Please sign in to comment.