Пример #1
0
// A match is a font object created for
//	1) the same rc type
//	2) the same fmi
//	3) the same accessor
// All fonts served by the native displayer can be shared
// irrespective of the accessor.
//
// So in the algorithm for a match of RcFmi2Font(), we will
// look for only sharable fonts.
//
struct nff *
wfFontObjectCache::RcFmi2Font(struct nfrc *rc, struct nffmi *fmi)
{
	struct nff *f = NULL;
	struct wfListElement *tmp = head;
    for (; tmp; tmp = tmp->next)
	  {
		struct font_store *ele = (struct font_store *) tmp->item;

		cfImpl *oimpl = nff2cfImpl(ele->f);
		FontObject *fob = (FontObject *)oimpl->object;
		if (!fob->isShared())
		{
			continue;
		}
		
		jint f_rcMajorType = nff_GetRcMajorType(ele->f, NULL);
		jint f_rcMinorType = nff_GetRcMinorType(ele->f, NULL);
		if (nfrc_IsEquivalent(rc, f_rcMajorType, f_rcMinorType, NULL)) {
			const char* eleFmiStr = nffmi_toString(ele->fmi, NULL);
			const char* fmiStr = nffmi_toString(fmi, NULL);
			if (eleFmiStr && fmiStr && !strcmp(eleFmiStr, fmiStr)) {
				f = ele->f;
				nff_addRef(f, NULL);
				break;
			}
		}
	  }
	return f;
}
Пример #2
0
void wfComplete(NET_StreamClass *stream)
{
	struct stream_data *data = (struct stream_data *) stream->data_object;
	void *fh = nfstrm_Complete((nfstrm *)data->fpStream, NULL);
	cfImpl *oimpl = cf2cfImpl(data->f);
	FontObject *fob = (FontObject *)oimpl->object;	
	if (fh)
	{
		// Include this fh in the correct FontObject
		fob->addFontHandle(data->fpPeer, fh);
		WF_TRACEMSG( ("NF: Stream done. Fonthandle created. Setting font state to COMPLETE.") );
		fob->setState(NF_FONT_COMPLETE);
	}
	else
	{
		// This font will never become ok as the fonthandle
		// that we got was 0. We will assume that the data
		// that we streamed didn't make a valid font.
		WF_TRACEMSG( ("NF: Stream done. Fonthandle NOT CREATED. Setting font state to ERROR.") );
		fob->setState(NF_FONT_ERROR);
	}
	
	// Notify the nfdoer on the status of Complete
	wf_NotifyObserver(data);
	wf_ReleaseStreamData(data);
	return;
}
Пример #3
0
/*ARGSUSED*/
_cf_GetState(struct cf* self, jint op, struct JMCException* *exceptionThrown)
{
	cfImpl *oimpl = cf2cfImpl(self);
	XP_ASSERT(oimpl->header.refcount);
	FontObject *fob = (FontObject *)oimpl->object;
	return((jint)fob->GetState());
}
Пример #4
0
/*ARGSUSED*/
_cf_GetMatchInfo(struct cf* self, jint op, struct nfrc *rc,
				 jint pointsize, struct JMCException* *exceptionThrown)
{
	cfImpl *oimpl = cf2cfImpl(self);
	XP_ASSERT(oimpl->header.refcount);
	FontObject *fob = (FontObject *)oimpl->object;
	return(fob->GetMatchInfo(rc, pointsize));
}
Пример #5
0
/*ARGSUSED*/
_cf_EnumerateSizes(struct cf* self, jint op, struct nfrc *rc,
				   struct JMCException* *exceptionThrown)
{
	cfImpl *oimpl = cf2cfImpl(self);
	XP_ASSERT(oimpl->header.refcount);
	FontObject *fob = (FontObject *)oimpl->object;
	return(fob->EnumerateSizes(rc));
}
Пример #6
0
int
wfFontObjectCache::releaseRf(struct nfrf *rf)
{
#ifdef DEBUG
	WF_TRACEMSG( ("NF: Deleting rf (0x%x).", rf) );
#endif /* DEBUG */

	struct wfListElement *tmp = head;
	int nrelease = 0;
    while(tmp)
	{
		struct font_store *ele = (struct font_store *) tmp->item;

		// We know that this Font object was created by us. So we can
		// snoop into its implementation to call implementation specific
		// methods.
		cfImpl *oimpl = cf2cfImpl(ele->f);
		FontObject *fob = (FontObject *)oimpl->object;

		//
		// WARNING: Before calling FontObject::releaseRf we need to get the
		// next item in the list. This is because the FontObject could turn
		// around and decide to remove itself from our list.
		//
		tmp = tmp->next;
		int n = fob->releaseRf(rf);
		if (n)
		{
			// Run the garbage collector since some rf was released. This
			// could even cause the font object to be deleted.
			if (!fob->GC())
			{
				struct nff *f_to_delete = (struct nff *) ele->f;

				// Delete the FontObject. Deleting the FontObject will turn
				// around and delete the element in the fontObjectCache list
				// by calling FontObjectCache::releaseFont().
				//
				// So DONT REMOVE THE ELEMENT. It will be removed.
				// wfList::remove(ele);

				nff_addRef(f_to_delete, NULL);
				nff_release(f_to_delete, NULL);
			}
		}
		nrelease += n;
	}

	if (nrelease)
	{
		// Some font had this rf. It is not possbile then for the same rf
		// exist with webfonts. Skip looking into the webfonts.
		return(nrelease);
	}
	return (nrelease);
}
Пример #7
0
bool
CWin32Platform::renderText(const char* utf8String, void * pFont, u32 color,
						   u16 width, u16 height, u8 * pBuffer8888,
						   s16 stride, s16 base_x, s16 base_y, bool use4444)
{
	FontObject* pObjFont = (FontObject*)pFont;
	if (pObjFont) {
		pObjFont->renderText(base_x, base_y, utf8String, pBuffer8888, color, width, height, stride, use4444);
	}
	return true;
}
Пример #8
0
void *
CWin32Platform::getFont(int size, const char * fontName, float* pAscent)
{
	FontObject* pFont = FontObject::createFont(fontName, size);
	if (pFont) {
		// pFont->
		if (pAscent) {
			*pAscent = pFont->getAscent();
		}
	}
	return pFont;
}
Пример #9
0
void wfAbort(NET_StreamClass *stream, int status)
{
	struct stream_data *data = (struct stream_data *) stream->data_object;
	nfstrm_Abort((nfstrm *)data->fpStream, (jint) status, NULL);

	// Mark the font as in error
	cfImpl *oimpl = cf2cfImpl(data->f);
	FontObject *fob = (FontObject *)oimpl->object;
	fob->setState(NF_FONT_ERROR);	
	
	// Notify nfdoer with status of Abort
	wf_NotifyObserver(data);
	wf_ReleaseStreamData(data);
	return;
}
Пример #10
0
/*ARGSUSED*/
_cf_release(struct cf* self, jint op, JMCException* *exc)
{
	cfImplHeader* impl = (cfImplHeader*)cf2cfImpl(self);
	--impl->refcount;

	// Run the GC
	cfImpl *oimpl = cf2cfImpl(self);
	FontObject *fob = (FontObject *)oimpl->object;
	int ret = fob->GC();
	
	if (impl->refcount == 0)
	{
		cf_finalize(self, exc);
	}
}
Пример #11
0
bool
CWin32Platform::getTextInfo(const char* utf8String, void * pFont, STextInfo* pReturnInfo)
{
	FontObject* pF = (FontObject*)pFont;
	if (pF) {
		pF->getTextInfo(utf8String, pReturnInfo);
	} else {
		pReturnInfo->ascent		= 0.0f;
		pReturnInfo->descent	= 0.0f;
		pReturnInfo->bottom		= 0.0f;
		pReturnInfo->top		= 0.0f;
		pReturnInfo->width		= 0.0f;
		pReturnInfo->height		= 0.0f;
	}
	return true;
}
Пример #12
0
struct nff *
wfFontObjectCache::
Rf2Font(struct nfrf *rf)
{
	struct nff *f = NULL;
	struct wfListElement *tmp = head;
    for (; tmp; tmp = tmp->next)
	  {
		struct font_store *ele = (struct font_store *) tmp->item;

		// We know that this Font object was created by us. So we can
		// snoop into its implementation to call implementation specific
		// methods.
		cfImpl *oimpl = cf2cfImpl(ele->f);
		FontObject *fob = (FontObject *)oimpl->object;
		if (fob->isRfExist(rf))
		  {
			f = ele->f;
			nff_addRef((struct nff *)f, NULL);
			break;
		  }
	  }
	return f;
}