Merge "Disable native_coverage for libGLESv2" into qt-dev am: bf01857cc2 am: 5648ceb812
am: 358a2a1d3b
Change-Id: I8519c75eef4c861179dba226b361946d550c87d6
diff --git a/PREUPLOAD.cfg b/PREUPLOAD.cfg
index 1a932c3..4f7cdf3 100644
--- a/PREUPLOAD.cfg
+++ b/PREUPLOAD.cfg
@@ -4,13 +4,16 @@
[Builtin Hooks Options]
# Only turn on clang-format check for the following subfolders.
clang_format = --commit ${PREUPLOAD_COMMIT} --style file --extensions c,h,cc,cpp
+ include/input/
libs/binder/ndk/
libs/graphicsenv/
libs/gui/
+ libs/input/
libs/renderengine/
libs/ui/
libs/vr/
services/bufferhub/
+ services/inputflinger/
services/surfaceflinger/
services/vr/
diff --git a/include/android/surface_control.h b/include/android/surface_control.h
index ef2ad99..abb8368 100644
--- a/include/android/surface_control.h
+++ b/include/android/surface_control.h
@@ -130,7 +130,7 @@
/**
* Returns a sync fence that signals when the transaction has been presented.
* The recipient of the callback takes ownership of the fence and is responsible for closing
- * it.
+ * it. If a device does not support present fences, a -1 will be returned.
*/
int ASurfaceTransactionStats_getPresentFenceFd(ASurfaceTransactionStats* surface_transaction_stats)
__INTRODUCED_IN(29);
diff --git a/libs/binder/Parcel.cpp b/libs/binder/Parcel.cpp
index 0e8945c..580573e 100644
--- a/libs/binder/Parcel.cpp
+++ b/libs/binder/Parcel.cpp
@@ -616,7 +616,7 @@
return err == NO_ERROR;
}
-uid_t Parcel::readCallingWorkSourceUid()
+uid_t Parcel::readCallingWorkSourceUid() const
{
if (!mRequestHeaderPresent) {
return IPCThreadState::kUnsetWorkSource;
diff --git a/libs/binder/include/binder/Parcel.h b/libs/binder/include/binder/Parcel.h
index 0cdabb0..0046e3a 100644
--- a/libs/binder/include/binder/Parcel.h
+++ b/libs/binder/include/binder/Parcel.h
@@ -399,7 +399,7 @@
bool replaceCallingWorkSourceUid(uid_t uid);
// Returns the work source provided by the caller. This can only be trusted for trusted calling
// uid.
- uid_t readCallingWorkSourceUid();
+ uid_t readCallingWorkSourceUid() const;
void readRequestHeaders() const;
private:
diff --git a/libs/gui/Android.bp b/libs/gui/Android.bp
index 34575f5..b2a7557 100644
--- a/libs/gui/Android.bp
+++ b/libs/gui/Android.bp
@@ -15,6 +15,10 @@
name: "libgui_headers",
vendor_available: true,
export_include_dirs: ["include"],
+
+ // we must build this module to get the required header as that is generated
+ export_shared_lib_headers: [ "android.hidl.token@1.0-utils" ],
+ shared_libs: [ "android.hidl.token@1.0-utils" ],
}
cc_library_shared {
diff --git a/libs/gui/SurfaceComposerClient.cpp b/libs/gui/SurfaceComposerClient.cpp
index d6f88fc..cc9e468 100644
--- a/libs/gui/SurfaceComposerClient.cpp
+++ b/libs/gui/SurfaceComposerClient.cpp
@@ -623,6 +623,7 @@
layer_state_t* s = getLayerState(sc);
if (!s) {
mStatus = BAD_INDEX;
+ return *this;
}
s->what |= layer_state_t::eRelativeLayerChanged;
s->what &= ~layer_state_t::eLayerChanged;
@@ -1052,6 +1053,7 @@
layer_state_t* s = getLayerState(sc);
if (!s) {
mStatus = BAD_INDEX;
+ return *this;
}
s->what |= layer_state_t::eDetachChildren;
diff --git a/libs/gui/tests/RegionSampling_test.cpp b/libs/gui/tests/RegionSampling_test.cpp
index d33ecfb..c9de37d 100644
--- a/libs/gui/tests/RegionSampling_test.cpp
+++ b/libs/gui/tests/RegionSampling_test.cpp
@@ -297,4 +297,70 @@
composer->removeRegionSamplingListener(grayListener);
}
+TEST_F(RegionSamplingTest, DISABLED_TestIfInvalidInputParameters) {
+ sp<ISurfaceComposer> composer = ComposerService::getComposerService();
+ sp<Listener> listener = new Listener();
+ const Rect sampleArea{100, 100, 200, 200};
+ // Invalid input sampleArea
+ EXPECT_EQ(BAD_VALUE,
+ composer->addRegionSamplingListener(Rect::INVALID_RECT, mTopLayer->getHandle(),
+ listener));
+ listener->reset();
+ // Invalid input binder
+ EXPECT_EQ(NO_ERROR, composer->addRegionSamplingListener(sampleArea, NULL, listener));
+ // Invalid input listener
+ EXPECT_EQ(BAD_VALUE,
+ composer->addRegionSamplingListener(sampleArea, mTopLayer->getHandle(), NULL));
+ EXPECT_EQ(BAD_VALUE, composer->removeRegionSamplingListener(NULL));
+ // remove the listener
+ composer->removeRegionSamplingListener(listener);
+}
+
+TEST_F(RegionSamplingTest, DISABLED_TestCallbackAfterRemoveListener) {
+ fill_render(rgba_green);
+ sp<ISurfaceComposer> composer = ComposerService::getComposerService();
+ sp<Listener> listener = new Listener();
+ const Rect sampleArea{100, 100, 200, 200};
+ composer->addRegionSamplingListener(sampleArea, mTopLayer->getHandle(), listener);
+ fill_render(rgba_green);
+
+ EXPECT_TRUE(listener->wait_event(300ms)) << "timed out waiting for luma event to be received";
+ EXPECT_NEAR(listener->luma(), luma_green, error_margin);
+
+ listener->reset();
+ composer->removeRegionSamplingListener(listener);
+ fill_render(rgba_green);
+ EXPECT_FALSE(listener->wait_event(100ms))
+ << "callback should stop after remove the region sampling listener";
+}
+
+TEST_F(RegionSamplingTest, DISABLED_CollectsLumaFromMovingLayer) {
+ sp<ISurfaceComposer> composer = ComposerService::getComposerService();
+ sp<Listener> listener = new Listener();
+ Rect sampleArea{100, 100, 200, 200};
+
+ // Test: listener in (100, 100). See layer before move, no layer after move.
+ fill_render(rgba_blue);
+ composer->addRegionSamplingListener(sampleArea, mTopLayer->getHandle(), listener);
+ EXPECT_TRUE(listener->wait_event(300ms)) << "timed out waiting for luma event to be received";
+ EXPECT_NEAR(listener->luma(), luma_blue, error_margin);
+ listener->reset();
+ SurfaceComposerClient::Transaction{}.setPosition(mContentLayer, 600, 600).apply();
+ EXPECT_TRUE(listener->wait_event(300ms)) << "timed out waiting for luma event to be received";
+ EXPECT_NEAR(listener->luma(), luma_gray, error_margin);
+ composer->removeRegionSamplingListener(listener);
+
+ // Test: listener offset to (600, 600). No layer before move, see layer after move.
+ fill_render(rgba_green);
+ sampleArea.offsetTo(600, 600);
+ composer->addRegionSamplingListener(sampleArea, mTopLayer->getHandle(), listener);
+ EXPECT_TRUE(listener->wait_event(300ms)) << "timed out waiting for luma event to be received";
+ EXPECT_NEAR(listener->luma(), luma_gray, error_margin);
+ listener->reset();
+ SurfaceComposerClient::Transaction{}.setPosition(mContentLayer, 600, 600).apply();
+ EXPECT_TRUE(listener->wait_event(300ms)) << "timed out waiting for luma event to be received";
+ EXPECT_NEAR(listener->luma(), luma_green, error_margin);
+ composer->removeRegionSamplingListener(listener);
+}
+
} // namespace android::test
diff --git a/libs/vr/libbufferhub/consumer_buffer.cpp b/libs/vr/libbufferhub/consumer_buffer.cpp
index 115e866..7823e36 100644
--- a/libs/vr/libbufferhub/consumer_buffer.cpp
+++ b/libs/vr/libbufferhub/consumer_buffer.cpp
@@ -52,12 +52,6 @@
while (!buffer_state_->compare_exchange_weak(
current_buffer_state, updated_buffer_state, std::memory_order_acq_rel,
std::memory_order_acquire)) {
- ALOGD(
- "%s Failed to acquire the buffer. Current buffer state was changed to "
- "%" PRIx32
- " when trying to acquire the buffer and modify the buffer state to "
- "%" PRIx32 ". About to try again if the buffer is still posted.",
- __FUNCTION__, current_buffer_state, updated_buffer_state);
if (!BufferHubDefs::isClientPosted(current_buffer_state,
client_state_mask())) {
ALOGE(
@@ -152,12 +146,6 @@
while (!buffer_state_->compare_exchange_weak(
current_buffer_state, updated_buffer_state, std::memory_order_acq_rel,
std::memory_order_acquire)) {
- ALOGD(
- "%s: Failed to release the buffer. Current buffer state was changed to "
- "%" PRIx32
- " when trying to release the buffer and modify the buffer state to "
- "%" PRIx32 ". About to try again.",
- __FUNCTION__, current_buffer_state, updated_buffer_state);
// The failure of compare_exchange_weak updates current_buffer_state.
updated_buffer_state = current_buffer_state & (~client_state_mask());
}
diff --git a/libs/vr/libbufferhub/producer_buffer.cpp b/libs/vr/libbufferhub/producer_buffer.cpp
index 3d88ba5..aa9d072 100644
--- a/libs/vr/libbufferhub/producer_buffer.cpp
+++ b/libs/vr/libbufferhub/producer_buffer.cpp
@@ -96,13 +96,6 @@
while (!buffer_state_->compare_exchange_weak(
current_buffer_state, updated_buffer_state, std::memory_order_acq_rel,
std::memory_order_acquire)) {
- ALOGD(
- "%s: Failed to post the buffer. Current buffer state was changed to "
- "%" PRIx32
- " when trying to post the buffer and modify the buffer state to "
- "%" PRIx32
- ". About to try again if the buffer is still gained by this client.",
- __FUNCTION__, current_buffer_state, updated_buffer_state);
if (!BufferHubDefs::isClientGained(current_buffer_state,
client_state_mask())) {
ALOGE(
@@ -186,15 +179,6 @@
while (!buffer_state_->compare_exchange_weak(
current_buffer_state, updated_buffer_state, std::memory_order_acq_rel,
std::memory_order_acquire)) {
- ALOGD(
- "%s: Failed to gain the buffer. Current buffer state was changed to "
- "%" PRIx32
- " when trying to gain the buffer and modify the buffer state to "
- "%" PRIx32
- ". About to try again if the buffer is still not read by other "
- "clients.",
- __FUNCTION__, current_buffer_state, updated_buffer_state);
-
if (BufferHubDefs::isAnyClientAcquired(current_buffer_state) ||
BufferHubDefs::isAnyClientGained(current_buffer_state) ||
(BufferHubDefs::isAnyClientPosted(
diff --git a/opengl/libs/Android.bp b/opengl/libs/Android.bp
index abc7a72..8144c8a 100644
--- a/opengl/libs/Android.bp
+++ b/opengl/libs/Android.bp
@@ -162,7 +162,7 @@
"libEGL_getProcAddress",
"libEGL_blobCache",
],
- ldflags: ["-Wl,--exclude-libs=ALL"],
+ ldflags: ["-Wl,--exclude-libs=ALL,--Bsymbolic-functions"],
export_include_dirs: ["EGL/include"],
}
diff --git a/services/inputflinger/EventHub.cpp b/services/inputflinger/EventHub.cpp
index ce56272..af02314 100644
--- a/services/inputflinger/EventHub.cpp
+++ b/services/inputflinger/EventHub.cpp
@@ -28,7 +28,6 @@
#include <sys/limits.h>
#include <sys/inotify.h>
#include <sys/ioctl.h>
-#include <sys/utsname.h>
#include <unistd.h>
#define LOG_TAG "EventHub"
@@ -94,14 +93,6 @@
return out;
}
-static void getLinuxRelease(int* major, int* minor) {
- struct utsname info;
- if (uname(&info) || sscanf(info.release, "%d.%d", major, minor) <= 0) {
- *major = 0, *minor = 0;
- ALOGE("Could not get linux version: %s", strerror(errno));
- }
-}
-
/**
* Return true if name matches "v4l-touch*"
*/
@@ -292,11 +283,6 @@
result = epoll_ctl(mEpollFd, EPOLL_CTL_ADD, mWakeReadPipeFd, &eventItem);
LOG_ALWAYS_FATAL_IF(result != 0, "Could not add wake read pipe to epoll instance. errno=%d",
errno);
-
- int major, minor;
- getLinuxRelease(&major, &minor);
- // EPOLLWAKEUP was introduced in kernel 3.5
- mUsingEpollWakeup = major > 3 || (major == 3 && minor >= 5);
}
EventHub::~EventHub(void) {
@@ -1487,28 +1473,13 @@
}
}
- std::string wakeMechanism = "EPOLLWAKEUP";
- if (!mUsingEpollWakeup) {
-#ifndef EVIOCSSUSPENDBLOCK
- // uapi headers don't include EVIOCSSUSPENDBLOCK, and future kernels
- // will use an epoll flag instead, so as long as we want to support
- // this feature, we need to be prepared to define the ioctl ourselves.
-#define EVIOCSSUSPENDBLOCK _IOW('E', 0x91, int)
-#endif
- if (ioctl(device->fd, EVIOCSSUSPENDBLOCK, 1)) {
- wakeMechanism = "<none>";
- } else {
- wakeMechanism = "EVIOCSSUSPENDBLOCK";
- }
- }
// Tell the kernel that we want to use the monotonic clock for reporting timestamps
// associated with input events. This is important because the input system
// uses the timestamps extensively and assumes they were recorded using the monotonic
// clock.
int clockId = CLOCK_MONOTONIC;
bool usingClockIoctl = !ioctl(device->fd, EVIOCSCLOCKID, &clockId);
- ALOGI("wakeMechanism=%s, usingClockIoctl=%s", wakeMechanism.c_str(),
- toString(usingClockIoctl));
+ ALOGI("usingClockIoctl=%s", toString(usingClockIoctl));
}
void EventHub::openVideoDeviceLocked(const std::string& devicePath) {
diff --git a/services/inputflinger/EventHub.h b/services/inputflinger/EventHub.h
index 63a20ef..eb4e8f2 100644
--- a/services/inputflinger/EventHub.h
+++ b/services/inputflinger/EventHub.h
@@ -479,8 +479,6 @@
size_t mPendingEventCount;
size_t mPendingEventIndex;
bool mPendingINotify;
-
- bool mUsingEpollWakeup;
};
}; // namespace android
diff --git a/services/surfaceflinger/CompositionEngine/tests/FloatRectMatcher.h b/services/surfaceflinger/CompositionEngine/tests/FloatRectMatcher.h
new file mode 100644
index 0000000..6741cc9
--- /dev/null
+++ b/services/surfaceflinger/CompositionEngine/tests/FloatRectMatcher.h
@@ -0,0 +1,48 @@
+/*
+ * Copyright 2019 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 <string>
+
+#include <android-base/stringprintf.h>
+#include <gmock/gmock.h>
+
+namespace {
+
+using android::base::StringAppendF;
+using FloatRect = android::FloatRect;
+
+void dumpFloatRect(const FloatRect& rect, std::string& result, const char* name) {
+ StringAppendF(&result, "%s (%f %f %f %f) ", name, rect.left, rect.top, rect.right, rect.bottom);
+}
+
+// Checks for a region match
+MATCHER_P(FloatRectEq, expected, "") {
+ std::string buf;
+ buf.append("FloatRects are not equal\n");
+ dumpFloatRect(expected, buf, "expected rect");
+ dumpFloatRect(arg, buf, "actual rect");
+ *result_listener << buf;
+
+ const float TOLERANCE = 1e-3f;
+ return (std::fabs(expected.left - arg.left) < TOLERANCE) &&
+ (std::fabs(expected.top - arg.top) < TOLERANCE) &&
+ (std::fabs(expected.right - arg.right) < TOLERANCE) &&
+ (std::fabs(expected.bottom - arg.bottom) < TOLERANCE);
+}
+
+} // namespace
diff --git a/services/surfaceflinger/CompositionEngine/tests/OutputLayerTest.cpp b/services/surfaceflinger/CompositionEngine/tests/OutputLayerTest.cpp
index 2060c5a..ae906cd 100644
--- a/services/surfaceflinger/CompositionEngine/tests/OutputLayerTest.cpp
+++ b/services/surfaceflinger/CompositionEngine/tests/OutputLayerTest.cpp
@@ -21,6 +21,7 @@
#include <compositionengine/mock/Output.h>
#include <gtest/gtest.h>
+#include "FloatRectMatcher.h"
#include "MockHWC2.h"
#include "MockHWComposer.h"
#include "RectMatcher.h"
@@ -106,6 +107,114 @@
}
/*
+ * OutputLayer::calculateOutputSourceCrop()
+ */
+
+struct OutputLayerSourceCropTest : public OutputLayerTest {
+ OutputLayerSourceCropTest() {
+ // Set reasonable default values for a simple case. Each test will
+ // set one specific value to something different.
+ mLayerState.frontEnd.geomUsesSourceCrop = true;
+ mLayerState.frontEnd.geomContentCrop = Rect{0, 0, 1920, 1080};
+ mLayerState.frontEnd.geomActiveTransparentRegion = Region{};
+ mLayerState.frontEnd.geomLayerBounds = FloatRect{0.f, 0.f, 1920.f, 1080.f};
+ mLayerState.frontEnd.geomLayerTransform = ui::Transform{TR_IDENT};
+ mLayerState.frontEnd.geomBufferSize = Rect{0, 0, 1920, 1080};
+ mLayerState.frontEnd.geomBufferTransform = TR_IDENT;
+
+ mOutputState.viewport = Rect{0, 0, 1920, 1080};
+ }
+
+ FloatRect calculateOutputSourceCrop() {
+ mLayerState.frontEnd.geomInverseLayerTransform =
+ mLayerState.frontEnd.geomLayerTransform.inverse();
+
+ return mOutputLayer.calculateOutputSourceCrop();
+ }
+};
+
+TEST_F(OutputLayerSourceCropTest, computesEmptyIfSourceCropNotUsed) {
+ mLayerState.frontEnd.geomUsesSourceCrop = false;
+
+ const FloatRect expected{};
+ EXPECT_THAT(calculateOutputSourceCrop(), FloatRectEq(expected));
+}
+
+TEST_F(OutputLayerSourceCropTest, correctForSimpleDefaultCase) {
+ const FloatRect expected{0.f, 0.f, 1920.f, 1080.f};
+ EXPECT_THAT(calculateOutputSourceCrop(), FloatRectEq(expected));
+}
+
+TEST_F(OutputLayerSourceCropTest, handlesBoundsOutsideViewport) {
+ mLayerState.frontEnd.geomLayerBounds = FloatRect{-2000.f, -2000.f, 2000.f, 2000.f};
+
+ const FloatRect expected{0.f, 0.f, 1920.f, 1080.f};
+ EXPECT_THAT(calculateOutputSourceCrop(), FloatRectEq(expected));
+}
+
+TEST_F(OutputLayerSourceCropTest, handlesBoundsOutsideViewportRotated) {
+ mLayerState.frontEnd.geomLayerBounds = FloatRect{-2000.f, -2000.f, 2000.f, 2000.f};
+ mLayerState.frontEnd.geomLayerTransform.set(HAL_TRANSFORM_ROT_90, 1920, 1080);
+
+ const FloatRect expected{0.f, 0.f, 1080.f, 1080.f};
+ EXPECT_THAT(calculateOutputSourceCrop(), FloatRectEq(expected));
+}
+
+TEST_F(OutputLayerSourceCropTest, calculateOutputSourceCropWorksWithATransformedBuffer) {
+ struct Entry {
+ uint32_t bufferInvDisplay;
+ uint32_t buffer;
+ uint32_t display;
+ FloatRect expected;
+ };
+ // Not an exhaustive list of cases, but hopefully enough.
+ const std::array<Entry, 12> testData = {
+ // clang-format off
+ // inv buffer display expected
+ /* 0 */ Entry{false, TR_IDENT, TR_IDENT, FloatRect{0.f, 0.f, 1920.f, 1080.f}},
+ /* 1 */ Entry{false, TR_IDENT, TR_ROT_90, FloatRect{0.f, 0.f, 1920.f, 1080.f}},
+ /* 2 */ Entry{false, TR_IDENT, TR_ROT_180, FloatRect{0.f, 0.f, 1920.f, 1080.f}},
+ /* 3 */ Entry{false, TR_IDENT, TR_ROT_270, FloatRect{0.f, 0.f, 1920.f, 1080.f}},
+
+ /* 4 */ Entry{true, TR_IDENT, TR_IDENT, FloatRect{0.f, 0.f, 1920.f, 1080.f}},
+ /* 5 */ Entry{true, TR_IDENT, TR_ROT_90, FloatRect{0.f, 0.f, 1920.f, 1080.f}},
+ /* 6 */ Entry{true, TR_IDENT, TR_ROT_180, FloatRect{0.f, 0.f, 1920.f, 1080.f}},
+ /* 7 */ Entry{true, TR_IDENT, TR_ROT_270, FloatRect{0.f, 0.f, 1920.f, 1080.f}},
+
+ /* 8 */ Entry{false, TR_IDENT, TR_IDENT, FloatRect{0.f, 0.f, 1920.f, 1080.f}},
+ /* 9 */ Entry{false, TR_ROT_90, TR_ROT_90, FloatRect{0.f, 0.f, 1920.f, 1080.f}},
+ /* 10 */ Entry{false, TR_ROT_180, TR_ROT_180, FloatRect{0.f, 0.f, 1920.f, 1080.f}},
+ /* 11 */ Entry{false, TR_ROT_270, TR_ROT_270, FloatRect{0.f, 0.f, 1920.f, 1080.f}},
+
+ // clang-format on
+ };
+
+ for (size_t i = 0; i < testData.size(); i++) {
+ const auto& entry = testData[i];
+
+ mLayerState.frontEnd.geomBufferUsesDisplayInverseTransform = entry.bufferInvDisplay;
+ mLayerState.frontEnd.geomBufferTransform = entry.buffer;
+ mOutputState.orientation = entry.display;
+
+ EXPECT_THAT(calculateOutputSourceCrop(), FloatRectEq(entry.expected)) << "entry " << i;
+ }
+}
+
+TEST_F(OutputLayerSourceCropTest, geomContentCropAffectsCrop) {
+ mLayerState.frontEnd.geomContentCrop = Rect{0, 0, 960, 540};
+
+ const FloatRect expected{0.f, 0.f, 960.f, 540.f};
+ EXPECT_THAT(calculateOutputSourceCrop(), FloatRectEq(expected));
+}
+
+TEST_F(OutputLayerSourceCropTest, viewportAffectsCrop) {
+ mOutputState.viewport = Rect{0, 0, 960, 540};
+
+ const FloatRect expected{0.f, 0.f, 960.f, 540.f};
+ EXPECT_THAT(calculateOutputSourceCrop(), FloatRectEq(expected));
+}
+
+/*
* OutputLayer::calculateOutputDisplayFrame()
*/
@@ -163,7 +272,7 @@
EXPECT_THAT(calculateOutputDisplayFrame(), RectEq(expected));
}
-TEST_F(OutputLayerDisplayFrameTest, geomLayerSnapToBoundsAffectsFrame) {
+TEST_F(OutputLayerDisplayFrameTest, geomLayerBoundsAffectsFrame) {
mLayerState.frontEnd.geomLayerBounds = FloatRect{0.f, 0.f, 960.f, 540.f};
const Rect expected{0, 0, 960, 540};
EXPECT_THAT(calculateOutputDisplayFrame(), RectEq(expected));
@@ -242,6 +351,159 @@
}
}
+TEST_F(OutputLayerTest,
+ calculateOutputRelativeBufferTransformTestWithOfBufferUsesDisplayInverseTransform) {
+ mLayerState.frontEnd.geomBufferUsesDisplayInverseTransform = true;
+
+ struct Entry {
+ uint32_t layer;
+ uint32_t buffer;
+ uint32_t display;
+ uint32_t expected;
+ };
+ // Not an exhaustive list of cases, but hopefully enough.
+ const std::array<Entry, 24> testData = {
+ // clang-format off
+ // layer buffer display expected
+ /* 0 */ Entry{TR_IDENT, TR_IDENT, TR_IDENT, TR_IDENT},
+ /* 1 */ Entry{TR_IDENT, TR_IDENT, TR_ROT_90, TR_IDENT},
+ /* 2 */ Entry{TR_IDENT, TR_IDENT, TR_ROT_180, TR_IDENT},
+ /* 3 */ Entry{TR_IDENT, TR_IDENT, TR_ROT_270, TR_IDENT},
+
+ /* 4 */ Entry{TR_IDENT, TR_FLP_H, TR_IDENT, TR_FLP_H},
+ /* 5 */ Entry{TR_IDENT, TR_FLP_H, TR_ROT_90, TR_FLP_H},
+ /* 6 */ Entry{TR_IDENT, TR_FLP_H, TR_ROT_180, TR_FLP_H},
+ /* 7 */ Entry{TR_IDENT, TR_FLP_H, TR_ROT_270, TR_FLP_H},
+
+ /* 8 */ Entry{TR_IDENT, TR_FLP_V, TR_IDENT, TR_FLP_V},
+ /* 9 */ Entry{TR_IDENT, TR_ROT_90, TR_ROT_90, TR_ROT_90},
+ /* 10 */ Entry{TR_IDENT, TR_ROT_180, TR_ROT_180, TR_ROT_180},
+ /* 11 */ Entry{TR_IDENT, TR_ROT_270, TR_ROT_270, TR_ROT_270},
+
+ /* 12 */ Entry{TR_ROT_90, TR_IDENT, TR_IDENT, TR_IDENT},
+ /* 13 */ Entry{TR_ROT_90, TR_FLP_H, TR_ROT_90, TR_FLP_H},
+ /* 14 */ Entry{TR_ROT_90, TR_IDENT, TR_ROT_180, TR_IDENT},
+ /* 15 */ Entry{TR_ROT_90, TR_FLP_H, TR_ROT_270, TR_FLP_H},
+
+ /* 16 */ Entry{TR_ROT_180, TR_FLP_H, TR_IDENT, TR_FLP_H},
+ /* 17 */ Entry{TR_ROT_180, TR_IDENT, TR_ROT_90, TR_IDENT},
+ /* 18 */ Entry{TR_ROT_180, TR_FLP_H, TR_ROT_180, TR_FLP_H},
+ /* 19 */ Entry{TR_ROT_180, TR_IDENT, TR_ROT_270, TR_IDENT},
+
+ /* 20 */ Entry{TR_ROT_270, TR_IDENT, TR_IDENT, TR_IDENT},
+ /* 21 */ Entry{TR_ROT_270, TR_FLP_H, TR_ROT_90, TR_FLP_H},
+ /* 22 */ Entry{TR_ROT_270, TR_FLP_H, TR_ROT_180, TR_FLP_H},
+ /* 23 */ Entry{TR_ROT_270, TR_IDENT, TR_ROT_270, TR_IDENT},
+ // clang-format on
+ };
+
+ for (size_t i = 0; i < testData.size(); i++) {
+ const auto& entry = testData[i];
+
+ mLayerState.frontEnd.geomLayerTransform = ui::Transform{entry.layer};
+ mLayerState.frontEnd.geomBufferTransform = entry.buffer;
+ mOutputState.orientation = entry.display;
+
+ auto actual = mOutputLayer.calculateOutputRelativeBufferTransform();
+ EXPECT_EQ(entry.expected, actual) << "entry " << i;
+ }
+}
+
+/*
+ * OutputLayer::updateCompositionState()
+ */
+
+struct OutputLayerPartialMockForUpdateCompositionState : public impl::OutputLayer {
+ OutputLayerPartialMockForUpdateCompositionState(const compositionengine::Output& output,
+ std::shared_ptr<compositionengine::Layer> layer,
+ sp<compositionengine::LayerFE> layerFE)
+ : impl::OutputLayer(output, layer, layerFE) {}
+ // Mock everything called by updateCompositionState to simplify testing it.
+ MOCK_CONST_METHOD0(calculateOutputSourceCrop, FloatRect());
+ MOCK_CONST_METHOD0(calculateOutputDisplayFrame, Rect());
+ MOCK_CONST_METHOD0(calculateOutputRelativeBufferTransform, uint32_t());
+};
+
+struct OutputLayerUpdateCompositionStateTest : public OutputLayerTest {
+public:
+ OutputLayerUpdateCompositionStateTest() {
+ EXPECT_CALL(*mLayer, getState()).WillRepeatedly(ReturnRef(mLayerState));
+ EXPECT_CALL(mOutput, getState()).WillRepeatedly(ReturnRef(mOutputState));
+ }
+
+ ~OutputLayerUpdateCompositionStateTest() = default;
+
+ void setupGeometryChildCallValues() {
+ EXPECT_CALL(mOutputLayer, calculateOutputSourceCrop()).WillOnce(Return(kSourceCrop));
+ EXPECT_CALL(mOutputLayer, calculateOutputDisplayFrame()).WillOnce(Return(kDisplayFrame));
+ EXPECT_CALL(mOutputLayer, calculateOutputRelativeBufferTransform())
+ .WillOnce(Return(mBufferTransform));
+ }
+
+ void validateComputedGeometryState() {
+ const auto& state = mOutputLayer.getState();
+ EXPECT_EQ(kSourceCrop, state.sourceCrop);
+ EXPECT_EQ(kDisplayFrame, state.displayFrame);
+ EXPECT_EQ(static_cast<Hwc2::Transform>(mBufferTransform), state.bufferTransform);
+ }
+
+ const FloatRect kSourceCrop{1.f, 2.f, 3.f, 4.f};
+ const Rect kDisplayFrame{11, 12, 13, 14};
+ uint32_t mBufferTransform{21};
+
+ using OutputLayer = OutputLayerPartialMockForUpdateCompositionState;
+ StrictMock<OutputLayer> mOutputLayer{mOutput, mLayer, mLayerFE};
+};
+
+TEST_F(OutputLayerUpdateCompositionStateTest, setsStateNormally) {
+ mLayerState.frontEnd.isSecure = true;
+ mOutputState.isSecure = true;
+
+ setupGeometryChildCallValues();
+
+ mOutputLayer.updateCompositionState(true);
+
+ validateComputedGeometryState();
+
+ EXPECT_EQ(false, mOutputLayer.getState().forceClientComposition);
+}
+
+TEST_F(OutputLayerUpdateCompositionStateTest,
+ alsoSetsForceCompositionIfSecureLayerOnNonsecureOutput) {
+ mLayerState.frontEnd.isSecure = true;
+ mOutputState.isSecure = false;
+
+ setupGeometryChildCallValues();
+
+ mOutputLayer.updateCompositionState(true);
+
+ validateComputedGeometryState();
+
+ EXPECT_EQ(true, mOutputLayer.getState().forceClientComposition);
+}
+
+TEST_F(OutputLayerUpdateCompositionStateTest,
+ alsoSetsForceCompositionIfUnsupportedBufferTransform) {
+ mLayerState.frontEnd.isSecure = true;
+ mOutputState.isSecure = true;
+
+ mBufferTransform = ui::Transform::ROT_INVALID;
+
+ setupGeometryChildCallValues();
+
+ mOutputLayer.updateCompositionState(true);
+
+ validateComputedGeometryState();
+
+ EXPECT_EQ(true, mOutputLayer.getState().forceClientComposition);
+}
+
+TEST_F(OutputLayerUpdateCompositionStateTest, doesNotRecomputeGeometryIfNotRequested) {
+ mOutputLayer.updateCompositionState(false);
+
+ EXPECT_EQ(false, mOutputLayer.getState().forceClientComposition);
+}
+
/*
* OutputLayer::writeStateToHWC()
*/
diff --git a/services/surfaceflinger/Layer.cpp b/services/surfaceflinger/Layer.cpp
index 898f3bc..cae1b46 100644
--- a/services/surfaceflinger/Layer.cpp
+++ b/services/surfaceflinger/Layer.cpp
@@ -428,7 +428,7 @@
auto& parentState = parent->getDrawingState();
const int parentType = parentState.metadata.getInt32(METADATA_WINDOW_TYPE, 0);
const int parentAppId = parentState.metadata.getInt32(METADATA_OWNER_UID, 0);
- if (parentType >= 0 || parentAppId >= 0) {
+ if (parentType > 0 && parentAppId > 0) {
type = parentType;
appId = parentAppId;
}
diff --git a/services/vr/bufferhubd/producer_channel.cpp b/services/vr/bufferhubd/producer_channel.cpp
index a7fd912..b71964b 100644
--- a/services/vr/bufferhubd/producer_channel.cpp
+++ b/services/vr/bufferhubd/producer_channel.cpp
@@ -350,7 +350,7 @@
while (!buffer_state_->compare_exchange_weak(
current_buffer_state, updated_buffer_state, std::memory_order_acq_rel,
std::memory_order_acquire)) {
- ALOGI(
+ ALOGV(
"%s: Failed to post to the new consumer. "
"Current buffer state was changed to %" PRIx32
" when trying to acquire the buffer and modify the buffer state to "
diff --git a/services/vr/hardware_composer/impl/vr_hwc.cpp b/services/vr/hardware_composer/impl/vr_hwc.cpp
index fb7932d..7323277 100644
--- a/services/vr/hardware_composer/impl/vr_hwc.cpp
+++ b/services/vr/hardware_composer/impl/vr_hwc.cpp
@@ -994,6 +994,26 @@
vsync_callback_->SetEventCallback(send_vsync ? event_callback_ : nullptr);
}
+Return<void> VrHwc::debug(const hidl_handle& fd,
+ const hidl_vec<hidl_string>& args) {
+ std::string result;
+
+ {
+ std::lock_guard<std::mutex> guard(mutex_);
+ for (const auto& pair : displays_) {
+ result += StringPrintf("Display id: %d\n", static_cast<int>(pair.first));
+ pair.second->dumpDebugInfo(&result);
+ }
+ result += "\n";
+ }
+
+ FILE* out = fdopen(dup(fd->data[0]), "w");
+ fprintf(out, "%s", result.c_str());
+ fclose(out);
+
+ return Void();
+}
+
void HwcLayer::dumpDebugInfo(std::string* result) const {
if (!result) {
return;
diff --git a/services/vr/hardware_composer/impl/vr_hwc.h b/services/vr/hardware_composer/impl/vr_hwc.h
index e8c0212..15358c5 100644
--- a/services/vr/hardware_composer/impl/vr_hwc.h
+++ b/services/vr/hardware_composer/impl/vr_hwc.h
@@ -295,6 +295,9 @@
void RegisterObserver(Observer* observer) override;
void UnregisterObserver(Observer* observer) override;
+ Return<void> debug(const hidl_handle& fd,
+ const hidl_vec<hidl_string>& args) override;
+
private:
class VsyncCallback : public BnVsyncCallback {
public:
diff --git a/services/vr/virtual_touchpad/virtual_touchpad.rc b/services/vr/virtual_touchpad/virtual_touchpad.rc
index 99315ef..0de0f9e 100644
--- a/services/vr/virtual_touchpad/virtual_touchpad.rc
+++ b/services/vr/virtual_touchpad/virtual_touchpad.rc
@@ -1,5 +1,5 @@
service virtual_touchpad /system/bin/virtual_touchpad
class core
user system
- group system input
+ group system input uhid
writepid /dev/cpuset/system/tasks
diff --git a/vulkan/libvulkan/api_gen.cpp b/vulkan/libvulkan/api_gen.cpp
index df86af0..ad46c3b 100644
--- a/vulkan/libvulkan/api_gen.cpp
+++ b/vulkan/libvulkan/api_gen.cpp
@@ -16,12 +16,11 @@
// WARNING: This file is generated. See ../README.md for instructions.
+#include <log/log.h>
#include <string.h>
#include <algorithm>
-#include <log/log.h>
-
// to catch mismatches between vulkan.h and this file
#undef VK_NO_PROTOTYPES
#include "api.h"
diff --git a/vulkan/libvulkan/api_gen.h b/vulkan/libvulkan/api_gen.h
index 4bedbeb..f582224 100644
--- a/vulkan/libvulkan/api_gen.h
+++ b/vulkan/libvulkan/api_gen.h
@@ -20,7 +20,9 @@
#define LIBVULKAN_API_GEN_H
#include <vulkan/vulkan.h>
+
#include <bitset>
+
#include "driver_gen.h"
namespace vulkan {
diff --git a/vulkan/libvulkan/code-generator.tmpl b/vulkan/libvulkan/code-generator.tmpl
index bdd3573..940b747 100644
--- a/vulkan/libvulkan/code-generator.tmpl
+++ b/vulkan/libvulkan/code-generator.tmpl
@@ -37,8 +37,10 @@
#ifndef LIBVULKAN_API_GEN_H
#define LIBVULKAN_API_GEN_H
¶
-#include <bitset>
#include <vulkan/vulkan.h>
+¶
+#include <bitset>
+¶
#include "driver_gen.h"
¶
namespace vulkan {«
@@ -90,12 +92,11 @@
¶
// WARNING: This file is generated. See ../README.md for instructions.
¶
+#include <log/log.h>
#include <string.h>
¶
#include <algorithm>
¶
-#include <log/log.h>
-¶
// to catch mismatches between vulkan.h and this file
#undef VK_NO_PROTOTYPES
#include "api.h"
@@ -217,9 +218,10 @@
#ifndef LIBVULKAN_DRIVER_GEN_H
#define LIBVULKAN_DRIVER_GEN_H
¶
-#include <bitset>
-#include <vulkan/vulkan.h>
#include <vulkan/vk_android_native_buffer.h>
+#include <vulkan/vulkan.h>
+¶
+#include <bitset>
¶
namespace vulkan {«
namespace driver {«
@@ -271,12 +273,11 @@
¶
// WARNING: This file is generated. See ../README.md for instructions.
¶
+#include <log/log.h>
#include <string.h>
¶
#include <algorithm>
¶
-#include <log/log.h>
-¶
#include "driver.h"
¶
namespace vulkan {«
diff --git a/vulkan/libvulkan/driver_gen.cpp b/vulkan/libvulkan/driver_gen.cpp
index 574c327..7020be1 100644
--- a/vulkan/libvulkan/driver_gen.cpp
+++ b/vulkan/libvulkan/driver_gen.cpp
@@ -16,12 +16,11 @@
// WARNING: This file is generated. See ../README.md for instructions.
+#include <log/log.h>
#include <string.h>
#include <algorithm>
-#include <log/log.h>
-
#include "driver.h"
namespace vulkan {
diff --git a/vulkan/libvulkan/driver_gen.h b/vulkan/libvulkan/driver_gen.h
index 3faf6c0..c299549 100644
--- a/vulkan/libvulkan/driver_gen.h
+++ b/vulkan/libvulkan/driver_gen.h
@@ -21,6 +21,7 @@
#include <vulkan/vk_android_native_buffer.h>
#include <vulkan/vulkan.h>
+
#include <bitset>
namespace vulkan {
diff --git a/vulkan/nulldrv/null_driver.tmpl b/vulkan/nulldrv/null_driver.tmpl
index ce15517..0f53015 100644
--- a/vulkan/nulldrv/null_driver.tmpl
+++ b/vulkan/nulldrv/null_driver.tmpl
@@ -97,9 +97,10 @@
¶
// WARNING: This file is generated. See ../README.md for instructions.
¶
-#include "null_driver_gen.h"
#include <algorithm>
¶
+#include "null_driver_gen.h"
+¶
using namespace null_driver;
¶
namespace {
diff --git a/vulkan/nulldrv/null_driver_gen.cpp b/vulkan/nulldrv/null_driver_gen.cpp
index 92b7468..b8d7d2b 100644
--- a/vulkan/nulldrv/null_driver_gen.cpp
+++ b/vulkan/nulldrv/null_driver_gen.cpp
@@ -17,6 +17,7 @@
// WARNING: This file is generated. See ../README.md for instructions.
#include <algorithm>
+
#include "null_driver_gen.h"
using namespace null_driver;