2019-01-10 17:09:52 +00:00
|
|
|
/*
|
|
|
|
* 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
|
|
|
|
|
2021-10-28 14:07:54 +00:00
|
|
|
#include "include/core/SkTypes.h"
|
|
|
|
|
|
|
|
#if SK_SUPPORT_GPU
|
2019-04-23 17:05:21 +00:00
|
|
|
#include "include/core/SkRefCnt.h"
|
|
|
|
#include "include/gpu/GrBackendSurface.h"
|
2019-01-10 17:09:52 +00:00
|
|
|
/**
|
|
|
|
* This type is used to fulfill textures for PromiseImages. Once an instance is returned from a
|
2020-11-09 20:40:27 +00:00
|
|
|
* PromiseImageTextureFulfillProc the GrBackendTexture it wraps must remain valid until the
|
2021-12-21 20:56:08 +00:00
|
|
|
* corresponding PromiseImageTextureReleaseProc is called.
|
2019-01-10 17:09:52 +00:00
|
|
|
*/
|
2019-01-11 21:03:19 +00:00
|
|
|
class SK_API SkPromiseImageTexture : public SkNVRefCnt<SkPromiseImageTexture> {
|
2019-01-10 17:09:52 +00:00
|
|
|
public:
|
2019-01-11 21:03:19 +00:00
|
|
|
SkPromiseImageTexture() = delete;
|
2019-01-10 17:09:52 +00:00
|
|
|
SkPromiseImageTexture(const SkPromiseImageTexture&) = delete;
|
2019-01-11 21:03:19 +00:00
|
|
|
SkPromiseImageTexture(SkPromiseImageTexture&&) = delete;
|
2019-01-10 17:09:52 +00:00
|
|
|
~SkPromiseImageTexture();
|
|
|
|
SkPromiseImageTexture& operator=(const SkPromiseImageTexture&) = delete;
|
2019-01-11 21:03:19 +00:00
|
|
|
SkPromiseImageTexture& operator=(SkPromiseImageTexture&&) = delete;
|
|
|
|
|
|
|
|
static sk_sp<SkPromiseImageTexture> Make(const GrBackendTexture& backendTexture) {
|
|
|
|
if (!backendTexture.isValid()) {
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
return sk_sp<SkPromiseImageTexture>(new SkPromiseImageTexture(backendTexture));
|
|
|
|
}
|
|
|
|
|
2020-09-30 14:34:49 +00:00
|
|
|
GrBackendTexture backendTexture() const { return fBackendTexture; }
|
2019-01-10 17:09:52 +00:00
|
|
|
|
|
|
|
private:
|
2019-01-11 21:03:19 +00:00
|
|
|
explicit SkPromiseImageTexture(const GrBackendTexture& backendTexture);
|
|
|
|
|
2019-01-10 17:09:52 +00:00
|
|
|
GrBackendTexture fBackendTexture;
|
|
|
|
};
|
2021-10-28 14:07:54 +00:00
|
|
|
#endif // SK_SUPPORT_GPU
|
2019-01-10 17:09:52 +00:00
|
|
|
|
2021-10-28 14:07:54 +00:00
|
|
|
#endif // SkPromiseImageTexture_DEFINED
|