Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(304)

Unified Diff: src/gpu/GrLayerAtlas.cpp

Issue 1406013006: Update Layer Hoisting to store its atlas texture in the resource cache (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Fix Android bug Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/gpu/GrLayerAtlas.h ('k') | src/gpu/GrLayerCache.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/gpu/GrLayerAtlas.cpp
diff --git a/src/gpu/GrLayerAtlas.cpp b/src/gpu/GrLayerAtlas.cpp
index 3b30607c8cfc72cea328bbea9eb3023b89842098..9beb509f86ebe0e3f51a68de36ce30e10376ab7f 100644
--- a/src/gpu/GrLayerAtlas.cpp
+++ b/src/gpu/GrLayerAtlas.cpp
@@ -6,6 +6,7 @@
* found in the LICENSE file.
*/
+#include "GrGpuResourcePriv.h"
#include "GrLayerAtlas.h"
#include "GrRectanizer.h"
#include "GrTextureProvider.h"
@@ -43,6 +44,32 @@ void GrLayerAtlas::Plot::reset() {
}
///////////////////////////////////////////////////////////////////////////////
+GR_DECLARE_STATIC_UNIQUE_KEY(gLayerAtlasKey);
+static const GrUniqueKey& get_layer_atlas_key() {
+ GR_DEFINE_STATIC_UNIQUE_KEY(gLayerAtlasKey);
+ return gLayerAtlasKey;
+}
+
+bool GrLayerAtlas::reattachBackingTexture() {
+ SkASSERT(!fTexture);
+
+ fTexture.reset(fTexProvider->findAndRefTextureByUniqueKey(get_layer_atlas_key()));
+ return SkToBool(fTexture);
+}
+
+void GrLayerAtlas::createBackingTexture() {
+ SkASSERT(!fTexture);
+
+ GrSurfaceDesc desc;
+ desc.fFlags = fFlags;
+ desc.fWidth = fBackingTextureSize.width();
+ desc.fHeight = fBackingTextureSize.height();
+ desc.fConfig = fPixelConfig;
+
+ fTexture.reset(fTexProvider->createTexture(desc, true, nullptr, 0));
+
+ fTexture->resourcePriv().setUniqueKey(get_layer_atlas_key());
+}
GrLayerAtlas::GrLayerAtlas(GrTextureProvider* texProvider, GrPixelConfig config,
GrSurfaceFlags flags,
@@ -52,7 +79,6 @@ GrLayerAtlas::GrLayerAtlas(GrTextureProvider* texProvider, GrPixelConfig config,
fPixelConfig = config;
fFlags = flags;
fBackingTextureSize = backingTextureSize;
- fTexture = nullptr;
int textureWidth = fBackingTextureSize.width();
int textureHeight = fBackingTextureSize.height();
@@ -81,8 +107,14 @@ GrLayerAtlas::GrLayerAtlas(GrTextureProvider* texProvider, GrPixelConfig config,
}
}
+void GrLayerAtlas::resetPlots() {
+ PlotIter iter;
+ for (Plot* plot = iter.init(fPlotList, PlotIter::kHead_IterStart); plot; plot = iter.next()) {
+ plot->reset();
+ }
+}
+
GrLayerAtlas::~GrLayerAtlas() {
- SkSafeUnref(fTexture);
delete[] fPlotArray;
}
@@ -111,14 +143,7 @@ GrLayerAtlas::Plot* GrLayerAtlas::addToAtlas(ClientPlotUsage* usage,
// before we get a new plot, make sure we have a backing texture
if (nullptr == fTexture) {
- // TODO: Update this to use the cache rather than directly creating a texture.
- GrSurfaceDesc desc;
- desc.fFlags = fFlags;
- desc.fWidth = fBackingTextureSize.width();
- desc.fHeight = fBackingTextureSize.height();
- desc.fConfig = fPixelConfig;
-
- fTexture = fTexProvider->createTexture(desc, true, nullptr, 0);
+ this->createBackingTexture();
if (nullptr == fTexture) {
return nullptr;
}
« no previous file with comments | « src/gpu/GrLayerAtlas.h ('k') | src/gpu/GrLayerCache.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698