Update Layer Hoisting to store its atlas texture in the resource cache
BUG=skia:4346
Review URL: https://codereview.chromium.org/1406013006
diff --git a/src/gpu/GrLayerAtlas.h b/src/gpu/GrLayerAtlas.h
index ae08e45..e84667b 100644
--- a/src/gpu/GrLayerAtlas.h
+++ b/src/gpu/GrLayerAtlas.h
@@ -9,15 +9,13 @@
#ifndef GrLayerAtlas_DEFINED
#define GrLayerAtlas_DEFINED
-#include "GrTypes.h"
+#include "GrTexture.h"
#include "SkPoint.h"
-#include "SkSize.h"
#include "SkTDArray.h"
#include "SkTInternalLList.h"
class GrLayerAtlas;
-class GrTexture;
class GrTextureProvider;
class GrRectanizer;
@@ -109,10 +107,23 @@
// nullptr is returned if there is no more space in the atlas.
Plot* addToAtlas(ClientPlotUsage*, int width, int height, SkIPoint16* loc);
- GrTexture* getTexture() const {
+ GrTexture* getTextureOrNull() const {
return fTexture;
}
+ GrTexture* getTexture() const {
+ SkASSERT(fTexture);
+ return fTexture;
+ }
+
+ bool reattachBackingTexture();
+
+ void detachBackingTexture() {
+ fTexture.reset(nullptr);
+ }
+
+ void resetPlots();
+
enum IterOrder {
kLRUFirst_IterOrder,
kMRUFirst_IterOrder
@@ -127,12 +138,14 @@
}
private:
+ void createBackingTexture();
+
void makeMRU(Plot* plot);
GrTextureProvider* fTexProvider;
GrPixelConfig fPixelConfig;
GrSurfaceFlags fFlags;
- GrTexture* fTexture;
+ SkAutoTUnref<GrTexture> fTexture;
SkISize fBackingTextureSize;