コード例 #1
0
ファイル: main.cpp プロジェクト: Manuzor/LispCpp
            EZ_FORCE_INLINE
            void blockHandler(const LogBlockInfo& blockInfo)
            {
                switch(blockInfo.action)
                {
                case LogBlockAction::Begin:
                {
                    auto pBlock = EZ_NEW(lcpp::defaultAllocator(), ezLogBlock) { m_pInterface, blockInfo.name.cString() };
                    m_logBlocks.PushBack(pBlock);
                    break;
                }
                case LogBlockAction::End:
                {
                    EZ_ASSERT(m_logBlocks.GetCount() > 0, "Invalid state of the LogBlock stack.");

                    auto& pBlock = m_logBlocks.PeekBack();
                    EZ_DELETE(lcpp::defaultAllocator(), pBlock);
                    m_logBlocks.PopBack();
                    break;
                }
                default:
                    EZ_REPORT_FAILURE("Unknown LogBlockAction.");
                    ezLog::Warning("Unknown LogBlockAction.");
                    break;
                }
            }
コード例 #2
0
bool ezIReflectedTypeAccessor::GetValues(const char* szProperty, ezHybridArray<ezVariant, 16>& out_values) const
{
  ezHybridArray<ezVariant, 16> keys;
  if (!GetKeys(szProperty, keys))
    return false;

  out_values.Clear();
  out_values.Reserve(keys.GetCount());
  for (ezVariant key : keys)
  {
    out_values.PushBack(GetValue(szProperty, key));
  }
  return true;
}
コード例 #3
0
void ezSceneExportModifier::CreateModifiers(ezHybridArray<ezSceneExportModifier*, 8>& modifiers)
{
  for (const ezRTTI* pRtti = ezRTTI::GetFirstInstance(); pRtti != nullptr; pRtti = pRtti->GetNextInstance())
  {
    if (!pRtti->IsDerivedFrom<ezSceneExportModifier>())
      continue;

    if (pRtti->GetTypeFlags().IsAnySet(ezTypeFlags::Abstract))
      continue;

    if (pRtti->GetAllocator() == nullptr || !pRtti->GetAllocator()->CanAllocate())
      continue;

    ezSceneExportModifier* pMod = pRtti->GetAllocator()->Allocate<ezSceneExportModifier>();

    modifiers.PushBack(pMod);
  }
}
コード例 #4
0
void ezImguiRenderer::GetSupportedRenderDataTypes(ezHybridArray<const ezRTTI*, 8>& types)
{
  types.PushBack(ezGetStaticRTTI<ezImguiRenderData>());
}
コード例 #5
0
ファイル: ImageConversion.cpp プロジェクト: ezEngine/ezEngine
ezResult ezImageConversion::BuildPath(ezImageFormat::Enum sourceFormat, ezImageFormat::Enum targetFormat, bool bSourceEqualsTarget,
                                      ezHybridArray<ezImageConversion::ConversionPathNode, 16>& path_out, ezUInt32& numScratchBuffers_out)
{
  path_out.Clear();
  numScratchBuffers_out = 0;

  if (sourceFormat == targetFormat)
  {
    ConversionPathNode node;
    node.m_sourceFormat = sourceFormat;
    node.m_targetFormat = targetFormat;
    node.m_inPlace = bSourceEqualsTarget;
    node.m_sourceBufferIndex = 0;
    node.m_targetBufferIndex = 0;
    node.m_step = nullptr;
    path_out.PushBack(node);
    return EZ_SUCCESS;
  }

  if (!s_conversionTableValid)
  {
    RebuildConversionTable();
  }

  for (ezImageFormat::Enum current = sourceFormat; current != targetFormat;)
  {
    ezUInt32 currentTableIndex = MakeKey(current, targetFormat);

    TableEntry entry;

    if (!s_conversionTable.TryGetValue(currentTableIndex, entry))
    {
      return EZ_FAILURE;
    }

    ezImageConversion::ConversionPathNode step;
    step.m_sourceFormat = entry.m_sourceFormat;
    step.m_targetFormat = entry.m_targetFormat;
    step.m_inPlace = entry.m_flags.IsAnySet(ezImageConversionFlags::InPlace);
    step.m_step = entry.m_step;

    current = entry.m_targetFormat;

    path_out.PushBack(step);
  }

  ezHybridArray<IntermediateBuffer, 16> scratchBuffers;
  scratchBuffers.PushBack(IntermediateBuffer(ezImageFormat::GetBitsPerBlock(targetFormat)));

  for (int i = path_out.GetCount() - 1; i >= 0; --i)
  {
    if (i == path_out.GetCount() - 1)
      path_out[i].m_targetBufferIndex = 0;
    else
      path_out[i].m_targetBufferIndex = path_out[i + 1].m_sourceBufferIndex;

    if (i > 0)
    {
      if (path_out[i].m_inPlace)
      {
        path_out[i].m_sourceBufferIndex = path_out[i].m_targetBufferIndex;
      }
      else
      {
        ezUInt32 bitsPerBlock = ezImageFormat::GetBitsPerBlock(path_out[i].m_sourceFormat);

        path_out[i].m_sourceBufferIndex = allocateScratchBufferIndex(scratchBuffers, bitsPerBlock, path_out[i].m_targetBufferIndex);
      }
    }
  }

  if (bSourceEqualsTarget)
  {
    // Enforce constraint that source == target
    path_out[0].m_sourceBufferIndex = 0;

    // Did we accidentally break the in-place invariant?
    if (path_out[0].m_sourceBufferIndex == path_out[0].m_targetBufferIndex && !path_out[0].m_inPlace)
    {
      if (path_out.GetCount() == 1)
      {
        // Only a single step, so we need to add a copy step
        ezImageConversion::ConversionPathNode copy;
        copy.m_inPlace = false;
        copy.m_sourceFormat = sourceFormat;
        copy.m_targetFormat = sourceFormat;
        copy.m_sourceBufferIndex = path_out[0].m_sourceBufferIndex;
        copy.m_targetBufferIndex = allocateScratchBufferIndex(scratchBuffers, ezImageFormat::GetBitsPerBlock(path_out[0].m_sourceFormat),
                                                              path_out[0].m_sourceBufferIndex);
        path_out[0].m_sourceBufferIndex = copy.m_targetBufferIndex;
        copy.m_step = nullptr;
        path_out.Insert(copy, 0);
      }
      else
      {
        // Turn second step to non-inplace
        path_out[1].m_inPlace = false;
        path_out[1].m_sourceBufferIndex = allocateScratchBufferIndex(
            scratchBuffers, ezImageFormat::GetBitsPerBlock(path_out[1].m_sourceFormat), path_out[0].m_sourceBufferIndex);
        path_out[0].m_targetBufferIndex = path_out[1].m_sourceBufferIndex;
      }
    }
  }
  else
  {
    path_out[0].m_sourceBufferIndex = scratchBuffers.GetCount();
  }

  numScratchBuffers_out = scratchBuffers.GetCount() - 1;

  return EZ_SUCCESS;
}