Remove all unused uniqueKey support from SkPromiseImageTexture.
At this point SkPromiseImageTexture is not much more than a wrapper around a GrBackendTexture. The next steps would be to switch to just directly using GrBackendTexture in the fulfill procs and deleting SkPromiseImageTexture. Bug: skia:12758 Change-Id: Ic0526b869a0730c25b41b46fd6523604dedaba40 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/487382 Auto-Submit: Greg Daniel <egdaniel@google.com> Reviewed-by: Brian Salomon <bsalomon@google.com> Commit-Queue: Brian Salomon <bsalomon@google.com>
This commit is contained in:
parent
bdc0bad2e2
commit
fe995770fe
@ -13,17 +13,10 @@
|
||||
#if SK_SUPPORT_GPU
|
||||
#include "include/core/SkRefCnt.h"
|
||||
#include "include/gpu/GrBackendSurface.h"
|
||||
#include "include/private/GrResourceKey.h"
|
||||
/**
|
||||
* This type is used to fulfill textures for PromiseImages. Once an instance is returned from a
|
||||
* PromiseImageTextureFulfillProc the GrBackendTexture it wraps must remain valid until the
|
||||
* corresponding PromiseImageTextureReleaseProc is called. For performance reasons it is
|
||||
* recommended that the client reuse a single PromiseImageTexture each time a given texture
|
||||
* is returned by the PromiseImageTextureFulfillProc rather than creating a new PromiseImageTexture
|
||||
* representing the same underlying backend API texture. If the underlying texture is deleted (after
|
||||
* PromiseImageTextureReleaseProc has been called if this was returned by a
|
||||
* PromiseImageTextureFulfillProc) then this object should be disposed as the texture it represented
|
||||
* cannot be used to fulfill again.
|
||||
* corresponding PromiseImageTextureReleaseProc is called.
|
||||
*/
|
||||
class SK_API SkPromiseImageTexture : public SkNVRefCnt<SkPromiseImageTexture> {
|
||||
public:
|
||||
@ -43,20 +36,10 @@ public:
|
||||
|
||||
GrBackendTexture backendTexture() const { return fBackendTexture; }
|
||||
|
||||
void addKeyToInvalidate(uint32_t contextID, const GrUniqueKey& key);
|
||||
uint32_t uniqueID() const { return fUniqueID; }
|
||||
|
||||
#if GR_TEST_UTILS
|
||||
SkTArray<GrUniqueKey> testingOnly_uniqueKeysToInvalidate() const;
|
||||
#endif
|
||||
|
||||
private:
|
||||
explicit SkPromiseImageTexture(const GrBackendTexture& backendTexture);
|
||||
|
||||
SkSTArray<1, GrUniqueKeyInvalidatedMessage> fMessages;
|
||||
GrBackendTexture fBackendTexture;
|
||||
uint32_t fUniqueID = SK_InvalidUniqueID;
|
||||
static std::atomic<uint32_t> gUniqueID;
|
||||
};
|
||||
#endif // SK_SUPPORT_GPU
|
||||
|
||||
|
@ -8,41 +8,12 @@
|
||||
#include "include/core/SkPromiseImageTexture.h"
|
||||
|
||||
#if SK_SUPPORT_GPU
|
||||
#include "src/core/SkMessageBus.h"
|
||||
|
||||
std::atomic<uint32_t> SkPromiseImageTexture::gUniqueID{1};
|
||||
|
||||
SkPromiseImageTexture::SkPromiseImageTexture(const GrBackendTexture& backendTexture) {
|
||||
SkASSERT(backendTexture.isValid());
|
||||
fBackendTexture = backendTexture;
|
||||
fUniqueID = gUniqueID.fetch_add(1, std::memory_order_relaxed);
|
||||
}
|
||||
|
||||
SkPromiseImageTexture::~SkPromiseImageTexture() {
|
||||
for (const auto& msg : fMessages) {
|
||||
SkMessageBus<GrUniqueKeyInvalidatedMessage, uint32_t>::Post(msg);
|
||||
}
|
||||
}
|
||||
|
||||
void SkPromiseImageTexture::addKeyToInvalidate(uint32_t contextID, const GrUniqueKey& key) {
|
||||
SkASSERT(contextID != SK_InvalidUniqueID);
|
||||
SkASSERT(key.isValid());
|
||||
for (const auto& msg : fMessages) {
|
||||
if (msg.contextID() == contextID && msg.key() == key) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
fMessages.emplace_back(key, contextID, /* inThreadSafeCache */ false);
|
||||
}
|
||||
|
||||
#if GR_TEST_UTILS
|
||||
SkTArray<GrUniqueKey> SkPromiseImageTexture::testingOnly_uniqueKeysToInvalidate() const {
|
||||
SkTArray<GrUniqueKey> results;
|
||||
for (const auto& msg : fMessages) {
|
||||
results.push_back(msg.key());
|
||||
}
|
||||
return results;
|
||||
}
|
||||
#endif // GR_TEST_UTILS
|
||||
SkPromiseImageTexture::~SkPromiseImageTexture() {}
|
||||
|
||||
#endif // SK_SUPPORT_GPU
|
||||
|
@ -33,16 +33,6 @@ struct PromiseTextureChecker {
|
||||
int fFulfillCount = 0;
|
||||
int fReleaseCount = 0;
|
||||
|
||||
/**
|
||||
* Releases the SkPromiseImageTexture. Used to test that cached GrTexture representations
|
||||
* in the cache are freed.
|
||||
*/
|
||||
void releaseTexture() { fTexture.reset(); }
|
||||
|
||||
SkTArray<GrUniqueKey> uniqueKeys() const {
|
||||
return fTexture->testingOnly_uniqueKeysToInvalidate();
|
||||
}
|
||||
|
||||
static sk_sp<SkPromiseImageTexture> Fulfill(void* self) {
|
||||
auto checker = static_cast<PromiseTextureChecker*>(self);
|
||||
checker->fFulfillCount++;
|
||||
|
Loading…
Reference in New Issue
Block a user