Merge "Modified SurfaceFlinger to implment setActiveConfig and getActiveConfig."
This commit is contained in:
commit
659c015d94
@ -72,7 +72,8 @@ DisplayDevice::DisplayDevice(
|
|||||||
mSecureLayerVisible(false),
|
mSecureLayerVisible(false),
|
||||||
mLayerStack(NO_LAYER_STACK),
|
mLayerStack(NO_LAYER_STACK),
|
||||||
mOrientation(),
|
mOrientation(),
|
||||||
mPowerMode(HWC_POWER_MODE_OFF)
|
mPowerMode(HWC_POWER_MODE_OFF),
|
||||||
|
mActiveConfig(0)
|
||||||
{
|
{
|
||||||
mNativeWindow = new Surface(producer, false);
|
mNativeWindow = new Surface(producer, false);
|
||||||
ANativeWindow* const window = mNativeWindow.get();
|
ANativeWindow* const window = mNativeWindow.get();
|
||||||
@ -335,6 +336,15 @@ bool DisplayDevice::isDisplayOn() const {
|
|||||||
return (mPowerMode != HWC_POWER_MODE_OFF);
|
return (mPowerMode != HWC_POWER_MODE_OFF);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
void DisplayDevice::setActiveConfig(int mode) {
|
||||||
|
mActiveConfig = mode;
|
||||||
|
}
|
||||||
|
|
||||||
|
int DisplayDevice::getActiveConfig() const {
|
||||||
|
return mActiveConfig;
|
||||||
|
}
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
void DisplayDevice::setLayerStack(uint32_t stack) {
|
void DisplayDevice::setLayerStack(uint32_t stack) {
|
||||||
@ -461,13 +471,14 @@ void DisplayDevice::dump(String8& result) const {
|
|||||||
result.appendFormat(
|
result.appendFormat(
|
||||||
"+ DisplayDevice: %s\n"
|
"+ DisplayDevice: %s\n"
|
||||||
" type=%x, hwcId=%d, layerStack=%u, (%4dx%4d), ANativeWindow=%p, orient=%2d (type=%08x), "
|
" type=%x, hwcId=%d, layerStack=%u, (%4dx%4d), ANativeWindow=%p, orient=%2d (type=%08x), "
|
||||||
"flips=%u, isSecure=%d, secureVis=%d, powerMode=%d, numLayers=%zu\n"
|
"flips=%u, isSecure=%d, secureVis=%d, powerMode=%d, activeConfig=%d, numLayers=%zu\n"
|
||||||
" v:[%d,%d,%d,%d], f:[%d,%d,%d,%d], s:[%d,%d,%d,%d],"
|
" v:[%d,%d,%d,%d], f:[%d,%d,%d,%d], s:[%d,%d,%d,%d],"
|
||||||
"transform:[[%0.3f,%0.3f,%0.3f][%0.3f,%0.3f,%0.3f][%0.3f,%0.3f,%0.3f]]\n",
|
"transform:[[%0.3f,%0.3f,%0.3f][%0.3f,%0.3f,%0.3f][%0.3f,%0.3f,%0.3f]]\n",
|
||||||
mDisplayName.string(), mType, mHwcDisplayId,
|
mDisplayName.string(), mType, mHwcDisplayId,
|
||||||
mLayerStack, mDisplayWidth, mDisplayHeight, mNativeWindow.get(),
|
mLayerStack, mDisplayWidth, mDisplayHeight, mNativeWindow.get(),
|
||||||
mOrientation, tr.getType(), getPageFlipCount(),
|
mOrientation, tr.getType(), getPageFlipCount(),
|
||||||
mIsSecure, mSecureLayerVisible, mPowerMode, mVisibleLayersSortedByZ.size(),
|
mIsSecure, mSecureLayerVisible, mPowerMode, mActiveConfig,
|
||||||
|
mVisibleLayersSortedByZ.size(),
|
||||||
mViewport.left, mViewport.top, mViewport.right, mViewport.bottom,
|
mViewport.left, mViewport.top, mViewport.right, mViewport.bottom,
|
||||||
mFrame.left, mFrame.top, mFrame.right, mFrame.bottom,
|
mFrame.left, mFrame.top, mFrame.right, mFrame.bottom,
|
||||||
mScissor.left, mScissor.top, mScissor.right, mScissor.bottom,
|
mScissor.left, mScissor.top, mScissor.right, mScissor.bottom,
|
||||||
|
@ -153,6 +153,12 @@ public:
|
|||||||
void setPowerMode(int mode);
|
void setPowerMode(int mode);
|
||||||
bool isDisplayOn() const;
|
bool isDisplayOn() const;
|
||||||
|
|
||||||
|
/* ------------------------------------------------------------------------
|
||||||
|
* Display active config management.
|
||||||
|
*/
|
||||||
|
int getActiveConfig() const;
|
||||||
|
void setActiveConfig(int mode);
|
||||||
|
|
||||||
// release HWC resources (if any) for removable displays
|
// release HWC resources (if any) for removable displays
|
||||||
void disconnect(HWComposer& hwc);
|
void disconnect(HWComposer& hwc);
|
||||||
|
|
||||||
@ -215,6 +221,8 @@ private:
|
|||||||
bool mNeedsFiltering;
|
bool mNeedsFiltering;
|
||||||
// Current power mode
|
// Current power mode
|
||||||
int mPowerMode;
|
int mPowerMode;
|
||||||
|
// Current active config
|
||||||
|
int mActiveConfig;
|
||||||
};
|
};
|
||||||
|
|
||||||
}; // namespace android
|
}; // namespace android
|
||||||
|
@ -775,6 +775,16 @@ status_t HWComposer::setPowerMode(int disp, int mode) {
|
|||||||
return NO_ERROR;
|
return NO_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
status_t HWComposer::setActiveConfig(int disp, int mode) {
|
||||||
|
LOG_FATAL_IF(disp >= VIRTUAL_DISPLAY_ID_BASE);
|
||||||
|
if (mHwc && hwcHasApiVersion(mHwc, HWC_DEVICE_API_VERSION_1_4)) {
|
||||||
|
return (status_t)mHwc->setActiveConfig(mHwc, disp, mode);
|
||||||
|
} else {
|
||||||
|
LOG_FATAL_IF(mode != 0);
|
||||||
|
}
|
||||||
|
return NO_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
void HWComposer::disconnectDisplay(int disp) {
|
void HWComposer::disconnectDisplay(int disp) {
|
||||||
LOG_ALWAYS_FATAL_IF(disp < 0 || disp == HWC_DISPLAY_PRIMARY);
|
LOG_ALWAYS_FATAL_IF(disp < 0 || disp == HWC_DISPLAY_PRIMARY);
|
||||||
DisplayData& dd(mDisplayData[disp]);
|
DisplayData& dd(mDisplayData[disp]);
|
||||||
|
@ -100,6 +100,9 @@ public:
|
|||||||
// set power mode
|
// set power mode
|
||||||
status_t setPowerMode(int disp, int mode);
|
status_t setPowerMode(int disp, int mode);
|
||||||
|
|
||||||
|
// set active config
|
||||||
|
status_t setActiveConfig(int disp, int mode);
|
||||||
|
|
||||||
// reset state when an external, non-virtual display is disconnected
|
// reset state when an external, non-virtual display is disconnected
|
||||||
void disconnectDisplay(int disp);
|
void disconnectDisplay(int disp);
|
||||||
|
|
||||||
|
@ -603,11 +603,55 @@ status_t SurfaceFlinger::getDisplayConfigs(const sp<IBinder>& display,
|
|||||||
return NO_ERROR;
|
return NO_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
int SurfaceFlinger::getActiveConfig(const sp<IBinder>&) {
|
int SurfaceFlinger::getActiveConfig(const sp<IBinder>& display) {
|
||||||
return 0;
|
return getDisplayDevice(display)->getActiveConfig();
|
||||||
}
|
}
|
||||||
|
|
||||||
status_t SurfaceFlinger::setActiveConfig(const sp<IBinder>&, int) {
|
void SurfaceFlinger::setActiveConfigInternal(const sp<DisplayDevice>& hw, int mode) {
|
||||||
|
ALOGD("Set active config mode=%d, type=%d flinger=%p", mode, hw->getDisplayType(),
|
||||||
|
this);
|
||||||
|
int32_t type = hw->getDisplayType();
|
||||||
|
int currentMode = hw->getActiveConfig();
|
||||||
|
|
||||||
|
if (mode == currentMode) {
|
||||||
|
ALOGD("Screen type=%d is already mode=%d", hw->getDisplayType(), mode);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (type >= DisplayDevice::NUM_BUILTIN_DISPLAY_TYPES) {
|
||||||
|
ALOGW("Trying to set config for virtual display");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
hw->setActiveConfig(mode);
|
||||||
|
getHwComposer().setActiveConfig(type, mode);
|
||||||
|
}
|
||||||
|
|
||||||
|
status_t SurfaceFlinger::setActiveConfig(const sp<IBinder>& display, int mode) {
|
||||||
|
class MessageSetActiveConfig: public MessageBase {
|
||||||
|
SurfaceFlinger& mFlinger;
|
||||||
|
sp<IBinder> mDisplay;
|
||||||
|
int mMode;
|
||||||
|
public:
|
||||||
|
MessageSetActiveConfig(SurfaceFlinger& flinger, const sp<IBinder>& disp,
|
||||||
|
int mode) :
|
||||||
|
mFlinger(flinger), mDisplay(disp) { mMode = mode; }
|
||||||
|
virtual bool handler() {
|
||||||
|
sp<DisplayDevice> hw(mFlinger.getDisplayDevice(mDisplay));
|
||||||
|
if (hw == NULL) {
|
||||||
|
ALOGE("Attempt to set active config = %d for null display %p",
|
||||||
|
mDisplay.get(), mMode);
|
||||||
|
} else if (hw->getDisplayType() >= DisplayDevice::DISPLAY_VIRTUAL) {
|
||||||
|
ALOGW("Attempt to set active config = %d for virtual display",
|
||||||
|
mMode);
|
||||||
|
} else {
|
||||||
|
mFlinger.setActiveConfigInternal(hw, mMode);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
sp<MessageBase> msg = new MessageSetActiveConfig(*this, display, mode);
|
||||||
|
postMessageSync(msg);
|
||||||
return NO_ERROR;
|
return NO_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -239,6 +239,8 @@ private:
|
|||||||
|
|
||||||
// called on the main thread in response to initializeDisplays()
|
// called on the main thread in response to initializeDisplays()
|
||||||
void onInitializeDisplays();
|
void onInitializeDisplays();
|
||||||
|
// called on the main thread in response to setActiveConfig()
|
||||||
|
void setActiveConfigInternal(const sp<DisplayDevice>& hw, int mode);
|
||||||
// called on the main thread in response to setPowerMode()
|
// called on the main thread in response to setPowerMode()
|
||||||
void setPowerModeInternal(const sp<DisplayDevice>& hw, int mode);
|
void setPowerModeInternal(const sp<DisplayDevice>& hw, int mode);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user