skia2/tools/graphite/ContextFactory.h
Jim Van Verth ab4d4ae9e2 Revert "[graphite] Move Graphite into Skia base directories."
This reverts commit ae5e846047.

Reason for revert: Breaking Google3

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: Ia57992a22c42b17216b40fd29452865f957fb802
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/528653
Auto-Submit: Jim Van Verth <jvanverth@google.com>
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Reviewed-by: Greg Daniel <egdaniel@google.com>
Commit-Queue: Greg Daniel <egdaniel@google.com>
2022-04-09 01:02:26 +00:00

69 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::graphite {
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::graphite::Context* context() const { return fContext.get(); }
GraphiteTestContext* testContext() const { return fTestContext.get(); }
private:
friend class ContextFactory; // for ctor
ContextInfo(ContextFactory::ContextType type,
std::unique_ptr<GraphiteTestContext> testContext,
std::unique_ptr<skgpu::graphite::Context> context);
ContextType fType = ContextType::kMock;
std::unique_ptr<GraphiteTestContext> fTestContext;
std::unique_ptr<skgpu::graphite::Context> fContext;
};
ContextFactory() = default;
ContextFactory(const ContextFactory&) = delete;
ContextFactory& operator=(const ContextFactory&) = delete;
~ContextFactory() = default;
std::tuple<GraphiteTestContext*, skgpu::graphite::Context*> getContextInfo(ContextType);
private:
std::vector<ContextInfo> fContexts;
};
} // namespace skiatest::graphite
#endif // skiatest_graphite_ContextFactory_DEFINED