skia2/tools/graphite/ContextFactory.h
Robert Phillips 297d096cfb [graphite] More testing infrastructure
With this CL we can run as:

     dm --src gm skp tests --config grmtl -v --nocpu --nogpu

and not get all the non-Graphite unit tests.

Bug: skia:12466
Change-Id: Ib3f04f315fe4b5731a54e4c72979a0c1e00baf24
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/457898
Commit-Queue: Robert Phillips <robertphillips@google.com>
Reviewed-by: Michael Ludwig <michaelludwig@google.com>
2021-10-13 15:15:29 +00:00

70 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 skiatest_graphite_ContextFactory_DEFINED
#define skiatest_graphite_ContextFactory_DEFINED
#include <vector>
#include "experimental/graphite/include/GraphiteTypes.h"
#include "include/core/SkRefCnt.h"
#include "tools/graphite/GraphiteTestContext.h"
namespace skgpu {
class Context;
};
namespace skiatest::graphite {
class ContextFactory {
public:
enum class ContextType {
kDirect3D,
kMetal,
kVulkan,
kMock,
};
class ContextInfo {
public:
ContextInfo() = default;
ContextInfo(ContextInfo&& other);
~ContextInfo() = default;
ContextFactory::ContextType type() const { return fType; }
skgpu::Context* context() const { return fContext.get(); }
sk_sp<skgpu::Context> refContext() const;
GraphiteTestContext* testContext() const { return fTestContext.get(); }
private:
friend class ContextFactory; // for ctor
ContextInfo(ContextFactory::ContextType type,
std::unique_ptr<GraphiteTestContext> testContext,
sk_sp<skgpu::Context> context);
ContextType fType = ContextType::kMock;
std::unique_ptr<GraphiteTestContext> fTestContext;
sk_sp<skgpu::Context> fContext;
};
ContextFactory() = default;
ContextFactory(const ContextFactory&) = delete;
ContextFactory& operator=(const ContextFactory&) = delete;
~ContextFactory() = default;
std::tuple<GraphiteTestContext*, sk_sp<skgpu::Context>> getContextInfo(ContextType);
private:
std::vector<ContextInfo> fContexts;
};
} // namespace skiatest::graphite
#endif // skiatest_graphite_ContextFactory_DEFINED