コード例 #1
0
bool FileLoader::ReadPageCount(const QString& fileName, int *num1, int *num2, QStringList & masterPageNames)
{
	QList<FileFormat>::const_iterator it;
	if (findFormat(FileType, it))
		return (*it).readPageCount(fileName, num1, num2, masterPageNames);
	return false;
}
コード例 #2
0
ファイル: texture.cpp プロジェクト: rokuz/DemoScene
bool Texture::init(const std::string & fileName)
{
    destroy();

    stbi_set_flip_vertically_on_load(true);
    int width, height, components;
    uint8_t * imageData = stbi_load(fileName.c_str(), &width, &height, &components, STBI_rgb_alpha);
    if (imageData == nullptr)
    {
        common::Logger::toLogWithFormat("Error: could not load file '%s'.\n", fileName.c_str());
        return false;
    }

    m_format = findFormat(components);
    if (m_format == -1)
    {
        common::Logger::toLogWithFormat("Error: format of file '%s' is unknown.\n", fileName.c_str());
        if (imageData != nullptr)
            stbi_image_free(imageData);
        return false;
    }

    bool result = initWithData(m_format, imageData, width, height, true, -1);

    if (imageData != nullptr)
        stbi_image_free(imageData);

    return result;
}
コード例 #3
0
ファイル: fileloader.cpp プロジェクト: HOST-Oman/scribus
bool FileLoader::loadPage(ScribusDoc* currDoc, int PageToLoad, bool Mpage, QString renamedPageName)
{
	bool ret = false;
// 	newReplacement = false;
	m_ReplacedFonts = currDoc->AllFonts->getSubstitutions();
// 	dummyScFaces.clear();
	QList<FileFormat>::const_iterator it;
	if (findFormat(m_fileType, it))
	{
		if (m_fileType == FORMATID_SLA12XIMPORT)
		{
			it->plug->setupTargets(currDoc, currDoc->view(), currDoc->scMW(), currDoc->scMW()->mainWindowProgressBar, &(m_prefsManager->appPrefs.fontPrefs.AvailFonts));
			ret = it->plug->loadPage(m_fileName, PageToLoad, Mpage, renamedPageName);
// 			if (ret)
// 				it->plug->getReplacedFontData(newReplacement, ReplacedFonts, dummyScFaces);
		}
		if (m_fileType == FORMATID_SLA13XIMPORT || m_fileType == FORMATID_SLA134IMPORT || m_fileType == FORMATID_SLA150IMPORT)
		{
			it->plug->setupTargets(currDoc, 0, currDoc->scMW(), currDoc->scMW()->mainWindowProgressBar, &(m_prefsManager->appPrefs.fontPrefs.AvailFonts));
			ret = it->plug->loadPage(m_fileName, PageToLoad, Mpage, renamedPageName);
// 			if (ret)
// 				it->plug->getReplacedFontData(newReplacement, ReplacedFonts, dummyScFaces);
		}
	}
	if (ret)
		ret = postLoad(currDoc);  // FIXME: return false if user doesn't want to replace fonts??

	return ret;
}
コード例 #4
0
ファイル: kimportdialog.cpp プロジェクト: serghei/kde3-kdepim
void KImportDialog::setData(uint row, uint col, const QString &value)
{
    QString val = value;
    val.replace("\\n", "\n");

    if(row >= mData.count())
    {
        mData.resize(row + 1);
    }

    QValueVector<QString> *rowVector = mData[ row ];
    if(!rowVector)
    {
        rowVector = new QValueVector<QString>;
        mData.insert(row, rowVector);
    }
    if(col >= rowVector->size())
    {
        rowVector->resize(col + 1);
    }

    KImportColumn *c = mColumnDict.find(col);
    if(c)
        rowVector->at(col) = c->preview(val, findFormat(col));
    else
        rowVector->at(col) = val;
}
コード例 #5
0
bool FileLoader::ReadLineStyles(const QString& fileName, QMap<QString,multiLine> *Sty)
{
	QList<FileFormat>::const_iterator it;
	if (findFormat(FileType, it))
		return (*it).readLineStyles(fileName, Sty);
	return false;
}
コード例 #6
0
ファイル: CAudioFormat.cpp プロジェクト: Siv3D/OpenSiv3D
	Wave CAudioFormat::decode(IReader&& reader, AudioFormat format) const
	{
		if (format == AudioFormat::Unknown)
		{
			format = getFormatFromReader(reader, String());
		}

		const auto it = findFormat(format);

		if (it == m_audioFormats.end())
		{
			return Wave();
		}

	# if defined(SIV3D_TARGET_MACOS)

		if ((*it)->format() == AudioFormat::AAC)
		{
			detail::TemporaryFile tmp(reader);
			
			return (*it)->decodeFromFile(tmp.path());
		}

	# endif

		return (*it)->decode(reader);
	}
コード例 #7
0
ファイル: fileloader.cpp プロジェクト: HOST-Oman/scribus
bool FileLoader::readColors(ColorList & colors)
{
	QList<FileFormat>::const_iterator it;
	if (findFormat(m_fileType, it))
		return it->readColors(m_fileName, colors);
	return false;
}
コード例 #8
0
ファイル: loadsaveplugin.cpp プロジェクト: luzpaz/scribus
const QStringList LoadSavePlugin::getExtensionsForColors(const int id)
{
	QList<FileFormat>::const_iterator it(findFormat(id));
	QList<FileFormat>::const_iterator itEnd(formats.constEnd());
	QStringList filterList;
	// We know the list is sorted by id, then priority, so we can just take the
	// highest priority entry for each ID, and we can start with the first entry
	// in the list.
	//First, check if we even have any plugins to load with
	if (it != itEnd)
	{
		if ((it->load) && (it->colorReading))
			filterList.append(it->fileExtensions);
		unsigned int lastID = it->formatId;
		++it;
		for ( ; it != itEnd ; ++it)
		{
			// Find the next load/save (as appropriate) plugin for the next format type
			if (((it->load) && (it->colorReading)) && (it->formatId > lastID))
			{
				// And add it to the filter list, since we know it's 
				// the highest priority because of the sort order.
				filterList.append(it->fileExtensions);
				lastID = it->formatId;
			}
		}
	}
	else
		qDebug("%s", tr("No File Loader Plugins Found").toLocal8Bit().data());
	// Avoid duplicate entries in the list
	QSet<QString> fSet = filterList.toSet();
	filterList = fSet.toList();
	qSort(filterList);
	return filterList;
}
コード例 #9
0
ファイル: fileloader.cpp プロジェクト: HOST-Oman/scribus
bool FileLoader::readLineStyles(QHash<QString,multiLine> *Sty)
{
	QList<FileFormat>::const_iterator it;
	if (findFormat(m_fileType, it))
		return it->readLineStyles(m_fileName, Sty);
	return false;
}
コード例 #10
0
ファイル: loadsaveplugin.cpp プロジェクト: luzpaz/scribus
FileFormat* LoadSavePlugin::getFormatByExt(const QString& ext)
{
	QList<FileFormat>::iterator it(findFormat(ext));
	if (it == formats.end())
		return nullptr;
	return &(*it);
}
コード例 #11
0
ファイル: loadsaveplugin.cpp プロジェクト: luzpaz/scribus
FileFormat * LoadSavePlugin::getFormatByID(int id)
{
	QList<FileFormat>::iterator it(findFormat(id));
	if (it == formats.end())
		return nullptr;
	return &(*it);
}
コード例 #12
0
bool FileLoader::ReadColors(const QString& fileName, ColorList & colors)
{
	QList<FileFormat>::const_iterator it;
	if (findFormat(FileType, it))
		return (*it).readColors(fileName, colors);
	return false;
}
コード例 #13
0
ファイル: fileloader.cpp プロジェクト: HOST-Oman/scribus
/*!
 \fn bool FileLoader::LoadFile(ScribusDoc* currDoc)
 \author Franz Schmid
 \date
 \brief Loads the file "FileName" as a Scribus document
 \param currDoc the current document
 \retval bool true when loading is succsessful, false otherwise
 */
bool FileLoader::loadFile(ScribusDoc* currDoc)
{
	m_newReplacement = false;
	currDoc->guidesPrefs().marginsShown = m_prefsManager->appPrefs.guidesPrefs.marginsShown;
	currDoc->guidesPrefs().framesShown = m_prefsManager->appPrefs.guidesPrefs.framesShown;
	currDoc->guidesPrefs().layerMarkersShown = m_prefsManager->appPrefs.guidesPrefs.layerMarkersShown;
	currDoc->guidesPrefs().gridShown = m_prefsManager->appPrefs.guidesPrefs.gridShown;
	currDoc->guidesPrefs().guidesShown = m_prefsManager->appPrefs.guidesPrefs.guidesShown;
	currDoc->guidesPrefs().colBordersShown = m_prefsManager->appPrefs.guidesPrefs.colBordersShown;
	currDoc->guidesPrefs().baselineGridShown = m_prefsManager->appPrefs.guidesPrefs.baselineGridShown;
	currDoc->guidesPrefs().linkShown = m_prefsManager->appPrefs.guidesPrefs.linkShown;
	currDoc->itemToolPrefs().polyCorners = m_prefsManager->appPrefs.itemToolPrefs.polyCorners;
	currDoc->itemToolPrefs().polyFactor = m_prefsManager->appPrefs.itemToolPrefs.polyFactor;
	currDoc->itemToolPrefs().polyRotation = m_prefsManager->appPrefs.itemToolPrefs.polyRotation;
	currDoc->itemToolPrefs().polyCurvature = m_prefsManager->appPrefs.itemToolPrefs.polyCurvature;
	currDoc->itemToolPrefs().polyOuterCurvature = m_prefsManager->appPrefs.itemToolPrefs.polyOuterCurvature;
	currDoc->itemToolPrefs().polyInnerRot = m_prefsManager->appPrefs.itemToolPrefs.polyInnerRot;
	currDoc->itemToolPrefs().polyUseFactor = m_prefsManager->appPrefs.itemToolPrefs.polyUseFactor;
	currDoc->setAutoSave(m_prefsManager->appPrefs.docSetupPrefs.AutoSave);
	currDoc->setAutoSaveTime(m_prefsManager->appPrefs.docSetupPrefs.AutoSaveTime);
	currDoc->setAutoSaveCount(m_prefsManager->appPrefs.docSetupPrefs.AutoSaveCount);
	currDoc->setAutoSaveKeep(m_prefsManager->appPrefs.docSetupPrefs.AutoSaveKeep);
	currDoc->setAutoSaveInDocDir(m_prefsManager->appPrefs.docSetupPrefs.AutoSaveLocation);
	currDoc->setAutoSaveDir(m_prefsManager->appPrefs.docSetupPrefs.AutoSaveDir);
	m_ReplacedFonts = currDoc->AllFonts->getSubstitutions();
	//dummyScFaces.clear();
	bool ret = false;
	QList<FileFormat>::const_iterator it;
	if (findFormat(m_fileType, it))
	{
//		qDebug("fileloader: type %d plugin %s"),m_fileType,it->trName);
		switch (m_fileType)
		{
			case FORMATID_SLA12XIMPORT:
				{
					it->setupTargets(currDoc, currDoc->view(), currDoc->scMW(), currDoc->scMW()->mainWindowProgressBar, &(m_prefsManager->appPrefs.fontPrefs.AvailFonts));
					ret=it->loadFile(m_fileName, LoadSavePlugin::lfCreateDoc);
// 					if (ret)
// 						it->getReplacedFontData(newReplacement, ReplacedFonts, dummyScFaces);
				}
				break;
			case FORMATID_SLA13XIMPORT:
			case FORMATID_SLA134IMPORT:
			case FORMATID_SLA150IMPORT:
				{
					it->setupTargets(currDoc, 0, currDoc->scMW(), currDoc->scMW()->mainWindowProgressBar, &(m_prefsManager->appPrefs.fontPrefs.AvailFonts));
					ret=it->loadFile(m_fileName, LoadSavePlugin::lfCreateDoc);
// 					if (ret)
// 						it->getReplacedFontData(newReplacement, ReplacedFonts, dummyScFaces);
				}
				break;
			default:
				it->setupTargets(currDoc, currDoc->view(), currDoc->scMW(), currDoc->scMW()->mainWindowProgressBar, &(m_prefsManager->appPrefs.fontPrefs.AvailFonts));
				ret = it->loadFile(m_fileName, LoadSavePlugin::lfCreateDoc);
				break;
		}
	}
	return ret;
}
コード例 #14
0
ファイル: kimportdialog.cpp プロジェクト: serghei/kde3-kdepim
void KImportDialog::updateFormatSelection(int column)
{
    int format = findFormat(column);

    if(format == KImportColumn::FormatUndefined)
        mFormatCombo->setCurrentItem(0);
    else
        mFormatCombo->setCurrentItem(format - 1);
}
コード例 #15
0
ファイル: fileloader.cpp プロジェクト: HOST-Oman/scribus
bool FileLoader::readCharStyles(ScribusDoc* doc, StyleSet<CharStyle> &docCharStyles)
{
	QList<FileFormat>::const_iterator it;
	if (findFormat(m_fileType, it)) {
		it->plug->setupTargets(doc, 0, doc->scMW(), doc->scMW()->mainWindowProgressBar, &(m_prefsManager->appPrefs.fontPrefs.AvailFonts));
		return it->readCharStyles(m_fileName, doc, docCharStyles);
	}
	return false;
}
コード例 #16
0
bool FileLoader::ReadCharStyles(const QString& fileName, ScribusDoc* doc, StyleSet<CharStyle> &docCharStyles)
{
	QList<FileFormat>::const_iterator it;
	if (findFormat(FileType, it)) {
		(*it).plug->setupTargets(doc, 0, doc->scMW(), doc->scMW()->mainWindowProgressBar, &(prefsManager->appPrefs.AvailFonts));
		return (*it).readCharStyles(fileName, doc, docCharStyles);
	}
	return false;
}
コード例 #17
0
ファイル: CAudioFormat.cpp プロジェクト: Siv3D/OpenSiv3D
	AudioFormat CAudioFormat::getFormatFromReader(const IReader& reader, const FilePath& pathHint) const
	{
		const auto it = findFormat(reader, pathHint);

		if (it == m_audioFormats.end())
		{
			return AudioFormat::Unknown;
		}

		return (*it)->format();
	}
コード例 #18
0
/*!
 \fn bool FileLoader::LoadFile(ScribusDoc* currDoc)
 \author Franz Schmid
 \date
 \brief Loads the file "FileName" as a Scribus document
 \param currDoc the current document
 \retval bool true when loading is succsessful, false otherwise
 */
bool FileLoader::LoadFile(ScribusDoc* currDoc)
{
	newReplacement = false;
	currDoc->guidesSettings.marginsShown = prefsManager->appPrefs.guidesSettings.marginsShown;
	currDoc->guidesSettings.framesShown = prefsManager->appPrefs.guidesSettings.framesShown;
	currDoc->guidesSettings.layerMarkersShown = prefsManager->appPrefs.guidesSettings.layerMarkersShown;
	currDoc->guidesSettings.gridShown = prefsManager->appPrefs.guidesSettings.gridShown;
	currDoc->guidesSettings.guidesShown = prefsManager->appPrefs.guidesSettings.guidesShown;
	currDoc->guidesSettings.colBordersShown = prefsManager->appPrefs.guidesSettings.colBordersShown;
	currDoc->guidesSettings.baseShown = prefsManager->appPrefs.guidesSettings.baseShown;
	currDoc->guidesSettings.linkShown = prefsManager->appPrefs.guidesSettings.linkShown;
	currDoc->toolSettings.polyC = prefsManager->appPrefs.toolSettings.polyC;
	currDoc->toolSettings.polyF = prefsManager->appPrefs.toolSettings.polyF;
	currDoc->toolSettings.polyR = prefsManager->appPrefs.toolSettings.polyR;
	currDoc->toolSettings.polyCurvature = prefsManager->appPrefs.toolSettings.polyCurvature;
	currDoc->toolSettings.polyFd = prefsManager->appPrefs.toolSettings.polyFd;
	currDoc->toolSettings.polyS = prefsManager->appPrefs.toolSettings.polyS;
	currDoc->AutoSave = prefsManager->appPrefs.AutoSave;
	currDoc->AutoSaveTime = prefsManager->appPrefs.AutoSaveTime;
	ReplacedFonts = currDoc->AllFonts->getSubstitutions();
	//dummyScFaces.clear();
	bool ret = false;
	QList<FileFormat>::const_iterator it;
	if (findFormat(FileType, it))
	{
//		qDebug("fileloader: type %d plugin %s"),FileType,(*it).trName);
		switch (FileType)
		{
			case FORMATID_SLA12XIMPORT:
				{
					(*it).setupTargets(currDoc, currDoc->view(), currDoc->scMW(), currDoc->scMW()->mainWindowProgressBar, &(prefsManager->appPrefs.AvailFonts));
					ret=(*it).loadFile(FileName, LoadSavePlugin::lfCreateDoc);
// 					if (ret)
// 						(*it).getReplacedFontData(newReplacement, ReplacedFonts, dummyScFaces);
				}
				break;
			case FORMATID_SLA13XIMPORT:
			case FORMATID_SLA134IMPORT:
				{
					(*it).setupTargets(currDoc, 0, currDoc->scMW(), currDoc->scMW()->mainWindowProgressBar, &(prefsManager->appPrefs.AvailFonts));
					ret=(*it).loadFile(FileName, LoadSavePlugin::lfCreateDoc);
// 					if (ret)
// 						(*it).getReplacedFontData(newReplacement, ReplacedFonts, dummyScFaces);
				}
				break;
			default:
				(*it).setupTargets(currDoc, currDoc->view(), currDoc->scMW(), currDoc->scMW()->mainWindowProgressBar, &(prefsManager->appPrefs.AvailFonts));
				ret = (*it).loadFile(FileName, LoadSavePlugin::lfCreateDoc);
				break;
		}
	}
	return ret;
}
コード例 #19
0
ファイル: kimportdialog.cpp プロジェクト: serghei/kde3-kdepim
void KImportDialog::setCellText(int row, int col, const QString &text)
{
    if(row < 0) return;

    if((mTable->numRows() - 1) < row) mTable->setNumRows(row + 1);
    if((mTable->numCols() - 1) < col) mTable->setNumCols(col + 1);

    KImportColumn *c = mColumnDict.find(col);
    QString formattedText;
    if(c) formattedText = c->preview(text, findFormat(col));
    else formattedText = text;
    mTable->setText(row, col, formattedText);
}
コード例 #20
0
bool FileLoader::SaveFile(const QString& fileName, ScribusDoc *doc, QString *savedFile)
{
	bool ret = false;
	QList<FileFormat>::const_iterator it;
	if (findFormat(FORMATID_SLA134EXPORT, it))
	{
		it->setupTargets(doc, 0, doc->scMW(), doc->scMW()->mainWindowProgressBar, &(prefsManager->appPrefs.AvailFonts));
		ret = it->saveFile(fileName);
		if (savedFile)
			*savedFile = it->lastSavedFile();
	}
	return ret;
}
コード例 #21
0
ファイル: CAudioFormat.cpp プロジェクト: Siv3D/OpenSiv3D
	bool CAudioFormat::encodeWAVE(IWriter& writer, const Wave& wave, const WAVEFormat format) const
	{
		const auto p = findFormat(AudioFormat::WAVE);

		if (p == m_audioFormats.end())
		{
			return false;
		}

		if (const AudioFormat_WAVE* wav = dynamic_cast<AudioFormat_WAVE*>(p->get()))
		{
			return wav->encode(wave, writer, format);
		}

		return false;
	}
コード例 #22
0
ファイル: aiExport.cpp プロジェクト: npapier/vgsdk
const bool aiExport::aiExecute( const aiScene * scene )
{
	// Retrieves the file path.
	const boost::filesystem::path path = getPath();

	// If there is a file path, we can export.
	if( !path.empty() )
	{
		Assimp::Exporter		exporter;
		Formats::const_iterator format = findFormat( path );

		vgAssertN( format != m_formats.end(), "Export format must be specified." );
		exporter.Export( scene, format->aiId, path.string().c_str(), 0u );
		// We should do some error checking !
	}

	return false; // We never need to refresh the scene.
}
コード例 #23
0
ファイル: CAudioFormat.cpp プロジェクト: Siv3D/OpenSiv3D
	Wave CAudioFormat::load(const FilePath& path) const
	{
		BinaryReader reader(path);

		const auto it = findFormat(reader, path);

		if (it == m_audioFormats.end())
		{
			return Wave();
		}
		
	# if defined(SIV3D_TARGET_MACOS)

		if ((*it)->format() == AudioFormat::AAC)
		{
			reader.close();

			return (*it)->decodeFromFile(path);
		}

	# endif

		return (*it)->decode(reader);
	}
コード例 #24
0
ファイル: loadsaveplugin.cpp プロジェクト: luzpaz/scribus
void LoadSavePlugin::unregisterFormat(unsigned int id)
{
	QList<FileFormat>::iterator it(findFormat(id, this));
	Q_ASSERT(it != formats.end());
	formats.erase(it);
}
コード例 #25
0
ファイル: D3D9.cpp プロジェクト: L0FKA/OBGE_clone4nv
OBGEDirect3D9::OBGEDirect3D9(IDirect3D9 *d3d) : m_d3d(d3d) {
    _MESSAGE("OD3D9: Driver 0x%08x constructed from 0x%08x (%d drivers available)", this, _ReturnAddress(), OBGEDrivers.size() + 1);

    DoesRESZflag = false;
    DoesNULLflag = false;
    DoesFCH4flag = false;

    /* --------------------------------------------------- */
    D3DDISPLAYMODE d3ddm;
    if (m_d3d->GetAdapterDisplayMode(D3DADAPTER_DEFAULT, &d3ddm) == D3D_OK) {
        m_d3d->GetDeviceCaps(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, &lastOBGEDirect3D9CAPS);

        HRESULT hrs, hrt;
        char rts[2048];
        rts[0] = '\0';
        char dss[2048];
        dss[0] = '\0';
        for (int fmtn = 0; fmtn < (sizeof(testingFmts) / sizeof(D3DFORMAT)); fmtn++) {
            D3DFORMAT fmt = testingFmts[fmtn];
            const char *FMT = findFormat(fmt);
            if (strcmp(FMT, "unknown")) {
                hrs = m_d3d->CheckDeviceFormat(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, d3ddm.Format, D3DUSAGE_RENDERTARGET, D3DRTYPE_SURFACE, fmt);
                hrt = m_d3d->CheckDeviceFormat(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, d3ddm.Format, D3DUSAGE_RENDERTARGET, D3DRTYPE_TEXTURE, fmt);
                if ((hrs == D3D_OK) || (hrt == D3D_OK)) {
                    if (rts[0])
                        strcat(rts, ", ");
                    strcat(rts, FMT);

                    if (hrs != hrt) {
                        if (hrs == D3D_OK)
                            strcat(rts, " (srf)");
                        if (hrt == D3D_OK)
                            strcat(rts, " (tex)");
                    }
                }

                if ((fmt == CODE_NULL) && ((hrs == D3D_OK) || (hrt == D3D_OK))) DoesNULLflag = true;

                hrs = m_d3d->CheckDeviceFormat(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, d3ddm.Format, D3DUSAGE_DEPTHSTENCIL, D3DRTYPE_SURFACE, fmt);
                hrt = m_d3d->CheckDeviceFormat(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, d3ddm.Format, D3DUSAGE_DEPTHSTENCIL, D3DRTYPE_TEXTURE, fmt);
                if ((hrs == D3D_OK) || (hrt == D3D_OK)) {
                    if (dss[0])
                        strcat(dss, ", ");
                    strcat(dss, FMT);

                    if (hrs != hrt) {
                        if (hrs == D3D_OK)
                            strcat(dss, " (srf)");
                        if (hrt == D3D_OK)
                            strcat(dss, " (tex)");
                    }
                }

                if ((fmt == CODE_DF24) && ((hrs == D3D_OK) || (hrt == D3D_OK))) DoesFCH4flag = true;
                if ((fmt == CODE_RESZ) && ((hrs == D3D_OK) || (hrt == D3D_OK))) DoesRESZflag = true;
            }
        }

        _MESSAGE("OD3D9: Supported render-targets: %s", rts);
        _MESSAGE("OD3D9: Supported depth-stencils: %s", dss);

        if (DoesNULLflag) {
            hrs = m_d3d->CheckDeviceMultiSampleType(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, (D3DFORMAT)MAKEFOURCC('N','U','L','L'), FALSE, D3DMULTISAMPLE_2_SAMPLES, NULL);

            _MESSAGE("OD3D9: NULL has multi-sample support: %s", hrs == D3D_OK ? "yes" : "no");
        }

        if (DoesFCH4flag)
            _MESSAGE("OD3D9: Fetch4 supported.");
        else
            _MESSAGE("OD3D9: Fetch4 not supported.");
    }

    /* add to vector and replace by the new version */
    lastOBGEDirect3D9 = this;
    OBGEDrivers.push_back(this);
}
コード例 #26
0
ファイル: texture.cpp プロジェクト: rokuz/DemoScene
bool Texture::initAsCubemap(const std::string& frontFilename, const std::string& backFilename,
                            const std::string& leftFilename, const std::string& rightFilename,
                            const std::string& topFilename, const std::string& bottomFilename,
                            bool mipmaps)
{
    destroy();

    std::string filenames[6] = { rightFilename, leftFilename, topFilename, bottomFilename, frontFilename, backFilename };
    uint8_t * imageData[6] = { 0, 0, 0, 0, 0, 0 };
    auto cleanFunc = [&]()
    {
        for (size_t i = 0; i < 6; i++) if (imageData[i] != 0) stbi_image_free(imageData[i]);
    };

    int width = 0, height = 0, components = 0;
    for (size_t i = 0; i < 6; i++)
    {
        int w, h, c;
        imageData[i] = stbi_load(filenames[i].c_str(), &w, &h, &c, 0);
        if (!imageData[i])
        {
            common::Logger::toLogWithFormat("Error: could not load file '%s'.\n", filenames[i].c_str());
            cleanFunc();
            return false;
        }

        if (i > 0 && (width != w || height != h || components != c))
        {
            common::Logger::toLog("Error: could not create a cubemap, files have different properties (width, height, components).\n");
            cleanFunc();
            return false;
        }
        else
        {
            width = w;
            height = h;
            components = c;
        }
    }

    m_format = findFormat(components);
    if (m_format == -1)
    {
        common::Logger::toLog("Error: texture format is unknown.\n");
        cleanFunc();
        return false;
    }

    m_target = GL_TEXTURE_CUBE_MAP;
    m_width = width;
    m_height = height;
    m_pixelFormat = findPixelFormat(m_format);
    glGenTextures(1, &m_texture);
    glBindTexture(m_target, m_texture);
    int mipLevels = mipmaps ? getMipLevelsCount(m_width, m_height) : 1;
    glTexStorage2D(m_target, mipLevels, m_format, m_width, m_height);
    for (uint32_t i = 0; i < 6; i++)
    {
        glTexSubImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X + i, 0, 0, 0, m_width, m_height, m_pixelFormat, GL_UNSIGNED_BYTE, imageData[i]);
    }
    setSampling();
    if (mipmaps) generateMipmaps();
    glBindTexture(m_target, 0);

    cleanFunc();

    if (glCheckError())
    {
        destroy();
        return false;
    }

    m_isLoaded = true;
    return m_isLoaded;
}
コード例 #27
0
/*
static void replaceFonts(ScribusDoc* currDoc, PageItem *it, QMap<QString, int> UsedFonts, QMap<QString, QString> ReplacedFonts)
{	
	if ((it->asTextFrame()) || (it->asPathText()))
	{
		CharStyle newFontStyle;
		for (uint e = 0; e < it->itemText.nrOfRuns(); ++e)
		{
			int start = it->itemText.startOfRun(e);
			ScFace oldFont = it->itemText.charStyle(start).font();
			if (!UsedFonts.contains(oldFont.scName())) {
				newFontStyle.setFont((*currDoc->AllFonts)[ReplacedFonts[oldFont.scName()]]);
				it->itemText.applyCharStyle(start, it->itemText.endOfRun(e) - start, newFontStyle );
			}
		}
	}
}

*/
bool FileLoader::LoadPage(ScribusDoc* currDoc, int PageToLoad, bool Mpage, QString renamedPageName)
{
	bool ret = false;
// 	newReplacement = false;
	ReplacedFonts = currDoc->AllFonts->getSubstitutions();
// 	dummyScFaces.clear();
	QList<FileFormat>::const_iterator it;
	if (findFormat(FileType, it))
	{
		if (FileType==FORMATID_SLA12XIMPORT)
		{
			(*it).plug->setupTargets(currDoc, currDoc->view(), currDoc->scMW(), currDoc->scMW()->mainWindowProgressBar, &(prefsManager->appPrefs.AvailFonts));
			ret=(*it).plug->loadPage(FileName, PageToLoad, Mpage, renamedPageName);
// 			if (ret)
// 				(*it).plug->getReplacedFontData(newReplacement, ReplacedFonts, dummyScFaces);
		}
		if (FileType==FORMATID_SLA13XIMPORT || FileType==FORMATID_SLA134IMPORT)
		{
			(*it).plug->setupTargets(currDoc, 0, currDoc->scMW(), currDoc->scMW()->mainWindowProgressBar, &(prefsManager->appPrefs.AvailFonts));
			ret=(*it).plug->loadPage(FileName, PageToLoad, Mpage, renamedPageName);
// 			if (ret)
// 				(*it).plug->getReplacedFontData(newReplacement, ReplacedFonts, dummyScFaces);
		}
	}
	if (ret)
		ret = postLoad(currDoc);  // FIXME: return false if user doesnt want to replace fonts??
	
	/*
	//FIXME: this goes into scribusdoc and should work with substitutes
	if (ReplacedFonts.count() != 0)
	{
		if ((prefsManager->appPrefs.askBeforeSubstituite) || (newReplacement))
		{
			qApp->setOverrideCursor(QCursor(Qt::arrowCursor), true);
			FontReplaceDialog dia(0, &ReplacedFonts);
			if (dia.exec())
			{
				QMap<QString,QString>::Iterator itfsu;
				for (itfsu = ReplacedFonts.begin(); itfsu != ReplacedFonts.end(); ++itfsu)
				{
					if (dia.stickyReplacements->isChecked())
						prefsManager->appPrefs.GFontSub[itfsu.key()] = itfsu.data();
				}
			}
			else
			{
				return false;
			}
		}
		for (uint d = 0; d < currDoc->MasterItems.count(); ++d)
		{
			replaceFonts(currDoc, currDoc->MasterItems.at(d), currDoc->UsedFonts, ReplacedFonts);
		}
		for (uint d = 0; d < currDoc->DocItems.count(); ++d)
		{
			replaceFonts(currDoc, currDoc->DocItems.at(d), currDoc->UsedFonts, ReplacedFonts);
		}
		for (uint d = 0; d < currDoc->FrameItems.count(); ++d)
		{
			replaceFonts(currDoc, currDoc->FrameItems.at(d), currDoc->UsedFonts, ReplacedFonts);
		}
		for (uint a = 0; a < currDoc->paragraphStyles().count(); ++a)
		{
//			if ( !currDoc->paragraphStyles()[a].charStyle().font().isNone() && !currDoc->UsedFonts.contains(currDoc->paragraphStyles()[a].charStyle().font().scName()))
//				currDoc->paragraphStyles()[a].charStyle().setFont
//					((*currDoc->AllFonts)[ReplacedFonts[currDoc->paragraphStyles()[a].charStyle().font().scName()]]);
		}
		QMap<QString,QString>::Iterator itfsu;
		for (itfsu = ReplacedFonts.begin(); itfsu != ReplacedFonts.end(); ++itfsu)
		{
			if (!currDoc->UsedFonts.contains(itfsu.data()))
			{
//				QFont fo = prefsManager->appPrefs.AvailFonts[itfsu.data()]->Font;
//				fo.setPointSize(qRound(ScMW->doc->toolSettings.defSize / 10.0));
				currDoc->AddFont(itfsu.data(), qRound(currDoc->toolSettings.defSize / 10.0));
			}
		}
		if (prefsManager->appPrefs.askBeforeSubstituite)
			ReplacedFonts.clear();
// 		dummyScFaces.clear();
	}
	*/
	return ret;
}
コード例 #28
0
ファイル: texture.cpp プロジェクト: rokuz/DemoScene
bool Texture::initAsArray(const std::vector<std::string> & filenames, bool mipmaps)
{
    destroy();

    m_arraySize = (uint32_t)filenames.size();
    std::vector<uint8_t *> imageData;
    imageData.resize(m_arraySize, nullptr);
    auto cleanFunc = [&]()
    {
        for (uint32_t i = 0; i < m_arraySize; i++) if (imageData[i] != 0) stbi_image_free(imageData[i]);
    };

    int width = 0, height = 0, components = 0;
    for (uint32_t i = 0; i < m_arraySize; i++)
    {
        int w, h, c;
        imageData[i] = stbi_load(filenames[i].c_str(), &w, &h, &c, 0);
        if (!imageData[i])
        {
            common::Logger::toLogWithFormat("Error: could not load file '%s'.\n", filenames[i].c_str());
            cleanFunc();
            return false;
        }

        if (i > 0 && (width != w || height != h || components != c))
        {
            common::Logger::toLog("Error: could not create a cubemap, files have different properties (width, height, components).\n");
            cleanFunc();
            return false;
        }
        else
        {
            width = w;
            height = h;
            components = c;
        }
    }

    m_format = findFormat(components);
    if (m_format == -1)
    {
        common::Logger::toLog("Error: texture format is unknown.\n");
        cleanFunc();
        return false;
    }

    m_target = GL_TEXTURE_2D_ARRAY;
    m_width = width;
    m_height = height;
    m_pixelFormat = findPixelFormat(m_format);
    glGenTextures(1, &m_texture);
    glBindTexture(m_target, m_texture);
    int mipLevels = mipmaps ? getMipLevelsCount(m_width, m_height) : 1;
    glTexStorage3D(m_target, mipLevels, m_format, m_width, m_height, m_arraySize);
    for (uint32_t i = 0; i < m_arraySize; i++)
    {
        glTexSubImage3D(m_target, 0, 0, 0, i, m_width, m_height, 1, m_pixelFormat, GL_UNSIGNED_BYTE, imageData[i]);
    }
    setSampling();
    if (mipmaps) generateMipmaps();
    glBindTexture(m_target, 0);

    cleanFunc();

    if (glCheckError())
    {
        destroy();
        return false;
    }

    m_isLoaded = true;
    return m_isLoaded;
}
コード例 #29
0
bool
DepthSurfaceD3D11::create()
{
    if (_initializationData)
    {
         if (_initializationData->width() == MIRROR_BACK_BUFFER)
        {
             _textureDesc.Width  = _deviceInterface->backbuffer()->width();
        }
        else if (_initializationData->width() == MIRROR_BACK_BUFFER_HALF)
        {
             _textureDesc.Width  = _deviceInterface->backbuffer()->width() / 2;
        }
        else if (_initializationData->width() == MIRROR_BACK_BUFFER_QUARTER)
        {
             _textureDesc.Width  = _deviceInterface->backbuffer()->width() / 4;
        }
        else if (_initializationData->width() == MIRROR_BACK_BUFFER_EIGTH)
        {
             _textureDesc.Width  = _deviceInterface->backbuffer()->width() / 8;
        }
        else
        {
            _textureDesc.Width = _initializationData->width();
        }

        if (_initializationData->height() == MIRROR_BACK_BUFFER)
        {
             _textureDesc.Height = _deviceInterface->backbuffer()->height();
        }
        else if (_initializationData->width() == MIRROR_BACK_BUFFER_HALF)
        {
             _textureDesc.Height = _deviceInterface->backbuffer()->height() / 2;
        }
        else if (_initializationData->width() == MIRROR_BACK_BUFFER_QUARTER)
        {
             _textureDesc.Height = _deviceInterface->backbuffer()->height() / 4;
        }
        else if (_initializationData->width() == MIRROR_BACK_BUFFER_EIGTH)
        {
             _textureDesc.Height = _deviceInterface->backbuffer()->height() / 8;
        }
        else
        {
            _textureDesc.Height = _initializationData->height();
        }
    


        // Create depth stencil texture

        _textureDesc.MipLevels = 1;
        
        if (_initializationData->slices() > 1)
        {
            _textureDesc.ArraySize = _initializationData->slices();
        }
        else
        {
            _textureDesc.ArraySize = 1;
        }

        _textureDesc.Format = findFormat (_initializationData->format());
        _textureDesc.SampleDesc.Count = _initializationData->multiSampleCount();
        _textureDesc.SampleDesc.Quality = _initializationData->multiSampleQuality();
        _textureDesc.Usage = D3D11_USAGE_DEFAULT;
        _textureDesc.BindFlags = D3D11_BIND_DEPTH_STENCIL | D3D11_BIND_SHADER_RESOURCE; 

        _textureDesc.CPUAccessFlags = 0;
        _textureDesc.MiscFlags = 0;
         
        HRESULT hr = _direct3d->CreateTexture2D( &_textureDesc, nullptr, &_depthTexture );
        if (FAILED(hr))
        {
            LOG_CRITICAL ("Failed to create Texture2D for depth!\n");
        }

        DXGI_FORMAT srvFormat = DXGI_FORMAT_UNKNOWN;
        DXGI_FORMAT dsvFormat = DXGI_FORMAT_UNKNOWN;
        
        if (_textureDesc.Format == DXGI_FORMAT_R16_TYPELESS)
        {
            srvFormat = DXGI_FORMAT_R16_UNORM;
            dsvFormat = DXGI_FORMAT_D16_UNORM;
        }
        else if (_textureDesc.Format == DXGI_FORMAT_R32_TYPELESS)
        {
            srvFormat = DXGI_FORMAT_R32_FLOAT;
            dsvFormat = DXGI_FORMAT_D32_FLOAT;
        }
        else if (_textureDesc.Format ==  DXGI_FORMAT_R24G8_TYPELESS ||
            _textureDesc.Format == DXGI_FORMAT_D24_UNORM_S8_UINT)
        { 
            dsvFormat = DXGI_FORMAT_D24_UNORM_S8_UINT;
            srvFormat = DXGI_FORMAT_R24_UNORM_X8_TYPELESS;
        }

        // Create the depth stencil view
        D3D11_DEPTH_STENCIL_VIEW_DESC descDSV;
        memset (&descDSV, 0, sizeof(descDSV));
        descDSV.Format = dsvFormat;

        if (_initializationData->slices() > 1)
        {
            descDSV.ViewDimension = _initializationData->multiSampleCount() > 1 ? D3D11_DSV_DIMENSION_TEXTURE2DMSARRAY : D3D11_DSV_DIMENSION_TEXTURE2DARRAY;
            descDSV.Texture2DArray.ArraySize = _initializationData->slices();    
            descDSV.Texture2DArray.FirstArraySlice = 0;
            descDSV.Texture2DArray.MipSlice = 0;
        }
        else
        {
            descDSV.ViewDimension = _initializationData->multiSampleCount() > 1 ? D3D11_DSV_DIMENSION_TEXTURE2DMS : D3D11_DSV_DIMENSION_TEXTURE2D;
            descDSV.Texture2D.MipSlice = 0;
        }

        descDSV.Flags = 0;

        if (SUCCEEDED(_direct3d->CreateDepthStencilView (_depthTexture, &descDSV, &_depthSurface )))
        {
            _depthSurface->GetDesc (&_desc);
        }
        else
        {
            LOG ("Failed to to create depth surface view");
        }

        {
            // Create a shader resource view
            D3D11_SHADER_RESOURCE_VIEW_DESC srvDesc;

            srvDesc.Format = srvFormat;

            if (_initializationData->slices() > 1)
            {
                srvDesc.ViewDimension = _initializationData->multiSampleCount() > 1 ? D3D11_SRV_DIMENSION_TEXTURE2DMSARRAY : D3D11_SRV_DIMENSION_TEXTURE2DARRAY;
                srvDesc.Texture2DArray.ArraySize = _initializationData->slices();    
                srvDesc.Texture2DArray.FirstArraySlice = 0;
                srvDesc.Texture2DArray.MipLevels = 1;
                srvDesc.Texture2DArray.MostDetailedMip = 0;
            }
            else
            {
                srvDesc.ViewDimension = _initializationData->multiSampleCount() > 1 ? D3D11_SRV_DIMENSION_TEXTURE2DMS : D3D11_SRV_DIMENSION_TEXTURE2D;
                srvDesc.Texture2D.MipLevels = 1;
                srvDesc.Texture2D.MostDetailedMip = 0;
            }

            ID3D11ShaderResourceView * resourceView = nullptr;
            if (SUCCEEDED (_direct3d->CreateShaderResourceView( _depthTexture, 
                                                                &srvDesc, 
                                                                &resourceView)))
            {
                _depthShaderResourceView = resourceView;
            }
            else
            {
                LOG ("FAILED in create shader resource view for depthTexture");
            }
        }


        return SUCCEEDED (hr);
    }    
    return false;
}