public AndroidFramebuffer(Surface surface) { if (surface == null) { throw new ArgumentNullException(nameof(surface)); } _window = ANativeWindow_fromSurface(JNIEnv.Handle, surface.Handle); if (_window == IntPtr.Zero) { throw new Exception("Unable to obtain ANativeWindow"); } ANativeWindow_Buffer buffer; var rc = new ARect() { right = Width = ANativeWindow_getWidth(_window), bottom = Height = ANativeWindow_getHeight(_window) }; ANativeWindow_lock(_window, out buffer, ref rc); Format = buffer.format == AndroidPixelFormat.WINDOW_FORMAT_RGB_565 ? PixelFormat.Rgb565 : PixelFormat.Rgba8888; RowBytes = buffer.stride * (Format == PixelFormat.Rgb565 ? 2 : 4); Address = buffer.bits; }
public AndroidFramebuffer(Surface surface) { _window = ANativeWindow_fromSurface(JNIEnv.Handle, surface.Handle); ANativeWindow_Buffer buffer; var rc = new ARect() { right = Width = ANativeWindow_getWidth(_window), bottom = Height = ANativeWindow_getHeight(_window) }; ANativeWindow_lock(_window, out buffer, ref rc); Format = buffer.format == AndroidPixelFormat.WINDOW_FORMAT_RGB_565 ? PixelFormat.Rgb565 : PixelFormat.Rgba8888; RowBytes = buffer.stride * (Format == PixelFormat.Rgb565 ? 2 : 4); Address = buffer.bits; }
internal static extern int ANativeWindow_lock(IntPtr window, out ANativeWindow_Buffer outBuffer, ref ARect inOutDirtyBounds);