michael@0: michael@0: /* michael@0: * Copyright 2006 The Android Open Source Project michael@0: * michael@0: * Use of this source code is governed by a BSD-style license that can be michael@0: * found in the LICENSE file. michael@0: */ michael@0: michael@0: michael@0: #include "SkScan.h" michael@0: #include "SkBlitter.h" michael@0: #include "SkRasterClip.h" michael@0: michael@0: static inline void blitrect(SkBlitter* blitter, const SkIRect& r) { michael@0: blitter->blitRect(r.fLeft, r.fTop, r.width(), r.height()); michael@0: } michael@0: michael@0: void SkScan::FillIRect(const SkIRect& r, const SkRegion* clip, michael@0: SkBlitter* blitter) { michael@0: if (!r.isEmpty()) { michael@0: if (clip) { michael@0: if (clip->isRect()) { michael@0: const SkIRect& clipBounds = clip->getBounds(); michael@0: michael@0: if (clipBounds.contains(r)) { michael@0: blitrect(blitter, r); michael@0: } else { michael@0: SkIRect rr = r; michael@0: if (rr.intersect(clipBounds)) { michael@0: blitrect(blitter, rr); michael@0: } michael@0: } michael@0: } else { michael@0: SkRegion::Cliperator cliper(*clip, r); michael@0: const SkIRect& rr = cliper.rect(); michael@0: michael@0: while (!cliper.done()) { michael@0: blitrect(blitter, rr); michael@0: cliper.next(); michael@0: } michael@0: } michael@0: } else { michael@0: blitrect(blitter, r); michael@0: } michael@0: } michael@0: } michael@0: michael@0: void SkScan::FillXRect(const SkXRect& xr, const SkRegion* clip, michael@0: SkBlitter* blitter) { michael@0: SkIRect r; michael@0: michael@0: XRect_round(xr, &r); michael@0: SkScan::FillIRect(r, clip, blitter); michael@0: } michael@0: michael@0: void SkScan::FillRect(const SkRect& r, const SkRegion* clip, michael@0: SkBlitter* blitter) { michael@0: SkIRect ir; michael@0: michael@0: r.round(&ir); michael@0: SkScan::FillIRect(ir, clip, blitter); michael@0: } michael@0: michael@0: /////////////////////////////////////////////////////////////////////////////// michael@0: michael@0: void SkScan::FillIRect(const SkIRect& r, const SkRasterClip& clip, michael@0: SkBlitter* blitter) { michael@0: if (clip.isEmpty() || r.isEmpty()) { michael@0: return; michael@0: } michael@0: michael@0: if (clip.isBW()) { michael@0: FillIRect(r, &clip.bwRgn(), blitter); michael@0: return; michael@0: } michael@0: michael@0: SkAAClipBlitterWrapper wrapper(clip, blitter); michael@0: FillIRect(r, &wrapper.getRgn(), wrapper.getBlitter()); michael@0: } michael@0: michael@0: void SkScan::FillXRect(const SkXRect& xr, const SkRasterClip& clip, michael@0: SkBlitter* blitter) { michael@0: if (clip.isEmpty() || xr.isEmpty()) { michael@0: return; michael@0: } michael@0: michael@0: if (clip.isBW()) { michael@0: FillXRect(xr, &clip.bwRgn(), blitter); michael@0: return; michael@0: } michael@0: michael@0: SkAAClipBlitterWrapper wrapper(clip, blitter); michael@0: FillXRect(xr, &wrapper.getRgn(), wrapper.getBlitter()); michael@0: } michael@0: michael@0: void SkScan::FillRect(const SkRect& r, const SkRasterClip& clip, michael@0: SkBlitter* blitter) { michael@0: if (clip.isEmpty() || r.isEmpty()) { michael@0: return; michael@0: } michael@0: michael@0: if (clip.isBW()) { michael@0: FillRect(r, &clip.bwRgn(), blitter); michael@0: return; michael@0: } michael@0: michael@0: SkAAClipBlitterWrapper wrapper(clip, blitter); michael@0: FillRect(r, &wrapper.getRgn(), wrapper.getBlitter()); michael@0: }