diff options
Diffstat (limited to 'services/java/com/android/server/wm/Watermark.java')
-rw-r--r-- | services/java/com/android/server/wm/Watermark.java | 51 |
1 files changed, 26 insertions, 25 deletions
diff --git a/services/java/com/android/server/wm/Watermark.java b/services/java/com/android/server/wm/Watermark.java index ac152c9..fedd314 100644 --- a/services/java/com/android/server/wm/Watermark.java +++ b/services/java/com/android/server/wm/Watermark.java @@ -28,6 +28,7 @@ import android.util.Log; import android.util.TypedValue; import android.view.Display; import android.view.Surface; +import android.view.SurfaceControl; import android.view.SurfaceSession; import android.view.Surface.OutOfResourcesException; @@ -35,21 +36,20 @@ import android.view.Surface.OutOfResourcesException; * Displays a watermark on top of the window manager's windows. */ class Watermark { - final Display mDisplay; - final String[] mTokens; - final String mText; - final Paint mTextPaint; - final int mTextWidth; - final int mTextHeight; - final int mTextAscent; - final int mTextDescent; - final int mDeltaX; - final int mDeltaY; - - Surface mSurface; - int mLastDW; - int mLastDH; - boolean mDrawNeeded; + private final Display mDisplay; + private final String[] mTokens; + private final String mText; + private final Paint mTextPaint; + private final int mTextWidth; + private final int mTextHeight; + private final int mDeltaX; + private final int mDeltaY; + + private final SurfaceControl mSurfaceControl; + private final Surface mSurface = new Surface(); + private int mLastDW; + private int mLastDH; + private boolean mDrawNeeded; Watermark(Display display, DisplayMetrics dm, SurfaceSession session, String[] tokens) { if (false) { @@ -90,8 +90,6 @@ class Watermark { FontMetricsInt fm = mTextPaint.getFontMetricsInt(); mTextWidth = (int)mTextPaint.measureText(mText); - mTextAscent = fm.ascent; - mTextDescent = fm.descent; mTextHeight = fm.descent - fm.ascent; mDeltaX = WindowManagerService.getPropertyInt(tokens, 2, @@ -112,22 +110,25 @@ class Watermark { mTextPaint.setColor(color); mTextPaint.setShadowLayer(shadowRadius, shadowDx, shadowDy, shadowColor); + SurfaceControl ctrl = null; try { - mSurface = new Surface(session, "WatermarkSurface", - 1, 1, PixelFormat.TRANSLUCENT, Surface.HIDDEN); - mSurface.setLayerStack(mDisplay.getLayerStack()); - mSurface.setLayer(WindowManagerService.TYPE_LAYER_MULTIPLIER*100); - mSurface.setPosition(0, 0); - mSurface.show(); - } catch (OutOfResourcesException e) { + ctrl = new SurfaceControl(session, "WatermarkSurface", + 1, 1, PixelFormat.TRANSLUCENT, SurfaceControl.HIDDEN); + ctrl.setLayerStack(mDisplay.getLayerStack()); + ctrl.setLayer(WindowManagerService.TYPE_LAYER_MULTIPLIER*100); + ctrl.setPosition(0, 0); + ctrl.show(); + mSurface.copyFrom(ctrl); + } catch (SurfaceControl.OutOfResourcesException e) { } + mSurfaceControl = ctrl; } void positionSurface(int dw, int dh) { if (mLastDW != dw || mLastDH != dh) { mLastDW = dw; mLastDH = dh; - mSurface.setSize(dw, dh); + mSurfaceControl.setSize(dw, dh); mDrawNeeded = true; } } |