Move CaptureArgs + friends to structured aidl
No more manual parceling!
Bug: 329465218
Flag: EXEMPT mechanical refactor
Test: builds
Test: courage
Change-Id: I9f5eba12db615d6b02de0686193381f7a63bb043
diff --git a/libs/gui/LayerState.cpp b/libs/gui/LayerState.cpp
index 0714fd9..b109969 100644
--- a/libs/gui/LayerState.cpp
+++ b/libs/gui/LayerState.cpp
@@ -892,88 +892,6 @@
// ----------------------------------------------------------------------------
-namespace gui {
-
-status_t CaptureArgs::writeToParcel(Parcel* output) const {
- SAFE_PARCEL(output->writeInt32, static_cast<int32_t>(pixelFormat));
- SAFE_PARCEL(output->write, sourceCrop);
- SAFE_PARCEL(output->writeFloat, frameScaleX);
- SAFE_PARCEL(output->writeFloat, frameScaleY);
- SAFE_PARCEL(output->writeBool, captureSecureLayers);
- SAFE_PARCEL(output->writeInt32, uid);
- SAFE_PARCEL(output->writeInt32, static_cast<int32_t>(dataspace));
- SAFE_PARCEL(output->writeBool, allowProtected);
- SAFE_PARCEL(output->writeBool, grayscale);
- SAFE_PARCEL(output->writeInt32, excludeHandles.size());
- for (auto& excludeHandle : excludeHandles) {
- SAFE_PARCEL(output->writeStrongBinder, excludeHandle);
- }
- SAFE_PARCEL(output->writeBool, hintForSeamlessTransition);
- return NO_ERROR;
-}
-
-status_t CaptureArgs::readFromParcel(const Parcel* input) {
- int32_t value = 0;
- SAFE_PARCEL(input->readInt32, &value);
- pixelFormat = static_cast<ui::PixelFormat>(value);
- SAFE_PARCEL(input->read, sourceCrop);
- SAFE_PARCEL(input->readFloat, &frameScaleX);
- SAFE_PARCEL(input->readFloat, &frameScaleY);
- SAFE_PARCEL(input->readBool, &captureSecureLayers);
- SAFE_PARCEL(input->readInt32, &uid);
- SAFE_PARCEL(input->readInt32, &value);
- dataspace = static_cast<ui::Dataspace>(value);
- SAFE_PARCEL(input->readBool, &allowProtected);
- SAFE_PARCEL(input->readBool, &grayscale);
- int32_t numExcludeHandles = 0;
- SAFE_PARCEL_READ_SIZE(input->readInt32, &numExcludeHandles, input->dataSize());
- excludeHandles.reserve(numExcludeHandles);
- for (int i = 0; i < numExcludeHandles; i++) {
- sp<IBinder> binder;
- SAFE_PARCEL(input->readStrongBinder, &binder);
- excludeHandles.emplace(binder);
- }
- SAFE_PARCEL(input->readBool, &hintForSeamlessTransition);
- return NO_ERROR;
-}
-
-status_t DisplayCaptureArgs::writeToParcel(Parcel* output) const {
- SAFE_PARCEL(CaptureArgs::writeToParcel, output);
-
- SAFE_PARCEL(output->writeStrongBinder, displayToken);
- SAFE_PARCEL(output->writeUint32, width);
- SAFE_PARCEL(output->writeUint32, height);
- return NO_ERROR;
-}
-
-status_t DisplayCaptureArgs::readFromParcel(const Parcel* input) {
- SAFE_PARCEL(CaptureArgs::readFromParcel, input);
-
- SAFE_PARCEL(input->readStrongBinder, &displayToken);
- SAFE_PARCEL(input->readUint32, &width);
- SAFE_PARCEL(input->readUint32, &height);
- return NO_ERROR;
-}
-
-status_t LayerCaptureArgs::writeToParcel(Parcel* output) const {
- SAFE_PARCEL(CaptureArgs::writeToParcel, output);
-
- SAFE_PARCEL(output->writeStrongBinder, layerHandle);
- SAFE_PARCEL(output->writeBool, childrenOnly);
- return NO_ERROR;
-}
-
-status_t LayerCaptureArgs::readFromParcel(const Parcel* input) {
- SAFE_PARCEL(CaptureArgs::readFromParcel, input);
-
- SAFE_PARCEL(input->readStrongBinder, &layerHandle);
-
- SAFE_PARCEL(input->readBool, &childrenOnly);
- return NO_ERROR;
-}
-
-}; // namespace gui
-
ReleaseCallbackId BufferData::generateReleaseCallbackId() const {
uint64_t bufferId;
if (buffer) {
diff --git a/libs/gui/aidl/Android.bp b/libs/gui/aidl/Android.bp
index 8ed08c2..fd035f6 100644
--- a/libs/gui/aidl/Android.bp
+++ b/libs/gui/aidl/Android.bp
@@ -28,9 +28,6 @@
":libgui_extra_unstructured_aidl_files",
"android/gui/BitTube.aidl",
- "android/gui/CaptureArgs.aidl",
- "android/gui/DisplayCaptureArgs.aidl",
- "android/gui/LayerCaptureArgs.aidl",
"android/gui/LayerMetadata.aidl",
"android/gui/ParcelableVsyncEventData.aidl",
"android/gui/ScreenCaptureResults.aidl",
diff --git a/libs/gui/aidl/android/gui/CaptureArgs.aidl b/libs/gui/aidl/android/gui/CaptureArgs.aidl
index 9f198ca..2bbed2b 100644
--- a/libs/gui/aidl/android/gui/CaptureArgs.aidl
+++ b/libs/gui/aidl/android/gui/CaptureArgs.aidl
@@ -16,4 +16,58 @@
package android.gui;
-parcelable CaptureArgs cpp_header "gui/DisplayCaptureArgs.h" rust_type "gui_aidl_types_rs::CaptureArgs";
+import android.gui.ARect;
+
+// Common arguments for capturing content on-screen
+parcelable CaptureArgs {
+ const int UNSET_UID = -1;
+
+ // Desired pixel format of the final screenshotted buffer
+ int /*ui::PixelFormat*/ pixelFormat = 1;
+
+ // Crop in layer space: all content outside of the crop will not be captured.
+ ARect sourceCrop;
+
+ // Scale in the x-direction for the screenshotted result.
+ float frameScaleX = 1.0f;
+
+ // Scale in the y-direction for the screenshotted result.
+ float frameScaleY = 1.0f;
+
+ // True if capturing secure layers is permitted
+ boolean captureSecureLayers = false;
+
+ // UID whose content we want to screenshot
+ int uid = UNSET_UID;
+
+ // Force capture to be in a color space. If the value is ui::Dataspace::UNKNOWN, the captured
+ // result will be in a colorspace appropriate for capturing the display contents
+ // The display may use non-RGB dataspace (ex. displayP3) that could cause pixel data could be
+ // different from SRGB (byte per color), and failed when checking colors in tests.
+ // NOTE: In normal cases, we want the screen to be captured in display's colorspace.
+ int /*ui::Dataspace*/ dataspace = 0;
+
+ // The receiver of the capture can handle protected buffer. A protected buffer has
+ // GRALLOC_USAGE_PROTECTED usage bit and must not be accessed unprotected behaviour.
+ // Any read/write access from unprotected context will result in undefined behaviour.
+ // Protected contents are typically DRM contents. This has no direct implication to the
+ // secure property of the surface, which is specified by the application explicitly to avoid
+ // the contents being accessed/captured by screenshot or unsecure display.
+ boolean allowProtected = false;
+
+ // True if the content should be captured in grayscale
+ boolean grayscale = false;
+
+ // List of layers to exclude capturing from
+ IBinder[] excludeHandles;
+
+ // Hint that the caller will use the screenshot animation as part of a transition animation.
+ // The canonical example would be screen rotation - in such a case any color shift in the
+ // screenshot is a detractor so composition in the display's colorspace is required.
+ // Otherwise, the system may choose a colorspace that is more appropriate for use-cases
+ // such as file encoding or for blending HDR content into an ap's UI, where the display's
+ // exact colorspace is not an appropriate intermediate result.
+ // Note that if the caller is requesting a specific dataspace, this hint does nothing.
+ boolean hintForSeamlessTransition = false;
+}
+
diff --git a/libs/gui/aidl/android/gui/DisplayCaptureArgs.aidl b/libs/gui/aidl/android/gui/DisplayCaptureArgs.aidl
index fc97dbf..e00a2df 100644
--- a/libs/gui/aidl/android/gui/DisplayCaptureArgs.aidl
+++ b/libs/gui/aidl/android/gui/DisplayCaptureArgs.aidl
@@ -16,5 +16,18 @@
package android.gui;
-parcelable DisplayCaptureArgs cpp_header "gui/DisplayCaptureArgs.h" rust_type "gui_aidl_types_rs::DisplayCaptureArgs";
+import android.gui.CaptureArgs;
+
+// Arguments for screenshotting an entire display
+parcelable DisplayCaptureArgs {
+ CaptureArgs captureArgs;
+
+ // The display that we want to screenshot
+ IBinder displayToken;
+
+ // The width of the render area when we screenshot
+ int width = 0;
+ // The length of the render area when we screenshot
+ int height = 0;
+}
diff --git a/libs/gui/aidl/android/gui/LayerCaptureArgs.aidl b/libs/gui/aidl/android/gui/LayerCaptureArgs.aidl
index 18d293f..004c35a 100644
--- a/libs/gui/aidl/android/gui/LayerCaptureArgs.aidl
+++ b/libs/gui/aidl/android/gui/LayerCaptureArgs.aidl
@@ -16,4 +16,15 @@
package android.gui;
-parcelable LayerCaptureArgs cpp_header "gui/LayerCaptureArgs.h" rust_type "gui_aidl_types_rs::LayerCaptureArgs";
+import android.gui.CaptureArgs;
+
+// Arguments for capturing a layer and/or its children
+parcelable LayerCaptureArgs {
+ CaptureArgs captureArgs;
+
+ // The Layer that we may want to capture. We would also capture its children
+ IBinder layerHandle;
+ // True if we don't actually want to capture the layer and want to capture
+ // its children instead.
+ boolean childrenOnly = false;
+}
diff --git a/libs/gui/include/gui/AidlStatusUtil.h b/libs/gui/include/gui/AidlStatusUtil.h
index 55be27b..159e032 100644
--- a/libs/gui/include/gui/AidlStatusUtil.h
+++ b/libs/gui/include/gui/AidlStatusUtil.h
@@ -16,9 +16,11 @@
#pragma once
+#include <android/gui/ARect.h>
#include <binder/Status.h>
+#include <ui/Rect.h>
-// Extracted from frameworks/av/media/libaudioclient/include/media/AidlConversionUtil.h
+// Originally extracted from frameworks/av/media/libaudioclient/include/media/AidlConversionUtil.h
namespace android::gui::aidl_utils {
/**
@@ -111,4 +113,26 @@
return Status::fromServiceSpecificError(status, emptyIfNull);
}
+static inline Rect fromARect(ARect rect) {
+ return Rect(rect.left, rect.top, rect.right, rect.bottom);
+}
+
+static inline ARect toARect(Rect rect) {
+ ARect aRect;
+
+ aRect.left = rect.left;
+ aRect.top = rect.top;
+ aRect.right = rect.right;
+ aRect.bottom = rect.bottom;
+ return aRect;
+}
+
+static inline ARect toARect(int32_t left, int32_t top, int32_t right, int32_t bottom) {
+ return toARect(Rect(left, top, right, bottom));
+}
+
+static inline ARect toARect(int32_t width, int32_t height) {
+ return toARect(Rect(width, height));
+}
+
} // namespace android::gui::aidl_utils
diff --git a/libs/gui/include/gui/DisplayCaptureArgs.h b/libs/gui/include/gui/DisplayCaptureArgs.h
deleted file mode 100644
index e29ce41..0000000
--- a/libs/gui/include/gui/DisplayCaptureArgs.h
+++ /dev/null
@@ -1,84 +0,0 @@
-/*
- * Copyright (C) 2022 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.
- */
-
-#pragma once
-
-#include <stdint.h>
-#include <sys/types.h>
-
-#include <binder/IBinder.h>
-#include <binder/Parcel.h>
-#include <binder/Parcelable.h>
-#include <gui/SpHash.h>
-#include <ui/GraphicTypes.h>
-#include <ui/PixelFormat.h>
-#include <ui/Rect.h>
-#include <unordered_set>
-
-namespace android::gui {
-
-struct CaptureArgs : public Parcelable {
- const static int32_t UNSET_UID = -1;
- virtual ~CaptureArgs() = default;
-
- ui::PixelFormat pixelFormat{ui::PixelFormat::RGBA_8888};
- Rect sourceCrop;
- float frameScaleX{1};
- float frameScaleY{1};
- bool captureSecureLayers{false};
- int32_t uid{UNSET_UID};
- // Force capture to be in a color space. If the value is ui::Dataspace::UNKNOWN, the captured
- // result will be in a colorspace appropriate for capturing the display contents
- // The display may use non-RGB dataspace (ex. displayP3) that could cause pixel data could be
- // different from SRGB (byte per color), and failed when checking colors in tests.
- // NOTE: In normal cases, we want the screen to be captured in display's colorspace.
- ui::Dataspace dataspace = ui::Dataspace::UNKNOWN;
-
- // The receiver of the capture can handle protected buffer. A protected buffer has
- // GRALLOC_USAGE_PROTECTED usage bit and must not be accessed unprotected behaviour.
- // Any read/write access from unprotected context will result in undefined behaviour.
- // Protected contents are typically DRM contents. This has no direct implication to the
- // secure property of the surface, which is specified by the application explicitly to avoid
- // the contents being accessed/captured by screenshot or unsecure display.
- bool allowProtected = false;
-
- bool grayscale = false;
-
- std::unordered_set<sp<IBinder>, SpHash<IBinder>> excludeHandles;
-
- // Hint that the caller will use the screenshot animation as part of a transition animation.
- // The canonical example would be screen rotation - in such a case any color shift in the
- // screenshot is a detractor so composition in the display's colorspace is required.
- // Otherwise, the system may choose a colorspace that is more appropriate for use-cases
- // such as file encoding or for blending HDR content into an ap's UI, where the display's
- // exact colorspace is not an appropriate intermediate result.
- // Note that if the caller is requesting a specific dataspace, this hint does nothing.
- bool hintForSeamlessTransition = false;
-
- virtual status_t writeToParcel(Parcel* output) const;
- virtual status_t readFromParcel(const Parcel* input);
-};
-
-struct DisplayCaptureArgs : CaptureArgs {
- sp<IBinder> displayToken;
- uint32_t width{0};
- uint32_t height{0};
-
- status_t writeToParcel(Parcel* output) const override;
- status_t readFromParcel(const Parcel* input) override;
-};
-
-}; // namespace android::gui
diff --git a/libs/gui/include/gui/ISurfaceComposer.h b/libs/gui/include/gui/ISurfaceComposer.h
index 1ecc216..9a422fd 100644
--- a/libs/gui/include/gui/ISurfaceComposer.h
+++ b/libs/gui/include/gui/ISurfaceComposer.h
@@ -18,6 +18,7 @@
#include <android/gui/CachingHint.h>
#include <android/gui/DisplayBrightness.h>
+#include <android/gui/DisplayCaptureArgs.h>
#include <android/gui/FrameTimelineInfo.h>
#include <android/gui/IDisplayEventConnection.h>
#include <android/gui/IFpsListener.h>
@@ -27,6 +28,7 @@
#include <android/gui/ITunnelModeEnabledListener.h>
#include <android/gui/IWindowInfosListener.h>
#include <android/gui/IWindowInfosPublisher.h>
+#include <android/gui/LayerCaptureArgs.h>
#include <binder/IBinder.h>
#include <binder/IInterface.h>
#include <gui/ITransactionCompletedListener.h>
@@ -70,13 +72,6 @@
using gui::IScreenCaptureListener;
using gui::SpHash;
-namespace gui {
-
-struct DisplayCaptureArgs;
-struct LayerCaptureArgs;
-
-} // namespace gui
-
namespace ui {
struct DisplayMode;
diff --git a/libs/gui/include/gui/LayerCaptureArgs.h b/libs/gui/include/gui/LayerCaptureArgs.h
deleted file mode 100644
index fae2bcc..0000000
--- a/libs/gui/include/gui/LayerCaptureArgs.h
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * Copyright (C) 2022 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.
- */
-
-#pragma once
-
-#include <stdint.h>
-#include <sys/types.h>
-
-#include <gui/DisplayCaptureArgs.h>
-
-namespace android::gui {
-
-struct LayerCaptureArgs : CaptureArgs {
- sp<IBinder> layerHandle;
- bool childrenOnly{false};
-
- status_t writeToParcel(Parcel* output) const override;
- status_t readFromParcel(const Parcel* input) override;
-};
-
-}; // namespace android::gui
diff --git a/libs/gui/include/gui/LayerState.h b/libs/gui/include/gui/LayerState.h
index d419945..2cdde32 100644
--- a/libs/gui/include/gui/LayerState.h
+++ b/libs/gui/include/gui/LayerState.h
@@ -21,7 +21,9 @@
#include <stdint.h>
#include <sys/types.h>
+#include <android/gui/DisplayCaptureArgs.h>
#include <android/gui/IWindowInfosReportedListener.h>
+#include <android/gui/LayerCaptureArgs.h>
#include <android/gui/TrustedPresentationThresholds.h>
#include <android/native_window.h>
#include <gui/IGraphicBufferProducer.h>
@@ -35,9 +37,7 @@
#include <ftl/flags.h>
#include <gui/BufferReleaseChannel.h>
-#include <gui/DisplayCaptureArgs.h>
#include <gui/ISurfaceComposer.h>
-#include <gui/LayerCaptureArgs.h>
#include <gui/LayerMetadata.h>
#include <gui/SpHash.h>
#include <gui/SurfaceControl.h>
diff --git a/libs/gui/rust/aidl_types/src/lib.rs b/libs/gui/rust/aidl_types/src/lib.rs
index fead018..2351df0 100644
--- a/libs/gui/rust/aidl_types/src/lib.rs
+++ b/libs/gui/rust/aidl_types/src/lib.rs
@@ -42,10 +42,7 @@
}
stub_unstructured_parcelable!(BitTube);
-stub_unstructured_parcelable!(CaptureArgs);
-stub_unstructured_parcelable!(DisplayCaptureArgs);
stub_unstructured_parcelable!(DisplayInfo);
-stub_unstructured_parcelable!(LayerCaptureArgs);
stub_unstructured_parcelable!(LayerDebugInfo);
stub_unstructured_parcelable!(LayerMetadata);
stub_unstructured_parcelable!(ParcelableVsyncEventData);
diff --git a/libs/gui/tests/BLASTBufferQueue_test.cpp b/libs/gui/tests/BLASTBufferQueue_test.cpp
index 6852589..46a19c2 100644
--- a/libs/gui/tests/BLASTBufferQueue_test.cpp
+++ b/libs/gui/tests/BLASTBufferQueue_test.cpp
@@ -229,7 +229,8 @@
ISurfaceComposerClient::eFXSurfaceBufferState,
/*parent*/ mRootSurfaceControl->getHandle());
- mCaptureArgs.sourceCrop = Rect(ui::Size(mDisplayWidth, mDisplayHeight));
+ mCaptureArgs.captureArgs.sourceCrop =
+ gui::aidl_utils::toARect(mDisplayWidth, mDisplayHeight);
mCaptureArgs.layerHandle = mRootSurfaceControl->getHandle();
}
diff --git a/services/surfaceflinger/SurfaceFlinger.cpp b/services/surfaceflinger/SurfaceFlinger.cpp
index 9be9fee..1e374c0 100644
--- a/services/surfaceflinger/SurfaceFlinger.cpp
+++ b/services/surfaceflinger/SurfaceFlinger.cpp
@@ -7105,7 +7105,8 @@
const sp<IScreenCaptureListener>& captureListener) {
SFTRACE_CALL();
- status_t validate = validateScreenshotPermissions(args);
+ const auto& captureArgs = args.captureArgs;
+ status_t validate = validateScreenshotPermissions(captureArgs);
if (validate != OK) {
ALOGD("Permission denied to captureDisplay");
invokeScreenCaptureError(validate, captureListener);
@@ -7118,7 +7119,7 @@
return;
}
- if (args.captureSecureLayers && !hasCaptureBlackoutContentPermission()) {
+ if (captureArgs.captureSecureLayers && !hasCaptureBlackoutContentPermission()) {
ALOGD("Attempting to capture secure layers without CAPTURE_BLACKOUT_CONTENT");
invokeScreenCaptureError(PERMISSION_DENIED, captureListener);
return;
@@ -7144,7 +7145,7 @@
reqSize = display->getLayerStackSpaceRect().getSize();
}
- for (const auto& handle : args.excludeHandles) {
+ for (const auto& handle : captureArgs.excludeHandles) {
uint32_t excludeLayer = LayerHandle::getLayerId(handle);
if (excludeLayer != UNASSIGNED_LAYER_ID) {
excludeLayerIds.emplace(excludeLayer);
@@ -7157,17 +7158,21 @@
}
GetLayerSnapshotsFunction getLayerSnapshotsFn =
- getLayerSnapshotsForScreenshots(layerStack, args.uid, std::move(excludeLayerIds));
+ getLayerSnapshotsForScreenshots(layerStack, captureArgs.uid,
+ std::move(excludeLayerIds));
ftl::Flags<RenderArea::Options> options;
- if (args.captureSecureLayers) options |= RenderArea::Options::CAPTURE_SECURE_LAYERS;
- if (args.hintForSeamlessTransition)
+ if (captureArgs.captureSecureLayers) options |= RenderArea::Options::CAPTURE_SECURE_LAYERS;
+ if (captureArgs.hintForSeamlessTransition)
options |= RenderArea::Options::HINT_FOR_SEAMLESS_TRANSITION;
captureScreenCommon(RenderAreaBuilderVariant(std::in_place_type<DisplayRenderAreaBuilder>,
- args.sourceCrop, reqSize, args.dataspace,
+ gui::aidl_utils::fromARect(captureArgs.sourceCrop),
+ reqSize,
+ static_cast<ui::Dataspace>(captureArgs.dataspace),
displayWeak, options),
- getLayerSnapshotsFn, reqSize, args.pixelFormat, args.allowProtected,
- args.grayscale, captureListener);
+ getLayerSnapshotsFn, reqSize,
+ static_cast<ui::PixelFormat>(captureArgs.pixelFormat),
+ captureArgs.allowProtected, captureArgs.grayscale, captureListener);
}
void SurfaceFlinger::captureDisplay(DisplayId displayId, const CaptureArgs& args,
@@ -7220,10 +7225,11 @@
if (args.hintForSeamlessTransition)
options |= RenderArea::Options::HINT_FOR_SEAMLESS_TRANSITION;
captureScreenCommon(RenderAreaBuilderVariant(std::in_place_type<DisplayRenderAreaBuilder>,
- Rect(), size, args.dataspace, displayWeak,
- options),
- getLayerSnapshotsFn, size, args.pixelFormat, kAllowProtected, kGrayscale,
- captureListener);
+ Rect(), size,
+ static_cast<ui::Dataspace>(args.dataspace),
+ displayWeak, options),
+ getLayerSnapshotsFn, size, static_cast<ui::PixelFormat>(args.pixelFormat),
+ kAllowProtected, kGrayscale, captureListener);
}
ScreenCaptureResults SurfaceFlinger::captureLayersSync(const LayerCaptureArgs& args) {
@@ -7236,20 +7242,23 @@
const sp<IScreenCaptureListener>& captureListener) {
SFTRACE_CALL();
- status_t validate = validateScreenshotPermissions(args);
+ const auto& captureArgs = args.captureArgs;
+
+ status_t validate = validateScreenshotPermissions(captureArgs);
if (validate != OK) {
ALOGD("Permission denied to captureLayers");
invokeScreenCaptureError(validate, captureListener);
return;
}
+ auto crop = gui::aidl_utils::fromARect(captureArgs.sourceCrop);
+
ui::Size reqSize;
sp<Layer> parent;
- Rect crop(args.sourceCrop);
std::unordered_set<uint32_t> excludeLayerIds;
- ui::Dataspace dataspace = args.dataspace;
+ ui::Dataspace dataspace = static_cast<ui::Dataspace>(captureArgs.dataspace);
- if (args.captureSecureLayers && !hasCaptureBlackoutContentPermission()) {
+ if (captureArgs.captureSecureLayers && !hasCaptureBlackoutContentPermission()) {
ALOGD("Attempting to capture secure layers without CAPTURE_BLACKOUT_CONTENT");
invokeScreenCaptureError(PERMISSION_DENIED, captureListener);
return;
@@ -7266,26 +7275,27 @@
}
Rect parentSourceBounds = parent->getCroppedBufferSize(parent->getDrawingState());
- if (args.sourceCrop.width() <= 0) {
+ if (crop.width() <= 0) {
crop.left = 0;
crop.right = parentSourceBounds.getWidth();
}
- if (args.sourceCrop.height() <= 0) {
+ if (crop.height() <= 0) {
crop.top = 0;
crop.bottom = parentSourceBounds.getHeight();
}
- if (crop.isEmpty() || args.frameScaleX <= 0.0f || args.frameScaleY <= 0.0f) {
+ if (crop.isEmpty() || captureArgs.frameScaleX <= 0.0f || captureArgs.frameScaleY <= 0.0f) {
// Error out if the layer has no source bounds (i.e. they are boundless) and a source
// crop was not specified, or an invalid frame scale was provided.
ALOGD("Boundless layer, unspecified crop, or invalid frame scale to captureLayers");
invokeScreenCaptureError(BAD_VALUE, captureListener);
return;
}
- reqSize = ui::Size(crop.width() * args.frameScaleX, crop.height() * args.frameScaleY);
+ reqSize = ui::Size(crop.width() * captureArgs.frameScaleX,
+ crop.height() * captureArgs.frameScaleY);
- for (const auto& handle : args.excludeHandles) {
+ for (const auto& handle : captureArgs.excludeHandles) {
uint32_t excludeLayer = LayerHandle::getLayerId(handle);
if (excludeLayer != UNASSIGNED_LAYER_ID) {
excludeLayerIds.emplace(excludeLayer);
@@ -7311,8 +7321,9 @@
}
GetLayerSnapshotsFunction getLayerSnapshotsFn =
- getLayerSnapshotsForScreenshots(parent->sequence, args.uid, std::move(excludeLayerIds),
- args.childrenOnly, parentCrop);
+ getLayerSnapshotsForScreenshots(parent->sequence, captureArgs.uid,
+ std::move(excludeLayerIds), args.childrenOnly,
+ parentCrop);
if (captureListener == nullptr) {
ALOGD("capture screen must provide a capture listener callback");
@@ -7321,14 +7332,15 @@
}
ftl::Flags<RenderArea::Options> options;
- if (args.captureSecureLayers) options |= RenderArea::Options::CAPTURE_SECURE_LAYERS;
- if (args.hintForSeamlessTransition)
+ if (captureArgs.captureSecureLayers) options |= RenderArea::Options::CAPTURE_SECURE_LAYERS;
+ if (captureArgs.hintForSeamlessTransition)
options |= RenderArea::Options::HINT_FOR_SEAMLESS_TRANSITION;
captureScreenCommon(RenderAreaBuilderVariant(std::in_place_type<LayerRenderAreaBuilder>, crop,
reqSize, dataspace, parent, args.childrenOnly,
options),
- getLayerSnapshotsFn, reqSize, args.pixelFormat, args.allowProtected,
- args.grayscale, captureListener);
+ getLayerSnapshotsFn, reqSize,
+ static_cast<ui::PixelFormat>(captureArgs.pixelFormat),
+ captureArgs.allowProtected, captureArgs.grayscale, captureListener);
}
// Creates a Future release fence for a layer and keeps track of it in a list to
diff --git a/services/surfaceflinger/tests/Credentials_test.cpp b/services/surfaceflinger/tests/Credentials_test.cpp
index d355e72..babbcd4 100644
--- a/services/surfaceflinger/tests/Credentials_test.cpp
+++ b/services/surfaceflinger/tests/Credentials_test.cpp
@@ -280,7 +280,7 @@
std::function<status_t()> condition = [=, this]() {
LayerCaptureArgs captureArgs;
captureArgs.layerHandle = mBGSurfaceControl->getHandle();
- captureArgs.sourceCrop = {0, 0, 1, 1};
+ captureArgs.captureArgs.sourceCrop = gui::aidl_utils::toARect(0, 0, 1, 1);
ScreenCaptureResults captureResults;
return ScreenCapture::captureLayers(captureArgs, captureResults);
diff --git a/services/surfaceflinger/tests/LayerState_test.cpp b/services/surfaceflinger/tests/LayerState_test.cpp
index 15a98df..cc57e11 100644
--- a/services/surfaceflinger/tests/LayerState_test.cpp
+++ b/services/surfaceflinger/tests/LayerState_test.cpp
@@ -28,66 +28,6 @@
namespace test {
-TEST(LayerStateTest, ParcellingDisplayCaptureArgs) {
- DisplayCaptureArgs args;
- args.pixelFormat = ui::PixelFormat::RGB_565;
- args.sourceCrop = Rect(0, 0, 500, 200);
- args.frameScaleX = 2;
- args.frameScaleY = 4;
- args.captureSecureLayers = true;
- args.displayToken = sp<BBinder>::make();
- args.width = 10;
- args.height = 20;
- args.grayscale = true;
-
- Parcel p;
- args.writeToParcel(&p);
- p.setDataPosition(0);
-
- DisplayCaptureArgs args2;
- args2.readFromParcel(&p);
-
- ASSERT_EQ(args.pixelFormat, args2.pixelFormat);
- ASSERT_EQ(args.sourceCrop, args2.sourceCrop);
- ASSERT_EQ(args.frameScaleX, args2.frameScaleX);
- ASSERT_EQ(args.frameScaleY, args2.frameScaleY);
- ASSERT_EQ(args.captureSecureLayers, args2.captureSecureLayers);
- ASSERT_EQ(args.displayToken, args2.displayToken);
- ASSERT_EQ(args.width, args2.width);
- ASSERT_EQ(args.height, args2.height);
- ASSERT_EQ(args.grayscale, args2.grayscale);
-}
-
-TEST(LayerStateTest, ParcellingLayerCaptureArgs) {
- LayerCaptureArgs args;
- args.pixelFormat = ui::PixelFormat::RGB_565;
- args.sourceCrop = Rect(0, 0, 500, 200);
- args.frameScaleX = 2;
- args.frameScaleY = 4;
- args.captureSecureLayers = true;
- args.layerHandle = sp<BBinder>::make();
- args.excludeHandles = {sp<BBinder>::make(), sp<BBinder>::make()};
- args.childrenOnly = false;
- args.grayscale = true;
-
- Parcel p;
- args.writeToParcel(&p);
- p.setDataPosition(0);
-
- LayerCaptureArgs args2;
- args2.readFromParcel(&p);
-
- ASSERT_EQ(args.pixelFormat, args2.pixelFormat);
- ASSERT_EQ(args.sourceCrop, args2.sourceCrop);
- ASSERT_EQ(args.frameScaleX, args2.frameScaleX);
- ASSERT_EQ(args.frameScaleY, args2.frameScaleY);
- ASSERT_EQ(args.captureSecureLayers, args2.captureSecureLayers);
- ASSERT_EQ(args.layerHandle, args2.layerHandle);
- ASSERT_EQ(args.excludeHandles, args2.excludeHandles);
- ASSERT_EQ(args.childrenOnly, args2.childrenOnly);
- ASSERT_EQ(args.grayscale, args2.grayscale);
-}
-
TEST(LayerStateTest, ParcellingScreenCaptureResultsWithFence) {
ScreenCaptureResults results;
results.buffer = sp<GraphicBuffer>::make(100u, 200u, PIXEL_FORMAT_RGBA_8888, 1u, 0u);
diff --git a/services/surfaceflinger/tests/LayerTypeTransaction_test.cpp b/services/surfaceflinger/tests/LayerTypeTransaction_test.cpp
index f9b4bba..e655df7 100644
--- a/services/surfaceflinger/tests/LayerTypeTransaction_test.cpp
+++ b/services/surfaceflinger/tests/LayerTypeTransaction_test.cpp
@@ -15,6 +15,7 @@
*/
// TODO(b/129481165): remove the #pragma below and fix conversion issues
+#include "gui/AidlStatusUtil.h"
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wconversion"
@@ -64,7 +65,7 @@
// only layerB is in this range
LayerCaptureArgs captureArgs;
captureArgs.layerHandle = parent->getHandle();
- captureArgs.sourceCrop = {0, 0, 32, 32};
+ captureArgs.captureArgs.sourceCrop = gui::aidl_utils::toARect(32, 32);
ScreenCapture::captureLayers(&screenshot, captureArgs);
screenshot->expectColor(Rect(0, 0, 32, 32), Color::BLUE);
}
diff --git a/services/surfaceflinger/tests/MirrorLayer_test.cpp b/services/surfaceflinger/tests/MirrorLayer_test.cpp
index d97d433..2a53588 100644
--- a/services/surfaceflinger/tests/MirrorLayer_test.cpp
+++ b/services/surfaceflinger/tests/MirrorLayer_test.cpp
@@ -20,6 +20,7 @@
#include <android-base/properties.h>
#include <common/FlagManager.h>
+#include <gui/AidlStatusUtil.h>
#include <private/android_filesystem_config.h>
#include "LayerTransactionTest.h"
#include "utils/TransactionUtils.h"
@@ -350,7 +351,7 @@
// Capture just the mirror layer and child.
LayerCaptureArgs captureArgs;
captureArgs.layerHandle = mirrorParent->getHandle();
- captureArgs.sourceCrop = childBounds;
+ captureArgs.captureArgs.sourceCrop = gui::aidl_utils::toARect(childBounds);
std::unique_ptr<ScreenCapture> shot;
ScreenCapture::captureLayers(&shot, captureArgs);
shot->expectSize(childBounds.width(), childBounds.height());
diff --git a/services/surfaceflinger/tests/ScreenCapture_test.cpp b/services/surfaceflinger/tests/ScreenCapture_test.cpp
index 9a78550..069f199 100644
--- a/services/surfaceflinger/tests/ScreenCapture_test.cpp
+++ b/services/surfaceflinger/tests/ScreenCapture_test.cpp
@@ -20,6 +20,7 @@
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wconversion"
+#include <gui/AidlStatusUtil.h>
#include <private/android_filesystem_config.h>
#include <ui/DisplayState.h>
@@ -65,7 +66,7 @@
.show(mFGSurfaceControl);
});
- mCaptureArgs.sourceCrop = mDisplayRect;
+ mCaptureArgs.captureArgs.sourceCrop = gui::aidl_utils::toARect(mDisplayRect);
mCaptureArgs.layerHandle = mRootSurfaceControl->getHandle();
}
@@ -112,7 +113,7 @@
shot->expectColor(Rect(0, 0, 32, 32), Color::BLACK);
}
- mCaptureArgs.captureSecureLayers = true;
+ mCaptureArgs.captureArgs.captureSecureLayers = true;
// AID_SYSTEM is allowed to capture secure content.
ASSERT_EQ(NO_ERROR, ScreenCapture::captureLayers(mCaptureArgs, mCaptureResults));
ASSERT_TRUE(mCaptureResults.capturedSecureLayers);
@@ -164,7 +165,7 @@
// Here we pass captureSecureLayers = true and since we are AID_SYSTEM we should be able
// to receive them...we are expected to take care with the results.
- mCaptureArgs.captureSecureLayers = true;
+ mCaptureArgs.captureArgs.captureSecureLayers = true;
ASSERT_EQ(NO_ERROR, ScreenCapture::captureLayers(mCaptureArgs, mCaptureResults));
ASSERT_TRUE(mCaptureResults.capturedSecureLayers);
ScreenCapture sc(mCaptureResults.buffer, mCaptureResults.capturedHdrLayers);
@@ -198,8 +199,8 @@
.apply();
LayerCaptureArgs captureArgs;
captureArgs.layerHandle = childLayer->getHandle();
- captureArgs.sourceCrop = size;
- captureArgs.captureSecureLayers = false;
+ captureArgs.captureArgs.sourceCrop = gui::aidl_utils::toARect(size);
+ captureArgs.captureArgs.captureSecureLayers = false;
{
SCOPED_TRACE("parent hidden");
ASSERT_EQ(NO_ERROR, ScreenCapture::captureLayers(captureArgs, mCaptureResults));
@@ -208,7 +209,7 @@
sc.expectColor(size, Color::BLACK);
}
- captureArgs.captureSecureLayers = true;
+ captureArgs.captureArgs.captureSecureLayers = true;
{
SCOPED_TRACE("capture secure parent not visible");
ASSERT_EQ(NO_ERROR, ScreenCapture::captureLayers(captureArgs, mCaptureResults));
@@ -218,7 +219,7 @@
}
Transaction().show(parentLayer).apply();
- captureArgs.captureSecureLayers = false;
+ captureArgs.captureArgs.captureSecureLayers = false;
{
SCOPED_TRACE("parent visible");
ASSERT_EQ(NO_ERROR, ScreenCapture::captureLayers(captureArgs, mCaptureResults));
@@ -227,7 +228,7 @@
sc.expectColor(size, Color::BLACK);
}
- captureArgs.captureSecureLayers = true;
+ captureArgs.captureArgs.captureSecureLayers = true;
{
SCOPED_TRACE("capture secure parent visible");
ASSERT_EQ(NO_ERROR, ScreenCapture::captureLayers(captureArgs, mCaptureResults));
@@ -259,8 +260,8 @@
.apply();
LayerCaptureArgs captureArgs;
captureArgs.layerHandle = childLayer->getHandle();
- captureArgs.sourceCrop = size;
- captureArgs.captureSecureLayers = false;
+ captureArgs.captureArgs.sourceCrop = gui::aidl_utils::toARect(size);
+ captureArgs.captureArgs.captureSecureLayers = false;
{
SCOPED_TRACE("parent hidden");
ASSERT_EQ(NO_ERROR, ScreenCapture::captureLayers(captureArgs, mCaptureResults));
@@ -269,7 +270,7 @@
sc.expectColor(size, Color::BLACK);
}
- captureArgs.captureSecureLayers = true;
+ captureArgs.captureArgs.captureSecureLayers = true;
{
SCOPED_TRACE("capture secure parent not visible");
ASSERT_EQ(NO_ERROR, ScreenCapture::captureLayers(captureArgs, mCaptureResults));
@@ -279,7 +280,7 @@
}
Transaction().show(parentLayer).apply();
- captureArgs.captureSecureLayers = false;
+ captureArgs.captureArgs.captureSecureLayers = false;
{
SCOPED_TRACE("parent visible");
ASSERT_EQ(NO_ERROR, ScreenCapture::captureLayers(captureArgs, mCaptureResults));
@@ -288,7 +289,7 @@
sc.expectColor(size, Color::BLACK);
}
- captureArgs.captureSecureLayers = true;
+ captureArgs.captureArgs.captureSecureLayers = true;
{
SCOPED_TRACE("capture secure parent visible");
ASSERT_EQ(NO_ERROR, ScreenCapture::captureLayers(captureArgs, mCaptureResults));
@@ -361,14 +362,14 @@
LayerCaptureArgs captureArgs;
captureArgs.layerHandle = fgHandle;
captureArgs.childrenOnly = true;
- captureArgs.excludeHandles = {child2->getHandle()};
+ captureArgs.captureArgs.excludeHandles = {child2->getHandle()};
ScreenCapture::captureLayers(&mCapture, captureArgs);
mCapture->checkPixel(10, 10, 0, 0, 0);
mCapture->checkPixel(0, 0, 200, 200, 200);
}
TEST_F(ScreenCaptureTest, CaptureLayerExcludeThroughDisplayArgs) {
- mCaptureArgs.excludeHandles = {mFGSurfaceControl->getHandle()};
+ mCaptureArgs.captureArgs.excludeHandles = {mFGSurfaceControl->getHandle()};
ScreenCapture::captureLayers(&mCapture, mCaptureArgs);
mCapture->expectBGColor(0, 0);
// Doesn't capture FG layer which is at 64, 64
@@ -401,7 +402,7 @@
LayerCaptureArgs captureArgs;
captureArgs.layerHandle = fgHandle;
captureArgs.childrenOnly = true;
- captureArgs.excludeHandles = {child2->getHandle()};
+ captureArgs.captureArgs.excludeHandles = {child2->getHandle()};
ScreenCapture::captureLayers(&mCapture, captureArgs);
mCapture->checkPixel(10, 10, 0, 0, 0);
mCapture->checkPixel(0, 0, 200, 200, 200);
@@ -418,7 +419,7 @@
// Captures child
LayerCaptureArgs captureArgs;
captureArgs.layerHandle = child->getHandle();
- captureArgs.sourceCrop = {0, 0, 10, 20};
+ captureArgs.captureArgs.sourceCrop = gui::aidl_utils::toARect(10, 20);
ScreenCapture::captureLayers(&mCapture, captureArgs);
mCapture->expectColor(Rect(0, 0, 9, 9), {200, 200, 200, 255});
// Area outside of child's bounds is transparent.
@@ -481,7 +482,7 @@
LayerCaptureArgs captureArgs;
captureArgs.layerHandle = child->getHandle();
- captureArgs.sourceCrop = {0, 0, 10, 10};
+ captureArgs.captureArgs.sourceCrop = gui::aidl_utils::toARect(10, 10);
ScreenCapture::captureLayers(&mCapture, captureArgs);
mCapture->expectColor(Rect(0, 0, 9, 9), Color::RED);
@@ -623,7 +624,7 @@
// red area to the right of the blue area
mCapture->expectColor(Rect(30, 0, 59, 59), Color::RED);
- captureArgs.sourceCrop = {0, 0, 30, 30};
+ captureArgs.captureArgs.sourceCrop = gui::aidl_utils::toARect(30, 30);
ScreenCapture::captureLayers(&mCapture, captureArgs);
// Capturing the cropped screen, cropping out the shown red area, should leave only the blue
// area visible.
@@ -658,8 +659,8 @@
// red area to the right of the blue area
mCapture->expectColor(Rect(30, 0, 59, 59), Color::RED);
- captureArgs.frameScaleX = 0.5f;
- captureArgs.frameScaleY = 0.5f;
+ captureArgs.captureArgs.frameScaleX = 0.5f;
+ captureArgs.captureArgs.frameScaleY = 0.5f;
sleep(1);
ScreenCapture::captureLayers(&mCapture, captureArgs);
@@ -689,8 +690,8 @@
LayerCaptureArgs captureArgs;
captureArgs.layerHandle = redLayer->getHandle();
- captureArgs.frameScaleX = INT32_MAX / 60;
- captureArgs.frameScaleY = INT32_MAX / 60;
+ captureArgs.captureArgs.frameScaleX = INT32_MAX / 60;
+ captureArgs.captureArgs.frameScaleY = INT32_MAX / 60;
ScreenCaptureResults captureResults;
ASSERT_EQ(BAD_VALUE, ScreenCapture::captureLayers(captureArgs, captureResults));
@@ -736,7 +737,7 @@
mCapture->expectColor(Rect(30, 30, 60, 60), Color::RED);
// Passing flag secure so the blue layer should be screenshot too.
- args.captureSecureLayers = true;
+ args.captureArgs.captureSecureLayers = true;
ScreenCapture::captureLayers(&mCapture, args);
mCapture->expectColor(Rect(0, 0, 30, 30), Color::BLUE);
mCapture->expectColor(Rect(30, 30, 60, 60), Color::RED);
@@ -780,7 +781,7 @@
// Reading color data will expectedly result in crash, only check usage bit
// b/309965549 Checking that the usage bit is protected does not work for
// devices that do not support usage protected.
- mCaptureArgs.allowProtected = true;
+ mCaptureArgs.captureArgs.allowProtected = true;
ASSERT_EQ(NO_ERROR, ScreenCapture::captureLayers(mCaptureArgs, captureResults));
// ASSERT_EQ(GRALLOC_USAGE_PROTECTED, GRALLOC_USAGE_PROTECTED &
// captureResults.buffer->getUsage());
@@ -898,7 +899,7 @@
// Make screenshot request with current uid set. No layers were created with the current
// uid so screenshot will be black.
- captureArgs.uid = fakeUid;
+ captureArgs.captureArgs.uid = fakeUid;
ScreenCapture::captureLayers(&mCapture, captureArgs);
mCapture->expectColor(Rect(0, 0, 32, 32), Color::TRANSPARENT);
mCapture->expectBorder(Rect(0, 0, 32, 32), Color::TRANSPARENT);
@@ -935,7 +936,7 @@
mCapture->expectBorder(Rect(128, 128, 160, 160), Color::TRANSPARENT);
// Screenshot from the fakeUid caller with no uid requested allows everything to be screenshot.
- captureArgs.uid = -1;
+ captureArgs.captureArgs.uid = -1;
ScreenCapture::captureLayers(&mCapture, captureArgs);
mCapture->expectColor(Rect(128, 128, 160, 160), Color::RED);
mCapture->expectBorder(Rect(128, 128, 160, 160), {63, 63, 195, 255});
@@ -955,7 +956,7 @@
ScreenCapture::captureLayers(&mCapture, captureArgs);
mCapture->expectColor(Rect(0, 0, 32, 32), Color::RED);
- captureArgs.grayscale = true;
+ captureArgs.captureArgs.grayscale = true;
const uint8_t tolerance = 1;
@@ -1052,7 +1053,7 @@
LayerCaptureArgs captureArgs;
captureArgs.layerHandle = mirroredLayer->getHandle();
- captureArgs.sourceCrop = Rect(0, 0, 1, 1);
+ captureArgs.captureArgs.sourceCrop = gui::aidl_utils::toARect(1, 1);
// Screenshot path should only use the children of the layer hierarchy so
// that it will not create a new snapshot. A snapshot would otherwise be
diff --git a/services/surfaceflinger/tests/TextureFiltering_test.cpp b/services/surfaceflinger/tests/TextureFiltering_test.cpp
index c5d118c..f8c5364 100644
--- a/services/surfaceflinger/tests/TextureFiltering_test.cpp
+++ b/services/surfaceflinger/tests/TextureFiltering_test.cpp
@@ -14,9 +14,10 @@
* limitations under the License.
*/
+#include <android/gui/DisplayCaptureArgs.h>
#include <android/gui/ISurfaceComposerClient.h>
#include <gtest/gtest.h>
-#include <gui/DisplayCaptureArgs.h>
+#include <gui/AidlStatusUtil.h>
#include <ui/GraphicTypes.h>
#include <ui/Rect.h>
@@ -84,7 +85,7 @@
};
TEST_F(TextureFilteringTest, NoFiltering) {
- captureArgs.sourceCrop = Rect{0, 0, 100, 100};
+ captureArgs.captureArgs.sourceCrop = gui::aidl_utils::toARect(100, 100);
captureArgs.layerHandle = mParent->getHandle();
ScreenCapture::captureLayers(&mCapture, captureArgs);
@@ -93,7 +94,7 @@
}
TEST_F(TextureFilteringTest, BufferCropNoFiltering) {
- captureArgs.sourceCrop = Rect{0, 0, 100, 100};
+ captureArgs.captureArgs.sourceCrop = gui::aidl_utils::toARect(100, 100);
captureArgs.layerHandle = mParent->getHandle();
ScreenCapture::captureLayers(&mCapture, captureArgs);
@@ -105,7 +106,7 @@
TEST_F(TextureFilteringTest, BufferCropIsFiltered) {
Transaction().setBufferCrop(mLayer, Rect{25, 25, 75, 75}).apply();
- captureArgs.sourceCrop = Rect{0, 0, 100, 100};
+ captureArgs.captureArgs.sourceCrop = gui::aidl_utils::toARect(100, 100);
captureArgs.layerHandle = mParent->getHandle();
ScreenCapture::captureLayers(&mCapture, captureArgs);
@@ -114,9 +115,9 @@
// Expect filtering because the output source crop is stretched to the output buffer's size.
TEST_F(TextureFilteringTest, OutputSourceCropIsFiltered) {
- captureArgs.frameScaleX = 2;
- captureArgs.frameScaleY = 2;
- captureArgs.sourceCrop = Rect{25, 25, 75, 75};
+ captureArgs.captureArgs.frameScaleX = 2;
+ captureArgs.captureArgs.frameScaleY = 2;
+ captureArgs.captureArgs.sourceCrop = gui::aidl_utils::toARect(25, 25, 75, 75);
captureArgs.layerHandle = mParent->getHandle();
ScreenCapture::captureLayers(&mCapture, captureArgs);
@@ -127,9 +128,9 @@
// buffer's size.
TEST_F(TextureFilteringTest, LayerCropOutputSourceCropIsFiltered) {
Transaction().setCrop(mLayer, Rect{25, 25, 75, 75}).apply();
- captureArgs.frameScaleX = 2;
- captureArgs.frameScaleY = 2;
- captureArgs.sourceCrop = Rect{25, 25, 75, 75};
+ captureArgs.captureArgs.frameScaleX = 2;
+ captureArgs.captureArgs.frameScaleY = 2;
+ captureArgs.captureArgs.sourceCrop = gui::aidl_utils::toARect(25, 25, 75, 75);
captureArgs.layerHandle = mParent->getHandle();
ScreenCapture::captureLayers(&mCapture, captureArgs);
@@ -139,8 +140,8 @@
// Expect filtering because the layer is scaled up.
TEST_F(TextureFilteringTest, LayerCaptureWithScalingIsFiltered) {
captureArgs.layerHandle = mLayer->getHandle();
- captureArgs.frameScaleX = 2;
- captureArgs.frameScaleY = 2;
+ captureArgs.captureArgs.frameScaleX = 2;
+ captureArgs.captureArgs.frameScaleY = 2;
ScreenCapture::captureLayers(&mCapture, captureArgs);
expectFiltered({0, 0, 100, 200}, {100, 0, 200, 200});
@@ -149,7 +150,7 @@
// Expect no filtering because the output buffer's size matches the source crop.
TEST_F(TextureFilteringTest, LayerCaptureOutputSourceCropNoFiltering) {
captureArgs.layerHandle = mLayer->getHandle();
- captureArgs.sourceCrop = Rect{25, 25, 75, 75};
+ captureArgs.captureArgs.sourceCrop = gui::aidl_utils::toARect(25, 25, 75, 75);
ScreenCapture::captureLayers(&mCapture, captureArgs);
mCapture->expectColor(Rect{0, 0, 25, 50}, Color::RED);
@@ -162,7 +163,7 @@
Transaction().setCrop(mLayer, Rect{10, 10, 90, 90}).apply();
captureArgs.layerHandle = mLayer->getHandle();
- captureArgs.sourceCrop = Rect{25, 25, 75, 75};
+ captureArgs.captureArgs.sourceCrop = gui::aidl_utils::toARect(25, 25, 75, 75);
ScreenCapture::captureLayers(&mCapture, captureArgs);
mCapture->expectColor(Rect{0, 0, 25, 50}, Color::RED);
@@ -172,7 +173,7 @@
// Expect no filtering because the output source crop and output buffer are the same size.
TEST_F(TextureFilteringTest, OutputSourceCropDisplayFrameMatchNoFiltering) {
captureArgs.layerHandle = mLayer->getHandle();
- captureArgs.sourceCrop = Rect{25, 25, 75, 75};
+ captureArgs.captureArgs.sourceCrop = gui::aidl_utils::toARect(25, 25, 75, 75);
ScreenCapture::captureLayers(&mCapture, captureArgs);
mCapture->expectColor(Rect{0, 0, 25, 50}, Color::RED);
@@ -206,7 +207,7 @@
Transaction().setPosition(mParent, 100, 100).apply();
captureArgs.layerHandle = mParent->getHandle();
- captureArgs.sourceCrop = Rect{0, 0, 100, 100};
+ captureArgs.captureArgs.sourceCrop = gui::aidl_utils::toARect(100, 100);
ScreenCapture::captureLayers(&mCapture, captureArgs);
mCapture->expectColor(Rect{0, 0, 50, 100}, Color::RED);
diff --git a/services/surfaceflinger/tests/utils/ScreenshotUtils.h b/services/surfaceflinger/tests/utils/ScreenshotUtils.h
index 1675584..efce6b6 100644
--- a/services/surfaceflinger/tests/utils/ScreenshotUtils.h
+++ b/services/surfaceflinger/tests/utils/ScreenshotUtils.h
@@ -39,7 +39,7 @@
const auto sf = ComposerServiceAIDL::getComposerService();
SurfaceComposerClient::Transaction().apply(true);
- captureArgs.dataspace = ui::Dataspace::V0_SRGB;
+ captureArgs.captureArgs.dataspace = static_cast<int32_t>(ui::Dataspace::V0_SRGB);
const sp<SyncScreenCaptureListener> captureListener = sp<SyncScreenCaptureListener>::make();
binder::Status status = sf->captureDisplay(captureArgs, captureListener);
status_t err = statusTFromBinderStatus(status);
@@ -77,7 +77,7 @@
const auto sf = ComposerServiceAIDL::getComposerService();
SurfaceComposerClient::Transaction().apply(true);
- captureArgs.dataspace = ui::Dataspace::V0_SRGB;
+ captureArgs.captureArgs.dataspace = static_cast<int32_t>(ui::Dataspace::V0_SRGB);
const sp<SyncScreenCaptureListener> captureListener = sp<SyncScreenCaptureListener>::make();
binder::Status status = sf->captureLayers(captureArgs, captureListener);
status_t err = statusTFromBinderStatus(status);