xref: /aosp_15_r20/external/skia/src/gpu/ganesh/image/SkSpecialImage_Ganesh.h (revision c8dee2aa9b3f27cf6c858bd81872bdeb2c07ed17)
1 /*
2  * Copyright 2019 Google LLC
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 SkSpecialImageGanesh_DEFINED
9 #define SkSpecialImageGanesh_DEFINED
10 
11 #include "include/core/SkRefCnt.h"
12 #include "src/gpu/ganesh/GrColorInfo.h"
13 #include "src/gpu/ganesh/GrSurfaceProxyView.h"
14 
15 #include <cstdint>
16 
17 class GrRecordingContext;
18 class SkImage;
19 class SkSpecialImage;
20 class SkSurfaceProps;
21 struct SkIRect;
22 
23 namespace SkSpecialImages {
24 
25 sk_sp<SkSpecialImage> MakeFromTextureImage(GrRecordingContext* rContext,
26                                            const SkIRect& subset,
27                                            sk_sp<SkImage> image,
28                                            const SkSurfaceProps& props);
29 
30 sk_sp<SkSpecialImage> MakeDeferredFromGpu(GrRecordingContext*,
31                                           const SkIRect& subset,
32                                           uint32_t uniqueID,
33                                           GrSurfaceProxyView,
34                                           const GrColorInfo&,
35                                           const SkSurfaceProps&);
36 
37 /**
38  * Regardless of how the underlying backing data is stored, returns the contents as a
39  * GrSurfaceProxyView. The returned view's proxy represents the entire backing image, so texture
40  * coordinates must be mapped from the content rect (e.g. relative to 'subset()') to the proxy's
41  * space (offset by subset().topLeft()).
42  */
43 GrSurfaceProxyView AsView(GrRecordingContext*, const SkSpecialImage*);
AsView(GrRecordingContext * rContext,const sk_sp<const SkSpecialImage> & img)44 inline GrSurfaceProxyView AsView(GrRecordingContext* rContext,
45                                  const sk_sp<const SkSpecialImage>& img) {
46     return AsView(rContext, img.get());
47 }
48 
49 }  // namespace SkSpecialImages
50 
51 #endif
52