Jim Van Verth | 8026ccc | 2018-10-04 13:10:39 -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 SkImage_GpuBase_DEFINED |
| 9 | #define SkImage_GpuBase_DEFINED |
| 10 | |
Mike Klein | c0bd9f9 | 2019-04-23 12:05:21 -0500 | [diff] [blame] | 11 | #include "include/core/SkDeferredDisplayListRecorder.h" |
Mike Klein | c0bd9f9 | 2019-04-23 12:05:21 -0500 | [diff] [blame] | 12 | #include "include/gpu/GrBackendSurface.h" |
Mike Klein | c0bd9f9 | 2019-04-23 12:05:21 -0500 | [diff] [blame] | 13 | #include "include/private/GrTypesPriv.h" |
Brian Salomon | 0c0b5a6 | 2021-01-11 14:40:44 -0500 | [diff] [blame] | 14 | #include "src/core/SkYUVAInfoLocation.h" |
Mike Klein | c0bd9f9 | 2019-04-23 12:05:21 -0500 | [diff] [blame] | 15 | #include "src/image/SkImage_Base.h" |
Jim Van Verth | 8026ccc | 2018-10-04 13:10:39 -0400 | [diff] [blame] | 16 | |
Brian Osman | e956049 | 2019-02-05 17:00:03 -0500 | [diff] [blame] | 17 | class GrColorSpaceXform; |
Robert Phillips | 1a57857 | 2020-07-13 13:17:09 -0400 | [diff] [blame] | 18 | class GrDirectContext; |
Adlai Holler | 302e8fb | 2020-09-14 11:58:06 -0400 | [diff] [blame] | 19 | class GrImageContext; |
Jim Van Verth | 8026ccc | 2018-10-04 13:10:39 -0400 | [diff] [blame] | 20 | class SkColorSpace; |
| 21 | |
| 22 | class SkImage_GpuBase : public SkImage_Base { |
| 23 | public: |
Adlai Holler | 302e8fb | 2020-09-14 11:58:06 -0400 | [diff] [blame] | 24 | GrImageContext* context() const final { return fContext.get(); } |
Jim Van Verth | 8026ccc | 2018-10-04 13:10:39 -0400 | [diff] [blame] | 25 | |
Adlai Holler | bcfc554 | 2020-08-27 12:44:07 -0400 | [diff] [blame] | 26 | bool getROPixels(GrDirectContext*, SkBitmap*, CachingHint) const final; |
Adlai Holler | 872a32c | 2020-07-10 14:33:22 -0400 | [diff] [blame] | 27 | sk_sp<SkImage> onMakeSubset(const SkIRect& subset, GrDirectContext*) const final; |
Jim Van Verth | 8026ccc | 2018-10-04 13:10:39 -0400 | [diff] [blame] | 28 | |
Adlai Holler | bcfc554 | 2020-08-27 12:44:07 -0400 | [diff] [blame] | 29 | bool onReadPixels(GrDirectContext *dContext, |
| 30 | const SkImageInfo& dstInfo, |
| 31 | void* dstPixels, |
| 32 | size_t dstRB, |
| 33 | int srcX, |
| 34 | int srcY, |
| 35 | CachingHint) const override; |
Jim Van Verth | 8bbce0e | 2018-10-08 14:34:52 -0400 | [diff] [blame] | 36 | |
Robert Phillips | 4a3ebc2 | 2020-07-10 11:27:43 -0400 | [diff] [blame] | 37 | bool onIsValid(GrRecordingContext*) const final; |
Jim Van Verth | 8026ccc | 2018-10-04 13:10:39 -0400 | [diff] [blame] | 38 | |
Robert Phillips | 62221e7 | 2019-07-24 15:07:38 -0400 | [diff] [blame] | 39 | static bool ValidateBackendTexture(const GrCaps*, const GrBackendTexture& tex, |
| 40 | GrColorType grCT, SkColorType ct, SkAlphaType at, |
Jim Van Verth | 8026ccc | 2018-10-04 13:10:39 -0400 | [diff] [blame] | 41 | sk_sp<SkColorSpace> cs); |
Robert Phillips | ead321b | 2019-12-19 10:16:32 -0500 | [diff] [blame] | 42 | static bool ValidateCompressedBackendTexture(const GrCaps*, const GrBackendTexture& tex, |
| 43 | SkAlphaType); |
Jim Van Verth | 8bbce0e | 2018-10-08 14:34:52 -0400 | [diff] [blame] | 44 | |
Adlai Holler | c44e21f | 2021-02-22 14:08:07 -0500 | [diff] [blame] | 45 | // Helper for making a lazy proxy for a promise image. |
| 46 | // PromiseImageTextureFulfillProc must not be null. |
Adlai Holler | dced31f | 2021-02-19 12:33:46 -0500 | [diff] [blame] | 47 | static sk_sp<GrTextureProxy> MakePromiseImageLazyProxy(GrContextThreadSafeProxy*, |
Brian Salomon | f143274 | 2020-11-09 15:40:27 -0500 | [diff] [blame] | 48 | SkISize dimensions, |
| 49 | GrBackendFormat, |
| 50 | GrMipmapped, |
| 51 | PromiseImageTextureFulfillProc, |
| 52 | sk_sp<GrRefCntedCallback> releaseHelper); |
Brian Salomon | be5a093 | 2018-12-10 10:03:26 -0500 | [diff] [blame] | 53 | |
Adlai Holler | c44e21f | 2021-02-22 14:08:07 -0500 | [diff] [blame] | 54 | protected: |
Brian Salomon | 9a56eb7 | 2021-04-20 16:52:11 -0400 | [diff] [blame] | 55 | SkImage_GpuBase(sk_sp<GrImageContext>, SkImageInfo, uint32_t uniqueID); |
Adlai Holler | c44e21f | 2021-02-22 14:08:07 -0500 | [diff] [blame] | 56 | |
Adlai Holler | 302e8fb | 2020-09-14 11:58:06 -0400 | [diff] [blame] | 57 | sk_sp<GrImageContext> fContext; |
Jim Van Verth | 8026ccc | 2018-10-04 13:10:39 -0400 | [diff] [blame] | 58 | |
| 59 | private: |
John Stiles | 7571f9e | 2020-09-02 22:42:33 -0400 | [diff] [blame] | 60 | using INHERITED = SkImage_Base; |
Jim Van Verth | 8026ccc | 2018-10-04 13:10:39 -0400 | [diff] [blame] | 61 | }; |
| 62 | |
Jim Van Verth | 8026ccc | 2018-10-04 13:10:39 -0400 | [diff] [blame] | 63 | #endif |