From ac51e4353acbe44ec8beef3f36715faa9568231c Mon Sep 17 00:00:00 2001 From: Hou Qi Date: Fri, 11 Oct 2024 18:16:14 +0900 Subject: [PATCH 09/19] display: Add fps in SkiaOutputSurfaceImplOnGpu by VLOG(1) Upstream-Status: Inappropriate [NXP specific] --- .../skia_output_surface_impl_on_gpu.cc | 18 ++++++++++++++++++ .../skia_output_surface_impl_on_gpu.h | 1 + 2 files changed, 19 insertions(+) diff --git a/components/viz/service/display_embedder/skia_output_surface_impl_on_gpu.cc b/components/viz/service/display_embedder/skia_output_surface_impl_on_gpu.cc index 1ad55916b42a5..227173cd9bc76 100644 --- a/components/viz/service/display_embedder/skia_output_surface_impl_on_gpu.cc +++ b/components/viz/service/display_embedder/skia_output_surface_impl_on_gpu.cc @@ -15,6 +15,7 @@ #include #include #include +#include #include "base/debug/crash_logging.h" #include "base/debug/dump_without_crashing.h" @@ -138,6 +139,15 @@ #include "components/viz/service/display_embedder/output_presenter_fuchsia.h" #endif +static uint64_t start_time = 0; +static uint64_t stop_time = 0; + +uint64_t NowMicros() { + struct timeval tv; + gettimeofday(&tv, nullptr); + return static_cast(tv.tv_sec) * 1e6 + tv.tv_usec; +} + namespace viz { namespace { @@ -341,6 +351,7 @@ SkiaOutputSurfaceImplOnGpu::SkiaOutputSurfaceImplOnGpu( async_read_result_lock_(base::MakeRefCounted()) { DCHECK_CALLED_ON_VALID_THREAD(thread_checker_); + swap_buffers_number_ = 0; weak_ptr_ = weak_ptr_factory_.GetWeakPtr(); buffer_presented_callback_ = CreateSafeRepeatingCallback( weak_ptr_, std::move(buffer_presented_callback)); @@ -595,7 +606,13 @@ void SkiaOutputSurfaceImplOnGpu::SwapBuffers(OutputSurfaceFrame frame) { TRACE_EVENT0("viz", "SkiaOutputSurfaceImplOnGpu::SwapBuffers"); DCHECK_CALLED_ON_VALID_THREAD(thread_checker_); + if ( swap_buffers_number_ == 0) + start_time = NowMicros(); + + swap_buffers_number_++; + stop_time = NowMicros(); SwapBuffersInternal(std::move(frame)); + VLOG(1) << "total showed " << swap_buffers_number_ << " frames, total time " << (stop_time - start_time) << " ms, fps is " << swap_buffers_number_*1e6/(stop_time - start_time) << std::endl; } void SkiaOutputSurfaceImplOnGpu::SetDependenciesResolvedTimings( @@ -1938,6 +1955,7 @@ bool SkiaOutputSurfaceImplOnGpu::Initialize() { // allow neither to be set in the offscreen case. DCHECK(!(gl_surface_ != nullptr && presenter_ != nullptr)); + start_time = NowMicros(); return true; } diff --git a/components/viz/service/display_embedder/skia_output_surface_impl_on_gpu.h b/components/viz/service/display_embedder/skia_output_surface_impl_on_gpu.h index b82de4041e78a..532866bc30297 100644 --- a/components/viz/service/display_embedder/skia_output_surface_impl_on_gpu.h +++ b/components/viz/service/display_embedder/skia_output_surface_impl_on_gpu.h @@ -498,6 +498,7 @@ class SkiaOutputSurfaceImplOnGpu ScheduleGpuTaskCallback schedule_gpu_task_; AddChildWindowToBrowserCallback add_child_window_to_browser_callback_; SkiaOutputDevice::ReleaseOverlaysCallback release_overlays_callback_; + size_t swap_buffers_number_; // ImplOnGpu::CopyOutput can create SharedImages via ImplOnGpu's // SharedImageFactory. Clients can use these images via CopyOutputResult and -- 2.34.1