Remove unused Counter and CounterValues class. (flutter/engine#31130)
This commit is contained in:
@@ -55,7 +55,6 @@ CompositorContext::~CompositorContext() = default;
|
||||
void CompositorContext::BeginFrame(ScopedFrame& frame,
|
||||
bool enable_instrumentation) {
|
||||
if (enable_instrumentation) {
|
||||
frame_count_.Increment();
|
||||
raster_time_.Start();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -161,8 +161,6 @@ class CompositorContext {
|
||||
|
||||
TextureRegistry& texture_registry() { return texture_registry_; }
|
||||
|
||||
const Counter& frame_count() const { return frame_count_; }
|
||||
|
||||
const Stopwatch& raster_time() const { return raster_time_; }
|
||||
|
||||
Stopwatch& ui_time() { return ui_time_; }
|
||||
@@ -170,7 +168,6 @@ class CompositorContext {
|
||||
private:
|
||||
RasterCache raster_cache_;
|
||||
TextureRegistry texture_registry_;
|
||||
Counter frame_count_;
|
||||
Stopwatch raster_time_;
|
||||
Stopwatch ui_time_;
|
||||
|
||||
|
||||
@@ -5,7 +5,6 @@
|
||||
#include "flutter/flow/instrumentation.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <limits>
|
||||
|
||||
#include "third_party/skia/include/core/SkPath.h"
|
||||
#include "third_party/skia/include/core/SkSurface.h"
|
||||
@@ -241,94 +240,6 @@ fml::Milliseconds Stopwatch::GetFrameBudget() const {
|
||||
return refresh_rate_updater_.GetFrameBudget();
|
||||
}
|
||||
|
||||
CounterValues::CounterValues() : current_sample_(kMaxSamples - 1) {
|
||||
values_.resize(kMaxSamples, 0);
|
||||
}
|
||||
|
||||
CounterValues::~CounterValues() = default;
|
||||
|
||||
void CounterValues::Add(int64_t value) {
|
||||
current_sample_ = (current_sample_ + 1) % kMaxSamples;
|
||||
values_[current_sample_] = value;
|
||||
}
|
||||
|
||||
void CounterValues::Visualize(SkCanvas* canvas, const SkRect& rect) const {
|
||||
size_t max_bytes = GetMaxValue();
|
||||
|
||||
if (max_bytes == 0) {
|
||||
// The backend for this counter probably did not fill in any values.
|
||||
return;
|
||||
}
|
||||
|
||||
size_t min_bytes = GetMinValue();
|
||||
|
||||
SkPaint paint;
|
||||
|
||||
// Paint the background.
|
||||
paint.setColor(0x99FFFFFF);
|
||||
canvas->drawRect(rect, paint);
|
||||
|
||||
// Establish the graph position.
|
||||
const SkScalar x = rect.x();
|
||||
const SkScalar y = rect.y();
|
||||
const SkScalar width = rect.width();
|
||||
const SkScalar height = rect.height();
|
||||
const SkScalar bottom = y + height;
|
||||
const SkScalar right = x + width;
|
||||
|
||||
// Prepare a path for the data.
|
||||
SkPath path;
|
||||
path.moveTo(x, bottom);
|
||||
|
||||
for (size_t i = 0; i < kMaxSamples; ++i) {
|
||||
int64_t current_bytes = values_[i];
|
||||
double ratio = static_cast<double>(current_bytes - min_bytes) /
|
||||
static_cast<double>(max_bytes - min_bytes);
|
||||
path.lineTo(
|
||||
x + ((static_cast<double>(i) / static_cast<double>(kMaxSamples)) *
|
||||
width),
|
||||
y + ((1.0 - ratio) * height));
|
||||
}
|
||||
|
||||
path.rLineTo(100, 0);
|
||||
path.lineTo(right, bottom);
|
||||
path.close();
|
||||
|
||||
// Draw the graph.
|
||||
paint.setColor(0xAA0000FF);
|
||||
canvas->drawPath(path, paint);
|
||||
|
||||
// Paint the vertical marker for the current frame.
|
||||
const double sample_unit_width = (1.0 / kMaxSamples);
|
||||
const double sample_margin_unit_width = sample_unit_width / 6.0;
|
||||
const double sample_margin_width = width * sample_margin_unit_width;
|
||||
paint.setStyle(SkPaint::Style::kFill_Style);
|
||||
paint.setColor(SK_ColorGRAY);
|
||||
double sample_x =
|
||||
x + width * (static_cast<double>(current_sample_) / kMaxSamples) -
|
||||
sample_margin_width;
|
||||
const auto marker_rect = SkRect::MakeLTRB(
|
||||
sample_x, y,
|
||||
sample_x + width * sample_unit_width + sample_margin_width * 2, bottom);
|
||||
canvas->drawRect(marker_rect, paint);
|
||||
}
|
||||
|
||||
int64_t CounterValues::GetMaxValue() const {
|
||||
auto max = std::numeric_limits<int64_t>::min();
|
||||
for (size_t i = 0; i < kMaxSamples; ++i) {
|
||||
max = std::max<int64_t>(max, values_[i]);
|
||||
}
|
||||
return max;
|
||||
}
|
||||
|
||||
int64_t CounterValues::GetMinValue() const {
|
||||
auto min = std::numeric_limits<int64_t>::max();
|
||||
for (size_t i = 0; i < kMaxSamples; ++i) {
|
||||
min = std::min<int64_t>(min, values_[i]);
|
||||
}
|
||||
return min;
|
||||
}
|
||||
|
||||
fml::Milliseconds FixedRefreshRateUpdater::GetFrameBudget() const {
|
||||
return fixed_frame_budget_;
|
||||
}
|
||||
|
||||
@@ -89,43 +89,6 @@ class FixedRefreshRateStopwatch : public Stopwatch {
|
||||
FixedRefreshRateUpdater fixed_delegate_;
|
||||
};
|
||||
|
||||
class Counter {
|
||||
public:
|
||||
Counter() : count_(0) {}
|
||||
|
||||
size_t count() const { return count_; }
|
||||
|
||||
void Reset(size_t count = 0) { count_ = count; }
|
||||
|
||||
void Increment(size_t count = 1) { count_ += count; }
|
||||
|
||||
private:
|
||||
size_t count_;
|
||||
|
||||
FML_DISALLOW_COPY_AND_ASSIGN(Counter);
|
||||
};
|
||||
|
||||
class CounterValues {
|
||||
public:
|
||||
CounterValues();
|
||||
|
||||
~CounterValues();
|
||||
|
||||
void Add(int64_t value);
|
||||
|
||||
void Visualize(SkCanvas* canvas, const SkRect& rect) const;
|
||||
|
||||
int64_t GetMaxValue() const;
|
||||
|
||||
int64_t GetMinValue() const;
|
||||
|
||||
private:
|
||||
std::vector<int64_t> values_;
|
||||
size_t current_sample_;
|
||||
|
||||
FML_DISALLOW_COPY_AND_ASSIGN(CounterValues);
|
||||
};
|
||||
|
||||
} // namespace flutter
|
||||
|
||||
#endif // FLUTTER_FLOW_INSTRUMENTATION_H_
|
||||
|
||||
Reference in New Issue
Block a user