Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
third_party
skia
tests
SkSLGLSLTestbed.cpp
Go to the documentation of this file.
1
/*
2
* Copyright 2020 Google LLC
3
*
4
* Use of this source code is governed by a BSD-style license that can be
5
* found in the LICENSE file.
6
*/
7
8
#include "
include/core/SkTypes.h
"
9
#include "
src/sksl/SkSLCompiler.h
"
10
#include "
src/sksl/SkSLProgramKind.h
"
11
#include "
src/sksl/SkSLProgramSettings.h
"
12
#include "
src/sksl/SkSLUtil.h
"
13
#include "
src/sksl/codegen/SkSLGLSLCodeGenerator.h
"
14
#include "
src/sksl/ir/SkSLProgram.h
"
15
#include "
tests/Test.h
"
16
17
#include <memory>
18
#include <string>
19
20
static
void
test
(
skiatest::Reporter
* r,
21
const
char
* src,
22
SkSL::ProgramKind
kind =
SkSL::ProgramKind::kFragment
) {
23
SkSL::Compiler
compiler
;
24
SkSL::ProgramSettings
settings;
25
std::unique_ptr<SkSL::Program> program =
compiler
.convertProgram(kind, std::string(src),
26
settings);
27
if
(!program) {
28
SkDebugf
(
"Unexpected error compiling %s\n%s"
, src,
compiler
.errorText().c_str());
29
REPORTER_ASSERT
(r, program);
30
}
else
{
31
std::string output;
32
REPORTER_ASSERT
(r,
SkSL::ToGLSL
(*program,
SkSL::ShaderCapsFactory::Default
(), &output));
33
REPORTER_ASSERT
(r, output !=
""
);
34
//SkDebugf("GLSL output:\n\n%s", output.c_str());
35
}
36
}
37
38
DEF_TEST
(SkSLGLSLTestbed, r) {
39
// Add in your SkSL here.
40
test
(r,
41
R
"__SkSL__(
42
void main() {
43
sk_FragColor = half4(0);
44
}
45
)__SkSL__");
46
}
test
#define test(name)
SkDebugf
void SK_SPI SkDebugf(const char format[],...) SK_PRINTF_LIKE(1
SkSLCompiler.h
SkSLGLSLCodeGenerator.h
SkSLProgramKind.h
SkSLProgramSettings.h
SkSLProgram.h
SkSLUtil.h
SkTypes.h
Test.h
DEF_TEST
#define DEF_TEST(name, reporter)
Definition
Test.h:312
REPORTER_ASSERT
#define REPORTER_ASSERT(r, cond,...)
Definition
Test.h:286
SkSL::Compiler
Definition
SkSLCompiler.h:69
SkSL::ShaderCapsFactory::Default
static const ShaderCaps * Default()
Definition
SkSLUtil.h:166
skiatest::Reporter
Definition
Test.h:58
SkSL::ToGLSL
bool ToGLSL(Program &program, const ShaderCaps *caps, OutputStream &out)
Definition
SkSLGLSLCodeGenerator.cpp:2023
SkSL::ProgramKind
ProgramKind
Definition
SkSLProgramKind.h:18
SkSL::ProgramKind::kFragment
@ kFragment
compiler
Definition
compiler.py:1
SkSL::ProgramSettings
Definition
SkSLProgramSettings.h:22
Generated on Fri Apr 26 2024 06:18:03 for Flutter Engine by
1.9.8