Beispiel #1
0
nuiModule *nuiFactory::create(const std::string &name)
{
	if (pipelineDescriptors.find(name) != pipelineDescriptors.end())
	{
		return createPipeline(pipelineDescriptors[name]);
	}
	if (moduleDescriptors.find(name) != moduleDescriptors.end())
	{
		nuiPluginFramework::nuiPluginEntity* module = NULL;
		if (nuiPluginManager::getInstance()->queryPluginObject((const nuiPluginFramework::nuiPluginEntity**)&module,name) == nuiPluginFrameworkOK)
			return (nuiModule*)module->getEntity();
		return NULL;
	}
	return NULL;
}
void RenderablePolyLineEntityItem::render(RenderArgs* args) {
    checkFading();

    QWriteLocker lock(&_quadReadWriteLock);
    if (_points.size() < 2 || _normals.size () < 2 || _strokeWidths.size() < 2) {
        return;
    }

    if (!_pipeline) {
        createPipeline();
    }

    if (!_texture || _texturesChangedFlag) {
        auto textureCache = DependencyManager::get<TextureCache>();
        QString path = _textures.isEmpty() ? PathUtils::resourcesPath() + "images/paintStroke.png" : _textures;
        _texture = textureCache->getTexture(QUrl(path));
        _texturesChangedFlag = false;
    }

    PerformanceTimer perfTimer("RenderablePolyLineEntityItem::render");
    Q_ASSERT(getType() == EntityTypes::PolyLine);
    Q_ASSERT(args->_batch);

    gpu::Batch& batch = *args->_batch;
    Transform transform = Transform();
    transform.setTranslation(getPosition());
    transform.setRotation(getRotation());
    batch.setUniformBuffer(0, _uniformBuffer);
    batch.setModelTransform(transform);

    batch.setPipeline(_pipeline);
    if (_texture->isLoaded()) {
        batch.setResourceTexture(PAINTSTROKE_GPU_SLOT, _texture->getGPUTexture());
    } else {
        batch.setResourceTexture(PAINTSTROKE_GPU_SLOT, args->_whiteTexture);
    }
   
    batch.setInputFormat(_format);
    batch.setInputBuffer(0, _verticesBuffer, 0, _format->getChannels().at(0)._stride);

    if (_isFading) {
        batch._glColor4f(1.0f, 1.0f, 1.0f, Interpolate::calculateFadeRatio(_fadeStartTime));
    }

    batch.draw(gpu::TRIANGLE_STRIP, _numVertices, 0);
};
	VulkanPipeline* VulkanGraphicsPipelineState::getPipeline(
		UINT32 deviceIdx, VulkanFramebuffer* framebuffer, UINT32 readOnlyFlags, DrawOperationType drawOp, 
			const SPtr<VulkanVertexInput>& vertexInput)
	{
		Lock(mMutex);

		if (mPerDeviceData[deviceIdx].device == nullptr)
			return nullptr;

		readOnlyFlags &= ~FBT_COLOR; // Ignore the color
		GpuPipelineKey key(framebuffer->getId(), vertexInput->getId(), readOnlyFlags, drawOp);

		PerDeviceData& perDeviceData = mPerDeviceData[deviceIdx];
		auto iterFind = perDeviceData.pipelines.find(key);
		if (iterFind != perDeviceData.pipelines.end())
			return iterFind->second;

		VulkanPipeline* newPipeline = createPipeline(deviceIdx, framebuffer, readOnlyFlags, drawOp, vertexInput);
		perDeviceData.pipelines[key] = newPipeline;

		return newPipeline;
	}
Beispiel #4
0
bool ofGstVideoPlayer::load(string name){
	if( name.find( "file://",0 ) != string::npos){
		bIsStream = bAsyncLoad;
	}else if( name.find( "://",0 ) == string::npos){
		GError * err = NULL;
		gchar* name_ptr = gst_filename_to_uri(ofToDataPath(name).c_str(),&err);
		name = name_ptr;
		g_free(name_ptr);
		if(err) g_free(err);
		//name = ofToDataPath(name);
		bIsStream = bAsyncLoad;
	}else{
		bIsStream = true;
	}
	ofLogVerbose("ofGstVideoPlayer") << "loadMovie(): loading \"" << name << "\"";

	if(isInitialized()){
		gst_element_set_state (videoUtils.getPipeline(), GST_STATE_READY);
		if(!bIsStream){
			gst_element_get_state (videoUtils.getPipeline(), NULL, NULL, -1);
		}
		internalPixelFormat = OF_PIXELS_NATIVE;
		bIsAllocated = false;
		videoUtils.reallocateOnNextFrame();
		g_object_set(G_OBJECT(videoUtils.getPipeline()), "uri", name.c_str(), (void*)NULL);
		gst_element_set_state (videoUtils.getPipeline(), GST_STATE_PAUSED);
		if(!bIsStream){
			gst_element_get_state (videoUtils.getPipeline(), NULL, NULL, -1);
			return allocate();
		}else{
			return true;
		}
	}else{
		ofGstUtils::startGstMainLoop();
		return createPipeline(name) &&
				videoUtils.startPipeline() &&
				(bIsStream || allocate());
	}
}
void
MinimalImpactTEDWriter::write(std::string filename) {

	updateInputs();

	// Create the internal pipeline
	createPipeline();

	// Remove the old file
	/*if( std::remove( filename ) != 0 ) {
		LOG_DEBUG(minimalImpactTEDlog) << "Old file to output minimal impact TED approximation sucessfully deleted." << std::endl;
	} 
	else {
		LOG_DEBUG(minimalImpactTEDlog) << "Could not delete old file to output minimal impact TED approximation." << std::endl;
	}*/

	 // Get a vector with all gold standard segments.
        const std::vector<boost::shared_ptr<Segment> > goldStandard = _goldStandard->getSegments();

	int constant = 0;

	LOG_DEBUG(minimalImpactTEDlog) << "in write function." << std::endl;

	// Loop through variables
	std::set<unsigned int> variables = _problemConfiguration->getVariables();
	for ( unsigned int varNum = 0 ; varNum < variables.size() ; varNum++ ) {

		// Introduce constraints that flip the segment corresponding to the ith variable
		// compared to the goldstandard.
	
		// Is the segment that corresponds to the variable part of the gold standard?
                unsigned int segmentId = _problemConfiguration->getSegmentId(varNum);

                bool isContained = false;
                foreach (boost::shared_ptr<Segment> s, goldStandard) {
                        if (s->getId() == segmentId) {
                                isContained = true;
                        }
                }
	
		LinearConstraint constraint;
		constraint.setRelation(Equal);

                if (isContained == true) {
			// Force segment to not be used in reconstruction
			constraint.setCoefficient(varNum,1.0);
			constraint.setValue(0);
                }
                else {
			// Force segment to be used in reconstruction
			constraint.setCoefficient(varNum,1.0);
			constraint.setValue(1);
                }

		_linearConstraints->add(constraint);
		
		_linearSolver->setInput("linear constraints",_linearConstraints);

		pipeline::Value<Errors> errors = _teDistance->getOutput("errors");
		unsigned int sumErrors = errors->getNumSplits() + errors->getNumMerges() + errors->getNumFalsePositives() + errors->getNumFalseNegatives();
		int sumErrorsInt = (int) sumErrors;

		if (isContained == true) {
			// Forced segment to not be part of the reconstruction.
			// This resulted in a number of errors that are going to be stored in the constant.
			// To make net 0 errors when the variable is on, minus the number of errors will be written to the file.

			writeToFile(filename, -sumErrorsInt, varNum, false);

			constant += sumErrorsInt;
		}
		else {
			// Forced segment to be part of the reconstruction.
			// This resulted in a number of errors that are going to be written to the file.

			writeToFile(filename, sumErrorsInt, varNum, false);
		}

		// Remove constraint
		_linearConstraints->removeLastConstraint();
	}

	// Write constant to file
	writeToFile(filename, constant, 0, true);
}
Beispiel #6
0
void
Sopnet::updateOutputs() {

	if (!_pipelineCreated)
		createPipeline();
}