• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright 2021 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 SkStuff_DEFINED
9 #define SkStuff_DEFINED
10 
11 #include "include/core/SkImageInfo.h"
12 #include "include/core/SkRefCnt.h"
13 
14 class SkSurface;
15 class SkSurfaceProps;
16 
17 namespace skgpu {
18     class BackendTexture;
19     class Recorder;
20 }
21 
22 // TODO: Should be in SkSurface.h
23 sk_sp<SkSurface> MakeGraphite(skgpu::Recorder*, const SkImageInfo&);
24 
25 /**
26  * Wraps a GPU-backed texture into SkSurface. Depending on the backend gpu API, the caller may be
27  * required to ensure the texture is valid for the lifetime of returned SkSurface. The required
28  * lifetimes for the specific apis are:
29  *     Metal: Skia will call retain on the underlying MTLTexture so the caller can drop it once this
30  *            call returns.
31  *
32  * SkSurface is returned if all parameters are valid. BackendTexture is valid if its format agrees
33  * with colorSpace and context; for instance, if backendTexture has an sRGB configuration, then
34  * context must support sRGB, and colorSpace must be present. Further, backendTexture width and
35  * height must not exceed context capabilities, and the context must be able to support back-end
36  * textures.
37  *
38  * If SK_ENABLE_GRAPHITE is not defined, this has no effect and returns nullptr.
39  */
40 sk_sp<SkSurface> MakeGraphiteFromBackendTexture(skgpu::Recorder*,
41                                                 const skgpu::BackendTexture&,
42                                                 SkColorType colorType,
43                                                 sk_sp<SkColorSpace> colorSpace,
44                                                 const SkSurfaceProps* props);
45 
46 #endif // SkStuff_DEFINED
47