Revert of Discard atlas after every MultiPictureDraw::draw (patchset #4 id:60001 of https://codereview.chromium.org/678403002/)

Reason for revert:
Breaking bots

Original issue's description:
> Discard atlas after every MultiPictureDraw::draw
>
> This is intended to prevent ghosting on tiled architectures.
>
> This CL also defers creation of the atlas (and its texture) until it is actually needed.
>
> Committed: https://skia.googlesource.com/skia/+/6d5b5455743414ddb11d2b8c1fe9d7959f2b853d

TBR=bsalomon@google.com
NOTREECHECKS=true
NOTRY=true

Review URL: https://codereview.chromium.org/687233002
This commit is contained in:
robertphillips 2014-10-29 08:17:35 -07:00 committed by Commit bot
parent bf8dc343df
commit 9f36b8719b
5 changed files with 18 additions and 48 deletions

View File

@ -146,9 +146,6 @@ void SkMultiPictureDraw::draw() {
if (NULL != context) {
GrLayerHoister::UnlockLayers(context, atlasedNeedRendering);
GrLayerHoister::UnlockLayers(context, atlasedRecycled);
#if !GR_CACHE_HOISTED_LAYERS
GrLayerHoister::PurgeCache(context);
#endif
}
#endif

View File

@ -81,6 +81,7 @@ private:
GrLayerCache::GrLayerCache(GrContext* context)
: fContext(context) {
this->initAtlas();
memset(fPlotLocks, 0, sizeof(fPlotLocks));
}
@ -119,6 +120,11 @@ void GrLayerCache::freeAll() {
// The atlas only lets go of its texture when the atlas is deleted.
fAtlas.free();
// GrLayerCache always assumes an atlas exists so recreate it. The atlas
// lazily allocates a replacement texture so reallocating a new
// atlas here won't disrupt a GrContext::abandonContext or freeGpuResources.
// TODO: Make GrLayerCache lazily allocate the atlas manager?
this->initAtlas();
}
GrCachedLayer* GrLayerCache::createLayer(uint32_t pictureID,
@ -164,7 +170,6 @@ bool GrLayerCache::tryToAtlas(GrCachedLayer* layer,
if (layer->locked()) {
// This layer is already locked
SkASSERT(fAtlas);
SkASSERT(layer->isAtlased());
SkASSERT(layer->rect().width() == desc.fWidth);
SkASSERT(layer->rect().height() == desc.fHeight);
@ -173,19 +178,12 @@ bool GrLayerCache::tryToAtlas(GrCachedLayer* layer,
}
if (layer->isAtlased()) {
SkASSERT(fAtlas);
// Hooray it is still in the atlas - make sure it stays there
layer->setLocked(true);
this->incPlotLock(layer->plot()->id());
*needsRendering = false;
return true;
} else {
if (!fAtlas) {
this->initAtlas();
if (!fAtlas) {
return false;
}
}
// Not in the atlas - will it fit?
GrPictureInfo* pictInfo = fPictureHash.find(layer->pictureID());
if (NULL == pictInfo) {
@ -258,7 +256,7 @@ void GrLayerCache::unlock(GrCachedLayer* layer) {
this->decPlotLock(plotID);
// At this point we could aggressively clear out un-locked plots but
// by delaying we may be able to reuse some of the atlased layers later.
#if !GR_CACHE_HOISTED_LAYERS
#if DISABLE_CACHING
// This testing code aggressively removes the atlased layers. This
// can be used to separate the performance contribution of less
// render target pingponging from that due to the re-use of cached layers
@ -357,7 +355,6 @@ void GrLayerCache::purge(uint32_t pictureID) {
bool GrLayerCache::purgePlot() {
SkDEBUGCODE(GrAutoValidateCache avc(this);)
SkASSERT(fAtlas);
GrAtlas::PlotIter iter;
GrPlot* plot;
@ -412,12 +409,7 @@ void GrLayerCache::purgePlot(GrPlot* plot) {
plot->resetRects();
}
#if !GR_CACHE_HOISTED_LAYERS
void GrLayerCache::purgeAll() {
if (!fAtlas) {
return;
}
GrAtlas::PlotIter iter;
GrPlot* plot;
for (plot = fAtlas->iterInit(&iter, GrAtlas::kLRUFirst_IterOrder);
@ -427,10 +419,7 @@ void GrLayerCache::purgeAll() {
this->purgePlot(plot);
}
fContext->discardRenderTarget(fAtlas->getTexture()->asRenderTarget());
}
#endif
class GrPictureDeletionListener : public SkPicture::DeletionListener {
virtual void onDeletion(uint32_t pictureID) SK_OVERRIDE{
@ -459,7 +448,6 @@ void GrLayerCache::processDeletedPictures() {
#ifdef SK_DEVELOPER
void GrLayerCache::writeLayersToDisk(const SkString& dirName) {
if (fAtlas) {
GrTexture* atlasTexture = fAtlas->getTexture();
if (NULL != atlasTexture) {
SkString fileName(dirName);
@ -467,7 +455,6 @@ void GrLayerCache::writeLayersToDisk(const SkString& dirName) {
atlasTexture->surfacePriv().savePixels(fileName.c_str());
}
}
SkTDynamicHash<GrCachedLayer, GrCachedLayer::Key>::Iter iter(&fLayerHash);
for (; !iter.done(); ++iter) {

View File

@ -18,9 +18,6 @@
class SkPicture;
// Set to 0 to disable caching of hoisted layers
#define GR_CACHE_HOISTED_LAYERS 0
// The layer cache listens for these messages to purge picture-related resources.
struct GrPictureDeletedMessage {
uint32_t pictureID;
@ -252,10 +249,6 @@ public:
return width <= kPlotWidth && height <= kPlotHeight;
}
#if !GR_CACHE_HOISTED_LAYERS
void purgeAll();
#endif
private:
static const int kAtlasTextureWidth = 1024;
static const int kAtlasTextureHeight = 1024;
@ -298,6 +291,8 @@ private:
const SkIRect& bounds, const SkMatrix& ctm,
const SkPaint* paint);
void purgeAll();
// Remove all the layers (and unlock any resources) associated with 'pictureID'
void purge(uint32_t pictureID);

View File

@ -314,16 +314,13 @@ void GrLayerHoister::UnlockLayers(GrContext* context,
layerCache->removeUse(layers[i].fLayer);
}
SkDEBUGCODE(layerCache->validate();)
}
void GrLayerHoister::PurgeCache(GrContext* context) {
#if !GR_CACHE_HOISTED_LAYERS
GrLayerCache* layerCache = context->getLayerCache();
#if DISABLE_CACHING
// This code completely clears out the atlas. It is required when
// caching is disabled so the atlas doesn't fill up and force more
// free floating layers
layerCache->purgeAll();
#endif
SkDEBUGCODE(layerCache->validate();)
}

View File

@ -87,12 +87,6 @@ public:
@param layers Unneeded layers in the atlas
*/
static void UnlockLayers(GrContext* context, const SkTDArray<GrHoistedLayer>& layers);
/** Forceably remove all cached layers and release the atlas. Useful for debugging and timing.
This is only functional when GR_CACHE_HOISTED_LAYERS is set to 1 in GrLayerCache.h
@param context Owner of the layer cache (and thus the layers)
*/
static void PurgeCache(GrContext* context);
};
#endif