Flutter Engine
The Flutter Engine
Classes | Functions
imagefilterscropped.cpp File Reference
#include "gm/gm.h"
#include "include/core/SkBitmap.h"
#include "include/core/SkBlendMode.h"
#include "include/core/SkCanvas.h"
#include "include/core/SkColor.h"
#include "include/core/SkColorFilter.h"
#include "include/core/SkFont.h"
#include "include/core/SkImageFilter.h"
#include "include/core/SkPaint.h"
#include "include/core/SkRect.h"
#include "include/core/SkRefCnt.h"
#include "include/core/SkScalar.h"
#include "include/core/SkSize.h"
#include "include/core/SkString.h"
#include "include/core/SkTypeface.h"
#include "include/core/SkTypes.h"
#include "include/effects/SkImageFilters.h"
#include "include/utils/SkTextUtils.h"
#include "tools/ToolUtils.h"
#include "tools/fonts/FontToolUtils.h"
#include <utility>

Go to the source code of this file.

Classes

class  ImageFiltersCroppedGM
 

Functions

static void draw_paint (SkCanvas *canvas, const SkRect &r, sk_sp< SkImageFilter > imf)
 
static void draw_path (SkCanvas *canvas, const SkRect &r, sk_sp< SkImageFilter > imf)
 
static void draw_text (SkCanvas *canvas, const SkRect &r, sk_sp< SkImageFilter > imf)
 
static void draw_bitmap (SkCanvas *canvas, const SkRect &r, sk_sp< SkImageFilter > imf)
 

Function Documentation

◆ draw_bitmap()

static void draw_bitmap ( SkCanvas canvas,
const SkRect r,
sk_sp< SkImageFilter imf 
)
static

Definition at line 60 of file imagefilterscropped.cpp.

60 {
62
64 r.roundOut(&bounds);
65
66 auto surf = SkSurfaces::Raster(SkImageInfo::MakeN32Premul(bounds.width(), bounds.height()));
67 draw_path(surf->getCanvas(), r, nullptr);
68
69 paint.setImageFilter(std::move(imf));
70 surf->draw(canvas, 0, 0, SkSamplingOptions(), &paint);
71}
const Paint & paint
Definition: color_source.cc:38
static void draw_path(SkCanvas *canvas, const SkRect &r, sk_sp< SkImageFilter > imf)
Optional< SkRect > bounds
Definition: SkRecords.h:189
SK_API sk_sp< SkSurface > Raster(const SkImageInfo &imageInfo, size_t rowBytes, const SkSurfaceProps *surfaceProps)
SkSamplingOptions(SkFilterMode::kLinear))
Definition: SkRect.h:32
static SkImageInfo MakeN32Premul(int width, int height)
void roundOut(SkIRect *dst) const
Definition: SkRect.h:1241

◆ draw_paint()

static void draw_paint ( SkCanvas canvas,
const SkRect r,
sk_sp< SkImageFilter imf 
)
static

Definition at line 33 of file imagefilterscropped.cpp.

33 {
35 paint.setImageFilter(std::move(imf));
36 paint.setColor(SK_ColorBLACK);
37 canvas->save();
38 canvas->clipRect(r);
39 canvas->drawPaint(paint);
40 canvas->restore();
41}
constexpr SkColor SK_ColorBLACK
Definition: SkColor.h:103
void clipRect(const SkRect &rect, SkClipOp op, bool doAntiAlias)
Definition: SkCanvas.cpp:1361
void restore()
Definition: SkCanvas.cpp:461
void drawPaint(const SkPaint &paint)
Definition: SkCanvas.cpp:1668
int save()
Definition: SkCanvas.cpp:447

◆ draw_path()

static void draw_path ( SkCanvas canvas,
const SkRect r,
sk_sp< SkImageFilter imf 
)
static

Definition at line 43 of file imagefilterscropped.cpp.

43 {
45 paint.setColor(SK_ColorMAGENTA);
46 paint.setImageFilter(std::move(imf));
47 paint.setAntiAlias(true);
48 canvas->drawCircle(r.centerX(), r.centerY(), r.width()*2/5, paint);
49}
constexpr SkColor SK_ColorMAGENTA
Definition: SkColor.h:147
void drawCircle(SkScalar cx, SkScalar cy, SkScalar radius, const SkPaint &paint)
Definition: SkCanvas.cpp:2707
constexpr float centerX() const
Definition: SkRect.h:776
constexpr float centerY() const
Definition: SkRect.h:785
constexpr float width() const
Definition: SkRect.h:762

◆ draw_text()

static void draw_text ( SkCanvas canvas,
const SkRect r,
sk_sp< SkImageFilter imf 
)
static

Definition at line 51 of file imagefilterscropped.cpp.

51 {
53 paint.setImageFilter(std::move(imf));
54 paint.setColor(SK_ColorGREEN);
55
58}
constexpr SkColor SK_ColorGREEN
Definition: SkColor.h:131
Definition: SkFont.h:35
static void DrawString(SkCanvas *canvas, const char text[], SkScalar x, SkScalar y, const SkFont &font, const SkPaint &paint, Align align=kLeft_Align)
Definition: SkTextUtils.h:34
sk_sp< SkTypeface > DefaultPortableTypeface()
font
Font Metadata and Metrics.
constexpr float height() const
Definition: SkRect.h:769