1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
|
From a49818e6727dc3ec25e438b032b761e668542886 Mon Sep 17 00:00:00 2001
From: Hou Qi <qi.hou@nxp.com>
Date: Thu, 18 Aug 2022 12:22:20 +0800
Subject: [PATCH 12/17] V4L2VDA: 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 946f4f40aaa08..8a05a8c41bd05 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
@@ -6,6 +6,7 @@
#include <memory>
#include <vector>
+#include <sys/time.h>
#include "base/atomic_sequence_num.h"
#include "base/bind.h"
@@ -104,6 +105,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<uint64_t>(tv.tv_sec) * 1e6 + tv.tv_usec;
+}
+
namespace viz {
namespace {
@@ -320,6 +330,7 @@ SkiaOutputSurfaceImplOnGpu::SkiaOutputSurfaceImplOnGpu(
async_read_result_lock_(base::MakeRefCounted<AsyncReadResultLock>()) {
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));
@@ -500,10 +511,16 @@ 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();
if (release_frame_buffer)
output_device_->ReleaseOneFrameBuffer();
+ 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::AllocateFrameBuffers(size_t n) {
@@ -1525,6 +1542,7 @@ bool SkiaOutputSurfaceImplOnGpu::Initialize() {
if (context_state_)
context_state_->AddContextLostObserver(this);
+ 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 febdaebbb740c..be1cedf2babc9 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
@@ -423,6 +423,7 @@ class SkiaOutputSurfaceImplOnGpu
BufferPresentedCallback buffer_presented_callback_;
ContextLostCallback context_lost_callback_;
GpuVSyncCallback gpu_vsync_callback_;
+ size_t swap_buffers_number_;
// ImplOnGpu::CopyOutput can create SharedImages via ImplOnGpu's
// SharedImageFactory. Clients can use these images via CopyOutputResult and
--
2.17.1
|