Esempio n. 1
0
void TextNode::renderItself(RenderContext& renderContext)
{
    NVGcontext& nanoVgContext = renderContext.getNanoVgContext();
    nvgSave(&nanoVgContext);

    setupContext(nanoVgContext);

    Color finalColor = mFontColor.getBlendedColor(renderContext.getBlendColors());
    nvgFillColor(&nanoVgContext, nvgRGBAf(finalColor.getRed(), finalColor.getGreen(),
            finalColor.getBlue(), finalColor.getAlpha()));

    for(const Text& text : mTexts)
    {
        const char* charArray = text.getString().getCharArray();
        float positionX = text.getPosition().getX();
        float positionY = text.getPosition().getY();
        if(isPositive(text.getBoxWidth()))
        {
            nvgTextBox(&nanoVgContext, positionX, positionY, text.getBoxWidth(), charArray, nullptr);
        }
        else
        {
            nvgText(&nanoVgContext, positionX, positionY, charArray, nullptr);
        }
    }

    nvgRestore(&nanoVgContext);

    Node::renderItself(renderContext);
}
Esempio n. 2
0
Rect TextNode::generateBoundingBox()
{
    Rect boundingBox = Node::generateBoundingBox();

    if(mFontColor.isVisible())
    {
        NVGcontext& nanoVgContext = Application::getNanoVgContext();
        nvgSave(&nanoVgContext);

        float bounds[4];
        setupContext(nanoVgContext);

        for(const Text& text : mTexts)
        {
            const char* charArray = text.getString().getCharArray();
            float positionX = text.getPosition().getX();
            float positionY = text.getPosition().getY();
            if(isPositive(text.getBoxWidth()))
            {
                nvgTextBoxBounds(&nanoVgContext, positionX, positionY, text.getBoxWidth(),
                        charArray, nullptr, bounds);
            }
            else
            {
                nvgTextBounds(&nanoVgContext, positionX, positionY, charArray, nullptr, bounds);
            }

            boundingBox.join(Rect(Point(bounds[0], bounds[1]), Point(bounds[2], bounds[3])));
        }

        nvgRestore(&nanoVgContext);
    }

    return boundingBox;
}
Esempio n. 3
0
void SchedulerCPU::SetupNode(GraphicsTask& task, const FrameContextEx& context) {
	// Setup given node.
	SetupContext setupContext(context.memoryManager,
							  context.textureSpace,
							  context.rtvHeap,
							  context.dsvHeap,
							  context.shaderManager,
							  context.gxApi);
	task.Setup(setupContext);
}
Esempio n. 4
0
void TextNode::getTextMetrics(float& ascender, float& descender, float& lineHeight) const
{
    NVGcontext& nanoVgContext = Application::getNanoVgContext();
    nvgSave(&nanoVgContext);

    setupContext(nanoVgContext);

    nvgTextMetrics(&nanoVgContext, &ascender, &descender, &lineHeight);

    nvgRestore(&nanoVgContext);
}
//
// The Session's init() function calls your setupContext() method to prepare
// it for action, then calls the context's init() method.
//
CSPContext *CSPFullPluginSession::init(CSSM_CC_HANDLE ccHandle,
									CSSM_CONTEXT_TYPE type,
									const Context &context, bool encoding)
{
    CSPContext *ctx = getContext<CSPContext>(ccHandle);
    checkOperation(context.type(), type);

    // ask the implementation to set up an internal context
    setupContext(ctx, context, encoding);
    assert(ctx != NULL);	// must have context now (@@@ throw INTERNAL_ERROR instead?)
    ctx->mType = context.type();
    ctx->mDirection = encoding;
    setContext(ccHandle, ctx);

    // initialize the context and return it
    ctx->init(context, encoding);
    return ctx;
}
void SplitCookieResultMapperTest::ConfiguredTests() {
	StartTrace(SplitCookieResultMapperTest.ConfiguredTests);
	ROAnything caseConfig;
	AnyExtensions::Iterator<ROAnything, ROAnything, TString> aEntryIterator(GetTestCaseConfig());
	while (aEntryIterator.Next(caseConfig)) {
		TString caseName;
		if (!aEntryIterator.SlotName(caseName)) {
			t_assertm(false, "can not execute with unnamed case name, only named anything slots allowed");
			continue;
		}
		String putKeyName = caseConfig["Putkey"].AsString("HTTPHeader");
		if (t_assertm(setupMappers(caseConfig["MapperConfig"]), "ResultMapper setup must succeed to execute tests")) {
			String mapperName = caseConfig["MapperConfig"].SlotName(0L);
			ResultMapper *rm = ResultMapper::FindResultMapper(mapperName);
			if (t_assertm(rm != 0, TString("could not find mapper [") << mapperName.cstr() << "]")) {
				Context ctx;
				setupContext(caseConfig, ctx);
				ROAnything roaValue;
				if (caseConfig.LookupPath(roaValue, _Value)) {
					Anything value = roaValue.DeepClone();
					t_assertm(rm->Put(putKeyName, value, ctx), caseName);
				} else  if (caseConfig.LookupPath(roaValue, _Stream)) {
					String strValue = roaValue.AsString();
					IStringStream stream(strValue);
					t_assertm(rm->Put(putKeyName, stream, ctx), caseName);
				} else {
					t_assertm(false, TString("neither ").Append(_Value).Append(" nor ").Append(_Stream).Append(" is defined in configuration for ").Append(caseName));
					continue;
				}
				Anything anyFailureStrings;
				coast::testframework::CheckStores(anyFailureStrings, caseConfig["Result"], ctx, caseName, coast::testframework::exists);
				// non-existence tests
				coast::testframework::CheckStores(anyFailureStrings, caseConfig["NotResult"], ctx, caseName,
						coast::testframework::notExists);
				for (long sz = anyFailureStrings.GetSize(), i = 0; i < sz; ++i) {
					t_assertm(false, anyFailureStrings[i].AsString().cstr());
				}
			}
			unregisterMappers();
		}
	}
}
Esempio n. 7
0
static std::tuple<std::unique_ptr<BasicCommandList>, std::unique_ptr<VolatileViewHeap>> ExecuteUploadTask(const FrameContext& context) {
	UploadTask uploadTask(context.uploadRequests);
	SetupContext setupContext(context.memoryManager,
		context.textureSpace,
		context.rtvHeap,
		context.dsvHeap,
		context.shaderManager,
		context.gxApi);
	RenderContext renderContext(context.memoryManager,
		context.textureSpace,
		context.shaderManager,
		context.gxApi,
		context.commandListPool,
		context.commandAllocatorPool,
		context.scratchSpacePool,
		nullptr);
	uploadTask.Setup(setupContext);
	uploadTask.Execute(renderContext);
	std::unique_ptr<BasicCommandList> uploadInherit, uploadList;
	std::unique_ptr<VolatileViewHeap> uploadVheap;
	renderContext.Decompose(uploadInherit, uploadList, uploadVheap);
	return { std::move(uploadList), std::move(uploadVheap) };
}
Esempio n. 8
0
	bool BaseWindow::run(){
		if(!setupContext()) return false;
		gameLoop();
		if(!cleanupContext()) return false;
		return true;
	}