f143274cda
Remove done and release distinction. Chrome is not using either as it tracks texture access using other synchronization mechanisms (semaphores, flush finish procs). Now there is just fulfill and release where release is called when the texture can be deleted. Also, release proc can be null. Simplify texture idle mechanism as the "flushed" state was only used to implement the old idea of a release proc. The "finished" idle state is still used to implement the new release proc. Though, it could also be removed if GrTexture were to be removed for textures returned by fulfill. Not directly tied to this bug, but a new YUVA factory will be required and it's good to clean things up first to avoid adding another instance of the current complexity. Bug: skia:10632 Change-Id: I4fe3c0af3f5a591506b1b3c736fd3284a38465a6 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/331836 Commit-Queue: Brian Salomon <bsalomon@google.com> Reviewed-by: Greg Daniel <egdaniel@google.com> Reviewed-by: Robert Phillips <robertphillips@google.com>
63 lines
2.4 KiB
C++
63 lines
2.4 KiB
C++
/*
|
|
* Copyright 2017 Google Inc.
|
|
*
|
|
* Use of this source code is governed by a BSD-style license that can be
|
|
* found in the LICENSE file.
|
|
*/
|
|
|
|
#ifndef SkPromiseImageTexture_DEFINED
|
|
#define SkPromiseImageTexture_DEFINED
|
|
|
|
#include "include/core/SkRefCnt.h"
|
|
#include "include/gpu/GrBackendSurface.h"
|
|
#include "include/private/GrResourceKey.h"
|
|
|
|
#if SK_SUPPORT_GPU
|
|
/**
|
|
* 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.
|
|
*/
|
|
class SK_API SkPromiseImageTexture : public SkNVRefCnt<SkPromiseImageTexture> {
|
|
public:
|
|
SkPromiseImageTexture() = delete;
|
|
SkPromiseImageTexture(const SkPromiseImageTexture&) = delete;
|
|
SkPromiseImageTexture(SkPromiseImageTexture&&) = delete;
|
|
~SkPromiseImageTexture();
|
|
SkPromiseImageTexture& operator=(const SkPromiseImageTexture&) = delete;
|
|
SkPromiseImageTexture& operator=(SkPromiseImageTexture&&) = delete;
|
|
|
|
static sk_sp<SkPromiseImageTexture> Make(const GrBackendTexture& backendTexture) {
|
|
if (!backendTexture.isValid()) {
|
|
return nullptr;
|
|
}
|
|
return sk_sp<SkPromiseImageTexture>(new SkPromiseImageTexture(backendTexture));
|
|
}
|
|
|
|
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
|
|
|
|
#endif
|