blob: b21dd6bf9c6822f4b03abcb17d66a8fd780a4a0b [file] [log] [blame]
epoger@google.comec3ed6a2011-07-28 14:26:00 +00001
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
reed@android.com8a1c16f2008-12-17 15:59:43 +00009
10#include "SkScan.h"
11#include "SkBlitter.h"
reed@google.comda965632011-10-13 15:29:01 +000012#include "SkRasterClip.h"
reed@android.com8a1c16f2008-12-17 15:59:43 +000013
14static inline void blitrect(SkBlitter* blitter, const SkIRect& r) {
15 blitter->blitRect(r.fLeft, r.fTop, r.width(), r.height());
16}
17
18void SkScan::FillIRect(const SkIRect& r, const SkRegion* clip,
19 SkBlitter* blitter) {
20 if (!r.isEmpty()) {
21 if (clip) {
22 if (clip->isRect()) {
23 const SkIRect& clipBounds = clip->getBounds();
rmistry@google.comfbfcd562012-08-23 18:09:54 +000024
reed@android.com8a1c16f2008-12-17 15:59:43 +000025 if (clipBounds.contains(r)) {
26 blitrect(blitter, r);
27 } else {
28 SkIRect rr = r;
29 if (rr.intersect(clipBounds)) {
30 blitrect(blitter, rr);
31 }
32 }
33 } else {
34 SkRegion::Cliperator cliper(*clip, r);
35 const SkIRect& rr = cliper.rect();
rmistry@google.comfbfcd562012-08-23 18:09:54 +000036
reed@android.com8a1c16f2008-12-17 15:59:43 +000037 while (!cliper.done()) {
38 blitrect(blitter, rr);
39 cliper.next();
40 }
41 }
42 } else {
43 blitrect(blitter, r);
44 }
45 }
46}
47
48void SkScan::FillXRect(const SkXRect& xr, const SkRegion* clip,
49 SkBlitter* blitter) {
50 SkIRect r;
rmistry@google.comfbfcd562012-08-23 18:09:54 +000051
reed@android.com8a1c16f2008-12-17 15:59:43 +000052 XRect_round(xr, &r);
53 SkScan::FillIRect(r, clip, blitter);
54}
55
reed@android.com8a1c16f2008-12-17 15:59:43 +000056void SkScan::FillRect(const SkRect& r, const SkRegion* clip,
57 SkBlitter* blitter) {
58 SkIRect ir;
rmistry@google.comfbfcd562012-08-23 18:09:54 +000059
reed@android.com8a1c16f2008-12-17 15:59:43 +000060 r.round(&ir);
61 SkScan::FillIRect(ir, clip, blitter);
62}
63
reed@google.comda965632011-10-13 15:29:01 +000064///////////////////////////////////////////////////////////////////////////////
65
66void SkScan::FillIRect(const SkIRect& r, const SkRasterClip& clip,
67 SkBlitter* blitter) {
68 if (clip.isEmpty() || r.isEmpty()) {
69 return;
70 }
rmistry@google.comfbfcd562012-08-23 18:09:54 +000071
reed@google.comda965632011-10-13 15:29:01 +000072 if (clip.isBW()) {
73 FillIRect(r, &clip.bwRgn(), blitter);
74 return;
75 }
76
reed@google.com045e62d2011-10-24 12:19:46 +000077 SkAAClipBlitterWrapper wrapper(clip, blitter);
78 FillIRect(r, &wrapper.getRgn(), wrapper.getBlitter());
reed@google.comda965632011-10-13 15:29:01 +000079}
80
reed@google.com045e62d2011-10-24 12:19:46 +000081void SkScan::FillXRect(const SkXRect& xr, const SkRasterClip& clip,
82 SkBlitter* blitter) {
83 if (clip.isEmpty() || xr.isEmpty()) {
84 return;
85 }
rmistry@google.comfbfcd562012-08-23 18:09:54 +000086
reed@google.com045e62d2011-10-24 12:19:46 +000087 if (clip.isBW()) {
88 FillXRect(xr, &clip.bwRgn(), blitter);
89 return;
90 }
91
92 SkAAClipBlitterWrapper wrapper(clip, blitter);
93 FillXRect(xr, &wrapper.getRgn(), wrapper.getBlitter());
94}
95
reed@google.com045e62d2011-10-24 12:19:46 +000096void SkScan::FillRect(const SkRect& r, const SkRasterClip& clip,
97 SkBlitter* blitter) {
98 if (clip.isEmpty() || r.isEmpty()) {
99 return;
100 }
rmistry@google.comfbfcd562012-08-23 18:09:54 +0000101
reed@google.com045e62d2011-10-24 12:19:46 +0000102 if (clip.isBW()) {
103 FillRect(r, &clip.bwRgn(), blitter);
104 return;
105 }
106
107 SkAAClipBlitterWrapper wrapper(clip, blitter);
108 FillRect(r, &wrapper.getRgn(), wrapper.getBlitter());
109}