bool Buffer::SetStorage(UInt32 storage) { #if NAZARA_UTILITY_SAFE if (!m_impl) { NazaraError("Buffer not valid"); return false; } #endif if (m_storage == storage) return true; if (!IsStorageSupported(storage)) { NazaraError("Storage not supported"); return false; } void* ptr = m_impl->Map(BufferAccess_ReadOnly, 0, m_size); if (!ptr) { NazaraError("Failed to map buffer"); return false; } CallOnExit unmapMyImpl([this]() { m_impl->Unmap(); }); std::unique_ptr<AbstractBuffer> impl(s_bufferFactories[storage](this, m_type)); if (!impl->Create(m_size, m_usage)) { NazaraError("Failed to create buffer"); return false; } CallOnExit destroyImpl([&impl]() { impl->Destroy(); }); if (!impl->Fill(ptr, 0, m_size)) { NazaraError("Failed to fill buffer"); return false; } destroyImpl.Reset(); unmapMyImpl.CallAndReset(); m_impl->Destroy(); delete m_impl; m_impl = impl.release(); m_storage = storage; return true; }
Error Surface::onDestroy(const Display *display) { mDestroyed = true; if (mRefCount == 0) { return destroyImpl(display); } return NoError(); }
Error Surface::releaseRef(const Display *display) { ASSERT(mRefCount > 0); mRefCount--; if (mRefCount == 0 && mDestroyed) { ASSERT(display); return destroyImpl(display); } return NoError(); }
TyErrorId EngineBase::destroy() { try { util::Trace clTrace(util::enTraceDetailLow, UIMA_TRACE_ORIGIN, UIMA_TRACE_COMPID_ENGINE); if (!checkAndSetCallingSequenceDestroy()) { return logError(clTrace, UIMA_ERR_ENGINE_INVALID_CALLING_SEQUENCE); } return destroyImpl(); } catch (Exception& rclException) { getAnnotatorContext().getLogger().logError(rclException.getErrorInfo()); return rclException.getErrorInfo().getErrorId(); } }
Error Surface::setIsCurrent(const gl::Context *context, bool isCurrent) { if (isCurrent) { mCurrentCount++; return NoError(); } ASSERT(mCurrentCount > 0); mCurrentCount--; if (mCurrentCount == 0 && mDestroyed) { ASSERT(context); return destroyImpl(context->getCurrentDisplay()); } return NoError(); }