summaryrefslogtreecommitdiffstats
path: root/glow
diff options
context:
space:
mode:
authorLibravatar Héctor Ramón <hector0193@gmail.com>2023-01-09 19:10:45 +0100
committerLibravatar GitHub <noreply@github.com>2023-01-09 19:10:45 +0100
commit07d755c6a270bd46fe9752ed57b3ceaddda1f081 (patch)
treecbd8f75d8cd6beeb3c04cbedc0127f2e17b70f56 /glow
parentba20ac8e49aedfa9d822d71784587d0635cec4f8 (diff)
parent2e5dc1f37a32e1f3aaa6db2aa9cf9c95e83bff42 (diff)
downloadiced-07d755c6a270bd46fe9752ed57b3ceaddda1f081.tar.gz
iced-07d755c6a270bd46fe9752ed57b3ceaddda1f081.tar.bz2
iced-07d755c6a270bd46fe9752ed57b3ceaddda1f081.zip
Merge pull request #1565 from bungoboingo/feat/tracing
[Feature] Profiling
Diffstat (limited to '')
-rw-r--r--glow/Cargo.toml4
-rw-r--r--glow/src/image.rs6
-rw-r--r--glow/src/quad.rs6
-rw-r--r--glow/src/triangle.rs6
4 files changed, 22 insertions, 0 deletions
diff --git a/glow/Cargo.toml b/glow/Cargo.toml
index f586d24d..c126a511 100644
--- a/glow/Cargo.toml
+++ b/glow/Cargo.toml
@@ -42,6 +42,10 @@ version = "0.5"
path = "../graphics"
features = ["font-fallback", "font-icons", "opengl"]
+[dependencies.tracing]
+version = "0.1.6"
+optional = true
+
[package.metadata.docs.rs]
rustdoc-args = ["--cfg", "docsrs"]
all-features = true
diff --git a/glow/src/image.rs b/glow/src/image.rs
index 521a01e7..d3a25b5b 100644
--- a/glow/src/image.rs
+++ b/glow/src/image.rs
@@ -21,6 +21,9 @@ use glow::HasContext;
use std::cell::RefCell;
+#[cfg(feature = "tracing")]
+use tracing::info_span;
+
#[derive(Debug)]
pub(crate) struct Pipeline {
program: <glow::Context as HasContext>::Program,
@@ -148,6 +151,9 @@ impl Pipeline {
images: &[layer::Image],
layer_bounds: Rectangle<u32>,
) {
+ #[cfg(feature = "tracing")]
+ let _ = info_span!("Glow::Image", "DRAW").entered();
+
unsafe {
gl.use_program(Some(self.program));
gl.bind_vertex_array(Some(self.vertex_array));
diff --git a/glow/src/quad.rs b/glow/src/quad.rs
index d9f1c6ae..67d9a098 100644
--- a/glow/src/quad.rs
+++ b/glow/src/quad.rs
@@ -7,6 +7,9 @@ use glow::HasContext;
use iced_graphics::layer;
use iced_native::Rectangle;
+#[cfg(feature = "tracing")]
+use tracing::info_span;
+
#[derive(Debug)]
pub enum Pipeline {
Core(core::Pipeline),
@@ -42,6 +45,9 @@ impl Pipeline {
scale: f32,
bounds: Rectangle<u32>,
) {
+ #[cfg(feature = "tracing")]
+ let _ = info_span!("Glow::Quad", "DRAW").enter();
+
match self {
Pipeline::Core(pipeline) => {
pipeline.draw(
diff --git a/glow/src/triangle.rs b/glow/src/triangle.rs
index d0205e08..42c88455 100644
--- a/glow/src/triangle.rs
+++ b/glow/src/triangle.rs
@@ -9,6 +9,9 @@ use iced_graphics::triangle::{ColoredVertex2D, Vertex2D};
use glow::HasContext;
use std::marker::PhantomData;
+#[cfg(feature = "tracing")]
+use tracing::info_span;
+
const DEFAULT_VERTICES: usize = 1_000;
const DEFAULT_INDICES: usize = 1_000;
@@ -58,6 +61,9 @@ impl Pipeline {
transformation: Transformation,
scale_factor: f32,
) {
+ #[cfg(feature = "tracing")]
+ let _ = info_span!("Glow::Triangle", "DRAW").enter();
+
unsafe {
gl.enable(glow::MULTISAMPLE);
gl.enable(glow::SCISSOR_TEST);