使用QNX screen API填充屏幕显示
main.c
#include <stdio.h>
#include <stdint.h>
#include <unistd.h>
#include <stdlib.h>
#include <pthread.h>
#include "display.h"
struct display_context_t ctx = {
.id_string = "demo",
.display_index = 0,
.pipeline = 6,
.zorder = 5,
.property_buffer_size[0] = 4032,
.property_buffer_size[1] = 756,
.index_screen_buf = 0,
.property_source_pos[0] = 0,
.property_source_pos[1] = 0,
.property_source_size[0] = 4032,
.property_source_size[1] = 756,
.property_win_pos[0] = 0,
.property_win_pos[1] = 0,
.screen_property_size[0] = 4032,
.screen_property_size[1] = 756,
.screen_property_format = SCREEN_FORMAT_RGBA8888,
.picture_buffer_count = 2,
};
int main(int argc, char *argv[])
{
display_init(&ctx);
while(1)
{
int rect[4] = { 0, 0, 1, 1 };
rect[0] = rect[1] = 0;
rect[2] = 0;//width;
rect[3] = 0;//height;
uint32_t *p = (void *)ctx.picture_buffer[ctx.index_screen_buf];
for(int i = 0; i < 4032; i++)
{
for(int j = 0; j < 756; j++)
{
p[i * 756 + j] = 0x00FF0000;
}
}
if( screen_post_window(ctx.screen_win, ctx.screen_buf[ctx.index_screen_buf], 1, rect, 0) != 0)
{
SLOG_ERR( "screen_post_window() failed, errno = %d.", errno );
}
else
{
}
}
return 0;
}
display.h
#if ! defined(__DISPLAY_H__)
#define __DISPLAY_H__
#include <sys/strm.h>
#include <sys/stat.h>
#include <stdio.h>
#include <limits.h>
#include <pthread.h>
#include <sys/mman.h>
#include <screen/screen.h>
#include <string.h>
#include <unistd.h>
#include <stdlib.h>
//#define V_DEC_PICTURE_BUFF_COUNT 2
#define SLOG_ERR(fmt,...) do{printf(fmt,##__VA_ARGS__);printf("\n");}while(0);
#define SLOG_INFO SLOG_ERR
#define SLOG_DEBUG2 SLOG_ERR
struct display_context_t
{
char *id_string; /* /dev/screen/<pid>/id_string */
int display_index; /* display index defined i