Esempio n. 1
0
PPMdContext *NewPPMdContextAsChildOf(PPMdCoreModel *model,PPMdContext *suffixcontext,PPMdState *suffixstate,PPMdState *firststate)
{
	PPMdContext *context=OffsetToPointer(model->alloc,AllocContext(model->alloc));
	if(context)
	{
		context->LastStateIndex=0;
		context->Flags=0;
		SetPPMdContextSuffixPointer(context,suffixcontext,model);
		SetPPMdStateSuccessorPointer(suffixstate,context,model);
		if(firststate) *(PPMdContextOneState(context))=*firststate;
	}
	return context;
}
Esempio n. 2
0
TInt CFbsFont::DoGetFontTable(TGetFontTableParam* aParam) const
    {
    TInt ret = KErrGeneral;

    TPckgBuf<TOffsetLen> retBuf;
    ret = iFbs->SendCommand(EFbsMessGetFontTable, 
            TIpcArgs(iHandle, aParam->iTag, &retBuf));
    
    if (KErrNone == ret)
        {
        aParam->iLength = retBuf().iLen;
        aParam->iContent = OffsetToPointer(retBuf().iOffset, iFbs->HeapBase());
        }
    return ret;
    }
Esempio n. 3
0
/*
 * _bt_parallel_release() -- Complete the process of advancing the scan to a
 *		new page.  We now have the new value btps_scanPage; some other backend
 *		can now begin advancing the scan.
 */
void
_bt_parallel_release(IndexScanDesc scan, BlockNumber scan_page)
{
	ParallelIndexScanDesc parallel_scan = scan->parallel_scan;
	BTParallelScanDesc btscan;

	btscan = (BTParallelScanDesc) OffsetToPointer((void *) parallel_scan,
												  parallel_scan->ps_offset);

	SpinLockAcquire(&btscan->btps_mutex);
	btscan->btps_scanPage = scan_page;
	btscan->btps_pageStatus = BTPARALLEL_IDLE;
	SpinLockRelease(&btscan->btps_mutex);
	ConditionVariableSignal(&btscan->btps_cv);
}
uint32_t MoveUnitsUpVariantI(PPMdSubAllocatorVariantI *self,uint32_t oldoffs,int num)
{
	void *oldptr=OffsetToPointer(self,oldoffs);
	int index=self->Units2Index[num-1];

	if((uint8_t *)oldptr>self->UnitsStart+16*1024||oldoffs>self->BList[index].next) return oldoffs;

	void *ptr=RemoveBlockAfter(&self->BList[index],self);
	memcpy(ptr,oldptr,num*UNIT_SIZE);

	int newnum=self->Index2Units[index];
	if((uint8_t *)oldptr!=self->UnitsStart) InsertBlockAfter(&self->BList[index],oldptr,newnum,self);
	else self->UnitsStart+=newnum*UNIT_SIZE;

	return PointerToOffset(self,ptr);
}
Esempio n. 5
0
/** help DoExtendedFunction to perform KFontGetShaping function
@param aParam Input & output parameter block, 
if successful aParam->iShapeHeaderOutput points to the shape data.
@return KErrNone if successful, otherwise a system wide error code.
*/
TInt CFbsFont::DoFontGetShaping(TFontShapeFunctionParameters* aParam) const
	{
	if (!iHandle)
		{
		return KErrGeneral;
		}
	TPckgBuf<TShapeMessageParameters> sp;
	sp().iStart = aParam->iStart;
	sp().iEnd = aParam->iEnd;
	sp().iScript = aParam->iScript;
	sp().iLanguage = aParam->iLanguage;

	TInt offset = iFbs->SendCommand( EFbsMessShapeText,TIpcArgs(iHandle, aParam->iText, &sp));

	// Convert the returned offset to pointer relative to the heap base of the current process
	aParam->iShapeHeaderOutput = reinterpret_cast<const TShapeHeader*>(OffsetToPointer(offset, iFbs->HeapBase()));
	return aParam->iShapeHeaderOutput? KErrNone : KErrGeneral;
	}
Esempio n. 6
0
static uint32_t ShrinkUnitsBrimstone(PPMdSubAllocatorBrimstone *self,uint32_t oldoffs,int oldnum,int newnum)
{
	void *oldptr=OffsetToPointer(self,oldoffs);
	int oldindex=self->Units2Index[oldnum-1];
	int newindex=self->Units2Index[newnum-1];
	if(oldindex==newindex) return oldoffs;

	if(self->FreeList[newindex].next)
	{
		void *ptr=RemoveNode(self,newindex);
		memcpy(ptr,oldptr,I2B(self,newindex));
		InsertNode(self,oldptr,oldindex);
		return PointerToOffset(self,ptr);
	}
	else
	{
		SplitBlock(self,oldptr,oldindex,newindex);
		return oldoffs;
    }
}
static uint32_t ShrinkUnitsVariantI(PPMdSubAllocatorVariantI *self,uint32_t oldoffs,int oldnum,int newnum)
{
	void *oldptr=OffsetToPointer(self,oldoffs);
	int oldindex=self->Units2Index[oldnum-1];
	int newindex=self->Units2Index[newnum-1];
	if(oldindex==newindex) return oldoffs;

	if(AreBlocksAvailable(&self->BList[newindex]))
	{
		void *ptr=RemoveBlockAfter(&self->BList[newindex],self);
		memcpy(ptr,oldptr,newnum*UNIT_SIZE);
		InsertBlockAfter(&self->BList[oldindex],oldptr,self->Index2Units[oldindex],self);
		return PointerToOffset(self,ptr);
	}
	else
	{
		SplitBlock(self,oldptr,oldindex,newindex);
		return oldoffs;
    }
}
Esempio n. 8
0
/*
 * _bt_parallel_advance_array_keys() -- Advances the parallel scan for array
 *			keys.
 *
 * Updates the count of array keys processed for both local and parallel
 * scans.
 */
void
_bt_parallel_advance_array_keys(IndexScanDesc scan)
{
	BTScanOpaque so = (BTScanOpaque) scan->opaque;
	ParallelIndexScanDesc parallel_scan = scan->parallel_scan;
	BTParallelScanDesc btscan;

	btscan = (BTParallelScanDesc) OffsetToPointer((void *) parallel_scan,
												  parallel_scan->ps_offset);

	so->arrayKeyCount++;
	SpinLockAcquire(&btscan->btps_mutex);
	if (btscan->btps_pageStatus == BTPARALLEL_DONE)
	{
		btscan->btps_scanPage = InvalidBlockNumber;
		btscan->btps_pageStatus = BTPARALLEL_NOT_INITIALIZED;
		btscan->btps_arrayKeyCount++;
	}
	SpinLockRelease(&btscan->btps_mutex);
}
Esempio n. 9
0
/*
 *	btparallelrescan() -- reset parallel scan
 */
void
btparallelrescan(IndexScanDesc scan)
{
	BTParallelScanDesc btscan;
	ParallelIndexScanDesc parallel_scan = scan->parallel_scan;

	Assert(parallel_scan);

	btscan = (BTParallelScanDesc) OffsetToPointer((void *) parallel_scan,
												  parallel_scan->ps_offset);

	/*
	 * In theory, we don't need to acquire the spinlock here, because there
	 * shouldn't be any other workers running at this point, but we do so for
	 * consistency.
	 */
	SpinLockAcquire(&btscan->btps_mutex);
	btscan->btps_scanPage = InvalidBlockNumber;
	btscan->btps_pageStatus = BTPARALLEL_NOT_INITIALIZED;
	btscan->btps_arrayKeyCount = 0;
	SpinLockRelease(&btscan->btps_mutex);
}
Esempio n. 10
0
TInt CFbsFont::DoGetGlyphOutline(TGetGlyphOutlineParam* aParam) const
    {
    TInt ret = KErrGeneral;
    
    TPckgBuf<TFBSGlyphOutlineParam> paramsBuf;
    TInt count = aParam->iCount;
    paramsBuf().iCount = aParam->iCount;
    paramsBuf().iHinted = aParam->iHinted;
    paramsBuf().iHandle = iHandle;

    TOffsetLen* offsetLen = (TOffsetLen *)User::Alloc(count * sizeof(TOffsetLen));
    if (NULL == offsetLen)
        {
        return KErrNoMemory;
        }
    TPtr8 retBuf((TUint8 *)offsetLen, count * sizeof(TOffsetLen),
            count * sizeof(TOffsetLen));
    TPtr8 codes((TUint8 *)(aParam->iCodes), count * sizeof(TUint), 
            count * sizeof(TUint));
    
    ret = iFbs->SendCommand( EFbsMessGetGlyphOutline, 
            TIpcArgs(&paramsBuf, &codes, &retBuf));
    
    if (KErrNone == ret)
        {
        // server writes the offsets back to client, convert them
        // to local pointers.
        for (TInt i = 0; i < aParam->iCount; ++i)
            {
            aParam->iOutlines[i] = OffsetToPointer(offsetLen[i].iOffset, 
                    iFbs->HeapBase());
            aParam->iLengths[i] = offsetLen[i].iLen;
            }
        }
    User::Free(offsetLen);
    return ret;
    }
Esempio n. 11
0
PPMdContext *PPMdStateSuccessor(PPMdState *self,PPMdCoreModel *model)
{ return OffsetToPointer(model->alloc,self->Successor); }
static PPMdMemoryBlockVariantI *NextBlock(PPMdMemoryBlockVariantI *self,PPMdSubAllocatorVariantI *alloc)
{
	return OffsetToPointer(&alloc->core,self->next);
}
static void FreeUnitsVariantI(PPMdSubAllocatorVariantI *self,uint32_t offs,int num)
{
    int index=self->Units2Index[num-1];
	InsertBlockAfter(&self->BList[index],OffsetToPointer(self,offs),self->Index2Units[index],self);
}
/**
Helper function for Get(). 
Given a list of indices into a glyph code array, the corresponding glyph
codes are made into a single list sent to the server, and the received glyph
metrics are set in the array of metrics at the corresponding indices.

@param aFont The font to receive the glyph metrics of.
@param aArrayIndices An array of indices into the glyphcode array which
    will be sent for requesting of metrics to the server.
@param aArrayIndicesCount The number of glyphs in aGlyphArrayIndices.
@param aMetrics The array which will store the resulting metrics objects upon
    completion.
@return KErrNone if successful, otherwise one of the system-wide error codes. 

@panic FBSCLI 39 in debug builds only, if the parameters to this method are
    invalid, or if the output array is of the wrong size when appending to it.
 */
TInt RFbsGlyphMetricsArray::SendRecvGlyphMetrics(CFbsFont& aFont, TUint* aArrayIndices, TInt aArrayIndicesCount, RArray<TOpenFontCharMetrics>* aMetrics) const
    {
    __ASSERT_DEBUG(aArrayIndicesCount > 0, Panic(EFbsPanicGlyphDataIteratorInvalidState)); 
    __ASSERT_DEBUG(aArrayIndicesCount <= KMaxMetricsBatchSize, Panic(EFbsPanicGlyphDataIteratorInvalidState)); 
    __ASSERT_DEBUG(aArrayIndices, Panic(EFbsPanicGlyphDataIteratorInvalidState));
    TInt err = KErrNone;
    
    TUint glyphCodes[KMaxMetricsBatchSize];
    for (TInt i = 0; i < aArrayIndicesCount; ++i)
        {
        glyphCodes[i] = iGlyphCodes[aArrayIndices[i]];
        }
    
    TInt rcvdGlyphMetricsOffsets[KMaxMetricsBatchSize];
    TPckg<TUint[KMaxMetricsBatchSize]> argGlyphCodes(glyphCodes);
    TPckg<TInt[KMaxMetricsBatchSize]> argGlyphMetricsOffsets(rcvdGlyphMetricsOffsets);
    if (aArrayIndicesCount < KMaxMetricsBatchSize)
        {
        argGlyphCodes.SetLength(aArrayIndicesCount * sizeof(TUint));
        argGlyphMetricsOffsets.SetLength(aArrayIndicesCount * sizeof(TInt));
        }   
    err = aFont.iFbs->SendCommand(EFbsMessGetGlyphMetrics, TIpcArgs(aFont.iHandle, &argGlyphCodes, &argGlyphMetricsOffsets));
    
    if (err == KErrNone)
        {
        TInt numRcvdMetrics = argGlyphMetricsOffsets.Length() / sizeof(TInt);
        __ASSERT_DEBUG(argGlyphMetricsOffsets.Length() % sizeof(TInt) == 0, Panic(EFbsPanicGlyphMetricsArrayInvalidState));
        __ASSERT_DEBUG(numRcvdMetrics == aArrayIndicesCount, Panic(EFbsPanicGlyphMetricsArrayInvalidState));
        
        if (numRcvdMetrics == aArrayIndicesCount)
            {
            TInt arrayCount = aMetrics->Count();
            TUint8* heapBase = aFont.iFbs->HeapBase();
            for (TInt rcvdMetricsItem = 0; rcvdMetricsItem < numRcvdMetrics; ++rcvdMetricsItem)
                {
                TInt arrayIndex = aArrayIndices[rcvdMetricsItem];
                // The array should never need to grow more than one item. If the difference is larger, 
                // it means the glyph and the metrics are not in sync.
                __ASSERT_DEBUG(arrayIndex <= arrayCount, Panic(EFbsPanicGlyphMetricsArrayInvalidState));
                
                TInt metricsOffset = rcvdGlyphMetricsOffsets[rcvdMetricsItem];              
                const TOpenFontCharMetrics* metrics = (const TOpenFontCharMetrics*)(OffsetToPointer(metricsOffset, heapBase));
                
                if (arrayIndex < arrayCount)
                    {
                    // Copy metrics into existing element
                    (*aMetrics)[arrayIndex] = *metrics;
                    }
                else if (arrayIndex == arrayCount)
                    {
                    // Memory should already be reserved by GetGlyphMetricsArray()
                    (void) aMetrics->Append(*metrics);    
                    ++arrayCount;
                    }
                }
            }
        else
            {
            // did not receive the same number of glyphs as was asked.
            err = KErrGeneral;
            }
        }
    return err;
    }
Esempio n. 15
0
	for(;currcontext!=mincontext;currcontext=PPMdContextSuffix(currcontext,&self->core))
	{
		int currnum=currcontext->LastStateIndex+1;
		if(currnum!=1)
		{
			if((currnum&1)==0)
			{
				uint32_t states=ExpandUnits(self->core.alloc,currcontext->States,currnum>>1);
				if(!states) goto RESTART_MODEL;
				currcontext->States=states;
			}
			if(3*currnum-1<minnum) currcontext->SummFreq++;
		}
		else
		{
			PPMdState *states=OffsetToPointer(self->core.alloc,AllocUnits(self->core.alloc,1));
			if(!states) goto RESTART_MODEL;
			states[0]=*(PPMdContextOneState(currcontext));
			SetPPMdContextStatesPointer(currcontext,states,&self->core);

			if(states[0].Freq<MAX_FREQ/4-1) states[0].Freq*=2;
			else states[0].Freq=MAX_FREQ-4;

			currcontext->SummFreq=states[0].Freq+self->core.InitEsc+(minnum>3?1:0);
		}

		unsigned int cf=2*fs.Freq*(currcontext->SummFreq+6);
		unsigned int sf=s0+currcontext->SummFreq;
		unsigned int freq;

		if(cf<6*sf)
Esempio n. 16
0
PPMdContext *PPMdContextSuffix(PPMdContext *self,PPMdCoreModel *model)
{ return OffsetToPointer(model->alloc,self->Suffix); } 
Esempio n. 17
0
BOOL
FindFormToTrayAssignment(
    PFORMTRAYTABLE  pFormTrayTable,
    PWSTR           pTrayName,
    PWSTR           pFormName,
    PFINDFORMTRAY   pFindData
    )

/*++

Routine Description:

    Search for a form-to-tray assignment entry

Arguments:

    pFormTrayTable - Points to the form-to-tray assignment table to be searched
    pTrayName - Specifies the tray name to searched
    pFormName - Specifies the form name to searched
    pFindData - Points to a buffer for storing search result

Return Value:

    TRUE if the specified entry is found, FALSE otherwise

Note:

    If pTrayName or pFormName is NULL, it will act as wildcard and match anything.

    REMEMBER to call ResetFindFormData(pFindData) before calling this function
    for the very first time.

--*/

{
    PWORD   pNextEntry;
    PWSTR   pTray;
    PWSTR   pForm;

    pNextEntry = &pFormTrayTable->table[pFindData->nextEntry*3];

    while (pFindData->nextEntry < pFormTrayTable->count) {

        pFindData->nextEntry++;

        //
        // Translate byte offsets to string pointers
        //

        Assert(pNextEntry[0] && pNextEntry[1]);
        pTray = OffsetToPointer(pFormTrayTable, pNextEntry[0]);
        pForm = OffsetToPointer(pFormTrayTable, pNextEntry[1]);

        //
        // Either the tray and form name match what's requested 
        // Or the caller specified a wildcard
        //

        if ((pTrayName == NULL || wcscmp(pTrayName, pTray) == EQUAL_STRING) &&
            (pFormName == NULL || wcscmp(pFormName, pForm) == EQUAL_STRING))
        {
            pFindData->pTrayName = pTray;
            pFindData->pFormName = pForm;
            pFindData->flags = pNextEntry[2];
            return TRUE;
        }
        
        // Each table entry takes 3 WORDs

        pNextEntry += 3;
    }

    return FALSE;
}
Esempio n. 18
0
static void FreeUnitsBrimstone(PPMdSubAllocatorBrimstone *self,uint32_t offs,int num)
{
	InsertNode(self,OffsetToPointer(self,offs),self->Units2Index[num-1]);
}
Esempio n. 19
0
PPMdState *PPMdContextStates(PPMdContext *self,PPMdCoreModel *model)
{ return OffsetToPointer(model->alloc,self->States); }
static void FreeUnitsVariantH(PPMdSubAllocatorVariantH *self,uint32_t offs,int num)
{
	InsertNode(self,OffsetToPointer(self,offs),self->Units2Index[num-1]);
}