Ejemplo n.º 1
0
GlfTextureRegistry::_TextureMetadata::_TextureMetadata(
    const TfToken *textures, const std::uint32_t numTextures)
    : _numTextures(numTextures)
    , _fileSize(0)
    , _mtime(0)
{
    TRACE_FUNCTION();

    for (std::uint32_t i = 0; i < numTextures; ++i) {
        const TfToken& tex = textures[i];
        double time;
        if (!ArchGetModificationTime(tex.GetText(), &time)) {
            continue;
        }
        int64_t size = ArchGetFileLength(tex.GetText());
        if (size == -1) {
            continue;
        }

        // The file size is not a particularly good indicator that the texture
        // has changed (i.e. uncompressed images with the same dimensions,
        // depth, etc are very likely to have the same size even if they are
        // different.)
        //
        // We aggregate the size of every file in the texture array, but use
        // the most recent mtime of any file so that we reload the array if any
        // file is modified.
        _fileSize += size;
        _mtime = std::max(_mtime, time);
    }
}
Ejemplo n.º 2
0
SdfAttributeSpecHandle
SdfAttributeSpec::New(
    const SdfPrimSpecHandle& owner,
    const std::string& name,
    const SdfValueTypeName& typeName,
    SdfVariability variability,
    bool custom)
{
    TRACE_FUNCTION();

    if (not owner) {
	TF_CODING_ERROR("Cannot create an SdfAttributeSpec with a null owner");
	return TfNullPtr;
    }

    if (not Sdf_ChildrenUtils<Sdf_AttributeChildPolicy>::IsValidName(name)) {
        TF_CODING_ERROR(
            "Cannot create attribute on %s with invalid name: %s",
            owner->GetPath().GetText(), name.c_str());
        return TfNullPtr;
    }

    SdfPath attributePath = owner->GetPath().AppendProperty(TfToken(name));
    if (not attributePath.IsPropertyPath()) {
        TF_CODING_ERROR(
            "Cannot create attribute at invalid path <%s.%s>",
            owner->GetPath().GetText(), name.c_str());
        return TfNullPtr;
    }

    return _New(owner, attributePath, typeName, variability, custom);
}
nsresult sbRequestThreadQueue::PushRequest(sbRequestItem * aRequestItem)
{
  TRACE_FUNCTION("RequestType=%ui", aRequestItem->mType);
  NS_ENSURE_ARG_POINTER(aRequestItem);

  NS_ENSURE_STATE(mLock);

  nsresult rv;

  { /* scope for request lock */
    nsAutoLock lock(mLock);

    nsAutoMonitor monitor(mStopWaitMonitor);
    // If we're aborting or shutting down don't accept any more requests
    if (mAbortRequests || mStopProcessing)
    {
      return NS_ERROR_ABORT;
    }

    rv = PushRequestInternal(aRequestItem);
    NS_ENSURE_SUCCESS(rv, rv);
  }

  NS_ASSERTION(mBatchDepth >= 0,
               "Batch depth out of whack in sbBaseDevice::PushRequest");
  // Only process requests if we're not in a batch
  if (mBatchDepth == 0) {
    rv = ProcessRequest();
    NS_ENSURE_SUCCESS(rv, rv);
  }
  return NS_OK;
}
Ejemplo n.º 4
0
UsdGeomPrimvar
UsdGeomPrimvarsAPI::FindPrimvarWithInheritance(const TfToken &name,
                                               const std::vector<UsdGeomPrimvar>
                                               &inheritedFromAncestors) const
{
    TRACE_FUNCTION();

    const UsdPrim &prim = GetPrim();
    if (!prim) {
        TF_CODING_ERROR("FindPrimvarWithInheritance called on invalid prim: %s", 
                        UsdDescribe(prim).c_str());
        return UsdGeomPrimvar();
    }
    const TfToken attrName = UsdGeomPrimvar::_MakeNamespaced(name);
    UsdGeomPrimvar  pv = GetPrimvar(attrName);
    if (pv.HasAuthoredValue()){
        return pv;
    }
    
    for (UsdGeomPrimvar const &inherited : inheritedFromAncestors) {
        if (inherited.GetName() == attrName){
            return inherited;
        }
    }

    return pv;
}
Ejemplo n.º 5
0
//解析图标
STDMETHODIMP CExtractIcon::Extract( LPCTSTR pstrName, UINT nIconIndex, HICON *phiconLarge, HICON *phiconSmall, UINT /*nIconSize*/ )
{
    TRACE_FUNCTION();
    LOG(_T("%s GetIcon %s %d"), __TFUNCTION__, pstrName, nIconIndex );
    ATLASSERT(phiconLarge);
    ATLASSERT(phiconSmall);
    
    //HMODULE hLib = LoadLibrary( pstrName );
    //if ( hLib )
    //{
    //    *phiconSmall = LoadIcon( (HINSTANCE)hLib, MAKEINTRESOURCE(nIconIndex) );
    //    *phiconLarge = LoadIcon( (HINSTANCE)hLib, MAKEINTRESOURCE(nIconIndex) );
    //    FreeLibrary( hLib );
    //    return S_OK;
    //}
    SHFILEINFO   sfi = { 0 };
    HIMAGELIST hImgList = (HIMAGELIST)SHGetFileInfo( m_szPath, 0,\
        &sfi, sizeof(SHFILEINFO), SHGFI_SYSICONINDEX|SHGFI_SMALLICON|SHGFI_ICON );
    if ( hImgList )
    {
        LOG( _T("%s Geting Smallone"), __TFUNCTION__ );
        *phiconSmall = ImageList_ExtractIcon(NULL, hImgList, nIconIndex);
    }
    hImgList = (HIMAGELIST)SHGetFileInfo( m_szPath, 0, &sfi, \
        sizeof(SHFILEINFO), SHGFI_SYSICONINDEX|SHGFI_LARGEICON|SHGFI_ICON );
    if ( hImgList )
    {
        LOG( _T("%s Geting Bigone"), __TFUNCTION__ );
        *phiconLarge = ImageList_ExtractIcon(NULL, hImgList, nIconIndex);
    }
    TRACE_RETURN S_OK;
}
Ejemplo n.º 6
0
UsdSkelAnimQuery
UsdSkel_CacheImpl::ReadScope::FindOrCreateAnimQuery(const UsdPrim& prim)
{
    TRACE_FUNCTION();

    if(ARCH_UNLIKELY(!prim || !prim.IsActive()))
        return UsdSkelAnimQuery();

    if(prim.IsInstanceProxy())
        return FindOrCreateAnimQuery(prim.GetPrimInMaster());

    {
        _PrimToAnimMap::const_accessor a;
        if(_cache->_animQueryCache.find(a, prim))
            return UsdSkelAnimQuery(a->second);
    }

    if (UsdSkelIsSkelAnimationPrim(prim)) {
        _PrimToAnimMap::accessor a;
        if(_cache->_animQueryCache.insert(a, prim)) {
            a->second = UsdSkel_AnimQueryImpl::New(prim);
        }
        return UsdSkelAnimQuery(a->second);
    }
    return UsdSkelAnimQuery();
}
Ejemplo n.º 7
0
void
HdxIntersector::SetResolution(GfVec2i const& widthHeight)
{
    TRACE_FUNCTION();

    // Make sure we're in a sane GL state before attempting anything.
    if (GlfHasLegacyGraphics()) {
        TF_RUNTIME_ERROR("framebuffer object not supported");
        return;
    }

    if (!_drawTarget) {
        // Initialize the shared draw target late to ensure there is a valid GL
        // context, which may not be the case at constructon time.
        _Init(widthHeight);
        return;
    }

    if (widthHeight == _drawTarget->GetSize()){
        return;
    }

    // Make sure master draw target is always modified on the shared context,
    // so we access it consistently.
    GlfSharedGLContextScopeHolder sharedContextHolder;
    {
        _drawTarget->Bind();
        _drawTarget->SetSize(widthHeight);
        _drawTarget->Unbind();
    }
}
Ejemplo n.º 8
0
bool
UsdGeomPrimvarsAPI::HasPossiblyInheritedPrimvar(const TfToken &name) const
{
    TRACE_FUNCTION();

    UsdPrim prim = GetPrim();
    if (!prim) {
        TF_CODING_ERROR("HasPossiblyInheritedPrimvar called on invalid prim: %s", 
                        UsdDescribe(prim).c_str());
        return false;
    }
    UsdGeomPrimvar  pv = GetPrimvar(name);
    if (pv.HasAuthoredValue()){
        return true;
    }

    const TfToken attrName = UsdGeomPrimvar::_MakeNamespaced(name);
    if (attrName.IsEmpty()) {
        return false;
    }
    for (prim = prim.GetParent(); prim && !prim.IsPseudoRoot();
         prim = prim.GetParent()) {
        UsdAttribute attr = prim.GetAttribute(attrName);
        if (attr.HasAuthoredValue() && UsdGeomPrimvar::IsPrimvar(attr)) {
            // Only constant primvars can be inherited.
            // Non-constant interpolation blocks inheritance.
            return UsdGeomPrimvar(attr).GetInterpolation()
                == UsdGeomTokens->constant;
        }
    }
    return false;
}
Ejemplo n.º 9
0
UsdSkel_SkelDefinitionRefPtr
UsdSkel_CacheImpl::ReadScope::FindOrCreateSkelDefinition(const UsdPrim& prim)
{
    TRACE_FUNCTION();

    if(ARCH_UNLIKELY(!prim || !prim.IsActive()))
        return nullptr;

    if(prim.IsInstanceProxy())
        return FindOrCreateSkelDefinition(prim.GetPrimInMaster());

    {
        _PrimToSkelDefinitionMap::const_accessor a;
        if(_cache->_skelDefinitionCache.find(a, prim))
            return a->second;
    }

    if(prim.IsA<UsdSkelSkeleton>()) {
        _PrimToSkelDefinitionMap::accessor a;
        if(_cache->_skelDefinitionCache.insert(a, prim)) {
            a->second = UsdSkel_SkelDefinition::New(UsdSkelSkeleton(prim));
        }
        return a->second;
    }
    return nullptr;
}
Ejemplo n.º 10
0
UsdSkelSkeletonQuery
UsdSkel_CacheImpl::ReadScope::FindOrCreateSkelQuery(const UsdPrim& prim)
{
    TRACE_FUNCTION();

    {
        _PrimToSkelQueryMap::const_accessor a;
        if (_cache->_skelQueryCache.find(a, prim))
            return a->second;
    }

    if (auto skelDef = FindOrCreateSkelDefinition(prim)) {
        _PrimToSkelQueryMap::accessor a;
        if (_cache->_skelQueryCache.insert(a, prim)) {

            UsdSkelAnimQuery animQuery =
                FindOrCreateAnimQuery(
                    UsdSkelBindingAPI(prim).GetInheritedAnimationSource());

            a->second = UsdSkelSkeletonQuery(skelDef, animQuery);
        }
        return a->second;
    }
    return UsdSkelSkeletonQuery();
}
nsresult sbRequestThreadQueue::CancelRequests()
{
  TRACE_FUNCTION("");

  NS_ENSURE_STATE(mStopWaitMonitor);

  nsresult rv;

  Batch batch;
  {
    // Have to lock mLock before mStopWaitMonitor to avoid deadlocks
    nsAutoLock lock(mLock);
    nsAutoMonitor monitor(mStopWaitMonitor);
    // If we're aborting set the flag, reset batch depth and clear requests
    if (!mAbortRequests) {
      if (mIsHandlingRequests) {
        mAbortRequests = true;
        monitor.NotifyAll();
      }
      mBatchDepth = 0;
      rv = ClearRequestsNoLock(batch);
      NS_ENSURE_SUCCESS(rv, rv);
    }
  }
  // must not hold onto the monitor while we create sbDeviceStatus objects
  // because that involves proxying to the main thread
  rv = CleanupBatch(batch);
  NS_ENSURE_SUCCESS(rv, rv);

  return NS_OK;
}
Ejemplo n.º 12
0
	void bigfixedTest::testInitialise()
	{
		TRACE_FUNCTION();

		fixed_128_64 v;
		verify ("init default", v.toDecString() == "0.0");

		v = fixed_128_64(100);
		verify ("init 100", v.toDecString() == "100.0");
		
		v = fixed_128_64(-100);
		verify ("init -100", v.toDecString() == "-100.0");

		v = fixed_128_64(1.0);
		verify ("init 1.0", v.toDecString() == "1.0");

		v = fixed_128_64 (1000.0);
		verify ("init 1000.0", v.toDecString() == "1000.0");

		v = fixed_128_64 (1000.125);
		verify ("init 1000.125", v.toDecString() == "1000.125");

		v = fixed_128_64 (0.0001220703125);
		verify ("init 0.0001220703125", v.toDecString() == "0.0001220703125");

		v = fixed_128_64 (-0.00000762939453125);
		verify ("init -0.00000762939453125", v.toDecString() == "-0.00000762939453125");

		fixed_128_128 v2 = fixed_128_128 (std::numeric_limits<double>::denorm_min());
		verify ("init subnormal", v2.toDecString() == "0.0");

		v = fixed_128_64 (-2000.123456);
		double d = v.toDouble();
	}
Ejemplo n.º 13
0
UsdGeomPrimvar 
UsdGeomPrimvarsAPI::FindPrimvarWithInheritance(const TfToken &name) const
{
    TRACE_FUNCTION();

    const TfToken attrName = UsdGeomPrimvar::_MakeNamespaced(name);
    UsdPrim prim = GetPrim();
    if (!prim) {
        TF_CODING_ERROR("FindPrimvarWithInheritance called on invalid prim: %s", 
                        UsdDescribe(prim).c_str());
        return UsdGeomPrimvar();
    }
    UsdGeomPrimvar  localPv = GetPrimvar(name);
    if (localPv.HasAuthoredValue()){
        return localPv;
    }
    
    for (prim = prim.GetParent(); prim && !prim.IsPseudoRoot();
         prim = prim.GetParent()) {
        UsdAttribute attr = prim.GetAttribute(attrName);
        if (attr.HasAuthoredValue()) {
            if (UsdGeomPrimvar pv = UsdGeomPrimvar(attr)) {
                // Only constant primvars can be inherited.
                if (pv.GetInterpolation() == UsdGeomTokens->constant) {
                    return pv;
                } else {
                    // Non-constant interpolation blocks inheritance.
                    return UsdGeomPrimvar();
                }
            }
        }
    }
    return localPv;
}
nsresult sbRequestThreadQueue::ClearRequests()
{
  TRACE_FUNCTION("");

  nsresult rv;

  NS_ENSURE_STATE(mLock);

  Batch batch;
  // Lock the queue while copy and clear it
  {
    nsAutoLock lock(mLock);

    rv = ClearRequestsNoLock(batch);
    NS_ENSURE_SUCCESS(rv, rv);
  }

  // Now that we have released the lock, cleanup the unprocessed items in the
  // the batch. Cleanup can result in proxying to the main thread which can
  // deadlock if we're holding the lock.
  rv = CleanupBatch(batch);
  NS_ENSURE_SUCCESS(rv, rv);

  return NS_OK;
}
Ejemplo n.º 15
0
bool
HdxIntersector::Result::ResolveNearest(HdxIntersector::Hit* hit) const
{
    TRACE_FUNCTION();

    if (!IsValid()) {
        return false;
    }

    int xMin = 0;
    int yMin = 0;
    double zMin = 1.0;
    int zMinIndex = -1;
    float const* depths = _depths.get();

    // Find the smallest value (nearest pixel) in the z buffer
    for (int y=0, i=0; y < _viewport[2]; y++) {
        for (int x=0; x < _viewport[3]; x++, i++) {
            if (depths[i] < zMin) {
                xMin = x;
                yMin = y;
                zMin = depths[i];
                zMinIndex = i;
            }
        }
    }

    if (zMin >= 1.0) {
        return false;
    }

    return _ResolveHit(zMinIndex, xMin, yMin, zMin, hit);
}
Ejemplo n.º 16
0
bool
Usd_ClipCache::PopulateClipsForPrim(
    const SdfPath& path, const PcpPrimIndex& primIndex)
{
    TRACE_FUNCTION();

    std::vector<Clips> allClips;
    Clips clipsFromNode;
    _AddClipsFromNode(primIndex, &clipsFromNode);
    if (!clipsFromNode.valueClips.empty()) {
        allClips.push_back(clipsFromNode);
    }

    const bool primHasClips = !allClips.empty();
    if (primHasClips) {
        tbb::mutex::scoped_lock lock(_mutex);

        const std::vector<Clips>& ancestralClips = 
            _GetClipsForPrim_NoLock(path.GetParentPath());
        allClips.insert(
            allClips.end(), ancestralClips.begin(), ancestralClips.end());

        TF_DEBUG(USD_CLIPS).Msg(
            "Populated clips for prim <%s>\n", 
            path.GetString().c_str());

        _table[path].swap(allClips);
    }

    return primHasClips;
}
Ejemplo n.º 17
0
const std::vector<Usd_ClipCache::Clips>&
Usd_ClipCache::GetClipsForPrim(const SdfPath& path) const
{
    TRACE_FUNCTION();
    tbb::mutex::scoped_lock lock(_mutex);
    return _GetClipsForPrim_NoLock(path);
}
Ejemplo n.º 18
0
/////////////////////////////////////////////////////////////////////////////
// IShellView
HRESULT CSEShellView::AddPropertySheetPages(
    DWORD /*dwReserved*/,
    LPFNADDPROPSHEETPAGE /*lpfn*/, 
    LPARAM /*lParam*/)
{
    TRACE_FUNCTION();
    TRACE_RETURN E_NOTIMPL;
}
Ejemplo n.º 19
0
STDMETHODIMP CSEShellView::DestroyViewWindow(void)
{
    TRACE_FUNCTION();
    UIActivate(SVUIA_DEACTIVATE);
    ::DestroyWindow(m_hWnd);
    m_pShellBrowser->Release();
    TRACE_RETURN S_OK;
}
void Recursion(int N)
{
    TRACE_FUNCTION();
    if (N <= 1) {
        return;
    }
    Recursion(N-1);
}
Ejemplo n.º 21
0
bool
HdSt_MeshTopology::operator==(HdSt_MeshTopology const &other) const {

    TRACE_FUNCTION();

    // no need to compare _adajency and _quadInfo
    return HdMeshTopology::operator==(other);
}
Ejemplo n.º 22
0
HRESULT CExtractIcon::_Init(LPCITEMIDLIST pidl)
{
    TRACE_FUNCTION();
    m_pidl=m_pidlManager.Copy(pidl);
    DWORD dwLen = MAX_PATH;
    m_pidlManager.GetFullName( m_pidl, m_szPath, &dwLen );
    m_pidlManager.ReplaceRoot( m_szPath );
    LOG( _T("%s %s"), __TFUNCTION__, m_szPath );
    TRACE_RETURN S_OK;
}
Ejemplo n.º 23
0
HRESULT CSEShellView::GetWindow(HWND* phWnd)
{
    TRACE_FUNCTION();
    if(::IsWindow(m_hWnd)==0)
    {
        TRACE_RETURN E_FAIL;
    }
    *phWnd = m_hWnd;
    TRACE_RETURN S_OK;
}
Ejemplo n.º 24
0
PcpPrimIndex_GraphRefPtr 
PcpPrimIndex_Graph::New(const PcpPrimIndex_GraphPtr& copy)
{
    TfAutoMallocTag2 tag("Pcp", "PcpPrimIndex_Graph");

    TRACE_FUNCTION();

    return TfCreateRefPtr(
        new PcpPrimIndex_Graph(*boost::get_pointer(copy)));
}
Ejemplo n.º 25
0
void
GlfTextureRegistry::GarbageCollectIfNeeded()
{
    // Even if we hold the list of texture handles to be deleted, we have to
    // traverse entire map to remove the entry for them. So simple flag works
    // enough to avoid unnecessary process.
    if (!_requiresGarbageCollection) return;

    // XXX:
    // Frequent garbage collection causing slow UI when reading textures.
    // We're freeing and re-loading textures instead of caching them.
    // 
    // Can we only garbage collect when GPU memory is high?  Or have a
    // least-recently-used queue or something?
    TRACE_FUNCTION();

    std::map<std::pair<TfToken, GlfImage::ImageOriginLocation>,
             _TextureMetadata>::iterator it =
        _textureRegistry.begin();
    while (it != _textureRegistry.end()){
        const GlfTextureHandleRefPtr &handle = it->second.GetHandle();

        // Null handles should not have been added to the registry
        if (TF_VERIFY(handle) && handle->IsUnique()) {
            it = _textureRegistry.erase(it);
            // TextureHandle (and its GlfTexture) will be released here.
        } else {
            ++it;
        }
    }

    // we only have a weakptr for non-shared texture handle (i.e. DrawTarget)
    // note: Since the lifetime of drawtarget attachment is controlled by
    // GlfDrawTarget, even though there are no samplers refers to that
    // attachment, it may still exists when this GC function is called.
    // As a result the entry of textureHandle might remain in 
    // _textureRegistryNonShared, but it just holds an invalid WeakPtr and 
    // will be cleaned at the next GC opportunity. so it's no harm.
    {
        std::map<GlfTexturePtr, GlfTextureHandlePtr>::iterator it =
            _textureRegistryNonShared.begin();
        while (it != _textureRegistryNonShared.end() ){
            if (it->second.IsExpired()) {
                // TextureHandle has already been released by its owner
                // (GlfDrawTarget)
                _textureRegistryNonShared.erase(it++);
            } else {
                ++it;
            }
        }
    }

    _requiresGarbageCollection = false;
}
Ejemplo n.º 26
0
void close_fifo( void )
/***********************************************************************/
{
   TRACE_FUNCTION("single.c:  close_fifo");
   TerminateThread( hThread, 0 );
   DisconnectNamedPipe( (HANDLE)fifo_fd );
   CloseHandle( (HANDLE)fifo_fd );
   CloseHandle( (HANDLE)hPipeRead );
   CloseHandle( (HANDLE)hSemCommandCount );
   TRACE_RETURN();
}
Ejemplo n.º 27
0
HRESULT CSEShellView::FinalConstruct()
{
    TRACE_FUNCTION();

    m_pShellBrowser=NULL;
    m_hWnd=NULL;   
    m_hMenu = NULL;
    m_pFolder = NULL;
    m_pidlRoot = NULL;
    TRACE_RETURN S_OK;
}
nsresult sbRequestThreadQueue::BatchBegin()
{
  TRACE_FUNCTION("");

  NS_ENSURE_STATE(mLock);
  nsAutoLock lock(mLock);

  ++mBatchDepth;

  return NS_OK;
}
Ejemplo n.º 29
0
int STRICT( INSTRUCTION_FN_ARGS )
{
    unsigned char strict = istate.ep[0].num.c;

    TRACE_FUNCTION();

    istate.ep[0].num.c = strict_unsigned_conversions;
    strict_unsigned_conversions = strict;

    return 1;
}
Ejemplo n.º 30
0
void 
PcpPrimIndex_Graph::_DetachSharedNodePool()
{
    if (!_data.unique()) {
        TRACE_FUNCTION();
        _data.reset(new _SharedData(*_data));

        // XXX: This probably causes more finalization than necessary. Only
        //      need to finalize if (a) nodes are added (b) nodes are culled.
        _data->finalized = false;
    }
}