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 8 9#include "src/core/SkBlitter.h" 10#include "src/core/SkRasterClip.h" 11#include "src/core/SkScan.h" 12 13std::atomic<bool> gSkUseAnalyticAA{true}; 14std::atomic<bool> gSkForceAnalyticAA{false}; 15 16static inline void blitrect(SkBlitter* blitter, const SkIRect& r) { 17 blitter->blitRect(r.fLeft, r.fTop, r.width(), r.height()); 18} 19 20void SkScan::FillIRect(const SkIRect& r, const SkRegion* clip, 21 SkBlitter* blitter) { 22 if (!r.isEmpty()) { 23 if (clip) { 24 if (clip->isRect()) { 25 const SkIRect& clipBounds = clip->getBounds(); 26 27 if (clipBounds.contains(r)) { 28 blitrect(blitter, r); 29 } else { 30 SkIRect rr = r; 31 if (rr.intersect(clipBounds)) { 32 blitrect(blitter, rr); 33 } 34 } 35 } else { 36 SkRegion::Cliperator cliper(*clip, r); 37 const SkIRect& rr = cliper.rect(); 38 39 while (!cliper.done()) { 40 blitrect(blitter, rr); 41 cliper.next(); 42 } 43 } 44 } else { 45 blitrect(blitter, r); 46 } 47 } 48} 49 50void SkScan::FillXRect(const SkXRect& xr, const SkRegion* clip, 51 SkBlitter* blitter) { 52 SkIRect r; 53 54 XRect_round(xr, &r); 55 SkScan::FillIRect(r, clip, blitter); 56} 57 58void SkScan::FillRect(const SkRect& r, const SkRegion* clip, 59 SkBlitter* blitter) { 60 SkIRect ir; 61 62 r.round(&ir); 63 SkScan::FillIRect(ir, clip, blitter); 64} 65 66/////////////////////////////////////////////////////////////////////////////// 67 68void SkScan::FillIRect(const SkIRect& r, const SkRasterClip& clip, 69 SkBlitter* blitter) { 70 if (clip.isEmpty() || r.isEmpty()) { 71 return; 72 } 73 74 if (clip.isBW()) { 75 FillIRect(r, &clip.bwRgn(), blitter); 76 return; 77 } 78 79 SkAAClipBlitterWrapper wrapper(clip, blitter); 80 FillIRect(r, &wrapper.getRgn(), wrapper.getBlitter()); 81} 82 83void SkScan::FillXRect(const SkXRect& xr, const SkRasterClip& clip, 84 SkBlitter* blitter) { 85 if (clip.isEmpty() || xr.isEmpty()) { 86 return; 87 } 88 89 if (clip.isBW()) { 90 FillXRect(xr, &clip.bwRgn(), blitter); 91 return; 92 } 93 94 SkAAClipBlitterWrapper wrapper(clip, blitter); 95 FillXRect(xr, &wrapper.getRgn(), wrapper.getBlitter()); 96} 97 98void SkScan::FillRect(const SkRect& r, const SkRasterClip& clip, 99 SkBlitter* blitter) { 100 if (clip.isEmpty() || r.isEmpty()) { 101 return; 102 } 103 104 if (clip.isBW()) { 105 FillRect(r, &clip.bwRgn(), blitter); 106 return; 107 } 108 109 SkAAClipBlitterWrapper wrapper(clip, blitter); 110 FillRect(r, &wrapper.getRgn(), wrapper.getBlitter()); 111} 112