Example #1
0
int gAccel::blit(gSurface *dst, const gSurface *src, const eRect &p, const eRect &area, int flags)
{
#ifdef ATI_ACCEL
	ati_accel_blit(
		src->data_phys, src->x, src->y, src->stride,
		dst->data_phys, dst->x, dst->y, dst->stride, 
		area.left(), area.top(), area.width(), area.height(),
		p.x(), p.y());
	return 0;
#endif
#ifdef BCM_ACCEL
	if (!m_bcm_accel_state)
	{
		if (flags & (gPixmap::blitAlphaTest|gPixmap::blitAlphaBlend)) /* unsupported flags */
			return -1;
		unsigned long pal_addr = 0;
		int src_format = 0;
		if (src->bpp == 32)
			src_format = 0;
		else if ((src->bpp == 8) && src->clut.data)
		{
			src_format = 1;
			/* sync pal */
			int i;
			pal_addr = src->stride * src->y;
			unsigned long *pal = (unsigned long*)(((unsigned char*)src->data) + pal_addr);
			pal_addr += src->data_phys;
			for (i = 0; i < src->clut.colors; ++i)
				*pal++ = src->clut.data[i].argb() ^ 0xFF000000;
		} else
			return -1; /* unsupported source format */

		bcm_accel_blit(
			src->data_phys, src->x, src->y, src->stride, src_format,
			dst->data_phys, dst->x, dst->y, dst->stride, 
			area.left(), area.top(), area.width(), area.height(),
			p.x(), p.y(), p.width(), p.height(),
			pal_addr, flags);
		return 0;
	}
#endif
	return -1;
}
Example #2
0
void gFBDC::exec(const gOpcode *o)
{
	switch (o->opcode)
	{
	case gOpcode::setPalette:
	{
		gDC::exec(o);
		setPalette();
		break;
	}
	case gOpcode::flip:
	{
		if (surface_back.data_phys)
		{
			gUnmanagedSurface s(surface);
			surface = surface_back;
			surface_back = s;

			if (surface.data_phys > surface_back.data_phys)
				fb->setOffset(surface_back.y);
			else
				fb->setOffset(0);
		}
		break;
	}
	case gOpcode::waitVSync:
	{
		static timeval l;
		static int t;
		timeval now;

		if (t == 1000)
		{
			gettimeofday(&now, 0);

			int diff = (now.tv_sec - l.tv_sec) * 1000 + (now.tv_usec - l.tv_usec) / 1000;
			eDebug("[gFBDC] %d ms latency (%d fps)", diff, t * 1000 / (diff ? diff : 1));
			l = now;
			t = 0;
		}

		++t;

		fb->blit();
		fb->waitVSync();
		break;
	}
	case gOpcode::flush:
#ifdef USE_LIBVUGLES2
		if (gles_is_animation())
			gles_do_animation();
		else
			fb->blit();
#else
		fb->blit();
#endif
#if defined(CONFIG_HISILICON_FB)
		if(islocked()==0)
		{
			bcm_accel_blit(
				surface.data_phys, surface.x, surface.y, surface.stride, 0,
				surface_back.data_phys, surface_back.x, surface_back.y, surface_back.stride,
				0, 0, surface.x, surface.y,
				0, 0, surface.x, surface.y,
				0, 0);
		}
#endif
#ifdef HAVE_HISILICON_ACCEL
		dinibot_accel_notify();
#endif
		break;
	case gOpcode::sendShow:
	{
#ifdef HAVE_OSDANIMATION
		CFile::writeIntHex("/proc/stb/fb/animation_mode", 0x01);
#endif
#ifdef USE_LIBVUGLES2
		gles_set_buffer((unsigned int *)surface.data);
		gles_set_animation(1, o->parm.setShowHideInfo->point.x(), o->parm.setShowHideInfo->point.y(), o->parm.setShowHideInfo->size.width(), o->parm.setShowHideInfo->size.height());
#endif
		break;
	}
	case gOpcode::sendHide:
	{
#ifdef HAVE_OSDANIMATION
		CFile::writeIntHex("/proc/stb/fb/animation_mode", 0x10);
#endif
#ifdef USE_LIBVUGLES2
		gles_set_buffer((unsigned int *)surface.data);
		gles_set_animation(0, o->parm.setShowHideInfo->point.x(), o->parm.setShowHideInfo->point.y(), o->parm.setShowHideInfo->size.width(), o->parm.setShowHideInfo->size.height());
#endif
		break;
	}
#ifdef USE_LIBVUGLES2
	case gOpcode::setView:
	{
		gles_viewport(o->parm.setViewInfo->size.width(), o->parm.setViewInfo->size.height(), fb->Stride());
		break;
	}
#endif

	default:
		gDC::exec(o);
		break;
	}
}
Example #3
0
void gFBDC::exec(const gOpcode *o)
{
	switch (o->opcode)
	{
	case gOpcode::setPalette:
	{
		gDC::exec(o);
		setPalette();
		break;
	}
	case gOpcode::flip:
	{
		if (surface_back.data_phys)
		{
			gUnmanagedSurface s(surface);
			surface = surface_back;
			surface_back = s;

			if (surface.data_phys > surface_back.data_phys)
				fb->setOffset(surface_back.y);
			else
				fb->setOffset(0);
		}
		break;
	}
	case gOpcode::waitVSync:
	{
		static timeval l;
		static int t;
		timeval now;

		if (t == 1000)
		{
			gettimeofday(&now, 0);

			int diff = (now.tv_sec - l.tv_sec) * 1000 + (now.tv_usec - l.tv_usec) / 1000;
			eDebug("[gFBDC] %d ms latency (%d fps)", diff, t * 1000 / (diff ? diff : 1));
			l = now;
			t = 0;
		}

		++t;

		fb->blit();
		fb->waitVSync();
		break;
	}
	case gOpcode::flush:
		fb->blit();
#if defined(CONFIG_HISILICON_FB)
		if(islocked()==0)
		{
			bcm_accel_blit(
				surface.data_phys, surface.x, surface.y, surface.stride, 0,
				surface_back.data_phys, surface_back.x, surface_back.y, surface_back.stride,
				0, 0, surface.x, surface.y,
				0, 0, surface.x, surface.y,
				0, 0);
		}
#endif
		break;

#ifdef HAVE_OSDANIMATION
	case gOpcode::sendShow:
		CFile::writeIntHex("/proc/stb/fb/animation_mode", 0x01);
		break;
	case gOpcode::sendHide:
		CFile::writeIntHex("/proc/stb/fb/animation_mode", 0x10);
		break;
#endif

	default:
		gDC::exec(o);
		break;
	}
}
Example #4
0
int gAccel::blit(gSurface *dst, const gSurface *src, const eRect &p, const eRect &area, int flags)
{
#ifdef STMFB_ACCEL
	//eDebug( "src: %4d %4d %4d %4d\tdst: %4d %4d %4d %4d\n"
	//		"area: %4d %4d %4d %4d\tp: %4d %4d %4d %4d\n",
	//		src->data_phys, src->x, src->y, src->stride,
	//		dst->data_phys, dst->x, dst->y, dst->stride, 
	//		area.left(), area.top(), area.width(), area.height(),
	//		p.x(), p.y(), p.width(), p.height());

	int src_format = 0;
	void *data = 0;
     	int data_phys = 0;

	if (src->bpp == 32)
		src_format = 0;
	else if ((src->bpp == 8) && (dst->bpp == 32))
	{
		src_format = 1;
        	if(accelAlloc(data, data_phys, area.height() * area.width() * 4))
			return -1;

		__u8 *srcptr=(__u8*)src->data;
		__u8 *dstptr=(__u8*)data;
		__u32 pal[256];

		for (int i=0; i<256; ++i)
		{
			if (src->clut.data && (i<src->clut.colors))
				pal[i]=(src->clut.data[i].a<<24)|(src->clut.data[i].r<<16)|(src->clut.data[i].g<<8)|(src->clut.data[i].b);
			else
				pal[i]=0x010101*i;
			if((pal[i]&0xFF000000) >= 0xE0000000)
				pal[i] = 0xFF000000;
			pal[i]^=0xFF000000;
		}
		srcptr+=area.left()*src->bypp+area.top()*src->stride;

		for (int y=0; y<area.height(); y++)
		{
			int width=area.width();
			unsigned char *psrc=(unsigned char*)srcptr;
			__u32 *pdst=(__u32*)dstptr;

			while (width--)
				*pdst++=pal[*psrc++];

			srcptr+=src->stride;
			dstptr+=area.width() * 4;
		}
	} else {
		if(data_phys)
			accelFree(data_phys);
		return -1;
	}

	if(data_phys)
	{
		stmfb_accel_blit(
			data_phys, 0, 0, area.width() * 4, src_format,
			dst->data_phys, dst->x, dst->y, dst->stride,
			0, 0, area.width(), area.height(),
			p.x(), p.y(), p.width(), p.height());
		accelFree(data_phys);
	} else {
		stmfb_accel_blit(
			src->data_phys, src->x, src->y, src->stride, src_format,
			dst->data_phys, dst->x, dst->y, dst->stride,
			area.left(), area.top(), area.width(), area.height(),
			p.x(), p.y(), p.width(), p.height());
	}
	return 0;
#endif
#ifdef ATI_ACCEL
	ati_accel_blit(
		src->data_phys, src->x, src->y, src->stride,
		dst->data_phys, dst->x, dst->y, dst->stride, 
		area.left(), area.top(), area.width(), area.height(),
		p.x(), p.y());
	return 0;
#endif
#ifdef BCM_ACCEL
	if (!m_bcm_accel_state)
	{
		if (flags & (gPixmap::blitAlphaTest|gPixmap::blitAlphaBlend)) /* unsupported flags */
			return -1;
		unsigned long pal_addr = 0;
		int src_format = 0;
		if (src->bpp == 32)
			src_format = 0;
		else if ((src->bpp == 8) && src->clut.data)
		{
			src_format = 1;
			/* sync pal */
			int i;
			pal_addr = src->stride * src->y;
			unsigned long *pal = (unsigned long*)(((unsigned char*)src->data) + pal_addr);
			pal_addr += src->data_phys;
			for (i = 0; i < src->clut.colors; ++i)
				*pal++ = src->clut.data[i].argb() ^ 0xFF000000;
		} else
			return -1; /* unsupported source format */

		bcm_accel_blit(
			src->data_phys, src->x, src->y, src->stride, src_format,
			dst->data_phys, dst->x, dst->y, dst->stride, 
			area.left(), area.top(), area.width(), area.height(),
			p.x(), p.y(), p.width(), p.height(),
			pal_addr, flags);
		return 0;
	}
#endif
	return -1;
}