I'm working on a project that involves reading the content of a layer that is to be composited by the surfaceflinger.
I specifically need to check whether the layer to be composited is all 1-bits 0r all 0-bits.
This is to apply some optimizations before composition by the SurfaceFlinger.
I tracked the creation of the buffers via adb-logcat(by adding my own log messages) but couldn't find a way to read the actual contents of the layer.
Could anyone tell me if this is even possible, and if it is, how?
In general, it's not. For example, if the layer is displaying DRM-protected video, it's impossible to read the data.
For unprotected layers, you can read the pixel values out with glReadPixels()
-- there's some code in SurfaceFlinger's screenshot code that can be enabled to check for blank screenshots -- but this is going to be slow.
Bear in mind that not all layers are RGB. If the layer is YUV, an "all zero" layer would actually be a dull green.