Update the WebGL backend

This commit is contained in:
Patrick Walton 2020-06-23 13:08:02 -07:00
parent 769dae4a9c
commit 7a1db16340
1 changed files with 18 additions and 1 deletions

View File

@ -13,6 +13,7 @@
#[macro_use] #[macro_use]
extern crate log; extern crate log;
use js_sys::{Uint8Array, Uint16Array, Float32Array, Object};
use pathfinder_geometry::rect::RectI; use pathfinder_geometry::rect::RectI;
use pathfinder_geometry::vector::Vector2I; use pathfinder_geometry::vector::Vector2I;
use pathfinder_gpu::{BlendFactor, BlendOp, BufferData, BufferTarget, BufferUploadMode, ClearOps}; use pathfinder_gpu::{BlendFactor, BlendOp, BufferData, BufferTarget, BufferUploadMode, ClearOps};
@ -24,11 +25,11 @@ use pathfinder_gpu::{VertexAttrClass, VertexAttrDescriptor, VertexAttrType};
use pathfinder_resources::ResourceLoader; use pathfinder_resources::ResourceLoader;
use std::cell::RefCell; use std::cell::RefCell;
use std::mem; use std::mem;
use std::ops::Range;
use std::str; use std::str;
use std::time::Duration; use std::time::Duration;
use wasm_bindgen::JsCast; use wasm_bindgen::JsCast;
use web_sys::WebGl2RenderingContext as WebGl; use web_sys::WebGl2RenderingContext as WebGl;
use js_sys::{Uint8Array, Uint16Array, Float32Array, Object};
pub struct WebGlDevice { pub struct WebGlDevice {
context: web_sys::WebGl2RenderingContext, context: web_sys::WebGl2RenderingContext,
@ -426,6 +427,7 @@ unsafe fn check_and_extract_data(
impl Device for WebGlDevice { impl Device for WebGlDevice {
type Buffer = WebGlBuffer; type Buffer = WebGlBuffer;
type BufferDataReceiver = ();
type Fence = (); type Fence = ();
type Framebuffer = WebGlFramebuffer; type Framebuffer = WebGlFramebuffer;
type ImageParameter = (); type ImageParameter = ();
@ -943,9 +945,23 @@ impl Device for WebGlDevice {
fn recv_timer_query(&self, _query: &WebGlTimerQuery) -> Duration { fn recv_timer_query(&self, _query: &WebGlTimerQuery) -> Duration {
Duration::from_millis(0) Duration::from_millis(0)
} }
fn try_recv_buffer(&self, _: &()) -> Option<Vec<u8>> {
unimplemented!()
}
fn recv_buffer(&self, _: &()) -> Vec<u8> {
unimplemented!()
}
fn read_buffer(&self, _: &Self::Buffer, _: BufferTarget, _: Range<usize>) {
unimplemented!()
}
fn try_recv_texture_data(&self, _receiver: &Self::TextureDataReceiver) -> Option<TextureData> { fn try_recv_texture_data(&self, _receiver: &Self::TextureDataReceiver) -> Option<TextureData> {
None None
} }
fn recv_texture_data(&self, _receiver: &Self::TextureDataReceiver) -> TextureData { fn recv_texture_data(&self, _receiver: &Self::TextureDataReceiver) -> TextureData {
unimplemented!() unimplemented!()
} }
@ -1175,6 +1191,7 @@ impl VertexAttrTypeExt for VertexAttrType {
fn to_gl_type(self) -> u32 { fn to_gl_type(self) -> u32 {
match self { match self {
VertexAttrType::F32 => WebGl::FLOAT, VertexAttrType::F32 => WebGl::FLOAT,
VertexAttrType::I32 => WebGl::INT,
VertexAttrType::I16 => WebGl::SHORT, VertexAttrType::I16 => WebGl::SHORT,
VertexAttrType::I8 => WebGl::BYTE, VertexAttrType::I8 => WebGl::BYTE,
VertexAttrType::U16 => WebGl::UNSIGNED_SHORT, VertexAttrType::U16 => WebGl::UNSIGNED_SHORT,