/* * 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 #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 types, std::vector tileModes) : fTypes(std::move(types)) , fTileModes(std::move(tileModes)) { } std::vector fTypes; std::vector fTileModes; }; struct PaintCombo { std::vector fShaders; std::vector fBlendModes; }; class Context final : public SkRefCnt { public: ~Context() override; #ifdef SK_METAL static sk_sp MakeMetal(const skgpu::mtl::BackendContext&); #endif sk_sp createRecorder(); void insertRecording(std::unique_ptr); 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); private: friend class ContextPriv; std::vector> fRecordings; sk_sp fGpu; }; } // namespace skgpu #endif // skgpu_Context_DEFINED