35 lines
1.2 KiB
Zig
35 lines
1.2 KiB
Zig
const dvui = @import("dvui");
|
|
const CpuRenderEngine = @import("CpuRenderEngine.zig");
|
|
const Document = @import("../models/Document.zig");
|
|
const basic_models = @import("../models/basic_models.zig");
|
|
const RenderStats = @import("RenderStats.zig");
|
|
|
|
pub const RenderEngine = union(enum) {
|
|
cpu: *CpuRenderEngine,
|
|
|
|
pub fn exampleReset(self: RenderEngine) void {
|
|
switch (self) {
|
|
.cpu => |cpu_r| cpu_r.exampleReset(),
|
|
}
|
|
}
|
|
|
|
pub fn example(self: RenderEngine, canvas_size: basic_models.Size_i, visible_rect: basic_models.Rect_i) !?dvui.Texture {
|
|
return switch (self) {
|
|
.cpu => |cpu_r| cpu_r.example(canvas_size, visible_rect),
|
|
};
|
|
}
|
|
|
|
pub fn getStats(self: RenderEngine) RenderStats {
|
|
return switch (self) {
|
|
.cpu => |cpu_r| cpu_r.getStats(),
|
|
};
|
|
}
|
|
|
|
/// Растеризует документ в текстуру.
|
|
pub fn render(self: RenderEngine, document: *const Document, canvas_size: basic_models.Size_i, visible_rect: basic_models.Rect_i) !?dvui.Texture {
|
|
return switch (self) {
|
|
.cpu => |cpu_r| cpu_r.renderDocument(document, canvas_size, visible_rect),
|
|
};
|
|
}
|
|
};
|