[bazel] Add //gm/png_codec.cpp.

This proof-of-concept CL shows what it would be like if we reimplemented DM's CodecSrcs as GMs. The motivation is that the CodecSrc class, and other such classes, are conceptually very similar to a GM: they do some work and produce an image as their output. So, rather than introducing the notion of various "sources" in our Bazel work, I thought I would try rewriting DM's codec tests as GMs.

This particular CL focuses on PNG codec tests. Adding support for more file formats shouldn't be too different, and there is some potential for code reuse (e.g. a "BaseCodecGM" superclass).

Rather than relying on multiple nested loops to iterate over all possible combinations of options like DM does, this CL pushes those decisions to Bazel. In //gm/png_codec.bzl, we define multiple Bazel targets where each target focuses on a single combination of codec mode, color type, alpha type, etc. In //gm/png_codec.cpp, we take those options as command-line flags, and we register exactly one GM per image (whereas DM registers multiple GMs per image in a triply-nested loop; one GM per combination of options). This hopefully reduces the complexity of the C++ code, and provides better sharding by breaking up tests into smaller Bazel targets.

Notes to reviewers:

- I recommend reading //gm/png_codec.cpp from top to bottom, and reading the skia.googlesource.com links in my comments alongside this CL while reviewing. A lot of the code in //gm/png_codec.cpp is copied verbatim from the CodecSrc class and related functions.

- (Optional but recommended) See https://skia-review.googlesource.com/c/skia/+/728798 for an earlier attempt, where I tried to rewrite the entire CodecSrc class as a single CodecGM class. After chatting with kjlubick@, we decided it would be simpler to break that giant class into smaller ones focused e.g. on one file format per class. This CL is my attempt at isolating the parts of CodecSrc and related code that are only relevant to PNG files.

Tested with:

    $ bazel test //gm:png_codec_tests \
        --config=linux_rbe \
        --config=debug \
        --test_output=streamed \
        --strategy=TestRunner=local

Bug: b/40045301
Change-Id: I3e36c1ce03ceb892e7fae7fef5c0882e76b233e0
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/734379
Reviewed-by: Kevin Lubick <kjlubick@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Leandro Lovisolo <lovisolo@google.com>
10 files changed