blob: d51af1a08a724f09f692d1f73cd7e4ec0d580057 [file] [log] [blame]
// Copyright 2013 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "flutter/shell/common/variable_refresh_rate_display.h"
#include "flutter/fml/logging.h"
static double GetInitialRefreshRate(
const std::weak_ptr<flutter::VariableRefreshRateReporter>&
refresh_rate_reporter) {
if (auto reporter = refresh_rate_reporter.lock()) {
return reporter->GetRefreshRate();
}
return 0;
}
namespace flutter {
VariableRefreshRateDisplay::VariableRefreshRateDisplay(
DisplayId display_id,
const std::weak_ptr<VariableRefreshRateReporter>& refresh_rate_reporter)
: Display(display_id, GetInitialRefreshRate(refresh_rate_reporter)),
refresh_rate_reporter_(refresh_rate_reporter) {}
VariableRefreshRateDisplay::VariableRefreshRateDisplay(
const std::weak_ptr<VariableRefreshRateReporter>& refresh_rate_reporter)
: Display(GetInitialRefreshRate(refresh_rate_reporter)),
refresh_rate_reporter_(refresh_rate_reporter) {}
double VariableRefreshRateDisplay::GetRefreshRate() const {
return GetInitialRefreshRate(refresh_rate_reporter_);
}
} // namespace flutter