Skia
2D Graphics Library
SkPromiseImageTexture.h
Go to the documentation of this file.
1 /*
2  * Copyright 2017 Google Inc.
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 SkPromiseImageTexture_DEFINED
9 #define SkPromiseImageTexture_DEFINED
10 
11 #include "include/core/SkRefCnt.h"
13 #include "include/private/GrResourceKey.h"
14 
15 #if SK_SUPPORT_GPU
16 
27 class SK_API SkPromiseImageTexture : public SkNVRefCnt<SkPromiseImageTexture> {
28 public:
29  SkPromiseImageTexture() = delete;
30  SkPromiseImageTexture(const SkPromiseImageTexture&) = delete;
31  SkPromiseImageTexture(SkPromiseImageTexture&&) = delete;
32  ~SkPromiseImageTexture();
33  SkPromiseImageTexture& operator=(const SkPromiseImageTexture&) = delete;
34  SkPromiseImageTexture& operator=(SkPromiseImageTexture&&) = delete;
35 
36  static sk_sp<SkPromiseImageTexture> Make(const GrBackendTexture& backendTexture) {
37  if (!backendTexture.isValid()) {
38  return nullptr;
39  }
40  return sk_sp<SkPromiseImageTexture>(new SkPromiseImageTexture(backendTexture));
41  }
42 
43  GrBackendTexture backendTexture() const { return fBackendTexture; }
44 
45  void addKeyToInvalidate(uint32_t contextID, const GrUniqueKey& key);
46  uint32_t uniqueID() const { return fUniqueID; }
47 
48 #if GR_TEST_UTILS
49  SkTArray<GrUniqueKey> testingOnly_uniqueKeysToInvalidate() const;
50 #endif
51 
52 private:
53  explicit SkPromiseImageTexture(const GrBackendTexture& backendTexture);
54 
55  SkSTArray<1, GrUniqueKeyInvalidatedMessage> fMessages;
56  GrBackendTexture fBackendTexture;
57  uint32_t fUniqueID = SK_InvalidUniqueID;
58  static std::atomic<uint32_t> gUniqueID;
59 };
60 #endif
61 
62 #endif
SkNVRefCnt
Definition: SkRefCnt.h:159
SkRefCnt.h
sk_sp
Shared pointer class to wrap classes that support a ref()/unref() interface.
Definition: SkRefCnt.h:215
SK_InvalidUniqueID
static constexpr uint32_t SK_InvalidUniqueID
The unique IDs in Skia reserve 0 has an invalid marker.
Definition: SkTypes.h:573
GrBackendSurface.h
SK_API
#define SK_API
Definition: SkTypes.h:181
GrBackendTexture::isValid
bool isValid() const
Definition: GrBackendSurface.h:58
SkBlurDrawLooper::Make
sk_sp< SkDrawLooper > SK_API Make(SkColor4f color, SkColorSpace *cs, SkScalar sigma, SkScalar dx, SkScalar dy)
GrBackendTexture
Definition: GrBackendSurface.h:54