DO NOT MERGE - Merge pie-platform-release (PPRL.190605.003) into master
Bug: 134605042
Change-Id: I5a337edc2634ba6e2ff58ac2e563ca1f4ab2e786
diff --git a/include/core/SkPixelRef.h b/include/core/SkPixelRef.h
index 49f0f97..52e679e 100644
--- a/include/core/SkPixelRef.h
+++ b/include/core/SkPixelRef.h
@@ -88,7 +88,7 @@
virtual void onChange() = 0;
};
- // Takes ownership of listener.
+ // Takes ownership of listener. Threadsafe.
void addGenIDChangeListener(GenIDChangeListener* listener);
// Call when this pixelref is part of the key to a resourcecache entry. This allows the cache
@@ -119,6 +119,7 @@
const uint32_t fStableID;
#endif
+ SkMutex fGenIDChangeListenersMutex;
SkTDArray<GenIDChangeListener*> fGenIDChangeListeners; // pointers are owned
// Set true by caches when they cache content that's derived from the current pixels.
diff --git a/include/private/SkPathRef.h b/include/private/SkPathRef.h
index b9b52d4..0a1c579 100644
--- a/include/private/SkPathRef.h
+++ b/include/private/SkPathRef.h
@@ -12,6 +12,7 @@
#include "../private/SkAtomics.h"
#include "../private/SkTDArray.h"
#include "SkMatrix.h"
+#include "SkMutex.h"
#include "SkPoint.h"
#include "SkRRect.h"
#include "SkRect.h"
@@ -311,7 +312,7 @@
virtual void onChange() = 0;
};
- void addGenIDChangeListener(GenIDChangeListener* listener);
+ void addGenIDChangeListener(GenIDChangeListener* listener); // Threadsafe
bool isValid() const;
SkDEBUGCODE(void validate() const { SkASSERT(this->isValid()); } )
@@ -538,6 +539,7 @@
mutable uint32_t fGenerationID;
SkDEBUGCODE(int32_t fEditorsAttached;) // assert that only one editor in use at any time.
+ SkMutex fGenIDChangeListenersMutex;
SkTDArray<GenIDChangeListener*> fGenIDChangeListeners; // pointers are owned
mutable uint8_t fBoundsIsDirty;
diff --git a/src/core/SkPathRef.cpp b/src/core/SkPathRef.cpp
index c710f71..a725f7e 100644
--- a/src/core/SkPathRef.cpp
+++ b/src/core/SkPathRef.cpp
@@ -670,11 +670,13 @@
delete listener;
return;
}
+ SkAutoMutexAcquire lock(fGenIDChangeListenersMutex);
*fGenIDChangeListeners.append() = listener;
}
// we need to be called *before* the genID gets changed or zerod
void SkPathRef::callGenIDChangeListeners() {
+ SkAutoMutexAcquire lock(fGenIDChangeListenersMutex);
for (int i = 0; i < fGenIDChangeListeners.count(); i++) {
fGenIDChangeListeners[i]->onChange();
}
diff --git a/src/core/SkPixelRef.cpp b/src/core/SkPixelRef.cpp
index d5e9360..868ac8c 100644
--- a/src/core/SkPixelRef.cpp
+++ b/src/core/SkPixelRef.cpp
@@ -92,11 +92,13 @@
delete listener;
return;
}
+ SkAutoMutexAcquire lock(fGenIDChangeListenersMutex);
*fGenIDChangeListeners.append() = listener;
}
// we need to be called *before* the genID gets changed or zerod
void SkPixelRef::callGenIDChangeListeners() {
+ SkAutoMutexAcquire lock(fGenIDChangeListenersMutex);
// We don't invalidate ourselves if we think another SkPixelRef is sharing our genID.
if (this->genIDIsUnique()) {
for (int i = 0; i < fGenIDChangeListeners.count(); i++) {