void MP4Reader::UpdateIndex() { if (!mIndexReady) { return; } AutoPinned<MediaResource> resource(mDecoder->GetResource()); nsTArray<MediaByteRange> ranges; if (NS_SUCCEEDED(resource->GetCachedRanges(ranges))) { mDemuxer->UpdateIndex(ranges); } }
media::TimeIntervals MP4TrackDemuxer::GetBuffered() { EnsureUpToDateIndex(); AutoPinned<MediaResource> resource(mParent->mResource); MediaByteRangeSet byteRanges; nsresult rv = resource->GetCachedRanges(byteRanges); if (NS_FAILED(rv)) { return media::TimeIntervals(); } return mIndex->ConvertByteRangesToTimeRanges(byteRanges); }
TiXmlElement* XMLResourceLoader::LoadAndReturnRootXmlElement(const char* ResourceString) { Resource resource(ResourceString); shared_ptr<ResHandle> pResourceHandle = g_pApp->m_ResCache->GetHandle(&resource); // this actually loads the XML file from the zip file if (pResourceHandle == NULL) { LOG("XML Resource not found, actor creation aborted:"); LOG(ResourceString); return NULL; } shared_ptr<XMLResourceExtraData> pExtraData = static_pointer_cast<XMLResourceExtraData>(pResourceHandle->GetExtra()); return pExtraData->GetRoot(); }
void tst_QMediaResource::setResolution() { QMediaResource resource( QUrl(QString::fromLatin1("file::///thumbs/test.png")), QString::fromLatin1("image/png")); QCOMPARE(resource.resolution(), QSize()); resource.setResolution(QSize(120, 80)); QCOMPARE(resource.resolution(), QSize(120, 80)); resource.setResolution(QSize(-1, 23)); QCOMPARE(resource.resolution(), QSize(-1, 23)); resource.setResolution(QSize(-43, 34)); QCOMPARE(resource.resolution(), QSize(-43, 34)); resource.setResolution(QSize(64, -1)); QCOMPARE(resource.resolution(), QSize(64, -1)); resource.setResolution(QSize(64, -83)); QCOMPARE(resource.resolution(), QSize(64, -83)); resource.setResolution(QSize(-12, -83)); QCOMPARE(resource.resolution(), QSize(-12, -83)); resource.setResolution(QSize()); QCOMPARE(resource.resolution(), QSize(-1, -1)); resource.setResolution(120, 80); QCOMPARE(resource.resolution(), QSize(120, 80)); resource.setResolution(-1, 23); QCOMPARE(resource.resolution(), QSize(-1, 23)); resource.setResolution(-43, 34); QCOMPARE(resource.resolution(), QSize(-43, 34)); resource.setResolution(64, -1); QCOMPARE(resource.resolution(), QSize(64, -1)); resource.setResolution(64, -83); QCOMPARE(resource.resolution(), QSize(64, -83)); resource.setResolution(-12, -83); QCOMPARE(resource.resolution(), QSize(-12, -83)); resource.setResolution(-1, -1); QCOMPARE(resource.resolution(), QSize()); }
// // Alpha_D3D11NormalTexturePixelShader::OnRestore() // HRESULT Alpha_D3D11NormalTexturePixelShader::OnRestore(Scene *pScene) { HRESULT hr = S_OK; SAFE_RELEASE(m_pPixelShader); SAFE_RELEASE(m_pcbPSLighting); SAFE_RELEASE(m_pcbPSMaterial); shared_ptr<D3DRenderer11> d3dRenderer11 = static_pointer_cast<D3DRenderer11>(pScene->GetRenderer()); //======================================================== // Set up the pixel shader and related constant buffers ID3DBlob* pPixelShaderBuffer = NULL; // Load the file via the Resource controller std::string hlslFileName = "Effects\\Alpha_D3D11VertexPosNormalTexture.fx"; Resource resource(hlslFileName.c_str()); shared_ptr<ResHandle> pResourceHandle = g_pApp->m_ResCache->GetHandle(&resource); // Compile the shader if(FAILED(d3dRenderer11->CompileShader(pResourceHandle->Buffer(), pResourceHandle->Size(), hlslFileName.c_str(), "Alpha_PS", "ps_5_0", &pPixelShaderBuffer))) { SAFE_RELEASE (pPixelShaderBuffer); return hr; } // Create the shader if(SUCCEEDED(g_pDX11W->GetD3D11Device()->CreatePixelShader(pPixelShaderBuffer->GetBufferPointer(), pPixelShaderBuffer->GetBufferSize(), NULL, &m_pPixelShader))) { // Setup constant buffers D3D11_BUFFER_DESC constantBufferDesc; ZeroMemory(&constantBufferDesc, sizeof(constantBufferDesc)); constantBufferDesc.Usage = D3D11_USAGE_DYNAMIC; constantBufferDesc.BindFlags = D3D11_BIND_CONSTANT_BUFFER; constantBufferDesc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE; constantBufferDesc.MiscFlags = 0; // Create lighting constant buffer constantBufferDesc.ByteWidth = sizeof(ConstantBuffer_Lighting); V_RETURN(g_pDX11W->GetD3D11Device()->CreateBuffer(&constantBufferDesc, NULL, &m_pcbPSLighting)); // Create material constant buffer constantBufferDesc.ByteWidth = sizeof(ConstantBuffer_Material); V_RETURN(g_pDX11W->GetD3D11Device()->CreateBuffer(&constantBufferDesc, NULL, &m_pcbPSMaterial)); } SAFE_RELEASE(pPixelShaderBuffer); return hr; }
//! Instructs the content of the latest version to be cached. void ObjectCore::requestLatestVersion() { // Start caching the latest version. ObjectVersionCore* latest = this->latest(); if( latest == 0 ) { // Fetch information about the latest version. QString resource("/objects/%1/%2/latest?include=properties,propertiesForDisplay"); QString args = resource.arg( m_id.type() ).arg( m_id.id() ); QNetworkReply* reply = this->rest()->getJson( args ); QObject::connect( reply, &QNetworkReply::finished, [=]() { this->versionAvailable( reply, true ); } ); } }
NS_IMETHODIMP nsAbBSDirectory::DeleteDirectory(nsIAbDirectory *directory) { NS_ENSURE_ARG_POINTER(directory); nsresult rv = EnsureInitialized(); NS_ENSURE_SUCCESS(rv, rv); DIR_Server *server = nsnull; mServers.Get(directory, &server); if (!server) return NS_ERROR_FAILURE; GetDirectories getDirectories(server); mServers.EnumerateRead(GetDirectories_getDirectory, (void*)&getDirectories); DIR_DeleteServerFromList(server); nsCOMPtr<nsIAbDirFactoryService> dirFactoryService = do_GetService(NS_ABDIRFACTORYSERVICE_CONTRACTID,&rv); NS_ENSURE_SUCCESS (rv, rv); PRUint32 count = getDirectories.directories.Count(); nsCOMPtr<nsIAbManager> abManager = do_GetService(NS_ABMANAGER_CONTRACTID); for (PRUint32 i = 0; i < count; i++) { nsCOMPtr<nsIAbDirectory> d = getDirectories.directories[i]; mServers.Remove(d); rv = mSubDirectories.RemoveObject(d); if (abManager) abManager->NotifyDirectoryDeleted(this, d); nsCOMPtr<nsIRDFResource> resource(do_QueryInterface (d, &rv)); nsCString uri; resource->GetValueUTF8(uri); nsCOMPtr<nsIAbDirFactory> dirFactory; rv = dirFactoryService->GetDirFactory(uri, getter_AddRefs(dirFactory)); if (NS_FAILED(rv)) continue; rv = dirFactory->DeleteDirectory(d); } return rv; }
http::doc pref() { http::doc ret = resource("html/pref.html"); std::vector<std::string> sects = templ::split(ret.content(), 3, "pref.html"); std::stringstream buf{}; buf << sects[0]; for (const std::string &prefname : prefs::list()) { buf << templ::render(sects[1], {{"name", prefs::desc(prefname)}, {"key", prefname}, {"value", prefs::getstr(prefname)}, {"type", prefs::type(prefname)}}); } buf << sects[2]; ret.content(buf.str()); return ret; }
bool Cache::prefetch(const BinaryString &target) { // Test local availability if(Store::Instance->hasBlock(target)) { Resource resource(target, true); // local only if(resource.isLocallyAvailable()) return true; } mScheduler.schedule(Scheduler::clock::now(), [target]() { try { Resource resource(target); Resource::Reader reader(&resource); reader.discard(); // read everything } catch(const Exception &e) { LogWarn("Cache::prefetch", "Prefetching failed for " + target.toString()); } }); return false; }
void PendingScript::watchForLoad(ScriptResourceClient* client) { ASSERT(!m_watchingForLoad); // addClient() will call notifyFinished() if the load is complete. Callers // who do not expect to be re-entered from this call should not call // watchForLoad for a PendingScript which isReady. We also need to set // m_watchingForLoad early, since addClient() can result in calling // notifyFinished and further stopWatchingForLoad(). m_watchingForLoad = true; if (m_streamer) { m_streamer->addClient(client); } else { resource()->addClient(client); } }
MaterialNode::MaterialNode(std::string sMaterialResourceName, WeakBaseRenderComponentPtr renderComponent) { Resource resource(sMaterialResourceName); shared_ptr<ResHandle> handle = g_pApp->m_ResCache->GetHandle(&resource); if (handle.get() == NULL) { CHG_ERROR("Not found material resource: " + sMaterialResourceName); } m_pMaterial = ((MaterialResourceExtraData*)handle->GetExtra().get())->GetMaterial(); m_pRenderComponent = renderComponent; m_bActivePOM = false; }
void onDraw(const int loops, SkCanvas* canvas) override { if (!fContext) { return; } GrResourceCache* cache = fContext->getResourceCache(); SkASSERT(CACHE_SIZE_COUNT == cache->getResourceCount()); for (int i = 0; i < loops; ++i) { for (int k = 0; k < CACHE_SIZE_COUNT; ++k) { GrUniqueKey key; BenchResource::ComputeKey(k, fKeyData32Count, &key); SkAutoTUnref<GrGpuResource> resource(cache->findAndRefUniqueResource(key)); SkASSERT(resource); } } }
void EncodeDock::onProducerOpened() { if (MLT.isSeekable()) ui->encodeButton->setText(tr("Export File")); else ui->encodeButton->setText(tr("Capture File")); ui->fromCombo->blockSignals(true); ui->fromCombo->clear(); if (MAIN.multitrack()) ui->fromCombo->addItem(tr("Timeline"), "timeline"); if (MAIN.playlist() && MAIN.playlist()->count() > 0) ui->fromCombo->addItem(tr("Playlist"), "playlist"); if (MAIN.playlist() && MAIN.playlist()->count() > 1) ui->fromCombo->addItem(tr("Each Playlist Item"), "batch"); if (MLT.isClip() && MLT.producer() && MLT.producer()->is_valid()) { if (MLT.producer()->get(kShotcutCaptionProperty)) { ui->fromCombo->addItem(MLT.producer()->get(kShotcutCaptionProperty), "clip"); } else if (MLT.producer()->get("resource")) { QFileInfo resource(MLT.producer()->get("resource")); ui->fromCombo->addItem(resource.completeBaseName(), "clip"); } else { ui->fromCombo->addItem(tr("Source"), "clip"); } } else if (MLT.savedProducer() && MLT.savedProducer()->is_valid()) { if (MLT.savedProducer()->get(kShotcutCaptionProperty)) { ui->fromCombo->addItem(MLT.savedProducer()->get(kShotcutCaptionProperty), "clip"); } else if (MLT.savedProducer()->get("resource")) { QFileInfo resource(MLT.savedProducer()->get("resource")); ui->fromCombo->addItem(resource.completeBaseName(), "clip"); } else { ui->fromCombo->addItem(tr("Source"), "clip"); } } ui->fromCombo->blockSignals(false); }
bool QResourceFileEngineIterator::hasNext() const { if (index == -1) { // Lazy initialization of the iterator QResource resource(path()); if (!resource.isValid()) return false; // Initialize and move to the next entry. entries = resource.children(); index = 0; } return index < entries.size(); }
// // Alpha_Hlsl_LineShader::SetTexture - Chapter 15, page 519 // HRESULT Alpha_Hlsl_LineShader::SetTexture(const std::string& textureName) { m_textureResource = textureName; if (m_textureResource.length() > 0) { Resource resource(m_textureResource); shared_ptr<ResHandle> texture = g_pApp->m_ResCache->GetHandle(&resource); if (texture) { shared_ptr<D3DTextureResourceExtraData11> extra = static_pointer_cast<D3DTextureResourceExtraData11>(texture->GetExtra()); SetTexture(extra->GetTexture(), extra->GetSampler()); } } return S_OK; }
SkinsPlugIn::~SkinsPlugIn() { if (mpSkinsMenu != NULL) { qApp->setStyleSheet(mDefaultStyleSheet); QMapIterator<QString, QString> resource(mRegisteredResources); while (resource.hasNext()) { resource.next(); QResource::unregisterResource(resource.value(), resource.key()); } Service<DesktopServices>()->getMainMenuBar()->removeMenu(mpSkinsMenu); } delete mpSkinsMenu; }
Message JabberChatService::handleNormalReceivedMessage(const QXmppMessage &xmppMessage) { auto jid = Jid::parse(xmppMessage.from()); auto contact = ContactManager::instance()->byId(account(), jid.bare(), ActionCreateAndAdd); auto chat = ChatTypeContact::findChat(contact, ActionCreateAndAdd); contact.addProperty("jabber:chat-resource", jid.resource(), CustomProperties::NonStorable); auto message = Message::create(); message.setMessageChat(chat); message.setMessageSender(contact); return message; }
void MP4TrackDemuxer::EnsureUpToDateIndex() { if (!mNeedReIndex) { return; } AutoPinned<MediaResource> resource(mParent->mResource); MediaByteRangeSet byteRanges; nsresult rv = resource->GetCachedRanges(byteRanges); if (NS_FAILED(rv)) { return; } mIndex->UpdateMoofIndex(byteRanges); mNeedReIndex = false; }
void MgServerSiteService::DestroySession(CREFSTRING session) { MG_SITE_SERVICE_TRY() MG_LOG_TRACE_ENTRY(L"MgServerSiteService::DestroySession()"); MgResourceIdentifier resource(MgRepositoryType::Session, session, L"", L"", MgResourceType::Folder); GetResourceService().DeleteRepository(&resource); MgLongTransactionManager::RemoveLongTransactionNames(session); MgSessionManager::RemoveSession(session); MG_SITE_SERVICE_CATCH_AND_THROW(L"MgServerSiteService.DestroySession") }
bool BaseGameLogic::loadGame(const std::string& resource_name) { LOGI << "Loading game from resource '" << resource_name << "'." << endl; LOGINC; // Load the resource. LOGI << "Loading the resource." << endl; Resource resource(resource_name); StrongResourceHandlePtr resource_handle = res_cache_->getHandle(resource); // Parse the resource. LOGI << "Parsing the resource." << endl; rapidxml::xml_document<> xml_doc; xml_doc.parse<0>(reinterpret_cast<char*>(resource_handle->getBuffer())); // Get the root node (Should normally be <World>). rapidxml::xml_node<>* xml_root = xml_doc.first_node(); if (!xml_root) { LOGE << "No root node in game resource '" << resource_name << "'." << endl; return false; } LOG(LOGDEBUG) << "Root node: '" << xml_root->name() << "'." << endl; // Iterate over all actor nodes and create the actors. rapidxml::xml_node<>* xml_actor = xml_root->first_node("Actor"); while (xml_actor) { std::string actor_resource = xml_actor->first_attribute("resource")->value(); LOG(LOGDEBUG) << "Actor node resource attribute: '" << actor_resource << "'." << endl; if (!createActor(actor_resource)) { LOGE << "Creation of actor from resource '" << actor_resource << "' failed." << endl; return false; } xml_actor = xml_actor->next_sibling(); } LOGDEC; return true; }
http::doc content(Volume &vol, const std::string &path, bool toolbar = false) { if (! path.size()) return http::redirect(http::mkpath({"content", vol.id(), vol.info("home")})); try { std::pair<std::string, std::string> contpair = vol.get(path); if (toolbar && contpair.first == "text/html") { http::doc toolbar = resource("html/toolbar.html"); toolbar.content(templ::render(toolbar.content(), vol.tokens(path))); contpair.second = inject(contpair.second, toolbar.content()); } return http::doc{contpair.first, contpair.second}; } catch (Volume::error &e) { return error(e.header(), e.body()); } }
Binary::Container::Ptr Open(const String& path, const Parameters::Accessor& params, Log::ProgressCallback& cb) const override { try { const NetworkProviderParameters options(params); RemoteResource resource(Api); resource.SetSource(path); resource.SetOptions(options); resource.SetProgressCallback(cb); return resource.Download(); } catch (const Error& e) { throw MakeFormattedError(THIS_LINE, translate("Failed to open network resource '%1%'."), path).AddSuberror(e); } }
// ----------------------------------------------------------------------------- // CMmConferenceCallMessHandler::ReceiveMessageL // Called when an ISI message has been received. // ----------------------------------------------------------------------------- // void CMmConferenceCallMessHandler::ReceiveMessageL( const TIsiReceiveC& aIsiMsg ) { TFLOGSTRING("TSY: CMmConferenceCallMessHandler::ReceiveMessageL."); OstTrace0( TRACE_NORMAL, CMMCONFERENCECALLMESSHANDLER_RECEIVEMESSAGEL_TD, "CMmConferenceCallMessHandler::ReceiveMessageL" ); TInt resource( aIsiMsg.Get8bit( ISI_HEADER_OFFSET_RESOURCEID ) ); TInt messageId( aIsiMsg.Get8bit( ISI_HEADER_OFFSET_MESSAGEID ) ); switch( resource ) { case PN_MODEM_CALL: { switch( messageId ) { case CALL_MODEM_CONTROL_IND: { CallControlInd( aIsiMsg ); break; } case CALL_MODEM_CONTROL_RESP: { CallControlResp( aIsiMsg ); break; } case CALL_MODEM_RELEASE_RESP: { CallReleaseResp( aIsiMsg ); break; } default: { TFLOGSTRING("TSY: CMmConferenceCallMessHandler::ReceiveMessageL. PN_CALL Switch messageID case default."); OstTrace0( TRACE_NORMAL, DUP1_CMMCONFERENCECALLMESSHANDLER_RECEIVEMESSAGEL_TD, "CMmConferenceCallMessHandler::ReceiveMessageL. PN_CALL Switch messageID case default" ); break; } } break; // Case PN_CALL } default: { TFLOGSTRING("TSY: CMmConferenceCallMessHandler::ReceiveMessageL. Switch resource case default."); OstTrace0( TRACE_NORMAL, DUP2_CMMCONFERENCECALLMESSHANDLER_RECEIVEMESSAGEL_TD, "CMmConferenceCallMessHandler::ReceiveMessageL. Switch resource case default" ); break; } } }
/* * Create a bareos-fd director resource file * that corresponds to our client definition. */ static inline bool configure_create_fd_resource(UAContext *ua, const char *clientname) { POOL_MEM resource(PM_MESSAGE); POOL_MEM filename_tmp(PM_FNAME); POOL_MEM filename(PM_FNAME); POOL_MEM basedir(PM_FNAME); POOL_MEM temp(PM_MESSAGE); const char *dirname = NULL; const bool error_if_exists = false; const bool create_directories = true; const bool overwrite = true; if (!configure_create_fd_resource_string(ua, resource, clientname)) { return false; } /* * Get the path where the resource should get stored. */ basedir.bsprintf("bareos-dir-export/client/%s/bareos-fd.d", clientname); dirname = GetNextRes(R_DIRECTOR, NULL)->name; if (!my_config->get_path_of_new_resource(filename, temp, basedir.c_str(), "director", dirname, error_if_exists, create_directories)) { ua->error_msg("%s", temp.c_str()); return false; } filename_tmp.strcpy(temp); /* * Write resource to file. */ if (!configure_write_resource(filename.c_str(), "filedaemon-export", clientname, resource.c_str(), overwrite)) { ua->error_msg("failed to write filedaemon config resource file\n"); return false; } ua->send->object_start("export"); ua->send->object_key_value("clientname", clientname); ua->send->object_key_value("component", "bareos-fd"); ua->send->object_key_value("resource", "director"); ua->send->object_key_value("name", dirname); ua->send->object_key_value("filename", filename.c_str(), "Exported resource file \"%s\":\n"); ua->send->object_key_value("content", resource.c_str(), "%s"); ua->send->object_end("export"); return true; }
std::string WLink::url() const { switch (type_) { case Url: #ifndef WT_CNOR return boost::get<std::string>(value_); #else return boost::any_cast<std::string>(value_); #endif case Resource: return resource()->url(); case InternalPath: return WApplication::instance()->bookmarkUrl(internalPath().toUTF8()); } return std::string(); }
bool Platform::bytesFromFileSystem(const char* _path, std::function<char*(size_t)> _allocator) const { std::ifstream resource(_path, std::ifstream::ate | std::ifstream::binary); if(!resource.is_open()) { LOGW("Failed to read file at path: %s", _path); return false; } size_t size = resource.tellg(); char* cdata = _allocator(size); resource.seekg(std::ifstream::beg); resource.read(cdata, size); resource.close(); return true; }
void DocumentThreadableLoader::reportResponseReceived( unsigned long identifier, const ResourceResponse& response) { LocalFrame* frame = document().frame(); // We are seeing crashes caused by nullptr (crbug.com/578849). But the frame // must be set here. TODO(horo): Find the root cause of the unset frame. DCHECK(frame); if (!frame) return; TRACE_EVENT1( "devtools.timeline", "ResourceReceiveResponse", "data", InspectorReceiveResponseEvent::data(identifier, frame, response)); DocumentLoader* loader = frame->loader().documentLoader(); InspectorInstrumentation::didReceiveResourceResponse( frame, identifier, loader, response, resource()); frame->console().reportResourceResponseReceived(loader, identifier, response); }
void JabberRoomChat::participantChanged(const QString &id) { auto jid = Jid::parse(id); auto contact = m_contactManager->byId(m_chat.chatAccount(), id, ActionCreateAndAdd); auto buddy = m_buddyManager->byContact(contact, ActionCreateAndAdd); buddy.setDisplay(jid.resource()); buddy.setTemporary(true); auto status = m_presenceService->presenceToStatus(m_room->participantPresence(id)); contact.setCurrentStatus(status); auto details = static_cast<ChatDetailsRoom *>(m_chat.details()); if (status.isDisconnected()) details->removeContact(contact); else details->addContact(contact); }
//! Requests the properties for display to be fetched. void ObjectVersionCore::requestPropertiesForDisplay() { // Fetch information about the latest version. QString resource( "/objects/%1/%2/%3/properties?forDisplay=true" ); QString args = resource.arg( m_objver.type() ).arg( m_objver.id() ).arg( m_objver.version() ); QNetworkReply* reply = this->rest()->getJson( args ); QObject::connect( reply, &QNetworkReply::finished, [=]() { // Parse the returned JSON. QByteArray replyContent = reply->readAll(); QJsonDocument result = QJsonDocument::fromJson( replyContent ); QJsonArray propertiesForDisplay = result.array(); // Store the properties for display. this->setPropertiesForDisplay( propertiesForDisplay ); } ); }
bool NormalMaterialComponent::VLoad(XMLElement* pData) { assert(pData); XMLElement* pTexture = pData->FirstChildElement("Texture"); if (pTexture) { m_textureName = pTexture->Attribute("Name"); Resource resource(m_textureName); shared_ptr<ResHandle> resHandle = engine->m_pResCache->GetHandle(&resource); shared_ptr<TextureResourceExtraData> extra = static_pointer_cast<TextureResourceExtraData>(resHandle->GetExtra()); //m_pTexture = extra->m_texture; } return true; }