cast_display_util.cc 618 B

1234567891011121314151617181920212223
  1. // Copyright 2018 The Chromium Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style license that can be
  3. // found in the LICENSE file.
  4. #include "chromecast/graphics/cast_display_util.h"
  5. #include <math.h>
  6. #include <algorithm>
  7. namespace chromecast {
  8. float GetDeviceScaleFactor(const gfx::Size& display_resolution) {
  9. int smaller_dimension =
  10. std::min(display_resolution.width(), display_resolution.height());
  11. float ratio = smaller_dimension / 720.f;
  12. if (ratio >= 2.f)
  13. return floorf(ratio);
  14. if (ratio >= 1.5f)
  15. return 1.5f;
  16. return 1.f;
  17. }
  18. } // namespace chromecast