5b11a58c62
It would be nice if we could use infix operators, and it would also be nice if we could use literals instead of so many splats. To make infix operators possible, we need to have each I32 / F32 struct track its origin Builder, so that we know where to build the corresponding operation when we encounter an infix operator. E.g. struct F32 { Val id = NA; Builder* builder = ...; }; ... static inline F32 operator*(F32 x, F32 y) { SkASSERT(x.builder == y.builder); return x.builder->mul(x,y); } OK, that's great! But then once we start churning out overrides to work with literals, things get quite verbose, and it becomes easy to lose track of which methods can take literals and which can't. It'd be nice to have some sort of way to automatically handle literals. For that we notice that the F32 struct has 4 dead bytes anyway between the Val and the Builder*... perfect space for a literal. struct F32 { Val id = NA; float imm = 0.0f; Builder* builder = nulltpr; }; Now we can operate under the convention that when builder == nullptr, the F32 represents the value in `imm`, and when builder is set it is the result of the instruction at `id`. Then inside skvm::Builder, we'll look for F32's that are in that sort of Builder-less imm state and resolve them to splats. That's what id() does, returning that `id` val. I've renamed the field in the struct to make sure I caught all the old uses of `.id`. From there we make I32 and F32 much more locked down types, with three public constructors: NA/false, immediates, and instruction values. There's lots and lots and lots and lots and lots left to do both removing splat()s and especially converting to infix. I just tried to get enough in here that proves it works. luminance() has weird extra parens to preserve the order of evaluation, but I don't see any reason not to drop them in a follow up. Change-Id: If6889ec9ba1ecc23edb15361ccb2b2309be7a6b0 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/279907 Reviewed-by: Mike Reed <reed@google.com> Commit-Queue: Mike Klein <mtklein@google.com> |
||
---|---|---|
animations | ||
bench | ||
bin | ||
build/fuchsia | ||
build_overrides | ||
dm | ||
docker | ||
docs/examples | ||
example | ||
experimental | ||
fuzz | ||
gm | ||
gn | ||
include | ||
infra | ||
modules | ||
platform_tools | ||
resources | ||
samplecode | ||
site | ||
specs | ||
src | ||
tests | ||
third_party | ||
tools | ||
.clang-format | ||
.clang-tidy | ||
.gitignore | ||
.gn | ||
AUTHORS | ||
BUILD.gn | ||
codereview.settings | ||
CONTRIBUTING | ||
CQ_COMMITTERS | ||
DEPS | ||
go.mod | ||
go.sum | ||
LICENSE | ||
OWNERS | ||
PRESUBMIT.py | ||
public.bzl | ||
README | ||
README.chromium | ||
RELEASE_NOTES.txt | ||
whitespace.txt |
Skia is a complete 2D graphic library for drawing Text, Geometries, and Images. See full details, and build instructions, at https://skia.org.