skia2/include/gpu/graphite/SkStuff.h
Jim Van Verth 42f710f3fa Reland "[graphite] Move Graphite into Skia base directories."
This is a reland of commit ae5e846047

Original change's description:
> [graphite] Move Graphite into Skia base directories.
>
> Change-Id: Ie0fb74f3766a8b33387c145bd1151344c25808cb
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/528708
> Reviewed-by: Kevin Lubick <kjlubick@google.com>
> Reviewed-by: Greg Daniel <egdaniel@google.com>
> Commit-Queue: Jim Van Verth <jvanverth@google.com>

Change-Id: Ia575fd49206ad0b665a6a9153317e738bb321446
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/529059
Reviewed-by: Kevin Lubick <kjlubick@google.com>
Reviewed-by: Greg Daniel <egdaniel@google.com>
Commit-Queue: Jim Van Verth <jvanverth@google.com>
2022-04-11 18:37:20 +00:00

48 lines
1.8 KiB
C++

/*
* 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
#include "include/core/SkImageInfo.h"
#include "include/core/SkRefCnt.h"
class SkColorSpace;
class SkSurface;
class SkSurfaceProps;
namespace skgpu::graphite {
class BackendTexture;
class Recorder;
}
// TODO: Should be in SkSurface.h
sk_sp<SkSurface> MakeGraphite(skgpu::graphite::Recorder*, const SkImageInfo&);
/**
* 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.
*/
sk_sp<SkSurface> MakeGraphiteFromBackendTexture(skgpu::graphite::Recorder*,
const skgpu::graphite::BackendTexture&,
SkColorType colorType,
sk_sp<SkColorSpace> colorSpace,
const SkSurfaceProps* props);
#endif // SkStuff_DEFINED