Example #1
0
SkShader::Context* SkComposeShader::onCreateContext(const ContextRec& rec, void* storage) const {
    char* aStorage = (char*) storage + sizeof(ComposeShaderContext);
    char* bStorage = aStorage + fShaderA->contextSize(rec);

    // we preconcat our localMatrix (if any) with the device matrix
    // before calling our sub-shaders
    SkMatrix tmpM;
    tmpM.setConcat(*rec.fMatrix, this->getLocalMatrix());

    // Our sub-shaders need to see opaque, so by combining them we don't double-alphatize the
    // result. ComposeShader itself will respect the alpha, and post-apply it after calling the
    // sub-shaders.
    SkPaint opaquePaint(*rec.fPaint);
    opaquePaint.setAlpha(0xFF);

    ContextRec newRec(rec);
    newRec.fMatrix = &tmpM;
    newRec.fPaint = &opaquePaint;

    SkShader::Context* contextA = fShaderA->createContext(newRec, aStorage);
    SkShader::Context* contextB = fShaderB->createContext(newRec, bStorage);
    if (!contextA || !contextB) {
        safe_call_destructor(contextA);
        safe_call_destructor(contextB);
        return nullptr;
    }

    return new (storage) ComposeShaderContext(*this, rec, contextA, contextB);
}
SkShader::Context* SkComposeShader::onMakeContext(
    const ContextRec& rec, SkArenaAlloc* alloc) const
{
    // we preconcat our localMatrix (if any) with the device matrix
    // before calling our sub-shaders
    SkMatrix tmpM;
    tmpM.setConcat(*rec.fMatrix, this->getLocalMatrix());

    // Our sub-shaders need to see opaque, so by combining them we don't double-alphatize the
    // result. ComposeShader itself will respect the alpha, and post-apply it after calling the
    // sub-shaders.
    SkPaint opaquePaint(*rec.fPaint);
    opaquePaint.setAlpha(0xFF);

    ContextRec newRec(rec);
    newRec.fMatrix = &tmpM;
    newRec.fPaint = &opaquePaint;

    SkShader::Context* contextA = fShaderA->makeContext(newRec, alloc);
    SkShader::Context* contextB = fShaderB->makeContext(newRec, alloc);
    if (!contextA || !contextB) {
        return nullptr;
    }

    return alloc->make<ComposeShaderContext>(*this, rec, contextA, contextB);
}
Example #3
0
SkShader::Context* SkLocalMatrixShader::onCreateContext(const ContextRec& rec,
                                                        void* storage) const {
    ContextRec newRec(rec);
    SkMatrix tmp;
    if (rec.fLocalMatrix) {
        tmp.setConcat(*rec.fLocalMatrix, this->getLocalMatrix());
        newRec.fLocalMatrix = &tmp;
    } else {
        newRec.fLocalMatrix = &this->getLocalMatrix();
    }
    return fProxyShader->createContext(newRec, storage);
}
Example #4
0
void CSimpleReport::RowDown( bool (*copyFunc)(CSimpleReport*, CXTPReportRecord*, CXTPReportRecord*) )
{
	int rowidx = GetFocusedRow()->GetIndex();
	int recidx = GetFocusedRow()->GetRecord()->GetIndex();
	CXTPReportRecords* pRecs = GetRecords();
	if (!pRecs || recidx >= pRecs->GetCount() - 1)
		return;

	CXTPReportRecord* pRec = newRec();
	CXTPReportRecord* src = pRecs->GetAt(recidx);
	if (!pRec || !src)
		return;

	copyFunc(this, src, pRec);

	pRecs->RemoveAt(recidx);
	pRecs->InsertAt(recidx+1, pRec);

	Populate();
	SetFocusedRow(GetRows()->GetAt(rowidx+1));
	SetFocus();
}
Example #5
0
int main(int argc, char *argv[])
{
    char *filename;
    char *buf;
    char *tk;
    record vals;
    record *recp = &vals;
    FILE *fp;
    char guard[100];
    int idx = MINNAME;
    int lastval = 0;
    int lastmem = 0;

    if (argc != 2) {
	fprintf(stderr, "mkdefs: 1 argument necessary\n");
	exit(1);
    }
    filename = argv[1];

    vals.next = 0;
    buf = malloc(BSIZE);
    while (fgets(buf, BSIZE, stdin)) {
	lineno++;
	tokno = 0;
	tk = strTok(buf);
	if ((!tk) || (*tk == '#'))
	    continue;		/* comment */
	recp = newRec(recp);
	if (*tk == 'V')
	    recp->kind = K_val;
	else if (*tk == 'M')
	    recp->kind = K_member;
	else
	    recp->kind = 0;
	recp->data = buf;
	recp->symbol = tk;
	recp->name = strTok(0);
	recp->lex = strTok(0);
	recp->type = strTok(0);
	if (recp->kind) {
	    recp->domain = strTok(0);
	    recp->range = strTok(0);
	}
	buf = malloc(BSIZE);
    }

    fp = fopen(filename, "w");
    if (!fp) {
	fprintf(stderr, "mkdefs: Could not open %s for writing\n",
		filename);
	exit(1);
    }

    genGuard(filename, guard);
    fprintf(fp, header, guard, guard);
    fputs(prefix, fp);

    for (recp = vals.next; recp; recp = recp->next) {
	if (recp->kind == K_val)
	    lastval = idx;
	else if (recp->kind == K_member)
	    lastmem = idx;
	fprintf(fp, "#define\t%s\t% 5d\n", recp->symbol, idx++);
    }
    idx--;
    fprintf(fp, "\n#define LAST_V %d\n", lastval);
    fprintf(fp, "#define LAST_M %d\n", lastmem);
    fprintf(fp, "#define MINNAME %d\n#define MAXNAME %d\n\n", MINNAME,
	    idx);

    fprintf(fp, "static Exid_t symbols[] = {\n");
    for (recp = vals.next; recp; recp = recp->next) {
	fprintf(fp, "\tEXID ( %s, %s, %s, %s, 0),\n",
		recp->name, recp->lex, recp->symbol, recp->type);
    }
    fprintf(fp, "\tEXID ( {0}, 0, 0, 0, 0)\n};\n");

    fprintf(fp, "\nstatic char* typenames[] = {\n");
    for (recp = vals.next; recp; recp = recp->next) {
	if (*(recp->symbol) == 'T')
	    fprintf(fp, "\t%s,\n", recp->name);
    }
    fprintf(fp, "};\n");

#ifdef DEBUG
    fprintf(fp, "\nstatic char* gprnames[] = {\n\t\"\",\n");
    for (recp = vals.next; recp; recp = recp->next) {
	fprintf(fp, "\t\"%s\",\n", recp->symbol);
    }
    fprintf(fp, "};\n");
#endif

    fprintf(fp, "\ntypedef unsigned short tctype;\n");
    fprintf(fp, "\nstatic tctype tchk[][2] = {\n\t{ 0, 0 },\n");
    for (recp = vals.next; recp; recp = recp->next) {
	if (recp->kind)
	    fprintf(fp, "\t{ %s, %s },\n", recp->domain, recp->range);
    }
    fprintf(fp, "};\n");

    fprintf(fp, "\n#endif\n");
    fclose(fp);
    exit(0);
}
Example #6
0
//=============================================================================
//      e3ffw_3DMF_filter_in_toc : Adds the object to the TOC if needed and
//      returns a reference object
//-----------------------------------------------------------------------------
static TQ3Status
e3ffw_3DMF_filter_in_toc(TE3FFormatW3DMF_Data *fileFormatPrivate,  TQ3Object theObject , TQ3Object *theReference)
{
	const TQ3Uns32 TOC_GROW_SIZE = 1024;

	TE3FFormat3DMF_TOC	*toc = fileFormatPrivate->toc;
	TQ3Uns32			tocSize, i;

	TQ3Boolean			createReference = kQ3False;
	TQ3Boolean			forceTOC = kQ3False;
	
	switch (fileFormatPrivate->fileMode)
		{
		case kQ3FFormatWriterType3DMFStreamBin:
		case kQ3FFormatWriterType3DMFStreamBinSwap:
			// do nothing
			*theReference = Q3Shared_GetReference(theObject);
			return (kQ3Success);
			
		case kQ3FFormatWriterType3DMFDatabaseStreamBin:
		case kQ3FFormatWriterType3DMFDatabaseStreamBinSwap:
			forceTOC = kQ3True;
			break;
			
		case kQ3FFormatWriterType3DMFDatabaseBin:
		case kQ3FFormatWriterType3DMFDatabaseBinSwap:
			forceTOC = kQ3True;
		case kQ3FFormatWriterType3DMFNormalBin:
		case kQ3FFormatWriterType3DMFNormalBinSwap:
			createReference = kQ3True;
			break;
			
		}
		
	// if this is the first time allocate the TOC
	
	if(toc == NULL)
		{
		tocSize = sizeof(TE3FFormat3DMF_TOC) + 
				(sizeof(TE3FFormat3DMF_TOCEntry) * (TOC_GROW_SIZE - 1));
				
		toc = fileFormatPrivate->toc = (TE3FFormat3DMF_TOC*) Q3Memory_AllocateClear(tocSize);
		if(toc == NULL)
			return (kQ3Failure);
			
		toc->refSeed = 1;
		toc->typeSeed = -1;
		
		}
	
	if (fileFormatPrivate->index == NULL)
	{
		fileFormatPrivate->index = new TE3FFormatW3DMF_Map;
	}
	
	
	// If the object is already in the table of contents, we want to find it,
	// and if it is not, we will add it.  We need only search the index once.
	
	TE3FFormatW3DMF_Map::value_type newRec( theObject, toc->nEntries );
	
	std::pair< TE3FFormatW3DMF_Map::iterator, bool > insertResult =
		fileFormatPrivate->index->insert( newRec );
		
	if (insertResult.second) // inserted a new entry, so it was not there before
	{
		// make room for the new TOC entry

		if ((toc->nEntries != 0) && (toc->nEntries % TOC_GROW_SIZE == 0))
		{
			tocSize = static_cast<TQ3Uns32>(sizeof(TE3FFormat3DMF_TOC) + 
			
					(sizeof(TE3FFormat3DMF_TOCEntry) * (toc->nEntries + TOC_GROW_SIZE - 1)));
			if(Q3Memory_Reallocate(&fileFormatPrivate->toc,tocSize) != kQ3Success)
				return (kQ3Failure);
				
			toc = fileFormatPrivate->toc;
		}
			
		if (forceTOC == kQ3True)
		{
			toc->tocEntries[toc->nEntries].refID = toc->refSeed;
			toc->refSeed++;
		}
		else
			toc->tocEntries[toc->nEntries].refID = 0;
			
		toc->tocEntries[toc->nEntries].object = Q3Shared_GetReference(theObject);
		toc->tocEntries[toc->nEntries].objType = fileFormatPrivate->lastObjectType;
		toc->tocEntries[toc->nEntries].objLocation.hi = 0;
		toc->tocEntries[toc->nEntries].objLocation.lo = 0; // will be filled in e3ffw_3DMF_write_objects
		
		fileFormatPrivate->lastTocIndex = toc->nEntries;
		
		toc->nEntries++;
		
		
		*theReference = Q3Shared_GetReference(theObject);
	}
	else	// the object was already there
	{
		i = insertResult.first->second;
		
		if (createReference == kQ3True)
		{
			if (toc->tocEntries[i].refID == 0)
			{
				toc->tocEntries[i].refID = toc->refSeed;
				toc->refSeed++;
			}
				
			*theReference = E3ClassTree::CreateInstance(kQ3ShapeTypeReference, kQ3False, &toc->tocEntries[i].refID);
		}
		else
		{
			*theReference = Q3Shared_GetReference(theObject);
		}
	}
		
	return (kQ3Success);
}
Example #7
0
bool CSimpleReport::doCutPaste(CPoint pt, int op)
{
	CXTPReportSelectedRows* pRows = GetSelectedRows();
	if (pRows == NULL)
		return false;

	CXTPReportRow* pRow = pRows->GetAt(0);
	int nRow = 0;
	if (pRow)
		nRow = pRows->GetAt(0)->GetIndex();

	int n;
	CMenu menu;
	if (!menu.CreatePopupMenu())
		return false;

	if ((op & DO_ADD) != 0)	{
		menu.AppendMenu(MF_STRING, 10, "Add New");
		menu.AppendMenu(MF_STRING, 13, "Insert");
	}
	if (CanCopy() && (op & DO_COPY) != 0)
		menu.AppendMenu(MF_STRING, 11, "Copy");
	if (CanCut() && (op & DO_CUT) != 0)
		menu.AppendMenu(MF_STRING, 12, "Delete");

	n = menu.TrackPopupMenu(TPM_LEFTALIGN | TPM_LEFTBUTTON | TPM_RETURNCMD, pt.x, pt.y, this);
	menu.DestroyMenu();

	switch (n) {
		case 10:	// add
		case 13:	// insert
			{
				CXTPReportRecord* pRec = newRec();
				if (callback_add) {
					if (!callback_add(this, pRec)) {
						delete pRec;
						return false;
					}
				}
				RowInsert(pRec, (n == 10));
			}
			break;

		case 11:	// copy
			{
				pRow = GetFocusedRow();
				if (!pRow)
					return false;

				CXTPReportRecord* pSource = pRow->GetRecord();
				CXTPReportRecord* pTarget  = newRec();
		
				if (callback_copy) {
					if (!callback_copy(this, pSource, pTarget)) {
						delete pTarget;
						return false;
					}
				}
				RowInsert(pTarget);
			}
			break;
		case 12:	// delete
			{
				n = pRows->GetCount();
				for (int i = 0; i < n; i++) {
					if (callback_del) {
						CXTPReportRecord* pRec = pRows->GetAt(i)->GetRecord();
						if (!callback_del(this, pRec)) {
							return false;
						}
					}
				}

				for (int i = n - 1; i >= 0; i--) {
					pRow = pRows->GetAt(i);
					GetRecords()->RemoveAt(pRow->GetRecord()->GetIndex());
				}
				Populate();
				RowSetFocused(nRow);
			}
			break;
		default:
			return false;
	}
	return true;
}