статистика времени кадра

This commit is contained in:
2026-03-01 17:19:52 +03:00
parent 8ca31bf479
commit 9fa13fa913
8 changed files with 98 additions and 29 deletions

View File

@@ -5,6 +5,7 @@ const RenderEngine = @import("RenderEngine.zig").RenderEngine;
const Document = @import("../models/Document.zig");
const basic_models = @import("../models/basic_models.zig");
const cpu_draw = @import("cpu/draw.zig");
const RenderStats = @import("RenderStats.zig");
const Size_i = basic_models.Size_i;
const Rect_i = basic_models.Rect_i;
const Allocator = std.mem.Allocator;
@@ -17,14 +18,18 @@ const Type = enum {
};
type: Type,
_allocator: Allocator,
gradient_start: Color.PMA = .{ .r = 0, .g = 0, .b = 0, .a = 255 },
gradient_end: Color.PMA = .{ .r = 255, .g = 255, .b = 255, .a = 255 },
_allocator: Allocator,
_renderStats: RenderStats,
pub fn init(allocator: Allocator, render_type: Type) CpuRenderEngine {
return .{
._allocator = allocator,
.type = render_type,
._renderStats = .{
.render_time_ns = 0,
},
};
}
@@ -182,7 +187,13 @@ pub fn renderDocument(self: *CpuRenderEngine, document: *const Document, canvas_
defer self._allocator.free(pixels);
for (pixels) |*p| p.* = .{ .r = 255, .g = 255, .b = 255, .a = 255 };
var t = try std.time.Timer.start();
try cpu_draw.drawDocument(pixels, width, height, visible_rect, document, canvas_size, self._allocator);
self._renderStats.render_time_ns = t.read();
return try dvui.textureCreate(pixels, width, height, .nearest);
}
pub fn getStats(self: CpuRenderEngine) RenderStats {
return self._renderStats;
}