Skip to content

Commit

Permalink
Fix UI scaling issues (#1144)
Browse files Browse the repository at this point in the history
  • Loading branch information
MortimerGoro authored and bluemarvin committed May 2, 2019
1 parent 04a9479 commit ce9dd1e
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -543,8 +543,7 @@ public void onFrameAvailable(SurfaceTexture surfaceTexture) {
// Add widget to a virtual display for invalidation
View view = (View) widget;
if (view.getParent() == null) {
float scale = widget.getPlacement().textureScale;
mWidgetContainer.addView(view, new FrameLayout.LayoutParams((int) Math.ceil(aWidth / scale), (int) Math.ceil(aHeight / scale)));
mWidgetContainer.addView(view, new FrameLayout.LayoutParams(widget.getPlacement().viewWidth(), widget.getPlacement().viewHeight()));
}
});
}
Expand Down Expand Up @@ -863,15 +862,17 @@ public void updateWidget(final Widget aWidget) {

final int textureWidth = aWidget.getPlacement().textureWidth();
final int textureHeight = aWidget.getPlacement().textureHeight();
final int viewWidth = aWidget.getPlacement().viewWidth();
final int viewHeight = aWidget.getPlacement().viewHeight();

FrameLayout.LayoutParams params = (FrameLayout.LayoutParams)((View)aWidget).getLayoutParams();
if (params == null) {
// Widget not added yet
return;
}
if (params.width != textureWidth || params.height != textureHeight) {
params.width = textureWidth;
params.height = textureHeight;
if (params.width != viewWidth || params.height != viewHeight) {
params.width = viewWidth;
params.height = viewHeight;
((View)aWidget).setLayoutParams(params);
aWidget.resizeSurface(textureWidth, textureHeight);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,15 +127,10 @@ public void setSurface(Surface aSurface, final int aWidth, final int aHeight, Ru
}

@Override
public void resizeSurface(final int aWidth, final int aHeight) {
public void resizeSurface(final int aSurfaceWidth, final int aSurfaceHeight) {
if (mRenderer != null){
mRenderer.resize(aWidth, aHeight);
mRenderer.resize(aSurfaceWidth, aSurfaceHeight);
}

FrameLayout.LayoutParams params = (FrameLayout.LayoutParams) getLayoutParams();
params.width = aWidth;
params.height = aHeight;
setLayoutParams(params);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,18 @@ public void copyFrom(WidgetPlacement w) {
}

public int textureWidth() {
return (int) Math.ceil(width * density);
return (int) Math.ceil(width * density * textureScale);
}

public int textureHeight() {
return (int) Math.ceil(height * density * textureScale);
}

public int viewWidth() {
return (int) Math.ceil(width * density);
}

public int viewHeight() {
return (int) Math.ceil(height * density);
}

Expand Down

0 comments on commit ce9dd1e

Please sign in to comment.