Ptex
Public Member Functions | Private Member Functions | Private Attributes | Friends | List of all members
PtexCachedReader Class Reference

#include <PtexCache.h>

Inheritance diagram for PtexCachedReader:
PtexReader PtexTexture

Public Member Functions

 PtexCachedReader (bool premultiply, PtexInputHandler *inputHandler, PtexErrorHandler *errorHandler, PtexReaderCache *cache)
 
 ~PtexCachedReader ()
 
void ref ()
 
int32_t unref ()
 
virtual void release ()
 Release resources held by this pointer (pointer becomes invalid). More...
 
bool tryPrune (size_t &memUsedChange)
 
bool tryPurge (size_t &memUsedChange)
 
size_t getMemUsedChange ()
 
size_t getOpensChange ()
 
size_t getBlockReadsChange ()
 
- Public Member Functions inherited from PtexReader
 PtexReader (bool premultiply, PtexInputHandler *inputHandler, PtexErrorHandler *errorHandler)
 
virtual ~PtexReader ()
 
bool needToOpen () const
 
bool open (const char *path, Ptex::String &error)
 
void prune ()
 
void purge ()
 
void setPendingPurge ()
 
bool pendingPurge () const
 
bool tryClose ()
 
bool ok () const
 
bool isOpen ()
 
void invalidate ()
 
void increaseMemUsed (size_t amount)
 
void logOpen ()
 
void logBlockRead ()
 
virtual const char * path ()
 Path that file was opened with. More...
 
virtual Info getInfo ()
 
virtual Ptex::MeshType meshType ()
 Type of mesh for which texture data is defined. More...
 
virtual Ptex::DataType dataType ()
 Type of data stored in file. More...
 
virtual Ptex::BorderMode uBorderMode ()
 Mode for filtering texture access beyond mesh border. More...
 
virtual Ptex::BorderMode vBorderMode ()
 Mode for filtering texture access beyond mesh border. More...
 
virtual Ptex::EdgeFilterMode edgeFilterMode ()
 Mode for filtering textures across edges. More...
 
virtual int alphaChannel ()
 Index of alpha channel (if any). More...
 
virtual int numChannels ()
 Number of channels stored in file. More...
 
virtual int numFaces ()
 Number of faces stored in file. More...
 
virtual bool hasEdits ()
 True if the file has edit blocks. More...
 
virtual bool hasMipMaps ()
 True if the file has mipmaps. More...
 
virtual PtexMetaDatagetMetaData ()
 Access meta data. More...
 
virtual const Ptex::FaceInfogetFaceInfo (int faceid)
 Access resolution and adjacency information about a face. More...
 
virtual void getData (int faceid, void *buffer, int stride)
 Access texture data for a face at highest-resolution. More...
 
virtual void getData (int faceid, void *buffer, int stride, Res res)
 
virtual PtexFaceDatagetData (int faceid)
 Access texture data for a face at highest-resolution as stored on disk. More...
 
virtual PtexFaceDatagetData (int faceid, Res res)
 
virtual void getPixel (int faceid, int u, int v, float *result, int firstchan, int nchannels)
 Access a single texel from the highest resolution texture . More...
 
virtual void getPixel (int faceid, int u, int v, float *result, int firstchan, int nchannels, Ptex::Res res)
 Access a single texel for a face at a particular resolution. More...
 
DataType datatype () const
 
int nchannels () const
 
int pixelsize () const
 
const Headerheader () const
 
const ExtHeaderextheader () const
 
const LevelInfolevelinfo (int level) const
 
- Public Member Functions inherited from PtexTexture
virtual void getData (int faceid, void *buffer, int stride, Ptex::Res res)=0
 Access texture data for a face at a specific resolution. More...
 
virtual PtexFaceDatagetData (int faceid, Ptex::Res res)=0
 Access texture data for a face at a specific resolution as stored on disk. More...
 

Private Member Functions

bool trylock ()
 
void unlock ()
 

Private Attributes

PtexReaderCache_cache
 
volatile int32_t _refCount
 
size_t _memUsedAccountedFor
 
size_t _opensAccountedFor
 
size_t _blockReadsAccountedFor
 
PtexLruItem _openFilesItem
 
PtexLruItem _activeFilesItem
 

Friends

class PtexReaderCache
 

Additional Inherited Members

- Static Public Member Functions inherited from PtexTexture
static PtexTextureopen (const char *path, Ptex::String &error, bool premultiply=0)
 Open a ptex file for reading. More...
 
- Protected Types inherited from PtexReader
typedef PtexHashMap< ReductionKey, FaceData * > ReductionMap
 
- Protected Member Functions inherited from PtexReader
void setError (const char *error)
 
FilePos tell ()
 
void seek (FilePos pos)
 
void closeFP ()
 
bool reopenFP ()
 
bool readBlock (void *data, int size, bool reportError=true)
 
bool readZipBlock (void *data, int zipsize, int unzipsize)
 
LevelgetLevel (int levelid)
 
uint8_t * getConstData ()
 
FaceDatagetFace (int levelid, Level *level, int faceid, Res res)
 
void readFaceInfo ()
 
void readLevelInfo ()
 
void readConstData ()
 
void readLevel (int levelid, Level *&level)
 
void readFace (int levelid, Level *level, int faceid, Res res)
 
void readFaceData (FilePos pos, FaceDataHeader fdh, Res res, int levelid, FaceData *&face)
 
void readMetaData ()
 
void readMetaDataBlock (MetaData *metadata, FilePos pos, int zipsize, int memsize, size_t &metaDataMemUsed)
 
void readLargeMetaDataHeaders (MetaData *metadata, FilePos pos, int zipsize, int memsize, size_t &metaDataMemUsed)
 
void readEditData ()
 
void readEditFaceData ()
 
void readEditMetaData ()
 
FaceDataerrorData (bool deleteOnRelease=false)
 
void computeOffsets (FilePos pos, int noffsets, const FaceDataHeader *fdh, FilePos *offsets)
 
- Protected Member Functions inherited from PtexTexture
virtual ~PtexTexture ()
 Destructor not for public use. Use release() instead. More...
 
- Protected Attributes inherited from PtexReader
Mutex readlock
 
DefaultInputHandler _defaultIo
 
PtexInputHandler_io
 
PtexErrorHandler_err
 
bool _premultiply
 
bool _ok
 
bool _needToOpen
 
bool _pendingPurge
 
PtexInputHandler::Handle _fp
 
FilePos _pos
 
std::string _path
 
Header _header
 
ExtHeader _extheader
 
FilePos _faceinfopos
 
FilePos _constdatapos
 
FilePos _levelinfopos
 
FilePos _leveldatapos
 
FilePos _metadatapos
 
FilePos _lmdheaderpos
 
FilePos _lmddatapos
 
FilePos _editdatapos
 
int _pixelsize
 
uint8_t * _constdata
 
MetaData_metadata
 
bool _hasEdits
 
std::vector< FaceInfo > _faceinfo
 
std::vector< uint32_t > _rfaceids
 
std::vector< LevelInfo_levelinfo
 
std::vector< FilePos_levelpos
 
std::vector< Level * > _levels
 
std::vector< MetaEdit_metaedits
 
std::vector< FaceEdit_faceedits
 
ReductionMap _reductions
 
std::vector< char > _errorPixel
 
z_stream_s _zstream
 
size_t _baseMemUsed
 
volatile size_t _memUsed
 
volatile size_t _opens
 
volatile size_t _blockReads
 

Detailed Description

Definition at line 108 of file PtexCache.h.

Constructor & Destructor Documentation

◆ PtexCachedReader()

PtexCachedReader::PtexCachedReader ( bool  premultiply,
PtexInputHandler inputHandler,
PtexErrorHandler errorHandler,
PtexReaderCache cache 
)
inline

Definition at line 130 of file PtexCache.h.

◆ ~PtexCachedReader()

PtexCachedReader::~PtexCachedReader ( )
inline

Definition at line 136 of file PtexCache.h.

Member Function Documentation

◆ getBlockReadsChange()

size_t PtexCachedReader::getBlockReadsChange ( )
inline

Definition at line 187 of file PtexCache.h.

References PtexReader::_blockReads, and _blockReadsAccountedFor.

Referenced by PtexReaderCache::processMru().

◆ getMemUsedChange()

size_t PtexCachedReader::getMemUsedChange ( )
inline

Definition at line 173 of file PtexCache.h.

References PtexReader::_memUsed, and _memUsedAccountedFor.

Referenced by PtexReaderCache::processMru(), tryPrune(), and tryPurge().

◆ getOpensChange()

size_t PtexCachedReader::getOpensChange ( )
inline

Definition at line 180 of file PtexCache.h.

References PtexReader::_opens, and _opensAccountedFor.

Referenced by PtexReaderCache::processMru().

◆ ref()

void PtexCachedReader::ref ( )
inline

Definition at line 138 of file PtexCache.h.

References _refCount, and AtomicCompareAndSwap().

Referenced by PtexReaderCache::get(), and PtexReaderCache::purge().

◆ release()

PTEX_NAMESPACE_BEGIN void PtexCachedReader::release ( )
virtual

Release resources held by this pointer (pointer becomes invalid).

Reimplemented from PtexReader.

Definition at line 83 of file PtexCache.cpp.

References _cache, PtexReaderCache::logRecentlyUsed(), and unref().

◆ trylock()

bool PtexCachedReader::trylock ( )
inlineprivate

Definition at line 119 of file PtexCache.h.

References _refCount, and AtomicCompareAndSwap().

Referenced by tryPrune(), and tryPurge().

◆ tryPrune()

bool PtexCachedReader::tryPrune ( size_t &  memUsedChange)
inline

Definition at line 152 of file PtexCache.h.

References getMemUsedChange(), PtexReader::prune(), trylock(), and unlock().

Referenced by PtexReaderCache::pruneData().

◆ tryPurge()

bool PtexCachedReader::tryPurge ( size_t &  memUsedChange)
inline

◆ unlock()

void PtexCachedReader::unlock ( )
inlineprivate

Definition at line 124 of file PtexCache.h.

References _refCount, and AtomicStore().

Referenced by tryPrune(), and tryPurge().

◆ unref()

int32_t PtexCachedReader::unref ( )
inline

Definition at line 146 of file PtexCache.h.

References _refCount, and AtomicDecrement().

Referenced by PtexReaderCache::get(), PtexReaderCache::purge(), and release().

Friends And Related Function Documentation

◆ PtexReaderCache

friend class PtexReaderCache
friend

Definition at line 117 of file PtexCache.h.

Member Data Documentation

◆ _activeFilesItem

PtexLruItem PtexCachedReader::_activeFilesItem
private

Definition at line 116 of file PtexCache.h.

◆ _blockReadsAccountedFor

size_t PtexCachedReader::_blockReadsAccountedFor
private

Definition at line 114 of file PtexCache.h.

Referenced by getBlockReadsChange().

◆ _cache

PtexReaderCache* PtexCachedReader::_cache
private

Definition at line 110 of file PtexCache.h.

Referenced by release().

◆ _memUsedAccountedFor

size_t PtexCachedReader::_memUsedAccountedFor
private

Definition at line 112 of file PtexCache.h.

Referenced by getMemUsedChange().

◆ _openFilesItem

PtexLruItem PtexCachedReader::_openFilesItem
private

Definition at line 115 of file PtexCache.h.

◆ _opensAccountedFor

size_t PtexCachedReader::_opensAccountedFor
private

Definition at line 113 of file PtexCache.h.

Referenced by getOpensChange().

◆ _refCount

volatile int32_t PtexCachedReader::_refCount
private

Definition at line 111 of file PtexCache.h.

Referenced by ref(), trylock(), unlock(), and unref().


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