blob: c58928f7303e177a9ecfa7dd62a238758407b39f [file] [log] [blame]
Hal Canary6c8422c2020-01-10 15:22:09 -05001// Copyright 2020 Google LLC.
2// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.
3#include "tools/fiddle/examples.h"
4REG_FIDDLE(f16to8888busted, 256, 256, false, 0) {
5void draw(SkCanvas* canvas) {
6 // Create the linear-rgb color space and the image info
7 sk_sp<SkColorSpace> colorSpace = SkColorSpace::MakeSRGBLinear();
8 SkImageInfo info = SkImageInfo::Make(100, 100, SkColorType::kRGBA_F16_SkColorType,
9 SkAlphaType::kPremul_SkAlphaType, colorSpace);
10
11 sk_sp<SkSurface> offscreen = SkSurface::MakeRaster(info);
12 SkPaint paint;
13 offscreen->getCanvas()->drawRect(SkRect::MakeXYWH(25, 25, 50, 50), paint);
14
15 // Take a snapshot from surface and draw it on the canvas
16 sk_sp<SkImage> img = offscreen->makeImageSnapshot();
17 canvas->drawImageRect(img, SkRect::MakeWH(100, 100), nullptr);
18}
19} // END FIDDLE