Example #1
0
GlfTextureHandleRefPtr
GlfTextureRegistry::GetTextureHandle(const TfTokenVector &textures)
{
    if (textures.empty()) {
        TF_WARN("Attempting to register arrayTexture with empty token vector.");
        return GlfTextureHandlePtr();
    }

    const size_t numTextures = textures.size();
    // We register an array texture with the
    // path of the first texture in the array
    TfToken texture = textures[0];
    GlfTextureHandleRefPtr textureHandle;

    _TextureMetadata md(textures);

    // look into exisiting textures
    std::map<TfToken, _TextureMetadata>::iterator it =
        _textureRegistry.find(texture);
    
    if (it != _textureRegistry.end() && it->second.IsMetadataEqual(md)) {
        textureHandle = it->second.GetHandle();
    } else {
        // if not exists, create it
        textureHandle = _CreateTexture(textures, numTextures);
        md.SetHandle(textureHandle);
        _textureRegistry[texture] = md;
    }

    return textureHandle;
}
GlfTextureHandleRefPtr
GlfTextureRegistry::GetTextureHandle(const TfToken &texture,
                                   GlfImage::ImageOriginLocation originLocation)
{
    GlfTextureHandleRefPtr textureHandle;

    _TextureMetadata md(texture);

    // look into exisiting textures
    std::map<std::pair<TfToken, GlfImage::ImageOriginLocation>,
             _TextureMetadata>::iterator it =
        _textureRegistry.find(std::make_pair(texture, originLocation));

    if (it != _textureRegistry.end() && it->second.IsMetadataEqual(md)) {
        textureHandle = it->second.GetHandle();
    } else {
        // if not exists, create it
        textureHandle = _CreateTexture(texture, originLocation);
        if (textureHandle) {
            md.SetHandle(textureHandle);
            _textureRegistry[std::make_pair(texture, originLocation)] = md;
        }
    }

    return textureHandle;
}
GlfTextureHandleRefPtr
GlfTextureRegistry::GetTextureHandle(
    const TfToken& texture,
    GlfImage::ImageOriginLocation originLocation,
    const GlfTextureFactoryBase* textureFactory)
{
    if (!TF_VERIFY(textureFactory != nullptr)) {
        return nullptr;
    }

    _TextureMetadata md(texture);

    std::map<std::pair<TfToken, GlfImage::ImageOriginLocation>,
        _TextureMetadata>::iterator it =
        _textureRegistry.find(std::make_pair(texture, originLocation));

    if (it != _textureRegistry.end() && it->second.IsMetadataEqual(md)) {
        return it->second.GetHandle();
    } else {
        GlfTextureHandleRefPtr textureHandle;
        textureHandle = _CreateTexture(texture,
                                       originLocation,
                                       textureFactory);
        if (textureHandle) {
            md.SetHandle(textureHandle);
            _textureRegistry[std::make_pair(texture, originLocation)] = md;
        }
        return textureHandle;
    }
}
Example #4
0
r3dTexture *r3dRenderLayer::AllocateTexture()
{
	r3dCSHolderWithDeviceQueue csholder( g_ResourceCritSection ) ; (void)csholder ;

	r3dTexture	*Tex = _CreateTexture();

	_InsertTexture(&FirstTexture, Tex);

	return Tex;
}
Example #5
0
void
GlfUVTexture::_ReadTexture()
{
    GlfUVTextureDataRefPtr texData =
        GlfUVTextureData::New(_GetImageFilePath(), GetMemoryRequested(),
                              _GetCropTop(), _GetCropBottom(),
                              _GetCropLeft(), _GetCropRight());
    if (texData) {
        texData->Read(0, _GenerateMipmap(), GetOriginLocation());
    }
    _UpdateTexture(texData);
    _CreateTexture(texData, _GenerateMipmap());
    _SetLoaded();
}
Example #6
0
r3dTexture* r3dRenderLayer::LoadTexture( const char* TexFile, D3DFORMAT TexFormat, bool bCheckFormat, int DownScale /*= 1*/, int DownScaleMinDim /*= 1*/, int SystemMem /*= 0*/, int gameResourcePool /*= 0*/ )
{
	if(!bInited)
		return NULL;

	r3dCSHolderWithDeviceQueue csholder( g_ResourceCritSection ) ; (void)csholder ;

	assert(TexFile);

	char szFileName[ MAX_PATH ];
	FixFileName( TexFile, szFileName );

	r3dTexture*	Tex;

	// goes thru all textures and see if we already have with that name
	for(Tex = FirstTexture; Tex; Tex = Tex->pNext)
	{
		if((!bCheckFormat || (Tex->GetD3DFormat() == TexFormat) ) && (Tex->IsLoaded()) && (strcmp(Tex->getFileLoc().FileName, szFileName ) == NULL)) {
			Tex->Instances++;
			return Tex;
		}
	}

	Tex = _CreateTexture();

	if( gameResourcePool == PlayerTexMem )
	{
		Tex->MarkPlayerTexture() ;
	}

	if(!Tex->Load(szFileName, TexFormat, DownScale, DownScaleMinDim, SystemMem )) {
		_DeleteTexture(Tex);
		return NULL;
	}

	//r3dOutToLog("TEXTURE: LoadTexture %s complete\n", szFileName);

	// insert to LList.
	_InsertTexture(&FirstTexture, Tex);

	Tex->Instances++;
	return Tex;
}
Example #7
0
void touchmind::view::path::impl::DefaultPathView::CreateDeviceDependentResources(
    touchmind::Context *pContext,
    ID2D1RenderTarget *pRenderTarget )
{
    if (!_CheckValidity()) {
        return;
    }
    auto node = GetNodeModel().lock();
    auto path = node->GetPathModel();
    if (path->IsRepaintRequired(GetRepaintCounter()) ||
            m_pathBrush == nullptr ||
            m_pathGeometry == nullptr ||
            m_pathStyle == nullptr) {
        _CreateDeviceDependentResources(pContext, pRenderTarget, node);
        if (path->IsSelected()) {
            _CreateTexture(pContext, pRenderTarget, node);
        } else {
            m_pBitmap = nullptr;
        }
        SetRepaintCounter(path);
    }
}
Example #8
0
GlfTextureHandleRefPtr
GlfTextureRegistry::GetTextureHandle(const TfToken &texture)
{
    GlfTextureHandleRefPtr textureHandle;

    _TextureMetadata md(texture);

    // look into exisiting textures
    std::map<TfToken, _TextureMetadata>::iterator it =
        _textureRegistry.find(texture);

    if (it != _textureRegistry.end() && it->second.IsMetadataEqual(md)) {
        textureHandle = it->second.GetHandle();
    } else {
        // if not exists, create it
        textureHandle = _CreateTexture(texture);
        md.SetHandle(textureHandle);
        _textureRegistry[texture] = md;
    }

    return textureHandle;
}