Flutter Engine
The Flutter Engine
Classes | Functions
spritebitmap.cpp File Reference
#include "gm/gm.h"
#include "include/core/SkBitmap.h"
#include "include/core/SkCanvas.h"
#include "include/core/SkColor.h"
#include "include/core/SkImageFilter.h"
#include "include/core/SkMatrix.h"
#include "include/core/SkPaint.h"
#include "include/core/SkRect.h"
#include "include/core/SkRefCnt.h"
#include "include/core/SkSamplingOptions.h"
#include "include/core/SkScalar.h"
#include "include/core/SkSize.h"
#include "include/core/SkString.h"
#include "include/effects/SkImageFilters.h"
#include "tools/ToolUtils.h"
#include <utility>

Go to the source code of this file.

Classes

class  SpriteBitmapGM
 

Functions

static void make_bm (SkBitmap *bm)
 
static void draw_1_bitmap (SkCanvas *canvas, const SkBitmap &bm, bool doClip, int dx, int dy, sk_sp< SkImageFilter > filter)
 
 DEF_SIMPLE_GM_BG (drawimagerect_filter, canvas, 180, 60, SK_ColorWHITE)
 

Function Documentation

◆ DEF_SIMPLE_GM_BG()

DEF_SIMPLE_GM_BG ( drawimagerect_filter  ,
canvas  ,
180  ,
60  ,
SK_ColorWHITE   
)

Definition at line 107 of file spritebitmap.cpp.

107 {
110
111 canvas->translate(5, 5);
112 canvas->drawImage(image, 0.5f, 0.5f, sampling);
113
114 canvas->translate(60, 0);
115 canvas->drawImageRect(image, {0.5f, 0.5f, 50.5f, 50.5f}, sampling);
116
117 auto shader = image->makeShader(sampling);
118 canvas->translate(60, 0);
120 SkMatrix offset = SkMatrix::Translate(0.5f, 0.5f);
121 paint.setShader(image->makeShader(sampling, &offset));
122 canvas->drawRect({0.0f, 0.0f, 50.0f, 50.0f}, paint);
123}
constexpr SkColor SK_ColorBLACK
Definition: SkColor.h:103
constexpr SkColor SK_ColorWHITE
Definition: SkColor.h:122
sk_sp< SkShader > makeShader(SkTileMode tmx, SkTileMode tmy, const SkSamplingOptions &, const SkMatrix *localMatrix=nullptr) const
Definition: SkImage.cpp:179
static SkMatrix Translate(SkScalar dx, SkScalar dy)
Definition: SkMatrix.h:91
const Paint & paint
Definition: color_source.cc:38
sk_sp< const SkImage > image
Definition: SkRecords.h:269
SkSamplingOptions sampling
Definition: SkRecords.h:337
sk_sp< SkImage > create_checkerboard_image(int w, int h, SkColor c1, SkColor c2, int checkSize)
Definition: ToolUtils.cpp:168
SeparatedVector2 offset

◆ draw_1_bitmap()

static void draw_1_bitmap ( SkCanvas canvas,
const SkBitmap bm,
bool  doClip,
int  dx,
int  dy,
sk_sp< SkImageFilter filter 
)
static

Definition at line 37 of file spritebitmap.cpp.

38 {
39 SkAutoCanvasRestore acr(canvas, true);
41
43 SkIntToScalar(dy),
44 SkIntToScalar(bm.width()),
45 SkIntToScalar(bm.height()));
46
47 paint.setImageFilter(std::move(filter));
48 clipR.inset(5, 5);
49
50 canvas->translate(SkIntToScalar(bm.width() + 20), 0);
51
52 if (doClip) {
53 canvas->save();
54 canvas->clipRect(clipR);
55 }
58 if (doClip) {
59 canvas->restore();
60 }
61}
#define SkIntToScalar(x)
Definition: SkScalar.h:57
sk_sp< SkImage > asImage() const
Definition: SkBitmap.cpp:645
int width() const
Definition: SkBitmap.h:149
int height() const
Definition: SkBitmap.h:158
void clipRect(const SkRect &rect, SkClipOp op, bool doAntiAlias)
Definition: SkCanvas.cpp:1361
void restore()
Definition: SkCanvas.cpp:461
void translate(SkScalar dx, SkScalar dy)
Definition: SkCanvas.cpp:1278
int save()
Definition: SkCanvas.cpp:447
void drawImage(const SkImage *image, SkScalar left, SkScalar top)
Definition: SkCanvas.h:1528
skia_private::AutoTArray< sk_sp< SkImageFilter > > filters TypedMatrix matrix TypedMatrix matrix SkScalar dx
Definition: SkRecords.h:208
SkSamplingOptions(SkFilterMode::kLinear))
void inset(float dx, float dy)
Definition: SkRect.h:1060
static constexpr SkRect MakeXYWH(float x, float y, float w, float h)
Definition: SkRect.h:659

◆ make_bm()

static void make_bm ( SkBitmap bm)
static

Definition at line 26 of file spritebitmap.cpp.

26 {
27 bm->allocN32Pixels(100, 100);
29
30 SkCanvas canvas(*bm);
32 paint.setAntiAlias(true);
33 paint.setColor(SK_ColorRED);
34 canvas.drawCircle(50, 50, 50, paint);
35}
constexpr SkColor SK_ColorBLUE
Definition: SkColor.h:135
constexpr SkColor SK_ColorRED
Definition: SkColor.h:126
void allocN32Pixels(int width, int height, bool isOpaque=false)
Definition: SkBitmap.cpp:232
void eraseColor(SkColor4f) const
Definition: SkBitmap.cpp:442