Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Classes | Functions
LayersSlide.cpp File Reference
#include "include/core/SkCanvas.h"
#include "include/core/SkColorFilter.h"
#include "include/core/SkColorPriv.h"
#include "include/core/SkImage.h"
#include "include/core/SkMaskFilter.h"
#include "include/core/SkPath.h"
#include "include/core/SkRegion.h"
#include "include/core/SkShader.h"
#include "include/core/SkTypeface.h"
#include "include/effects/SkGradientShader.h"
#include "include/utils/SkCamera.h"
#include "src/base/SkTime.h"
#include "src/base/SkUTF.h"
#include "tools/DecodeUtils.h"
#include "tools/viewer/ClickHandlerSlide.h"
#include "tools/viewer/Slide.h"
#include "include/effects/SkImageFilters.h"
#include "tools/Resources.h"

Go to the source code of this file.

Classes

class  LayersSlide
 
class  BackdropSlide
 

Functions

static void make_paint (SkPaint *paint, const SkMatrix &localMatrix)
 
static void test_fade (SkCanvas *canvas)
 

Function Documentation

◆ make_paint()

static void make_paint ( SkPaint paint,
const SkMatrix localMatrix 
)
static

Definition at line 25 of file LayersSlide.cpp.

25 {
26 SkColor colors[] = { 0, SK_ColorWHITE };
27 SkPoint pts[] = { { 0, 0 }, { 0, SK_Scalar1*20 } };
28 paint->setShader(SkGradientShader::MakeLinear(pts, colors, nullptr, 2,
29 SkTileMode::kClamp, 0, &localMatrix));
30 paint->setBlendMode(SkBlendMode::kDstIn);
31}
@ kDstIn
r = d * sa
uint32_t SkColor
Definition SkColor.h:37
constexpr SkColor SK_ColorWHITE
Definition SkColor.h:122
#define SK_Scalar1
Definition SkScalar.h:18
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)
const Paint & paint
PODArray< SkColor > colors
Definition SkRecords.h:276

◆ test_fade()

static void test_fade ( SkCanvas canvas)
static

Definition at line 34 of file LayersSlide.cpp.

34 {
35 SkAutoCanvasRestore ar(canvas, true);
36
37 SkRect r;
38
39 SkAutoCanvasRestore ar2(canvas, false);
40
41 // create the layers
42
43 r.setWH(100, 100);
44 canvas->clipRect(r);
45
46 r.fBottom = SkIntToScalar(20);
47 canvas->saveLayer(&r, nullptr);
48
49 r.fTop = SkIntToScalar(80);
50 r.fBottom = SkIntToScalar(100);
51 canvas->saveLayer(&r, nullptr);
52
53 // now draw the "content"
54
55 if ((true)) {
56 r.setWH(100, 100);
57
58 canvas->saveLayerAlpha(&r, 0x80);
59
60 SkPaint p;
61 p.setColor(SK_ColorRED);
62 p.setAntiAlias(true);
63 canvas->drawOval(r, p);
64
65 canvas->restore();
66 } else {
67 r.setWH(100, 100);
68
69 SkPaint p;
70 p.setColor(SK_ColorRED);
71 p.setAntiAlias(true);
72 canvas->drawOval(r, p);
73 }
74
75// return;
76
77 // now apply an effect
78 SkMatrix m;
79 m.setScale(SK_Scalar1, -SK_Scalar1);
80 m.postTranslate(0, SkIntToScalar(100));
81
83 make_paint(&paint, m);
84 r.setWH(100, 20);
85// SkDebugf("--------- draw top grad\n");
86 canvas->drawRect(r, paint);
87
88 r.fTop = SkIntToScalar(80);
89 r.fBottom = SkIntToScalar(100);
90// SkDebugf("--------- draw bot grad\n");
91 canvas->drawRect(r, paint);
92}
static void make_paint(SkPaint *paint, const SkMatrix &localMatrix)
constexpr SkColor SK_ColorRED
Definition SkColor.h:126
#define SkIntToScalar(x)
Definition SkScalar.h:57
int saveLayer(const SkRect *bounds, const SkPaint *paint)
Definition SkCanvas.cpp:500
void drawRect(const SkRect &rect, const SkPaint &paint)
void drawOval(const SkRect &oval, const SkPaint &paint)
void clipRect(const SkRect &rect, SkClipOp op, bool doAntiAlias)
void restore()
Definition SkCanvas.cpp:465
int saveLayerAlpha(const SkRect *bounds, U8CPU alpha)
Definition SkCanvas.h:661
SkScalar fBottom
larger y-axis bounds
Definition extension.cpp:17
void setWH(float width, float height)
Definition SkRect.h:944
SkScalar fTop
smaller y-axis bounds
Definition extension.cpp:15