static bool ensureDatabaseFileExists(const String& fileName, bool createIfDoesNotExist) { if (createIfDoesNotExist) return makeAllDirectories(directoryName(fileName)); return fileExists(fileName); }
static String getExecutablePath() { CString executablePath = getCurrentExecutablePath(); if (!executablePath.isNull()) return directoryName(filenameToString(executablePath.data())); return String(); }
QString VdpauWidget::benchH264720p() { if ( !vc->isProfileSupported( VDPAUContext::ProfileH264High) ) return "Profile unsupported.\n"; QString directoryName(dataDirectory); directoryName.append("h264720p.dat"); H264Decoder *d = new H264Decoder( vc, directoryName ); if ( !d->init() ) { delete d; return "Can't initialize H264 decoder!\n"; } if ( mixerWidth!=d->width || mixerHeight!=d->height ) createMixer( d->width, d->height ); int i; for ( i=0; i<FRAMESINSAMPLE; ++i ) { displayFrame( d->getNextFrame(), d->width, d->height, d->ratio ); usleep( SHOWTIME ); } QTime t; t.start(); for ( i=0; i<FRAMESINLOOP; ++i ) { d->getNextFrame(); } int e = t.elapsed(); benchH264720pResult = QString("H264 DECODING (%1x%2): %3 frames/s\n").arg(d->width).arg(d->height).arg(FRAMESINLOOP*1000/e); delete d; return benchH264720pResult; }
void WebIconDatabase::setDatabasePath(const String& path) { if (isOpen()) { LOG_ERROR("Icon database already has a path and is already open. We don't currently support changing its path and reopening."); return; } m_iconDatabaseImpl = std::make_unique<IconDatabase>(); m_iconDatabaseImpl->setClient(this); IconDatabase::delayDatabaseCleanup(); m_databaseCleanupDisabled = true; m_iconDatabaseImpl->setEnabled(true); // FIXME: WebIconDatabases are per-WebContext but WebContext's don't have their own notion of the current private browsing setting. // As we clean up private browsing throughout the stack we need to clean it up here. m_iconDatabaseImpl->setPrivateBrowsingEnabled(WebPreferences::anyPagesAreUsingPrivateBrowsing()); if (!m_iconDatabaseImpl->open(directoryName(path), pathGetFileName(path))) { LOG_ERROR("Unable to open WebKit2 icon database on disk"); m_iconDatabaseImpl = nullptr; setGlobalIconDatabase(nullptr); IconDatabase::allowDatabaseCleanup(); m_databaseCleanupDisabled = false; } setGlobalIconDatabase(m_iconDatabaseImpl.get()); }
void COwnedLostItem::SetHandledViaNetscape() { m_nHandleMethod = OL_OTHER_APP; // Get the app's name. CString netscapeName; char buffer[_MAX_PATH+1]; ::GetModuleFileName(theApp.m_hInstance, buffer, _MAX_PATH); char *pSlash = ::strrchr(buffer, '\\'); netscapeName = (char*)(pSlash+1); netscapeName.MakeUpper(); // Get the app's directory. Adequate heuristic for version-checking Netscape CString directoryName(buffer); directoryName.MakeUpper(); // Special Internet Shortcut check if (IsInternetShortcut()) { CInternetShortcut internetShortcut; if (!internetShortcut.ShellSupport()) { m_nHandleMethod = OL_CURRENT_NETSCAPE; return; } CString fileClass = GetInternetShortcutFileClass(); SetHandleMethodViaFileClass(fileClass, netscapeName, directoryName); return; } CPtrList* allHelpers = &(CHelperApp::m_cplHelpers); for (POSITION pos = allHelpers->GetHeadPosition(); pos != NULL;) { CHelperApp* app = (CHelperApp*)allHelpers->GetNext(pos); CString helperMime(app->cd_item->ci.type); if (helperMime == m_csMimeType) { // Found the helper app. See if Netscape is truly handling this mime type. CString fileClass(app->strFileClass); if (fileClass != "") { SetHandleMethodViaFileClass(fileClass, netscapeName, directoryName); return; } else m_bBroken = TRUE; // Treat as if ignored. Don't want to pop up a dialog over this. if (app->how_handle == HANDLE_VIA_NETSCAPE) m_nHandleMethod = OL_CURRENT_NETSCAPE; else m_nHandleMethod = OL_OTHER_APP; return; } } m_bBroken = TRUE; // Didn't even find this mime type. Don't want to fool with it. }
bool InjectedBundle::load() { WCHAR currentPath[MAX_PATH]; if (!::GetCurrentDirectoryW(MAX_PATH, currentPath)) return false; String directorBundleResidesIn = directoryName(m_path); if (!::SetCurrentDirectoryW(directorBundleResidesIn.charactersWithNullTermination())) return false; m_platformBundle = ::LoadLibraryExW(m_path.charactersWithNullTermination(), 0, LOAD_WITH_ALTERED_SEARCH_PATH); if (!m_platformBundle) return false; // Reset the current directory. if (!::SetCurrentDirectoryW(currentPath)) { return false; } WKBundleInitializeFunctionPtr initializeFunction = reinterpret_cast<WKBundleInitializeFunctionPtr>(::GetProcAddress(m_platformBundle, "WKBundleInitialize")); if (!initializeFunction) return false; initializeFunction(toRef(this)); return true; }
bool SQLiteFileSystem::ensureDatabaseFileExists(const String& fileName, bool checkPathOnly) { if (fileName.isEmpty()) return false; if (checkPathOnly) { String dir = directoryName(fileName); return ensureDatabaseDirectoryExists(dir); } return fileExists(fileName); }
void FormData::removeGeneratedFilesIfNeeded() { for (FormDataElement& element : m_elements) { if (element.m_type == FormDataElement::Type::EncodedFile && element.m_ownsGeneratedFile) { ASSERT(!element.m_generatedFilename.isEmpty()); ASSERT(element.m_shouldGenerateFile); String directory = directoryName(element.m_generatedFilename); deleteFile(element.m_generatedFilename); deleteEmptyDirectory(directory); element.m_generatedFilename = String(); element.m_ownsGeneratedFile = false; } } }
sint64 VDGetDiskFreeSpace(const wchar_t *path) { typedef BOOL (WINAPI *tpGetDiskFreeSpaceExA)(LPCSTR lpDirectoryName, PULARGE_INTEGER lpFreeBytesAvailable, PULARGE_INTEGER lpTotalNumberOfBytes, PULARGE_INTEGER lpTotalNumberOfFreeBytes); typedef BOOL (WINAPI *tpGetDiskFreeSpaceExW)(LPCWSTR lpDirectoryName, PULARGE_INTEGER lpFreeBytesAvailable, PULARGE_INTEGER lpTotalNumberOfBytes, PULARGE_INTEGER lpTotalNumberOfFreeBytes); static bool sbChecked = false; static tpGetDiskFreeSpaceExA spGetDiskFreeSpaceExA; static tpGetDiskFreeSpaceExW spGetDiskFreeSpaceExW; if (!sbChecked) { HMODULE hmodKernel = GetModuleHandle("kernel32.dll"); spGetDiskFreeSpaceExA = (tpGetDiskFreeSpaceExA)GetProcAddress(hmodKernel, "GetDiskFreeSpaceExA"); spGetDiskFreeSpaceExW = (tpGetDiskFreeSpaceExW)GetProcAddress(hmodKernel, "GetDiskFreeSpaceExW"); sbChecked = true; } if (spGetDiskFreeSpaceExA) { BOOL success; uint64 freeClient, totalBytes, totalFreeBytes; VDStringW directoryName(path); if (!directoryName.empty()) { wchar_t c = directoryName[directoryName.length()-1]; if (c != L'/' && c != L'\\') directoryName += L'\\'; } if ((LONG)GetVersion() < 0) success = spGetDiskFreeSpaceExA(VDTextWToA(directoryName).c_str(), (PULARGE_INTEGER)&freeClient, (PULARGE_INTEGER)&totalBytes, (PULARGE_INTEGER)&totalFreeBytes); else success = spGetDiskFreeSpaceExW(directoryName.c_str(), (PULARGE_INTEGER)&freeClient, (PULARGE_INTEGER)&totalBytes, (PULARGE_INTEGER)&totalFreeBytes); return success ? (sint64)freeClient : -1; } else { DWORD sectorsPerCluster, bytesPerSector, freeClusters, totalClusters; BOOL success; VDStringW rootPath(VDFileGetRootPath(path)); if ((LONG)GetVersion() < 0) success = GetDiskFreeSpaceA(rootPath.empty() ? NULL : VDTextWToA(rootPath).c_str(), §orsPerCluster, &bytesPerSector, &freeClusters, &totalClusters); else success = GetDiskFreeSpaceW(rootPath.empty() ? NULL : rootPath.c_str(), §orsPerCluster, &bytesPerSector, &freeClusters, &totalClusters); return success ? (sint64)((uint64)sectorsPerCluster * bytesPerSector * freeClusters) : -1; } }
bool SQLiteFileSystem::ensureDatabaseFileExists(const std::string& fileName, bool checkPathOnly) { DLOG(INFO) << ">>>"; if (fileName.empty()) { DLOG(INFO) << "<<< " << "FALSE"; return false; } if (checkPathOnly) { std::string dir = directoryName(fileName); DLOG(INFO) << "<<<"; return ensureDatabaseDirectoryExists(dir); } DLOG(INFO) << "<<<"; return fileExists(fileName); }
void FormData::removeGeneratedFilesIfNeeded() { if (!m_hasGeneratedFiles) return; size_t n = m_elements.size(); for (size_t i = 0; i < n; ++i) { FormDataElement& e = m_elements[i]; if (e.m_type == FormDataElement::encodedFile && !e.m_generatedFilename.isEmpty()) { ASSERT(e.m_shouldGenerateFile); String directory = directoryName(e.m_generatedFilename); deleteFile(e.m_generatedFilename); deleteEmptyDirectory(directory); e.m_generatedFilename = String(); } } m_hasGeneratedFiles = false; }
std::string directory_name(const std::string& filePath) { const size_t PATH_LENGTH = 1024; char fullPath[PATH_LENGTH]; char* fileNameBegin; DWORD result = ::GetFullPathName(filePath.c_str(), PATH_LENGTH, fullPath, &fileNameBegin); if (!result) { return std::string(); } fileNameBegin[0] = '\0'; std::string directoryName(trim_path_separator(fullPath)); return directoryName; }
std::string PrincessModel::getGloveFileNameFromSlotIndex(int gloveIndex, int slot) { std::string directoryName(CLOTHES_BASE); directoryName.append("glove"); WJUtils::stringAddInt(directoryName, slot, 3); directoryName.append("/"); std::string fileName = WJUtils::stringAddInt("cloth", gloveIndex, 3).append(WJUtils::stringAddInt("_glove", slot, 3).c_str()); fileName.append(".png"); std::string fullFileName = directoryName + fileName; std::string fullPath = FileUtils::getInstance()->fullPathForFilename(fullFileName); if (fullPath.length() == 0) return BASE_NONE_PNG; else return directoryName.append(fileName); }
void WebIconDatabase::setDatabasePath(const String& path) { if (isOpen()) { LOG_ERROR("Icon database already has a path and is already open. We don't currently support changing its path and reopening."); return; } m_iconDatabaseImpl = IconDatabase::create(); m_iconDatabaseImpl->setClient(this); IconDatabase::delayDatabaseCleanup(); m_databaseCleanupDisabled = true; m_iconDatabaseImpl->setEnabled(true); if (!m_iconDatabaseImpl->open(directoryName(path), pathGetFileName(path))) { LOG_ERROR("Unable to open WebKit2 icon database on disk"); m_iconDatabaseImpl.clear(); setGlobalIconDatabase(0); IconDatabase::allowDatabaseCleanup(); m_databaseCleanupDisabled = false; } setGlobalIconDatabase(m_iconDatabaseImpl.get()); }
bool ParseClassPath(const string& pathString, deque<string>& pathList) { string::size_type startPosition = 0; string::size_type colonPosition; do { colonPosition = pathString.find(PATHSEPCHAR, startPosition); if (colonPosition > pathString.size()) { colonPosition = pathString.size(); } string directoryName(pathString, startPosition, colonPosition - startPosition); CJavaDirectory path(directoryName); if (path.IsValid()) { pathList.push_back(directoryName); } else { cerr << ">> Warning: Invalid classpath entry " << directoryName << endl; } startPosition = colonPosition + 1; } while(colonPosition < pathString.size()); return !pathList.empty(); }
void PluginDatabase::loadPersistentMetadataCache() { if (!isPersistentMetadataCacheEnabled() || persistentMetadataCachePath().isEmpty()) return; PlatformFileHandle file; String absoluteCachePath = pathByAppendingComponent(persistentMetadataCachePath(), persistentPluginMetadataCacheFilename); file = openFile(absoluteCachePath, OpenForRead); if (!isHandleValid(file)) return; // Mark cache as loaded regardless of success or failure. If // there's error in the cache, we won't try to load it anymore. m_persistentMetadataCacheIsLoaded = true; Vector<char> fileContents; fillBufferWithContentsOfFile(file, fileContents); closeFile(file); if (fileContents.size() < 2 || fileContents.first() != schemaVersion || fileContents.last() != '\0') { LOG_ERROR("Unable to read plugin metadata cache: corrupt schema"); deleteFile(absoluteCachePath); return; } char* bufferPos = fileContents.data() + 1; char* end = fileContents.data() + fileContents.size(); PluginSet cachedPlugins; HashMap<String, time_t> cachedPluginPathsWithTimes; HashMap<String, RefPtr<PluginPackage> > cachedPluginsByPath; while (bufferPos < end) { String path; time_t lastModified; String name; String desc; String mimeDesc; if (!(readUTF8String(path, bufferPos, end) && readTime(lastModified, bufferPos, end) && readUTF8String(name, bufferPos, end) && readUTF8String(desc, bufferPos, end) && readUTF8String(mimeDesc, bufferPos, end))) { LOG_ERROR("Unable to read plugin metadata cache: corrupt data"); deleteFile(absoluteCachePath); return; } // Skip metadata that points to plugins from directories that // are not part of plugin directory list anymore. String pluginDirectoryName = directoryName(path); if (m_pluginDirectories.find(pluginDirectoryName) == WTF::notFound) continue; RefPtr<PluginPackage> package = PluginPackage::createPackageFromCache(path, lastModified, name, desc, mimeDesc); if (package && cachedPlugins.add(package).isNewEntry) { cachedPluginPathsWithTimes.add(package->path(), package->lastModified()); cachedPluginsByPath.add(package->path(), package); } } m_plugins.swap(cachedPlugins); m_pluginsByPath.swap(cachedPluginsByPath); m_pluginPathsWithTimes.swap(cachedPluginPathsWithTimes); }
QString VdpauWidget::benchMixer() { QString directoryName(dataDirectory); directoryName.append("mpghd.dat"); MPEGDecoder *d = new MPEGDecoder( vc, directoryName ); if ( !d->init() ) { delete d; return "Can't initialize MPEG decoder!"; } if ( mixerWidth!=d->width || mixerHeight!=d->height ) createMixer( d->width, d->height ); QList< VdpVideoSurface > list = d->getOrderedFrames(); VdpStatus st = vc->vdp_output_surface_create( vc->vdpDevice, VDP_RGBA_FORMAT_B8G8R8A8, d->width, d->height, &mixerSurface ); if ( st != VDP_STATUS_OK ) { delete d; return "FATAL: Can't create mixer output surface !!\n"; } int i, loop=0; VdpRect vid_source = { 0, 0, d->width, d->height }; setSkipChroma( 0 ); // weave setDeinterlace( DEINT_BOB ); QTime t; int e; t.start(); while ( t.elapsed() < MIXERLOOP ) { for ( i=1; i<NUMSURFACES-1; ++i ) { vc->vdp_video_mixer_render( mixer, VDP_INVALID_HANDLE, 0, VDP_VIDEO_MIXER_PICTURE_STRUCTURE_FRAME, 0, 0, list.at(i), 0, 0, &vid_source, mixerSurface, &vid_source, &vid_source, 0, NULL ); } ++loop; } e = t.elapsed(); int n = (NUMSURFACES-2)*loop; benchMixerResult = QString("MIXER WEAVE (%1x%2): %3 frames/s\n").arg(d->width).arg(d->height).arg(n*1000/e); // bob loop = 0; t.start(); while ( t.elapsed() < MIXERLOOP ) { for ( i=1; i<NUMSURFACES-1; ++i ) { st = vc->vdp_video_mixer_render( mixer, VDP_INVALID_HANDLE, 0, VDP_VIDEO_MIXER_PICTURE_STRUCTURE_BOTTOM_FIELD, 0, 0, list.at(i), 0, 0, &vid_source, mixerSurface, &vid_source, &vid_source, 0, NULL ); if ( st != VDP_STATUS_OK ) fprintf( stderr, "vdp_video_mixer_render failed: %s\n", vc->vdp_get_error_string( st ) ); st = vc->vdp_video_mixer_render( mixer, VDP_INVALID_HANDLE, 0, VDP_VIDEO_MIXER_PICTURE_STRUCTURE_TOP_FIELD, 0, 0, list.at(i), 0, 0, &vid_source, mixerSurface, &vid_source, &vid_source, 0, NULL ); if ( st != VDP_STATUS_OK ) fprintf( stderr, "vdp_video_mixer_render failed: %s\n", vc->vdp_get_error_string( st ) ); } loop += 2; } e = t.elapsed(); n = (NUMSURFACES-2)*loop; benchMixerResult += QString("MIXER BOB (%1x%2): %3 fields/s\n").arg(d->width).arg(d->height).arg(n*1000/e); VdpVideoSurface past[2]; VdpVideoSurface future[1]; // temporal setDeinterlace( DEINT_TEMPORAL ); loop = 0; t.start(); while ( t.elapsed() < MIXERLOOP ) { for ( i=1; i<NUMSURFACES-1; ++i ) { past[1] = past[0] = list.at(i-1); future[0] = list.at(i); st = vc->vdp_video_mixer_render( mixer, VDP_INVALID_HANDLE, 0, VDP_VIDEO_MIXER_PICTURE_STRUCTURE_BOTTOM_FIELD, 2, past, list.at(i), 1, future, &vid_source, mixerSurface, &vid_source, &vid_source, 0, NULL ); if ( st != VDP_STATUS_OK ) fprintf( stderr, "vdp_video_mixer_render failed: %s\n", vc->vdp_get_error_string( st ) ); past[0] = list.at(i); future[0] = list.at(i+1); st = vc->vdp_video_mixer_render( mixer, VDP_INVALID_HANDLE, 0, VDP_VIDEO_MIXER_PICTURE_STRUCTURE_TOP_FIELD, 2, past, list.at(i), 1, future, &vid_source, mixerSurface, &vid_source, &vid_source, 0, NULL ); if ( st != VDP_STATUS_OK ) fprintf( stderr, "vdp_video_mixer_render failed: %s\n", vc->vdp_get_error_string( st ) ); } loop += 2; } e = t.elapsed(); n = (NUMSURFACES-2)*loop; benchMixerResult += QString("MIXER TEMPORAL (%1x%2): %3 fields/s\n").arg(d->width).arg(d->height).arg(n*1000/e); // temporal + ivtc setIvtc( 1 ); loop = 0; t.start(); while ( t.elapsed() < MIXERLOOP ) { for ( i=1; i<NUMSURFACES-1; ++i ) { past[1] = past[0] = list.at(i-1); future[0] = list.at(i); st = vc->vdp_video_mixer_render( mixer, VDP_INVALID_HANDLE, 0, VDP_VIDEO_MIXER_PICTURE_STRUCTURE_BOTTOM_FIELD, 2, past, list.at(i), 1, future, &vid_source, mixerSurface, &vid_source, &vid_source, 0, NULL ); if ( st != VDP_STATUS_OK ) fprintf( stderr, "vdp_video_mixer_render failed: %s\n", vc->vdp_get_error_string( st ) ); past[0] = list.at(i); future[0] = list.at(i+1); st = vc->vdp_video_mixer_render( mixer, VDP_INVALID_HANDLE, 0, VDP_VIDEO_MIXER_PICTURE_STRUCTURE_TOP_FIELD, 2, past, list.at(i), 1, future, &vid_source, mixerSurface, &vid_source, &vid_source, 0, NULL ); if ( st != VDP_STATUS_OK ) fprintf( stderr, "vdp_video_mixer_render failed: %s\n", vc->vdp_get_error_string( st ) ); } loop += 2; } e = t.elapsed(); n = (NUMSURFACES-2)*loop; benchMixerResult += QString("MIXER TEMPORAL + IVTC (%1x%2): %3 fields/s\n").arg(d->width).arg(d->height).arg(n*1000/e); setIvtc( 0 ); // temporal + skip_chroma setSkipChroma( 1 ); loop = 0; t.start(); while ( t.elapsed() < MIXERLOOP ) { for ( i=1; i<NUMSURFACES-1; ++i ) { past[1] = past[0] = list.at(i-1); future[0] = list.at(i); st = vc->vdp_video_mixer_render( mixer, VDP_INVALID_HANDLE, 0, VDP_VIDEO_MIXER_PICTURE_STRUCTURE_BOTTOM_FIELD, 2, past, list.at(i), 1, future, &vid_source, mixerSurface, &vid_source, &vid_source, 0, NULL ); if ( st != VDP_STATUS_OK ) fprintf( stderr, "vdp_video_mixer_render failed: %s\n", vc->vdp_get_error_string( st ) ); past[0] = list.at(i); future[0] = list.at(i+1); st = vc->vdp_video_mixer_render( mixer, VDP_INVALID_HANDLE, 0, VDP_VIDEO_MIXER_PICTURE_STRUCTURE_TOP_FIELD, 2, past, list.at(i), 1, future, &vid_source, mixerSurface, &vid_source, &vid_source, 0, NULL ); if ( st != VDP_STATUS_OK ) fprintf( stderr, "vdp_video_mixer_render failed: %s\n", vc->vdp_get_error_string( st ) ); } loop += 2; } e = t.elapsed(); n = (NUMSURFACES-2)*loop; benchMixerResult += QString("MIXER TEMPORAL + SKIP_CHROMA (%1x%2): %3 fields/s\n").arg(d->width).arg(d->height).arg(n*1000/e); setSkipChroma( 0 ); // temporal_spatial setDeinterlace( DEINT_TEMPORAL_SPATIAL ); loop = 0; t.start(); while ( t.elapsed() < MIXERLOOP ) { for ( i=1; i<NUMSURFACES-1; ++i ) { past[1] = past[0] = list.at(i-1); future[0] = list.at(i); st = vc->vdp_video_mixer_render( mixer, VDP_INVALID_HANDLE, 0, VDP_VIDEO_MIXER_PICTURE_STRUCTURE_BOTTOM_FIELD, 2, past, list.at(i), 1, future, &vid_source, mixerSurface, &vid_source, &vid_source, 0, NULL ); if ( st != VDP_STATUS_OK ) fprintf( stderr, "vdp_video_mixer_render failed: %s\n", vc->vdp_get_error_string( st ) ); past[0] = list.at(i); future[0] = list.at(i+1); st = vc->vdp_video_mixer_render( mixer, VDP_INVALID_HANDLE, 0, VDP_VIDEO_MIXER_PICTURE_STRUCTURE_TOP_FIELD, 2, past, list.at(i), 1, future, &vid_source, mixerSurface, &vid_source, &vid_source, 0, NULL ); if ( st != VDP_STATUS_OK ) fprintf( stderr, "vdp_video_mixer_render failed: %s\n", vc->vdp_get_error_string( st ) ); } loop += 2; } e = t.elapsed(); n = (NUMSURFACES-2)*loop; benchMixerResult += QString("MIXER TEMPORAL_SPATIAL (%1x%2): %3 fields/s\n").arg(d->width).arg(d->height).arg(n*1000/e); // temporal_spatial + ivtc setIvtc( 1 ); loop = 0; t.start(); while ( t.elapsed() < MIXERLOOP ) { for ( i=1; i<NUMSURFACES-1; ++i ) { past[1] = past[0] = list.at(i-1); future[0] = list.at(i); st = vc->vdp_video_mixer_render( mixer, VDP_INVALID_HANDLE, 0, VDP_VIDEO_MIXER_PICTURE_STRUCTURE_BOTTOM_FIELD, 2, past, list.at(i), 1, future, &vid_source, mixerSurface, &vid_source, &vid_source, 0, NULL ); if ( st != VDP_STATUS_OK ) fprintf( stderr, "vdp_video_mixer_render failed: %s\n", vc->vdp_get_error_string( st ) ); past[0] = list.at(i); future[0] = list.at(i+1); st = vc->vdp_video_mixer_render( mixer, VDP_INVALID_HANDLE, 0, VDP_VIDEO_MIXER_PICTURE_STRUCTURE_TOP_FIELD, 2, past, list.at(i), 1, future, &vid_source, mixerSurface, &vid_source, &vid_source, 0, NULL ); if ( st != VDP_STATUS_OK ) fprintf( stderr, "vdp_video_mixer_render failed: %s\n", vc->vdp_get_error_string( st ) ); } loop += 2; } e = t.elapsed(); n = (NUMSURFACES-2)*loop; benchMixerResult += QString("MIXER TEMPORAL_SPATIAL + IVTC (%1x%2): %3 fields/s\n").arg(d->width).arg(d->height).arg(n*1000/e); setIvtc( 0 ); // temporal_spatial + skip_chroma setSkipChroma( 1 ); loop = 0; t.start(); while ( t.elapsed() < MIXERLOOP ) { for ( i=1; i<NUMSURFACES-1; ++i ) { past[1] = past[0] = list.at(i-1); future[0] = list.at(i); st = vc->vdp_video_mixer_render( mixer, VDP_INVALID_HANDLE, 0, VDP_VIDEO_MIXER_PICTURE_STRUCTURE_BOTTOM_FIELD, 2, past, list.at(i), 1, future, &vid_source, mixerSurface, &vid_source, &vid_source, 0, NULL ); if ( st != VDP_STATUS_OK ) fprintf( stderr, "vdp_video_mixer_render failed: %s\n", vc->vdp_get_error_string( st ) ); past[0] = list.at(i); future[0] = list.at(i+1); st = vc->vdp_video_mixer_render( mixer, VDP_INVALID_HANDLE, 0, VDP_VIDEO_MIXER_PICTURE_STRUCTURE_TOP_FIELD, 2, past, list.at(i), 1, future, &vid_source, mixerSurface, &vid_source, &vid_source, 0, NULL ); if ( st != VDP_STATUS_OK ) fprintf( stderr, "vdp_video_mixer_render failed: %s\n", vc->vdp_get_error_string( st ) ); } loop += 2; } e = t.elapsed(); n = (NUMSURFACES-2)*loop; benchMixerResult += QString("MIXER TEMPORAL_SPATIAL + SKIP_CHROMA (%1x%2): %3 fields/s\n").arg(d->width).arg(d->height).arg(n*1000/e); setSkipChroma( 0 ); delete d; vc->vdp_output_surface_destroy( mixerSurface ); // SD directoryName.clear(); directoryName.append(dataDirectory); directoryName.append("mpgsd.dat"); d = new MPEGDecoder( vc, directoryName ); if ( !d->init() ) { delete d; return "Can't initialize MPEG decoder!"; } if ( mixerWidth!=d->width || mixerHeight!=d->height ) createMixer( d->width, d->height ); list = d->getOrderedFrames(); int sdwidth=1920, sdheight=1080; st = vc->vdp_output_surface_create( vc->vdpDevice, VDP_RGBA_FORMAT_B8G8R8A8, sdwidth, sdheight, &mixerSurface ); if ( st != VDP_STATUS_OK ) { delete d; return "FATAL: Can't create mixer output surface !!\n"; } vid_source.x1 = d->width; vid_source.y1 = d->height; VdpRect vid_dest = { 0, 0, sdwidth, sdheight }; // temporal_spatial SD setDeinterlace( DEINT_TEMPORAL_SPATIAL ); loop = 0; t.start(); while ( t.elapsed() < MIXERLOOP ) { for ( i=1; i<NUMSURFACES-1; ++i ) { past[1] = past[0] = list.at(i-1); future[0] = list.at(i); st = vc->vdp_video_mixer_render( mixer, VDP_INVALID_HANDLE, 0, VDP_VIDEO_MIXER_PICTURE_STRUCTURE_TOP_FIELD, 2, past, list.at(i), 1, future, &vid_source, mixerSurface, &vid_dest, &vid_dest, 0, NULL ); if ( st != VDP_STATUS_OK ) fprintf( stderr, "vdp_video_mixer_render failed: %s\n", vc->vdp_get_error_string( st ) ); past[0] = list.at(i); future[0] = list.at(i+1); st = vc->vdp_video_mixer_render( mixer, VDP_INVALID_HANDLE, 0, VDP_VIDEO_MIXER_PICTURE_STRUCTURE_BOTTOM_FIELD, 2, past, list.at(i), 1, future, &vid_source, mixerSurface, &vid_dest, &vid_dest, 0, NULL ); if ( st != VDP_STATUS_OK ) fprintf( stderr, "vdp_video_mixer_render failed: %s\n", vc->vdp_get_error_string( st ) ); } loop+=2; } e = t.elapsed(); n = (NUMSURFACES-2)*loop; benchMixerResult += QString("MIXER TEMPORAL_SPATIAL (%1x%2 video to 1920x1080 display): %3 fields/s\n").arg(d->width).arg(d->height).arg(n*1000/e); // temporal_spatial SD + hqScaling if ( vc->hqScalingSupported() ) { setHqScaling( 1 ); loop = 0; t.start(); while ( t.elapsed() < MIXERLOOP ) { for ( i=1; i<NUMSURFACES-1; ++i ) { past[1] = past[0] = list.at(i-1); future[0] = list.at(i); st = vc->vdp_video_mixer_render( mixer, VDP_INVALID_HANDLE, 0, VDP_VIDEO_MIXER_PICTURE_STRUCTURE_TOP_FIELD, 2, past, list.at(i), 1, future, &vid_source, mixerSurface, &vid_dest, &vid_dest, 0, NULL ); if ( st != VDP_STATUS_OK ) fprintf( stderr, "vdp_video_mixer_render failed: %s\n", vc->vdp_get_error_string( st ) ); past[0] = list.at(i); future[0] = list.at(i+1); st = vc->vdp_video_mixer_render( mixer, VDP_INVALID_HANDLE, 0, VDP_VIDEO_MIXER_PICTURE_STRUCTURE_BOTTOM_FIELD, 2, past, list.at(i), 1, future, &vid_source, mixerSurface, &vid_dest, &vid_dest, 0, NULL ); if ( st != VDP_STATUS_OK ) fprintf( stderr, "vdp_video_mixer_render failed: %s\n", vc->vdp_get_error_string( st ) ); } loop+=2; } e = t.elapsed(); n = (NUMSURFACES-2)*loop; benchMixerResult += QString("MIXER TEMPORAL_SPATIAL + HQSCALING (%1x%2 video to 1920x1080 display): %3 fields/s\n").arg(d->width).arg(d->height).arg(n*1000/e); setHqScaling( 0 ); } delete d; return benchMixerResult; }
// next 2 functions are the 2 threads. // the first one (the main thread) runs the decoder // the second one runs the mixer QString VdpauWidget::benchMT() { // init a mpeg decoder QString directoryName(dataDirectory); directoryName.append("mpghd.dat"); MPEGDecoder *m = new MPEGDecoder( vc, directoryName ); if ( !m->init() ) { delete m; return "Can't initialize MPEG decoder (1)!"; } // create the rgba surface used by the mixer VdpStatus st = vc->vdp_output_surface_create( vc->vdpDevice, VDP_RGBA_FORMAT_B8G8R8A8, m->width, m->height, &mixerSurface ); if ( st != VDP_STATUS_OK ) { delete m; return "FATAL: Can't create mixer output surface !!\n"; } if ( mixerWidth!=m->width || mixerHeight!=m->height ) createMixer( m->width, m->height ); setDeinterlace( DEINT_TEMPORAL ); // init the mixer thread // m->getOrderedFrames returns a list of 22 decoded surfaces in display order and destroys the decoder ... VdpauThread vt( vc, m->getOrderedFrames(), mixer, mixerSurface, m->width, m->height ); // ... so we can create a new one here directoryName.clear(); directoryName.append(dataDirectory); directoryName.append("mpghd.dat"); MPEGDecoder *d = new MPEGDecoder( vc, directoryName ); if ( !d->init( true ) ) { delete d; delete m; vc->vdp_output_surface_destroy( mixerSurface ); return "Can't initialize MPEG decoder (2)!"; } vt.running = true; // start the mixer thread vt.start(); int loop=0; QTime t; t.start(); // this is the decoder loop while ( t.elapsed() < MIXERLOOP ) { // decode next frame (25 frames in turn) d->getNextFrame(); ++loop; } int e = t.elapsed(); vt.running = false; // wait for the mixer thread to end vt.wait(); benchMTResult = QString("MULTITHREADED MPEG DECODING (%1x%2): %3 frames/s\n").arg(d->width).arg(d->height).arg(loop*1000/e); benchMTResult += vt.result; delete d; delete m; vc->vdp_output_surface_destroy( mixerSurface ); return benchMTResult; }
void COwnedLostItem::GiveControlToNetscape() { char buffer[_MAX_PATH]; ::GetModuleFileName(theApp.m_hInstance, buffer, _MAX_PATH); // Get the app's directory into a short file name char shortBuffer[_MAX_PATH]; GetShortPathName(buffer, shortBuffer, _MAX_PATH); CString directoryName(shortBuffer); directoryName.MakeUpper(); // This is what we'll write to the registry CString strValueName, strCmdPath; // Special Internet Shortcut check if (IsInternetShortcut()) { CInternetShortcut internetShortcut; if (internetShortcut.ShellSupport()) { // Need to take over lots of stuff CString strType = GetInternetShortcutFileClass(); // Set the open command path strValueName.Format(strOPEN_CMD_FMT, (const char *)strType); strCmdPath = directoryName + " -h \"%1\""; FEU_RegistryWizard(HKEY_CLASSES_ROOT, strValueName, strCmdPath); // Set the DDE exec value strValueName.Format(strDDE_EXEC_FMT, (const char *)strType); FEU_RegistryWizard(HKEY_CLASSES_ROOT, strValueName, strDDE_EXEC_VALUE); // Set the DDE app name strValueName.Format(strDDE_APP_FMT, (const char *)strType); FEU_RegistryWizard(HKEY_CLASSES_ROOT, strValueName, strDDE_APP_NAME); // Set the DDE topic strValueName.Format(strDDE_TOPIC_FMT, (const char *)strType); CString strDDETopic; strDDETopic.LoadString(IDS_DDE_OPENURL); FEU_RegistryWizard(HKEY_CLASSES_ROOT, strValueName, strDDETopic); // Set the Default Icon CString strIconPath; if ((strType == "news") || (strType == "snews")) { // Use the news icon from URL.DLL ::GetSystemDirectory(buffer, _MAX_PATH); strIconPath = CString(buffer) + "\\URL.DLL,1"; } else { // Use the document icon strIconPath = CString(buffer) + ",1"; } strValueName.Format(strDEF_ICON_FMT, (const char *)strType); FEU_RegistryWizard(HKEY_CLASSES_ROOT, strValueName, strIconPath); // Take over printing (applies to ALL Internet Shortcuts. If we own one, we'll take // over printing for ALL of them). CString csMunge = directoryName + " /print(\"%1\")"; FEU_RegistryWizard(HKEY_CLASSES_ROOT, "InternetShortcut\\shell\\print\\command", csMunge); FEU_RegistryWizard(HKEY_CLASSES_ROOT, "InternetShortcut\\shell\\print\\ddeexec", "[print(\"%1\")]"); FEU_RegistryWizard(HKEY_CLASSES_ROOT, "InternetShortcut\\shell\\print\\ddeexec\\Application", strDDE_APP_NAME); // The PrintTo Command. csMunge = directoryName + " /printto(\"%1\",\"%2\",\"%3\",\"%4\")"; FEU_RegistryWizard(HKEY_CLASSES_ROOT, "InternetShortcut\\shell\\PrintTo\\command", csMunge); FEU_RegistryWizard(HKEY_CLASSES_ROOT, "InternetShortcut\\shell\\PrintTo\\ddeexec", "[printto(\"%1\",\"%2\",\"%3\",\"%4\")]"); FEU_RegistryWizard(HKEY_CLASSES_ROOT, "InternetShortcut\\shell\\PrintTo\\ddeexec\\Application", strDDE_APP_NAME); } return; } CPtrList* allHelpers = &(CHelperApp::m_cplHelpers); for (POSITION pos = allHelpers->GetHeadPosition(); pos != NULL;) { CHelperApp* app = (CHelperApp*)allHelpers->GetNext(pos); CString helperMime(app->cd_item->ci.type); if (helperMime == m_csMimeType) { // Found the helper app. Get the file class. CString fileClass(app->strFileClass); if (fileClass != "") { // We have some registry work to do. // In the case where this is text/html, we point .htm and .html to // NetscapeMarkup. HKEY hKey; DWORD dwDisp; if (m_csMimeType == "text/html") { ::RegCreateKeyEx(HKEY_CLASSES_ROOT, ".htm", 0L, NULL, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &hKey, &dwDisp); ::RegSetValueEx(hKey, NULL, 0L, REG_SZ, (const BYTE *)((const char *)strMARKUP_KEY), strMARKUP_KEY.GetLength() + 1); ::RegCloseKey(hKey); ::RegCreateKeyEx(HKEY_CLASSES_ROOT, ".html", 0L, NULL, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &hKey, &dwDisp); ::RegSetValueEx(hKey, NULL, 0L, REG_SZ, (const BYTE *)((const char *)strMARKUP_KEY), strMARKUP_KEY.GetLength() + 1); ::RegCloseKey(hKey); } // In the case where this is application/x-unknown-content-type-NetscapeMarkup, // we point .shtml to NetscapeMarkup. else if (m_csMimeType == "application/x-unknown-content-type-NetscapeMarkup") { ::RegCreateKeyEx(HKEY_CLASSES_ROOT, ".shtml", 0L, NULL, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &hKey, &dwDisp); ::RegSetValueEx(hKey, NULL, 0L, REG_SZ, (const BYTE *)((const char *)strMARKUP_KEY), strMARKUP_KEY.GetLength() + 1); ::RegCloseKey(hKey); } // In all other cases, we should use the existing file class else { // Need to take over lots of stuff CString strType = fileClass; if (strType == "NetscapeMarkup") return; // Don't let ANYTHING mess with NetscapeMarkup. // Someone might point something to it later, and // we don't want this code changing the stuff that's already there. // Set the open command path strValueName.Format(strOPEN_CMD_FMT, (const char *)strType); strCmdPath = directoryName + " \"%1\""; FEU_RegistryWizard(HKEY_CLASSES_ROOT, strValueName, strCmdPath); // Set the DDE exec value strValueName.Format(strDDE_EXEC_FMT, (const char *)strType); FEU_RegistryWizard(HKEY_CLASSES_ROOT, strValueName, strDDE_EXEC_VALUE); // Set the DDE app name strValueName.Format(strDDE_APP_FMT, (const char *)strType); FEU_RegistryWizard(HKEY_CLASSES_ROOT, strValueName, strDDE_APP_NAME); // Set the DDE topic strValueName.Format(strDDE_TOPIC_FMT, (const char *)strType); CString strDDETopic; strDDETopic.LoadString(IDS_DDE_OPENURL); FEU_RegistryWizard(HKEY_CLASSES_ROOT, strValueName, strDDETopic); // Set the Default Icon CString strIconPath; CString iconString = ",1"; if (m_csMimeType == "text/x-javascript" || m_csMimeType == "application/x-javascript") iconString = ",7"; else if (m_csMimeType.Left(5) == "image") iconString = ",6"; strIconPath = CString(buffer) + iconString; strValueName.Format(strDEF_ICON_FMT, (const char *)strType); FEU_RegistryWizard(HKEY_CLASSES_ROOT, strValueName, strIconPath); } } return; } } }