[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"project-4325":3},{"id":4,"name":5,"fullName":6,"owner":7,"repo":5,"description":8,"homepage":9,"htmlUrl":10,"language":11,"languages":10,"totalLinesOfCode":10,"stars":12,"forks":13,"watchers":14,"openIssues":15,"contributorsCount":16,"subscribersCount":16,"size":16,"stars1d":16,"stars7d":16,"stars30d":17,"stars90d":16,"forks30d":16,"starsTrendScore":16,"compositeScore":18,"rankGlobal":10,"rankLanguage":10,"license":19,"archived":20,"fork":21,"defaultBranch":22,"hasWiki":21,"hasPages":21,"topics":23,"createdAt":10,"pushedAt":10,"updatedAt":24,"readmeContent":25,"aiSummary":26,"trendingCount":16,"starSnapshotCount":16,"syncStatus":17,"lastSyncTime":27,"discoverSource":28},4325,"grafika","google\u002Fgrafika","google","Grafika test app","",null,"Java",6155,1477,6154,54,0,2,40.51,"Apache License 2.0",true,false,"master",[],"2026-06-12 02:01:02","Grafika\n=======\n\nWelcome to Grafika, a dumping ground for Android graphics & media hacks.\n\nGrafika is:\n- A collection of hacks exercising graphics features.\n- An SDK app, developed for API 18 (Android 4.3).  While some of the code\n  may work with older versions of Android, some sporatic work is done to\n  support them.\n- Open source (Apache 2 license), copyright by Google.  So you can use the\n  code according to the terms of the license (see \"LICENSE\").\n- A perpetual work-in-progress.  It's updated whenever the need arises.\n\nHowever:\n- It's not stable.\n- It's not polished or well tested.  Expect the UI to be ugly and awkward.\n- It's not intended as a demonstration of the proper way to do things.\n  The code may handle edge cases poorly or not at all.  Logging is often\n  left enabled at a moderately verbose level.\n- It's barely documented.\n- It's not part of the Android Open Source Project.  We cannot accept\n  contributions to Grafika, even if you have an AOSP CLA on file.\n- It's NOT AN OFFICIAL GOOGLE PRODUCT.  It's just a bunch of stuff that\n  got thrown together on company time and equipment.\n- It's generally just not supported.\n\nTo some extent, Grafika can be treated as a companion to the\n[Android System-Level Graphics Architecture](http:\u002F\u002Fsource.android.com\u002Fdevices\u002Fgraphics\u002Farchitecture.html)\ndocument.  The doc explains the technology that the examples rely on, and uses some of\nGrafika's activities as examples.  If you want to understand how the code here works, start\nby reading that.\n\nThere is some overlap with the code on http:\u002F\u002Fwww.bigflake.com\u002Fmediacodec\u002F.\nThe code there largely consists of \"headless\" CTS tests, which are designed\nto be robust, self-contained, and largely independent of the usual app\nlifecycle issues.  Grafika is a conventional app, and makes an effort to\nhandle app issues correctly (like not doing lots of work on the UI thread).\n\nFeatures are added to Grafika as the need arises, often in response to\ndeveloper complaints about correctness or performance problems in the\nplatform (either to confirm that the problems exist, or demonstrate an\napproach that works).\n\nThere are two areas where some amount of care is taken:\n- Thread safety.  It's really easy to get threads crossed in subtly dangerous ways when\n  working with the media classes.  (Read the\n  [Android SMP Primer](http:\u002F\u002Fdeveloper.android.com\u002Ftraining\u002Farticles\u002Fsmp.html)\n  for a detailed introduction to the problem.)  GL\u002FEGL's reliance on thread-local storage\n  doesn't help.  Threading issues are frequently called out in comments in the source code.\n- Garbage collection.  GC pauses cause jank.  Ideally, none of the activities will do any\n  allocations while in a \"steady state\".  Allocations may occur while changing modes,\n  e.g. starting or stopping recording.\n\nAll code is written in the Java programming language -- the NDK is not used.\n\nThe first time Grafika starts, two videos are generated (gen-eight-rects, gen-sliders).\nIf you want to experiment with the generation code, you can cause them to be re-generated\nfrom the main activity menu (\"Regenerate content\").\n\nCurrent features\n----------------\n\n[* Play video (TextureView)](app\u002Fsrc\u002Fmain\u002Fjava\u002Fcom\u002Fandroid\u002Fgrafika\u002FPlayMovieActivity.java).  Plays the video track from an MP4 file.\n- Only sees files in `\u002Fdata\u002Fdata\u002Fcom.android.grafika\u002Ffiles\u002F`.  All of the activities that\n  create video leave their files there.  You'll also find two automatically-generated videos\n  (gen-eight-rects.mp4 and gen-slides.mp4).\n- By default the video is played once, at the same rate it was recorded.  You can use the\n  checkboxes to loop playback and\u002For play the frames at a fixed rate of 60 FPS.\n- Uses a `TextureView` for output.\n- Name starts with an asterisk so it's at the top of the list of activities.\n\n[Continuous capture](app\u002Fsrc\u002Fmain\u002Fjava\u002Fcom\u002Fandroid\u002Fgrafika\u002FContinuousCaptureActivity.java).  Stores video in a circular buffer, saving it when you hit the \"capture\" button.  (Formerly \"Constant capture\".)\n- Currently hard-wired to try to capture 7 seconds of video from the camera at 6MB\u002Fsec,\n  preferably 15fps 720p.  That requires a buffer size of about 5MB.\n- The time span of frames currently held in the buffer is displayed.  The actual\n  time span saved when you hit \"capture\" will be slightly less than what is shown because\n  we have to start the output on a sync frame, which are configured to appear once per second.\n- Output is a video-only MP4 file (\"constant-capture.mp4\").  Video is always 1280x720, which\n  usually matches what the camera provides; if it doesn't, the recorded video will have the\n  wrong aspect ratio.\n\n[Double decode](app\u002Fsrc\u002Fmain\u002Fjava\u002Fcom\u002Fandroid\u002Fgrafika\u002FDoubleDecodeActivity.java).  Decodes two video streams side-by-side to a pair of `TextureViews`.\n- Plays the two auto-generated videos.  Note they play at different rates.\n- The video decoders don't stop when the screen is rotated.  We retain the `SurfaceTexture`\n  and just attach it to the new `TextureView`.  Useful for avoiding expensive codec reconfigures.\n  The decoders *do* stop if you leave the activity, so we don't tie up hardware codec\n  resources indefinitely.  (It also doesn't stop if you turn the screen off with the power\n  button, which isn't good for the battery, but might be handy if you're feeding an external\n  display or your player also handles audio.)\n- Unlike most activities in Grafika, this provides different layouts for portrait and landscape.\n  The videos are scaled to fit.\n\n[Hardware scaler exerciser](app\u002Fsrc\u002Fmain\u002Fjava\u002Fcom\u002Fandroid\u002Fgrafika\u002FHardwareScalerActivity.java).  Shows GL rendering with on-the-fly surface size changes.\n- The motivation behind the feature this explores is described in a developer blog post:\n  http:\u002F\u002Fandroid-developers.blogspot.com\u002F2013\u002F09\u002Fusing-hardware-scaler-for-performance.html\n- You will see one frame rendered incorrectly when changing sizes.  This is because the\n  render size is adjusted in the \"surface changed\" callback, but the surface's size doesn't\n  actually change until we latch the next buffer.  This is straightforward to fix (left as\n  an exercise for the reader).\n\n[Live camera (TextureView)](app\u002Fsrc\u002Fmain\u002Fjava\u002Fcom\u002Fandroid\u002Fgrafika\u002FLiveCameraActivity.java).  Directs the camera preview to a `TextureView`.\n- This comes more or less verbatim from the [TextureView](http:\u002F\u002Fdeveloper.android.com\u002Freference\u002Fandroid\u002Fview\u002FTextureView.html) documentation.\n- Uses the default (rear-facing) camera.  If the device has no default camera (e.g.\n  Nexus 7 (2012)), the Activity will crash.\n\n[Multi-surface test](app\u002Fsrc\u002Fmain\u002Fjava\u002Fcom\u002Fandroid\u002Fgrafika\u002FMultiSurfaceTest.java).  Simple activity with three overlapping SurfaceViews, one marked secure.\n- Useful for examining HWC behavior with multiple static layers, and\n  screencap \u002F screenrecord behavior with a secure surface.  (If you record the screen one\n  of the circles should be missing, and capturing the screen should just show black.)\n- If you tap the \"bounce\" button, the circle on the non-secure layer will animate.  It will\n  update as quickly as possible, which may be slower than the display refresh rate because\n  the circle is rendered in software.  The frame rate will be reported in logcat.\n\n[Play video (SurfaceView)](app\u002Fsrc\u002Fmain\u002Fjava\u002Fcom\u002Fandroid\u002Fgrafika\u002FPlayMovieSurfaceActivity.java).  Plays the video track from an MP4 file.\n- Works very much like \"Play video (TextureView)\", though not all features are present.\n  See the class comment for a list of advantages to using SurfaceView.\n\n[Record GL app](app\u002Fsrc\u002Fmain\u002Fjava\u002Fcom\u002Fandroid\u002Fgrafika\u002FRecordFBOActivity.java).  Simultaneously draws to the display and to a video encoder with OpenGL ES, using framebuffer objects to avoid re-rendering.\n- It can write to the video encoder three different ways: (1) draw twice; (2) draw offscreen and\n  blit twice; (3) draw onscreen and blit framebuffer.  #3 doesn't work yet.\n- The renderer is trigged by Choreographer to update every vsync.  If we get too far behind,\n  we will skip frames.  This is noted by an on-screen drop counter and a border flash.  You\n  generally won't see any stutter in the animation, because we don't skip the object\n  movement, just the render.\n- The encoder is fed every-other frame, so the recorded output will be ~30fps rather than ~60fps\n  on a typical device.\n- The recording is letter- or pillar-boxed to maintain an aspect ratio that matches the\n  display, so you'll get different results from recording in landscape vs. portrait.\n- The output is a video-only MP4 file (\"fbo-gl-recording.mp4\").\n\n[Record Screen using MediaProjectionManager](app\u002Fsrc\u002Fmain\u002Fjava\u002Fcom\u002Fandroid\u002Fgrafika\u002FScreenRecordActivity.java).\nRecords the screen to a movie using the MediaProjectionManager.  This API\nrequires API level 23 (Marshmallow) or greater.\n\n[Scheduled swap](app\u002Fsrc\u002Fmain\u002Fjava\u002Fcom\u002Fandroid\u002Fgrafika\u002FScheduledSwapActivity.java).  Exercises a SurfaceFlinger feature that allows you to submit buffers to be displayed at a specific time.\n- Requires API 19 (Android 4.4 \"KitKat\") to do what it's supposed to.  The current implementation\n  doesn't really look any different on API 18 to the naked eye.\n- You can configure the frame delivery timing (e.g. 24fps uses a 3-2 pattern) and how far\n  in advance frames are scheduled.  Selecting \"ASAP\" disables scheduling.\n- Use systrace with tags `sched gfx view --app=com.android.grafika` to observe the effects.\n- The moving square changes colors when the app is unhappy about timing.\n\n[Show + capture camera](app\u002Fsrc\u002Fmain\u002Fjava\u002Fcom\u002Fandroid\u002Fgrafika\u002FCameraCaptureActivity.java).  Attempts to record at 720p from the front-facing camera, displaying the preview and recording it simultaneously.\n- Use the record button to toggle recording on and off.\n- Recording continues until stopped.  If you back out and return, recording will start again,\n  with a real-time gap.  If you try to play the movie while it's recording, you will see\n  an incomplete file (and probably cause the play movie activity to crash).\n- The recorded video is scaled to 640x480, so it will probably look squished.  A real app\n  would either set the recording size equal to the camera input size, or correct the aspect\n  ratio by letter- or pillar-boxing the frames as they are rendered to the encoder.\n- You can select a filter to apply to the preview.  It does not get applied to the recording.\n  The shader used for the filters is not optimized, but seems to perform well on most devices\n  (the original Nexus 7 (2012) being a notable exception).  Demo\n  here: http:\u002F\u002Fwww.youtube.com\u002Fwatch?v=kH9kCP2T5Gg\n- The output is a video-only MP4 file (\"camera-test.mp4\").\n\n[Simple Canvas in TextureView](app\u002Fsrc\u002Fmain\u002Fjava\u002Fcom\u002Fandroid\u002Fgrafika\u002FTextureViewCanvasActivity.java).  Exercises software rendering to a `TextureView` with a `Canvas`.\n- Renders as quickly as possible.  Because it's using software rendering, this will likely\n  run more slowly than the \"Simple GL in TextureView\" activity.\n- Toggles the use of a dirty rect every 64 frames.  When enabled, the dirty rect extends\n  horizontally across the screen.\n\n[Simple GL in TextureView](app\u002Fsrc\u002Fmain\u002Fjava\u002Fcom\u002Fandroid\u002Fgrafika\u002FTextureViewGLActivity.java).  Demonstates simple use of GLES in a `TextureView`, rather than a `GLSurfaceView`.\n- Renders as quickly as possible.  On most devices it will exceed 60fps and flicker wildly,\n  but in 4.4 (\"KitKat\") a bug prevents the system from dropping frames.\n\n[Texture from Camera](app\u002Fsrc\u002Fmain\u002Fjava\u002Fcom\u002Fandroid\u002Fgrafika\u002FTextureFromCameraActivity.java).  Renders Camera preview output with a GLES texture.\n- Adjust the sliders to set the size, rotation, and zoom.  Touch anywhere else to center\n  the rect at the point of the touch.\n\n[Color bars](app\u002Fsrc\u002Fmain\u002Fjava\u002Fcom\u002Fandroid\u002Fgrafika\u002FColorBarActivity.java).  Displays RGB color bars.\n\n[OpenGL ES Info](app\u002Fsrc\u002Fmain\u002Fjava\u002Fcom\u002Fandroid\u002Fgrafika\u002FGlesInfoActivity.java).  Dumps version info and extension lists.\n- The \"Save\" button writes a copy of the output to the app's file area.\n\n[glTexImage2D speed test](app\u002Fsrc\u002Fmain\u002Fjava\u002Fcom\u002Fandroid\u002Fgrafika\u002FTextureUploadActivity.java).  Simple, unscientific measurement of the time required to upload a 512x512 RGBA texture with `glTexImage2D()`.\n\n[glReadPixels speed test](app\u002Fsrc\u002Fmain\u002Fjava\u002Fcom\u002Fandroid\u002Fgrafika\u002FReadPixelsActivity.java).  Simple, unscientific measurement of the time required for `glReadPixels()` to read a 720p frame.\n\n\nKnown issues\n------------\n\n- Nexus 4 running Android 4.3 (JWR67E): \"Show + capture camera\" crashes if you select one of\n  the filtered modes.  Appears to be a driver bug (Adreno \"Internal compiler error\").\n\n\nFeature & fix ideas\n-------------------\n\nIn no particular order.\n\n- Stop using AsyncTask for anything where performance or latency matters.\n- Add a \"fat bits\" viewer for camera (single SurfaceView; left half has live camera feed\n  and a pan rect, right half has 8x pixels)\n- Change the \"Simple GL in TextureView\" animation.  Or add an epilepsy warning.\n- Cross-fade from one video to another, recording the result.  Allow specification of\n  the resolution (maybe QVGA, 720p, 1080p) and generate appropriately.\n- Add features to the video player, like a slider for random access, and buttons for\n  single-frame advance \u002F rewind (requires seeking to nearest sync frame and decoding frames\n  until target is reached).\n- Convert a series of PNG images to video.\n- Play continuous video from a series of MP4 files with different characteristics.  Will\n  probably require \"preloading\" the next movie to keep playback seamless.\n- Experiment with alternatives to glReadPixels().  Add a PBO speed test.  (Doesn't seem\n  to be a way to play with eglCreateImageKHR from Java.)\n- Do something with ImageReader class (req API 19).\n- Figure out why \"double decode\" playback is sometimes janky.\n- Add fps indicator to \"Simple GL in TextureView\".\n- Capture audio from microphone, record + mux it.\n- Enable preview on front\u002Fback cameras simultaneously, display them side-by-side.  (This\n  appears to be impossible except on specific devices.)\n- Add a test that renders to two different TextureViews using different EGLContexts\n  from a single renderer thread.\n\n","Grafika 是一个用于探索和测试 Android 图形及媒体功能的实验性应用。该项目提供了一系列针对图形特性的示例代码，使用 Java 语言编写，并支持 API 18（Android 4.3）及以上版本。其核心功能包括多种图形处理技术的实现，特别注重线程安全与垃圾回收优化，以减少界面卡顿现象。尽管 Grafika 的用户界面较为粗糙且缺乏详尽文档，但它非常适合开发者研究 Android 系统级图形架构、调试相关问题或验证特定图形处理方法的有效性。需要注意的是，Grafika 并非官方稳定产品，不接受外部贡献。","2026-06-11 02:59:40","top_language"]