Flutter Engine
The Flutter Engine
SkScan.cpp
Go to the documentation of this file.
1/*
2 * Copyright 2006 The Android Open Source Project
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#include "src/core/SkScan.h"
8
10#include "src/core/SkBlitter.h"
12
13static inline void blitrect(SkBlitter* blitter, const SkIRect& r) {
14 blitter->blitRect(r.fLeft, r.fTop, r.width(), r.height());
15}
16
17void SkScan::FillIRect(const SkIRect& r, const SkRegion* clip,
18 SkBlitter* blitter) {
19 if (!r.isEmpty()) {
20 if (clip) {
21 if (clip->isRect()) {
22 const SkIRect& clipBounds = clip->getBounds();
23
24 if (clipBounds.contains(r)) {
25 blitrect(blitter, r);
26 } else {
27 SkIRect rr = r;
28 if (rr.intersect(clipBounds)) {
29 blitrect(blitter, rr);
30 }
31 }
32 } else {
33 SkRegion::Cliperator cliper(*clip, r);
34 const SkIRect& rr = cliper.rect();
35
36 while (!cliper.done()) {
37 blitrect(blitter, rr);
38 cliper.next();
39 }
40 }
41 } else {
42 blitrect(blitter, r);
43 }
44 }
45}
46
47void SkScan::FillXRect(const SkXRect& xr, const SkRegion* clip,
48 SkBlitter* blitter) {
49 SkIRect r;
50
51 XRect_round(xr, &r);
52 SkScan::FillIRect(r, clip, blitter);
53}
54
55void SkScan::FillRect(const SkRect& r, const SkRegion* clip,
56 SkBlitter* blitter) {
57 SkIRect ir;
58
59 r.round(&ir);
60 SkScan::FillIRect(ir, clip, blitter);
61}
62
63///////////////////////////////////////////////////////////////////////////////
64
66 SkBlitter* blitter) {
67 if (clip.isEmpty() || r.isEmpty()) {
68 return;
69 }
70
71 if (clip.isBW()) {
72 FillIRect(r, &clip.bwRgn(), blitter);
73 return;
74 }
75
76 SkAAClipBlitterWrapper wrapper(clip, blitter);
77 FillIRect(r, &wrapper.getRgn(), wrapper.getBlitter());
78}
79
81 SkBlitter* blitter) {
82 if (clip.isEmpty() || xr.isEmpty()) {
83 return;
84 }
85
86 if (clip.isBW()) {
87 FillXRect(xr, &clip.bwRgn(), blitter);
88 return;
89 }
90
91 SkAAClipBlitterWrapper wrapper(clip, blitter);
92 FillXRect(xr, &wrapper.getRgn(), wrapper.getBlitter());
93}
94
96 SkBlitter* blitter) {
97 if (clip.isEmpty() || r.isEmpty()) {
98 return;
99 }
100
101 if (clip.isBW()) {
102 FillRect(r, &clip.bwRgn(), blitter);
103 return;
104 }
105
106 SkAAClipBlitterWrapper wrapper(clip, blitter);
107 FillRect(r, &wrapper.getRgn(), wrapper.getBlitter());
108}
static SkPath clip(const SkPath &path, const SkHalfPlane &plane)
Definition: SkPath.cpp:3892
static void blitrect(SkBlitter *blitter, const SkIRect &r)
Definition: SkScan.cpp:13
static void XRect_round(const SkXRect &xr, SkIRect *dst)
Definition: SkScan.h:118
const SkRegion & getRgn() const
Definition: SkRasterClip.h:175
SkBlitter * getBlitter()
Definition: SkRasterClip.h:179
virtual void blitRect(int x, int y, int width, int height)
Blit a solid rectangle one or more pixels wide.
Definition: SkBlitter.cpp:133
bool isEmpty() const
Definition: SkPath.cpp:416
const SkRect & getBounds() const
Definition: SkPath.cpp:430
bool isRect(SkRect *rect, bool *isClosed=nullptr, SkPathDirection *direction=nullptr) const
Definition: SkPath.cpp:516
static void FillXRect(const SkXRect &, const SkRasterClip &, SkBlitter *)
Definition: SkScan.cpp:80
static void FillRect(const SkRect &, const SkRasterClip &, SkBlitter *)
Definition: SkScan.cpp:95
static void FillIRect(const SkIRect &, const SkRasterClip &, SkBlitter *)
Definition: SkScan.cpp:65
Definition: SkRect.h:32
bool intersect(const SkIRect &r)
Definition: SkRect.h:513
constexpr int32_t height() const
Definition: SkRect.h:165
int32_t fTop
smaller y-axis bounds
Definition: SkRect.h:34
constexpr int32_t width() const
Definition: SkRect.h:158
bool isEmpty() const
Definition: SkRect.h:202
int32_t fLeft
smaller x-axis bounds
Definition: SkRect.h:33
bool contains(int32_t x, int32_t y) const
Definition: SkRect.h:463
void round(SkIRect *dst) const
Definition: SkRect.h:1228
bool isEmpty() const
Definition: SkRect.h:693