2021-09-30 15:41:16 +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.
|
|
|
|
*/
|
|
|
|
|
2021-10-11 15:28:21 +00:00
|
|
|
#ifndef skiatest_graphite_ContextFactory_DEFINED
|
|
|
|
#define skiatest_graphite_ContextFactory_DEFINED
|
2021-09-30 15:41:16 +00:00
|
|
|
|
|
|
|
#include <vector>
|
2022-04-08 23:25:39 +00:00
|
|
|
#include "experimental/graphite/include/GraphiteTypes.h"
|
2021-09-30 15:41:16 +00:00
|
|
|
#include "include/core/SkRefCnt.h"
|
|
|
|
#include "tools/graphite/GraphiteTestContext.h"
|
|
|
|
|
2022-04-07 20:08:04 +00:00
|
|
|
namespace skgpu::graphite {
|
2021-09-30 15:41:16 +00:00
|
|
|
class Context;
|
|
|
|
};
|
|
|
|
|
2021-10-11 15:28:21 +00:00
|
|
|
namespace skiatest::graphite {
|
2021-09-30 15:41:16 +00:00
|
|
|
|
|
|
|
class ContextFactory {
|
|
|
|
public:
|
|
|
|
enum class ContextType {
|
2021-10-13 14:37:36 +00:00
|
|
|
kDirect3D,
|
2021-09-30 15:41:16 +00:00
|
|
|
kMetal,
|
2021-10-13 14:37:36 +00:00
|
|
|
kVulkan,
|
2021-09-30 15:41:16 +00:00
|
|
|
kMock,
|
|
|
|
};
|
|
|
|
|
|
|
|
class ContextInfo {
|
|
|
|
public:
|
|
|
|
ContextInfo() = default;
|
2021-10-13 14:37:36 +00:00
|
|
|
ContextInfo(ContextInfo&& other);
|
2021-09-30 15:41:16 +00:00
|
|
|
~ContextInfo() = default;
|
|
|
|
|
|
|
|
ContextFactory::ContextType type() const { return fType; }
|
|
|
|
|
2022-04-07 20:08:04 +00:00
|
|
|
skgpu::graphite::Context* context() const { return fContext.get(); }
|
2021-09-30 15:41:16 +00:00
|
|
|
GraphiteTestContext* testContext() const { return fTestContext.get(); }
|
|
|
|
|
|
|
|
private:
|
|
|
|
friend class ContextFactory; // for ctor
|
|
|
|
|
|
|
|
ContextInfo(ContextFactory::ContextType type,
|
|
|
|
std::unique_ptr<GraphiteTestContext> testContext,
|
2022-04-07 20:08:04 +00:00
|
|
|
std::unique_ptr<skgpu::graphite::Context> context);
|
2021-09-30 15:41:16 +00:00
|
|
|
|
2022-04-07 20:08:04 +00:00
|
|
|
ContextType fType = ContextType::kMock;
|
|
|
|
std::unique_ptr<GraphiteTestContext> fTestContext;
|
|
|
|
std::unique_ptr<skgpu::graphite::Context> fContext;
|
2021-09-30 15:41:16 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
ContextFactory() = default;
|
|
|
|
ContextFactory(const ContextFactory&) = delete;
|
|
|
|
ContextFactory& operator=(const ContextFactory&) = delete;
|
|
|
|
|
|
|
|
~ContextFactory() = default;
|
|
|
|
|
2022-04-07 20:08:04 +00:00
|
|
|
std::tuple<GraphiteTestContext*, skgpu::graphite::Context*> getContextInfo(ContextType);
|
2021-09-30 15:41:16 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
std::vector<ContextInfo> fContexts;
|
|
|
|
};
|
|
|
|
|
2021-10-11 15:28:21 +00:00
|
|
|
} // namespace skiatest::graphite
|
2021-09-30 15:41:16 +00:00
|
|
|
|
2021-10-11 15:28:21 +00:00
|
|
|
#endif // skiatest_graphite_ContextFactory_DEFINED
|