зеркало из https://github.com/mozilla/moz-skia.git
Added resource cache debug output to help track changes
http://codereview.appspot.com/6463079/ git-svn-id: http://skia.googlecode.com/svn/trunk@5220 2bbb7eff-a529-9590-31e7-b0007b416f81
This commit is contained in:
Родитель
936fb954db
Коммит
5f9f2f574f
|
@ -1148,7 +1148,22 @@ int main(int argc, char * const argv[]) {
|
|||
for (int i = 0; i < failedTests.count(); ++i) {
|
||||
SkDebugf("\t\t%s\n", failedTests[i].c_str());
|
||||
}
|
||||
|
||||
#if SK_SUPPORT_GPU
|
||||
|
||||
#if SK_DEBUG
|
||||
for (int i = 0; i < configs.count(); i++) {
|
||||
ConfigData config = gRec[configs[i]];
|
||||
|
||||
if (kGPU_Backend == config.fBackend) {
|
||||
GrContext* gr = grFactory->get(config.fGLContextType);
|
||||
|
||||
SkDebugf("config: %s %x\n", config.fName, gr);
|
||||
gr->printCacheStats();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
delete grFactory;
|
||||
#endif
|
||||
SkGraphics::Term();
|
||||
|
|
|
@ -752,6 +752,10 @@ public:
|
|||
bool antiAlias,
|
||||
bool allowSW);
|
||||
|
||||
#ifdef GR_DEBUG
|
||||
void printCacheStats() const;
|
||||
#endif
|
||||
|
||||
private:
|
||||
// Used to indicate whether a draw should be performed immediately or queued in fDrawBuffer.
|
||||
enum BufferedDraw {
|
||||
|
|
|
@ -1899,3 +1899,8 @@ GrTexture* GrContext::applyMorphology(GrTexture* srcTexture,
|
|||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
#if GR_DEBUG
|
||||
void GrContext::printCacheStats() const {
|
||||
fTextureCache->printStats();
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -38,11 +38,19 @@ void GrResourceEntry::validate() const {
|
|||
GrResourceCache::GrResourceCache(int maxCount, size_t maxBytes) :
|
||||
fMaxCount(maxCount),
|
||||
fMaxBytes(maxBytes) {
|
||||
fEntryCount = 0;
|
||||
fUnlockedEntryCount = 0;
|
||||
fEntryBytes = 0;
|
||||
fClientDetachedCount = 0;
|
||||
fClientDetachedBytes = 0;
|
||||
#if GR_DEBUG
|
||||
fHighWaterEntryCount = 0;
|
||||
fHighWaterUnlockedEntryCount = 0;
|
||||
fHighWaterEntryBytes = 0;
|
||||
fHighWaterClientDetachedCount = 0;
|
||||
fHighWaterClientDetachedBytes = 0;
|
||||
#endif
|
||||
|
||||
fEntryCount = 0;
|
||||
fUnlockedEntryCount = 0;
|
||||
fEntryBytes = 0;
|
||||
fClientDetachedCount = 0;
|
||||
fClientDetachedBytes = 0;
|
||||
|
||||
fHead = fTail = NULL;
|
||||
fPurging = false;
|
||||
|
@ -100,6 +108,16 @@ void GrResourceCache::internalDetach(GrResourceEntry* entry,
|
|||
if (clientDetach) {
|
||||
fClientDetachedCount += 1;
|
||||
fClientDetachedBytes += entry->resource()->sizeInBytes();
|
||||
|
||||
#if GR_DEBUG
|
||||
if (fHighWaterClientDetachedCount < fClientDetachedCount) {
|
||||
fHighWaterClientDetachedCount = fClientDetachedCount;
|
||||
}
|
||||
if (fHighWaterClientDetachedBytes < fClientDetachedBytes) {
|
||||
fHighWaterClientDetachedBytes = fClientDetachedBytes;
|
||||
}
|
||||
#endif
|
||||
|
||||
} else {
|
||||
fEntryCount -= 1;
|
||||
fEntryBytes -= entry->resource()->sizeInBytes();
|
||||
|
@ -119,6 +137,11 @@ void GrResourceCache::attachToHead(GrResourceEntry* entry,
|
|||
}
|
||||
if (!entry->isLocked()) {
|
||||
++fUnlockedEntryCount;
|
||||
#if GR_DEBUG
|
||||
if (fHighWaterUnlockedEntryCount < fUnlockedEntryCount) {
|
||||
fHighWaterUnlockedEntryCount = fUnlockedEntryCount;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
// update our stats
|
||||
|
@ -128,6 +151,15 @@ void GrResourceCache::attachToHead(GrResourceEntry* entry,
|
|||
} else {
|
||||
fEntryCount += 1;
|
||||
fEntryBytes += entry->resource()->sizeInBytes();
|
||||
|
||||
#if GR_DEBUG
|
||||
if (fHighWaterEntryCount < fEntryCount) {
|
||||
fHighWaterEntryCount = fEntryCount;
|
||||
}
|
||||
if (fHighWaterEntryBytes < fEntryBytes) {
|
||||
fHighWaterEntryBytes = fEntryBytes;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -269,6 +301,11 @@ void GrResourceCache::unlock(GrResourceEntry* entry) {
|
|||
entry->unlock();
|
||||
if (!entry->isLocked()) {
|
||||
++fUnlockedEntryCount;
|
||||
#if GR_DEBUG
|
||||
if (fHighWaterUnlockedEntryCount < fUnlockedEntryCount) {
|
||||
fHighWaterUnlockedEntryCount = fUnlockedEntryCount;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
this->purgeAsNeeded();
|
||||
}
|
||||
|
@ -409,4 +446,19 @@ void GrResourceCache::validate() const {
|
|||
GrAssert(1 == matches);
|
||||
}
|
||||
}
|
||||
|
||||
void GrResourceCache::printStats() const {
|
||||
SkDebugf("Budget: %d items %d bytes\n", fMaxCount, fMaxBytes);
|
||||
SkDebugf("\t\tEntry Count: current %d high %d\n",
|
||||
fEntryCount, fHighWaterEntryCount);
|
||||
SkDebugf("\t\tUnlocked Entry Count: current %d high %d\n",
|
||||
fUnlockedEntryCount, fHighWaterUnlockedEntryCount);
|
||||
SkDebugf("\t\tEntry Bytes: current %d high %d\n",
|
||||
fEntryBytes, fHighWaterEntryBytes);
|
||||
SkDebugf("\t\tDetached Entry Count: current %d high %d\n",
|
||||
fClientDetachedCount, fHighWaterClientDetachedCount);
|
||||
SkDebugf("\t\tDetached Bytes: current %d high %d\n",
|
||||
fClientDetachedBytes, fHighWaterClientDetachedBytes);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
@ -280,6 +280,7 @@ public:
|
|||
|
||||
#if GR_DEBUG
|
||||
void validate() const;
|
||||
void printStats() const;
|
||||
#else
|
||||
void validate() const {}
|
||||
#endif
|
||||
|
@ -301,6 +302,14 @@ private:
|
|||
size_t fMaxBytes;
|
||||
|
||||
// our current stats, related to our budget
|
||||
#if GR_DEBUG
|
||||
int fHighWaterEntryCount;
|
||||
int fHighWaterUnlockedEntryCount;
|
||||
size_t fHighWaterEntryBytes;
|
||||
int fHighWaterClientDetachedCount;
|
||||
size_t fHighWaterClientDetachedBytes;
|
||||
#endif
|
||||
|
||||
int fEntryCount;
|
||||
int fUnlockedEntryCount;
|
||||
size_t fEntryBytes;
|
||||
|
|
Загрузка…
Ссылка в новой задаче