android hwcomposer 抓取各个显示图层的raw显示数据
android 显示
amlogic 平台
void fill_color(void *vaddr)
{
int cnt;
unsigned int * p_data;
p_data = (unsigned int *)vaddr;
for( int i=0x00; i<256*1920; i++ ){
p_data[i] = 0xffff00ff;
}
}
//ctx->gralloc_module->base.registerBuffer(&(context->gralloc_module->base),display_ctx->fb_hnd);
//dump layer but need selinux permission: surfaceflinger default no permission to write
static void dump_layer_list(struct hwc_composer_device_1 * dev, hwc_display_contents_1_t * HwDisplay)
{
char value[PROPERTY_VALUE_MAX];
property_get("debug.sf.dumptofile", value, "0");
int dump = atoi(value);
struct hwc_context_1_t* ctx = (struct hwc_context_1_t *)dev;
// gralloc_module_t* module = dev->gralloc_module;
gralloc_module_t* module = &ctx->gralloc_module->base;
ALOGE( "dump = %d", dump );
ALOGE( "HwDisplay->numHwLayers = %d", HwDisplay->numHwLayers );
if (!dump || !HwDisplay || HwDisplay->numHwLayers < 2)
{
//return;
}
static int frame_count = 0;
frame_count++;
for (size_t i = 0; i < HwDisplay->numHwLayers - 1; i++)
{
hwc_layer_1_t * layer = &HwDisplay->hwLayers[i];
int cur_w, cur_h, format, size;
if ( layer->handle == NULL)
{ALOGE( "dump = xxxx layer->handle" );
continue;
}
private_handle_t* handle = ( private_handle_t*)layer->handle;
cur_w = handle->width;
cur_h = handle->height;
format = handle->format;
size = handle->size;
void *vaddr = (void *) handle->base;
module->lock(module, handle, GRALLOC_USAGE_SW_READ_OFTEN|GRALLOC_USAGE_SW_WRITE_OFTEN,
0, 0, cur_w, cur_h, &vaddr);
//GRALLOC_USAGE_SW_WRITE_OFTEN GRALLOC_USAGE_SW_READ_OFTEN
//memset( vaddr, 0xff, 512*1024 );
private_handle_t const* hnd = reinterpret_cast<private_handle_t const*>(layer->handle);
ALOGV("%d: hnd->flags 0x%x, %d-%d-%d-%d",i,hnd->flags,
layer->displayFrame.left,
layer->displayFrame.top,
layer->displayFrame.right - layer->displayFrame.left,
layer->displayFrame.bottom - layer->displayFrame.top);
over_layer_type overlayer_type = OVER_LAYER_VD1_NROMAL;
if ((hnd->flags & private_handle_t::PRIV_FLAGS_VIDEO_OVERLAY)){
fill_color(vaddr);
}
#if 0
//cur_w = HWC_ALIGN(cur_w, 16);
char fname[256] = "/data/misc/surface/Layer";
snprintf(fname, 256, "%s_%d-%d_%dx%d-%d.raw", fname, frame_count, i, cur_w, cur_h, format);
int fd = open(fname, O_CREAT | O_RDWR, 0666);
if(fd < 0)
{
ALOGE("open file failed %s:(errnor=%d)", fname, errno);
}
else
{
write(fd, vaddr, size);
close(fd);
}
#endif
module->unlock(module, handle);
}
}
更多推荐
所有评论(0)