Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
shadermaskfilter.cpp
Go to the documentation of this file.
1/*
2 * Copyright 2018 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#include "include/core/SkFont.h"
21#include "include/core/SkPath.h"
25#include "include/core/SkRect.h"
38#include "tools/Resources.h"
39#include "tools/ToolUtils.h"
40
41#include <initializer_list>
42
44 const SkPoint pts[] = {
45 { r.fLeft, r.fTop }, { r.fRight, r.fBottom },
46 };
47 const SkColor colors[] = { 0, SK_ColorWHITE };
48 return SkGradientShader::MakeLinear(pts, colors, nullptr, 2, SkTileMode::kRepeat);
49}
50
51DEF_SIMPLE_GM(shadermaskfilter_gradient, canvas, 512, 512) {
52 SkRect r = { 0, 0, 100, 150 };
53 auto shader = make_shader(r);
54 auto mf = SkShaderMaskFilter::Make(shader);
55
56 canvas->translate(20, 20);
57 canvas->scale(2, 2);
58
60 paint.setMaskFilter(mf);
61 paint.setColor(SK_ColorRED);
62 paint.setAntiAlias(true);
63 canvas->drawOval(r, paint);
64}
static sk_sp< SkShader > make_shader()
uint32_t SkColor
Definition SkColor.h:37
constexpr SkColor SK_ColorRED
Definition SkColor.h:126
constexpr SkColor SK_ColorWHITE
Definition SkColor.h:122
static sk_sp< SkShader > MakeLinear(const SkPoint pts[2], const SkColor colors[], const SkScalar pos[], int count, SkTileMode mode, uint32_t flags=0, const SkMatrix *localMatrix=nullptr)
static sk_sp< SkMaskFilter > Make(sk_sp< SkShader > shader)
const Paint & paint
#define DEF_SIMPLE_GM(NAME, CANVAS, W, H)
Definition gm.h:50
SkScalar fBottom
larger y-axis bounds
Definition extension.cpp:17
SkScalar fLeft
smaller x-axis bounds
Definition extension.cpp:14
SkScalar fRight
larger x-axis bounds
Definition extension.cpp:16
SkScalar fTop
smaller y-axis bounds
Definition extension.cpp:15