Robert Phillips | 9660108 | 2018-05-29 16:13:26 -0400 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2018 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 PromiseImageHelper_DEFINED |
| 9 | #define PromiseImageHelper_DEFINED |
| 10 | |
Mike Klein | c0bd9f9 | 2019-04-23 12:05:21 -0500 | [diff] [blame] | 11 | #include "include/core/SkBitmap.h" |
Kevin Lubick | 3b9113f | 2021-11-02 11:38:39 -0400 | [diff] [blame] | 12 | #include "include/core/SkRefCnt.h" |
Brian Salomon | be0e42c | 2020-08-27 11:00:04 -0400 | [diff] [blame] | 13 | #include "include/core/SkYUVAPixmaps.h" |
Mike Klein | c0bd9f9 | 2019-04-23 12:05:21 -0500 | [diff] [blame] | 14 | #include "include/gpu/GrBackendSurface.h" |
Kevin Lubick | dc6cc02 | 2023-01-13 11:24:27 -0500 | [diff] [blame] | 15 | #include "include/private/base/SkTArray.h" |
Kevin Lubick | eb98125 | 2023-06-13 07:51:26 -0400 | [diff] [blame] | 16 | #include "include/private/chromium/GrPromiseImageTexture.h" |
Kevin Lubick | 1b3aa8b | 2023-01-19 14:03:31 -0500 | [diff] [blame] | 17 | #include "src/base/SkTLazy.h" |
Mike Klein | c0bd9f9 | 2019-04-23 12:05:21 -0500 | [diff] [blame] | 18 | #include "src/core/SkCachedData.h" |
Robert Phillips | 9660108 | 2018-05-29 16:13:26 -0400 | [diff] [blame] | 19 | |
Kevin Lubick | 0bff57e | 2023-06-09 14:29:17 -0400 | [diff] [blame] | 20 | class GrContextThreadSafeProxy; |
Adlai Holler | b270568 | 2020-10-20 10:11:53 -0400 | [diff] [blame] | 21 | class GrDirectContext; |
Robert Phillips | 9660108 | 2018-05-29 16:13:26 -0400 | [diff] [blame] | 22 | class SkImage; |
Mike Reed | 13711eb | 2020-07-14 17:16:32 -0400 | [diff] [blame] | 23 | class SkMipmap; |
Robert Phillips | 9660108 | 2018-05-29 16:13:26 -0400 | [diff] [blame] | 24 | class SkPicture; |
Robert Phillips | 1a57857 | 2020-07-13 13:17:09 -0400 | [diff] [blame] | 25 | class SkTaskGroup; |
Robert Phillips | 9660108 | 2018-05-29 16:13:26 -0400 | [diff] [blame] | 26 | |
Robert Phillips | 11c6767 | 2020-04-23 15:10:03 -0400 | [diff] [blame] | 27 | // This class acts as a proxy for a GrBackendTexture that backs an image. |
| 28 | // Whenever a promise image is created for the image, the promise image receives a ref to |
| 29 | // potentially several of these objects. Once all the promise images receive their done |
| 30 | // callbacks this object is deleted - removing the GrBackendTexture from VRAM. |
| 31 | // Note that while the DDLs are being created in the threads, the PromiseImageHelper holds |
| 32 | // a ref on all the PromiseImageCallbackContexts. However, once all the threads are done |
| 33 | // it drops all of its refs (via "reset"). |
| 34 | class PromiseImageCallbackContext : public SkRefCnt { |
| 35 | public: |
Robert Phillips | d5f3c98 | 2020-07-07 13:18:47 -0400 | [diff] [blame] | 36 | PromiseImageCallbackContext(GrDirectContext* direct, GrBackendFormat backendFormat) |
| 37 | : fContext(direct) |
Robert Phillips | 11c6767 | 2020-04-23 15:10:03 -0400 | [diff] [blame] | 38 | , fBackendFormat(backendFormat) {} |
| 39 | |
Brian Salomon | d007281 | 2020-07-21 17:03:56 -0400 | [diff] [blame] | 40 | ~PromiseImageCallbackContext() override; |
Robert Phillips | 11c6767 | 2020-04-23 15:10:03 -0400 | [diff] [blame] | 41 | |
| 42 | const GrBackendFormat& backendFormat() const { return fBackendFormat; } |
| 43 | |
| 44 | void setBackendTexture(const GrBackendTexture& backendTexture); |
| 45 | |
Robert Phillips | d5f3c98 | 2020-07-07 13:18:47 -0400 | [diff] [blame] | 46 | void destroyBackendTexture(); |
Robert Phillips | 11c6767 | 2020-04-23 15:10:03 -0400 | [diff] [blame] | 47 | |
Kevin Lubick | eb98125 | 2023-06-13 07:51:26 -0400 | [diff] [blame] | 48 | sk_sp<GrPromiseImageTexture> fulfill() { |
Robert Phillips | 11c6767 | 2020-04-23 15:10:03 -0400 | [diff] [blame] | 49 | ++fTotalFulfills; |
| 50 | return fPromiseImageTexture; |
| 51 | } |
| 52 | |
| 53 | void release() { |
Robert Phillips | 11c6767 | 2020-04-23 15:10:03 -0400 | [diff] [blame] | 54 | ++fDoneCnt; |
Brian Salomon | 9679612 | 2021-01-19 12:11:07 -0500 | [diff] [blame] | 55 | SkASSERT(fDoneCnt <= fNumImages); |
Robert Phillips | 11c6767 | 2020-04-23 15:10:03 -0400 | [diff] [blame] | 56 | } |
| 57 | |
| 58 | void wasAddedToImage() { fNumImages++; } |
| 59 | |
Kevin Lubick | eb98125 | 2023-06-13 07:51:26 -0400 | [diff] [blame] | 60 | const GrPromiseImageTexture* promiseImageTexture() const { |
Robert Phillips | 11c6767 | 2020-04-23 15:10:03 -0400 | [diff] [blame] | 61 | return fPromiseImageTexture.get(); |
| 62 | } |
| 63 | |
Kevin Lubick | eb98125 | 2023-06-13 07:51:26 -0400 | [diff] [blame] | 64 | static sk_sp<GrPromiseImageTexture> PromiseImageFulfillProc(void* textureContext) { |
Robert Phillips | 11c6767 | 2020-04-23 15:10:03 -0400 | [diff] [blame] | 65 | auto callbackContext = static_cast<PromiseImageCallbackContext*>(textureContext); |
| 66 | return callbackContext->fulfill(); |
| 67 | } |
| 68 | |
| 69 | static void PromiseImageReleaseProc(void* textureContext) { |
| 70 | auto callbackContext = static_cast<PromiseImageCallbackContext*>(textureContext); |
| 71 | callbackContext->release(); |
Robert Phillips | 11c6767 | 2020-04-23 15:10:03 -0400 | [diff] [blame] | 72 | callbackContext->unref(); |
| 73 | } |
| 74 | |
| 75 | private: |
Robert Phillips | d5f3c98 | 2020-07-07 13:18:47 -0400 | [diff] [blame] | 76 | GrDirectContext* fContext; |
Robert Phillips | 11c6767 | 2020-04-23 15:10:03 -0400 | [diff] [blame] | 77 | GrBackendFormat fBackendFormat; |
Kevin Lubick | eb98125 | 2023-06-13 07:51:26 -0400 | [diff] [blame] | 78 | sk_sp<GrPromiseImageTexture> fPromiseImageTexture; |
Robert Phillips | 11c6767 | 2020-04-23 15:10:03 -0400 | [diff] [blame] | 79 | int fNumImages = 0; |
| 80 | int fTotalFulfills = 0; |
Robert Phillips | 11c6767 | 2020-04-23 15:10:03 -0400 | [diff] [blame] | 81 | int fDoneCnt = 0; |
| 82 | |
John Stiles | 7571f9e | 2020-09-02 22:42:33 -0400 | [diff] [blame] | 83 | using INHERITED = SkRefCnt; |
Robert Phillips | 11c6767 | 2020-04-23 15:10:03 -0400 | [diff] [blame] | 84 | }; |
| 85 | |
Robert Phillips | 9660108 | 2018-05-29 16:13:26 -0400 | [diff] [blame] | 86 | // This class consolidates tracking & extraction of the original image data from an skp, |
| 87 | // the upload of said data to the GPU and the fulfillment of promise images. |
| 88 | // |
| 89 | // The way this works is: |
| 90 | // the original skp is converted to SkData and all its image info is extracted into this |
Robert Phillips | 0d8722c | 2021-03-29 13:29:40 -0400 | [diff] [blame] | 91 | // class and only indices into this class are left in the SkData |
| 92 | // the PromiseImageCallbackContexts are created for each image |
| 93 | // the SkData is then reinflated into an SkPicture with promise images replacing all the indices |
| 94 | // (all in recreateSKP) |
Robert Phillips | 9660108 | 2018-05-29 16:13:26 -0400 | [diff] [blame] | 95 | // |
Robert Phillips | 0d8722c | 2021-03-29 13:29:40 -0400 | [diff] [blame] | 96 | // Prior to replaying in threads, all the images are uploaded to the gpu |
| 97 | // (in uploadAllToGPU) |
Robert Phillips | 9660108 | 2018-05-29 16:13:26 -0400 | [diff] [blame] | 98 | // |
| 99 | // This class is then reset - dropping all of its refs on the PromiseImageCallbackContexts |
| 100 | // |
| 101 | // Each done callback unrefs its PromiseImageCallbackContext so, once all the promise images |
Robert Phillips | e8e2bb1 | 2018-09-27 14:26:47 -0400 | [diff] [blame] | 102 | // are done, the PromiseImageCallbackContext is freed and its GrBackendTexture removed |
Robert Phillips | 9660108 | 2018-05-29 16:13:26 -0400 | [diff] [blame] | 103 | // from VRAM |
| 104 | // |
| 105 | // Note: if DDLs are going to be replayed multiple times, the reset call can be delayed until |
| 106 | // all the replaying is complete. This will pin the GrBackendTextures in VRAM. |
| 107 | class DDLPromiseImageHelper { |
| 108 | public: |
Brian Salomon | 59c60b0 | 2020-09-01 15:01:15 -0400 | [diff] [blame] | 109 | DDLPromiseImageHelper(const SkYUVAPixmapInfo::SupportedDataTypes& supportedYUVADataTypes) |
| 110 | : fSupportedYUVADataTypes(supportedYUVADataTypes) {} |
Brian Salomon | 7d88f31 | 2019-02-28 10:03:03 -0500 | [diff] [blame] | 111 | ~DDLPromiseImageHelper() = default; |
Robert Phillips | 9660108 | 2018-05-29 16:13:26 -0400 | [diff] [blame] | 112 | |
Robert Phillips | 0d8722c | 2021-03-29 13:29:40 -0400 | [diff] [blame] | 113 | // Convert the input SkPicture into a new one which has promise images rather than live |
| 114 | // images. |
| 115 | sk_sp<SkPicture> recreateSKP(GrDirectContext*, SkPicture*); |
Robert Phillips | 923181b | 2020-02-14 12:36:37 -0500 | [diff] [blame] | 116 | |
Robert Phillips | d5f3c98 | 2020-07-07 13:18:47 -0400 | [diff] [blame] | 117 | void uploadAllToGPU(SkTaskGroup*, GrDirectContext*); |
| 118 | void deleteAllFromGPU(SkTaskGroup*, GrDirectContext*); |
Robert Phillips | 9660108 | 2018-05-29 16:13:26 -0400 | [diff] [blame] | 119 | |
Robert Phillips | 0d8722c | 2021-03-29 13:29:40 -0400 | [diff] [blame] | 120 | // Remove this class' refs on the promise images and the PromiseImageCallbackContexts |
| 121 | void reset() { |
Herb Derby | e308b1c | 2022-12-13 09:27:24 -0500 | [diff] [blame] | 122 | fImageInfo.clear(); |
| 123 | fPromiseImages.clear(); |
Robert Phillips | 0d8722c | 2021-03-29 13:29:40 -0400 | [diff] [blame] | 124 | } |
Robert Phillips | 9660108 | 2018-05-29 16:13:26 -0400 | [diff] [blame] | 125 | |
| 126 | private: |
Robert Phillips | 0d8722c | 2021-03-29 13:29:40 -0400 | [diff] [blame] | 127 | void createCallbackContexts(GrDirectContext*); |
| 128 | // reinflate a deflated SKP, replacing all the indices with promise images. |
| 129 | sk_sp<SkPicture> reinflateSKP(sk_sp<GrContextThreadSafeProxy>, SkData* deflatedSKP); |
| 130 | |
Robert Phillips | 9660108 | 2018-05-29 16:13:26 -0400 | [diff] [blame] | 131 | // This is the information extracted into this class from the parsing of the skp file. |
| 132 | // Once it has all been uploaded to the GPU and distributed to the promise images, it |
| 133 | // is all dropped via "reset". |
| 134 | class PromiseImageInfo { |
| 135 | public: |
Robert Phillips | f95e2f4 | 2020-04-17 16:20:55 -0400 | [diff] [blame] | 136 | PromiseImageInfo(int index, uint32_t originalUniqueID, const SkImageInfo& ii); |
| 137 | PromiseImageInfo(PromiseImageInfo&& other); |
| 138 | ~PromiseImageInfo(); |
Robert Phillips | e8e2bb1 | 2018-09-27 14:26:47 -0400 | [diff] [blame] | 139 | |
| 140 | int index() const { return fIndex; } |
| 141 | uint32_t originalUniqueID() const { return fOriginalUniqueID; } |
Brian Salomon | 5660e8b | 2020-08-25 12:40:32 -0400 | [diff] [blame] | 142 | bool isYUV() const { return fYUVAPixmaps.isValid(); } |
Robert Phillips | e8e2bb1 | 2018-09-27 14:26:47 -0400 | [diff] [blame] | 143 | |
Adlai Holler | 55aaefe | 2021-03-03 16:12:56 -0700 | [diff] [blame] | 144 | SkISize overallDimensions() const { return fImageInfo.dimensions(); } |
Robert Phillips | e8e2bb1 | 2018-09-27 14:26:47 -0400 | [diff] [blame] | 145 | SkColorType overallColorType() const { return fImageInfo.colorType(); } |
| 146 | SkAlphaType overallAlphaType() const { return fImageInfo.alphaType(); } |
| 147 | sk_sp<SkColorSpace> refOverallColorSpace() const { return fImageInfo.refColorSpace(); } |
| 148 | |
Brian Salomon | bd3792d | 2020-11-10 14:17:58 -0500 | [diff] [blame] | 149 | const SkYUVAInfo& yuvaInfo() const { return fYUVAPixmaps.yuvaInfo(); } |
| 150 | |
Robert Phillips | e8e2bb1 | 2018-09-27 14:26:47 -0400 | [diff] [blame] | 151 | const SkPixmap& yuvPixmap(int index) const { |
| 152 | SkASSERT(this->isYUV()); |
Brian Salomon | 5660e8b | 2020-08-25 12:40:32 -0400 | [diff] [blame] | 153 | return fYUVAPixmaps.planes()[index]; |
Robert Phillips | e8e2bb1 | 2018-09-27 14:26:47 -0400 | [diff] [blame] | 154 | } |
Robert Phillips | f95e2f4 | 2020-04-17 16:20:55 -0400 | [diff] [blame] | 155 | |
| 156 | const SkBitmap& baseLevel() const { |
Robert Phillips | e8e2bb1 | 2018-09-27 14:26:47 -0400 | [diff] [blame] | 157 | SkASSERT(!this->isYUV()); |
Robert Phillips | f95e2f4 | 2020-04-17 16:20:55 -0400 | [diff] [blame] | 158 | return fBaseLevel; |
Robert Phillips | e8e2bb1 | 2018-09-27 14:26:47 -0400 | [diff] [blame] | 159 | } |
Robert Phillips | f95e2f4 | 2020-04-17 16:20:55 -0400 | [diff] [blame] | 160 | // This returns an array of all the available mipLevels - suitable for passing into |
| 161 | // createBackendTexture. |
John Stiles | ec9b4aa | 2020-08-07 13:05:14 -0400 | [diff] [blame] | 162 | std::unique_ptr<SkPixmap[]> normalMipLevels() const; |
Robert Phillips | f95e2f4 | 2020-04-17 16:20:55 -0400 | [diff] [blame] | 163 | int numMipLevels() const; |
Robert Phillips | e8e2bb1 | 2018-09-27 14:26:47 -0400 | [diff] [blame] | 164 | |
| 165 | void setCallbackContext(int index, sk_sp<PromiseImageCallbackContext> callbackContext) { |
Brian Salomon | 0c0b5a6 | 2021-01-11 14:40:44 -0500 | [diff] [blame] | 166 | SkASSERT(index >= 0 && index < (this->isYUV() ? SkYUVAInfo::kMaxPlanes : 1)); |
Robert Phillips | e8e2bb1 | 2018-09-27 14:26:47 -0400 | [diff] [blame] | 167 | fCallbackContexts[index] = callbackContext; |
| 168 | } |
Brian Salomon | cdd8a0a | 2019-01-10 12:09:52 -0500 | [diff] [blame] | 169 | PromiseImageCallbackContext* callbackContext(int index) const { |
Brian Salomon | 0c0b5a6 | 2021-01-11 14:40:44 -0500 | [diff] [blame] | 170 | SkASSERT(index >= 0 && index < (this->isYUV() ? SkYUVAInfo::kMaxPlanes : 1)); |
Robert Phillips | e8e2bb1 | 2018-09-27 14:26:47 -0400 | [diff] [blame] | 171 | return fCallbackContexts[index].get(); |
| 172 | } |
| 173 | sk_sp<PromiseImageCallbackContext> refCallbackContext(int index) const { |
Brian Salomon | 0c0b5a6 | 2021-01-11 14:40:44 -0500 | [diff] [blame] | 174 | SkASSERT(index >= 0 && index < (this->isYUV() ? SkYUVAInfo::kMaxPlanes : 1)); |
Robert Phillips | e8e2bb1 | 2018-09-27 14:26:47 -0400 | [diff] [blame] | 175 | return fCallbackContexts[index]; |
| 176 | } |
| 177 | |
Kevin Lubick | df73d16 | 2023-09-11 11:56:53 -0400 | [diff] [blame] | 178 | skgpu::Mipmapped mipmapped(int index) const { |
Robert Phillips | f95e2f4 | 2020-04-17 16:20:55 -0400 | [diff] [blame] | 179 | if (this->isYUV()) { |
Kevin Lubick | df73d16 | 2023-09-11 11:56:53 -0400 | [diff] [blame] | 180 | return skgpu::Mipmapped::kNo; |
Robert Phillips | f95e2f4 | 2020-04-17 16:20:55 -0400 | [diff] [blame] | 181 | } |
Kevin Lubick | df73d16 | 2023-09-11 11:56:53 -0400 | [diff] [blame] | 182 | return fMipLevels ? skgpu::Mipmapped::kYes : skgpu::Mipmapped::kNo; |
Robert Phillips | f95e2f4 | 2020-04-17 16:20:55 -0400 | [diff] [blame] | 183 | } |
Robert Phillips | 923181b | 2020-02-14 12:36:37 -0500 | [diff] [blame] | 184 | const GrBackendFormat& backendFormat(int index) const { |
Brian Salomon | 0c0b5a6 | 2021-01-11 14:40:44 -0500 | [diff] [blame] | 185 | SkASSERT(index >= 0 && index < (this->isYUV() ? SkYUVAInfo::kMaxPlanes : 1)); |
Robert Phillips | 923181b | 2020-02-14 12:36:37 -0500 | [diff] [blame] | 186 | return fCallbackContexts[index]->backendFormat(); |
| 187 | } |
Kevin Lubick | eb98125 | 2023-06-13 07:51:26 -0400 | [diff] [blame] | 188 | const GrPromiseImageTexture* promiseTexture(int index) const { |
Brian Salomon | 0c0b5a6 | 2021-01-11 14:40:44 -0500 | [diff] [blame] | 189 | SkASSERT(index >= 0 && index < (this->isYUV() ? SkYUVAInfo::kMaxPlanes : 1)); |
Brian Salomon | 3f4cd77 | 2019-01-11 16:03:19 -0500 | [diff] [blame] | 190 | return fCallbackContexts[index]->promiseImageTexture(); |
Robert Phillips | e8e2bb1 | 2018-09-27 14:26:47 -0400 | [diff] [blame] | 191 | } |
| 192 | |
Mike Reed | 13711eb | 2020-07-14 17:16:32 -0400 | [diff] [blame] | 193 | void setMipLevels(const SkBitmap& baseLevel, std::unique_ptr<SkMipmap> mipLevels); |
Robert Phillips | e8e2bb1 | 2018-09-27 14:26:47 -0400 | [diff] [blame] | 194 | |
Brian Salomon | efb5f07 | 2020-07-28 21:06:43 -0400 | [diff] [blame] | 195 | /** Takes ownership of the plane data. */ |
Brian Salomon | be0e42c | 2020-08-27 11:00:04 -0400 | [diff] [blame] | 196 | void setYUVPlanes(SkYUVAPixmaps yuvaPixmaps) { fYUVAPixmaps = std::move(yuvaPixmaps); } |
Brian Salomon | 5660e8b | 2020-08-25 12:40:32 -0400 | [diff] [blame] | 197 | |
Robert Phillips | e8e2bb1 | 2018-09-27 14:26:47 -0400 | [diff] [blame] | 198 | private: |
| 199 | const int fIndex; // index in the 'fImageInfo' array |
| 200 | const uint32_t fOriginalUniqueID; // original ID for deduping |
| 201 | |
| 202 | const SkImageInfo fImageInfo; // info for the overarching image |
| 203 | |
Robert Phillips | f95e2f4 | 2020-04-17 16:20:55 -0400 | [diff] [blame] | 204 | // CPU-side cache of a normal SkImage's mipmap levels |
| 205 | SkBitmap fBaseLevel; |
Mike Reed | 13711eb | 2020-07-14 17:16:32 -0400 | [diff] [blame] | 206 | std::unique_ptr<SkMipmap> fMipLevels; |
Robert Phillips | e8e2bb1 | 2018-09-27 14:26:47 -0400 | [diff] [blame] | 207 | |
| 208 | // CPU-side cache of a YUV SkImage's contents |
Brian Salomon | be0e42c | 2020-08-27 11:00:04 -0400 | [diff] [blame] | 209 | SkYUVAPixmaps fYUVAPixmaps; |
Robert Phillips | e8e2bb1 | 2018-09-27 14:26:47 -0400 | [diff] [blame] | 210 | |
Jim Van Verth | e24b587 | 2018-10-29 16:26:02 -0400 | [diff] [blame] | 211 | // Up to SkYUVASizeInfo::kMaxCount for a YUVA image. Only one for a normal image. |
Brian Salomon | 0c0b5a6 | 2021-01-11 14:40:44 -0500 | [diff] [blame] | 212 | sk_sp<PromiseImageCallbackContext> fCallbackContexts[SkYUVAInfo::kMaxPlanes]; |
Robert Phillips | 9660108 | 2018-05-29 16:13:26 -0400 | [diff] [blame] | 213 | }; |
| 214 | |
Adlai Holler | 55aaefe | 2021-03-03 16:12:56 -0700 | [diff] [blame] | 215 | struct DeserialImageProcContext { |
| 216 | sk_sp<GrContextThreadSafeProxy> fThreadSafeProxy; |
Robert Phillips | 0d8722c | 2021-03-29 13:29:40 -0400 | [diff] [blame] | 217 | DDLPromiseImageHelper* fHelper; |
Robert Phillips | 9660108 | 2018-05-29 16:13:26 -0400 | [diff] [blame] | 218 | }; |
| 219 | |
Robert Phillips | d5f3c98 | 2020-07-07 13:18:47 -0400 | [diff] [blame] | 220 | static void CreateBETexturesForPromiseImage(GrDirectContext*, PromiseImageInfo*); |
Brian Salomon | bd3792d | 2020-11-10 14:17:58 -0500 | [diff] [blame] | 221 | static void DeleteBETexturesForPromiseImage(PromiseImageInfo*); |
Robert Phillips | 923181b | 2020-02-14 12:36:37 -0500 | [diff] [blame] | 222 | |
Robert Phillips | 923181b | 2020-02-14 12:36:37 -0500 | [diff] [blame] | 223 | static sk_sp<SkImage> CreatePromiseImages(const void* rawData, size_t length, void* ctxIn); |
Robert Phillips | 9660108 | 2018-05-29 16:13:26 -0400 | [diff] [blame] | 224 | |
Herb Derby | ffacce5 | 2022-11-09 10:51:34 -0500 | [diff] [blame] | 225 | bool isValidID(int id) const { return id >= 0 && id < fImageInfo.size(); } |
Robert Phillips | 9660108 | 2018-05-29 16:13:26 -0400 | [diff] [blame] | 226 | const PromiseImageInfo& getInfo(int id) const { return fImageInfo[id]; } |
Robert Phillips | d5f3c98 | 2020-07-07 13:18:47 -0400 | [diff] [blame] | 227 | void uploadImage(GrDirectContext*, PromiseImageInfo*); |
Robert Phillips | 9660108 | 2018-05-29 16:13:26 -0400 | [diff] [blame] | 228 | |
| 229 | // returns -1 if not found |
| 230 | int findImage(SkImage* image) const; |
| 231 | |
| 232 | // returns -1 on failure |
| 233 | int addImage(SkImage* image); |
| 234 | |
| 235 | // returns -1 on failure |
| 236 | int findOrDefineImage(SkImage* image); |
| 237 | |
Herb Derby | d7a00839 | 2023-03-02 15:36:17 -0500 | [diff] [blame] | 238 | SkYUVAPixmapInfo::SupportedDataTypes fSupportedYUVADataTypes; |
| 239 | skia_private::TArray<PromiseImageInfo> fImageInfo; |
Robert Phillips | 0d8722c | 2021-03-29 13:29:40 -0400 | [diff] [blame] | 240 | |
| 241 | // TODO: review the use of 'fPromiseImages' - it doesn't seem useful/necessary |
Herb Derby | d7a00839 | 2023-03-02 15:36:17 -0500 | [diff] [blame] | 242 | skia_private::TArray<sk_sp<SkImage>> fPromiseImages; // All the promise images in the |
Robert Phillips | 0d8722c | 2021-03-29 13:29:40 -0400 | [diff] [blame] | 243 | // reconstituted picture |
Robert Phillips | 9660108 | 2018-05-29 16:13:26 -0400 | [diff] [blame] | 244 | }; |
| 245 | |
| 246 | #endif |