Files
rk35xx-android14/external/skia/tests/SkSLMetalTestbed.cpp
T
hmz007 36ed224bac Rockchip Anroid14_SDK 20240628-rkr5 (2556df1a)
Signed-off-by: hmz007 <hmz007@gmail.com>
Change-Id: Ib87fdbe7a0be7dc961af3500fe9ea4589a127f9f
2024-10-29 18:12:02 +08:00

46 lines
1.4 KiB
C++

/*
* Copyright 2020 Google LLC
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#include "include/core/SkTypes.h"
#include "include/private/SkSLProgramKind.h"
#include "src/sksl/SkSLCompiler.h"
#include "src/sksl/SkSLProgramSettings.h"
#include "src/sksl/SkSLUtil.h"
#include "src/sksl/ir/SkSLProgram.h"
#include "tests/Test.h"
#include <memory>
#include <string>
static void test(skiatest::Reporter* r,
const char* src,
SkSL::ProgramKind kind = SkSL::ProgramKind::kFragment) {
SkSL::Compiler compiler(SkSL::ShaderCapsFactory::Default());
SkSL::ProgramSettings settings;
std::unique_ptr<SkSL::Program> program = compiler.convertProgram(kind, std::string(src),
settings);
if (!program) {
SkDebugf("Unexpected error compiling %s\n%s", src, compiler.errorText().c_str());
REPORTER_ASSERT(r, program);
} else {
std::string output;
REPORTER_ASSERT(r, compiler.toMetal(*program, &output));
REPORTER_ASSERT(r, output != "");
//SkDebugf("Metal output:\n\n%s", output.c_str());
}
}
DEF_TEST(SkSLMetalTestbed, r) {
// Add in your SkSL here.
test(r,
R"__SkSL__(
void main() {
sk_FragColor = half4(0);
}
)__SkSL__");
}