Skip to content

Commit

Permalink
Don't push commands if there are no vertices
Browse files Browse the repository at this point in the history
  • Loading branch information
jbg committed Aug 18, 2017
1 parent 1f44dc4 commit cfab936
Showing 1 changed file with 29 additions and 11 deletions.
40 changes: 29 additions & 11 deletions src/backend/glium.rs
Original file line number Diff line number Diff line change
Expand Up @@ -447,7 +447,9 @@ impl Renderer {
match current_state {
State::Plain { .. } => (),
State::Image { image_id, start } => {
commands.push(PreparedCommand::Image(image_id, start..vertices.len()));
if vertices.len() > start {
commands.push(PreparedCommand::Image(image_id, start..vertices.len()));
}
current_state = State::Plain { start: vertices.len() };
},
}
Expand Down Expand Up @@ -495,10 +497,16 @@ impl Renderer {
if new_scizzor != current_scizzor {
// Finish the current command.
match current_state {
State::Plain { start } =>
commands.push(PreparedCommand::Plain(start..vertices.len())),
State::Image { image_id, start } =>
commands.push(PreparedCommand::Image(image_id, start..vertices.len())),
State::Plain { start } => {
if vertices.len() > start {
commands.push(PreparedCommand::Plain(start..vertices.len()));
}
},
State::Image { image_id, start } => {
if vertices.len() > start {
commands.push(PreparedCommand::Image(image_id, start..vertices.len()));
}
},
}

// Update the scizzor and produce a command.
Expand Down Expand Up @@ -682,7 +690,9 @@ impl Renderer {

// If we were in the `Plain` drawing state, switch to Image drawing state.
State::Plain { start } => {
commands.push(PreparedCommand::Plain(start..vertices.len()));
if vertices.len() > start {
commands.push(PreparedCommand::Plain(start..vertices.len()));
}
current_state = State::Image {
image_id: new_image_id,
start: vertices.len(),
Expand All @@ -691,7 +701,9 @@ impl Renderer {

// If we were drawing a different image, switch state to draw *this* image.
State::Image { image_id, start } => {
commands.push(PreparedCommand::Image(image_id, start..vertices.len()));
if vertices.len() > start {
commands.push(PreparedCommand::Image(image_id, start..vertices.len()));
}
current_state = State::Image {
image_id: new_image_id,
start: vertices.len(),
Expand Down Expand Up @@ -755,10 +767,16 @@ impl Renderer {

// Enter the final command.
match current_state {
State::Plain { start } =>
commands.push(PreparedCommand::Plain(start..vertices.len())),
State::Image { image_id, start } =>
commands.push(PreparedCommand::Image(image_id, start..vertices.len())),
State::Plain { start } => {
if vertices.len() > start {
commands.push(PreparedCommand::Plain(start..vertices.len()));
}
},
State::Image { image_id, start } => {
if vertices.len() > start {
commands.push(PreparedCommand::Image(image_id, start..vertices.len()));
}
},
}
}

Expand Down

0 comments on commit cfab936

Please sign in to comment.