tiny_skia/scan/
mod.rs

1// Copyright 2011 The Android Open Source Project
2// Copyright 2020 Yevhenii Reizner
3//
4// Use of this source code is governed by a BSD-style license that can be
5// found in the LICENSE file.
6
7pub mod hairline;
8pub mod hairline_aa;
9pub mod path;
10pub mod path_aa;
11
12use crate::{IntRect, Rect};
13
14use crate::blitter::Blitter;
15use crate::geom::{IntRectExt, ScreenIntRect};
16
17pub fn fill_rect(rect: &Rect, clip: &ScreenIntRect, blitter: &mut dyn Blitter) {
18    if let Some(rect) = rect.round() {
19        fill_int_rect(&rect, clip, blitter);
20    }
21}
22
23fn fill_int_rect(rect: &IntRect, clip: &ScreenIntRect, blitter: &mut dyn Blitter) {
24    let rect = match rect.intersect(&clip.to_int_rect()) {
25        Some(v) => v,
26        None => return, // everything was clipped out
27    };
28
29    let rect = match rect.to_screen_int_rect() {
30        Some(v) => v,
31        None => return,
32    };
33
34    blitter.blit_rect(&rect);
35}
36
37pub fn fill_rect_aa(rect: &Rect, clip: &ScreenIntRect, blitter: &mut dyn Blitter) {
38    hairline_aa::fill_rect(rect, clip, blitter);
39}