implements PLN-0087
This commit is contained in:
@@ -661,9 +661,7 @@ impl Gfx {
|
||||
self.load_frame_sprites(&sprites);
|
||||
self.render_no_scene_frame();
|
||||
|
||||
for command in &packet.gfx2d {
|
||||
self.apply_gfx2d_command(command);
|
||||
}
|
||||
self.apply_gfx2d_commands(&packet.gfx2d);
|
||||
}
|
||||
|
||||
pub fn render_shell_ui_frame_packet(&mut self, packet: &ShellUiFramePacket) {
|
||||
@@ -672,6 +670,12 @@ impl Gfx {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn apply_gfx2d_commands(&mut self, commands: &[Gfx2dCommand]) {
|
||||
for command in commands {
|
||||
self.apply_gfx2d_command(command);
|
||||
}
|
||||
}
|
||||
|
||||
fn apply_gfx2d_command(&mut self, command: &Gfx2dCommand) {
|
||||
match command {
|
||||
Gfx2dCommand::Clear { color } => self.clear(*color),
|
||||
|
||||
@@ -79,6 +79,7 @@ impl HardwareBridge for Hardware {
|
||||
self.gfx.render_game2d_frame_packet(packet);
|
||||
} else {
|
||||
self.frame_composer.render_frame(&mut self.gfx);
|
||||
self.gfx.apply_gfx2d_commands(&packet.gfx2d);
|
||||
}
|
||||
}
|
||||
RenderSubmissionPacket::ShellUi(packet) => {
|
||||
@@ -187,12 +188,14 @@ mod tests {
|
||||
use prometeu_hal::color::Color;
|
||||
use prometeu_hal::glyph::Glyph;
|
||||
use prometeu_hal::glyph_bank::{GlyphBank, TileSize};
|
||||
use prometeu_hal::primitives::Rect;
|
||||
use prometeu_hal::scene_bank::SceneBank;
|
||||
use prometeu_hal::scene_layer::{ParallaxFactor, SceneLayer};
|
||||
use prometeu_hal::scene_viewport_cache::SceneViewportCache;
|
||||
use prometeu_hal::scene_viewport_resolver::SceneViewportResolver;
|
||||
use prometeu_hal::tile::Tile;
|
||||
use prometeu_hal::tilemap::TileMap;
|
||||
use prometeu_hal::{FrameId, Gfx2dCommand};
|
||||
|
||||
fn make_glyph_bank() -> GlyphBank {
|
||||
let mut bank = GlyphBank::new(TileSize::Size8, 8, 8);
|
||||
@@ -204,9 +207,13 @@ mod tests {
|
||||
}
|
||||
|
||||
fn make_scene() -> SceneBank {
|
||||
make_scene_with_glyph_asset_id(1)
|
||||
}
|
||||
|
||||
fn make_scene_with_glyph_asset_id(glyph_asset_id: i32) -> SceneBank {
|
||||
let layer = SceneLayer {
|
||||
active: true,
|
||||
glyph_asset_id: 1,
|
||||
glyph_asset_id,
|
||||
tile_size: TileSize::Size8,
|
||||
parallax_factor: ParallaxFactor { x: 1.0, y: 1.0 },
|
||||
tilemap: TileMap {
|
||||
@@ -231,7 +238,7 @@ mod tests {
|
||||
fn hardware_can_render_scene_from_shared_scene_bank_pipeline() {
|
||||
let banks = Arc::new(MemoryBanks::new());
|
||||
banks.install_glyph_bank(0, Arc::new(make_glyph_bank()));
|
||||
banks.install_scene_bank(0, Arc::new(make_scene()));
|
||||
banks.install_scene_bank(0, Arc::new(make_scene_with_glyph_asset_id(0)));
|
||||
|
||||
let mut hardware = Hardware::new_with_memory_banks(Arc::clone(&banks));
|
||||
let scene = banks.scene_bank_slot(0).expect("scene bank slot 0 should be resident");
|
||||
@@ -262,4 +269,27 @@ mod tests {
|
||||
assert_eq!(hardware.frame_composer.scene_bank_slot_count(), 16);
|
||||
assert_eq!(scene.layers[0].tile_size, TileSize::Size8);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn publish_game2d_submission_applies_gfx2d_overlay_after_active_scene() {
|
||||
let banks = Arc::new(MemoryBanks::new());
|
||||
banks.install_glyph_bank(0, Arc::new(make_glyph_bank()));
|
||||
banks.install_scene_bank(0, Arc::new(make_scene_with_glyph_asset_id(0)));
|
||||
|
||||
let mut hardware = Hardware::new_with_memory_banks(banks);
|
||||
let mut glyph_slots = [None; 16];
|
||||
glyph_slots[0] = Some(0);
|
||||
hardware.assets.glyph_asset_slot_index().rebuild_from_slots(&glyph_slots);
|
||||
assert!(hardware.bind_scene(0));
|
||||
|
||||
let mut packet = hardware.close_game2d_packet();
|
||||
packet.gfx2d = vec![Gfx2dCommand::FillRect {
|
||||
rect: Rect { x: 0, y: 0, w: 1, h: 1 },
|
||||
color: Color::BLUE,
|
||||
}];
|
||||
|
||||
hardware.publish_render_submission(&RenderSubmission::game2d(FrameId::ZERO, packet));
|
||||
|
||||
assert_eq!(hardware.gfx.front_buffer()[0], Color::BLUE.raw());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user