示例#1
0
/*!
    \internal
    Creates a new hardware surface (usually on the Gfx card memory) with the dimensions \a w * \a h.
*/
static inline bool createHwSurface(QQnxScreenContext * const d, int w, int h)
{
    int ret = gf_surface_create_layer(&d->hwSurface, &d->layer, 1, 0,
                                      w, h, d->displayInfo.format, 0, 0);
    if (ret != GF_ERR_OK) {
        qWarning("QQnxScreen: gf_surface_create_layer(%dx%d) failed with error code %d", w, h, ret);
        return false;
    }

    gf_layer_set_surfaces(d->layer, &d->hwSurface, 1);

    gf_layer_enable(d->layer);

    ret = gf_layer_update(d->layer, 0);
    if (ret != GF_ERR_OK) {
        qWarning("QQnxScreen: gf_layer_update() failed with error code %d\n", ret);
        return false;
    }

    ret = gf_context_create(&d->context);
    if (ret != GF_ERR_OK) {
        qWarning("QQnxScreen: gf_context_create() failed with error code %d", ret);
        return false;
    }

    ret = gf_context_set_surface(d->context, d->hwSurface);
    if (ret != GF_ERR_OK) {
        qWarning("QQnxScreen: gf_context_set_surface() failed with error code %d", ret);
        return false;
    }

    return true;
}
示例#2
0
/* \internal
   Creates a QNX gf context and sets our memory surface on it.
 */
static bool createContext(QQnxScreenContext * const d)
{
    int ret = gf_context_create(&d->context);
    if (ret != GF_ERR_OK) {
        qWarning("QQnxScreen: gf_context_create() failed with error code %d", ret);
        return false;
    }

    ret = gf_context_set_surface(d->context, d->memSurface);
    if (ret != GF_ERR_OK) {
        qWarning("QQnxScreen: gf_context_set_surface() failed with error code %d", ret);
        return false;
    }

    return true;
}
示例#3
0
int
gf_setup(gf_setup_t *setup,
	int argc,
	char * const argv[],
	unsigned flags)
{
	gf_dev_t	gdev;
	unsigned	dispno = 0;
	const char 	*dev_name = NULL;
	int			layer_idx = GF_SETUP_LAYER_MAIN,
				rc,
				verbose = 0;
	gf_sid_t	sid = GF_SID_INVALID;
	unsigned	vx1 = 0, vx2 = ~0,
				vy1 = 0, vy2 = ~0;

	

	memset(setup, 0, sizeof *setup);

	setup->fname = strdup("tt0419m_.ttf");

#ifdef _MSC_VER
#else
	opterr = 0;

	while ((rc = getopt(argc, argv, "d:D:l:s:vx:y:f:")) != -1) {
		switch (rc) {
			case 'd':
				if (isdigit(*optarg)) {
					dev_name = GF_DEVICE_INDEX(atoi(optarg));
				} else {
					dev_name = optarg;
				}
				break;
			case 'D':
				dispno = atoi(optarg);
				break;
			case 'l':
				layer_idx = atoi(optarg);
				break;
			case 's':
				sid = (gf_sid_t)atoi(optarg);
				break;
			case 'v':
				verbose = ~0;
				break;
			case 'x':
				switch (*optarg++) {
					case '1':
						vx1 = atoi(optarg);
						break;
					case '2':
						vx2 = atoi(optarg);
						break;
					default:
						break;
				}

				break;
			case 'y':
				switch (*optarg++) {
					case '1':
						vy1 = atoi(optarg);
						break;
					case '2':
						vy2 = atoi(optarg);
						break;
					default:
						break;
				}

				break;
			case 'f':
				setup->fname = strdup(optarg);
				break;
			default:
				break;
		}
	}

#endif

	if ((rc = gf_dev_attach(&gdev, dev_name, NULL)) == GF_ERR_OK) {
		if (sid != GF_SID_INVALID) {
			gf_surface_t	surface;

			if ((rc = gf_surface_attach_by_sid(&surface, gdev, sid)) == GF_ERR_OK) {
				gf_context_t	context;

				if ((rc = gf_context_create(&context)) == GF_ERR_OK) {
					if ((rc = gf_context_set_surface(context, surface)) == GF_ERR_OK) {
						gf_surface_info_t	sinfo;

						gf_surface_get_info(surface, &sinfo);
						--sinfo.w;
						--sinfo.h;

						if (vx2 > sinfo.w) {
							vx2 = sinfo.w;
						}

						if (vy2 > sinfo.h) {
							vy2 = sinfo.h;
						}

						if (vx1 <= vx2 && vy1 <= vy2 &&
							(vx1 || vy1 || vx2 < sinfo.w || vy2 < sinfo.h)) {
							gf_context_set_clipping(context, vx1, vy1, vx2, vy2);
							setup->x1 = vx1;
							setup->x2 = vx2;
							setup->y1 = vy1;
							setup->y2 = vy2;
						}

						setup->surface1 = surface;
						setup->context = context;
						setup->gdev = gdev;

						return GF_ERR_OK;
					}

					gf_context_free(context);
				}

				gf_surface_free(surface);
			}
		} else {
			gf_display_t display;
			gf_display_info_t dinfo;

			if ((rc = gf_display_attach(&display, gdev, dispno, &dinfo)) == GF_ERR_OK) {
				gf_layer_t	layer;

				if (verbose) {
					fprintf(stderr, "Display %d:\n\tResolution: %dX%d\n",
						dispno, dinfo.xres, dinfo.yres);
					fprintf(stderr, "\tRefresh rate: %d\n\tPixel format: ", dinfo.refresh);
					switch (dinfo.format) {
						case GF_FORMAT_PAL8:
							fprintf(stderr, "PAL8");
							break;
						case GF_FORMAT_PACK_ARGB1555:
							fprintf(stderr, "ARGB1555");
							break;
						case GF_FORMAT_PACK_RGB565:
							fprintf(stderr, "RGB565");
							break;
						case GF_FORMAT_BGR888:
							fprintf(stderr, "BGR888");
							break;
						case GF_FORMAT_BGRA8888:
							fprintf(stderr, "BGRA8888");
							break;
						default:
							fprintf(stderr, "%x", (unsigned)dinfo.format);
							break;
					}

					fprintf(stderr, "\n\tNumber of layers: %d\n", dinfo.nlayers);
					fprintf(stderr, "\tMain layer index: %d\n", dinfo.main_layer_index);
				}

				if ((rc = gf_layer_attach(&layer, display, 
					layer_idx == GF_SETUP_LAYER_MAIN ? dinfo.main_layer_index : layer_idx,
					0)) == GF_ERR_OK) {
					gf_surface_t surface1, surface2 = NULL;
					int layer_format;

					layer_format = find_rgb_format(layer);
					if(verbose && layer_format != dinfo.format) {
						fprintf(stderr, "\tChoosing non-default layer format: ");
						switch (layer_format) {
							case GF_FORMAT_PAL8:
								fprintf(stderr, "PAL8");
								break;
							case GF_FORMAT_PACK_ARGB1555:
								fprintf(stderr, "ARGB1555");
								break;
							case GF_FORMAT_PACK_RGB565:
								fprintf(stderr, "RGB565");
								break;
							case GF_FORMAT_BGR888:
								fprintf(stderr, "BGR888");
								break;
							case GF_FORMAT_BGRA8888:
								fprintf(stderr, "BGRA8888");
								break;
							default:
								fprintf(stderr, "%x", (unsigned)layer_format);
								break;
						}
						fprintf(stderr, "\n");
					}
					dinfo.format = layer_format;

					if ((rc = gf_surface_create_layer(&surface1, &layer, 1, 0,
						dinfo.xres, dinfo.yres, 
						dinfo.format, NULL, 0)) == GF_ERR_OK &&
						(!(flags & GF_SETUP_FLAG_DBLBUFFER) || 
						 (rc = gf_surface_create_layer(&surface2, &layer, 1, 0,
						 dinfo.xres, dinfo.yres,
						 dinfo.format, NULL, 0)) == GF_ERR_OK)) {

						if (verbose) {
							gf_surface_info_t	sinfo;

							gf_surface_get_info(surface1, &sinfo);
							fprintf(stderr, "Surface:\n\tSID = %d\n", (unsigned)sinfo.sid);
							fprintf(stderr, "\tFlags = %x\n", sinfo.flags);
						}

						gf_layer_set_surfaces(layer, &surface1, 1);

						if ((rc = gf_layer_update(layer, 0)) == GF_ERR_OK) {
							gf_context_t context = NULL;

							if ((flags & GF_SETUP_FLAG_NOCONTEXT) ||
								((rc = gf_context_create(&context)) == GF_ERR_OK &&
								 (rc = gf_context_set_surface(context, surface1)) == GF_ERR_OK)) {
								setup->gdev = gdev;
								setup->display = display;
								memcpy(&setup->display_info, &dinfo, sizeof dinfo);
								setup->layer = layer;
								setup->surface1 = surface1;
								setup->surface2 = surface2;
								setup->context = context;
								return GF_ERR_OK;
							}
					
							if (context != NULL) {		
								gf_context_free(context);
							}
						}
					}
				}
			}
		}
	
		gf_dev_detach(gdev);
	}

	return rc;
}
示例#4
0
/*
 * Function : Framebuffer Driver Initializer
 *
 */
byte QNXGF_init(LIBAROMA_FBP me) {
  /* Allocating Internal Data */
  ALOGV("QNXGF Initialized Internal Data");
  QNXGF_INTERNALP mi = (QNXGF_INTERNALP) calloc(sizeof(QNXGF_INTERNAL),1);
  
  if (!mi) {
    ALOGE("QNXGF malloc internal data - Memory Error");
    return 0;
  }
  
  libaroma_mutex_init(___qnxfbmutex);

  /* Set Internal Address */
  me->internal      = (voidp) mi;
  me->release       = &QNXGF_release;
  me->double_buffer = 0; // 1;
  
  /************************* Init of Init QNX GF ******************************/
  /* Device Attach */
  if (gf_dev_attach(
        &mi->gdev, GF_DEVICE_INDEX(0), &mi->gdev_info
      ) != GF_ERR_OK) {
    ALOGE("QNXGF gf_dev_attach failed");
    goto error;
  }
  
  
  /* Display Attach */
  if (gf_display_attach(
        &mi->display, mi->gdev, 0, &mi->display_info
      ) != GF_ERR_OK) {
    ALOGE("QNXGF gf_display_attach failed");
    gf_dev_detach(mi->gdev);
    goto error;
  }
  /* Layer Attach */
  if (gf_layer_attach(
        &mi->layer, mi->display, 0, 0
      ) != GF_ERR_OK) {
    ALOGE("QNXGF gf_layer_attach failed");
    gf_display_detach(mi->display);
    gf_dev_detach(mi->gdev);
    goto error;
  }
  /* Create Surface */
  if (gf_surface_create_layer(
        &mi->surface, &mi->layer, 1, 0,
        mi->display_info.xres,
        mi->display_info.yres,
        GF_FORMAT_PKLE_RGB565,
        NULL, 0
      ) != GF_ERR_OK) {
    ALOGE("QNXGF gf_surface_create_layer failed");
    gf_layer_detach(mi->layer);
    gf_display_detach(mi->display);
    gf_dev_detach(mi->gdev);
    goto error;
  }
  /* Set Surface */
  gf_layer_set_surfaces(mi->layer, &mi->surface, 1);
  /* Create Context */
  if (gf_context_create(&mi->context) != GF_ERR_OK) {
    ALOGE("QNXGF gf_context_create failed");
    gf_surface_free(mi->surface);
    gf_layer_detach(mi->layer);
    gf_display_detach(mi->display);
    gf_dev_detach(mi->gdev);
    goto error;
  }
  /* Context Set Layer */
  if (gf_context_set_surface(mi->context, mi->surface) != GF_ERR_OK) {
    ALOGE("QNXGF gf_context_set_surface failed");
    gf_context_free(mi->context);
    gf_surface_free(mi->surface);
    gf_layer_detach(mi->layer);
    gf_display_detach(mi->display);
    gf_dev_detach(mi->gdev);
    goto error;
  }
  /*
  if (gf_display_set_dpms(mi->display,GF_DPMS_ON) != GF_ERR_OK) {
  	ALOGI("QNXGF gf_display_set_dpms failed");
  }
  else{
  	ALOGI("QNXGF gf_display_set_dpms OK");
  }
  */
  /************************* End of Init QNX GF *******************************/
  
  /* Set AROMA Core Framebuffer Instance Values */
  me->w       = mi->display_info.xres;            /* Width */
  me->h       = mi->display_info.yres;            /* Height */
  me->sz      = me->w * me->h;                    /* Width x Height */
  
  /* Set Callbacks */
  me->start_post  = &QNXGF_start_post;
  me->post        = &QNXGF_post;
  me->end_post    = &QNXGF_end_post;
  me->snapshoot   = NULL;
  
  /* DUMP INFO */
  QNXGF_dump(mi);
  /* Fixed DPI */
  me->dpi = 160;
  /* OK */
  goto ok;
  /* Return */
error:
  free(mi);
  return 0;
ok:
  return 1;
}