mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
This CL teaches SkyView the width, height, and device pixel ratio of the display. In the future, we'll want some sort of notification system for when these values change. R=eseidel@chromium.org Review URL: https://codereview.chromium.org/1139823010
47 lines
985 B
C++
47 lines
985 B
C++
// Copyright 2015 The Chromium 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 "sky/engine/config.h"
|
|
#include "sky/engine/core/view/View.h"
|
|
|
|
namespace blink {
|
|
|
|
PassRefPtr<View> View::create(const base::Closure& schedulePaintCallback)
|
|
{
|
|
return adoptRef(new View(schedulePaintCallback));
|
|
}
|
|
|
|
View::View(const base::Closure& schedulePaintCallback)
|
|
: m_schedulePaintCallback(schedulePaintCallback)
|
|
{
|
|
}
|
|
|
|
View::~View()
|
|
{
|
|
}
|
|
|
|
double View::width() const
|
|
{
|
|
double w = m_displayMetrics.physical_size.width;
|
|
return w / m_displayMetrics.device_pixel_ratio;
|
|
}
|
|
|
|
double View::height() const
|
|
{
|
|
double h = m_displayMetrics.physical_size.height;
|
|
return h / m_displayMetrics.device_pixel_ratio;
|
|
}
|
|
|
|
void View::schedulePaint()
|
|
{
|
|
m_schedulePaintCallback.Run();
|
|
}
|
|
|
|
void View::setDisplayMetrics(const SkyDisplayMetrics& metrics)
|
|
{
|
|
m_displayMetrics = metrics;
|
|
}
|
|
|
|
} // namespace blink
|