implements PLN-0099
This commit is contained in:
parent
9b03d13a0a
commit
a268bd0b75
@ -12,6 +12,7 @@ use prometeu_hal::cartridge::AssetsPayloadSource;
|
|||||||
use prometeu_hal::sprite::Sprite;
|
use prometeu_hal::sprite::Sprite;
|
||||||
use prometeu_hal::{AssetBridge, AudioBridge, GfxBridge, HardwareBridge, PadBridge, TouchBridge};
|
use prometeu_hal::{AssetBridge, AudioBridge, GfxBridge, HardwareBridge, PadBridge, TouchBridge};
|
||||||
use prometeu_hal::{Game2DFramePacket, RenderSubmission, RenderSubmissionPacket};
|
use prometeu_hal::{Game2DFramePacket, RenderSubmission, RenderSubmissionPacket};
|
||||||
|
use prometeu_hal::{RenderSubmissionSink, RenderSubmitError};
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
|
||||||
/// Aggregate structure for all virtual hardware peripherals.
|
/// Aggregate structure for all virtual hardware peripherals.
|
||||||
@ -138,6 +139,16 @@ impl HardwareBridge for Hardware {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl RenderSubmissionSink for Hardware {
|
||||||
|
fn submit_render_submission(
|
||||||
|
&mut self,
|
||||||
|
submission: RenderSubmission,
|
||||||
|
) -> Result<(), RenderSubmitError> {
|
||||||
|
self.publish_render_submission(&submission);
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl Hardware {
|
impl Hardware {
|
||||||
/// Internal hardware width in pixels.
|
/// Internal hardware width in pixels.
|
||||||
pub const W: usize = 480;
|
pub const W: usize = 480;
|
||||||
@ -197,6 +208,7 @@ mod tests {
|
|||||||
use prometeu_hal::tilemap::TileMap;
|
use prometeu_hal::tilemap::TileMap;
|
||||||
use prometeu_hal::{
|
use prometeu_hal::{
|
||||||
BoundScenePacket, Camera2D, ComposerFramePacket, FrameId, GameSpritePacket, Gfx2dCommand,
|
BoundScenePacket, Camera2D, ComposerFramePacket, FrameId, GameSpritePacket, Gfx2dCommand,
|
||||||
|
GfxUiCommand, ShellUiFramePacket,
|
||||||
};
|
};
|
||||||
|
|
||||||
fn make_glyph_bank() -> GlyphBank {
|
fn make_glyph_bank() -> GlyphBank {
|
||||||
@ -332,4 +344,31 @@ mod tests {
|
|||||||
|
|
||||||
assert_eq!(hardware.gfx.front_buffer()[0], Color::RED.raw());
|
assert_eq!(hardware.gfx.front_buffer()[0], Color::RED.raw());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn render_submission_sink_accepts_owned_game2d_submission() {
|
||||||
|
let mut hardware = Hardware::new();
|
||||||
|
let packet = Game2DFramePacket::new(
|
||||||
|
ComposerFramePacket::default(),
|
||||||
|
vec![Gfx2dCommand::Clear { color: Color::BLUE }],
|
||||||
|
);
|
||||||
|
let submission = RenderSubmission::game2d(FrameId::ZERO, packet);
|
||||||
|
|
||||||
|
RenderSubmissionSink::submit_render_submission(&mut hardware, submission)
|
||||||
|
.expect("local sink should accept owned Game2D submissions");
|
||||||
|
|
||||||
|
assert_eq!(hardware.gfx.front_buffer()[0], Color::BLUE.raw());
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn render_submission_sink_accepts_owned_shell_ui_submission() {
|
||||||
|
let mut hardware = Hardware::new();
|
||||||
|
let packet = ShellUiFramePacket::new(vec![GfxUiCommand::Clear { color: Color::RED }]);
|
||||||
|
let submission = RenderSubmission::shell_ui(FrameId::ZERO, packet);
|
||||||
|
|
||||||
|
RenderSubmissionSink::submit_render_submission(&mut hardware, submission)
|
||||||
|
.expect("local sink should accept owned ShellUi submissions");
|
||||||
|
|
||||||
|
assert_eq!(hardware.gfx.front_buffer()[0], Color::RED.raw());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user