示例#1
0
 @Override
 protected void closeNativeImpl() {
   Log.d(
       MD.TAG,
       "closeNativeImpl 0 - surfaceHandle 0x"
           + Long.toHexString(surfaceHandle)
           + ", eglSurfaceHandle 0x"
           + Long.toHexString(eglSurface)
           + ", format [a "
           + androidFormat
           + ", n "
           + nativeFormat
           + "], "
           + getX()
           + "/"
           + getY()
           + " "
           + getWidth()
           + "x"
           + getHeight()
           + " - "
           + Thread.currentThread().getName());
   if (0 != eglSurface) {
     final EGLGraphicsDevice eglDevice =
         (EGLGraphicsDevice) getScreen().getDisplay().getGraphicsDevice();
     if (!EGL.eglDestroySurface(eglDevice.getHandle(), eglSurface)) {
       throw new GLException("Error destroying window surface (eglDestroySurface)");
     }
     eglSurface = 0;
   }
   release0(surfaceHandle);
   surface = null;
   surfaceHandle = 0;
 }
示例#2
0
  @Override
  protected void createNativeImpl() {
    Log.d(
        MD.TAG,
        "createNativeImpl 0 - surfaceHandle 0x"
            + Long.toHexString(surfaceHandle)
            + ", format [a "
            + androidFormat
            + ", n "
            + nativeFormat
            + "], "
            + getX()
            + "/"
            + getY()
            + " "
            + getWidth()
            + "x"
            + getHeight()
            + " - "
            + Thread.currentThread().getName());

    if (0 != getParentWindowHandle()) {
      throw new NativeWindowException("Window parenting not supported (yet)");
    }
    if (0 == surfaceHandle) {
      throw new InternalError("XXX");
    }

    final EGLGraphicsDevice eglDevice =
        (EGLGraphicsDevice) getScreen().getDisplay().getGraphicsDevice();
    final EGLGraphicsConfiguration eglConfig =
        EGLGraphicsConfigurationFactory.chooseGraphicsConfigurationStatic(
            capsByFormat,
            (GLCapabilitiesImmutable) getRequestedCapabilities(),
            (GLCapabilitiesChooser) capabilitiesChooser,
            getScreen().getGraphicsScreen(),
            nativeFormat,
            isAndroidFormatTransparent(androidFormat));
    if (eglConfig == null) {
      throw new NativeWindowException(
          "Error choosing GraphicsConfiguration creating window: " + this);
    }
    final int nativeVisualID = eglConfig.getVisualID(VisualIDHolder.VIDType.NATIVE);
    Log.d(MD.TAG, "nativeVisualID 0x" + Integer.toHexString(nativeVisualID));
    if (VisualIDHolder.VID_UNDEFINED != nativeVisualID) {
      setSurfaceVisualID0(surfaceHandle, nativeVisualID);
    }

    eglSurface =
        EGL.eglCreateWindowSurface(
            eglDevice.getHandle(), eglConfig.getNativeConfig(), surfaceHandle, null);
    if (EGL.EGL_NO_SURFACE == eglSurface) {
      throw new NativeWindowException(
          "Creation of window surface failed: "
              + eglConfig
              + ", surfaceHandle 0x"
              + Long.toHexString(surfaceHandle)
              + ", error "
              + toHexString(EGL.eglGetError()));
    }

    // propagate data ..
    setGraphicsConfiguration(eglConfig);
    setWindowHandle(surfaceHandle);
    focusChanged(false, true);
    Log.d(MD.TAG, "createNativeImpl X: eglSurfaceHandle 0x" + Long.toHexString(eglSurface));
  }