tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

image_helper.rs (782B)


      1 /* This Source Code Form is subject to the terms of the Mozilla Public
      2 * License, v. 2.0. If a copy of the MPL was not distributed with this
      3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
      4 
      5 use webrender::api::{ImageData, ImageDescriptor, ImageFormat, ImageDescriptorFlags};
      6 
      7 pub fn make_checkerboard(width: u32, height: u32) -> (ImageDescriptor, ImageData) {
      8    let mut image_data = Vec::new();
      9    for y in 0 .. height {
     10        for x in 0 .. width {
     11            let lum = 255 * (((x & 8) == 0) ^ ((y & 8) == 0)) as u8;
     12            image_data.extend_from_slice(&[lum, lum, lum, 0xff]);
     13        }
     14    }
     15    (
     16        ImageDescriptor::new(width as i32, height as i32, ImageFormat::BGRA8, ImageDescriptorFlags::IS_OPAQUE),
     17        ImageData::new(image_data)
     18    )
     19 }