1 :
2 : /*
3 : * Copyright 2006 The Android Open Source Project
4 : *
5 : * Use of this source code is governed by a BSD-style license that can be
6 : * found in the LICENSE file.
7 : */
8 :
9 :
10 : #include "SkScan.h"
11 : #include "SkBlitter.h"
12 : #include "SkRasterClip.h"
13 :
14 0 : static inline void blitrect(SkBlitter* blitter, const SkIRect& r) {
15 0 : blitter->blitRect(r.fLeft, r.fTop, r.width(), r.height());
16 0 : }
17 :
18 0 : void SkScan::FillIRect(const SkIRect& r, const SkRegion* clip,
19 : SkBlitter* blitter) {
20 0 : if (!r.isEmpty()) {
21 0 : if (clip) {
22 0 : if (clip->isRect()) {
23 0 : const SkIRect& clipBounds = clip->getBounds();
24 :
25 0 : if (clipBounds.contains(r)) {
26 0 : blitrect(blitter, r);
27 : } else {
28 0 : SkIRect rr = r;
29 0 : if (rr.intersect(clipBounds)) {
30 0 : blitrect(blitter, rr);
31 : }
32 : }
33 : } else {
34 0 : SkRegion::Cliperator cliper(*clip, r);
35 0 : const SkIRect& rr = cliper.rect();
36 :
37 0 : while (!cliper.done()) {
38 0 : blitrect(blitter, rr);
39 0 : cliper.next();
40 : }
41 : }
42 : } else {
43 0 : blitrect(blitter, r);
44 : }
45 : }
46 0 : }
47 :
48 0 : void SkScan::FillXRect(const SkXRect& xr, const SkRegion* clip,
49 : SkBlitter* blitter) {
50 : SkIRect r;
51 :
52 0 : XRect_round(xr, &r);
53 0 : SkScan::FillIRect(r, clip, blitter);
54 0 : }
55 :
56 : #ifdef SK_SCALAR_IS_FLOAT
57 :
58 0 : void SkScan::FillRect(const SkRect& r, const SkRegion* clip,
59 : SkBlitter* blitter) {
60 : SkIRect ir;
61 :
62 0 : r.round(&ir);
63 0 : SkScan::FillIRect(ir, clip, blitter);
64 0 : }
65 :
66 : #endif
67 :
68 : ///////////////////////////////////////////////////////////////////////////////
69 :
70 0 : void SkScan::FillIRect(const SkIRect& r, const SkRasterClip& clip,
71 : SkBlitter* blitter) {
72 0 : if (clip.isEmpty() || r.isEmpty()) {
73 0 : return;
74 : }
75 :
76 0 : if (clip.isBW()) {
77 0 : FillIRect(r, &clip.bwRgn(), blitter);
78 0 : return;
79 : }
80 :
81 0 : SkAAClipBlitterWrapper wrapper(clip, blitter);
82 0 : FillIRect(r, &wrapper.getRgn(), wrapper.getBlitter());
83 : }
84 :
85 0 : void SkScan::FillXRect(const SkXRect& xr, const SkRasterClip& clip,
86 : SkBlitter* blitter) {
87 0 : if (clip.isEmpty() || xr.isEmpty()) {
88 0 : return;
89 : }
90 :
91 0 : if (clip.isBW()) {
92 0 : FillXRect(xr, &clip.bwRgn(), blitter);
93 0 : return;
94 : }
95 :
96 0 : SkAAClipBlitterWrapper wrapper(clip, blitter);
97 0 : FillXRect(xr, &wrapper.getRgn(), wrapper.getBlitter());
98 : }
99 :
100 : #ifdef SK_SCALAR_IS_FLOAT
101 :
102 0 : void SkScan::FillRect(const SkRect& r, const SkRasterClip& clip,
103 : SkBlitter* blitter) {
104 0 : if (clip.isEmpty() || r.isEmpty()) {
105 0 : return;
106 : }
107 :
108 0 : if (clip.isBW()) {
109 0 : FillRect(r, &clip.bwRgn(), blitter);
110 0 : return;
111 : }
112 :
113 0 : SkAAClipBlitterWrapper wrapper(clip, blitter);
114 0 : FillRect(r, &wrapper.getRgn(), wrapper.getBlitter());
115 : }
116 :
117 : #endif
118 :
|