Home | History | Annotate | Download | only in core
      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 static inline void blitrect(SkBlitter* blitter, const SkIRect& r) {
     15     blitter->blitRect(r.fLeft, r.fTop, r.width(), r.height());
     16 }
     17 
     18 void 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();
     24 
     25                 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();
     36 
     37                 while (!cliper.done()) {
     38                     blitrect(blitter, rr);
     39                     cliper.next();
     40                 }
     41             }
     42         } else {
     43             blitrect(blitter, r);
     44         }
     45     }
     46 }
     47 
     48 void SkScan::FillXRect(const SkXRect& xr, const SkRegion* clip,
     49                        SkBlitter* blitter) {
     50     SkIRect r;
     51 
     52     XRect_round(xr, &r);
     53     SkScan::FillIRect(r, clip, blitter);
     54 }
     55 
     56 void SkScan::FillRect(const SkRect& r, const SkRegion* clip,
     57                        SkBlitter* blitter) {
     58     SkIRect ir;
     59 
     60     r.round(&ir);
     61     SkScan::FillIRect(ir, clip, blitter);
     62 }
     63 
     64 ///////////////////////////////////////////////////////////////////////////////
     65 
     66 void SkScan::FillIRect(const SkIRect& r, const SkRasterClip& clip,
     67                        SkBlitter* blitter) {
     68     if (clip.isEmpty() || r.isEmpty()) {
     69         return;
     70     }
     71 
     72     if (clip.isBW()) {
     73         FillIRect(r, &clip.bwRgn(), blitter);
     74         return;
     75     }
     76 
     77     SkAAClipBlitterWrapper wrapper(clip, blitter);
     78     FillIRect(r, &wrapper.getRgn(), wrapper.getBlitter());
     79 }
     80 
     81 void SkScan::FillXRect(const SkXRect& xr, const SkRasterClip& clip,
     82                        SkBlitter* blitter) {
     83     if (clip.isEmpty() || xr.isEmpty()) {
     84         return;
     85     }
     86 
     87     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 
     96 void SkScan::FillRect(const SkRect& r, const SkRasterClip& clip,
     97                       SkBlitter* blitter) {
     98     if (clip.isEmpty() || r.isEmpty()) {
     99         return;
    100     }
    101 
    102     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 }
    110