• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
11 #include "include/core/SkDeferredDisplayListRecorder.h"
12 #include "include/gpu/GrBackendSurface.h"
13 #include "include/private/GrTypesPriv.h"
14 #include "src/core/SkYUVAInfoLocation.h"
15 #include "src/image/SkImage_Base.h"
16 
17 class GrColorSpaceXform;
18 class GrDirectContext;
19 class GrImageContext;
20 class SkColorSpace;
21 
22 class SkImage_GpuBase : public SkImage_Base {
23 public:
context()24     GrImageContext* context() const final { return fContext.get(); }
25 
26     bool getROPixels(GrDirectContext*, SkBitmap*, CachingHint) const final;
27     sk_sp<SkImage> onMakeSubset(const SkIRect& subset, GrDirectContext*) const final;
28 
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;
36 
37     bool onIsValid(GrRecordingContext*) const final;
38 
39     static bool ValidateBackendTexture(const GrCaps*, const GrBackendTexture& tex,
40                                        GrColorType grCT, SkColorType ct, SkAlphaType at,
41                                        sk_sp<SkColorSpace> cs);
42     static bool ValidateCompressedBackendTexture(const GrCaps*, const GrBackendTexture& tex,
43                                                  SkAlphaType);
44 
45     // Helper for making a lazy proxy for a promise image.
46     // PromiseImageTextureFulfillProc must not be null.
47     static sk_sp<GrTextureProxy> MakePromiseImageLazyProxy(GrContextThreadSafeProxy*,
48                                                            SkISize dimensions,
49                                                            GrBackendFormat,
50                                                            GrMipmapped,
51                                                            PromiseImageTextureFulfillProc,
52                                                            sk_sp<GrRefCntedCallback> releaseHelper);
53 
54 protected:
55     SkImage_GpuBase(sk_sp<GrImageContext>, SkImageInfo, uint32_t uniqueID);
56 
57     sk_sp<GrImageContext> fContext;
58 
59 private:
60     using INHERITED = SkImage_Base;
61 };
62 
63 #endif
64