Skia
2DGraphicsLibrary
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
GrTextureProvider Class Reference

Public Types

enum  ScratchTexMatch { kExact_ScratchTexMatch, kApprox_ScratchTexMatch }
 Legacy function that no longer should be used. More...
 

Public Member Functions

GrTexturecreateMipMappedTexture (const GrSurfaceDesc &desc, SkBudgeted budgeted, const GrMipLevel *texels, int mipLevelCount)
 Creates a new texture in the resource cache and returns it. More...
 
GrTexturecreateTexture (const GrSurfaceDesc &desc, SkBudgeted budgeted, const void *srcData, size_t rowBytes)
 This function is a shim which creates a SkTArray<GrMipLevel> of size 1. More...
 
GrTexturecreateTexture (const GrSurfaceDesc &desc, SkBudgeted budgeted)
 Shortcut for creating a texture with no initial data to upload. More...
 
void assignUniqueKeyToTexture (const GrUniqueKey &key, GrTexture *texture)
 Assigns a unique key to the texture. More...
 
GrTexturefindAndRefTextureByUniqueKey (const GrUniqueKey &key)
 Finds a texture by unique key. More...
 
bool existsTextureWithUniqueKey (const GrUniqueKey &key) const
 Determines whether a texture is associated with the unique key. More...
 
GrTexturecreateApproxTexture (const GrSurfaceDesc &)
 Finds a texture that approximately matches the descriptor. More...
 
GrTexturerefScratchTexture (const GrSurfaceDesc &desc, ScratchTexMatch match)
 
GrTexturewrapBackendTexture (const GrBackendTextureDesc &desc, GrWrapOwnership=kBorrow_GrWrapOwnership)
 Wraps an existing texture with a GrTexture object. More...
 
GrRenderTargetwrapBackendRenderTarget (const GrBackendRenderTargetDesc &desc)
 Wraps an existing render target with a GrRenderTarget object. More...
 

Protected Types

enum  ScratchTextureFlags { kExact_ScratchTextureFlag = 0x1, kNoPendingIO_ScratchTextureFlag = 0x2, kNoCreate_ScratchTextureFlag = 0x4 }
 

Protected Member Functions

 GrTextureProvider (GrGpu *gpu, GrResourceCache *cache, GrSingleOwner *singleOwner)
 
void assignUniqueKeyToResource (const GrUniqueKey &, GrGpuResource *)
 Assigns a unique key to a resource. More...
 
GrGpuResourcefindAndRefResourceByUniqueKey (const GrUniqueKey &)
 Finds a resource in the cache, based on the specified key. More...
 
bool existsResourceWithUniqueKey (const GrUniqueKey &key) const
 Determines whether a resource is in the cache. More...
 
GrTextureinternalCreateApproxTexture (const GrSurfaceDesc &desc, uint32_t scratchTextureFlags)
 A common impl for GrTextureProvider and GrResourceProvider variants. More...
 
GrTexturerefScratchTexture (const GrSurfaceDesc &, uint32_t scratchTextureFlags)
 
void abandon ()
 
GrResourceCache * cache ()
 
const GrResourceCache * cache () const
 
GrGpu * gpu ()
 
const GrGpu * gpu () const
 
bool isAbandoned () const
 

Private Attributes

GrResourceCache * fCache
 
GrGpu * fGpu
 

Member Enumeration Documentation

Legacy function that no longer should be used.

Member Function Documentation

void GrTextureProvider::assignUniqueKeyToResource ( const GrUniqueKey ,
GrGpuResource  
)
protected

Assigns a unique key to a resource.

If the key is associated with another resource that association is removed and replaced by this resource.

void GrTextureProvider::assignUniqueKeyToTexture ( const GrUniqueKey key,
GrTexture texture 
)
inline

Assigns a unique key to the texture.

The texture will be findable via this key using findTextureByUniqueKey(). If an existing texture has this key, it's key will be removed.

GrTexture* GrTextureProvider::createApproxTexture ( const GrSurfaceDesc )

Finds a texture that approximately matches the descriptor.

Will be at least as large in width and height as desc specifies. If desc specifies that the texture should be a render target then result will be a render target. Format and sample count will always match the request. The contents of the texture are undefined. The caller owns a ref on the returned texture and must balance with a call to unref.

GrTexture* GrTextureProvider::createMipMappedTexture ( const GrSurfaceDesc desc,
SkBudgeted  budgeted,
const GrMipLevel texels,
int  mipLevelCount 
)

Creates a new texture in the resource cache and returns it.

The caller owns a ref on the returned texture which must be balanced by a call to unref.

Parameters
descDescription of the texture properties.
budgetedDoes the texture count against the resource cache budget?
texelsA contiguous array of mipmap levels
mipLevelCountThe amount of elements in the texels array
GrTexture* GrTextureProvider::createTexture ( const GrSurfaceDesc desc,
SkBudgeted  budgeted,
const void *  srcData,
size_t  rowBytes 
)

This function is a shim which creates a SkTArray<GrMipLevel> of size 1.

It then calls createTexture with that SkTArray.

Parameters
srcDataPointer to the pixel values (optional).
rowBytesThe number of bytes between rows of the texture. Zero implies tightly packed rows. For compressed pixel configs, this field is ignored.
GrTexture* GrTextureProvider::createTexture ( const GrSurfaceDesc desc,
SkBudgeted  budgeted 
)
inline

Shortcut for creating a texture with no initial data to upload.

bool GrTextureProvider::existsResourceWithUniqueKey ( const GrUniqueKey key) const
protected

Determines whether a resource is in the cache.

If the resource is found it will not be locked or returned. This call does not affect the priority of the resource for deletion.

bool GrTextureProvider::existsTextureWithUniqueKey ( const GrUniqueKey key) const
inline

Determines whether a texture is associated with the unique key.

If the texture is found it will not be locked or returned. This call does not affect the priority of the resource for deletion.

GrGpuResource* GrTextureProvider::findAndRefResourceByUniqueKey ( const GrUniqueKey )
protected

Finds a resource in the cache, based on the specified key.

This is intended for use in conjunction with addResourceToCache(). The return value will be NULL if not found. The caller must balance with a call to unref().

GrTexture* GrTextureProvider::findAndRefTextureByUniqueKey ( const GrUniqueKey key)

Finds a texture by unique key.

If the texture is found it is ref'ed and returned.

GrTexture* GrTextureProvider::internalCreateApproxTexture ( const GrSurfaceDesc desc,
uint32_t  scratchTextureFlags 
)
protected

A common impl for GrTextureProvider and GrResourceProvider variants.

GrRenderTarget* GrTextureProvider::wrapBackendRenderTarget ( const GrBackendRenderTargetDesc desc)

Wraps an existing render target with a GrRenderTarget object.

It is similar to wrapBackendTexture but can be used to draw into surfaces that are not also textures (e.g. FBO 0 in OpenGL, or an MSAA buffer that the client will resolve to a texture). Currently wrapped render targets always use the kBorrow_GrWrapOwnership semantics.

Returns
GrRenderTarget object or NULL on failure.
GrTexture* GrTextureProvider::wrapBackendTexture ( const GrBackendTextureDesc desc,
GrWrapOwnership  = kBorrow_GrWrapOwnership 
)

Wraps an existing texture with a GrTexture object.

OpenGL: if the object is a texture Gr may change its GL texture params when it is drawn.

Returns
GrTexture object or NULL on failure.

The documentation for this class was generated from the following file: