skia2/tests/SkSLTypeTest.cpp
John Stiles 2dda4b6563 Allow Mangler to be used outside of Inliner.
It now lives in the Compiler instead of the Inliner, and we have a
pointer to it inside the Context. I also took the opportunity to remove
a few unnecessary #includes from Context and fixed up the fallout from
this.

POTENTIALLY IMPORTANT FOOTNOTE: DSLWriter has its own Mangler object
inside of it. I experimented with removing this and having it share the
Mangler object inside the Context, but this caused failures in
"testThreading" and "testpersistentcache" CQ bots; the Expected and
Actual images would mismatch. (The Expected would be missing some
draws.) This particularly affected some blur-related tests which are
likely to be GaussianConvolution--i.e. it uses DSL.
This might be a canary in the coalmine for some quirky DSL threading
issue? e.g. using the same Context on two threads at once?

Change-Id: I2290b810d9487c40a3dbef119c95d1572b14a5ae
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/449357
Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
Commit-Queue: John Stiles <johnstiles@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
2021-09-16 21:53:19 +00:00

38 lines
1.4 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 <limits>
#include "include/sksl/SkSLErrorReporter.h"
#include "src/gpu/GrCaps.h"
#include "src/sksl/SkSLContext.h"
#include "src/sksl/SkSLMangler.h"
#include "tests/Test.h"
DEF_TEST(SkSLTypeLimits, r) {
GrShaderCaps caps(GrContextOptions{});
SkSL::TestingOnly_AbortErrorReporter errors;
SkSL::Mangler mangler;
SkSL::Context context(errors, caps, mangler);
using int_limits = std::numeric_limits<int32_t>;
REPORTER_ASSERT(r, context.fTypes.fInt->minimumValue() == int_limits::min());
REPORTER_ASSERT(r, context.fTypes.fInt->maximumValue() == int_limits::max());
using short_limits = std::numeric_limits<int16_t>;
REPORTER_ASSERT(r, context.fTypes.fShort->minimumValue() == short_limits::min());
REPORTER_ASSERT(r, context.fTypes.fShort->maximumValue() == short_limits::max());
using uint_limits = std::numeric_limits<uint32_t>;
REPORTER_ASSERT(r, context.fTypes.fUInt->minimumValue() == uint_limits::min());
REPORTER_ASSERT(r, context.fTypes.fUInt->maximumValue() == uint_limits::max());
using ushort_limits = std::numeric_limits<uint16_t>;
REPORTER_ASSERT(r, context.fTypes.fUShort->minimumValue() == ushort_limits::min());
REPORTER_ASSERT(r, context.fTypes.fUShort->maximumValue() == ushort_limits::max());
}