a750dfcce2
Bug: skia:12466 Change-Id: I6b15d099f3853b392f3763cd1100d89ff4e4fd1d Reviewed-on: https://skia-review.googlesource.com/c/skia/+/459122 Reviewed-by: Jim Van Verth <jvanverth@google.com> Reviewed-by: Greg Daniel <egdaniel@google.com> Commit-Queue: Robert Phillips <robertphillips@google.com>
83 lines
1.8 KiB
C++
83 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 skgpu_Context_DEFINED
|
|
#define skgpu_Context_DEFINED
|
|
|
|
#include <vector>
|
|
#include "include/core/SkBlendMode.h"
|
|
#include "include/core/SkRefCnt.h"
|
|
#include "include/core/SkShader.h"
|
|
#include "include/core/SkTileMode.h"
|
|
|
|
#include "experimental/graphite/include/GraphiteTypes.h"
|
|
|
|
namespace skgpu {
|
|
|
|
class ContextPriv;
|
|
class Gpu;
|
|
class Recorder;
|
|
class Recording;
|
|
namespace mtl { struct BackendContext; }
|
|
|
|
struct ShaderCombo {
|
|
enum class ShaderType {
|
|
kNone,
|
|
kLinearGradient,
|
|
kRadialGradient,
|
|
kSweepGradient,
|
|
kConicalGradient
|
|
};
|
|
|
|
ShaderCombo() {}
|
|
ShaderCombo(std::vector<ShaderType> types,
|
|
std::vector<SkTileMode> tileModes)
|
|
: fTypes(std::move(types))
|
|
, fTileModes(std::move(tileModes)) {
|
|
}
|
|
std::vector<ShaderType> fTypes;
|
|
std::vector<SkTileMode> fTileModes;
|
|
};
|
|
|
|
struct PaintCombo {
|
|
std::vector<ShaderCombo> fShaders;
|
|
std::vector<SkBlendMode> fBlendModes;
|
|
};
|
|
|
|
class Context final : public SkRefCnt {
|
|
public:
|
|
~Context() override;
|
|
|
|
#ifdef SK_METAL
|
|
static sk_sp<Context> MakeMetal(const skgpu::mtl::BackendContext&);
|
|
#endif
|
|
|
|
sk_sp<Recorder> createRecorder();
|
|
|
|
void insertRecording(std::unique_ptr<Recording>);
|
|
void submit(SyncToCpu = SyncToCpu::kNo);
|
|
|
|
void preCompile(const PaintCombo&);
|
|
|
|
// Provides access to functions that aren't part of the public API.
|
|
ContextPriv priv();
|
|
const ContextPriv priv() const; // NOLINT(readability-const-return-type)
|
|
|
|
protected:
|
|
Context(sk_sp<Gpu>);
|
|
|
|
private:
|
|
friend class ContextPriv;
|
|
|
|
std::vector<std::unique_ptr<Recording>> fRecordings;
|
|
sk_sp<Gpu> fGpu;
|
|
};
|
|
|
|
} // namespace skgpu
|
|
|
|
#endif // skgpu_Context_DEFINED
|