Moved brightness from Lights to SF.
Test: manual. Check that brightness works. Fixes: 111435292 Change-Id: I3d19bc2fc4088bc9a956a5cf38c3b163fe35256f
This commit is contained in:
parent
fc084a1c1f
commit
3e83c4558a
8 changed files with 133 additions and 5 deletions
|
@ -479,7 +479,7 @@ b826892686850a9cf2b60ca5845db7185c2196ea4dd765cd80cd163169678a78 android.hardwar
|
||||||
01c6398c90fc6be0640810e2c5d8a4863b457280132bb3f97dd5682e19632b62 android.hardware.graphics.bufferqueue@2.0::types
|
01c6398c90fc6be0640810e2c5d8a4863b457280132bb3f97dd5682e19632b62 android.hardware.graphics.bufferqueue@2.0::types
|
||||||
7a2d64095252f85781b2d521f4f11d04ce774544feececcec2088c568656e93c android.hardware.graphics.common@1.2::types
|
7a2d64095252f85781b2d521f4f11d04ce774544feececcec2088c568656e93c android.hardware.graphics.common@1.2::types
|
||||||
3dff04a36b86660b5807414587e530bb0c294ed56fdff06f8915ba0a9b73f974 android.hardware.graphics.composer@2.3::IComposer
|
3dff04a36b86660b5807414587e530bb0c294ed56fdff06f8915ba0a9b73f974 android.hardware.graphics.composer@2.3::IComposer
|
||||||
daa44e83d7709bf1c9e0bd9a6b552feff496fd14574a9461ee93c21980fc5b15 android.hardware.graphics.composer@2.3::IComposerClient
|
54bc1dc874f8bc0781767786075dafd33a0796c1eea7d2317231b8929280e946 android.hardware.graphics.composer@2.3::IComposerClient
|
||||||
5c8bf8e1af9efe225a4661db8c08ff1b7e13fdc8ed49f35291bd0b6c9436b8f2 android.hardware.graphics.mapper@3.0::IMapper
|
5c8bf8e1af9efe225a4661db8c08ff1b7e13fdc8ed49f35291bd0b6c9436b8f2 android.hardware.graphics.mapper@3.0::IMapper
|
||||||
7183d9d9acfa41a61a64bdfed548e98299265a7bb1821a3ed204173b5c2cfd4a android.hardware.graphics.mapper@3.0::types
|
7183d9d9acfa41a61a64bdfed548e98299265a7bb1821a3ed204173b5c2cfd4a android.hardware.graphics.mapper@3.0::types
|
||||||
c3f831a66d5815baf74f5b82fe79cf099542ddae4dfab3f388e1d41828e794fc android.hardware.health.storage@1.0::IGarbageCollectCallback
|
c3f831a66d5815baf74f5b82fe79cf099542ddae4dfab3f388e1d41828e794fc android.hardware.health.storage@1.0::IGarbageCollectCallback
|
||||||
|
|
|
@ -61,6 +61,11 @@ interface IComposerClient extends @2.2::IComposerClient {
|
||||||
* PowerMode::DOZE_SUSPEND.
|
* PowerMode::DOZE_SUSPEND.
|
||||||
*/
|
*/
|
||||||
DOZE = 2,
|
DOZE = 2,
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Indicates that the display supports brightness operations.
|
||||||
|
*/
|
||||||
|
BRIGHTNESS = 3,
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -495,4 +500,38 @@ interface IComposerClient extends @2.2::IComposerClient {
|
||||||
float maxLuminance,
|
float maxLuminance,
|
||||||
float maxAverageLuminance,
|
float maxAverageLuminance,
|
||||||
float minLuminance);
|
float minLuminance);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets whether brightness operations are supported on a display.
|
||||||
|
*
|
||||||
|
* @param display
|
||||||
|
* The display.
|
||||||
|
*
|
||||||
|
* @return error is NONE upon success. Otherwise,
|
||||||
|
* BAD_DISPLAY when the display is invalid, or
|
||||||
|
* BAD_PARAMETER when the output parameter is invalid.
|
||||||
|
* @return support
|
||||||
|
* Whether brightness operations are supported on the display.
|
||||||
|
*/
|
||||||
|
getDisplayBrightnessSupport(Display display) generates (Error error, bool support);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the brightness of a display.
|
||||||
|
*
|
||||||
|
* Ideally, the brightness change should take effect in the next frame post (so that it can be
|
||||||
|
* aligned with color transforms).
|
||||||
|
*
|
||||||
|
* @param display
|
||||||
|
* The display whose brightness is set.
|
||||||
|
* @param brightness
|
||||||
|
* A number between 0.0f (minimum brightness) and 1.0f (maximum brightness), or -1.0 to
|
||||||
|
* turn the backlight off.
|
||||||
|
*
|
||||||
|
* @return error is NONE upon success. Otherwise,
|
||||||
|
* BAD_DISPLAY when the display is invalid, or
|
||||||
|
* UNSUPPORTED when brightness operations are not supported, or
|
||||||
|
* BAD_PARAMETER when the brightness is invalid, or
|
||||||
|
* NO_RESOURCES when the brightness cannot be applied.
|
||||||
|
*/
|
||||||
|
setDisplayBrightness(Display display, float brightness) generates (Error error);
|
||||||
};
|
};
|
||||||
|
|
|
@ -172,7 +172,19 @@ class ComposerClientImpl : public V2_2::hal::detail::ComposerClientImpl<Interfac
|
||||||
return Void();
|
return Void();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected:
|
Return<void> getDisplayBrightnessSupport(
|
||||||
|
Display display, IComposerClient::getDisplayBrightnessSupport_cb hidl_cb) override {
|
||||||
|
bool support = false;
|
||||||
|
Error error = mHal->getDisplayBrightnessSupport(display, &support);
|
||||||
|
hidl_cb(error, support);
|
||||||
|
return Void();
|
||||||
|
}
|
||||||
|
|
||||||
|
Return<Error> setDisplayBrightness(Display display, float brightness) override {
|
||||||
|
return mHal->setDisplayBrightness(display, brightness);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected:
|
||||||
std::unique_ptr<V2_1::hal::ComposerCommandEngine> createCommandEngine() override {
|
std::unique_ptr<V2_1::hal::ComposerCommandEngine> createCommandEngine() override {
|
||||||
return std::make_unique<ComposerCommandEngine>(
|
return std::make_unique<ComposerCommandEngine>(
|
||||||
mHal, static_cast<V2_2::hal::ComposerResources*>(mResources.get()));
|
mHal, static_cast<V2_2::hal::ComposerResources*>(mResources.get()));
|
||||||
|
|
|
@ -119,6 +119,8 @@ class ComposerHal : public V2_2::hal::ComposerHal {
|
||||||
virtual Error setLayerPerFrameMetadataBlobs(
|
virtual Error setLayerPerFrameMetadataBlobs(
|
||||||
Display display, Layer layer,
|
Display display, Layer layer,
|
||||||
std::vector<IComposerClient::PerFrameMetadataBlob>& blobs) = 0;
|
std::vector<IComposerClient::PerFrameMetadataBlob>& blobs) = 0;
|
||||||
|
virtual Error getDisplayBrightnessSupport(Display display, bool* outSupport) = 0;
|
||||||
|
virtual Error setDisplayBrightness(Display display, float brightness) = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace hal
|
} // namespace hal
|
||||||
|
|
|
@ -245,7 +245,29 @@ class HwcHalImpl : public V2_2::passthrough::detail::HwcHalImpl<Hal> {
|
||||||
return static_cast<Error>(err);
|
return static_cast<Error>(err);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected:
|
Error getDisplayBrightnessSupport(Display display, bool* outSupport) {
|
||||||
|
if (!mDispatch.getDisplayBrightnessSupport) {
|
||||||
|
return Error::UNSUPPORTED;
|
||||||
|
}
|
||||||
|
bool support = false;
|
||||||
|
int32_t error = mDispatch.getDisplayBrightnessSupport(mDevice, display, &support);
|
||||||
|
*outSupport = support;
|
||||||
|
return static_cast<Error>(error);
|
||||||
|
}
|
||||||
|
|
||||||
|
Error setDisplayBrightness(Display display, float brightness) {
|
||||||
|
if (std::isnan(brightness) || brightness > 1.0f ||
|
||||||
|
(brightness < 0.0f && brightness != -1.0f)) {
|
||||||
|
return Error::BAD_PARAMETER;
|
||||||
|
}
|
||||||
|
if (!mDispatch.setDisplayBrightness) {
|
||||||
|
return Error::UNSUPPORTED;
|
||||||
|
}
|
||||||
|
int32_t error = mDispatch.setDisplayBrightness(mDevice, display, brightness);
|
||||||
|
return static_cast<Error>(error);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected:
|
||||||
bool initDispatch() override {
|
bool initDispatch() override {
|
||||||
if (!BaseType2_2::initDispatch()) {
|
if (!BaseType2_2::initDispatch()) {
|
||||||
return false;
|
return false;
|
||||||
|
@ -265,6 +287,10 @@ class HwcHalImpl : public V2_2::passthrough::detail::HwcHalImpl<Hal> {
|
||||||
&mDispatch.getDisplayCapabilities);
|
&mDispatch.getDisplayCapabilities);
|
||||||
this->initOptionalDispatch(HWC2_FUNCTION_SET_LAYER_PER_FRAME_METADATA_BLOBS,
|
this->initOptionalDispatch(HWC2_FUNCTION_SET_LAYER_PER_FRAME_METADATA_BLOBS,
|
||||||
&mDispatch.setLayerPerFrameMetadataBlobs);
|
&mDispatch.setLayerPerFrameMetadataBlobs);
|
||||||
|
this->initOptionalDispatch(HWC2_FUNCTION_GET_DISPLAY_BRIGHTNESS_SUPPORT,
|
||||||
|
&mDispatch.getDisplayBrightnessSupport);
|
||||||
|
this->initOptionalDispatch(HWC2_FUNCTION_SET_DISPLAY_BRIGHTNESS,
|
||||||
|
&mDispatch.setDisplayBrightness);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -277,6 +303,8 @@ class HwcHalImpl : public V2_2::passthrough::detail::HwcHalImpl<Hal> {
|
||||||
HWC2_PFN_GET_DISPLAYED_CONTENT_SAMPLE getDisplayedContentSample;
|
HWC2_PFN_GET_DISPLAYED_CONTENT_SAMPLE getDisplayedContentSample;
|
||||||
HWC2_PFN_GET_DISPLAY_CAPABILITIES getDisplayCapabilities;
|
HWC2_PFN_GET_DISPLAY_CAPABILITIES getDisplayCapabilities;
|
||||||
HWC2_PFN_SET_LAYER_PER_FRAME_METADATA_BLOBS setLayerPerFrameMetadataBlobs;
|
HWC2_PFN_SET_LAYER_PER_FRAME_METADATA_BLOBS setLayerPerFrameMetadataBlobs;
|
||||||
|
HWC2_PFN_GET_DISPLAY_BRIGHTNESS_SUPPORT getDisplayBrightnessSupport;
|
||||||
|
HWC2_PFN_SET_DISPLAY_BRIGHTNESS setDisplayBrightness;
|
||||||
} mDispatch = {};
|
} mDispatch = {};
|
||||||
|
|
||||||
using BaseType2_2 = V2_2::passthrough::detail::HwcHalImpl<Hal>;
|
using BaseType2_2 = V2_2::passthrough::detail::HwcHalImpl<Hal>;
|
||||||
|
|
|
@ -186,6 +186,19 @@ std::vector<IComposerClient::DisplayCapability> ComposerClient::getDisplayCapabi
|
||||||
return capabilities;
|
return capabilities;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool ComposerClient::getDisplayBrightnessSupport(Display display) {
|
||||||
|
bool support = false;
|
||||||
|
mClient->getDisplayBrightnessSupport(display, [&](const auto& error, const auto& tmpSupport) {
|
||||||
|
ASSERT_EQ(Error::NONE, error) << "failed to get brightness support";
|
||||||
|
support = tmpSupport;
|
||||||
|
});
|
||||||
|
return support;
|
||||||
|
}
|
||||||
|
|
||||||
|
Error ComposerClient::setDisplayBrightness(Display display, float brightness) {
|
||||||
|
return mClient->setDisplayBrightness(display, brightness);
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace vts
|
} // namespace vts
|
||||||
} // namespace V2_3
|
} // namespace V2_3
|
||||||
} // namespace composer
|
} // namespace composer
|
||||||
|
|
|
@ -52,7 +52,7 @@ class Composer : public V2_2::vts::Composer {
|
||||||
|
|
||||||
std::unique_ptr<ComposerClient> createClient();
|
std::unique_ptr<ComposerClient> createClient();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
explicit Composer(const sp<IComposer>& composer);
|
explicit Composer(const sp<IComposer>& composer);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -99,7 +99,11 @@ class ComposerClient : public V2_2::vts::ComposerClient {
|
||||||
|
|
||||||
std::vector<IComposerClient::PerFrameMetadataKey> getPerFrameMetadataKeys_2_3(Display display);
|
std::vector<IComposerClient::PerFrameMetadataKey> getPerFrameMetadataKeys_2_3(Display display);
|
||||||
|
|
||||||
private:
|
bool getDisplayBrightnessSupport(Display display);
|
||||||
|
|
||||||
|
Error setDisplayBrightness(Display display, float brightness);
|
||||||
|
|
||||||
|
private:
|
||||||
const sp<IComposerClient> mClient;
|
const sp<IComposerClient> mClient;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -600,6 +600,36 @@ TEST_F(GraphicsComposerHidlTest, SetLayerPerFrameMetadataBlobs) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Test that getDisplayBrightnessSupport works as expected.
|
||||||
|
*/
|
||||||
|
TEST_F(GraphicsComposerHidlTest, getDisplayBrightnessSupport) {
|
||||||
|
auto capabilities = mComposerClient->getDisplayCapabilities(mPrimaryDisplay);
|
||||||
|
bool brightnessSupport =
|
||||||
|
std::find(capabilities.begin(), capabilities.end(),
|
||||||
|
IComposerClient::DisplayCapability::BRIGHTNESS) != capabilities.end();
|
||||||
|
EXPECT_EQ(mComposerClient->getDisplayBrightnessSupport(mPrimaryDisplay), brightnessSupport);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Test that if brightness operations are supported, setDisplayBrightness works as expected.
|
||||||
|
*/
|
||||||
|
TEST_F(GraphicsComposerHidlTest, setDisplayBrightness) {
|
||||||
|
if (!mComposerClient->getDisplayBrightnessSupport(mPrimaryDisplay)) {
|
||||||
|
EXPECT_EQ(mComposerClient->getRaw()->setDisplayBrightness(mPrimaryDisplay, 0.5f),
|
||||||
|
Error::UNSUPPORTED);
|
||||||
|
GTEST_SUCCEED() << "Brightness operations are not supported";
|
||||||
|
}
|
||||||
|
|
||||||
|
EXPECT_EQ(mComposerClient->setDisplayBrightness(mPrimaryDisplay, 0.0f), Error::NONE);
|
||||||
|
EXPECT_EQ(mComposerClient->setDisplayBrightness(mPrimaryDisplay, 0.5f), Error::NONE);
|
||||||
|
EXPECT_EQ(mComposerClient->setDisplayBrightness(mPrimaryDisplay, 1.0f), Error::NONE);
|
||||||
|
EXPECT_EQ(mComposerClient->setDisplayBrightness(mPrimaryDisplay, -1.0f), Error::NONE);
|
||||||
|
|
||||||
|
EXPECT_EQ(mComposerClient->setDisplayBrightness(mPrimaryDisplay, +2.0f), Error::BAD_PARAMETER);
|
||||||
|
EXPECT_EQ(mComposerClient->setDisplayBrightness(mPrimaryDisplay, -2.0f), Error::BAD_PARAMETER);
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
} // namespace vts
|
} // namespace vts
|
||||||
} // namespace V2_3
|
} // namespace V2_3
|
||||||
|
|
Loading…
Reference in a new issue