profile font rendering with tracy
This commit is contained in:
parent
12199ac7b6
commit
20ba7b51a1
@ -82,7 +82,7 @@ pub fn build(b: *std.Build) void {
|
||||
});
|
||||
|
||||
const ztracy = b.dependency("ztracy", .{
|
||||
.enable_ztracy = false,
|
||||
.enable_ztracy = true,
|
||||
.enable_fibers = false,
|
||||
.on_demand = false,
|
||||
});
|
||||
|
||||
@ -43,7 +43,7 @@ pub const Font = struct {
|
||||
texture : rl.Texture2D,
|
||||
kb_file_data : []u8,
|
||||
|
||||
pub fn init(filename : []const u8, size : i32, allocator: std.mem.Allocator) !Font {
|
||||
pub fn init(filename : [:0]const u8, size : i32, allocator: std.mem.Allocator) !Font {
|
||||
|
||||
const file_data = try std.fs.cwd().readFileAlloc(
|
||||
allocator,
|
||||
@ -189,7 +189,7 @@ pub const Font = struct {
|
||||
pub fn deinit(self: *Font, allocator : std.mem.Allocator) void {
|
||||
self.glyphs.deinit();
|
||||
self.face.deinit();
|
||||
kb.kbts_FreeFont(&self.kb);
|
||||
kb.kbts_FreeFont(&self.kbts_font);
|
||||
self.texture.unload();
|
||||
allocator.free(self.kb_file_data);
|
||||
}
|
||||
@ -237,7 +237,7 @@ pub const Font = struct {
|
||||
|
||||
const Context = kb.kbts_CreateShapeContext(null, null);
|
||||
defer kb.kbts_DestroyShapeContext(Context);
|
||||
const kb_font = kb.kbts_ShapePushFont(Context, &self.kb);
|
||||
const kb_font = kb.kbts_ShapePushFont(Context, &self.kbts_font);
|
||||
if (kb_font == null) {
|
||||
std.log.info("Could not open font!", .{});
|
||||
return;
|
||||
@ -253,7 +253,7 @@ pub const Font = struct {
|
||||
var cursor_y : f32 = 0;
|
||||
|
||||
var Run = kb.kbts_run{};
|
||||
while (kb.kbts_ShapeRun(Context, &Run) != 0) {
|
||||
while (my_kbts_ShapeRun(Context, &Run) != 0) {
|
||||
const zone3 = ztracy.ZoneNC(@src(), "shape run", 0x00_ff_00_00);
|
||||
defer zone3.End();
|
||||
if ((Run.Flags & kb.KBTS_BREAK_FLAG_LINE_HARD) != 0) {
|
||||
@ -374,3 +374,9 @@ pub const Font = struct {
|
||||
return .{ size, max_descent, 0};
|
||||
}
|
||||
};
|
||||
|
||||
fn my_kbts_ShapeRun(Context: ?*kb.kbts_shape_context, Run: [*c]kb.kbts_run) c_int {
|
||||
const zone = ztracy.ZoneNC(@src(), "my_kbts_ShapeRun", 0x00_ff_00_00);
|
||||
defer zone.End();
|
||||
return kb.kbts_ShapeRun(Context, Run);
|
||||
}
|
||||
|
||||
@ -247,15 +247,15 @@ pub fn main() !void {
|
||||
true
|
||||
);
|
||||
|
||||
arabic[0].render_text(
|
||||
"الليل طويل وبارد في الخارج",
|
||||
rl.Vector2{ .x = 0, .y = 100},
|
||||
true,
|
||||
.white,
|
||||
.blank,
|
||||
false,
|
||||
true
|
||||
);
|
||||
// arabic[0].render_text(
|
||||
// "الليل طويل وبارد في الخارج",
|
||||
// rl.Vector2{ .x = 0, .y = 100},
|
||||
// true,
|
||||
// .white,
|
||||
// .blank,
|
||||
// false,
|
||||
// true
|
||||
// );
|
||||
|
||||
// var y : f32 = 0;
|
||||
// var it = std.mem.splitScalar(u8, lorem, '\n');
|
||||
@ -483,7 +483,9 @@ pub fn main() !void {
|
||||
|
||||
rl.endDrawing();
|
||||
|
||||
const swap_zone = ztracy.ZoneNC(@src(), "swapScreenBuffer", 0x00_ff_00_00);
|
||||
rl.swapScreenBuffer();
|
||||
swap_zone.End();
|
||||
|
||||
frame += 1;
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user