• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright 2015 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_Gpu_DEFINED
9 #define SkImage_Gpu_DEFINED
10 
11 #include "include/gpu/GrContext.h"
12 #include "src/core/SkImagePriv.h"
13 #include "src/gpu/GrGpuResourcePriv.h"
14 #include "src/gpu/GrSurfaceProxyPriv.h"
15 #include "src/gpu/SkGr.h"
16 #include "src/image/SkImage_GpuBase.h"
17 
18 class GrTexture;
19 
20 class SkBitmap;
21 struct SkYUVAIndex;
22 
23 class SkImage_Gpu : public SkImage_GpuBase {
24 public:
25     SkImage_Gpu(sk_sp<GrContext>, uint32_t uniqueID, SkAlphaType, sk_sp<GrTextureProxy>,
26                 sk_sp<SkColorSpace>);
27     ~SkImage_Gpu() override;
28 
29     GrSemaphoresSubmitted onFlush(GrContext*, const GrFlushInfo&) override;
30 
peekProxy()31     GrTextureProxy* peekProxy() const override {
32         return fProxy.get();
33     }
asTextureProxyRef(GrRecordingContext *)34     sk_sp<GrTextureProxy> asTextureProxyRef(GrRecordingContext*) const override {
35         return fProxy;
36     }
37 
onIsTextureBacked()38     bool onIsTextureBacked() const override { return SkToBool(fProxy.get()); }
39 
40     sk_sp<SkImage> onMakeColorTypeAndColorSpace(GrRecordingContext*,
41                                                 SkColorType, sk_sp<SkColorSpace>) const final;
42 
43     sk_sp<SkImage> onReinterpretColorSpace(sk_sp<SkColorSpace>) const final;
44 
45     /**
46      * This is the implementation of SkDeferredDisplayListRecorder::makePromiseImage.
47      */
48     static sk_sp<SkImage> MakePromiseTexture(GrContext* context,
49                                              const GrBackendFormat& backendFormat,
50                                              int width,
51                                              int height,
52                                              GrMipMapped mipMapped,
53                                              GrSurfaceOrigin origin,
54                                              SkColorType colorType,
55                                              SkAlphaType alphaType,
56                                              sk_sp<SkColorSpace> colorSpace,
57                                              PromiseImageTextureFulfillProc textureFulfillProc,
58                                              PromiseImageTextureReleaseProc textureReleaseProc,
59                                              PromiseImageTextureDoneProc textureDoneProc,
60                                              PromiseImageTextureContext textureContext,
61                                              PromiseImageApiVersion);
62 
63     static sk_sp<SkImage> ConvertYUVATexturesToRGB(GrContext*, SkYUVColorSpace yuvColorSpace,
64                                                    const GrBackendTexture yuvaTextures[],
65                                                    const SkYUVAIndex yuvaIndices[4],
66                                                    SkISize imageSize, GrSurfaceOrigin imageOrigin,
67                                                    GrRenderTargetContext*);
68 
69 private:
70     sk_sp<GrTextureProxy> fProxy;
71 
72     typedef SkImage_GpuBase INHERITED;
73 };
74 
75 #endif
76