Loading...
Searching...
No Matches
UsdColorSpaceAPI::ColorSpaceHashCache Class Reference

This is a simple example of a color space cache implementation. More...

#include <colorSpaceAPI.h>

+ Inheritance diagram for UsdColorSpaceAPI::ColorSpaceHashCache:

Public Member Functions

TfToken Find (const SdfPath &prim) override
 
void Insert (const SdfPath &prim, const TfToken &colorSpace) override
 
- Public Member Functions inherited from UsdColorSpaceAPI::ColorSpaceCache

Protected Attributes

TfHashMap< SdfPath, TfToken, SdfPath::Hash > _cache
 
TfBigRWMutex _mutex
 

Detailed Description

This is a simple example of a color space cache implementation.

An application can use this cache to avoid redundant color space lookups, but may substitute its own cache implementation if desired. This implementation does not track changes to the color space properties, so it is the application's responsibility to clear or update the cache when necessary.

A more sophisticated cache implementation might also be intelligent about caching locally defined color spaces and their computed GfColorSpaces. It might also be aware of changes to the scene hierarchy and update the cache accordingly.

As it is, this simple cache will be efficient in a typical scene using built in color spaces. It uses TfBigRWMutex to enable many-reader single-writer thread safety; however this example does not provide a guarantee of thread-efficiency for any given cache access pattern.

Definition at line 269 of file colorSpaceAPI.h.

Member Function Documentation

◆ Find()

TfToken Find ( const SdfPath & prim)
inlineoverridevirtual

Implements UsdColorSpaceAPI::ColorSpaceCache.

Definition at line 277 of file colorSpaceAPI.h.

◆ Insert()

void Insert ( const SdfPath & prim,
const TfToken & colorSpace )
inlineoverridevirtual

Implements UsdColorSpaceAPI::ColorSpaceCache.

Definition at line 286 of file colorSpaceAPI.h.

Member Data Documentation

◆ _cache

TfHashMap<SdfPath, TfToken, SdfPath::Hash> _cache
protected

Definition at line 271 of file colorSpaceAPI.h.

◆ _mutex

TfBigRWMutex _mutex
mutableprotected

Definition at line 272 of file colorSpaceAPI.h.


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