2017-01-11 23:44:10 -05:00
|
|
|
// Copyright 2017 The Servo Project Developers. See the COPYRIGHT
|
|
|
|
// file at the top-level directory of this distribution and at
|
|
|
|
// http://rust-lang.org/COPYRIGHT.
|
|
|
|
//
|
|
|
|
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
|
|
|
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
|
|
|
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
|
|
|
// option. This file may not be copied, modified, or distributed
|
|
|
|
// except according to those terms.
|
|
|
|
|
2017-01-23 22:39:51 -05:00
|
|
|
use compute_shader::buffer::Protection;
|
2017-01-11 23:44:10 -05:00
|
|
|
use compute_shader::device::Device;
|
2017-01-23 22:39:51 -05:00
|
|
|
use compute_shader::texture::{Format, Texture};
|
2017-01-11 23:44:10 -05:00
|
|
|
use euclid::size::Size2D;
|
|
|
|
use std::mem;
|
|
|
|
|
|
|
|
pub struct CoverageBuffer {
|
2017-01-23 22:39:51 -05:00
|
|
|
pub texture: Texture,
|
2017-01-11 23:44:10 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
impl CoverageBuffer {
|
|
|
|
pub fn new(device: &Device, size: &Size2D<u32>) -> Result<CoverageBuffer, ()> {
|
2017-01-23 22:39:51 -05:00
|
|
|
let texture = try!(device.create_texture(Format::R32F, Protection::ReadWrite, size)
|
|
|
|
.map_err(drop));
|
2017-01-11 23:44:10 -05:00
|
|
|
Ok(CoverageBuffer {
|
2017-01-23 22:39:51 -05:00
|
|
|
texture: texture,
|
2017-01-11 23:44:10 -05:00
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|