Loading cmds/dumpstate/dumpstate.cpp +1 −1 Original line number Diff line number Diff line Loading @@ -4656,7 +4656,7 @@ void Dumpstate::UpdateProgress(int32_t delta_sec) { void Dumpstate::TakeScreenshot(const std::string& path) { const std::string& real_path = path.empty() ? screenshot_path_ : path; int status = RunCommand("", {"/system/bin/screencap", "-p", real_path}, RunCommand("", {"screencap", "-p", real_path}, CommandOptions::WithTimeout(10).Always().DropRoot().RedirectStderr().Build()); if (status == 0) { MYLOGD("Screenshot saved on %s\n", real_path.c_str()); Loading libs/gui/Android.bp +1 −0 Original line number Diff line number Diff line Loading @@ -274,6 +274,7 @@ filegroup { "LayerMetadata.cpp", "LayerStatePermissions.cpp", "LayerState.cpp", "DisplayLuts.cpp", "OccupancyTracker.cpp", "StreamSplitter.cpp", "ScreenCaptureResults.cpp", Loading libs/gui/DisplayLuts.cpp 0 → 100644 +81 −0 Original line number Diff line number Diff line /* * Copyright (C) 2024 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #include "include/gui/DisplayLuts.h" #include <gui/DisplayLuts.h> #include <private/gui/ParcelUtils.h> namespace android::gui { status_t DisplayLuts::Entry::readFromParcel(const android::Parcel* parcel) { if (parcel == nullptr) { ALOGE("%s: Null parcel", __func__); return BAD_VALUE; } SAFE_PARCEL(parcel->readInt32, &dimension); SAFE_PARCEL(parcel->readInt32, &size); SAFE_PARCEL(parcel->readInt32, &samplingKey); return OK; } status_t DisplayLuts::Entry::writeToParcel(android::Parcel* parcel) const { if (parcel == nullptr) { ALOGE("%s: Null parcel", __func__); return BAD_VALUE; } SAFE_PARCEL(parcel->writeInt32, dimension); SAFE_PARCEL(parcel->writeInt32, size); SAFE_PARCEL(parcel->writeInt32, samplingKey); return OK; } status_t DisplayLuts::readFromParcel(const android::Parcel* parcel) { if (parcel == nullptr) { ALOGE("%s: Null parcel", __func__); return BAD_VALUE; } SAFE_PARCEL(parcel->readUniqueFileDescriptor, &fd); SAFE_PARCEL(parcel->readInt32Vector, &offsets); int32_t numLutProperties; SAFE_PARCEL(parcel->readInt32, &numLutProperties); lutProperties.reserve(numLutProperties); for (int32_t i = 0; i < numLutProperties; i++) { lutProperties.push_back({}); SAFE_PARCEL(lutProperties.back().readFromParcel, parcel); } return OK; } status_t DisplayLuts::writeToParcel(android::Parcel* parcel) const { if (parcel == nullptr) { ALOGE("%s: Null parcel", __func__); return BAD_VALUE; } SAFE_PARCEL(parcel->writeUniqueFileDescriptor, fd); SAFE_PARCEL(parcel->writeInt32Vector, offsets); SAFE_PARCEL(parcel->writeInt32, static_cast<int32_t>(lutProperties.size())); for (auto& entry : lutProperties) { SAFE_PARCEL(entry.writeToParcel, parcel); } return OK; } } // namespace android::gui No newline at end of file libs/gui/LayerState.cpp +41 −1 Original line number Diff line number Diff line Loading @@ -21,6 +21,7 @@ #include <android/gui/ISurfaceComposerClient.h> #include <android/native_window.h> #include <binder/Parcel.h> #include <com_android_graphics_libgui_flags.h> #include <gui/FrameRateUtils.h> #include <gui/IGraphicBufferProducer.h> #include <gui/LayerState.h> Loading Loading @@ -91,7 +92,9 @@ layer_state_t::layer_state_t() trustedOverlay(gui::TrustedOverlay::UNSET), bufferCrop(Rect::INVALID_RECT), destinationFrame(Rect::INVALID_RECT), dropInputMode(gui::DropInputMode::NONE) { dropInputMode(gui::DropInputMode::NONE), pictureProfileHandle(PictureProfileHandle::NONE), appContentPriority(0) { matrix.dsdx = matrix.dtdy = 1.0f; matrix.dsdy = matrix.dtdx = 0.0f; hdrMetadata.validTypes = 0; Loading Loading @@ -202,6 +205,16 @@ status_t layer_state_t::write(Parcel& output) const if (hasBufferReleaseChannel) { SAFE_PARCEL(output.writeParcelable, *bufferReleaseChannel); } #if COM_ANDROID_GRAPHICS_LIBGUI_FLAGS_APPLY_PICTURE_PROFILES SAFE_PARCEL(output.writeInt64, pictureProfileHandle.getId()); SAFE_PARCEL(output.writeInt32, appContentPriority); #endif // COM_ANDROID_GRAPHICS_LIBGUI_FLAGS_APPLY_PICTURE_PROFILES const bool hasLuts = (luts != nullptr); SAFE_PARCEL(output.writeBool, hasLuts); if (hasLuts) { SAFE_PARCEL(output.writeParcelable, *luts); } return NO_ERROR; } Loading Loading @@ -357,6 +370,21 @@ status_t layer_state_t::read(const Parcel& input) bufferReleaseChannel = std::make_shared<gui::BufferReleaseChannel::ProducerEndpoint>(); SAFE_PARCEL(input.readParcelable, bufferReleaseChannel.get()); } #if COM_ANDROID_GRAPHICS_LIBGUI_FLAGS_APPLY_PICTURE_PROFILES int64_t pictureProfileId; SAFE_PARCEL(input.readInt64, &pictureProfileId); pictureProfileHandle = PictureProfileHandle(pictureProfileId); SAFE_PARCEL(input.readInt32, &appContentPriority); #endif // COM_ANDROID_GRAPHICS_LIBGUI_FLAGS_APPLY_PICTURE_PROFILES bool hasLuts; SAFE_PARCEL(input.readBool, &hasLuts); if (hasLuts) { luts = std::make_shared<gui::DisplayLuts>(); SAFE_PARCEL(input.readParcelable, luts.get()); } else { luts = nullptr; } return NO_ERROR; } Loading Loading @@ -745,6 +773,16 @@ void layer_state_t::merge(const layer_state_t& other) { what |= eBufferReleaseChannelChanged; bufferReleaseChannel = other.bufferReleaseChannel; } if (com_android_graphics_libgui_flags_apply_picture_profiles()) { if (other.what & ePictureProfileHandleChanged) { what |= ePictureProfileHandleChanged; pictureProfileHandle = other.pictureProfileHandle; } if (other.what & eAppContentPriorityChanged) { what |= eAppContentPriorityChanged; appContentPriority = other.appContentPriority; } } if ((other.what & what) != other.what) { ALOGE("Unmerged SurfaceComposer Transaction properties. LayerState::merge needs updating? " "other.what=0x%" PRIX64 " what=0x%" PRIX64 " unmerged flags=0x%" PRIX64, Loading Loading @@ -826,6 +864,8 @@ uint64_t layer_state_t::diff(const layer_state_t& other) const { CHECK_DIFF(diff, eDimmingEnabledChanged, other, dimmingEnabled); if (other.what & eBufferReleaseChannelChanged) diff |= eBufferReleaseChannelChanged; if (other.what & eLutsChanged) diff |= eLutsChanged; CHECK_DIFF(diff, ePictureProfileHandleChanged, other, pictureProfileHandle); CHECK_DIFF(diff, eAppContentPriorityChanged, other, appContentPriority); return diff; } Loading libs/gui/SurfaceComposerClient.cpp +41 −4 Original line number Diff line number Diff line Loading @@ -20,8 +20,6 @@ #include <stdint.h> #include <sys/types.h> #include <com_android_graphics_libgui_flags.h> #include <android/gui/BnWindowInfosReportedListener.h> #include <android/gui/DisplayState.h> #include <android/gui/EdgeExtensionParameters.h> Loading @@ -29,6 +27,7 @@ #include <android/gui/IWindowInfosListener.h> #include <android/gui/TrustedPresentationThresholds.h> #include <android/os/IInputConstants.h> #include <com_android_graphics_libgui_flags.h> #include <gui/DisplayLuts.h> #include <gui/FrameRateUtils.h> #include <gui/TraceUtils.h> Loading Loading @@ -1971,9 +1970,13 @@ SurfaceComposerClient::Transaction& SurfaceComposerClient::Transaction::setLuts( return *this; } s->what |= layer_state_t::eLutsChanged; if (lutFd.ok()) { s->luts = std::make_shared<gui::DisplayLuts>(base::unique_fd(dup(lutFd.get())), offsets, dimensions, sizes, samplingKeys); s->what |= layer_state_t::eLutsChanged; } else { s->luts = nullptr; } registerSurfaceControlForCallback(sc); return *this; Loading Loading @@ -2447,6 +2450,40 @@ SurfaceComposerClient::Transaction& SurfaceComposerClient::Transaction::setBuffe return *this; } SurfaceComposerClient::Transaction& SurfaceComposerClient::Transaction::setPictureProfileHandle( const sp<SurfaceControl>& sc, const PictureProfileHandle& pictureProfileHandle) { if (com_android_graphics_libgui_flags_apply_picture_profiles()) { layer_state_t* s = getLayerState(sc); if (!s) { mStatus = BAD_INDEX; return *this; } s->what |= layer_state_t::ePictureProfileHandleChanged; s->pictureProfileHandle = pictureProfileHandle; registerSurfaceControlForCallback(sc); } return *this; } SurfaceComposerClient::Transaction& SurfaceComposerClient::Transaction::setContentPriority( const sp<SurfaceControl>& sc, int32_t priority) { if (com_android_graphics_libgui_flags_apply_picture_profiles()) { layer_state_t* s = getLayerState(sc); if (!s) { mStatus = BAD_INDEX; return *this; } s->what |= layer_state_t::eAppContentPriorityChanged; s->appContentPriority = priority; registerSurfaceControlForCallback(sc); } return *this; } // --------------------------------------------------------------------------- DisplayState& SurfaceComposerClient::Transaction::getDisplayState(const sp<IBinder>& token) { Loading Loading
cmds/dumpstate/dumpstate.cpp +1 −1 Original line number Diff line number Diff line Loading @@ -4656,7 +4656,7 @@ void Dumpstate::UpdateProgress(int32_t delta_sec) { void Dumpstate::TakeScreenshot(const std::string& path) { const std::string& real_path = path.empty() ? screenshot_path_ : path; int status = RunCommand("", {"/system/bin/screencap", "-p", real_path}, RunCommand("", {"screencap", "-p", real_path}, CommandOptions::WithTimeout(10).Always().DropRoot().RedirectStderr().Build()); if (status == 0) { MYLOGD("Screenshot saved on %s\n", real_path.c_str()); Loading
libs/gui/Android.bp +1 −0 Original line number Diff line number Diff line Loading @@ -274,6 +274,7 @@ filegroup { "LayerMetadata.cpp", "LayerStatePermissions.cpp", "LayerState.cpp", "DisplayLuts.cpp", "OccupancyTracker.cpp", "StreamSplitter.cpp", "ScreenCaptureResults.cpp", Loading
libs/gui/DisplayLuts.cpp 0 → 100644 +81 −0 Original line number Diff line number Diff line /* * Copyright (C) 2024 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #include "include/gui/DisplayLuts.h" #include <gui/DisplayLuts.h> #include <private/gui/ParcelUtils.h> namespace android::gui { status_t DisplayLuts::Entry::readFromParcel(const android::Parcel* parcel) { if (parcel == nullptr) { ALOGE("%s: Null parcel", __func__); return BAD_VALUE; } SAFE_PARCEL(parcel->readInt32, &dimension); SAFE_PARCEL(parcel->readInt32, &size); SAFE_PARCEL(parcel->readInt32, &samplingKey); return OK; } status_t DisplayLuts::Entry::writeToParcel(android::Parcel* parcel) const { if (parcel == nullptr) { ALOGE("%s: Null parcel", __func__); return BAD_VALUE; } SAFE_PARCEL(parcel->writeInt32, dimension); SAFE_PARCEL(parcel->writeInt32, size); SAFE_PARCEL(parcel->writeInt32, samplingKey); return OK; } status_t DisplayLuts::readFromParcel(const android::Parcel* parcel) { if (parcel == nullptr) { ALOGE("%s: Null parcel", __func__); return BAD_VALUE; } SAFE_PARCEL(parcel->readUniqueFileDescriptor, &fd); SAFE_PARCEL(parcel->readInt32Vector, &offsets); int32_t numLutProperties; SAFE_PARCEL(parcel->readInt32, &numLutProperties); lutProperties.reserve(numLutProperties); for (int32_t i = 0; i < numLutProperties; i++) { lutProperties.push_back({}); SAFE_PARCEL(lutProperties.back().readFromParcel, parcel); } return OK; } status_t DisplayLuts::writeToParcel(android::Parcel* parcel) const { if (parcel == nullptr) { ALOGE("%s: Null parcel", __func__); return BAD_VALUE; } SAFE_PARCEL(parcel->writeUniqueFileDescriptor, fd); SAFE_PARCEL(parcel->writeInt32Vector, offsets); SAFE_PARCEL(parcel->writeInt32, static_cast<int32_t>(lutProperties.size())); for (auto& entry : lutProperties) { SAFE_PARCEL(entry.writeToParcel, parcel); } return OK; } } // namespace android::gui No newline at end of file
libs/gui/LayerState.cpp +41 −1 Original line number Diff line number Diff line Loading @@ -21,6 +21,7 @@ #include <android/gui/ISurfaceComposerClient.h> #include <android/native_window.h> #include <binder/Parcel.h> #include <com_android_graphics_libgui_flags.h> #include <gui/FrameRateUtils.h> #include <gui/IGraphicBufferProducer.h> #include <gui/LayerState.h> Loading Loading @@ -91,7 +92,9 @@ layer_state_t::layer_state_t() trustedOverlay(gui::TrustedOverlay::UNSET), bufferCrop(Rect::INVALID_RECT), destinationFrame(Rect::INVALID_RECT), dropInputMode(gui::DropInputMode::NONE) { dropInputMode(gui::DropInputMode::NONE), pictureProfileHandle(PictureProfileHandle::NONE), appContentPriority(0) { matrix.dsdx = matrix.dtdy = 1.0f; matrix.dsdy = matrix.dtdx = 0.0f; hdrMetadata.validTypes = 0; Loading Loading @@ -202,6 +205,16 @@ status_t layer_state_t::write(Parcel& output) const if (hasBufferReleaseChannel) { SAFE_PARCEL(output.writeParcelable, *bufferReleaseChannel); } #if COM_ANDROID_GRAPHICS_LIBGUI_FLAGS_APPLY_PICTURE_PROFILES SAFE_PARCEL(output.writeInt64, pictureProfileHandle.getId()); SAFE_PARCEL(output.writeInt32, appContentPriority); #endif // COM_ANDROID_GRAPHICS_LIBGUI_FLAGS_APPLY_PICTURE_PROFILES const bool hasLuts = (luts != nullptr); SAFE_PARCEL(output.writeBool, hasLuts); if (hasLuts) { SAFE_PARCEL(output.writeParcelable, *luts); } return NO_ERROR; } Loading Loading @@ -357,6 +370,21 @@ status_t layer_state_t::read(const Parcel& input) bufferReleaseChannel = std::make_shared<gui::BufferReleaseChannel::ProducerEndpoint>(); SAFE_PARCEL(input.readParcelable, bufferReleaseChannel.get()); } #if COM_ANDROID_GRAPHICS_LIBGUI_FLAGS_APPLY_PICTURE_PROFILES int64_t pictureProfileId; SAFE_PARCEL(input.readInt64, &pictureProfileId); pictureProfileHandle = PictureProfileHandle(pictureProfileId); SAFE_PARCEL(input.readInt32, &appContentPriority); #endif // COM_ANDROID_GRAPHICS_LIBGUI_FLAGS_APPLY_PICTURE_PROFILES bool hasLuts; SAFE_PARCEL(input.readBool, &hasLuts); if (hasLuts) { luts = std::make_shared<gui::DisplayLuts>(); SAFE_PARCEL(input.readParcelable, luts.get()); } else { luts = nullptr; } return NO_ERROR; } Loading Loading @@ -745,6 +773,16 @@ void layer_state_t::merge(const layer_state_t& other) { what |= eBufferReleaseChannelChanged; bufferReleaseChannel = other.bufferReleaseChannel; } if (com_android_graphics_libgui_flags_apply_picture_profiles()) { if (other.what & ePictureProfileHandleChanged) { what |= ePictureProfileHandleChanged; pictureProfileHandle = other.pictureProfileHandle; } if (other.what & eAppContentPriorityChanged) { what |= eAppContentPriorityChanged; appContentPriority = other.appContentPriority; } } if ((other.what & what) != other.what) { ALOGE("Unmerged SurfaceComposer Transaction properties. LayerState::merge needs updating? " "other.what=0x%" PRIX64 " what=0x%" PRIX64 " unmerged flags=0x%" PRIX64, Loading Loading @@ -826,6 +864,8 @@ uint64_t layer_state_t::diff(const layer_state_t& other) const { CHECK_DIFF(diff, eDimmingEnabledChanged, other, dimmingEnabled); if (other.what & eBufferReleaseChannelChanged) diff |= eBufferReleaseChannelChanged; if (other.what & eLutsChanged) diff |= eLutsChanged; CHECK_DIFF(diff, ePictureProfileHandleChanged, other, pictureProfileHandle); CHECK_DIFF(diff, eAppContentPriorityChanged, other, appContentPriority); return diff; } Loading
libs/gui/SurfaceComposerClient.cpp +41 −4 Original line number Diff line number Diff line Loading @@ -20,8 +20,6 @@ #include <stdint.h> #include <sys/types.h> #include <com_android_graphics_libgui_flags.h> #include <android/gui/BnWindowInfosReportedListener.h> #include <android/gui/DisplayState.h> #include <android/gui/EdgeExtensionParameters.h> Loading @@ -29,6 +27,7 @@ #include <android/gui/IWindowInfosListener.h> #include <android/gui/TrustedPresentationThresholds.h> #include <android/os/IInputConstants.h> #include <com_android_graphics_libgui_flags.h> #include <gui/DisplayLuts.h> #include <gui/FrameRateUtils.h> #include <gui/TraceUtils.h> Loading Loading @@ -1971,9 +1970,13 @@ SurfaceComposerClient::Transaction& SurfaceComposerClient::Transaction::setLuts( return *this; } s->what |= layer_state_t::eLutsChanged; if (lutFd.ok()) { s->luts = std::make_shared<gui::DisplayLuts>(base::unique_fd(dup(lutFd.get())), offsets, dimensions, sizes, samplingKeys); s->what |= layer_state_t::eLutsChanged; } else { s->luts = nullptr; } registerSurfaceControlForCallback(sc); return *this; Loading Loading @@ -2447,6 +2450,40 @@ SurfaceComposerClient::Transaction& SurfaceComposerClient::Transaction::setBuffe return *this; } SurfaceComposerClient::Transaction& SurfaceComposerClient::Transaction::setPictureProfileHandle( const sp<SurfaceControl>& sc, const PictureProfileHandle& pictureProfileHandle) { if (com_android_graphics_libgui_flags_apply_picture_profiles()) { layer_state_t* s = getLayerState(sc); if (!s) { mStatus = BAD_INDEX; return *this; } s->what |= layer_state_t::ePictureProfileHandleChanged; s->pictureProfileHandle = pictureProfileHandle; registerSurfaceControlForCallback(sc); } return *this; } SurfaceComposerClient::Transaction& SurfaceComposerClient::Transaction::setContentPriority( const sp<SurfaceControl>& sc, int32_t priority) { if (com_android_graphics_libgui_flags_apply_picture_profiles()) { layer_state_t* s = getLayerState(sc); if (!s) { mStatus = BAD_INDEX; return *this; } s->what |= layer_state_t::eAppContentPriorityChanged; s->appContentPriority = priority; registerSurfaceControlForCallback(sc); } return *this; } // --------------------------------------------------------------------------- DisplayState& SurfaceComposerClient::Transaction::getDisplayState(const sp<IBinder>& token) { Loading