Flutter Engine
The Flutter Engine
Classes | Macros | Functions
SkDraw.cpp File Reference
#include "include/core/SkBitmap.h"
#include "include/core/SkColorType.h"
#include "include/core/SkMatrix.h"
#include "include/core/SkPaint.h"
#include "include/core/SkPixmap.h"
#include "include/core/SkPoint.h"
#include "include/core/SkRect.h"
#include "include/core/SkRegion.h"
#include "include/core/SkScalar.h"
#include "include/core/SkTileMode.h"
#include "include/private/base/SkAssert.h"
#include "include/private/base/SkDebug.h"
#include "include/private/base/SkFixed.h"
#include "include/private/base/SkFloatingPoint.h"
#include "include/private/base/SkTemplates.h"
#include "include/private/base/SkTo.h"
#include "src/base/SkArenaAlloc.h"
#include "src/base/SkTLazy.h"
#include "src/core/SkAutoBlitterChoose.h"
#include "src/core/SkBlitter.h"
#include "src/core/SkDraw.h"
#include "src/core/SkImageInfoPriv.h"
#include "src/core/SkImagePriv.h"
#include "src/core/SkMatrixUtils.h"
#include "src/core/SkRasterClip.h"
#include "src/core/SkRectPriv.h"
#include "src/core/SkScan.h"

Go to the source code of this file.

Classes

struct  PtProcRec
 

Macros

#define MAX_DEV_PTS   32
 

Functions

static SkPaint make_paint_with_image (const SkPaint &origPaint, const SkBitmap &bitmap, const SkSamplingOptions &sampling, SkMatrix *matrix=nullptr)
 
static void bw_pt_hair_proc (const PtProcRec &rec, const SkPoint devPts[], int count, SkBlitter *blitter)
 
static void bw_line_hair_proc (const PtProcRec &rec, const SkPoint devPts[], int count, SkBlitter *blitter)
 
static void bw_poly_hair_proc (const PtProcRec &rec, const SkPoint devPts[], int count, SkBlitter *blitter)
 
static void aa_line_hair_proc (const PtProcRec &rec, const SkPoint devPts[], int count, SkBlitter *blitter)
 
static void aa_poly_hair_proc (const PtProcRec &rec, const SkPoint devPts[], int count, SkBlitter *blitter)
 
static SkRect make_square_rad (SkPoint center, SkScalar radius)
 
static SkXRect make_xrect (const SkRect &r)
 
static void bw_square_proc (const PtProcRec &rec, const SkPoint devPts[], int count, SkBlitter *blitter)
 
static void aa_square_proc (const PtProcRec &rec, const SkPoint devPts[], int count, SkBlitter *blitter)
 
static bool clipped_out (const SkMatrix &m, const SkRasterClip &c, const SkRect &srcR)
 
static bool clipped_out (const SkMatrix &matrix, const SkRasterClip &clip, int width, int height)
 
static bool clipHandlesSprite (const SkRasterClip &clip, int x, int y, const SkPixmap &pmap)
 

Macro Definition Documentation

◆ MAX_DEV_PTS

#define MAX_DEV_PTS   32

Definition at line 235 of file SkDraw.cpp.

Function Documentation

◆ aa_line_hair_proc()

static void aa_line_hair_proc ( const PtProcRec rec,
const SkPoint  devPts[],
int  count,
SkBlitter blitter 
)
static

Definition at line 102 of file SkDraw.cpp.

103 {
104 for (int i = 0; i < count; i += 2) {
105 SkScan::AntiHairLine(&devPts[i], 2, *rec.fRC, blitter);
106 }
107}
int count
Definition: FontMgrTest.cpp:50
static void AntiHairLine(const SkPoint[], int count, const SkRasterClip &, SkBlitter *)
const SkRasterClip * fRC
Definition: SkDraw.cpp:60

◆ aa_poly_hair_proc()

static void aa_poly_hair_proc ( const PtProcRec rec,
const SkPoint  devPts[],
int  count,
SkBlitter blitter 
)
static

Definition at line 109 of file SkDraw.cpp.

110 {
111 SkScan::AntiHairLine(devPts, count, *rec.fRC, blitter);
112}

◆ aa_square_proc()

static void aa_square_proc ( const PtProcRec rec,
const SkPoint  devPts[],
int  count,
SkBlitter blitter 
)
static

Definition at line 141 of file SkDraw.cpp.

142 {
143 for (int i = 0; i < count; i++) {
144 SkRect r = make_square_rad(devPts[i], rec.fRadius);
145 if (r.intersect(rec.fClipBounds)) {
146 SkScan::AntiFillXRect(make_xrect(r), *rec.fRC, blitter);
147 }
148 }
149}
static SkXRect make_xrect(const SkRect &r)
Definition: SkDraw.cpp:123
static SkRect make_square_rad(SkPoint center, SkScalar radius)
Definition: SkDraw.cpp:116
static void AntiFillXRect(const SkXRect &, const SkRasterClip &, SkBlitter *)
SkScalar fRadius
Definition: SkDraw.cpp:64
SkRect fClipBounds
Definition: SkDraw.cpp:63
bool intersect(const SkRect &r)
Definition: SkRect.cpp:114

◆ bw_line_hair_proc()

static void bw_line_hair_proc ( const PtProcRec rec,
const SkPoint  devPts[],
int  count,
SkBlitter blitter 
)
static

Definition at line 88 of file SkDraw.cpp.

89 {
90 for (int i = 0; i < count; i += 2) {
91 SkScan::HairLine(&devPts[i], 2, *rec.fRC, blitter);
92 }
93}
static void HairLine(const SkPoint[], int count, const SkRasterClip &, SkBlitter *)

◆ bw_poly_hair_proc()

static void bw_poly_hair_proc ( const PtProcRec rec,
const SkPoint  devPts[],
int  count,
SkBlitter blitter 
)
static

Definition at line 95 of file SkDraw.cpp.

96 {
97 SkScan::HairLine(devPts, count, *rec.fRC, blitter);
98}

◆ bw_pt_hair_proc()

static void bw_pt_hair_proc ( const PtProcRec rec,
const SkPoint  devPts[],
int  count,
SkBlitter blitter 
)
static

Definition at line 77 of file SkDraw.cpp.

78 {
79 for (int i = 0; i < count; i++) {
80 int x = SkScalarFloorToInt(devPts[i].fX);
81 int y = SkScalarFloorToInt(devPts[i].fY);
82 if (rec.fClip->contains(x, y)) {
83 blitter->blitH(x, y, 1);
84 }
85 }
86}
#define SkScalarFloorToInt(x)
Definition: SkScalar.h:35
virtual void blitH(int x, int y, int width)=0
Blit a horizontal run of one or more pixels.
bool contains(int32_t x, int32_t y) const
Definition: SkRegion.cpp:364
double y
double x
const SkRegion * fClip
Definition: SkDraw.cpp:59

◆ bw_square_proc()

static void bw_square_proc ( const PtProcRec rec,
const SkPoint  devPts[],
int  count,
SkBlitter blitter 
)
static

Definition at line 131 of file SkDraw.cpp.

132 {
133 for (int i = 0; i < count; i++) {
134 SkRect r = make_square_rad(devPts[i], rec.fRadius);
135 if (r.intersect(rec.fClipBounds)) {
136 SkScan::FillXRect(make_xrect(r), *rec.fRC, blitter);
137 }
138 }
139}
static void FillXRect(const SkXRect &, const SkRasterClip &, SkBlitter *)
Definition: SkScan.cpp:80

◆ clipHandlesSprite()

static bool clipHandlesSprite ( const SkRasterClip clip,
int  x,
int  y,
const SkPixmap pmap 
)
static

Definition at line 299 of file SkDraw.cpp.

299 {
300 return clip.isBW() || clip.quickContains(SkIRect::MakeXYWH(x, y, pmap.width(), pmap.height()));
301}
static SkPath clip(const SkPath &path, const SkHalfPlane &plane)
Definition: SkPath.cpp:3892
int width() const
Definition: SkPixmap.h:160
int height() const
Definition: SkPixmap.h:166
static constexpr SkIRect MakeXYWH(int32_t x, int32_t y, int32_t w, int32_t h)
Definition: SkRect.h:104

◆ clipped_out() [1/2]

static bool clipped_out ( const SkMatrix m,
const SkRasterClip c,
const SkRect srcR 
)
static

Definition at line 285 of file SkDraw.cpp.

286 {
287 SkRect dstR;
288 m.mapRect(&dstR, srcR);
289 return c.quickReject(dstR.roundOut());
290}
bool quickReject(const SkIRect &rect) const
Definition: SkRasterClip.h:85
void roundOut(SkIRect *dst) const
Definition: SkRect.h:1241

◆ clipped_out() [2/2]

static bool clipped_out ( const SkMatrix matrix,
const SkRasterClip clip,
int  width,
int  height 
)
static

Definition at line 292 of file SkDraw.cpp.

293 {
294 SkRect r;
295 r.setIWH(width, height);
296 return clipped_out(matrix, clip, r);
297}
static bool clipped_out(const SkMatrix &m, const SkRasterClip &c, const SkRect &srcR)
Definition: SkDraw.cpp:285
unsigned useCenter Optional< SkMatrix > matrix
Definition: SkRecords.h:258
int32_t height
int32_t width
void setIWH(int32_t width, int32_t height)
Definition: SkRect.h:950

◆ make_paint_with_image()

static SkPaint make_paint_with_image ( const SkPaint origPaint,
const SkBitmap bitmap,
const SkSamplingOptions sampling,
SkMatrix matrix = nullptr 
)
static

Definition at line 42 of file SkDraw.cpp.

44 {
45 SkPaint paint(origPaint);
49 return paint;
50}
@ kNever_SkCopyPixelsMode
never copy src pixels (even if they are marked mutable)
Definition: SkImagePriv.h:20
sk_sp< SkShader > SkMakeBitmapShaderForPaint(const SkPaint &paint, const SkBitmap &src, SkTileMode, SkTileMode, const SkSamplingOptions &, const SkMatrix *localMatrix, SkCopyPixelsMode)
const Paint & paint
Definition: color_source.cc:38
SkSamplingOptions sampling
Definition: SkRecords.h:337
Definition: bitmap.py:1

◆ make_square_rad()

static SkRect make_square_rad ( SkPoint  center,
SkScalar  radius 
)
static

Definition at line 116 of file SkDraw.cpp.

116 {
117 return {
118 center.fX - radius, center.fY - radius,
119 center.fX + radius, center.fY + radius
120 };
121}
static SkScalar center(float pos0, float pos1)

◆ make_xrect()

static SkXRect make_xrect ( const SkRect r)
static

Definition at line 123 of file SkDraw.cpp.

123 {
125 return {
128 };
129}
#define SkASSERT(cond)
Definition: SkAssert.h:116
#define SkScalarToFixed(x)
Definition: SkFixed.h:125
static bool FitsInFixed(const SkRect &r)
Definition: SkRectPriv.h:56
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