Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
bicubic.cpp
Go to the documentation of this file.
1/*
2 * Copyright 2020 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
8#include "gm/gm.h"
14
15DEF_SIMPLE_GM(bicubic, canvas, 300, 320) {
16 canvas->clear(SK_ColorBLACK);
17
22 };
23
24 auto make_img = []() {
26 surf->getCanvas()->drawColor(SK_ColorBLACK);
27
29 paint.setColor(SK_ColorWHITE);
30 surf->getCanvas()->drawLine(3.5f, 0, 3.5f, 8, paint);
31 return surf->makeImageSnapshot();
32 };
33
34 auto img = make_img();
35
36 canvas->scale(40, 8);
37 for (const auto& s : gSamplings) {
38 canvas->drawImage(img, 0, 0, s, nullptr);
39 canvas->translate(0, img->height() + 1.0f);
40 }
41
42 const SkRect r = SkRect::MakeIWH(img->width(), img->height());
44
45 SkCubicResampler cubics[] = {
48 };
49 for (auto c : cubics) {
50 paint.setShader(img->makeShader(SkTileMode::kClamp, SkTileMode::kClamp,
52 canvas->drawRect(r, paint);
53 canvas->translate(0, img->height() + 1.0f);
54 }
55}
constexpr SkColor SK_ColorBLACK
Definition SkColor.h:103
constexpr SkColor SK_ColorWHITE
Definition SkColor.h:122
const Paint & paint
struct MyStruct s
#define DEF_SIMPLE_GM(NAME, CANVAS, W, H)
Definition gm.h:50
static sk_sp< SkImage > make_img()
SK_API sk_sp< SkSurface > Raster(const SkImageInfo &imageInfo, size_t rowBytes, const SkSurfaceProps *surfaceProps)
static constexpr SkCubicResampler CatmullRom()
static constexpr SkCubicResampler Mitchell()
static SkImageInfo MakeN32Premul(int width, int height)
static SkRect MakeIWH(int w, int h)
Definition SkRect.h:623
const SkSamplingOptions gSamplings[]
Definition image.cpp:57