Welcome to Grafika, a dumping ground for Android graphics & media hacks.

Grafika is:


To some extent, Grafika can be treated as a companion to the Android System-Level Graphics Architecture document. The doc explains the technology that the examples rely on, and uses some of Grafika's activities as examples. If you want to understand how the code here works, start by reading that.

There is some overlap with the code on The code there largely consists of "headless" CTS tests, which are designed to be robust, self-contained, and largely independent of the usual app lifecycle issues. Grafika is a conventional app, and makes an effort to handle app issues correctly (like not doing lots of work on the UI thread).

Features are added to Grafika as the need arises, often in response to developer complaints about correctness or performance problems in the platform (either to confirm that the problems exist, or demonstrate an approach that works).

There are two areas where some amount of care is taken:

All code is written in the Java programming language -- the NDK is not used.

The first time Grafika starts, two videos are generated (gen-eight-rects, gen-sliders). If you want to experiment with the generation code, you can cause them to be re-generated from the main activity menu ("Regenerate content").

Current features

* Play video (TextureView). Plays the video track from an MP4 file.

Continuous capture. Stores video in a circular buffer, saving it when you hit the "capture" button. (Formerly "Constant capture".)

Double decode. Decodes two video streams side-by-side to a pair of TextureViews.

Hardware scaler exerciser. Shows GL rendering with on-the-fly surface size changes.

Live camera (TextureView). Directs the camera preview to a TextureView.

Multi-surface test. Simple activity with three overlapping SurfaceViews, one marked secure.

Play video (SurfaceView). Plays the video track from an MP4 file.

Record GL app. Simultaneously draws to the display and to a video encoder with OpenGL ES, using framebuffer objects to avoid re-rendering.

Record Screen using MediaProjectionManager. Records the screen to a movie using the MediaProjectionManager. This API requires API level 23 (Marshmallow) or greater.

Scheduled swap. Exercises a SurfaceFlinger feature that allows you to submit buffers to be displayed at a specific time.

Show + capture camera. Attempts to record at 720p from the front-facing camera, displaying the preview and recording it simultaneously.

Simple Canvas in TextureView. Exercises software rendering to a TextureView with a Canvas.

Simple GL in TextureView. Demonstates simple use of GLES in a TextureView, rather than a GLSurfaceView.

Texture from Camera. Renders Camera preview output with a GLES texture.

Color bars. Displays RGB color bars.

OpenGL ES Info. Dumps version info and extension lists.

glTexImage2D speed test. Simple, unscientific measurement of the time required to upload a 512x512 RGBA texture with glTexImage2D().

glReadPixels speed test. Simple, unscientific measurement of the time required for glReadPixels() to read a 720p frame.

Known issues

Feature & fix ideas

In no particular order.