skia2/docs/examples/upscale_checkerboard.cpp
Hal Canary 6c8422c671 add more docs/examples from named fiddles.
ignore offscreen, srgb, and animated fiddles for now.

Change-Id: I923131b684865698e6cda138b004930e11f504d5
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/263713
Commit-Queue: Hal Canary <halcanary@google.com>
Reviewed-by: Ben Wagner <bungeman@google.com>
2020-01-14 19:22:26 +00:00

19 lines
707 B
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 "tools/fiddle/examples.h"
REG_FIDDLE(upscale_checkerboard, 512, 512, false, 0) {
void draw(SkCanvas* canvas) {
SkPMColor p[] = {0xFFFFFFFF, 0xFF000000, 0xFF000000, 0xFFFFFFFF};
const auto info = SkImageInfo::MakeN32Premul(2, 2);
auto img = SkImage::MakeRasterCopy({info, p, 8});
SkPaint paint;
paint.setFilterQuality(kMedium_SkFilterQuality);
paint.setShader(img->makeShader(SkTileMode::kRepeat, SkTileMode::kRepeat));
canvas->translate(20, 20);
canvas->scale(20, 20);
canvas->drawRect({0, 0, 20, 20}, paint);
}
} // END FIDDLE