summaryrefslogtreecommitdiff
path: root/native/android
diff options
context:
space:
mode:
authorchaviw <chaviw@google.com>2021-03-25 15:28:44 -0500
committerchaviw <chaviw@google.com>2021-04-14 16:40:33 -0500
commitccf3e8b9f965b7d60e5d0a23ca1396f681ce252d (patch)
treee680811e60dcee4f686b7079b940d39243121d71 /native/android
parente5bb44a832dfb740ba7395b7941f96a723b89567 (diff)
Updated native SurfaceControl APIs to reflect their behavior.
Updated setPosition, setCrop, setBufferTransform, and added setScale to native SurfaceControl API. The new functions should be pass through calls to SurfaceComposerClient that sends it to SurfaceFlinger. Test: ASurfaceControlTest Bug: 170765639 Change-Id: I214c5ae998d8f896200f3010cf2de6754d1e8510
Diffstat (limited to 'native/android')
-rw-r--r--native/android/libandroid.map.txt5
-rw-r--r--native/android/surface_control.cpp36
2 files changed, 26 insertions, 15 deletions
diff --git a/native/android/libandroid.map.txt b/native/android/libandroid.map.txt
index 4d137e0e1acc..9729524b47b2 100644
--- a/native/android/libandroid.map.txt
+++ b/native/android/libandroid.map.txt
@@ -260,8 +260,9 @@ LIBANDROID {
ASurfaceTransaction_setHdrMetadata_smpte2086; # introduced=29
ASurfaceTransaction_setOnComplete; # introduced=29
ASurfaceTransaction_setPosition; # introduced=31
- ASurfaceTransaction_setSourceRect; # introduced=31
- ASurfaceTransaction_setTransform; # introduced=31
+ ASurfaceTransaction_setCrop; # introduced=31
+ ASurfaceTransaction_setBufferTransform; # introduced=31
+ ASurfaceTransaction_setScale; # introduced=31
ASurfaceTransaction_setVisibility; # introduced=29
ASurfaceTransaction_setZOrder; # introduced=29
ASystemFontIterator_open; # introduced=29
diff --git a/native/android/surface_control.cpp b/native/android/surface_control.cpp
index 7433cf970566..3d14c425ed4d 100644
--- a/native/android/surface_control.cpp
+++ b/native/android/surface_control.cpp
@@ -459,34 +459,31 @@ void ASurfaceTransaction_setGeometry(ASurfaceTransaction* aSurfaceTransaction,
transaction->setTransformToDisplayInverse(surfaceControl, transformToInverseDisplay);
}
-void ASurfaceTransaction_setSourceRect(ASurfaceTransaction* aSurfaceTransaction,
- ASurfaceControl* aSurfaceControl, const ARect& source) {
+void ASurfaceTransaction_setCrop(ASurfaceTransaction* aSurfaceTransaction,
+ ASurfaceControl* aSurfaceControl, const ARect& crop) {
CHECK_NOT_NULL(aSurfaceTransaction);
CHECK_NOT_NULL(aSurfaceControl);
- CHECK_VALID_RECT(source);
+ CHECK_VALID_RECT(crop);
sp<SurfaceControl> surfaceControl = ASurfaceControl_to_SurfaceControl(aSurfaceControl);
Transaction* transaction = ASurfaceTransaction_to_Transaction(aSurfaceTransaction);
- transaction->setCrop(surfaceControl, static_cast<const Rect&>(source));
+ transaction->setCrop(surfaceControl, static_cast<const Rect&>(crop));
}
-void ASurfaceTransaction_setPosition(ASurfaceTransaction* /* aSurfaceTransaction */,
- ASurfaceControl* /* aSurfaceControl */,
- const ARect& /* destination */) {
- // TODO: Fix this function
- /* CHECK_NOT_NULL(aSurfaceTransaction);
+void ASurfaceTransaction_setPosition(ASurfaceTransaction* aSurfaceTransaction,
+ ASurfaceControl* aSurfaceControl, int32_t x, int32_t y) {
+ CHECK_NOT_NULL(aSurfaceTransaction);
CHECK_NOT_NULL(aSurfaceControl);
- CHECK_VALID_RECT(destination);
sp<SurfaceControl> surfaceControl = ASurfaceControl_to_SurfaceControl(aSurfaceControl);
Transaction* transaction = ASurfaceTransaction_to_Transaction(aSurfaceTransaction);
- transaction->setFrame(surfaceControl, static_cast<const Rect&>(destination));*/
+ transaction->setPosition(surfaceControl, x, y);
}
-void ASurfaceTransaction_setTransform(ASurfaceTransaction* aSurfaceTransaction,
- ASurfaceControl* aSurfaceControl, int32_t transform) {
+void ASurfaceTransaction_setBufferTransform(ASurfaceTransaction* aSurfaceTransaction,
+ ASurfaceControl* aSurfaceControl, int32_t transform) {
CHECK_NOT_NULL(aSurfaceTransaction);
CHECK_NOT_NULL(aSurfaceControl);
@@ -499,6 +496,19 @@ void ASurfaceTransaction_setTransform(ASurfaceTransaction* aSurfaceTransaction,
transaction->setTransformToDisplayInverse(surfaceControl, transformToInverseDisplay);
}
+void ASurfaceTransaction_setScale(ASurfaceTransaction* aSurfaceTransaction,
+ ASurfaceControl* aSurfaceControl, float xScale, float yScale) {
+ CHECK_NOT_NULL(aSurfaceTransaction);
+ CHECK_NOT_NULL(aSurfaceControl);
+ LOG_ALWAYS_FATAL_IF(xScale < 0, "negative value passed in for xScale");
+ LOG_ALWAYS_FATAL_IF(yScale < 0, "negative value passed in for yScale");
+
+ sp<SurfaceControl> surfaceControl = ASurfaceControl_to_SurfaceControl(aSurfaceControl);
+ Transaction* transaction = ASurfaceTransaction_to_Transaction(aSurfaceTransaction);
+
+ transaction->setMatrix(surfaceControl, xScale, 0, 0, yScale);
+}
+
void ASurfaceTransaction_setBufferTransparency(ASurfaceTransaction* aSurfaceTransaction,
ASurfaceControl* aSurfaceControl,
int8_t transparency) {