Discuz! Board

 找回密码
 立即注册
搜索
热搜: 活动 交友 discuz
查看: 6|回复: 6
打印 上一主题 下一主题

change display attribute!

[复制链接]

1198

主题

2060

帖子

7058

积分

超级版主

Rank: 8Rank: 8

积分
7058
跳转到指定楼层
楼主
发表于 2016-4-20 07:07:49 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
status_t SurfaceFlinger::getDisplayConfigs(const sp<IBinder>& display,
        Vector<DisplayInfo>* configs) {
    if (configs == NULL) {
        return BAD_VALUE;
    }

    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();

        float xdpi = hwConfig.xdpi;
        float ydpi = hwConfig.ydpi;

        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;
        }

        info.w = hwConfig.width;
//zcfdebug--        info.h = hwConfig.height;
        info.h = hwConfig.height/2;    //zcfdebug++
        info.xdpi = xdpi;
//zcfdebug--        info.ydpi = ydpi;
        info.ydpi = ydpi/2;    //zcfdebug++
        info.fps = float(1e9 / hwConfig.refresh);
        info.appVsyncOffset = VSYNC_EVENT_PHASE_OFFSET_NS;

        // 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

        configs->push_back(info);
    }

    return NO_ERROR;
}


回复

使用道具 举报

1198

主题

2060

帖子

7058

积分

超级版主

Rank: 8Rank: 8

积分
7058
沙发
 楼主| 发表于 2016-4-20 07:10:29 | 只看该作者
native/libs/gui/SurfaceComposerClient.cpp:status_t SurfaceComposerClient::getDisplayConfigs(
native/libs/gui/SurfaceComposerClient.cpp:    return ComposerService::getComposerService()->getDisplayConfigs(display, configs);
native/libs/gui/SurfaceComposerClient.cpp:    status_t result = getDisplayConfigs(display, &configs);

回复 支持 反对

使用道具 举报

1198

主题

2060

帖子

7058

积分

超级版主

Rank: 8Rank: 8

积分
7058
板凳
 楼主| 发表于 2016-4-20 07:12:13 | 只看该作者
base/core/jni/android_view_SurfaceControl.cpp:    if (SurfaceComposerClient::getDisplayConfigs(token, &configs) != NO_ERROR ||
回复 支持 反对

使用道具 举报

1198

主题

2060

帖子

7058

积分

超级版主

Rank: 8Rank: 8

积分
7058
地板
 楼主| 发表于 2016-4-20 07:13:39 | 只看该作者
base/core/java/android/view/SurfaceControl.java:    public static SurfaceControl.PhysicalDisplayInfo[] getDisplayConfigs(IBinder displayToken) {
回复 支持 反对

使用道具 举报

1198

主题

2060

帖子

7058

积分

超级版主

Rank: 8Rank: 8

积分
7058
5#
 楼主| 发表于 2016-4-20 07:13:54 | 只看该作者
base/services/core/java/com/android/server/display/LocalDisplayAdapter.java:                    SurfaceControl.getDisplayConfigs(displayToken);
回复 支持 反对

使用道具 举报

1198

主题

2060

帖子

7058

积分

超级版主

Rank: 8Rank: 8

积分
7058
6#
 楼主| 发表于 2016-4-20 07:15:50 | 只看该作者
base/services/core/java/com/android/server/display/DisplayManagerService.java:            registerDisplayAdapterLocked(new LocalDisplayAdapter(
回复 支持 反对

使用道具 举报

1198

主题

2060

帖子

7058

积分

超级版主

Rank: 8Rank: 8

积分
7058
7#
 楼主| 发表于 2016-4-20 08:23:14 | 只看该作者
现在修改的思路是,在返回屏幕尺寸的时候,让高度减半,而在createLayer的时候,再让高度增加一倍。
看看效果如何。
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

Archiver|手机版|小黑屋|Comsenz Inc.

GMT+8, 2025-12-15 02:05 , Processed in 0.012237 second(s), 7 queries , Apc On.

Powered by Discuz! X3.2

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表