skia2/docs/examples/f16to8888drawImageBug.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

26 lines
1.1 KiB
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(f16to8888drawImageBug, 256, 256, false, 0) {
// f16to8888drawImageBug
void draw(SkCanvas* canvas) {
sk_sp<SkColorSpace> colorSpace = SkColorSpace::MakeSRGBLinear();
SkImageInfo imageInfo =
SkImageInfo::Make(100, 100, kRGBA_F16_SkColorType, kPremul_SkAlphaType, colorSpace);
sk_sp<SkSurface> surface = SkSurface::MakeRaster(imageInfo);
SkPaint p;
surface->getCanvas()->drawRect(SkRect::MakeXYWH(20, 20, 40, 40), p);
sk_sp<SkColorSpace> colorSpace2 = SkColorSpace::MakeSRGB();
SkImageInfo imageInfo2 =
SkImageInfo::Make(100, 100, kN32_SkColorType, kPremul_SkAlphaType, colorSpace2);
sk_sp<SkSurface> surface2 = SkSurface::MakeRaster(imageInfo2);
surface2->getCanvas()->drawImage(surface->makeImageSnapshot(), 0, 0);
canvas->drawImage(surface->makeImageSnapshot(), 0, 0);
canvas->drawImage(surface2->makeImageSnapshot(), 50, 0);
}
} // END FIDDLE