Skip to content

Commit 2beca48

Browse files
author
Sally Qi
committed
[Lut screenshot] backend implementation
Bug: 352585077 Test: builds Flag: EXEMPT no flag needed Change-Id: Ib1e3bbb7e7c9ca35817f8d6e80e0a45f296a6af8
1 parent 1903112 commit 2beca48

12 files changed

Lines changed: 71 additions & 0 deletions

File tree

services/surfaceflinger/DisplayHardware/AidlComposerHal.cpp

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1678,6 +1678,29 @@ Error AidlComposer::setLayerPictureProfileId(Display display, Layer layer, Pictu
16781678
return error;
16791679
}
16801680

1681+
Error AidlComposer::getLuts(Display display, const std::vector<sp<GraphicBuffer>>& buffers,
1682+
std::vector<aidl::android::hardware::graphics::composer3::Luts>* luts) {
1683+
std::vector<aidl::android::hardware::graphics::composer3::Buffer> aidlBuffers;
1684+
aidlBuffers.reserve(buffers.size());
1685+
1686+
for (auto& buffer : buffers) {
1687+
if (buffer.get()) {
1688+
aidl::android::hardware::graphics::composer3::Buffer aidlBuffer;
1689+
aidlBuffer.handle.emplace(::android::dupToAidl(buffer->getNativeBuffer()->handle));
1690+
aidlBuffers.emplace_back(std::move(aidlBuffer));
1691+
}
1692+
}
1693+
1694+
const auto status =
1695+
mAidlComposerClient->getLuts(translate<int64_t>(display), aidlBuffers, luts);
1696+
if (!status.isOk()) {
1697+
ALOGE("getLuts failed %s", status.getDescription().c_str());
1698+
return static_cast<Error>(status.getServiceSpecificError());
1699+
}
1700+
1701+
return Error::NONE;
1702+
}
1703+
16811704
ftl::Optional<std::reference_wrapper<ComposerClientWriter>> AidlComposer::getWriter(Display display)
16821705
REQUIRES_SHARED(mMutex) {
16831706
return mWriters.get(display);

services/surfaceflinger/DisplayHardware/AidlComposerHal.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,8 @@ class AidlComposer final : public Hwc2::Composer {
245245
Error getMaxLayerPictureProfiles(Display, int32_t* outMaxProfiles) override;
246246
Error setDisplayPictureProfileId(Display, PictureProfileId id) override;
247247
Error setLayerPictureProfileId(Display, Layer, PictureProfileId id) override;
248+
Error getLuts(Display, const std::vector<sp<GraphicBuffer>>&,
249+
std::vector<aidl::android::hardware::graphics::composer3::Luts>*) override;
248250

249251
private:
250252
// Many public functions above simply write a command into the command

services/surfaceflinger/DisplayHardware/ComposerHal.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@
4646
#include <aidl/android/hardware/graphics/composer3/DisplayConfiguration.h>
4747
#include <aidl/android/hardware/graphics/composer3/DisplayLuts.h>
4848
#include <aidl/android/hardware/graphics/composer3/IComposerCallback.h>
49+
#include <aidl/android/hardware/graphics/composer3/Luts.h>
4950
#include <aidl/android/hardware/graphics/composer3/OverlayProperties.h>
5051

5152
#include <optional>
@@ -313,6 +314,8 @@ class Composer {
313314
virtual Error getMaxLayerPictureProfiles(Display display, int32_t* outMaxProfiles) = 0;
314315
virtual Error setDisplayPictureProfileId(Display display, PictureProfileId id) = 0;
315316
virtual Error setLayerPictureProfileId(Display display, Layer layer, PictureProfileId id) = 0;
317+
virtual Error getLuts(Display display, const std::vector<sp<GraphicBuffer>>&,
318+
std::vector<V3_0::Luts>*) = 0;
316319
};
317320

318321
} // namespace Hwc2

services/surfaceflinger/DisplayHardware/HWC2.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -669,6 +669,12 @@ Error Display::setPictureProfileHandle(const PictureProfileHandle& handle) {
669669
return static_cast<Error>(error);
670670
}
671671

672+
Error Display::getLuts(const std::vector<sp<GraphicBuffer>>& buffers,
673+
std::vector<aidl::android::hardware::graphics::composer3::Luts>* outLuts) {
674+
const auto error = mComposer.getLuts(mId, buffers, outLuts);
675+
return static_cast<Error>(error);
676+
}
677+
672678
// For use by Device
673679

674680
void Display::setConnected(bool connected) {

services/surfaceflinger/DisplayHardware/HWC2.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,9 @@ class Display {
203203
[[nodiscard]] virtual hal::Error getMaxLayerPictureProfiles(int32_t* maxProfiles) = 0;
204204
[[nodiscard]] virtual hal::Error setPictureProfileHandle(
205205
const PictureProfileHandle& handle) = 0;
206+
[[nodiscard]] virtual hal::Error getLuts(
207+
const std::vector<android::sp<android::GraphicBuffer>>&,
208+
std::vector<aidl::android::hardware::graphics::composer3::Luts>*) = 0;
206209
};
207210

208211
namespace impl {
@@ -288,6 +291,8 @@ class Display : public HWC2::Display {
288291
hal::Error setIdleTimerEnabled(std::chrono::milliseconds timeout) override;
289292
hal::Error getMaxLayerPictureProfiles(int32_t* maxProfiles) override;
290293
hal::Error setPictureProfileHandle(const android::PictureProfileHandle& handle) override;
294+
hal::Error getLuts(const std::vector<android::sp<android::GraphicBuffer>>&,
295+
std::vector<aidl::android::hardware::graphics::composer3::Luts>*) override;
291296

292297
// Other Display methods
293298
hal::HWDisplayId getId() const override { return mId; }

services/surfaceflinger/DisplayHardware/HWComposer.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1046,6 +1046,16 @@ status_t HWComposer::setDisplayPictureProfileHandle(PhysicalDisplayId displayId,
10461046
return NO_ERROR;
10471047
}
10481048

1049+
status_t HWComposer::getLuts(
1050+
PhysicalDisplayId displayId, const std::vector<sp<GraphicBuffer>>& buffers,
1051+
std::vector<aidl::android::hardware::graphics::composer3::Luts>* luts) {
1052+
RETURN_IF_INVALID_DISPLAY(displayId, BAD_INDEX);
1053+
auto& hwcDisplay = mDisplayData[displayId].hwcDisplay;
1054+
auto error = hwcDisplay->getLuts(buffers, luts);
1055+
RETURN_IF_HWC_ERROR(error, displayId, UNKNOWN_ERROR);
1056+
return NO_ERROR;
1057+
}
1058+
10491059
const std::unordered_map<std::string, bool>& HWComposer::getSupportedLayerGenericMetadata() const {
10501060
return mSupportedLayerGenericMetadata;
10511061
}

services/surfaceflinger/DisplayHardware/HWComposer.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@
5555
#include <aidl/android/hardware/graphics/composer3/DisplayCapability.h>
5656
#include <aidl/android/hardware/graphics/composer3/DisplayLuts.h>
5757
#include <aidl/android/hardware/graphics/composer3/LutProperties.h>
58+
#include <aidl/android/hardware/graphics/composer3/Luts.h>
5859
#include <aidl/android/hardware/graphics/composer3/OutputType.h>
5960
#include <aidl/android/hardware/graphics/composer3/OverlayProperties.h>
6061

@@ -324,6 +325,8 @@ class HWComposer {
324325
virtual int32_t getMaxLayerPictureProfiles(PhysicalDisplayId) = 0;
325326
virtual status_t setDisplayPictureProfileHandle(PhysicalDisplayId,
326327
const PictureProfileHandle& handle) = 0;
328+
virtual status_t getLuts(PhysicalDisplayId, const std::vector<sp<GraphicBuffer>>&,
329+
std::vector<aidl::android::hardware::graphics::composer3::Luts>*) = 0;
327330
};
328331

329332
static inline bool operator==(const android::HWComposer::DeviceRequestedChanges& lhs,
@@ -491,6 +494,8 @@ class HWComposer final : public android::HWComposer {
491494
int32_t getMaxLayerPictureProfiles(PhysicalDisplayId) override;
492495
status_t setDisplayPictureProfileHandle(PhysicalDisplayId,
493496
const android::PictureProfileHandle& profile) override;
497+
status_t getLuts(PhysicalDisplayId, const std::vector<sp<GraphicBuffer>>&,
498+
std::vector<aidl::android::hardware::graphics::composer3::Luts>*) override;
494499

495500
// for debugging ----------------------------------------------------------
496501
void dump(std::string& out) const override;

services/surfaceflinger/DisplayHardware/HidlComposerHal.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1452,6 +1452,11 @@ Error HidlComposer::getMaxLayerPictureProfiles(Display, int32_t*) {
14521452
return Error::UNSUPPORTED;
14531453
}
14541454

1455+
Error HidlComposer::getLuts(Display, const std::vector<sp<GraphicBuffer>>&,
1456+
std::vector<aidl::android::hardware::graphics::composer3::Luts>*) {
1457+
return Error::UNSUPPORTED;
1458+
}
1459+
14551460
Error HidlComposer::setDisplayPictureProfileId(Display, PictureProfileId) {
14561461
return Error::UNSUPPORTED;
14571462
}

services/surfaceflinger/DisplayHardware/HidlComposerHal.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -359,6 +359,8 @@ class HidlComposer final : public Composer {
359359
Error getMaxLayerPictureProfiles(Display, int32_t* outMaxProfiles) override;
360360
Error setDisplayPictureProfileId(Display, PictureProfileId) override;
361361
Error setLayerPictureProfileId(Display, Layer, PictureProfileId) override;
362+
Error getLuts(Display, const std::vector<sp<GraphicBuffer>>&,
363+
std::vector<aidl::android::hardware::graphics::composer3::Luts>*) override;
362364

363365
private:
364366
class CommandWriter : public CommandWriterBase {

services/surfaceflinger/tests/unittests/mock/DisplayHardware/MockComposer.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,9 @@ class Composer : public Hwc2::Composer {
190190
MOCK_METHOD(Error, getMaxLayerPictureProfiles, (Display, int32_t*));
191191
MOCK_METHOD(Error, setDisplayPictureProfileId, (Display, PictureProfileId id));
192192
MOCK_METHOD(Error, setLayerPictureProfileId, (Display, Layer, PictureProfileId id));
193+
MOCK_METHOD(Error, getLuts,
194+
(Display, const std::vector<sp<GraphicBuffer>>&,
195+
std::vector<aidl::android::hardware::graphics::composer3::Luts>*));
193196
};
194197

195198
} // namespace Hwc2::mock

0 commit comments

Comments
 (0)