blob: d5331af9e7d56dd92c60abcc4b6ccf635e6ca97a [file] [log] [blame]
Jim Van Verth8026ccc2018-10-04 13:10:39 -04001/*
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 Kleinc0bd9f92019-04-23 12:05:21 -050011#include "include/core/SkDeferredDisplayListRecorder.h"
Mike Kleinc0bd9f92019-04-23 12:05:21 -050012#include "include/gpu/GrBackendSurface.h"
Mike Kleinc0bd9f92019-04-23 12:05:21 -050013#include "include/private/GrTypesPriv.h"
Brian Salomon0c0b5a62021-01-11 14:40:44 -050014#include "src/core/SkYUVAInfoLocation.h"
Mike Kleinc0bd9f92019-04-23 12:05:21 -050015#include "src/image/SkImage_Base.h"
Jim Van Verth8026ccc2018-10-04 13:10:39 -040016
Brian Osmane9560492019-02-05 17:00:03 -050017class GrColorSpaceXform;
Robert Phillips1a578572020-07-13 13:17:09 -040018class GrDirectContext;
Adlai Holler302e8fb2020-09-14 11:58:06 -040019class GrImageContext;
Jim Van Verth8026ccc2018-10-04 13:10:39 -040020class SkColorSpace;
21
22class SkImage_GpuBase : public SkImage_Base {
23public:
Adlai Holler302e8fb2020-09-14 11:58:06 -040024 GrImageContext* context() const final { return fContext.get(); }
Jim Van Verth8026ccc2018-10-04 13:10:39 -040025
Adlai Hollerbcfc5542020-08-27 12:44:07 -040026 bool getROPixels(GrDirectContext*, SkBitmap*, CachingHint) const final;
Adlai Holler872a32c2020-07-10 14:33:22 -040027 sk_sp<SkImage> onMakeSubset(const SkIRect& subset, GrDirectContext*) const final;
Jim Van Verth8026ccc2018-10-04 13:10:39 -040028
Adlai Hollerbcfc5542020-08-27 12:44:07 -040029 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 Verth8bbce0e2018-10-08 14:34:52 -040036
Robert Phillips4a3ebc22020-07-10 11:27:43 -040037 bool onIsValid(GrRecordingContext*) const final;
Jim Van Verth8026ccc2018-10-04 13:10:39 -040038
Robert Phillips62221e72019-07-24 15:07:38 -040039 static bool ValidateBackendTexture(const GrCaps*, const GrBackendTexture& tex,
40 GrColorType grCT, SkColorType ct, SkAlphaType at,
Jim Van Verth8026ccc2018-10-04 13:10:39 -040041 sk_sp<SkColorSpace> cs);
Robert Phillipsead321b2019-12-19 10:16:32 -050042 static bool ValidateCompressedBackendTexture(const GrCaps*, const GrBackendTexture& tex,
43 SkAlphaType);
Jim Van Verth8bbce0e2018-10-08 14:34:52 -040044
Adlai Hollerc44e21f2021-02-22 14:08:07 -050045 // Helper for making a lazy proxy for a promise image.
46 // PromiseImageTextureFulfillProc must not be null.
Adlai Hollerdced31f2021-02-19 12:33:46 -050047 static sk_sp<GrTextureProxy> MakePromiseImageLazyProxy(GrContextThreadSafeProxy*,
Brian Salomonf1432742020-11-09 15:40:27 -050048 SkISize dimensions,
49 GrBackendFormat,
50 GrMipmapped,
51 PromiseImageTextureFulfillProc,
52 sk_sp<GrRefCntedCallback> releaseHelper);
Brian Salomonbe5a0932018-12-10 10:03:26 -050053
Adlai Hollerc44e21f2021-02-22 14:08:07 -050054protected:
Brian Salomon9a56eb72021-04-20 16:52:11 -040055 SkImage_GpuBase(sk_sp<GrImageContext>, SkImageInfo, uint32_t uniqueID);
Adlai Hollerc44e21f2021-02-22 14:08:07 -050056
Adlai Holler302e8fb2020-09-14 11:58:06 -040057 sk_sp<GrImageContext> fContext;
Jim Van Verth8026ccc2018-10-04 13:10:39 -040058
59private:
John Stiles7571f9e2020-09-02 22:42:33 -040060 using INHERITED = SkImage_Base;
Jim Van Verth8026ccc2018-10-04 13:10:39 -040061};
62
Jim Van Verth8026ccc2018-10-04 13:10:39 -040063#endif