aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorandroid-autoroll <android-autoroll@skia-corp.google.com.iam.gserviceaccount.com>2019-04-29 17:07:44 +0000
committerDerek Sollenberger <djsollen@google.com>2019-04-30 16:33:20 +0000
commit544e3c4cf3d69ce0bde4e138d0817b5a8562ab30 (patch)
tree7300d8851549eb3aa289a0de1d3540476a21e7b5
parent95211ca99131884e4b5de90427a98c899d74f0cb (diff)
parentf4c057af0bab3b3b03ca04cff8f7439cd926372d (diff)
downloadskia-544e3c4cf3d69ce0bde4e138d0817b5a8562ab30.tar.gz
Roll external/skia e5d7107f6..f4c057af0 (1 commits)
https://skia.googlesource.com/skia.git/+log/e5d7107f6..f4c057af0 2019-04-29 jvanverth@google.com Clean out stale shadow vertices from the SkResourceCache The AutoRoll server is located here: https://autoroll-internal.skia.org/r/android-next-autoroll Documentation for the AutoRoller is here: https://skia.googlesource.com/buildbot/+/master/autoroll/README.md If the roll is causing failures, please contact the current sheriff, who should be CC'd on the roll, and stop the roller if necessary. Test: Presubmit checks will test this change. Exempt-From-Owner-Approval: The autoroll bot does not require owner approval. Bug: 130757982 Merged-In: I48b225a2801844e1265ac2181eb02fcf2cd71c39 Change-Id: If8838e268b1267115c6f35f3021b6c4805c714cc
-rw-r--r--src/utils/SkShadowUtils.cpp27
1 files changed, 27 insertions, 0 deletions
diff --git a/src/utils/SkShadowUtils.cpp b/src/utils/SkShadowUtils.cpp
index 4cc8398040..df167d32df 100644
--- a/src/utils/SkShadowUtils.cpp
+++ b/src/utils/SkShadowUtils.cpp
@@ -14,6 +14,7 @@
#include "SkDrawShadowInfo.h"
#include "SkMaskFilter.h"
#include "SkPath.h"
+#include "SkPathPriv.h"
#include "SkRandom.h"
#include "SkRasterPipeline.h"
#include "SkResourceCache.h"
@@ -379,6 +380,31 @@ private:
// This creates a domain of keys in SkResourceCache used by this file.
static void* kNamespace;
+// When the SkPathRef genID changes, invalidate a corresponding GrResource described by key.
+class ShadowInvalidator : public SkPathRef::GenIDChangeListener {
+public:
+ ShadowInvalidator(const SkResourceCache::Key& key) {
+ fKey.reset(new uint8_t[key.size()]);
+ memcpy(fKey.get(), &key, key.size());
+ }
+
+private:
+ const SkResourceCache::Key& getKey() const {
+ return *reinterpret_cast<SkResourceCache::Key*>(fKey.get());
+ }
+
+ // always purge
+ static bool FindVisitor(const SkResourceCache::Rec&, void*) {
+ return false;
+ }
+
+ void onChange() override {
+ SkResourceCache::Find(this->getKey(), ShadowInvalidator::FindVisitor, nullptr);
+ }
+
+ std::unique_ptr<uint8_t[]> fKey;
+};
+
/**
* Draws a shadow to 'canvas'. The vertices used to draw the shadow are created by 'factory' unless
* they are first found in SkResourceCache.
@@ -420,6 +446,7 @@ bool draw_shadow(const FACTORY& factory,
return false;
}
auto rec = new CachedTessellationsRec(*key, std::move(tessellations));
+ SkPathPriv::AddGenIDChangeListener(path.path(), sk_make_sp<ShadowInvalidator>(*key));
SkResourceCache::Add(rec);
} else {
vertices = factory.makeVertices(path.path(), path.viewMatrix(),