42f710f3fa
This is a reland of commit ae5e846047
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: Ia575fd49206ad0b665a6a9153317e738bb321446
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/529059
Reviewed-by: Kevin Lubick <kjlubick@google.com>
Reviewed-by: Greg Daniel <egdaniel@google.com>
Commit-Queue: Jim Van Verth <jvanverth@google.com>
70 lines
1.8 KiB
C++
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.
|
|
*/
|
|
|
|
#include "tools/graphite/ContextFactory.h"
|
|
|
|
#include "include/gpu/graphite/Context.h"
|
|
|
|
#ifdef SK_METAL
|
|
#include "tools/graphite/mtl/GraphiteMtlTestContext.h"
|
|
#endif
|
|
|
|
namespace skiatest::graphite {
|
|
|
|
ContextFactory::ContextInfo::ContextInfo(ContextInfo&& other)
|
|
: fType(other.fType)
|
|
, fTestContext(std::move(other.fTestContext))
|
|
, fContext(std::move(other.fContext)) {
|
|
}
|
|
|
|
ContextFactory::ContextInfo::ContextInfo(ContextFactory::ContextType type,
|
|
std::unique_ptr<GraphiteTestContext> testContext,
|
|
std::unique_ptr<skgpu::graphite::Context> context)
|
|
: fType(type)
|
|
, fTestContext(std::move(testContext))
|
|
, fContext(std::move(context)) {
|
|
}
|
|
|
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
std::tuple<GraphiteTestContext*, skgpu::graphite::Context*> ContextFactory::getContextInfo(
|
|
ContextType type) {
|
|
|
|
for (ContextInfo& c : fContexts) {
|
|
if (c.type() == type) {
|
|
return { c.testContext(), c.context() };
|
|
}
|
|
}
|
|
|
|
std::unique_ptr<GraphiteTestContext> testCtx;
|
|
|
|
switch (type) {
|
|
case ContextType::kMetal: {
|
|
#ifdef SK_METAL
|
|
testCtx = graphite::MtlTestContext::Make();
|
|
#endif
|
|
} break;
|
|
|
|
default:
|
|
break;
|
|
}
|
|
|
|
if (!testCtx) {
|
|
return {};
|
|
}
|
|
|
|
std::unique_ptr<skgpu::graphite::Context> context = testCtx->makeContext();
|
|
if (!context) {
|
|
return {};
|
|
}
|
|
|
|
fContexts.push_back({ type, std::move(testCtx), std::move(context) });
|
|
|
|
return { fContexts.back().testContext(), fContexts.back().context() };
|
|
}
|
|
|
|
} // namespace skiatest::graphite
|