Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Isolate GL calls to the device only #480

Merged
merged 3 commits into from Oct 27, 2016
Merged
Changes from 1 commit
Commits
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.

Always

Just for now

Removed GL dependency from render_backend and debug_render

  • Loading branch information
kvark committed Oct 27, 2016
commit d541c91302432d5bf66417e3c2df85a6773e6ead
@@ -6,7 +6,6 @@ use debug_font_data;
use device::{Device, ProgramId, VAOId, TextureId, VertexFormat};
use device::{TextureFilter, VertexUsageHint, TextureTarget};
use euclid::{Matrix4D, Point2D, Size2D, Rect};
use gleam::gl;
use internal_types::{ORTHO_NEAR_PLANE, ORTHO_FAR_PLANE, TextureSampler};
use internal_types::{DebugFontVertex, DebugColorVertex, RenderTargetMode, PackedColor};
use std::f32;
@@ -165,11 +164,10 @@ impl DebugRenderer {
if !self.font_indices.is_empty() ||
!self.line_vertices.is_empty() ||
!self.tri_vertices.is_empty() {
gl::disable(gl::DEPTH_TEST);
gl::enable(gl::BLEND);
gl::blend_equation(gl::FUNC_ADD);
gl::blend_func_separate(gl::SRC_ALPHA, gl::ONE_MINUS_SRC_ALPHA,
gl::ONE, gl::ONE);

device.disable_depth();
device.set_blend(true);
device.set_blend_mode_alpha();

let projection = Matrix4D::ortho(0.0,
viewport_size.width as f32,
@@ -187,14 +185,14 @@ impl DebugRenderer {
device.update_vao_main_vertices(self.tri_vao,
&self.tri_vertices,
VertexUsageHint::Dynamic);
device.draw_triangles_u32(0, self.tri_indices.len() as gl::GLint);
device.draw_triangles_u32(0, self.tri_indices.len() as i32);

// Lines
device.bind_vao(self.line_vao);
device.update_vao_main_vertices(self.line_vao,
&self.line_vertices,
VertexUsageHint::Dynamic);
device.draw_nonindexed_lines(0, self.line_vertices.len() as gl::GLint);
device.draw_nonindexed_lines(0, self.line_vertices.len() as i32);

// Glyphs
device.bind_program(self.font_program_id, &projection);
@@ -206,7 +204,7 @@ impl DebugRenderer {
device.update_vao_main_vertices(self.font_vao,
&self.font_vertices,
VertexUsageHint::Dynamic);
device.draw_triangles_u32(0, self.font_indices.len() as gl::GLint);
device.draw_triangles_u32(0, self.font_indices.len() as i32);
}

self.font_indices.clear();
@@ -1794,7 +1794,9 @@ impl Device {
}

pub fn set_blend_mode_alpha(&self) {
gl::blend_func(gl::SRC_ALPHA, gl::ONE_MINUS_SRC_ALPHA);
//gl::blend_func(gl::SRC_ALPHA, gl::ONE_MINUS_SRC_ALPHA);
gl::blend_func_separate(gl::SRC_ALPHA, gl::ONE_MINUS_SRC_ALPHA,
gl::ONE, gl::ONE);
gl::blend_equation(gl::FUNC_ADD);
}
}
@@ -16,14 +16,14 @@ use std::sync::{Arc, Mutex};
use std::sync::mpsc::Sender;
use texture_cache::TextureCache;
use webrender_traits::{ApiMsg, AuxiliaryLists, BuiltDisplayList, IdNamespace};
use webrender_traits::{RenderNotifier, WebGLContextId, RenderDispatcher};
use webrender_traits::{RenderNotifier, RenderDispatcher, WebGLCommand, WebGLContextId};
use batch::new_id;
use device::TextureId;
use record;
use tiling::FrameBuilderConfig;
use gleam::gl;
use offscreen_gl_context::GLContextDispatcher;


pub struct RenderBackend {
api_rx: IpcReceiver<ApiMsg>,
payload_rx: IpcBytesReceiver,
@@ -335,7 +335,7 @@ impl RenderBackend {
// incur minimal cost.
for (_, webgl_context) in &self.webgl_contexts {
webgl_context.make_current();
gl::flush();
webgl_context.apply_command(WebGLCommand::Flush);
webgl_context.unbind();
}

ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.