2021-09-21 13:57:43 +00:00
|
|
|
/*
|
|
|
|
* Copyright 2021 Google LLC
|
|
|
|
*
|
|
|
|
* Use of this source code is governed by a BSD-style license that can be
|
|
|
|
* found in the LICENSE file.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef SkStuff_DEFINED
|
|
|
|
#define SkStuff_DEFINED
|
|
|
|
|
2021-12-15 19:43:17 +00:00
|
|
|
#include "include/core/SkImageInfo.h"
|
2021-09-21 13:57:43 +00:00
|
|
|
#include "include/core/SkRefCnt.h"
|
|
|
|
|
2022-03-31 19:07:44 +00:00
|
|
|
class SkColorSpace;
|
2021-09-21 13:57:43 +00:00
|
|
|
class SkSurface;
|
2021-12-15 19:43:17 +00:00
|
|
|
class SkSurfaceProps;
|
2021-09-21 13:57:43 +00:00
|
|
|
|
2022-04-07 20:08:04 +00:00
|
|
|
namespace skgpu::graphite {
|
2021-12-15 19:43:17 +00:00
|
|
|
class BackendTexture;
|
2021-10-14 20:30:49 +00:00
|
|
|
class Recorder;
|
2021-09-30 15:41:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// TODO: Should be in SkSurface.h
|
2022-04-07 20:08:04 +00:00
|
|
|
sk_sp<SkSurface> MakeGraphite(skgpu::graphite::Recorder*, const SkImageInfo&);
|
2021-09-21 13:57:43 +00:00
|
|
|
|
2021-12-15 19:43:17 +00:00
|
|
|
/**
|
|
|
|
* Wraps a GPU-backed texture into SkSurface. Depending on the backend gpu API, the caller may be
|
|
|
|
* required to ensure the texture is valid for the lifetime of returned SkSurface. The required
|
|
|
|
* lifetimes for the specific apis are:
|
|
|
|
* Metal: Skia will call retain on the underlying MTLTexture so the caller can drop it once this
|
|
|
|
* call returns.
|
|
|
|
*
|
|
|
|
* SkSurface is returned if all parameters are valid. BackendTexture is valid if its format agrees
|
|
|
|
* with colorSpace and context; for instance, if backendTexture has an sRGB configuration, then
|
|
|
|
* context must support sRGB, and colorSpace must be present. Further, backendTexture width and
|
|
|
|
* height must not exceed context capabilities, and the context must be able to support back-end
|
|
|
|
* textures.
|
|
|
|
*
|
|
|
|
* If SK_ENABLE_GRAPHITE is not defined, this has no effect and returns nullptr.
|
|
|
|
*/
|
2022-04-07 20:08:04 +00:00
|
|
|
sk_sp<SkSurface> MakeGraphiteFromBackendTexture(skgpu::graphite::Recorder*,
|
|
|
|
const skgpu::graphite::BackendTexture&,
|
2021-12-15 19:43:17 +00:00
|
|
|
SkColorType colorType,
|
|
|
|
sk_sp<SkColorSpace> colorSpace,
|
|
|
|
const SkSurfaceProps* props);
|
|
|
|
|
2021-09-21 13:57:43 +00:00
|
|
|
#endif // SkStuff_DEFINED
|