From 2701a7e8b450233fd2421b91116882d49d3ab650 Mon Sep 17 00:00:00 2001 From: Miyoung shin Date: Mon, 20 Jan 2025 18:55:55 +0900 Subject: [PATCH] Apply border and brightness effects This patch applies border and brightness effects to OverlayContentWidget. The border will overlap 2px on the left/right/top/bottom of WebContents because the browser's compositor implementation doesn't consider the x, y coordinates when setting up the surface. It's same with Widget for Tab, and we maybe consider to have the inner Widget to avoid this issue later. Having a border effect will bring about a better UX even if it loses 2 pixels. --- .../ui/widgets/OverlayContentWidget.java | 21 +++++++++++-------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/app/src/common/shared/com/igalia/wolvic/ui/widgets/OverlayContentWidget.java b/app/src/common/shared/com/igalia/wolvic/ui/widgets/OverlayContentWidget.java index 5e3eb94aa3..c90e2df065 100644 --- a/app/src/common/shared/com/igalia/wolvic/ui/widgets/OverlayContentWidget.java +++ b/app/src/common/shared/com/igalia/wolvic/ui/widgets/OverlayContentWidget.java @@ -2,8 +2,6 @@ import android.content.Context; import android.graphics.SurfaceTexture; -import android.os.Handler; -import android.os.Looper; import android.util.AttributeSet; import android.view.KeyEvent; import android.view.MotionEvent; @@ -15,6 +13,7 @@ import com.igalia.wolvic.VRBrowserApplication; import com.igalia.wolvic.browser.api.WDisplay; import com.igalia.wolvic.browser.api.WSession; +import com.igalia.wolvic.utils.ViewUtils; import java.util.concurrent.Executor; @@ -27,7 +26,6 @@ public class OverlayContentWidget extends UIWidget implements WidgetManagerDeleg private WDisplay mDisplay; private WSession.ContentDelegate.OnPaymentHandlerCallback mCallback; private Executor mUIThreadExecutor; - private Handler mHandler; public OverlayContentWidget(Context aContext) { super(aContext); @@ -53,6 +51,7 @@ public void setDelegates(@NonNull WSession session, @NonNull WDisplay display, @Override public void releaseWidget() { + mWidgetManager.popWorldBrightness(OverlayContentWidget.this); mWidgetManager.removeWorldClickListener(this); mCallback.onDismiss(); @@ -62,9 +61,8 @@ public void releaseWidget() { @Override protected void initializeWidgetPlacement(WidgetPlacement aPlacement) { aPlacement.visible = false; - aPlacement.width = WidgetPlacement.dpDimension(getContext(), R.dimen.tabs_width); - aPlacement.height = WidgetPlacement.dpDimension(getContext(), R.dimen.tabs_height); - + aPlacement.width = WidgetPlacement.dpDimension(getContext(), R.dimen.tabs_width) + mBorderWidth * 2; + aPlacement.height = WidgetPlacement.dpDimension(getContext(), R.dimen.tabs_height) + mBorderWidth * 2; aPlacement.parentAnchorX = 0.5f; aPlacement.parentAnchorY = 0.0f; aPlacement.anchorX = 0.5f; @@ -72,6 +70,8 @@ protected void initializeWidgetPlacement(WidgetPlacement aPlacement) { aPlacement.translationY = WidgetPlacement.unitFromMeters(getContext(), R.dimen.settings_world_y) - WidgetPlacement.unitFromMeters(getContext(), R.dimen.window_world_y); updatePlacementTranslationZ(); + + mWidgetPlacement.borderColor = ViewUtils.ARGBtoRGBA(getContext().getColor(R.color.rhino_blur)); } @Override @@ -82,9 +82,11 @@ public void updatePlacementTranslationZ() { private void initialize(Context aContext) { mUIThreadExecutor = ((VRBrowserApplication)aContext.getApplicationContext()).getExecutors().mainThread(); - mHandler = new Handler(Looper.getMainLooper()); - mWidgetManager.addWorldClickListener(this); + mWidgetManager.pushWorldBrightness(OverlayContentWidget.this, WidgetManagerDelegate.DEFAULT_DIM_BRIGHTNESS); + + // TODO: Fix the compositor in the browser engine to support correct border offset + mBorderWidth = 0; } @Override @@ -198,7 +200,8 @@ public void setSurface(Surface aSurface, final int aWidth, final int aHeight, Ru private void callSurfaceChanged() { if (mSurface != null) { - mDisplay.surfaceChanged(mSurface, 0, 0, mSurfaceWidth, mSurfaceHeight); + int borderWidth = WidgetPlacement.convertDpToPixel(getContext(), mBorderWidth); + mDisplay.surfaceChanged(mSurface, borderWidth, borderWidth, mSurfaceWidth - borderWidth * 2, mSurfaceHeight - borderWidth * 2); } }