@@ -589,28 +589,30 @@ void OutputLayer::writeOutputIndependentGeometryStateToHWC(
589589
590590void OutputLayer::writeLutToHWC (HWC2::Layer* hwcLayer,
591591 const LayerFECompositionState& outputIndependentState) {
592- if (!outputIndependentState.luts ) {
593- return ;
594- }
595- auto & lutFileDescriptor = outputIndependentState.luts ->getLutFileDescriptor ();
596- auto lutOffsets = outputIndependentState.luts ->offsets ;
597- auto & lutProperties = outputIndependentState.luts ->lutProperties ;
592+ Luts luts;
593+ // if outputIndependentState.luts is nullptr, it means we want to clear the LUTs
594+ // and we pass an empty Luts object to the HWC.
595+ if (outputIndependentState.luts ) {
596+ auto & lutFileDescriptor = outputIndependentState.luts ->getLutFileDescriptor ();
597+ auto lutOffsets = outputIndependentState.luts ->offsets ;
598+ auto & lutProperties = outputIndependentState.luts ->lutProperties ;
599+
600+ std::vector<LutProperties> aidlProperties;
601+ aidlProperties.reserve (lutProperties.size ());
602+ for (size_t i = 0 ; i < lutOffsets.size (); i++) {
603+ LutProperties properties;
604+ properties.dimension = static_cast <LutProperties::Dimension>(lutProperties[i].dimension );
605+ properties.size = lutProperties[i].size ;
606+ properties.samplingKeys = {
607+ static_cast <LutProperties::SamplingKey>(lutProperties[i].samplingKey )};
608+ aidlProperties.emplace_back (properties);
609+ }
598610
599- std::vector<LutProperties> aidlProperties;
600- aidlProperties.reserve (lutProperties.size ());
601- for (size_t i = 0 ; i < lutOffsets.size (); i++) {
602- LutProperties properties;
603- properties.dimension = static_cast <LutProperties::Dimension>(lutProperties[i].dimension );
604- properties.size = lutProperties[i].size ;
605- properties.samplingKeys = {
606- static_cast <LutProperties::SamplingKey>(lutProperties[i].samplingKey )};
607- aidlProperties.emplace_back (properties);
608- }
609611
610- Luts luts;
611- luts.pfd = ndk::ScopedFileDescriptor ( dup (lutFileDescriptor. get ())) ;
612- luts.offsets = lutOffsets ;
613- luts. lutProperties = std::move (aidlProperties);
612+ luts. pfd = ndk::ScopedFileDescriptor ( dup (lutFileDescriptor. get ())) ;
613+ luts.offsets = lutOffsets ;
614+ luts.lutProperties = std::move (aidlProperties) ;
615+ }
614616
615617 switch (auto error = hwcLayer->setLuts (luts)) {
616618 case hal::Error::NONE:
0 commit comments