int32_t type = NAME_NOT_FOUND;
for (int i=0 ; i<DisplayDevice::NUM_BUILTIN_DISPLAY_TYPES ; i++) {
if (display == mBuiltinDisplays[i]) {
type = i;
break;
}
}
if (type < 0) {
return type;
}
#ifdef MTK_AOSP_ENHANCEMENT
// TODO: should it be placed at a better place
const HWComposer& hwc(getHwComposer());
#endif // MTK_AOSP_ENHANCEMENT
// TODO: Not sure if display density should handled by SF any longer
class Density {
static int getDensityFromProperty(char const* propName) {
char property[PROPERTY_VALUE_MAX];
int density = 0;
if (property_get(propName, property, NULL) > 0) {
density = atoi(property);
}
return density;
}
public:
static int getEmuDensity() {
return getDensityFromProperty("qemu.sf.lcd_density"); }
static int getBuildDensity() {
return getDensityFromProperty("ro.sf.lcd_density"); }
};
configs->clear();
const Vector<HWComposer:isplayConfig>& hwConfigs =
getHwComposer().getConfigs(type);
for (size_t c = 0; c < hwConfigs.size(); ++c) {
const HWComposer:isplayConfig& hwConfig = hwConfigs[c];
DisplayInfo info = DisplayInfo();
if (type == DisplayDevice:ISPLAY_PRIMARY) {
// The density of the device is provided by a build property
float density = Density::getBuildDensity() / 160.0f;
if (density == 0) {
// the build doesn't provide a density -- this is wrong!
// use xdpi instead
ALOGE("ro.sf.lcd_density must be defined as a build property");
density = xdpi / 160.0f;
}
if (Density::getEmuDensity()) {
// if "qemu.sf.lcd_density" is specified, it overrides everything
xdpi = ydpi = density = Density::getEmuDensity();
density /= 160.0f;
}
info.density = density;
// TODO: this needs to go away (currently needed only by webkit)
sp<const DisplayDevice> hw(getDefaultDisplayDevice());
info.orientation = hw->getOrientation();
#ifdef MTK_AOSP_ENHANCEMENT
} else if (HWC_DISPLAY_SMARTBOOK == hwc.getSubType(type)) {
static const int SMB_DENSITY = 160;
info.density = SMB_DENSITY / 160.0f;
info.orientation = 0;
#endif
} else {
// TODO: where should this value come from?
static const int TV_DENSITY = 213;
info.density = TV_DENSITY / 160.0f;
info.orientation = 0;
}
// This is how far in advance a buffer must be queued for
// presentation at a given time. If you want a buffer to appear
// on the screen at time N, you must submit the buffer before
// (N - presentationDeadline).
//
// Normally it's one full refresh period (to give SF a chance to
// latch the buffer), but this can be reduced by configuring a
// DispSync offset. Any additional delays introduced by the hardware
// composer or panel must be accounted for here.
//
// We add an additional 1ms to allow for processing time and
// differences between the ideal and actual refresh rate.
info.presentationDeadline =
hwConfig.refresh - SF_VSYNC_EVENT_PHASE_OFFSET_NS + 1000000;
// All non-virtual displays are currently considered secure.
info.secure = true;
#ifdef MTK_AOSP_ENHANCEMENT
// correct for primary display to normalize graphic plane
if (DisplayDevice:ISPLAY_PRIMARY == type) {
getDefaultDisplayDevice()->correctSizeByHwOrientation(info.w, info.h);
}
#endif