コード例 #1
0
 private boolean showSurface(float alpha) {
   if (!mSurfaceVisible || mSurfaceAlpha != alpha) {
     SurfaceControl.openTransaction();
     try {
       mSurfaceControl.setLayer(ELECTRON_BEAM_LAYER);
       mSurfaceControl.setAlpha(alpha);
       mSurfaceControl.show();
     } finally {
       SurfaceControl.closeTransaction();
     }
     mSurfaceVisible = true;
     mSurfaceAlpha = alpha;
   }
   return true;
 }
コード例 #2
0
 private void destroySurface() {
   if (mSurfaceControl != null) {
     mSurfaceLayout.dispose();
     mSurfaceLayout = null;
     SurfaceControl.openTransaction();
     try {
       mSurfaceControl.destroy();
       mSurface.release();
     } finally {
       SurfaceControl.closeTransaction();
     }
     mSurfaceControl = null;
     mSurfaceVisible = false;
     mSurfaceAlpha = 0f;
   }
 }
コード例 #3
0
  private boolean createSurface() {
    if (mSurfaceSession == null) {
      mSurfaceSession = new SurfaceSession();
    }

    SurfaceControl.openTransaction();
    try {
      if (mSurfaceControl == null) {
        try {
          int flags;
          if (mMode == MODE_FADE) {
            flags = SurfaceControl.FX_SURFACE_DIM | SurfaceControl.HIDDEN;
          } else {
            flags = SurfaceControl.OPAQUE | SurfaceControl.HIDDEN;
          }
          mSurfaceControl =
              new SurfaceControl(
                  mSurfaceSession,
                  "ElectronBeam",
                  mDisplayWidth,
                  mDisplayHeight,
                  PixelFormat.OPAQUE,
                  flags);
        } catch (OutOfResourcesException ex) {
          Slog.e(TAG, "Unable to create surface.", ex);
          return false;
        }
      }

      mSurfaceControl.setLayerStack(mDisplayLayerStack);
      mSurfaceControl.setSize(mDisplayWidth, mDisplayHeight);
      mSurface = new Surface();
      mSurface.copyFrom(mSurfaceControl);

      mSurfaceLayout = new NaturalSurfaceLayout(mDisplayManager, mSurfaceControl, mHWRotation);
      mSurfaceLayout.onDisplayTransaction();
    } finally {
      SurfaceControl.closeTransaction();
    }
    return true;
  }