xref: /aosp_15_r20/external/skia/include/private/chromium/GrPromiseImageTexture.h (revision c8dee2aa9b3f27cf6c858bd81872bdeb2c07ed17)
1 /*
2  * Copyright 2023 Google LLC
3  *
4  * Use of this source code is governed by a BSD-style license that can be
5  * found in the LICENSE file.
6  */
7 
8 #ifndef GrPromiseImageTexture_DEFINED
9 #define GrPromiseImageTexture_DEFINED
10 
11 #include "include/core/SkRefCnt.h"
12 #include "include/core/SkTypes.h"
13 #include "include/gpu/ganesh/GrBackendSurface.h"
14 /**
15  * This type is used to fulfill textures for PromiseImages. Once an instance is returned from a
16  * PromiseImageTextureFulfillProc the GrBackendTexture it wraps must remain valid until the
17  * corresponding PromiseImageTextureReleaseProc is called.
18  */
19 class SK_API GrPromiseImageTexture : public SkNVRefCnt<GrPromiseImageTexture> {
20 public:
21     GrPromiseImageTexture() = delete;
22     GrPromiseImageTexture(const GrPromiseImageTexture&) = delete;
23     GrPromiseImageTexture(GrPromiseImageTexture&&) = delete;
24     ~GrPromiseImageTexture();
25     GrPromiseImageTexture& operator=(const GrPromiseImageTexture&) = delete;
26     GrPromiseImageTexture& operator=(GrPromiseImageTexture&&) = delete;
27 
Make(const GrBackendTexture & backendTexture)28     static sk_sp<GrPromiseImageTexture> Make(const GrBackendTexture& backendTexture) {
29         if (!backendTexture.isValid()) {
30             return nullptr;
31         }
32         return sk_sp<GrPromiseImageTexture>(new GrPromiseImageTexture(backendTexture));
33     }
34 
backendTexture()35     GrBackendTexture backendTexture() const { return fBackendTexture; }
36 
37 private:
38     explicit GrPromiseImageTexture(const GrBackendTexture& backendTexture);
39 
40     GrBackendTexture fBackendTexture;
41 };
42 
43 #endif // GrPromiseImageTexture_DEFINED
44