Merge "Add atrace_userdebug.rc to enable some tracepoints for userdebug only." into oc-dev
diff --git a/cmds/flatland/GLHelper.cpp b/cmds/flatland/GLHelper.cpp
index 5c04f6c..dfc3e58 100644
--- a/cmds/flatland/GLHelper.cpp
+++ b/cmds/flatland/GLHelper.cpp
@@ -25,7 +25,6 @@
namespace android {
GLHelper::GLHelper() :
- mGraphicBufferAlloc(new GraphicBufferAlloc()),
mDisplay(EGL_NO_DISPLAY),
mContext(EGL_NO_CONTEXT),
mDummySurface(EGL_NO_SURFACE),
@@ -203,7 +202,7 @@
sp<GLConsumer>* glConsumer, EGLSurface* surface) {
sp<IGraphicBufferProducer> producer;
sp<IGraphicBufferConsumer> consumer;
- BufferQueue::createBufferQueue(&producer, &consumer, mGraphicBufferAlloc);
+ BufferQueue::createBufferQueue(&producer, &consumer);
sp<GLConsumer> glc = new GLConsumer(consumer, name,
GL_TEXTURE_EXTERNAL_OES, false, true);
glc->setDefaultBufferSize(w, h);
diff --git a/cmds/flatland/GLHelper.h b/cmds/flatland/GLHelper.h
index 7a9e9e3..d09463a 100644
--- a/cmds/flatland/GLHelper.h
+++ b/cmds/flatland/GLHelper.h
@@ -14,7 +14,6 @@
* limitations under the License.
*/
-#include <gui/GraphicBufferAlloc.h>
#include <gui/GLConsumer.h>
#include <gui/Surface.h>
#include <gui/SurfaceControl.h>
@@ -75,8 +74,6 @@
bool setUpShaders(const ShaderDesc* shaderDescs, size_t numShaders);
- sp<GraphicBufferAlloc> mGraphicBufferAlloc;
-
EGLDisplay mDisplay;
EGLContext mContext;
EGLSurface mDummySurface;
diff --git a/cmds/flatland/Main.cpp b/cmds/flatland/Main.cpp
index c47b0c8..ec1e543 100644
--- a/cmds/flatland/Main.cpp
+++ b/cmds/flatland/Main.cpp
@@ -16,7 +16,6 @@
#define ATRACE_TAG ATRACE_TAG_ALWAYS
-#include <gui/GraphicBufferAlloc.h>
#include <gui/Surface.h>
#include <gui/SurfaceControl.h>
#include <gui/GLConsumer.h>
diff --git a/cmds/installd/InstalldNativeService.cpp b/cmds/installd/InstalldNativeService.cpp
index 3e0f6f0..989fcda 100644
--- a/cmds/installd/InstalldNativeService.cpp
+++ b/cmds/installd/InstalldNativeService.cpp
@@ -395,7 +395,9 @@
}
// Consider restorecon over contents if label changed
- if (restorecon_app_data_lazy(path, seInfo, uid, existing)) {
+ if (restorecon_app_data_lazy(path, seInfo, uid, existing) ||
+ restorecon_app_data_lazy(path, "cache", seInfo, uid, existing) ||
+ restorecon_app_data_lazy(path, "code_cache", seInfo, uid, existing)) {
return error("Failed to restorecon " + path);
}
@@ -617,11 +619,9 @@
ATRACE_BEGIN("fixup user");
FTS* fts;
FTSENT* p;
- char *argv[] = {
- (char*) create_data_user_ce_path(uuid_, user).c_str(),
- (char*) create_data_user_de_path(uuid_, user).c_str(),
- nullptr
- };
+ auto ce_path = create_data_user_ce_path(uuid_, user);
+ auto de_path = create_data_user_de_path(uuid_, user);
+ char *argv[] = { (char*) ce_path.c_str(), (char*) de_path.c_str(), nullptr };
if (!(fts = fts_open(argv, FTS_PHYSICAL | FTS_NOCHDIR | FTS_XDEV, NULL))) {
return error("Failed to fts_open");
}
@@ -950,11 +950,9 @@
for (auto user : get_known_users(uuid_)) {
FTS *fts;
FTSENT *p;
- char *argv[] = {
- (char*) create_data_user_ce_path(uuid_, user).c_str(),
- (char*) create_data_user_de_path(uuid_, user).c_str(),
- nullptr
- };
+ auto ce_path = create_data_user_ce_path(uuid_, user);
+ auto de_path = create_data_user_de_path(uuid_, user);
+ char *argv[] = { (char*) ce_path.c_str(), (char*) de_path.c_str(), nullptr };
if (!(fts = fts_open(argv, FTS_PHYSICAL | FTS_NOCHDIR | FTS_XDEV, NULL))) {
return error("Failed to fts_open");
}
@@ -1395,12 +1393,16 @@
collectManualStats(dePath, &stats);
ATRACE_END();
- ATRACE_BEGIN("profiles");
- auto userProfilePath = create_primary_current_profile_package_dir_path(userId, pkgname);
- calculate_tree_size(userProfilePath, &stats.dataSize);
- auto refProfilePath = create_primary_reference_profile_package_dir_path(pkgname);
- calculate_tree_size(refProfilePath, &stats.codeSize);
- ATRACE_END();
+ if (!uuid) {
+ ATRACE_BEGIN("profiles");
+ calculate_tree_size(
+ create_primary_current_profile_package_dir_path(userId, pkgname),
+ &stats.dataSize);
+ calculate_tree_size(
+ create_primary_reference_profile_package_dir_path(pkgname),
+ &stats.codeSize);
+ ATRACE_END();
+ }
ATRACE_BEGIN("external");
auto extPath = create_data_media_package_path(uuid_, userId, "data", pkgname);
@@ -1410,15 +1412,15 @@
ATRACE_END();
}
- ATRACE_BEGIN("dalvik");
- int32_t sharedGid = multiuser_get_shared_gid(userId, appId);
- if (sharedGid != -1) {
- calculate_tree_size(create_data_dalvik_cache_path(), &stats.codeSize,
- sharedGid, -1);
+ if (!uuid) {
+ ATRACE_BEGIN("dalvik");
+ int32_t sharedGid = multiuser_get_shared_gid(userId, appId);
+ if (sharedGid != -1) {
+ calculate_tree_size(create_data_dalvik_cache_path(), &stats.codeSize,
+ sharedGid, -1);
+ }
+ ATRACE_END();
}
- calculate_tree_size(create_primary_cur_profile_dir_path(userId), &stats.dataSize,
- multiuser_get_uid(userId, appId), -1);
- ATRACE_END();
}
std::vector<int64_t> ret;
@@ -1496,12 +1498,14 @@
collectManualStatsForUser(dePath, &stats, true);
ATRACE_END();
- ATRACE_BEGIN("profile");
- auto userProfilePath = create_primary_cur_profile_dir_path(userId);
- calculate_tree_size(userProfilePath, &stats.dataSize, -1, -1, true);
- auto refProfilePath = create_primary_ref_profile_dir_path();
- calculate_tree_size(refProfilePath, &stats.codeSize, -1, -1, true);
- ATRACE_END();
+ if (!uuid) {
+ ATRACE_BEGIN("profile");
+ auto userProfilePath = create_primary_cur_profile_dir_path(userId);
+ calculate_tree_size(userProfilePath, &stats.dataSize, -1, -1, true);
+ auto refProfilePath = create_primary_ref_profile_dir_path();
+ calculate_tree_size(refProfilePath, &stats.codeSize, -1, -1, true);
+ ATRACE_END();
+ }
ATRACE_BEGIN("external");
uid_t uid = multiuser_get_uid(userId, AID_MEDIA_RW);
@@ -1518,12 +1522,14 @@
}
ATRACE_END();
- ATRACE_BEGIN("dalvik");
- calculate_tree_size(create_data_dalvik_cache_path(), &stats.codeSize,
- -1, -1, true);
- calculate_tree_size(create_primary_cur_profile_dir_path(userId), &stats.dataSize,
- -1, -1, true);
- ATRACE_END();
+ if (!uuid) {
+ ATRACE_BEGIN("dalvik");
+ calculate_tree_size(create_data_dalvik_cache_path(), &stats.codeSize,
+ -1, -1, true);
+ calculate_tree_size(create_primary_cur_profile_dir_path(userId), &stats.dataSize,
+ -1, -1, true);
+ ATRACE_END();
+ }
ATRACE_BEGIN("quota");
for (auto appId : appIds) {
@@ -1554,12 +1560,14 @@
collectManualStatsForUser(dePath, &stats);
ATRACE_END();
- ATRACE_BEGIN("profile");
- auto userProfilePath = create_primary_cur_profile_dir_path(userId);
- calculate_tree_size(userProfilePath, &stats.dataSize);
- auto refProfilePath = create_primary_ref_profile_dir_path();
- calculate_tree_size(refProfilePath, &stats.codeSize);
- ATRACE_END();
+ if (!uuid) {
+ ATRACE_BEGIN("profile");
+ auto userProfilePath = create_primary_cur_profile_dir_path(userId);
+ calculate_tree_size(userProfilePath, &stats.dataSize);
+ auto refProfilePath = create_primary_ref_profile_dir_path();
+ calculate_tree_size(refProfilePath, &stats.codeSize);
+ ATRACE_END();
+ }
ATRACE_BEGIN("external");
auto dataMediaPath = create_data_media_path(uuid_, userId);
@@ -1570,10 +1578,12 @@
#endif
ATRACE_END();
- ATRACE_BEGIN("dalvik");
- calculate_tree_size(create_data_dalvik_cache_path(), &stats.codeSize);
- calculate_tree_size(create_primary_cur_profile_dir_path(userId), &stats.dataSize);
- ATRACE_END();
+ if (!uuid) {
+ ATRACE_BEGIN("dalvik");
+ calculate_tree_size(create_data_dalvik_cache_path(), &stats.codeSize);
+ calculate_tree_size(create_primary_cur_profile_dir_path(userId), &stats.dataSize);
+ ATRACE_END();
+ }
}
std::vector<int64_t> ret;
diff --git a/cmds/installd/dexopt.cpp b/cmds/installd/dexopt.cpp
index 63afdcd..facb189 100644
--- a/cmds/installd/dexopt.cpp
+++ b/cmds/installd/dexopt.cpp
@@ -67,14 +67,6 @@
return unique_fd(-1);
}
-static const char* parse_null(const char* arg) {
- if (strcmp(arg, "!") == 0) {
- return nullptr;
- } else {
- return arg;
- }
-}
-
static bool clear_profile(const std::string& profile) {
unique_fd ufd(open(profile.c_str(), O_WRONLY | O_NOFOLLOW | O_CLOEXEC));
if (ufd.get() < 0) {
@@ -1863,20 +1855,5 @@
return return_value_oat && return_value_art;
}
-int dexopt(const char* const params[DEXOPT_PARAM_COUNT]) {
- return dexopt(params[0], // apk_path
- atoi(params[1]), // uid
- params[2], // pkgname
- params[3], // instruction_set
- atoi(params[4]), // dexopt_needed
- params[5], // oat_dir
- atoi(params[6]), // dexopt_flags
- params[7], // compiler_filter
- parse_null(params[8]), // volume_uuid
- parse_null(params[9]), // shared_libraries
- parse_null(params[10])); // se_info
- static_assert(DEXOPT_PARAM_COUNT == 11U, "Unexpected dexopt param count");
-}
-
} // namespace installd
} // namespace android
diff --git a/cmds/installd/dexopt.h b/cmds/installd/dexopt.h
index 88144b7..355adb1 100644
--- a/cmds/installd/dexopt.h
+++ b/cmds/installd/dexopt.h
@@ -62,12 +62,6 @@
int dexopt_needed, const char* oat_dir, int dexopt_flags, const char* compiler_filter,
const char* volume_uuid, const char* shared_libraries, const char* se_info);
-static constexpr size_t DEXOPT_PARAM_COUNT = 11U;
-static_assert(DEXOPT_PARAM_COUNT == 11U, "Unexpected dexopt param size");
-
-// Helper for the above, converting arguments.
-int dexopt(const char* const params[DEXOPT_PARAM_COUNT]);
-
} // namespace installd
} // namespace android
diff --git a/cmds/installd/otapreopt.cpp b/cmds/installd/otapreopt.cpp
index e8e6b56..78eadf2 100644
--- a/cmds/installd/otapreopt.cpp
+++ b/cmds/installd/otapreopt.cpp
@@ -16,6 +16,7 @@
#include <algorithm>
#include <inttypes.h>
+#include <limits>
#include <random>
#include <regex>
#include <selinux/android.h>
@@ -40,6 +41,7 @@
#include "dexopt.h"
#include "file_parsing.h"
#include "globals.h"
+#include "installd_constants.h"
#include "installd_deps.h" // Need to fill in requirements of commands.
#include "otapreopt_utils.h"
#include "system_properties.h"
@@ -145,6 +147,20 @@
private:
+ struct Parameters {
+ const char *apk_path;
+ uid_t uid;
+ const char *pkgName;
+ const char *instruction_set;
+ int dexopt_needed;
+ const char* oat_dir;
+ int dexopt_flags;
+ const char* compiler_filter;
+ const char* volume_uuid;
+ const char* shared_libraries;
+ const char* se_info;
+ };
+
bool ReadSystemProperties() {
static constexpr const char* kPropertyFiles[] = {
"/default.prop", "/system/build.prop"
@@ -246,15 +262,23 @@
return true;
}
- bool ReadArguments(int argc ATTRIBUTE_UNUSED, char** argv) {
- // Expected command line:
- // target-slot dexopt {DEXOPT_PARAMETERS}
- // The DEXOPT_PARAMETERS are passed on to dexopt(), so we expect DEXOPT_PARAM_COUNT
- // of them. We store them in package_parameters_ (size checks are done when
- // parsing the special parameters and when copying into package_parameters_.
+ bool ParseUInt(const char* in, uint32_t* out) {
+ char* end;
+ long long int result = strtoll(in, &end, 0);
+ if (in == end || *end != '\0') {
+ return false;
+ }
+ if (result < std::numeric_limits<uint32_t>::min() ||
+ std::numeric_limits<uint32_t>::max() < result) {
+ return false;
+ }
+ *out = static_cast<uint32_t>(result);
+ return true;
+ }
- static_assert(DEXOPT_PARAM_COUNT == ARRAY_SIZE(package_parameters_),
- "Unexpected dexopt param count");
+ bool ReadArguments(int argc, char** argv) {
+ // Expected command line:
+ // target-slot [version] dexopt {DEXOPT_PARAMETERS}
const char* target_slot_arg = argv[1];
if (target_slot_arg == nullptr) {
@@ -268,28 +292,230 @@
return false;
}
- // Check for "dexopt" next.
+ // Check for version or "dexopt" next.
+ if (argv[2] == nullptr) {
+ LOG(ERROR) << "Missing parameters";
+ return false;
+ }
+
+ if (std::string("dexopt").compare(argv[2]) == 0) {
+ // This is version 1 (N) or pre-versioning version 2.
+ constexpr int kV2ArgCount = 1 // "otapreopt"
+ + 1 // slot
+ + 1 // "dexopt"
+ + 1 // apk_path
+ + 1 // uid
+ + 1 // pkg
+ + 1 // isa
+ + 1 // dexopt_needed
+ + 1 // oat_dir
+ + 1 // dexopt_flags
+ + 1 // filter
+ + 1 // volume
+ + 1 // libs
+ + 1 // seinfo
+ + 1; // null
+ if (argc == kV2ArgCount) {
+ return ReadArgumentsV2(argc, argv, false);
+ } else {
+ return ReadArgumentsV1(argc, argv);
+ }
+ }
+
+ uint32_t version;
+ if (!ParseUInt(argv[2], &version)) {
+ LOG(ERROR) << "Could not parse version: " << argv[2];
+ return false;
+ }
+
+ switch (version) {
+ case 2:
+ return ReadArgumentsV2(argc, argv, true);
+
+ default:
+ LOG(ERROR) << "Unsupported version " << version;
+ return false;
+ }
+ }
+
+ bool ReadArgumentsV2(int argc ATTRIBUTE_UNUSED, char** argv, bool versioned) {
+ size_t dexopt_index = versioned ? 3 : 2;
+
+ // Check for "dexopt".
+ if (argv[dexopt_index] == nullptr) {
+ LOG(ERROR) << "Missing parameters";
+ return false;
+ }
+ if (std::string("dexopt").compare(argv[dexopt_index]) != 0) {
+ LOG(ERROR) << "Expected \"dexopt\"";
+ return false;
+ }
+
+ size_t param_index = 0;
+ for (;; ++param_index) {
+ const char* param = argv[dexopt_index + 1 + param_index];
+ if (param == nullptr) {
+ break;
+ }
+
+ switch (param_index) {
+ case 0:
+ package_parameters_.apk_path = param;
+ break;
+
+ case 1:
+ package_parameters_.uid = atoi(param);
+ break;
+
+ case 2:
+ package_parameters_.pkgName = param;
+ break;
+
+ case 3:
+ package_parameters_.instruction_set = param;
+ break;
+
+ case 4:
+ package_parameters_.dexopt_needed = atoi(param);
+ break;
+
+ case 5:
+ package_parameters_.oat_dir = param;
+ break;
+
+ case 6:
+ package_parameters_.dexopt_flags = atoi(param);
+ break;
+
+ case 7:
+ package_parameters_.compiler_filter = param;
+ break;
+
+ case 8:
+ package_parameters_.volume_uuid = ParseNull(param);
+ break;
+
+ case 9:
+ package_parameters_.shared_libraries = ParseNull(param);
+ break;
+
+ case 10:
+ package_parameters_.se_info = ParseNull(param);
+ break;
+
+ default:
+ LOG(ERROR) << "Too many arguments, got " << param;
+ return false;
+ }
+ }
+
+ if (param_index != 11) {
+ LOG(ERROR) << "Not enough parameters";
+ return false;
+ }
+
+ return true;
+ }
+
+ static int ReplaceMask(int input, int old_mask, int new_mask) {
+ return (input & old_mask) != 0 ? new_mask : 0;
+ }
+
+ bool ReadArgumentsV1(int argc ATTRIBUTE_UNUSED, char** argv) {
+ // Check for "dexopt".
if (argv[2] == nullptr) {
LOG(ERROR) << "Missing parameters";
return false;
}
if (std::string("dexopt").compare(argv[2]) != 0) {
- LOG(ERROR) << "Second parameter not dexopt: " << argv[2];
+ LOG(ERROR) << "Expected \"dexopt\"";
return false;
}
- // Copy the rest into package_parameters_, but be careful about over- and underflow.
- size_t index = 0;
- while (index < DEXOPT_PARAM_COUNT &&
- argv[index + 3] != nullptr) {
- package_parameters_[index] = argv[index + 3];
- index++;
+ size_t param_index = 0;
+ for (;; ++param_index) {
+ const char* param = argv[3 + param_index];
+ if (param == nullptr) {
+ break;
+ }
+
+ switch (param_index) {
+ case 0:
+ package_parameters_.apk_path = param;
+ break;
+
+ case 1:
+ package_parameters_.uid = atoi(param);
+ break;
+
+ case 2:
+ package_parameters_.pkgName = param;
+ break;
+
+ case 3:
+ package_parameters_.instruction_set = param;
+ break;
+
+ case 4: {
+ // Version 1 had:
+ // DEXOPT_DEX2OAT_NEEDED = 1
+ // DEXOPT_PATCHOAT_NEEDED = 2
+ // DEXOPT_SELF_PATCHOAT_NEEDED = 3
+ // We will simply use DEX2OAT_FROM_SCRATCH.
+ package_parameters_.dexopt_needed = DEX2OAT_FROM_SCRATCH;
+ break;
+ }
+
+ case 5:
+ package_parameters_.oat_dir = param;
+ break;
+
+ case 6: {
+ // Version 1 had:
+ constexpr int OLD_DEXOPT_PUBLIC = 1 << 1;
+ constexpr int OLD_DEXOPT_SAFEMODE = 1 << 2;
+ constexpr int OLD_DEXOPT_DEBUGGABLE = 1 << 3;
+ constexpr int OLD_DEXOPT_BOOTCOMPLETE = 1 << 4;
+ constexpr int OLD_DEXOPT_PROFILE_GUIDED = 1 << 5;
+ constexpr int OLD_DEXOPT_OTA = 1 << 6;
+ int input = atoi(param);
+ package_parameters_.dexopt_flags =
+ ReplaceMask(input, OLD_DEXOPT_PUBLIC, DEXOPT_PUBLIC) |
+ ReplaceMask(input, OLD_DEXOPT_SAFEMODE, DEXOPT_SAFEMODE) |
+ ReplaceMask(input, OLD_DEXOPT_DEBUGGABLE, DEXOPT_DEBUGGABLE) |
+ ReplaceMask(input, OLD_DEXOPT_BOOTCOMPLETE, DEXOPT_BOOTCOMPLETE) |
+ ReplaceMask(input, OLD_DEXOPT_PROFILE_GUIDED, DEXOPT_PROFILE_GUIDED) |
+ ReplaceMask(input, OLD_DEXOPT_OTA, 0);
+ break;
+ }
+
+ case 7:
+ package_parameters_.compiler_filter = param;
+ break;
+
+ case 8:
+ package_parameters_.volume_uuid = ParseNull(param);
+ break;
+
+ case 9:
+ package_parameters_.shared_libraries = ParseNull(param);
+ break;
+
+ default:
+ LOG(ERROR) << "Too many arguments, got " << param;
+ return false;
+ }
}
- if (index != ARRAY_SIZE(package_parameters_) || argv[index + 3] != nullptr) {
- LOG(ERROR) << "Wrong number of parameters";
+
+ if (param_index != 10) {
+ LOG(ERROR) << "Not enough parameters";
return false;
}
+ // Set se_info to null. It is only relevant for secondary dex files, which we won't
+ // receive from a v1 A side.
+ package_parameters_.se_info = nullptr;
+
return true;
}
@@ -306,11 +532,11 @@
// Ensure that we have the right boot image. The first time any app is
// compiled, we'll try to generate it.
bool PrepareBootImage(bool force) const {
- if (package_parameters_[kISAIndex] == nullptr) {
+ if (package_parameters_.instruction_set == nullptr) {
LOG(ERROR) << "Instruction set missing.";
return false;
}
- const char* isa = package_parameters_[kISAIndex];
+ const char* isa = package_parameters_.instruction_set;
// Check whether the file exists where expected.
std::string dalvik_cache = GetOTADataDirectory() + "/" + DALVIK_CACHE;
@@ -536,14 +762,12 @@
// (This is ugly as it's the only thing where we need to understand the contents
// of package_parameters_, but it beats postponing the decision or using the call-
// backs to do weird things.)
- constexpr size_t kApkPathIndex = 0;
- CHECK_GT(DEXOPT_PARAM_COUNT, kApkPathIndex);
- CHECK(package_parameters_[kApkPathIndex] != nullptr);
- if (StartsWith(package_parameters_[kApkPathIndex], android_root_.c_str())) {
- const char* last_slash = strrchr(package_parameters_[kApkPathIndex], '/');
+ const char* apk_path = package_parameters_.apk_path;
+ CHECK(apk_path != nullptr);
+ if (StartsWith(apk_path, android_root_.c_str())) {
+ const char* last_slash = strrchr(apk_path, '/');
if (last_slash != nullptr) {
- std::string path(package_parameters_[kApkPathIndex],
- last_slash - package_parameters_[kApkPathIndex] + 1);
+ std::string path(apk_path, last_slash - apk_path + 1);
CHECK(EndsWith(path, "/"));
path = path + "oat";
if (access(path.c_str(), F_OK) == 0) {
@@ -557,9 +781,8 @@
// partition will not be available and fail to build. This is problematic, as
// this tool will wipe the OTA artifact cache and try again (for robustness after
// a failed OTA with remaining cache artifacts).
- if (access(package_parameters_[kApkPathIndex], F_OK) != 0) {
- LOG(WARNING) << "Skipping preopt of non-existing package "
- << package_parameters_[kApkPathIndex];
+ if (access(apk_path, F_OK) != 0) {
+ LOG(WARNING) << "Skipping preopt of non-existing package " << apk_path;
return true;
}
@@ -571,7 +794,17 @@
return 0;
}
- int dexopt_result = dexopt(package_parameters_);
+ int dexopt_result = dexopt(package_parameters_.apk_path,
+ package_parameters_.uid,
+ package_parameters_.pkgName,
+ package_parameters_.instruction_set,
+ package_parameters_.dexopt_needed,
+ package_parameters_.oat_dir,
+ package_parameters_.dexopt_flags,
+ package_parameters_.compiler_filter,
+ package_parameters_.volume_uuid,
+ package_parameters_.shared_libraries,
+ package_parameters_.se_info);
if (dexopt_result == 0) {
return 0;
}
@@ -590,7 +823,17 @@
}
LOG(WARNING) << "Original dexopt failed, re-trying after boot image was regenerated.";
- return dexopt(package_parameters_);
+ return dexopt(package_parameters_.apk_path,
+ package_parameters_.uid,
+ package_parameters_.pkgName,
+ package_parameters_.instruction_set,
+ package_parameters_.dexopt_needed,
+ package_parameters_.oat_dir,
+ package_parameters_.dexopt_flags,
+ package_parameters_.compiler_filter,
+ package_parameters_.volume_uuid,
+ package_parameters_.shared_libraries,
+ package_parameters_.se_info);
}
////////////////////////////////////
@@ -720,7 +963,7 @@
std::string boot_classpath_;
std::string asec_mountpoint_;
- const char* package_parameters_[DEXOPT_PARAM_COUNT];
+ Parameters package_parameters_;
// Store environment values we need to set.
std::vector<std::string> environ_;
diff --git a/cmds/installd/otapreopt_chroot.cpp b/cmds/installd/otapreopt_chroot.cpp
index cec8f68..2030997 100644
--- a/cmds/installd/otapreopt_chroot.cpp
+++ b/cmds/installd/otapreopt_chroot.cpp
@@ -27,7 +27,6 @@
#include "installd_constants.h"
#include "otapreopt_utils.h"
-#include "dexopt.h"
#ifndef LOG_TAG
#define LOG_TAG "otapreopt"
@@ -137,44 +136,18 @@
// Now go on and run otapreopt.
- // Incoming: cmd + status-fd + target-slot + "dexopt" + dexopt-params + null
- // Outgoing: cmd + target-slot + "dexopt" + dexopt-params + null
- constexpr size_t kInArguments = 1 // Binary name.
- + 1 // status file descriptor.
- + 1 // target-slot.
- + 1 // "dexopt."
- + DEXOPT_PARAM_COUNT // dexopt parameters.
- + 1; // null termination.
- constexpr size_t kOutArguments = 1 // Binary name.
- + 1 // target-slot.
- + 1 // "dexopt."
- + DEXOPT_PARAM_COUNT // dexopt parameters.
- + 1; // null termination.
- const char* argv[kOutArguments];
- if (static_cast<size_t>(argc) != kInArguments - 1 /* null termination */) {
- LOG(ERROR) << "Unexpected argument size "
- << argc
- << " vs "
- << (kInArguments - 1);
- for (size_t i = 0; i < static_cast<size_t>(argc); ++i) {
- if (arg[i] == nullptr) {
- LOG(ERROR) << "(null)";
- } else {
- LOG(ERROR) << "\"" << arg[i] << "\"";
- }
- }
- exit(206);
- }
+ // Incoming: cmd + status-fd + target-slot + cmd... + null | Incoming | = argc + 1
+ // Outgoing: cmd + target-slot + cmd... + null | Outgoing | = argc
+ const char** argv = new const char*[argc];
+
argv[0] = "/system/bin/otapreopt";
// The first parameter is the status file descriptor, skip.
-
- for (size_t i = 1; i <= kOutArguments - 2 /* cmd + null */; ++i) {
- argv[i] = arg[i + 1];
+ for (size_t i = 2; i <= static_cast<size_t>(argc); ++i) {
+ argv[i - 1] = arg[i];
}
- argv[kOutArguments - 1] = nullptr;
- execv(argv[0], (char * const *)argv);
+ execv(argv[0], static_cast<char * const *>(const_cast<char**>(argv)));
PLOG(ERROR) << "execv(OTAPREOPT) failed.";
exit(99);
}
diff --git a/cmds/lshal/Lshal.cpp b/cmds/lshal/Lshal.cpp
index 4c57361..33bc43c 100644
--- a/cmds/lshal/Lshal.cpp
+++ b/cmds/lshal/Lshal.cpp
@@ -296,7 +296,7 @@
continue;
}
- vintf::ManifestHal *hal = manifest.getHal(fqName.package());
+ vintf::ManifestHal *hal = manifest.getAnyHal(fqName.package());
if (hal == nullptr) {
if (!manifest.add(vintf::ManifestHal{
.format = vintf::HalFormat::HIDL,
@@ -306,7 +306,7 @@
mErr << "Warning: cannot add hal '" << fqInstanceName << "'" << std::endl;
continue;
}
- hal = manifest.getHal(fqName.package());
+ hal = manifest.getAnyHal(fqName.package());
}
if (hal == nullptr) {
mErr << "Warning: cannot get hal '" << fqInstanceName
diff --git a/data/etc/android.software.preview_sdk.xml b/data/etc/android.software.preview_sdk.xml
new file mode 100644
index 0000000..928b4b3
--- /dev/null
+++ b/data/etc/android.software.preview_sdk.xml
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2017 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.
+-->
+
+<permissions>
+ <!-- The device is running a preview (i.e. unofficial) API version. -->
+ <feature name="android.software.preview_sdk" />
+</permissions>
diff --git a/include/binder b/include/binder
new file mode 120000
index 0000000..35a022a
--- /dev/null
+++ b/include/binder
@@ -0,0 +1 @@
+../libs/binder/include/binder/
\ No newline at end of file
diff --git a/include/gui/BufferQueue.h b/include/gui/BufferQueue.h
index c95c535..bd62d85 100644
--- a/include/gui/BufferQueue.h
+++ b/include/gui/BufferQueue.h
@@ -23,10 +23,6 @@
#include <gui/IGraphicBufferProducer.h>
#include <gui/IConsumerListener.h>
-// These are only required to keep other parts of the framework with incomplete
-// dependencies building successfully
-#include <gui/IGraphicBufferAlloc.h>
-
namespace android {
class BufferQueue {
@@ -81,11 +77,9 @@
// needed gralloc buffers.
static void createBufferQueue(sp<IGraphicBufferProducer>* outProducer,
sp<IGraphicBufferConsumer>* outConsumer,
- const sp<IGraphicBufferAlloc>& allocator = NULL,
bool consumerIsSurfaceFlinger = false);
-private:
- BufferQueue(); // Create through createBufferQueue
+ BufferQueue() = delete; // Create through createBufferQueue
};
// ----------------------------------------------------------------------------
diff --git a/include/gui/BufferQueueCore.h b/include/gui/BufferQueueCore.h
index 9146340..cfe716f 100644
--- a/include/gui/BufferQueueCore.h
+++ b/include/gui/BufferQueueCore.h
@@ -51,7 +51,6 @@
namespace android {
class IConsumerListener;
-class IGraphicBufferAlloc;
class IProducerListener;
class BufferQueueCore : public virtual RefBase {
@@ -79,9 +78,8 @@
typedef Vector<BufferItem> Fifo;
// BufferQueueCore manages a pool of gralloc memory slots to be used by
- // producers and consumers. allocator is used to allocate all the needed
- // gralloc buffers.
- BufferQueueCore(const sp<IGraphicBufferAlloc>& allocator = NULL);
+ // producers and consumers.
+ BufferQueueCore();
virtual ~BufferQueueCore();
private:
@@ -143,10 +141,6 @@
void validateConsistencyLocked() const;
#endif
- // mAllocator is the connection to SurfaceFlinger that is used to allocate
- // new GraphicBuffer objects.
- sp<IGraphicBufferAlloc> mAllocator;
-
// mMutex is the mutex used to prevent concurrent access to the member
// variables of BufferQueueCore objects. It must be locked whenever any
// member variable is accessed.
diff --git a/include/gui/GraphicBufferAlloc.h b/include/gui/GraphicBufferAlloc.h
deleted file mode 100644
index 54c9829..0000000
--- a/include/gui/GraphicBufferAlloc.h
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * Copyright (C) 2012 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.
- */
-
-#ifndef ANDROID_GUI_GRAPHIC_BUFFER_ALLOC_H
-#define ANDROID_GUI_GRAPHIC_BUFFER_ALLOC_H
-
-#include <stdint.h>
-#include <sys/types.h>
-
-#include <gui/IGraphicBufferAlloc.h>
-#include <ui/PixelFormat.h>
-#include <utils/Errors.h>
-
-namespace android {
-
-class GraphicBuffer;
-
-/*
- * Concrete implementation of the IGraphicBufferAlloc interface.
- *
- * This can create GraphicBuffer instance across processes. This is mainly used
- * by surfaceflinger.
- */
-
-class GraphicBufferAlloc : public BnGraphicBufferAlloc {
-public:
- GraphicBufferAlloc();
- virtual ~GraphicBufferAlloc();
- virtual sp<GraphicBuffer> createGraphicBuffer(uint32_t width,
- uint32_t height, PixelFormat format, uint32_t layerCount,
- uint64_t producerUsage, uint64_t consumerUsage,
- std::string requestorName, status_t* error) override;
-};
-
-
-} // namespace android
-
-#endif // ANDROID_GUI_GRAPHIC_BUFFER_ALLOC_H
diff --git a/include/gui/IGraphicBufferAlloc.h b/include/gui/IGraphicBufferAlloc.h
deleted file mode 100644
index 1e578cc..0000000
--- a/include/gui/IGraphicBufferAlloc.h
+++ /dev/null
@@ -1,82 +0,0 @@
-/*
- * Copyright (C) 2011 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.
- */
-
-#ifndef ANDROID_GUI_IGRAPHIC_BUFFER_ALLOC_H
-#define ANDROID_GUI_IGRAPHIC_BUFFER_ALLOC_H
-
-#include <stdint.h>
-#include <sys/types.h>
-
-#include <binder/IInterface.h>
-#include <ui/GraphicBuffer.h>
-#include <ui/PixelFormat.h>
-#include <utils/RefBase.h>
-
-#include <string>
-
-namespace android {
-// ----------------------------------------------------------------------------
-
-class IGraphicBufferAlloc : public IInterface
-{
-public:
- DECLARE_META_INTERFACE(GraphicBufferAlloc)
-
- /* Create a new GraphicBuffer for the client to use.
- */
- virtual sp<GraphicBuffer> createGraphicBuffer(uint32_t w, uint32_t h,
- PixelFormat format, uint32_t layerCount, uint64_t producerUsage,
- uint64_t consumerUsage, std::string requestorName,
- status_t* error) = 0;
-
- sp<GraphicBuffer> createGraphicBuffer(uint32_t w, uint32_t h,
- PixelFormat format, uint32_t layerCount, uint32_t usage,
- status_t* error) {
- return createGraphicBuffer(w, h, format, layerCount, usage,
- usage, "<Unknown>", error);
- }
-
- sp<GraphicBuffer> createGraphicBuffer(uint32_t w, uint32_t h,
- PixelFormat format, uint32_t layerCount, uint32_t usage,
- std::string requestorName, status_t* error) {
- return createGraphicBuffer(w, h, format, layerCount, usage,
- usage, requestorName, error);
- }
-
- sp<GraphicBuffer> createGraphicBuffer(uint32_t w, uint32_t h,
- PixelFormat format, uint32_t layerCount, uint64_t producerUsage,
- uint64_t consumerUsage, status_t* error) {
- return createGraphicBuffer(w, h, format, layerCount, producerUsage,
- consumerUsage, "<Unknown>", error);
- }
-};
-
-// ----------------------------------------------------------------------------
-
-class BnGraphicBufferAlloc : public BnInterface<IGraphicBufferAlloc>
-{
-public:
- virtual status_t onTransact(uint32_t code,
- const Parcel& data,
- Parcel* reply,
- uint32_t flags = 0);
-};
-
-// ----------------------------------------------------------------------------
-
-}; // namespace android
-
-#endif // ANDROID_GUI_IGRAPHIC_BUFFER_ALLOC_H
diff --git a/include/gui/ISurfaceComposer.h b/include/gui/ISurfaceComposer.h
index 9870ba0..1112973 100644
--- a/include/gui/ISurfaceComposer.h
+++ b/include/gui/ISurfaceComposer.h
@@ -41,7 +41,6 @@
struct DisplayStatInfo;
class HdrCapabilities;
class IDisplayEventConnection;
-class IGraphicBufferAlloc;
class IGraphicBufferProducer;
class ISurfaceComposerClient;
class Rect;
@@ -89,10 +88,6 @@
virtual sp<ISurfaceComposerClient> createScopedConnection(
const sp<IGraphicBufferProducer>& parent) = 0;
- /* create a graphic buffer allocator
- */
- virtual sp<IGraphicBufferAlloc> createGraphicBufferAlloc() = 0;
-
/* return an IDisplayEventConnection */
virtual sp<IDisplayEventConnection> createDisplayEventConnection() = 0;
@@ -205,7 +200,7 @@
// Java by ActivityManagerService.
BOOT_FINISHED = IBinder::FIRST_CALL_TRANSACTION,
CREATE_CONNECTION,
- CREATE_GRAPHIC_BUFFER_ALLOC,
+ UNUSED, // formerly CREATE_GRAPHIC_BUFFER_ALLOC
CREATE_DISPLAY_EVENT_CONNECTION,
CREATE_DISPLAY,
DESTROY_DISPLAY,
diff --git a/include/private/binder b/include/private/binder
new file mode 120000
index 0000000..09e9076
--- /dev/null
+++ b/include/private/binder
@@ -0,0 +1 @@
+../../libs/binder/include/private/binder
\ No newline at end of file
diff --git a/libs/binder/Android.bp b/libs/binder/Android.bp
index b225128..204fdb5 100644
--- a/libs/binder/Android.bp
+++ b/libs/binder/Android.bp
@@ -12,9 +12,17 @@
// See the License for the specific language governing permissions and
// limitations under the License.
+cc_library_headers {
+ name: "libbinder_headers",
+ export_include_dirs: ["include"],
+}
+
cc_library {
name: "libbinder",
+ // for vndbinder
+ vendor_available: true,
+
srcs: [
"AppOpsManager.cpp",
"Binder.cpp",
diff --git a/libs/binder/ProcessState.cpp b/libs/binder/ProcessState.cpp
index 9ccf07c..add5e74 100644
--- a/libs/binder/ProcessState.cpp
+++ b/libs/binder/ProcessState.cpp
@@ -79,6 +79,11 @@
{
Mutex::Autolock _l(gProcessMutex);
if (gProcess != NULL) {
+ // Allow for initWithDriver to be called repeatedly with the same
+ // driver.
+ if (!strcmp(gProcess->getDriverName().c_str(), driver)) {
+ return gProcess;
+ }
LOG_ALWAYS_FATAL("ProcessState was already initialized.");
}
gProcess = new ProcessState(driver);
diff --git a/include/binder/AppOpsManager.h b/libs/binder/include/binder/AppOpsManager.h
similarity index 100%
rename from include/binder/AppOpsManager.h
rename to libs/binder/include/binder/AppOpsManager.h
diff --git a/include/binder/Binder.h b/libs/binder/include/binder/Binder.h
similarity index 100%
rename from include/binder/Binder.h
rename to libs/binder/include/binder/Binder.h
diff --git a/include/binder/BinderService.h b/libs/binder/include/binder/BinderService.h
similarity index 100%
rename from include/binder/BinderService.h
rename to libs/binder/include/binder/BinderService.h
diff --git a/include/binder/BpBinder.h b/libs/binder/include/binder/BpBinder.h
similarity index 100%
rename from include/binder/BpBinder.h
rename to libs/binder/include/binder/BpBinder.h
diff --git a/include/binder/BufferedTextOutput.h b/libs/binder/include/binder/BufferedTextOutput.h
similarity index 100%
rename from include/binder/BufferedTextOutput.h
rename to libs/binder/include/binder/BufferedTextOutput.h
diff --git a/include/binder/Debug.h b/libs/binder/include/binder/Debug.h
similarity index 100%
rename from include/binder/Debug.h
rename to libs/binder/include/binder/Debug.h
diff --git a/include/binder/IActivityManager.h b/libs/binder/include/binder/IActivityManager.h
similarity index 100%
rename from include/binder/IActivityManager.h
rename to libs/binder/include/binder/IActivityManager.h
diff --git a/include/binder/IAppOpsCallback.h b/libs/binder/include/binder/IAppOpsCallback.h
similarity index 100%
rename from include/binder/IAppOpsCallback.h
rename to libs/binder/include/binder/IAppOpsCallback.h
diff --git a/include/binder/IAppOpsService.h b/libs/binder/include/binder/IAppOpsService.h
similarity index 100%
rename from include/binder/IAppOpsService.h
rename to libs/binder/include/binder/IAppOpsService.h
diff --git a/include/binder/IBatteryStats.h b/libs/binder/include/binder/IBatteryStats.h
similarity index 100%
rename from include/binder/IBatteryStats.h
rename to libs/binder/include/binder/IBatteryStats.h
diff --git a/include/binder/IBinder.h b/libs/binder/include/binder/IBinder.h
similarity index 100%
rename from include/binder/IBinder.h
rename to libs/binder/include/binder/IBinder.h
diff --git a/include/binder/IInterface.h b/libs/binder/include/binder/IInterface.h
similarity index 100%
rename from include/binder/IInterface.h
rename to libs/binder/include/binder/IInterface.h
diff --git a/include/binder/IMediaResourceMonitor.h b/libs/binder/include/binder/IMediaResourceMonitor.h
similarity index 100%
rename from include/binder/IMediaResourceMonitor.h
rename to libs/binder/include/binder/IMediaResourceMonitor.h
diff --git a/include/binder/IMemory.h b/libs/binder/include/binder/IMemory.h
similarity index 100%
rename from include/binder/IMemory.h
rename to libs/binder/include/binder/IMemory.h
diff --git a/include/binder/IPCThreadState.h b/libs/binder/include/binder/IPCThreadState.h
similarity index 100%
rename from include/binder/IPCThreadState.h
rename to libs/binder/include/binder/IPCThreadState.h
diff --git a/include/binder/IPermissionController.h b/libs/binder/include/binder/IPermissionController.h
similarity index 100%
rename from include/binder/IPermissionController.h
rename to libs/binder/include/binder/IPermissionController.h
diff --git a/include/binder/IProcessInfoService.h b/libs/binder/include/binder/IProcessInfoService.h
similarity index 100%
rename from include/binder/IProcessInfoService.h
rename to libs/binder/include/binder/IProcessInfoService.h
diff --git a/include/binder/IResultReceiver.h b/libs/binder/include/binder/IResultReceiver.h
similarity index 100%
rename from include/binder/IResultReceiver.h
rename to libs/binder/include/binder/IResultReceiver.h
diff --git a/include/binder/IServiceManager.h b/libs/binder/include/binder/IServiceManager.h
similarity index 100%
rename from include/binder/IServiceManager.h
rename to libs/binder/include/binder/IServiceManager.h
diff --git a/include/binder/IShellCallback.h b/libs/binder/include/binder/IShellCallback.h
similarity index 100%
rename from include/binder/IShellCallback.h
rename to libs/binder/include/binder/IShellCallback.h
diff --git a/include/binder/IpPrefix.h b/libs/binder/include/binder/IpPrefix.h
similarity index 100%
rename from include/binder/IpPrefix.h
rename to libs/binder/include/binder/IpPrefix.h
diff --git a/include/binder/Map.h b/libs/binder/include/binder/Map.h
similarity index 100%
rename from include/binder/Map.h
rename to libs/binder/include/binder/Map.h
diff --git a/include/binder/MemoryBase.h b/libs/binder/include/binder/MemoryBase.h
similarity index 100%
rename from include/binder/MemoryBase.h
rename to libs/binder/include/binder/MemoryBase.h
diff --git a/include/binder/MemoryDealer.h b/libs/binder/include/binder/MemoryDealer.h
similarity index 100%
rename from include/binder/MemoryDealer.h
rename to libs/binder/include/binder/MemoryDealer.h
diff --git a/include/binder/MemoryHeapBase.h b/libs/binder/include/binder/MemoryHeapBase.h
similarity index 100%
rename from include/binder/MemoryHeapBase.h
rename to libs/binder/include/binder/MemoryHeapBase.h
diff --git a/include/binder/Parcel.h b/libs/binder/include/binder/Parcel.h
similarity index 100%
rename from include/binder/Parcel.h
rename to libs/binder/include/binder/Parcel.h
diff --git a/include/binder/Parcelable.h b/libs/binder/include/binder/Parcelable.h
similarity index 100%
rename from include/binder/Parcelable.h
rename to libs/binder/include/binder/Parcelable.h
diff --git a/include/binder/PermissionCache.h b/libs/binder/include/binder/PermissionCache.h
similarity index 100%
rename from include/binder/PermissionCache.h
rename to libs/binder/include/binder/PermissionCache.h
diff --git a/include/binder/PersistableBundle.h b/libs/binder/include/binder/PersistableBundle.h
similarity index 100%
rename from include/binder/PersistableBundle.h
rename to libs/binder/include/binder/PersistableBundle.h
diff --git a/include/binder/ProcessInfoService.h b/libs/binder/include/binder/ProcessInfoService.h
similarity index 100%
rename from include/binder/ProcessInfoService.h
rename to libs/binder/include/binder/ProcessInfoService.h
diff --git a/include/binder/ProcessState.h b/libs/binder/include/binder/ProcessState.h
similarity index 100%
rename from include/binder/ProcessState.h
rename to libs/binder/include/binder/ProcessState.h
diff --git a/include/binder/Status.h b/libs/binder/include/binder/Status.h
similarity index 100%
rename from include/binder/Status.h
rename to libs/binder/include/binder/Status.h
diff --git a/include/binder/TextOutput.h b/libs/binder/include/binder/TextOutput.h
similarity index 100%
rename from include/binder/TextOutput.h
rename to libs/binder/include/binder/TextOutput.h
diff --git a/include/binder/Value.h b/libs/binder/include/binder/Value.h
similarity index 100%
rename from include/binder/Value.h
rename to libs/binder/include/binder/Value.h
diff --git a/include/private/binder/ParcelValTypes.h b/libs/binder/include/private/binder/ParcelValTypes.h
similarity index 100%
rename from include/private/binder/ParcelValTypes.h
rename to libs/binder/include/private/binder/ParcelValTypes.h
diff --git a/include/private/binder/Static.h b/libs/binder/include/private/binder/Static.h
similarity index 100%
rename from include/private/binder/Static.h
rename to libs/binder/include/private/binder/Static.h
diff --git a/include/private/binder/binder_module.h b/libs/binder/include/private/binder/binder_module.h
similarity index 100%
rename from include/private/binder/binder_module.h
rename to libs/binder/include/private/binder/binder_module.h
diff --git a/libs/binder/tests/schd-dbg.cpp b/libs/binder/tests/schd-dbg.cpp
index fe9e05a..13f03b1 100644
--- a/libs/binder/tests/schd-dbg.cpp
+++ b/libs/binder/tests/schd-dbg.cpp
@@ -40,7 +40,7 @@
// GOOD_SYNC_MIN is considered as good
#define GOOD_SYNC_MIN (0.6)
-#define DUMP_PRICISION 3
+#define DUMP_PRESICION 2
string trace_path = "/sys/kernel/debug/tracing";
@@ -246,10 +246,11 @@
double worst = (double)m_worst / 1.0E6;
double average = (double)m_total_time / m_transactions / 1.0E6;
// FIXME: libjson?
- cout << std::setprecision(DUMP_PRICISION) << "{ \"avg\":" << setw(5) << left
- << average << ", \"wst\":" << setw(5) << left << worst
- << ", \"bst\":" << setw(5) << left << best << ", \"miss\":" << setw(5)
- << left << m_miss << ", \"meetR\":" << setw(3) << left
+ int W = DUMP_PRESICION + 2;
+ cout << setprecision(DUMP_PRESICION) << "{ \"avg\":" << setw(W) << left
+ << average << ",\"wst\":" << setw(W) << left << worst
+ << ",\"bst\":" << setw(W) << left << best << ",\"miss\":" << left
+ << m_miss << ",\"meetR\":" << left << setprecision(DUMP_PRESICION + 3)
<< (1.0 - (double)m_miss / m_transactions) << "}";
}
};
@@ -272,8 +273,15 @@
}
}
+typedef struct {
+ void* result;
+ int target;
+} thread_priv_t;
+
static void* thread_start(void* p) {
- Results* results_fifo = (Results*)p;
+ thread_priv_t* priv = (thread_priv_t*)p;
+ int target = priv->target;
+ Results* results_fifo = (Results*)priv->result;
Parcel data, reply;
Tick sta, end;
@@ -281,7 +289,7 @@
thread_dump("fifo-caller");
sta = tickNow();
- status_t ret = workers[0]->transact(BINDER_NOP, data, &reply);
+ status_t ret = workers[target]->transact(BINDER_NOP, data, &reply);
end = tickNow();
results_fifo->add_time(tickNano(sta, end));
@@ -291,16 +299,19 @@
}
// create a fifo thread to transact and wait it to finished
-static void thread_transaction(Results* results_fifo) {
+static void thread_transaction(int target, Results* results_fifo) {
+ thread_priv_t thread_priv;
void* dummy;
pthread_t thread;
pthread_attr_t attr;
struct sched_param param;
+ thread_priv.target = target;
+ thread_priv.result = results_fifo;
ASSERT(!pthread_attr_init(&attr));
ASSERT(!pthread_attr_setschedpolicy(&attr, SCHED_FIFO));
param.sched_priority = sched_get_priority_max(SCHED_FIFO);
ASSERT(!pthread_attr_setschedparam(&attr, ¶m));
- ASSERT(!pthread_create(&thread, &attr, &thread_start, results_fifo));
+ ASSERT(!pthread_create(&thread, &attr, &thread_start, &thread_priv));
ASSERT(!pthread_join(thread, &dummy));
}
@@ -316,7 +327,9 @@
sp<IServiceManager> serviceMgr = defaultServiceManager();
sp<BinderWorkerService> service = new BinderWorkerService;
serviceMgr->addService(generateServiceName(num), service);
+ // init done
p.signal();
+ // wait for kick-off
p.wait();
// If client/server pairs, then half the workers are
@@ -338,7 +351,7 @@
int target = num % server_count;
// 1. transaction by fifo thread
- thread_transaction(&results_fifo);
+ thread_transaction(target, &results_fifo);
parcel_fill(data, payload_size, thread_pri(), sched_getcpu());
thread_dump("other-caller");
@@ -356,6 +369,7 @@
p.wait();
p.send(&dummy);
+ // wait for kill
p.wait();
// Client for each pair dump here
if (is_client(num)) {
@@ -367,10 +381,10 @@
<< "\"S\":" << (no_trans - no_sync) << ",\"I\":" << no_trans << ","
<< "\"R\":" << sync_ratio << "," << endl;
- cout << " \"other_ms\":";
+ cout << " \"other_ms\":";
results_other.dump();
cout << "," << endl;
- cout << " \"fifo_ms\": ";
+ cout << " \"fifo_ms\": ";
results_fifo.dump();
cout << endl;
cout << "}," << endl;
@@ -463,12 +477,17 @@
for (int i = 0; i < no_process; i++) {
pipes.push_back(make_process(i, iterations, no_process, payload_size));
}
+ // wait for init done
wait_all(pipes);
+ // kick-off iterations
signal_all(pipes);
+ // wait for completion
wait_all(pipes);
+ // start to send result
signal_all(pipes);
for (int i = 0; i < no_process; i++) {
int status;
+ // kill
pipes[i].signal();
wait(&status);
// the exit status is number of transactions without priority inheritance
diff --git a/libs/gui/Android.bp b/libs/gui/Android.bp
index 90ab286..5eafb2c 100644
--- a/libs/gui/Android.bp
+++ b/libs/gui/Android.bp
@@ -79,11 +79,9 @@
"DisplayEventReceiver.cpp",
"FrameTimestamps.cpp",
"GLConsumer.cpp",
- "GraphicBufferAlloc.cpp",
"GuiConfig.cpp",
"IDisplayEventConnection.cpp",
"IConsumerListener.cpp",
- "IGraphicBufferAlloc.cpp",
"IGraphicBufferConsumer.cpp",
"IGraphicBufferProducer.cpp",
"IProducerListener.cpp",
diff --git a/libs/gui/BufferQueue.cpp b/libs/gui/BufferQueue.cpp
index 13692eb..4151212 100644
--- a/libs/gui/BufferQueue.cpp
+++ b/libs/gui/BufferQueue.cpp
@@ -79,14 +79,13 @@
void BufferQueue::createBufferQueue(sp<IGraphicBufferProducer>* outProducer,
sp<IGraphicBufferConsumer>* outConsumer,
- const sp<IGraphicBufferAlloc>& allocator,
bool consumerIsSurfaceFlinger) {
LOG_ALWAYS_FATAL_IF(outProducer == NULL,
"BufferQueue: outProducer must not be NULL");
LOG_ALWAYS_FATAL_IF(outConsumer == NULL,
"BufferQueue: outConsumer must not be NULL");
- sp<BufferQueueCore> core(new BufferQueueCore(allocator));
+ sp<BufferQueueCore> core(new BufferQueueCore());
LOG_ALWAYS_FATAL_IF(core == NULL,
"BufferQueue: failed to create BufferQueueCore");
diff --git a/libs/gui/BufferQueueCore.cpp b/libs/gui/BufferQueueCore.cpp
index 566af90..cd94253 100644
--- a/libs/gui/BufferQueueCore.cpp
+++ b/libs/gui/BufferQueueCore.cpp
@@ -33,9 +33,7 @@
#include <gui/BufferItem.h>
#include <gui/BufferQueueCore.h>
-#include <gui/GraphicBufferAlloc.h>
#include <gui/IConsumerListener.h>
-#include <gui/IGraphicBufferAlloc.h>
#include <gui/IProducerListener.h>
#include <gui/ISurfaceComposer.h>
#include <private/gui/ComposerService.h>
@@ -54,8 +52,7 @@
return id | counter++;
}
-BufferQueueCore::BufferQueueCore(const sp<IGraphicBufferAlloc>& allocator) :
- mAllocator(allocator),
+BufferQueueCore::BufferQueueCore() :
mMutex(),
mIsAbandoned(false),
mConsumerControlledByApp(false),
@@ -97,30 +94,6 @@
mLastQueuedSlot(INVALID_BUFFER_SLOT),
mUniqueId(getUniqueId())
{
- if (allocator == NULL) {
-
-#ifdef HAVE_NO_SURFACE_FLINGER
- // Without a SurfaceFlinger, allocate in-process. This only makes
- // sense in systems with static SELinux configurations and no
- // applications (since applications need dynamic SELinux policy).
- mAllocator = new GraphicBufferAlloc();
-#else
- // Run time check for headless, where we also allocate in-process.
- char value[PROPERTY_VALUE_MAX];
- property_get("config.headless", value, "0");
- if (atoi(value) == 1) {
- mAllocator = new GraphicBufferAlloc();
- } else {
- sp<ISurfaceComposer> composer(ComposerService::getComposerService());
- mAllocator = composer->createGraphicBufferAlloc();
- }
-#endif // HAVE_NO_SURFACE_FLINGER
-
- if (mAllocator == NULL) {
- BQ_LOGE("createGraphicBufferAlloc failed");
- }
- }
-
int numStartingBuffers = getMaxBufferCountLocked();
for (int s = 0; s < numStartingBuffers; s++) {
mFreeSlots.insert(s);
diff --git a/libs/gui/BufferQueueProducer.cpp b/libs/gui/BufferQueueProducer.cpp
index aef231a..a540ab9 100644
--- a/libs/gui/BufferQueueProducer.cpp
+++ b/libs/gui/BufferQueueProducer.cpp
@@ -34,7 +34,6 @@
#include <gui/BufferQueueProducer.h>
#include <gui/GLConsumer.h>
#include <gui/IConsumerListener.h>
-#include <gui/IGraphicBufferAlloc.h>
#include <gui/IProducerListener.h>
#include <utils/Log.h>
@@ -454,8 +453,7 @@
mSlots[found].mBufferState.dequeue();
if ((buffer == NULL) ||
- buffer->needsReallocation(width, height, format, BQ_LAYER_COUNT,
- usage))
+ buffer->needsReallocation(width, height, format, BQ_LAYER_COUNT, usage))
{
mSlots[found].mAcquireCalled = false;
mSlots[found].mGraphicBuffer = NULL;
@@ -503,11 +501,13 @@
} // Autolock scope
if (returnFlags & BUFFER_NEEDS_REALLOCATION) {
- status_t error;
BQ_LOGV("dequeueBuffer: allocating a new buffer for slot %d", *outSlot);
- sp<GraphicBuffer> graphicBuffer(mCore->mAllocator->createGraphicBuffer(
- width, height, format, BQ_LAYER_COUNT, usage,
- {mConsumerName.string(), mConsumerName.size()}, &error));
+ sp<GraphicBuffer> graphicBuffer = new GraphicBuffer(
+ width, height, format, BQ_LAYER_COUNT, usage, usage,
+ {mConsumerName.string(), mConsumerName.size()});
+
+ status_t error = graphicBuffer->initCheck();
+
{ // Autolock scope
Mutex::Autolock lock(mCore->mMutex);
@@ -1337,11 +1337,12 @@
Vector<sp<GraphicBuffer>> buffers;
for (size_t i = 0; i < newBufferCount; ++i) {
- status_t result = NO_ERROR;
- sp<GraphicBuffer> graphicBuffer(mCore->mAllocator->createGraphicBuffer(
+ sp<GraphicBuffer> graphicBuffer = new GraphicBuffer(
allocWidth, allocHeight, allocFormat, BQ_LAYER_COUNT,
- allocUsage, {mConsumerName.string(), mConsumerName.size()},
- &result));
+ allocUsage, allocUsage, {mConsumerName.string(), mConsumerName.size()});
+
+ status_t result = graphicBuffer->initCheck();
+
if (result != NO_ERROR) {
BQ_LOGE("allocateBuffers: failed to allocate buffer (%u x %u, format"
" %u, usage %u)", width, height, format, usage);
diff --git a/libs/gui/ConsumerBase.cpp b/libs/gui/ConsumerBase.cpp
index 1783561..5c6158c 100644
--- a/libs/gui/ConsumerBase.cpp
+++ b/libs/gui/ConsumerBase.cpp
@@ -30,7 +30,6 @@
#include <cutils/atomic.h>
#include <gui/BufferItem.h>
-#include <gui/IGraphicBufferAlloc.h>
#include <gui/ISurfaceComposer.h>
#include <gui/SurfaceComposerClient.h>
#include <gui/ConsumerBase.h>
diff --git a/libs/gui/GLConsumer.cpp b/libs/gui/GLConsumer.cpp
index 55e0d26..c654f08 100644
--- a/libs/gui/GLConsumer.cpp
+++ b/libs/gui/GLConsumer.cpp
@@ -31,7 +31,6 @@
#include <gui/BufferItem.h>
#include <gui/GLConsumer.h>
-#include <gui/IGraphicBufferAlloc.h>
#include <gui/ISurfaceComposer.h>
#include <gui/SurfaceComposerClient.h>
diff --git a/libs/gui/GraphicBufferAlloc.cpp b/libs/gui/GraphicBufferAlloc.cpp
deleted file mode 100644
index cc7d403..0000000
--- a/libs/gui/GraphicBufferAlloc.cpp
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- **
- ** Copyright 2012 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 <gui/GraphicBufferAlloc.h>
-
-#include <log/log.h>
-
-
-namespace android {
-
-GraphicBufferAlloc::GraphicBufferAlloc() = default;
-GraphicBufferAlloc::~GraphicBufferAlloc() = default;
-
-sp<GraphicBuffer> GraphicBufferAlloc::createGraphicBuffer(uint32_t width,
- uint32_t height, PixelFormat format, uint32_t layerCount,
- uint64_t producerUsage, uint64_t consumerUsage,
- std::string requestorName, status_t* error) {
- sp<GraphicBuffer> graphicBuffer(new GraphicBuffer(
- width, height, format, layerCount, producerUsage, consumerUsage,
- std::move(requestorName)));
- status_t err = graphicBuffer->initCheck();
- *error = err;
- if (err != 0 || graphicBuffer->handle == 0) {
- if (err == NO_MEMORY) {
- GraphicBuffer::dumpAllocationsToSystemLog();
- }
- ALOGE("GraphicBufferAlloc::createGraphicBuffer(w=%u, h=%u, lc=%u) failed (%s), handle=%p",
- width, height, layerCount, strerror(-err),
- graphicBuffer->handle);
- graphicBuffer.clear();
- }
- return graphicBuffer;
-}
-
-} // namespace android
diff --git a/libs/gui/IGraphicBufferAlloc.cpp b/libs/gui/IGraphicBufferAlloc.cpp
deleted file mode 100644
index 21a0dd5..0000000
--- a/libs/gui/IGraphicBufferAlloc.cpp
+++ /dev/null
@@ -1,139 +0,0 @@
-/*
- * Copyright (C) 2011 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.
- */
-
-// tag as surfaceflinger
-#define LOG_TAG "SurfaceFlinger"
-
-#include <stdint.h>
-#include <sys/types.h>
-
-#include <binder/Parcel.h>
-
-#include <ui/GraphicBuffer.h>
-
-#include <gui/IGraphicBufferAlloc.h>
-
-// ---------------------------------------------------------------------------
-
-namespace android {
-
-enum {
- CREATE_GRAPHIC_BUFFER = IBinder::FIRST_CALL_TRANSACTION,
-};
-
-class BpGraphicBufferAlloc : public BpInterface<IGraphicBufferAlloc>
-{
-public:
- explicit BpGraphicBufferAlloc(const sp<IBinder>& impl)
- : BpInterface<IGraphicBufferAlloc>(impl)
- {
- }
-
- virtual ~BpGraphicBufferAlloc();
-
- virtual sp<GraphicBuffer> createGraphicBuffer(uint32_t width,
- uint32_t height, PixelFormat format, uint32_t layerCount,
- uint64_t producerUsage, uint64_t consumerUsage,
- std::string requestorName, status_t* error) {
- Parcel data, reply;
- data.writeInterfaceToken(IGraphicBufferAlloc::getInterfaceDescriptor());
- data.writeUint32(width);
- data.writeUint32(height);
- data.writeInt32(static_cast<int32_t>(format));
- data.writeUint32(layerCount);
- data.writeUint64(producerUsage);
- data.writeUint64(consumerUsage);
- if (requestorName.empty()) {
- requestorName += "[PID ";
- requestorName += std::to_string(getpid());
- requestorName += ']';
- }
- data.writeUtf8AsUtf16(requestorName);
- remote()->transact(CREATE_GRAPHIC_BUFFER, data, &reply);
- sp<GraphicBuffer> graphicBuffer;
- status_t result = reply.readInt32();
- if (result == NO_ERROR) {
- graphicBuffer = new GraphicBuffer();
- result = reply.read(*graphicBuffer);
- if (result != NO_ERROR) {
- graphicBuffer.clear();
- }
- // reply.readStrongBinder();
- // here we don't even have to read the BufferReference from
- // the parcel, it'll die with the parcel.
- }
- *error = result;
- return graphicBuffer;
- }
-};
-
-// Out-of-line virtual method definition to trigger vtable emission in this
-// translation unit (see clang warning -Wweak-vtables)
-BpGraphicBufferAlloc::~BpGraphicBufferAlloc() {}
-
-IMPLEMENT_META_INTERFACE(GraphicBufferAlloc, "android.ui.IGraphicBufferAlloc");
-
-// ----------------------------------------------------------------------
-
-status_t BnGraphicBufferAlloc::onTransact(
- uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags)
-{
- // codes that don't require permission check
-
- // BufferReference just keeps a strong reference to a GraphicBuffer until it
- // is destroyed (that is, until no local or remote process have a reference
- // to it).
- class BufferReference : public BBinder {
- sp<GraphicBuffer> mBuffer;
- public:
- explicit BufferReference(const sp<GraphicBuffer>& buffer) : mBuffer(buffer) {}
- };
-
-
- switch (code) {
- case CREATE_GRAPHIC_BUFFER: {
- CHECK_INTERFACE(IGraphicBufferAlloc, data, reply);
- uint32_t width = data.readUint32();
- uint32_t height = data.readUint32();
- PixelFormat format = static_cast<PixelFormat>(data.readInt32());
- uint32_t layerCount = data.readUint32();
- uint64_t producerUsage = data.readUint64();
- uint64_t consumerUsage = data.readUint64();
- status_t error = NO_ERROR;
- std::string requestorName;
- data.readUtf8FromUtf16(&requestorName);
- sp<GraphicBuffer> result = createGraphicBuffer(width, height,
- format, layerCount, producerUsage, consumerUsage,
- requestorName, &error);
- reply->writeInt32(error);
- if (result != 0) {
- reply->write(*result);
- // We add a BufferReference to this parcel to make sure the
- // buffer stays alive until the GraphicBuffer object on
- // the other side has been created.
- // This is needed so that the buffer handle can be
- // registered before the buffer is destroyed on implementations
- // that do not use file-descriptors to track their buffers.
- reply->writeStrongBinder( new BufferReference(result) );
- }
- return NO_ERROR;
- }
- default:
- return BBinder::onTransact(code, data, reply, flags);
- }
-}
-
-}; // namespace android
diff --git a/libs/gui/ISurfaceComposer.cpp b/libs/gui/ISurfaceComposer.cpp
index 4d2692f..2516fb8 100644
--- a/libs/gui/ISurfaceComposer.cpp
+++ b/libs/gui/ISurfaceComposer.cpp
@@ -25,7 +25,6 @@
#include <binder/IServiceManager.h>
#include <gui/IDisplayEventConnection.h>
-#include <gui/IGraphicBufferAlloc.h>
#include <gui/IGraphicBufferProducer.h>
#include <gui/ISurfaceComposer.h>
#include <gui/ISurfaceComposerClient.h>
@@ -72,14 +71,6 @@
return interface_cast<ISurfaceComposerClient>(reply.readStrongBinder());
}
- virtual sp<IGraphicBufferAlloc> createGraphicBufferAlloc()
- {
- Parcel data, reply;
- data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
- remote()->transact(BnSurfaceComposer::CREATE_GRAPHIC_BUFFER_ALLOC, data, &reply);
- return interface_cast<IGraphicBufferAlloc>(reply.readStrongBinder());
- }
-
virtual void setTransactionState(
const Vector<ComposerState>& state,
const Vector<DisplayState>& displays,
@@ -505,12 +496,6 @@
reply->writeStrongBinder(b);
return NO_ERROR;
}
- case CREATE_GRAPHIC_BUFFER_ALLOC: {
- CHECK_INTERFACE(ISurfaceComposer, data, reply);
- sp<IBinder> b = IInterface::asBinder(createGraphicBufferAlloc());
- reply->writeStrongBinder(b);
- return NO_ERROR;
- }
case SET_TRANSACTION_STATE: {
CHECK_INTERFACE(ISurfaceComposer, data, reply);
diff --git a/libs/gui/tests/Surface_test.cpp b/libs/gui/tests/Surface_test.cpp
index cf3d1b2..08d6715 100644
--- a/libs/gui/tests/Surface_test.cpp
+++ b/libs/gui/tests/Surface_test.cpp
@@ -377,9 +377,6 @@
const sp<IGraphicBufferProducer>& /* parent */) override {
return nullptr;
}
- sp<IGraphicBufferAlloc> createGraphicBufferAlloc() override {
- return nullptr;
- }
sp<IDisplayEventConnection> createDisplayEventConnection() override {
return nullptr;
}
diff --git a/libs/nativewindow/AHardwareBuffer.cpp b/libs/nativewindow/AHardwareBuffer.cpp
index 17b2a86..35b76c7 100644
--- a/libs/nativewindow/AHardwareBuffer.cpp
+++ b/libs/nativewindow/AHardwareBuffer.cpp
@@ -16,7 +16,7 @@
#define LOG_TAG "AHardwareBuffer"
-#include <android/hardware_buffer.h>
+#include <vndk/hardware_buffer.h>
#include <errno.h>
#include <sys/socket.h>
@@ -70,7 +70,7 @@
if (err == NO_MEMORY) {
GraphicBuffer::dumpAllocationsToSystemLog();
}
- ALOGE("GraphicBufferAlloc::createGraphicBuffer(w=%u, h=%u, lc=%u) failed (%s), handle=%p",
+ ALOGE("GraphicBuffer(w=%u, h=%u, lc=%u) failed (%s), handle=%p",
desc->width, desc->height, desc->layers, strerror(-err), gbuffer->handle);
return err;
}
@@ -261,7 +261,12 @@
return NO_ERROR;
}
-const struct native_handle* AHardwareBuffer_getNativeHandle(
+
+// ----------------------------------------------------------------------------
+// VNDK functions
+// ----------------------------------------------------------------------------
+
+const native_handle_t* AHardwareBuffer_getNativeHandle(
const AHardwareBuffer* buffer) {
if (!buffer) return nullptr;
const GraphicBuffer* gbuffer = AHardwareBuffer_to_GraphicBuffer(buffer);
diff --git a/libs/nativewindow/include/android/hardware_buffer.h b/libs/nativewindow/include/android/hardware_buffer.h
index e5b6853..02838d4 100644
--- a/libs/nativewindow/include/android/hardware_buffer.h
+++ b/libs/nativewindow/include/android/hardware_buffer.h
@@ -252,12 +252,6 @@
*/
int AHardwareBuffer_recvHandleFromUnixSocket(int socketFd, AHardwareBuffer** outBuffer);
-// ----------------------------------------------------------------------------
-// Everything below here is part of the public NDK API, but is intended only
-// for use by device-specific graphics drivers.
-struct native_handle;
-const struct native_handle* AHardwareBuffer_getNativeHandle(const AHardwareBuffer* buffer);
-
__END_DECLS
#endif // ANDROID_HARDWARE_BUFFER_H
diff --git a/libs/nativewindow/include/vndk/hardware_buffer.h b/libs/nativewindow/include/vndk/hardware_buffer.h
new file mode 100644
index 0000000..dc2dcbe
--- /dev/null
+++ b/libs/nativewindow/include/vndk/hardware_buffer.h
@@ -0,0 +1,31 @@
+/*
+ * Copyright 2017 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.
+ */
+
+#ifndef ANDROID_VNDK_NATIVEWINDOW_AHARDWAREBUFFER_H
+#define ANDROID_VNDK_NATIVEWINDOW_AHARDWAREBUFFER_H
+
+// vndk is a superset of the NDK
+#include <android/hardware_buffer.h>
+
+#include <cutils/native_handle.h>
+
+__BEGIN_DECLS
+
+const native_handle_t* AHardwareBuffer_getNativeHandle(const AHardwareBuffer* buffer);
+
+__END_DECLS
+
+#endif /* ANDROID_VNDK_NATIVEWINDOW_AHARDWAREBUFFER_H */
diff --git a/libs/nativewindow/libnativewindow.map.txt b/libs/nativewindow/libnativewindow.map.txt
index b29c888..b1d1a72 100644
--- a/libs/nativewindow/libnativewindow.map.txt
+++ b/libs/nativewindow/libnativewindow.map.txt
@@ -4,7 +4,6 @@
AHardwareBuffer_allocate;
AHardwareBuffer_describe;
AHardwareBuffer_fromHardwareBuffer;
- AHardwareBuffer_getNativeHandle;
AHardwareBuffer_lock;
AHardwareBuffer_recvHandleFromUnixSocket;
AHardwareBuffer_release;
diff --git a/libs/nativewindow/tests/c_compatibility.c b/libs/nativewindow/tests/c_compatibility.c
index a0dfdf9..befd88f 100644
--- a/libs/nativewindow/tests/c_compatibility.c
+++ b/libs/nativewindow/tests/c_compatibility.c
@@ -16,6 +16,7 @@
#include <android/hardware_buffer.h>
#include <android/native_window.h>
+#include <vndk/hardware_buffer.h>
#include <vndk/window.h>
// this checks that all these headers are C-compatible
diff --git a/libs/vr/libdvr/display_manager_client.cpp b/libs/vr/libdvr/display_manager_client.cpp
index 8d84f7b..64c7f16 100644
--- a/libs/vr/libdvr/display_manager_client.cpp
+++ b/libs/vr/libdvr/display_manager_client.cpp
@@ -1,6 +1,7 @@
#include "include/dvr/display_manager_client.h"
#include <dvr/dvr_buffer.h>
+#include <private/android/AHardwareBufferHelpers.h>
#include <private/dvr/buffer_hub_client.h>
#include <private/dvr/display_manager_client_impl.h>
@@ -44,10 +45,11 @@
DvrBuffer* dvrDisplayManagerSetupNamedBuffer(DvrDisplayManagerClient* client,
const char* name, size_t size,
- uint64_t producer_usage,
- uint64_t consumer_usage) {
- // TODO(hendrikw): When we move to gralloc1, pass both producer_usage and
- // consumer_usage down.
+ uint64_t usage0, uint64_t usage1) {
+ uint64_t producer_usage = 0;
+ uint64_t consumer_usage = 0;
+ android::AHardwareBuffer_convertToGrallocUsageBits(
+ &producer_usage, &consumer_usage, usage0, usage1);
auto ion_buffer = client->client->SetupNamedBuffer(name, size, producer_usage,
consumer_usage);
if (ion_buffer) {
diff --git a/libs/vr/libdvr/dvr_api.cpp b/libs/vr/libdvr/dvr_api.cpp
index b91de8f..c4634b1 100644
--- a/libs/vr/libdvr/dvr_api.cpp
+++ b/libs/vr/libdvr/dvr_api.cpp
@@ -53,14 +53,18 @@
dvr_api->write_buffer_post = dvrWriteBufferPost;
dvr_api->write_buffer_gain = dvrWriteBufferGain;
dvr_api->write_buffer_gain_async = dvrWriteBufferGainAsync;
+ dvr_api->write_buffer_get_native_handle = dvrWriteBufferGetNativeHandle;
dvr_api->read_buffer_destroy = dvrReadBufferDestroy;
dvr_api->read_buffer_get_ahardwarebuffer = dvrReadBufferGetAHardwareBuffer;
dvr_api->read_buffer_acquire = dvrReadBufferAcquire;
dvr_api->read_buffer_release = dvrReadBufferRelease;
dvr_api->read_buffer_release_async = dvrReadBufferReleaseAsync;
+ dvr_api->read_buffer_get_native_handle = dvrReadBufferGetNativeHandle;
+
dvr_api->buffer_destroy = dvrBufferDestroy;
dvr_api->buffer_get_ahardwarebuffer = dvrBufferGetAHardwareBuffer;
+ dvr_api->buffer_get_native_handle = dvrBufferGetNativeHandle;
// dvr_buffer_queue.h
dvr_api->write_buffer_queue_destroy = dvrWriteBufferQueueDestroy;
@@ -109,6 +113,11 @@
dvr_api->hwc_frame_get_display_width = dvrHwcFrameGetDisplayWidth;
dvr_api->hwc_frame_get_display_height = dvrHwcFrameGetDisplayHeight;
dvr_api->hwc_frame_get_display_removed = dvrHwcFrameGetDisplayRemoved;
+ dvr_api->hwc_frame_get_active_config = dvrHwcFrameGetActiveConfig;
+ dvr_api->hwc_frame_get_color_mode = dvrHwcFrameGetColorMode;
+ dvr_api->hwc_frame_get_color_transform = dvrHwcFrameGetColorTransform;
+ dvr_api->hwc_frame_get_power_mode = dvrHwcFrameGetPowerMode;
+ dvr_api->hwc_frame_get_vsync_enabled = dvrHwcFrameGetVsyncEnabled;
dvr_api->hwc_frame_get_layer_count = dvrHwcFrameGetLayerCount;
dvr_api->hwc_frame_get_layer_id = dvrHwcFrameGetLayerId;
dvr_api->hwc_frame_get_layer_buffer = dvrHwcFrameGetLayerBuffer;
@@ -121,6 +130,19 @@
dvr_api->hwc_frame_get_layer_type = dvrHwcFrameGetLayerType;
dvr_api->hwc_frame_get_layer_application_id =
dvrHwcFrameGetLayerApplicationId;
+ dvr_api->hwc_frame_get_layer_z_order = dvrHwcFrameGetLayerZOrder;
+ dvr_api->hwc_frame_get_layer_cursor = dvrHwcFrameGetLayerCursor;
+ dvr_api->hwc_frame_get_layer_transform = dvrHwcFrameGetLayerTransform;
+ dvr_api->hwc_frame_get_layer_dataspace = dvrHwcFrameGetLayerDataspace;
+ dvr_api->hwc_frame_get_layer_color = dvrHwcFrameGetLayerColor;
+ dvr_api->hwc_frame_get_layer_num_visible_regions =
+ dvrHwcFrameGetLayerNumVisibleRegions;
+ dvr_api->hwc_frame_get_layer_visible_region =
+ dvrHwcFrameGetLayerVisibleRegion;
+ dvr_api->hwc_frame_get_layer_num_damaged_regions =
+ dvrHwcFrameGetLayerNumDamagedRegions;
+ dvr_api->hwc_frame_get_layer_damaged_region =
+ dvrHwcFrameGetLayerDamagedRegion;
return 0;
}
diff --git a/libs/vr/libdvr/dvr_buffer.cpp b/libs/vr/libdvr/dvr_buffer.cpp
index 0942b3d..e7fdb91 100644
--- a/libs/vr/libdvr/dvr_buffer.cpp
+++ b/libs/vr/libdvr/dvr_buffer.cpp
@@ -136,4 +136,18 @@
return 0;
}
+const struct native_handle* dvrWriteBufferGetNativeHandle(
+ DvrWriteBuffer* write_buffer) {
+ return write_buffer->write_buffer->native_handle();
+}
+
+const struct native_handle* dvrReadBufferGetNativeHandle(
+ DvrReadBuffer* read_buffer) {
+ return read_buffer->read_buffer->native_handle();
+}
+
+const struct native_handle* dvrBufferGetNativeHandle(DvrBuffer* buffer) {
+ return buffer->buffer->handle();
+}
+
} // extern "C"
diff --git a/libs/vr/libdvr/dvr_hardware_composer_client.cpp b/libs/vr/libdvr/dvr_hardware_composer_client.cpp
index 39c2a90..d3ae299 100644
--- a/libs/vr/libdvr/dvr_hardware_composer_client.cpp
+++ b/libs/vr/libdvr/dvr_hardware_composer_client.cpp
@@ -104,6 +104,29 @@
return frame->frame.layers.size();
}
+uint32_t dvrHwcFrameGetActiveConfig(DvrHwcFrame* frame) {
+ return static_cast<uint32_t>(frame->frame.active_config);
+}
+
+uint32_t dvrHwcFrameGetColorMode(DvrHwcFrame* frame) {
+ return static_cast<uint32_t>(frame->frame.color_mode);
+}
+
+void dvrHwcFrameGetColorTransform(DvrHwcFrame* frame, float* out_matrix,
+ int32_t* out_hint) {
+ *out_hint = frame->frame.color_transform_hint;
+ memcpy(out_matrix, frame->frame.color_transform,
+ sizeof(frame->frame.color_transform));
+}
+
+uint32_t dvrHwcFrameGetPowerMode(DvrHwcFrame* frame) {
+ return static_cast<uint32_t>(frame->frame.power_mode);
+}
+
+uint32_t dvrHwcFrameGetVsyncEnabled(DvrHwcFrame* frame) {
+ return static_cast<uint32_t>(frame->frame.vsync_enabled);
+}
+
DvrHwcLayer dvrHwcFrameGetLayerId(DvrHwcFrame* frame, size_t layer_index) {
return frame->frame.layers[layer_index].id;
}
@@ -157,3 +180,58 @@
size_t layer_index) {
return frame->frame.layers[layer_index].app_id;
}
+
+uint32_t dvrHwcFrameGetLayerZOrder(DvrHwcFrame* frame, size_t layer_index) {
+ return frame->frame.layers[layer_index].z_order;
+}
+
+void dvrHwcFrameGetLayerCursor(DvrHwcFrame* frame, size_t layer_index,
+ int32_t* out_x, int32_t* out_y) {
+ *out_x = frame->frame.layers[layer_index].cursor_x;
+ *out_y = frame->frame.layers[layer_index].cursor_y;
+}
+
+uint32_t dvrHwcFrameGetLayerTransform(DvrHwcFrame* frame, size_t layer_index) {
+ return frame->frame.layers[layer_index].transform;
+}
+
+uint32_t dvrHwcFrameGetLayerDataspace(DvrHwcFrame* frame, size_t layer_index) {
+ return frame->frame.layers[layer_index].dataspace;
+}
+
+uint32_t dvrHwcFrameGetLayerColor(DvrHwcFrame* frame, size_t layer_index) {
+ const auto& color = frame->frame.layers[layer_index].color;
+ return color.r | (static_cast<uint32_t>(color.g) << 8) |
+ (static_cast<uint32_t>(color.b) << 16) |
+ (static_cast<uint32_t>(color.a) << 24);
+}
+
+uint32_t dvrHwcFrameGetLayerNumVisibleRegions(DvrHwcFrame* frame,
+ size_t layer_index) {
+ return frame->frame.layers[layer_index].visible_regions.size();
+}
+
+DvrHwcRecti dvrHwcFrameGetLayerVisibleRegion(DvrHwcFrame* frame,
+ size_t layer_index, size_t index) {
+ return DvrHwcRecti{
+ frame->frame.layers[layer_index].visible_regions[index].left,
+ frame->frame.layers[layer_index].visible_regions[index].top,
+ frame->frame.layers[layer_index].visible_regions[index].right,
+ frame->frame.layers[layer_index].visible_regions[index].bottom,
+ };
+}
+
+uint32_t dvrHwcFrameGetLayerNumDamagedRegions(DvrHwcFrame* frame,
+ size_t layer_index) {
+ return frame->frame.layers[layer_index].damaged_regions.size();
+}
+
+DvrHwcRecti dvrHwcFrameGetLayerDamagedRegion(DvrHwcFrame* frame,
+ size_t layer_index, size_t index) {
+ return DvrHwcRecti{
+ frame->frame.layers[layer_index].damaged_regions[index].left,
+ frame->frame.layers[layer_index].damaged_regions[index].top,
+ frame->frame.layers[layer_index].damaged_regions[index].right,
+ frame->frame.layers[layer_index].damaged_regions[index].bottom,
+ };
+}
diff --git a/libs/vr/libdvr/include/dvr/display_manager_client.h b/libs/vr/libdvr/include/dvr/display_manager_client.h
index 4e1f227..8cd948c 100644
--- a/libs/vr/libdvr/include/dvr/display_manager_client.h
+++ b/libs/vr/libdvr/include/dvr/display_manager_client.h
@@ -22,8 +22,7 @@
DvrBuffer* dvrDisplayManagerSetupNamedBuffer(DvrDisplayManagerClient* client,
const char* name, size_t size,
- uint64_t producer_usage,
- uint64_t consumer_usage);
+ uint64_t usage0, uint64_t usage1);
// Return an event fd for checking if there was an event on the server
// Note that the only event which will be flagged is POLLIN. You must use
diff --git a/libs/vr/libdvr/include/dvr/dvr_api.h b/libs/vr/libdvr/include/dvr/dvr_api.h
index 7dc6a30..56f937b 100644
--- a/libs/vr/libdvr/include/dvr/dvr_api.h
+++ b/libs/vr/libdvr/include/dvr/dvr_api.h
@@ -38,6 +38,8 @@
typedef struct DvrSurface DvrSurface;
+struct native_handle;
+
// display_manager_client.h
typedef int (*DvrDisplayManagerClientGetSurfaceListPtr)(
DvrDisplayManagerClient* client,
@@ -46,7 +48,7 @@
DvrDisplayManagerClientSurfaceList* surface_list);
typedef DvrBuffer* (*DvrDisplayManagerSetupNamedBufferPtr)(
DvrDisplayManagerClient* client, const char* name, size_t size,
- uint64_t producer_usage, uint64_t consumer_usage);
+ uint64_t usage0, uint64_t usage1);
typedef size_t (*DvrDisplayManagerClientSurfaceListGetSizePtr)(
DvrDisplayManagerClientSurfaceList* surface_list);
typedef int (*DvrDisplayManagerClientSurfaceListGetSurfaceIdPtr)(
@@ -70,6 +72,8 @@
typedef int (*DvrWriteBufferGainPtr)(DvrWriteBuffer* client,
int* release_fence_fd);
typedef int (*DvrWriteBufferGainAsyncPtr)(DvrWriteBuffer* client);
+typedef const struct native_handle* (*DvrWriteBufferGetNativeHandle)(
+ DvrWriteBuffer* write_buffer);
typedef void (*DvrReadBufferDestroyPtr)(DvrReadBuffer* client);
typedef int (*DvrReadBufferGetAHardwareBufferPtr)(
@@ -80,9 +84,14 @@
typedef int (*DvrReadBufferReleasePtr)(DvrReadBuffer* client,
int release_fence_fd);
typedef int (*DvrReadBufferReleaseAsyncPtr)(DvrReadBuffer* client);
+typedef const struct native_handle* (*DvrReadBufferGetNativeHandle)(
+ DvrReadBuffer* read_buffer);
+
typedef void (*DvrBufferDestroy)(DvrBuffer* buffer);
typedef int (*DvrBufferGetAHardwareBuffer)(DvrBuffer* buffer,
AHardwareBuffer** hardware_buffer);
+typedef const struct native_handle* (*DvrBufferGetNativeHandle)(
+ DvrBuffer* buffer);
// dvr_buffer_queue.h
typedef void (*DvrWriteBufferQueueDestroyPtr)(DvrWriteBufferQueue* write_queue);
@@ -159,6 +168,13 @@
typedef size_t (*DvrHwcFrameGetLayerCountPtr)(DvrHwcFrame* frame);
typedef DvrHwcLayer (*DvrHwcFrameGetLayerIdPtr)(DvrHwcFrame* frame,
size_t layer_index);
+typedef uint32_t (*DvrHwcFrameGetActiveConfigPtr)(DvrHwcFrame* frame);
+typedef uint32_t (*DvrHwcFrameGetColorModePtr)(DvrHwcFrame* frame);
+typedef void (*DvrHwcFrameGetColorTransformPtr)(DvrHwcFrame* frame,
+ float* out_matrix,
+ int32_t* out_hint);
+typedef uint32_t (*DvrHwcFrameGetPowerModePtr)(DvrHwcFrame* frame);
+typedef uint32_t (*DvrHwcFrameGetVsyncEnabledPtr)(DvrHwcFrame* frame);
typedef AHardwareBuffer* (*DvrHwcFrameGetLayerBufferPtr)(DvrHwcFrame* frame,
size_t layer_index);
typedef int (*DvrHwcFrameGetLayerFencePtr)(DvrHwcFrame* frame,
@@ -175,6 +191,33 @@
size_t layer_index);
typedef uint32_t (*DvrHwcFrameGetLayerApplicationIdPtr)(DvrHwcFrame* frame,
size_t layer_index);
+typedef uint32_t (*DvrHwcFrameGetLayerZOrderPtr)(DvrHwcFrame* frame,
+ size_t layer_index);
+
+typedef void (*DvrHwcFrameGetLayerCursorPtr)(DvrHwcFrame* frame,
+ size_t layer_index, int32_t* out_x,
+ int32_t* out_y);
+
+typedef uint32_t (*DvrHwcFrameGetLayerTransformPtr)(DvrHwcFrame* frame,
+ size_t layer_index);
+
+typedef uint32_t (*DvrHwcFrameGetLayerDataspacePtr)(DvrHwcFrame* frame,
+ size_t layer_index);
+
+typedef uint32_t (*DvrHwcFrameGetLayerColorPtr)(DvrHwcFrame* frame,
+ size_t layer_index);
+
+typedef uint32_t (*DvrHwcFrameGetLayerNumVisibleRegionsPtr)(DvrHwcFrame* frame,
+ size_t layer_index);
+typedef DvrHwcRecti (*DvrHwcFrameGetLayerVisibleRegionPtr)(DvrHwcFrame* frame,
+ size_t layer_index,
+ size_t index);
+
+typedef uint32_t (*DvrHwcFrameGetLayerNumDamagedRegionsPtr)(DvrHwcFrame* frame,
+ size_t layer_index);
+typedef DvrHwcRecti (*DvrHwcFrameGetLayerDamagedRegionPtr)(DvrHwcFrame* frame,
+ size_t layer_index,
+ size_t index);
struct DvrApi_v1 {
// Display manager client
@@ -204,6 +247,7 @@
DvrWriteBufferPostPtr write_buffer_post;
DvrWriteBufferGainPtr write_buffer_gain;
DvrWriteBufferGainAsyncPtr write_buffer_gain_async;
+ DvrWriteBufferGetNativeHandle write_buffer_get_native_handle;
// Read buffer
DvrReadBufferDestroyPtr read_buffer_destroy;
@@ -211,8 +255,12 @@
DvrReadBufferAcquirePtr read_buffer_acquire;
DvrReadBufferReleasePtr read_buffer_release;
DvrReadBufferReleaseAsyncPtr read_buffer_release_async;
+ DvrReadBufferGetNativeHandle read_buffer_get_native_handle;
+
+ // Buffer
DvrBufferDestroy buffer_destroy;
DvrBufferGetAHardwareBuffer buffer_get_ahardwarebuffer;
+ DvrBufferGetNativeHandle buffer_get_native_handle;
// Write buffer queue
DvrWriteBufferQueueDestroyPtr write_buffer_queue_destroy;
@@ -261,6 +309,11 @@
DvrHwcFrameGetDisplayWidthPtr hwc_frame_get_display_width;
DvrHwcFrameGetDisplayHeightPtr hwc_frame_get_display_height;
DvrHwcFrameGetDisplayRemovedPtr hwc_frame_get_display_removed;
+ DvrHwcFrameGetActiveConfigPtr hwc_frame_get_active_config;
+ DvrHwcFrameGetColorModePtr hwc_frame_get_color_mode;
+ DvrHwcFrameGetColorTransformPtr hwc_frame_get_color_transform;
+ DvrHwcFrameGetPowerModePtr hwc_frame_get_power_mode;
+ DvrHwcFrameGetVsyncEnabledPtr hwc_frame_get_vsync_enabled;
DvrHwcFrameGetLayerCountPtr hwc_frame_get_layer_count;
DvrHwcFrameGetLayerIdPtr hwc_frame_get_layer_id;
DvrHwcFrameGetLayerBufferPtr hwc_frame_get_layer_buffer;
@@ -271,6 +324,17 @@
DvrHwcFrameGetLayerAlphaPtr hwc_frame_get_layer_alpha;
DvrHwcFrameGetLayerTypePtr hwc_frame_get_layer_type;
DvrHwcFrameGetLayerApplicationIdPtr hwc_frame_get_layer_application_id;
+ DvrHwcFrameGetLayerZOrderPtr hwc_frame_get_layer_z_order;
+ DvrHwcFrameGetLayerCursorPtr hwc_frame_get_layer_cursor;
+ DvrHwcFrameGetLayerTransformPtr hwc_frame_get_layer_transform;
+ DvrHwcFrameGetLayerDataspacePtr hwc_frame_get_layer_dataspace;
+ DvrHwcFrameGetLayerColorPtr hwc_frame_get_layer_color;
+ DvrHwcFrameGetLayerNumVisibleRegionsPtr
+ hwc_frame_get_layer_num_visible_regions;
+ DvrHwcFrameGetLayerVisibleRegionPtr hwc_frame_get_layer_visible_region;
+ DvrHwcFrameGetLayerNumDamagedRegionsPtr
+ hwc_frame_get_layer_num_damaged_regions;
+ DvrHwcFrameGetLayerDamagedRegionPtr hwc_frame_get_layer_damaged_region;
};
int dvrGetApi(void* api, size_t struct_size, int version);
diff --git a/libs/vr/libdvr/include/dvr/dvr_buffer.h b/libs/vr/libdvr/include/dvr/dvr_buffer.h
index 6c9c4d3..b2cf0d7 100644
--- a/libs/vr/libdvr/include/dvr/dvr_buffer.h
+++ b/libs/vr/libdvr/include/dvr/dvr_buffer.h
@@ -13,6 +13,7 @@
typedef struct DvrReadBuffer DvrReadBuffer;
typedef struct DvrBuffer DvrBuffer;
typedef struct AHardwareBuffer AHardwareBuffer;
+struct native_handle;
// Write buffer
void dvrWriteBufferDestroy(DvrWriteBuffer* write_buffer);
@@ -23,6 +24,8 @@
const void* meta, size_t meta_size_bytes);
int dvrWriteBufferGain(DvrWriteBuffer* write_buffer, int* release_fence_fd);
int dvrWriteBufferGainAsync(DvrWriteBuffer* write_buffer);
+const struct native_handle* dvrWriteBufferGetNativeHandle(
+ DvrWriteBuffer* write_buffer);
// Read buffer
void dvrReadBufferDestroy(DvrReadBuffer* read_buffer);
@@ -33,11 +36,14 @@
void* meta, size_t meta_size_bytes);
int dvrReadBufferRelease(DvrReadBuffer* read_buffer, int release_fence_fd);
int dvrReadBufferReleaseAsync(DvrReadBuffer* read_buffer);
+const struct native_handle* dvrReadBufferGetNativeHandle(
+ DvrReadBuffer* read_buffer);
// Buffer
void dvrBufferDestroy(DvrBuffer* buffer);
int dvrBufferGetAHardwareBuffer(DvrBuffer* buffer,
AHardwareBuffer** hardware_buffer);
+const struct native_handle* dvrBufferGetNativeHandle(DvrBuffer* buffer);
#ifdef __cplusplus
} // extern "C"
diff --git a/libs/vr/libdvr/include/dvr/dvr_hardware_composer_client.h b/libs/vr/libdvr/include/dvr/dvr_hardware_composer_client.h
index 2d28aa3..7ee7f9e 100644
--- a/libs/vr/libdvr/include/dvr/dvr_hardware_composer_client.h
+++ b/libs/vr/libdvr/include/dvr/dvr_hardware_composer_client.h
@@ -43,6 +43,13 @@
// @return Number of layers in the frame.
size_t dvrHwcFrameGetLayerCount(DvrHwcFrame* frame);
+uint32_t dvrHwcFrameGetActiveConfig(DvrHwcFrame* frame);
+uint32_t dvrHwcFrameGetColorMode(DvrHwcFrame* frame);
+void dvrHwcFrameGetColorTransform(DvrHwcFrame* frame, float* out_matrix,
+ int32_t* out_hint);
+uint32_t dvrHwcFrameGetPowerMode(DvrHwcFrame* frame);
+uint32_t dvrHwcFrameGetVsyncEnabled(DvrHwcFrame* frame);
+
DvrHwcLayer dvrHwcFrameGetLayerId(DvrHwcFrame* frame, size_t layer_index);
// Return the graphic buffer associated with the layer at |layer_index| in
@@ -73,6 +80,26 @@
uint32_t dvrHwcFrameGetLayerApplicationId(DvrHwcFrame* frame,
size_t layer_index);
+uint32_t dvrHwcFrameGetLayerZOrder(DvrHwcFrame* frame, size_t layer_index);
+
+void dvrHwcFrameGetLayerCursor(DvrHwcFrame* frame, size_t layer_index,
+ int32_t* out_x, int32_t* out_y);
+
+uint32_t dvrHwcFrameGetLayerTransform(DvrHwcFrame* frame, size_t layer_index);
+
+uint32_t dvrHwcFrameGetLayerDataspace(DvrHwcFrame* frame, size_t layer_index);
+
+uint32_t dvrHwcFrameGetLayerColor(DvrHwcFrame* frame, size_t layer_index);
+
+uint32_t dvrHwcFrameGetLayerNumVisibleRegions(DvrHwcFrame* frame,
+ size_t layer_index);
+DvrHwcRecti dvrHwcFrameGetLayerVisibleRegion(DvrHwcFrame* frame,
+ size_t layer_index, size_t index);
+
+uint32_t dvrHwcFrameGetLayerNumDamagedRegions(DvrHwcFrame* frame,
+ size_t layer_index);
+DvrHwcRecti dvrHwcFrameGetLayerDamagedRegion(DvrHwcFrame* frame,
+ size_t layer_index, size_t index);
#ifdef __cplusplus
} // extern "C"
#endif
diff --git a/libs/vr/libdvr/tests/dvr_named_buffer-test.cpp b/libs/vr/libdvr/tests/dvr_named_buffer-test.cpp
index cd3285f..52531a9 100644
--- a/libs/vr/libdvr/tests/dvr_named_buffer-test.cpp
+++ b/libs/vr/libdvr/tests/dvr_named_buffer-test.cpp
@@ -116,6 +116,34 @@
dvrBufferDestroy(buffer2);
}
+TEST_F(DvrNamedBufferTest, TestNamedBufferUsage) {
+ const char* buffer_name = "buffer_usage";
+
+ // Set usage0 to AHARDWAREBUFFER_USAGE0_VIDEO_ENCODE. We use this because
+ // internally AHARDWAREBUFFER_USAGE0_VIDEO_ENCODE is converted to
+ // GRALLOC1_CONSUMER_USAGE_VIDEO_ENCODER, and these two values are different.
+ // If all is good, when we get the AHardwareBuffer, it should be converted
+ // back to AHARDWAREBUFFER_USAGE0_VIDEO_ENCODE.
+ const int64_t usage0 = AHARDWAREBUFFER_USAGE0_VIDEO_ENCODE;
+
+ DvrBuffer* setup_buffer =
+ dvrDisplayManagerSetupNamedBuffer(client_, buffer_name, 10, usage0, 0);
+ ASSERT_NE(nullptr, setup_buffer);
+
+ AHardwareBuffer* hardware_buffer = nullptr;
+ int e2 = dvrBufferGetAHardwareBuffer(setup_buffer, &hardware_buffer);
+ ASSERT_EQ(0, e2);
+ ASSERT_NE(nullptr, hardware_buffer);
+
+ AHardwareBuffer_Desc desc = {};
+ AHardwareBuffer_describe(hardware_buffer, &desc);
+
+ ASSERT_EQ(desc.usage0, AHARDWAREBUFFER_USAGE0_VIDEO_ENCODE);
+
+ dvrBufferDestroy(setup_buffer);
+}
+
+
} // namespace
} // namespace dvr
diff --git a/libs/vr/libdvrgraphics/gpu_profiler.cpp b/libs/vr/libdvrgraphics/gpu_profiler.cpp
index 49c515f..c8c978d 100644
--- a/libs/vr/libdvrgraphics/gpu_profiler.cpp
+++ b/libs/vr/libdvrgraphics/gpu_profiler.cpp
@@ -7,6 +7,12 @@
namespace android {
namespace dvr {
+namespace {
+
+constexpr int kMaxPendingQueries = 32;
+
+} // anonynmous namespace
+
static int64_t AdjustTimerQueryToNs(int64_t gpu_time) { return gpu_time; }
void GpuProfiler::TimerData::reset() {
@@ -21,6 +27,7 @@
// Enter a scope, records the timestamp for later matching with leave.
void GpuProfiler::TimerData::enter(int64_t timestamp_ns) {
+ entered = true;
enter_timestamp_ns = timestamp_ns;
}
@@ -28,6 +35,15 @@
void GpuProfiler::TimerData::leave(int64_t timestamp_ns, const char* name,
std::weak_ptr<int64_t> duration_ns,
int print_period) {
+ if (!entered) {
+ // We got the leave event but are missing the enter. This can happen if
+ // OnPendingQueryOverflow() is called, or if the calls to enter()/leave()
+ // aren't properly balanced. Ignore the call but print a warning.
+ ALOGW("Ignoring GpuProfiler::TimerData::leave event with no enter event");
+ return;
+ }
+ entered = false;
+
int64_t elapsed = timestamp_ns - enter_timestamp_ns;
if (elapsed > 1000 * 1000 * 1000) {
// More than one second, drop it as invalid data.
@@ -50,12 +66,12 @@
GpuProfiler::GpuProfiler()
: enable_gpu_tracing_(true),
+ has_gl_context_(false),
sync_with_cpu_time_(false),
gl_timer_offset_ns_(0) {
- SyncGlTimebase();
}
-GpuProfiler::~GpuProfiler() {}
+GpuProfiler::~GpuProfiler() { Clear(); }
bool GpuProfiler::IsGpuProfilingSupported() const {
// TODO(jbates) check for GL_EXT_disjoint_timer_query
@@ -63,6 +79,9 @@
}
GLuint GpuProfiler::TryAllocateGlQueryId() {
+ if (pending_gpu_queries_.size() >= kMaxPendingQueries)
+ OnPendingQueryOverflow();
+
GLuint query_id = 0;
if (gl_timer_query_id_pool_.empty()) {
glGenQueries(1, &query_id);
@@ -95,6 +114,35 @@
}
}
+void GpuProfiler::OnGlContextCreated() {
+ has_gl_context_ = true;
+ gl_timer_offset_ns_ = 0;
+ SyncGlTimebase();
+}
+
+void GpuProfiler::OnGlContextDestroyed() {
+ has_gl_context_ = false;
+ Clear();
+}
+
+void GpuProfiler::Clear() {
+ events_.clear();
+ for (auto& query : pending_gpu_queries_)
+ glDeleteQueries(1, &query.query_id);
+ pending_gpu_queries_.clear();
+ while (!gl_timer_query_id_pool_.empty()) {
+ GLuint id = gl_timer_query_id_pool_.top();
+ gl_timer_query_id_pool_.pop();
+ glDeleteQueries(1, &id);
+ }
+}
+
+void GpuProfiler::OnPendingQueryOverflow() {
+ ALOGW("Reached limit of %d pending queries in GpuProfiler."
+ " Clearing all queries.", kMaxPendingQueries);
+ Clear();
+}
+
void GpuProfiler::SyncGlTimebase() {
if (!sync_with_cpu_time_) {
return;
diff --git a/libs/vr/libdvrgraphics/include/private/dvr/graphics/gpu_profiler.h b/libs/vr/libdvrgraphics/include/private/dvr/graphics/gpu_profiler.h
index 2905d00..c6e752b 100644
--- a/libs/vr/libdvrgraphics/include/private/dvr/graphics/gpu_profiler.h
+++ b/libs/vr/libdvrgraphics/include/private/dvr/graphics/gpu_profiler.h
@@ -38,7 +38,7 @@
// one of the TRACE_GPU* macros defined below.
void SetEnableGpuTracing(bool enabled) { enable_gpu_tracing_ = enabled; }
- bool enabled() const { return enable_gpu_tracing_; }
+ bool enabled() const { return enable_gpu_tracing_ && has_gl_context_; }
// Attempt to keep the GPU times in sync with CPU times.
void SetEnableSyncCpuTime(bool enabled) { sync_with_cpu_time_ = enabled; }
@@ -62,6 +62,14 @@
void LeaveGlScope(const char* scope_name, std::weak_ptr<int64_t> duration_ns,
int print_period);
+ // Must be called when the GL context is created. The GpuProfiler will be
+ // inactive until this is called.
+ void OnGlContextCreated();
+
+ // Must be called before the GL context is destroyed. The GpuProfiler will be
+ // inactive until a call to OnGlContextCreated().
+ void OnGlContextDestroyed();
+
private:
// Data to queue the pending GPU timer queries that need to be polled
// for completion.
@@ -105,11 +113,20 @@
void leave(int64_t timestamp_ns, const char* name,
std::weak_ptr<int64_t> duration_ns, int print_period);
+ bool entered = false;
int64_t total_elapsed_ns = 0;
int64_t enter_timestamp_ns = 0;
int num_events = 0;
};
+ // Clear out events and free GL resources.
+ void Clear();
+
+ // Called when we detect that we've overflowed the pending query queue. This
+ // shouldn't occur in practice, and probably indicates some internal
+ // mismanagement of the gl query objects.
+ void OnPendingQueryOverflow();
+
// Synchronises the GL timebase with the CallTraceManager timebase.
void SyncGlTimebase();
@@ -119,6 +136,10 @@
// Setting for enabling GPU tracing.
bool enable_gpu_tracing_;
+ // True if we have a GL context, false otherwise. When the GpuProfiler is
+ // first created we assume no GL context.
+ bool has_gl_context_;
+
// Setting for synchronizing GPU timestamps with CPU time.
bool sync_with_cpu_time_;
diff --git a/libs/vr/libeds/Android.bp b/libs/vr/libeds/Android.bp
index 187cbbf..85e43cc 100644
--- a/libs/vr/libeds/Android.bp
+++ b/libs/vr/libeds/Android.bp
@@ -16,11 +16,9 @@
"eds.cpp",
"eds_mesh.cpp",
"composite_hmd.cpp",
- "cpu_thread_pose_updater.cpp",
"display_metrics.cpp",
"distortion_renderer.cpp",
- "lucid_metrics.cpp",
- "lucid_pose_tracker.cpp",
+ "device_metrics.cpp",
"lookup_radial_distortion.cpp",
"polynomial_radial_distortion.cpp",
]
diff --git a/libs/vr/libeds/cpu_thread_pose_updater.cpp b/libs/vr/libeds/cpu_thread_pose_updater.cpp
deleted file mode 100644
index 5b8a734..0000000
--- a/libs/vr/libeds/cpu_thread_pose_updater.cpp
+++ /dev/null
@@ -1,86 +0,0 @@
-#include "include/private/dvr/cpu_thread_pose_updater.h"
-
-#include <sys/prctl.h>
-#include <unistd.h>
-
-#define ATRACE_TAG ATRACE_TAG_INPUT
-#include <utils/Trace.h>
-
-#include <private/dvr/clock_ns.h>
-#include <private/dvr/debug.h>
-
-namespace android {
-namespace dvr {
-
-CpuThreadPoseUpdater::CpuThreadPoseUpdater()
- : stop_request_(false), update_period_us_(0), count_(0) {}
-
-CpuThreadPoseUpdater::~CpuThreadPoseUpdater() { StopAndJoin(); }
-
-void CpuThreadPoseUpdater::Start(volatile RawPosePair* mapped_pose_buffer,
- int period_us) {
- mapped_pose_buffer_ = mapped_pose_buffer;
- update_period_us_ = period_us;
- stop_request_ = false;
-
- // First buffer is odd (starts at 1), second is even (starts at 2).
- count_ = 0;
- mapped_pose_buffer_->pose1.Reset(++count_);
- mapped_pose_buffer_->pose2.Reset(++count_);
-
- update_thread_ = std::thread(&CpuThreadPoseUpdater::UpdateThread, this);
-}
-
-void CpuThreadPoseUpdater::StopAndJoin() {
- stop_request_ = true;
- if (update_thread_.joinable()) {
- update_thread_.join();
- }
-}
-
-void CpuThreadPoseUpdater::UpdateThread() {
- prctl(PR_SET_NAME, reinterpret_cast<intptr_t>("CpuPoseUpdater"),
- 0, 0, 0);
-
- ATRACE_NAME(__PRETTY_FUNCTION__);
- for (;;) {
- if (stop_request_) {
- break;
- }
-
- ++count_;
-
- // Choose the writable pose based on whether count is odd or even.
- volatile RawPose* out_pose = nullptr;
- if (count_ & 1) {
- out_pose = &mapped_pose_buffer_->pose1;
- } else {
- out_pose = &mapped_pose_buffer_->pose2;
- }
-
- {
- ATRACE_NAME("GetPose");
- Posef pose = pose_tracker_.GetPose(GetSystemClockNs());
- out_pose->qx = pose.GetRotation().x();
- out_pose->qy = pose.GetRotation().y();
- out_pose->qz = pose.GetRotation().z();
- out_pose->qw = pose.GetRotation().w();
- out_pose->px = pose.GetPosition()[0];
- out_pose->py = pose.GetPosition()[1];
- out_pose->pz = pose.GetPosition()[2];
- // Atomically store the count so that it hits memory last:
- out_pose->count.store(count_, std::memory_order_release);
- }
-
- // Sleep to simulate the IMU update process.
- usleep(update_period_us_);
- // TODO(jbates) sleep_for returns immediately, we need to fix our toolchain!
- // int64_t c1 = GetSystemClockNs();
- // std::this_thread::sleep_for(std::chrono::milliseconds(10));
- // int64_t c2 = GetSystemClockNs();
- // fprintf(stderr, "%lld us\n", (long long)(c2 - c1) / 1000);
- }
-}
-
-} // namesapce dvr
-} // namesapce android
diff --git a/libs/vr/libeds/device_metrics.cpp b/libs/vr/libeds/device_metrics.cpp
new file mode 100644
index 0000000..50c3e54
--- /dev/null
+++ b/libs/vr/libeds/device_metrics.cpp
@@ -0,0 +1,182 @@
+#include <private/dvr/device_metrics.h>
+
+#include <cutils/properties.h>
+#include <private/dvr/head_mount_metrics.h>
+#include <private/dvr/identity_distortion.h>
+#include <private/dvr/lookup_radial_distortion.h>
+#include <private/dvr/polynomial_radial_distortion.h>
+#include <private/dvr/types.h>
+#include "include/private/dvr/display_metrics.h"
+
+namespace {
+
+static constexpr char kRGBPolynomialOffset[] = "persist.dvr.rgb_poly_offset";
+static constexpr char kRPolynomial[] = "persist.dvr.r_poly";
+static constexpr char kGPolynomial[] = "persist.dvr.g_poly";
+static constexpr char kBPolynomial[] = "persist.dvr.b_poly";
+static constexpr char kLensDistance[] = "persist.dvr.lens_distance";
+static constexpr char kDisplayGap[] = "persist.dvr.display_gap";
+static constexpr char kVEyeToDisplay[] = "persist.dvr.v_eye_to_display";
+static constexpr char kFovIOBT[] = "persist.dvr.fov_iobt";
+static constexpr char kScreenSize[] = "persist.dvr.screen_size";
+
+bool StringToFloat(const char* str, float* result) {
+ char* endptr = nullptr;
+ *result = std::strtof(str, &endptr);
+ return !(str == endptr || !endptr);
+}
+
+std::vector<std::string> SplitString(const std::string& string_to_split,
+ char deliminator) {
+ std::vector<std::string> result;
+ std::string sub_string;
+ std::stringstream ss(string_to_split);
+ while (std::getline(ss, sub_string, deliminator))
+ result.push_back(sub_string);
+ return result;
+}
+
+std::vector<float> GetProperty(const char* name,
+ const std::vector<float>& default_values) {
+ char prop[PROPERTY_VALUE_MAX + 1] = {};
+ property_get(name, prop, "");
+ std::vector<std::string> values = SplitString(prop, ',');
+ std::vector<float> results;
+ for (const auto& value : values) {
+ float result = 0.0f;
+ if (StringToFloat(value.c_str(), &result)) {
+ results.push_back(static_cast<float>(result));
+ }
+ }
+ if (results.empty()) {
+ return default_values;
+ }
+ return results;
+}
+
+float GetProperty(const char* name, float default_value) {
+ char prop[PROPERTY_VALUE_MAX + 1] = {};
+ property_get(name, prop, "");
+ float result = 0.0f;
+ if (StringToFloat(prop, &result)) {
+ return static_cast<float>(result);
+ }
+ return default_value;
+}
+
+float GetInterLensDistance() { return GetProperty(kLensDistance, 0.064f); }
+
+float GetDisplayGap() { return GetProperty(kDisplayGap, 0.0f); }
+
+float GetVEyeToDisplay() { return GetProperty(kVEyeToDisplay, 0.035f); }
+
+android::dvr::vec2 GetDisplaySize() {
+ static const std::vector<float> default_size = {0.0742177f, 0.131943f};
+ std::vector<float> sizes = GetProperty(kScreenSize, default_size);
+ if (sizes.size() != 0)
+ sizes = default_size;
+ return android::dvr::vec2(sizes[0], sizes[1]);
+}
+
+std::vector<float> GetMaxFOVs() {
+ static const std::vector<float> defaults = {43.7f, 47.8f, 54.2f, 54.2f};
+ std::vector<float> fovs = GetProperty(kFovIOBT, defaults);
+ if (fovs.size() != 4)
+ fovs = defaults;
+ for (auto& value : fovs) {
+ value = value * M_PI / 180.0f;
+ }
+ return fovs;
+}
+
+static const android::dvr::HeadMountMetrics::VerticalAlignment
+ kDefaultVerticalAlignment = android::dvr::HeadMountMetrics::kCenter;
+
+// Default border size in meters.
+static const float kScreenBorderSize = 0.004f;
+
+// Refresh rate.
+static const float kScreenRefreshRate = 60.0f;
+
+// Default display orientation is portrait.
+static const android::dvr::DisplayOrientation kDisplayOrientation =
+ android::dvr::DisplayOrientation::kPortrait;
+
+} // anonymous namespace
+
+namespace android {
+namespace dvr {
+
+HeadMountMetrics CreateHeadMountMetrics(const FieldOfView& l_fov,
+ const FieldOfView& r_fov) {
+ static const std::vector<float> default_r = {
+ -4.08519004f, 34.70282075f, -67.37781249f, 56.97304235f,
+ -23.35768685f, 4.7199597f, 0.63198082f};
+ static const std::vector<float> default_g = {
+ 4.43078318f, 3.47806617f, -20.58017398f, 20.85880414f,
+ -8.4046504f, 1.61284685f, 0.8881761f};
+ static const std::vector<float> default_b = {
+ 12.04141265f, -21.98112491f, 14.06758389f, -3.15245629f,
+ 0.36549102f, 0.05252705f, 0.99844279f};
+ static const std::vector<float> default_offsets = {
+ 0.20971645238f, 0.15189450000f, 1.00096958278f};
+
+ std::vector<float> poly_offsets =
+ GetProperty(kRGBPolynomialOffset, default_offsets);
+ std::vector<float> poly_r = GetProperty(kRPolynomial, default_r);
+ std::vector<float> poly_g = GetProperty(kGPolynomial, default_g);
+ std::vector<float> poly_b = GetProperty(kBPolynomial, default_b);
+ if (poly_offsets.size() != 3)
+ poly_offsets = default_offsets;
+
+ std::shared_ptr<ColorChannelDistortion> distortion_r(
+ new PolynomialRadialDistortion(poly_offsets[0], poly_r));
+ std::shared_ptr<ColorChannelDistortion> distortion_g(
+ new PolynomialRadialDistortion(poly_offsets[1], poly_g));
+ std::shared_ptr<ColorChannelDistortion> distortion_b(
+ new PolynomialRadialDistortion(poly_offsets[2], poly_b));
+
+ return HeadMountMetrics(GetInterLensDistance(), GetVEyeToDisplay(),
+ GetVEyeToDisplay(), kDefaultVerticalAlignment, l_fov,
+ r_fov, distortion_r, distortion_g, distortion_b,
+ HeadMountMetrics::EyeOrientation::kCCW0Degrees,
+ HeadMountMetrics::EyeOrientation::kCCW0Degrees,
+ (GetInterLensDistance() - GetDisplayGap()) / 2.0f);
+}
+
+HeadMountMetrics CreateHeadMountMetrics() {
+ std::vector<float> fovs = GetMaxFOVs();
+ FieldOfView l_fov(fovs[1], fovs[0], fovs[2], fovs[3]);
+ FieldOfView r_fov(fovs[0], fovs[1], fovs[2], fovs[3]);
+ return CreateHeadMountMetrics(l_fov, r_fov);
+}
+
+DisplayMetrics CreateDisplayMetrics(vec2i screen_size) {
+ android::dvr::vec2 size_in_meters = GetDisplaySize();
+ vec2 meters_per_pixel(size_in_meters[0] / static_cast<float>(screen_size[0]),
+ size_in_meters[1] / static_cast<float>(screen_size[1]));
+ return DisplayMetrics(screen_size, meters_per_pixel, kScreenBorderSize,
+ 1000.0f / kScreenRefreshRate, kDisplayOrientation);
+}
+
+HeadMountMetrics CreateUndistortedHeadMountMetrics() {
+ std::vector<float> fovs = GetMaxFOVs();
+ FieldOfView l_fov(fovs[1], fovs[0], fovs[2], fovs[3]);
+ FieldOfView r_fov(fovs[0], fovs[1], fovs[2], fovs[3]);
+ return CreateUndistortedHeadMountMetrics(l_fov, r_fov);
+}
+
+HeadMountMetrics CreateUndistortedHeadMountMetrics(const FieldOfView& l_fov,
+ const FieldOfView& r_fov) {
+ auto distortion_all = std::make_shared<IdentityDistortion>();
+
+ return HeadMountMetrics(GetInterLensDistance(), GetVEyeToDisplay(),
+ GetVEyeToDisplay(), kDefaultVerticalAlignment, l_fov,
+ r_fov, distortion_all, distortion_all, distortion_all,
+ HeadMountMetrics::EyeOrientation::kCCW0Degrees,
+ HeadMountMetrics::EyeOrientation::kCCW0Degrees,
+ (GetInterLensDistance() - GetDisplayGap()) / 2.0f);
+}
+
+} // namespace dvr
+} // namespace android
diff --git a/libs/vr/libeds/include/private/dvr/cpu_thread_pose_updater.h b/libs/vr/libeds/include/private/dvr/cpu_thread_pose_updater.h
deleted file mode 100644
index 6a2c8a6..0000000
--- a/libs/vr/libeds/include/private/dvr/cpu_thread_pose_updater.h
+++ /dev/null
@@ -1,48 +0,0 @@
-#ifndef ANDROID_DVR_CPU_THREAD_POSE_UPDATER_H_
-#define ANDROID_DVR_CPU_THREAD_POSE_UPDATER_H_
-
-#include <atomic>
-#include <thread>
-
-#include <private/dvr/lucid_pose_tracker.h>
-#include <private/dvr/raw_pose.h>
-
-namespace android {
-namespace dvr {
-
-// Temporary version of pose updater that uses a CPU thread to update
-// the pose buffer. Note that this thread starts and runs indefinitely
-class CpuThreadPoseUpdater {
- public:
- CpuThreadPoseUpdater();
- ~CpuThreadPoseUpdater();
-
- // Start the thread to update the given buffer with the given number of
- // microseconds between updates.
- void Start(volatile RawPosePair* mapped_pose_buffer, int period_us);
-
- void StopAndJoin();
-
- private:
- void UpdateThread();
-
- volatile RawPosePair* mapped_pose_buffer_;
-
- // Pose update thread.
- std::thread update_thread_;
-
- volatile bool stop_request_;
-
- // Update period in microseconds.
- int update_period_us_;
-
- // Current pose count, used to avoid writing to the same buffer that is being
- // read by the GPU.
- uint32_t count_;
- LucidPoseTracker pose_tracker_;
-};
-
-} // namespace dvr
-} // namespace android
-
-#endif // ANDROID_DVR_CPU_THREAD_POSE_UPDATER_H_
diff --git a/libs/vr/libeds/include/private/dvr/lucid_metrics.h b/libs/vr/libeds/include/private/dvr/device_metrics.h
similarity index 84%
rename from libs/vr/libeds/include/private/dvr/lucid_metrics.h
rename to libs/vr/libeds/include/private/dvr/device_metrics.h
index 0e4ada4..7985f28 100644
--- a/libs/vr/libeds/include/private/dvr/lucid_metrics.h
+++ b/libs/vr/libeds/include/private/dvr/device_metrics.h
@@ -1,5 +1,5 @@
-#ifndef ANDROID_DVR_LUCID_METRICS_H_
-#define ANDROID_DVR_LUCID_METRICS_H_
+#ifndef ANDROID_DVR_DEVICE_METRICS_H_
+#define ANDROID_DVR_DEVICE_METRICS_H_
#include <private/dvr/display_metrics.h>
#include <private/dvr/head_mount_metrics.h>
@@ -19,4 +19,4 @@
} // namespace dvr
} // namespace android
-#endif // ANDROID_DVR_LUCID_METRICS_H_
+#endif // ANDROID_DVR_DEVICE_METRICS_H_
diff --git a/libs/vr/libeds/include/private/dvr/distortion_renderer.h b/libs/vr/libeds/include/private/dvr/distortion_renderer.h
index e1c8114..28fd48a 100644
--- a/libs/vr/libeds/include/private/dvr/distortion_renderer.h
+++ b/libs/vr/libeds/include/private/dvr/distortion_renderer.h
@@ -9,7 +9,6 @@
#include <private/dvr/eds_mesh.h>
#include <private/dvr/graphics/shader_program.h>
#include <private/dvr/late_latch.h>
-#include <private/dvr/lucid_pose_tracker.h>
#include <private/dvr/render_texture_params.h>
#include <private/dvr/types.h>
diff --git a/libs/vr/libeds/include/private/dvr/lucid_pose_tracker.h b/libs/vr/libeds/include/private/dvr/lucid_pose_tracker.h
deleted file mode 100644
index 4ceda5a..0000000
--- a/libs/vr/libeds/include/private/dvr/lucid_pose_tracker.h
+++ /dev/null
@@ -1,49 +0,0 @@
-#ifndef ANDROID_DVR_LUCID_POSE_TRACKER_H_
-#define ANDROID_DVR_LUCID_POSE_TRACKER_H_
-
-#include <memory>
-
-#include <dvr/pose_client.h>
-
-#include <private/dvr/types.h>
-
-namespace android {
-namespace dvr {
-
-// Provides pose tracking via the system pose service.
-class LucidPoseTracker {
- public:
- // When set, the pose service is ignored and the given pose is always returned
- // by GetPose. As long as this is called before any LucidPoseTracker is
- // used, the pose service will not be created.
- // Threading: this is not thread safe.
- static void SetPoseOverride(const Posef& pose);
-
- // Reset prior override pose.
- static void ClearPoseOverride();
-
- LucidPoseTracker();
- ~LucidPoseTracker();
-
- // Currently GetPose() will ignore timestamp_ns and always return the most
- // recent orientation.
- // TODO(stefanus): support prediction.
- Posef GetPose(uint64_t timestamp_ns);
-
- private:
- static bool is_override_pose_;
- static Posef override_pose_;
-
- DvrPose* pose_client_;
-
- // The most recent pose.
- Posef latest_pose_;
-
- // The time stamp corresponding to when latest_pose_ was last updated.
- uint64_t latest_timestamp_ns_;
-};
-
-} // namespace dvr
-} // namespace android
-
-#endif // ANDROID_DVR_LUCID_POSE_TRACKER_H_
diff --git a/libs/vr/libeds/include/private/dvr/polynomial_radial_distortion.h b/libs/vr/libeds/include/private/dvr/polynomial_radial_distortion.h
index 8f080aa..c1f1ce9 100644
--- a/libs/vr/libeds/include/private/dvr/polynomial_radial_distortion.h
+++ b/libs/vr/libeds/include/private/dvr/polynomial_radial_distortion.h
@@ -28,7 +28,8 @@
// in the distortion equation: coefficients[0] is K1, coefficients[1] is K2,
// etc. Thus the polynomial used for distortion has degree
// (2 * coefficients.size()).
- explicit PolynomialRadialDistortion(const std::vector<float>& coefficients);
+ explicit PolynomialRadialDistortion(float polynomial_offset,
+ const std::vector<float>& coefficients);
// Given a radius (measuring distance from the optical axis of the lens),
// returns the distortion factor for that radius.
@@ -51,6 +52,10 @@
const std::vector<float>& GetCoefficients() const;
private:
+ // This is makes the polynomial work nicer with a specific lens that doesn't
+ // fit nicely to a lower order polynomial. It's basically piecewise
+ // line->poly.
+ float polynomial_offset_;
std::vector<float> coefficients_;
};
diff --git a/libs/vr/libeds/lucid_metrics.cpp b/libs/vr/libeds/lucid_metrics.cpp
deleted file mode 100644
index 690c326..0000000
--- a/libs/vr/libeds/lucid_metrics.cpp
+++ /dev/null
@@ -1,327 +0,0 @@
-#include "include/private/dvr/display_metrics.h"
-#include <private/dvr/head_mount_metrics.h>
-#include <private/dvr/identity_distortion.h>
-#include <private/dvr/lookup_radial_distortion.h>
-#include <private/dvr/lucid_metrics.h>
-#include <private/dvr/types.h>
-
-namespace {
-
-// These numbers are specific to the OnePlus One and therefore
-// temporary until we advance to the next Lucid development platform.
-
-// Head mount metrics for Lucid A00
-static const float kDefaultInterLensDistance = 0.064f; // 64mm
-static const float kDefaultTrayToLensDistance = 0.035f;
-static const float kDefaultVirtualEyeToScreenDistance = 0.042f;
-static const android::dvr::HeadMountMetrics::VerticalAlignment
- kDefaultVerticalAlignment = android::dvr::HeadMountMetrics::kCenter;
-static const float kDefaultFovHalfAngleInsideH = 43.7f * M_PI / 180.0f;
-static const float kDefaultFovHalfAngleOutsideH = 47.8f * M_PI / 180.0f;
-static const float kDefaultFovHalfAngleV = 54.2f * M_PI / 180.0f;
-
-// Screen size in meters for Lucid (Nexus 6 display in portrait mode).
-static const android::dvr::vec2 kScreenSizeInMeters(0.0742177f, 0.131943f);
-
-// Border size in meters for the OnePlus One.
-static const float kScreenBorderSize = 0.004f;
-
-// Refresh rate.
-static const float kScreenRefreshRate = 60.0f;
-
-// Lucid display orientation is portrait.
-static const android::dvr::DisplayOrientation kDisplayOrientation =
- android::dvr::DisplayOrientation::kPortrait;
-
-} // anonymous namespace
-
-namespace android {
-namespace dvr {
-
-// The distortion lookup tables were generated via a raytraced lens simulation.
-// Please see for full calculations:
-// https://docs.google.com/a/google.com/spreadsheets/d/
-// 15cfHmCw5mHVOQ1rAJxMhta4q0e8zzcUDka1nRkfl7pY/edit?usp=sharing
-LookupRadialDistortion* GetBlueDistortionLookup() {
- // clang-format off
- vec2 kBlueDistortionLookup[] = {
- {0.00000000000f, 1.00000000000f},
- {0.01888626190f, 1.00096958278f},
- {0.03777223810f, 1.00133301793f},
- {0.05665761905f, 1.00193985168f},
- {0.07554214286f, 1.00279048731f},
- {0.09442542857f, 1.00388751781f},
- {0.11330704762f, 1.00523363045f},
- {0.13218657143f, 1.00683149424f},
- {0.15106340476f, 1.00868516849f},
- {0.16993695238f, 1.01079861126f},
- {0.18880640476f, 1.01317712726f},
- {0.20767092857f, 1.01582607321f},
- {0.22652945238f, 1.01875203063f},
- {0.24538078571f, 1.02196207850f},
- {0.26422352381f, 1.02546421601f},
- {0.28305602381f, 1.02926737969f},
- {0.30187640476f, 1.03338139216f},
- {0.32068252381f, 1.03781702504f},
- {0.33947190476f, 1.04258620905f},
- {0.35824171429f, 1.04770206653f},
- {0.37698869048f, 1.05317909331f},
- {0.39570916667f, 1.05903306635f},
- {0.41439900000f, 1.06528124790f},
- {0.43305350000f, 1.07194257391f},
- {0.45166738095f, 1.07903777957f},
- {0.47023471429f, 1.08658953759f},
- {0.48874897619f, 1.09462239798f},
- {0.50720285714f, 1.10316330018f},
- {0.52558835714f, 1.11224144183f},
- {0.54389669048f, 1.12188861421f},
- {0.56211826190f, 1.13213939967f},
- {0.58024261905f, 1.14303145047f},
- {0.59825847619f, 1.15460566091f},
- {0.61615335714f, 1.16690711338f},
- {0.63391345238f, 1.17998560444f},
- {0.65152300000f, 1.19389708987f},
- {0.66896328571f, 1.20870580446f},
- {0.68621100000f, 1.22448751087f},
- {0.70323578571f, 1.24133415620f},
- {0.71999716667f, 1.25935962776f},
- {0.73643969048f, 1.27870875648f},
- {0.75250778571f, 1.29953256670f},
- {0.76817614286f, 1.32193822000f},
- {0.78342009524f, 1.34604270338f},
- {0.79828314286f, 1.37185833833f},
- {0.81267376190f, 1.39964322604f},
- {0.82656559524f, 1.42955958262f},
- {0.83983054762f, 1.46196539657f},
- {0.85234333333f, 1.49724142650f},
- {0.86394971429f, 1.53585530271f},
- {0.87422461905f, 1.57881139444f},
- {0.88382583095f, 1.62091537826f},
- {0.89571361286f, 1.67610209261f},
- {0.90490389167f, 1.72118819668f},
- {0.91526452143f, 1.77496904481f},
- {0.92651365452f, 1.83722833673f},
- {0.93437489976f, 1.88337590145f},
- {0.94654105500f, 1.95937892848f},
- {0.95476685095f, 2.01469745492f},
- {0.96720383310f, 2.10451495481f},
- {0.97546726405f, 2.16904926656f},
- {0.98774046786f, 2.27302748020f},
- {0.99579206762f, 2.34720582421f},
- {1.00763328857f, 2.46603526105f},
- {1.01533118405f, 2.55049232288f},
- {1.02287120929f, 2.63936582235f}
- };
- // clang-format on
- return new LookupRadialDistortion(
- kBlueDistortionLookup, sizeof(kBlueDistortionLookup) / sizeof(vec2));
-}
-
-LookupRadialDistortion* GetGreenDistortionLookup() {
- // clang-format off
- vec2 kGreenDistortionLookup[] = {
- {0.00000000000f, 1.00000000000f},
- {0.01898883333f, 1.00000000000f},
- {0.03797750000f, 1.00000000000f},
- {0.05696585714f, 1.00000000000f},
- {0.07595369048f, 1.00000000000f},
- {0.09494078571f, 1.00000000000f},
- {0.11392685714f, 1.00000000000f},
- {0.13291157143f, 1.00000000000f},
- {0.15189450000f, 1.00176560670f},
- {0.17087511905f, 1.00384553961f},
- {0.18985280952f, 1.00618614484f},
- {0.20882680952f, 1.00879302066f},
- {0.22779623810f, 1.01167234096f},
- {0.24675997619f, 1.01483135203f},
- {0.26571680952f, 1.01827767641f},
- {0.28466519048f, 1.02202026825f},
- {0.30360342857f, 1.02606859705f},
- {0.32252950000f, 1.03043334057f},
- {0.34144104762f, 1.03512630376f},
- {0.36033538095f, 1.04016038545f},
- {0.37920942857f, 1.04554970984f},
- {0.39805966667f, 1.05130981266f},
- {0.41688209524f, 1.05745768999f},
- {0.43567214286f, 1.06401204155f},
- {0.45442473810f, 1.07099310305f},
- {0.47313411905f, 1.07842314596f},
- {0.49179388095f, 1.08632639514f},
- {0.51039692857f, 1.09472920992f},
- {0.52893538095f, 1.10366038032f},
- {0.54740061905f, 1.11315113705f},
- {0.56578326190f, 1.12323535769f},
- {0.58407300000f, 1.13395008040f},
- {0.60225871429f, 1.14533547370f},
- {0.62032809524f, 1.15743581542f},
- {0.63826750000f, 1.17030000749f},
- {0.65606135714f, 1.18398295206f},
- {0.67369107143f, 1.19854780583f},
- {0.69113350000f, 1.21406895255f},
- {0.70835842857f, 1.23063670464f},
- {0.72532545238f, 1.24836302903f},
- {0.74197478571f, 1.26739777609f},
- {0.75822164286f, 1.28793886907f},
- {0.77407361905f, 1.31003521318f},
- {0.78948523810f, 1.33383710115f},
- {0.80448471429f, 1.35938255065f},
- {0.81901733333f, 1.38686361242f},
- {0.83305214286f, 1.41644808409f},
- {0.84646438095f, 1.44848277406f},
- {0.85912733333f, 1.48334485259f},
- {0.87088369048f, 1.52149970074f},
- {0.88131250000f, 1.56392750036f},
- {0.89105132929f, 1.60552684742f},
- {0.90312479476f, 1.66002695068f},
- {0.91244067452f, 1.70458805205f},
- {0.92297971714f, 1.75767475825f},
- {0.93440940905f, 1.81916050294f},
- {0.94237194976f, 1.86478635937f},
- {0.95471202405f, 1.93989738862f},
- {0.96305355738f, 1.99457325750f},
- {0.97567372071f, 2.08333293385f},
- {0.98407229071f, 2.14708073108f},
- {0.99653762071f, 2.24981649552f},
- {1.00471276167f, 2.32311751786f},
- {1.01672394000f, 2.44057411530f},
- {1.02452363381f, 2.52407947994f},
- {1.03216732667f, 2.61194301580f}
- };
- // clang-format on
- return new LookupRadialDistortion(
- kGreenDistortionLookup, sizeof(kGreenDistortionLookup) / sizeof(vec2));
-}
-
-LookupRadialDistortion* GetRedDistortionLookup() {
- // clang-format off
- vec2 kRedDistortionLookup[] = {
- {0.00000000000f, 1.00000000000f},
- {0.01906776190f, 1.00000000000f},
- {0.03813547619f, 1.00000000000f},
- {0.05720304762f, 1.00000000000f},
- {0.07627040476f, 1.00000000000f},
- {0.09533740476f, 1.00000000000f},
- {0.11440385714f, 1.00000000000f},
- {0.13346952381f, 1.00000000000f},
- {0.15253409524f, 1.00000000000f},
- {0.17159714286f, 1.00000000000f},
- {0.19065814286f, 1.00053530030f},
- {0.20971645238f, 1.00310924426f},
- {0.22877123810f, 1.00595236192f},
- {0.24782154762f, 1.00907150786f},
- {0.26686623810f, 1.01247435420f},
- {0.28590388095f, 1.01616968529f},
- {0.30493288095f, 1.02016688932f},
- {0.32395133333f, 1.02447646681f},
- {0.34295697619f, 1.02911011406f},
- {0.36194726190f, 1.03408046560f},
- {0.38091921429f, 1.03940151599f},
- {0.39986942857f, 1.04508858434f},
- {0.41879402381f, 1.05115843585f},
- {0.43768857143f, 1.05762946333f},
- {0.45654809524f, 1.06452169646f},
- {0.47536695238f, 1.07185711363f},
- {0.49413888095f, 1.07965956927f},
- {0.51285690476f, 1.08795508025f},
- {0.53151326190f, 1.09677206014f},
- {0.55009952381f, 1.10614118417f},
- {0.56860633333f, 1.11609607621f},
- {0.58702361905f, 1.12667304464f},
- {0.60534028571f, 1.13791190276f},
- {0.62354421429f, 1.14985618930f},
- {0.64162188095f, 1.16255413653f},
- {0.65955780952f, 1.17605992962f},
- {0.67733352381f, 1.19043584317f},
- {0.69492602381f, 1.20575517508f},
- {0.71230514286f, 1.22210708787f},
- {0.72943057143f, 1.23960199799f},
- {0.74623921429f, 1.25839340501f},
- {0.76262400000f, 1.27871385661f},
- {0.77861754762f, 1.30056919119f},
- {0.79415866667f, 1.32413401001f},
- {0.80926385714f, 1.34946540639f},
- {0.82390640476f, 1.37670655635f},
- {0.83805190476f, 1.40602920817f},
- {0.85157807143f, 1.43777181543f},
- {0.86435700000f, 1.47230885729f},
- {0.87622914286f, 1.51010361811f},
- {0.88677650000f, 1.55211817236f},
- {0.89663317738f, 1.59330127207f},
- {0.90883197952f, 1.64729627820f},
- {0.91827594357f, 1.69138814689f},
- {0.92892199405f, 1.74398939784f},
- {0.94047261548f, 1.80490554711f},
- {0.94852659262f, 1.85009630648f},
- {0.96099790167f, 1.92451421938f},
- {0.96945317500f, 1.97863645920f},
- {0.98221554286f, 2.06656418112f},
- {0.99069599476f, 2.12974390154f},
- {1.00331392976f, 2.23149730290f},
- {1.01157138762f, 2.30414058939f},
- {1.02372409452f, 2.42049694265f},
- {1.03162992905f, 2.50318810924f},
- {1.03934762000f, 2.59027212626f}
- };
- // clang-format on
- return new LookupRadialDistortion(
- kRedDistortionLookup, sizeof(kRedDistortionLookup) / sizeof(vec2));
-}
-
-HeadMountMetrics CreateHeadMountMetrics(const FieldOfView& l_fov,
- const FieldOfView& r_fov) {
- std::shared_ptr<ColorChannelDistortion> default_distortion_r(
- GetRedDistortionLookup());
- std::shared_ptr<ColorChannelDistortion> default_distortion_g(
- GetGreenDistortionLookup());
- std::shared_ptr<ColorChannelDistortion> default_distortion_b(
- GetBlueDistortionLookup());
-
- return HeadMountMetrics(
- kDefaultInterLensDistance, kDefaultTrayToLensDistance,
- kDefaultVirtualEyeToScreenDistance, kDefaultVerticalAlignment, l_fov,
- r_fov, default_distortion_r, default_distortion_g, default_distortion_b,
- HeadMountMetrics::EyeOrientation::kCCW0Degrees,
- HeadMountMetrics::EyeOrientation::kCCW0Degrees,
- kDefaultInterLensDistance / 2.0f);
-}
-
-HeadMountMetrics CreateHeadMountMetrics() {
- FieldOfView l_fov(kDefaultFovHalfAngleOutsideH, kDefaultFovHalfAngleInsideH,
- kDefaultFovHalfAngleV, kDefaultFovHalfAngleV);
- FieldOfView r_fov(kDefaultFovHalfAngleInsideH, kDefaultFovHalfAngleOutsideH,
- kDefaultFovHalfAngleV, kDefaultFovHalfAngleV);
-
- return CreateHeadMountMetrics(l_fov, r_fov);
-}
-
-DisplayMetrics CreateDisplayMetrics(vec2i screen_size) {
- vec2 meters_per_pixel(
- kScreenSizeInMeters[0] / static_cast<float>(screen_size[0]),
- kScreenSizeInMeters[1] / static_cast<float>(screen_size[1]));
- return DisplayMetrics(screen_size, meters_per_pixel, kScreenBorderSize,
- 1000.0f / kScreenRefreshRate, kDisplayOrientation);
-}
-
-HeadMountMetrics CreateUndistortedHeadMountMetrics() {
- FieldOfView l_fov(kDefaultFovHalfAngleOutsideH, kDefaultFovHalfAngleInsideH,
- kDefaultFovHalfAngleV, kDefaultFovHalfAngleV);
- FieldOfView r_fov(kDefaultFovHalfAngleInsideH, kDefaultFovHalfAngleOutsideH,
- kDefaultFovHalfAngleV, kDefaultFovHalfAngleV);
- return CreateUndistortedHeadMountMetrics(l_fov, r_fov);
-}
-
-HeadMountMetrics CreateUndistortedHeadMountMetrics(const FieldOfView& l_fov,
- const FieldOfView& r_fov) {
- auto distortion_all = std::make_shared<IdentityDistortion>();
-
- return HeadMountMetrics(kDefaultInterLensDistance, kDefaultTrayToLensDistance,
- kDefaultVirtualEyeToScreenDistance,
- kDefaultVerticalAlignment, l_fov, r_fov,
- distortion_all, distortion_all, distortion_all,
- HeadMountMetrics::EyeOrientation::kCCW0Degrees,
- HeadMountMetrics::EyeOrientation::kCCW0Degrees,
- kDefaultInterLensDistance / 2.0f);
-}
-
-} // namespace dvr
-} // namespace dvr
diff --git a/libs/vr/libeds/lucid_pose_tracker.cpp b/libs/vr/libeds/lucid_pose_tracker.cpp
deleted file mode 100644
index 5247020..0000000
--- a/libs/vr/libeds/lucid_pose_tracker.cpp
+++ /dev/null
@@ -1,90 +0,0 @@
-#include "include/private/dvr/lucid_pose_tracker.h"
-
-#define LOG_TAG "LucidPoseTracker"
-#include <log/log.h>
-
-#include <private/dvr/clock_ns.h>
-
-namespace android {
-namespace dvr {
-
-bool LucidPoseTracker::is_override_pose_ = false;
-Posef LucidPoseTracker::override_pose_ = Posef();
-
-void LucidPoseTracker::SetPoseOverride(const Posef& pose) {
- is_override_pose_ = true;
- override_pose_ = pose;
-}
-
-void LucidPoseTracker::ClearPoseOverride() {
- is_override_pose_ = false;
- override_pose_ = Posef();
-}
-
-LucidPoseTracker::LucidPoseTracker() : pose_client_(NULL) {}
-
-LucidPoseTracker::~LucidPoseTracker() {
- if (pose_client_) {
- dvrPoseDestroy(pose_client_);
- }
-}
-
-Posef LucidPoseTracker::GetPose(uint64_t timestamp_ns) {
- if (is_override_pose_) {
- return override_pose_;
- }
-
- if (!pose_client_) {
- pose_client_ = dvrPoseCreate();
-
- if (!pose_client_) {
- ALOGE("No pose service, returning identity pose");
- return Posef();
- }
- }
-
- DvrPoseState state;
- dvrPosePoll(pose_client_, &state);
-
- const vec4 head_rotation_in_start_quat(
- state.head_from_start_rotation.x, state.head_from_start_rotation.y,
- state.head_from_start_rotation.z, state.head_from_start_rotation.w);
-
- // When the pose service hasn't computed a pose yet, it returns a zero
- // quaternion; just use the identity rotation in that case.
- // TODO(stefanus): Find a better way to signal and check this.
- if (head_rotation_in_start_quat.squaredNorm() < 0.5f) {
- latest_pose_.SetRotation(quat::Identity());
- } else {
- latest_pose_.SetRotation(
- quat(head_rotation_in_start_quat.w(), head_rotation_in_start_quat.x(),
- head_rotation_in_start_quat.y(), head_rotation_in_start_quat.z())
- .normalized());
- }
-
- const vec3 head_position_in_start(state.head_from_start_translation.x,
- state.head_from_start_translation.y,
- state.head_from_start_translation.z);
- latest_pose_.SetPosition(head_position_in_start);
-
- latest_timestamp_ns_ = GetSystemClockNs();
-
- // PoseState pose_state;
- // pose_state.timestamp_ns = latest_timestamp_ns_;
- // pose_state.sensor_from_start_rotation =
- // ion::math::Rotationd::FromQuaternion(ion::math::Vector4d(
- // state.head_from_start_rotation.x, state.head_from_start_rotation.y,
- // state.head_from_start_rotation.z,
- // state.head_from_start_rotation.w));
- //// TODO(stefanus): Determine the first derivative of the rotation and set it
- //// here.
- // pose_state.sensor_from_start_rotation_velocity =
- // ion::math::Vector3d::Zero();
-
- // TODO(stefanus): perform prediction.
-
- return latest_pose_;
-}
-
-} // namespace dvr
-} // namespace android
diff --git a/libs/vr/libeds/polynomial_radial_distortion.cpp b/libs/vr/libeds/polynomial_radial_distortion.cpp
index fa01bb4..a0c6ea3 100644
--- a/libs/vr/libeds/polynomial_radial_distortion.cpp
+++ b/libs/vr/libeds/polynomial_radial_distortion.cpp
@@ -4,10 +4,13 @@
namespace dvr {
PolynomialRadialDistortion::PolynomialRadialDistortion(
- const std::vector<float>& coefficients)
- : coefficients_(coefficients) {}
+ float polynomial_offset, const std::vector<float>& coefficients)
+ : polynomial_offset_(polynomial_offset), coefficients_(coefficients) {}
float PolynomialRadialDistortion::DistortionFactor(float r_squared) const {
+ if (r_squared < polynomial_offset_)
+ return 1.0f;
+
float r_factor = 1.0f;
float distortion_factor = 1.0f;
diff --git a/libs/vr/libvrflinger/compositor.cpp b/libs/vr/libvrflinger/compositor.cpp
index 5a111d4..07e4a8b 100644
--- a/libs/vr/libvrflinger/compositor.cpp
+++ b/libs/vr/libvrflinger/compositor.cpp
@@ -13,12 +13,12 @@
#include <private/dvr/buffer_hub_client.h>
#include <private/dvr/clock_ns.h>
#include <private/dvr/debug.h>
+#include <private/dvr/device_metrics.h>
#include <private/dvr/display_types.h>
#include <private/dvr/dummy_native_window.h>
#include <private/dvr/gl_fenced_flush.h>
#include <private/dvr/graphics/blur.h>
#include <private/dvr/graphics/gpu_profiler.h>
-#include <private/dvr/lucid_metrics.h>
#include <private/dvr/native_buffer.h>
#include <private/dvr/platform_defines.h>
#include <utils/Log.h>
@@ -403,6 +403,7 @@
}
load_gl_extensions();
+ GpuProfiler::Get()->OnGlContextCreated();
glEnable(BINNING_CONTROL_HINT_QCOM);
glHint(BINNING_CONTROL_HINT_QCOM, RENDER_DIRECT_TO_FRAMEBUFFER_QCOM);
@@ -438,6 +439,7 @@
eds_renderer_.reset();
if (context_) {
+ GpuProfiler::Get()->OnGlContextDestroyed();
eglDestroyContext(display_, context_);
context_ = 0;
}
diff --git a/libs/vr/libvrflinger/display_service.cpp b/libs/vr/libvrflinger/display_service.cpp
index 8cf9d64..971345b 100644
--- a/libs/vr/libvrflinger/display_service.cpp
+++ b/libs/vr/libvrflinger/display_service.cpp
@@ -6,9 +6,9 @@
#include <pdx/default_transport/service_endpoint.h>
#include <pdx/rpc/remote_method.h>
#include <private/dvr/composite_hmd.h>
+#include <private/dvr/device_metrics.h>
#include <private/dvr/display_rpc.h>
#include <private/dvr/display_types.h>
-#include <private/dvr/lucid_metrics.h>
#include <private/dvr/numeric.h>
#include <private/dvr/polynomial_radial_distortion.h>
#include <private/dvr/types.h>
@@ -209,16 +209,16 @@
// We should always have a red distortion.
LOG_FATAL_IF(view_params.distortion_coefficients_r.empty());
red_distortion = std::make_shared<PolynomialRadialDistortion>(
- view_params.distortion_coefficients_r);
+ 0.0f, view_params.distortion_coefficients_r);
if (!view_params.distortion_coefficients_g.empty()) {
green_distortion = std::make_shared<PolynomialRadialDistortion>(
- view_params.distortion_coefficients_g);
+ 0.0f, view_params.distortion_coefficients_g);
}
if (!view_params.distortion_coefficients_b.empty()) {
blue_distortion = std::make_shared<PolynomialRadialDistortion>(
- view_params.distortion_coefficients_b);
+ 0.0f, view_params.distortion_coefficients_b);
}
HeadMountMetrics::EyeOrientation left_orientation =
@@ -331,11 +331,9 @@
int consumer_usage) {
auto named_buffer = named_buffers_.find(name);
if (named_buffer == named_buffers_.end()) {
- // TODO(hendrikw): Update BufferProducer to take producer_usage and
- // consumer_usage flags.
auto ion_buffer = std::make_unique<IonBuffer>(
- static_cast<int>(size), 1, HAL_PIXEL_FORMAT_BLOB,
- producer_usage | consumer_usage);
+ static_cast<int>(size), 1, HAL_PIXEL_FORMAT_BLOB, producer_usage,
+ consumer_usage);
named_buffer =
named_buffers_.insert(std::make_pair(name, std::move(ion_buffer)))
.first;
diff --git a/opengl/libs/EGL/eglApi.cpp b/opengl/libs/EGL/eglApi.cpp
index 0807d1f..9de15d0 100644
--- a/opengl/libs/EGL/eglApi.cpp
+++ b/opengl/libs/EGL/eglApi.cpp
@@ -223,6 +223,10 @@
(__eglMustCastToProperFunctionPointerType)&eglGetFrameTimestampsANDROID },
{ "eglGetFrameTimestampSupportedANDROID",
(__eglMustCastToProperFunctionPointerType)&eglGetFrameTimestampSupportedANDROID },
+
+ // EGL_ANDROID_native_fence_sync
+ { "eglDupNativeFenceFDANDROID",
+ (__eglMustCastToProperFunctionPointerType)&eglDupNativeFenceFDANDROID },
};
/*
@@ -232,8 +236,7 @@
#define FILTER_EXTENSIONS(procname) \
(!strcmp((procname), "eglSetBlobCacheFuncsANDROID") || \
!strcmp((procname), "eglHibernateProcessIMG") || \
- !strcmp((procname), "eglAwakenProcessIMG") || \
- !strcmp((procname), "eglDupNativeFenceFDANDROID"))
+ !strcmp((procname), "eglAwakenProcessIMG"))
diff --git a/services/sensorservice/SensorDirectConnection.cpp b/services/sensorservice/SensorDirectConnection.cpp
index b096e1c..91923b3 100644
--- a/services/sensorservice/SensorDirectConnection.cpp
+++ b/services/sensorservice/SensorDirectConnection.cpp
@@ -185,17 +185,18 @@
struct stat s1, s2;
int fd1, fd2;
fd1 = mMem.handle->data[0];
- fd2 = mem->handle->data[1];
+ fd2 = mem->handle->data[0];
if (fstat(fd1, &s1) < 0 || fstat(fd2, &s2) < 0 || s1.st_ino == s2.st_ino) {
ret = true;
}
break;
}
case SENSOR_DIRECT_MEM_TYPE_GRALLOC:
- LOG_FATAL("%s: Implement GRALLOC or remove", __FUNCTION__);
- ret = true;
+ // there is no known method to test if two gralloc handle are equivalent
+ ret = false;
break;
default:
+ // should never happen
ALOGE("Unexpected mem type %d", mMem.type);
ret = true;
break;
diff --git a/services/sensorservice/SensorService.cpp b/services/sensorservice/SensorService.cpp
index 4d76272..26f9143 100644
--- a/services/sensorservice/SensorService.cpp
+++ b/services/sensorservice/SensorService.cpp
@@ -978,6 +978,7 @@
for (auto &i : mDirectConnections) {
sp<SensorDirectConnection> connection(i.promote());
if (connection != nullptr && connection->isEquivalent(&mem)) {
+ ALOGE("Duplicate create channel request for the same share memory");
return nullptr;
}
}
@@ -988,14 +989,15 @@
int fd = resource->data[0];
int size2 = ashmem_get_size_region(fd);
// check size consistency
- if (size2 != static_cast<int>(size)) {
- ALOGE("Ashmem direct channel size mismatch, %" PRIu32 " vs %d", size, size2);
+ if (size2 < static_cast<int>(size)) {
+ ALOGE("Ashmem direct channel size %" PRIu32 " greater than shared memory size %d",
+ size, size2);
return nullptr;
}
break;
}
case SENSOR_DIRECT_MEM_TYPE_GRALLOC:
- LOG_FATAL("%s: Finish implementation of ION and GRALLOC or remove", __FUNCTION__);
+ // no specific checks for gralloc
break;
default:
ALOGE("Unknown direct connection memory type %d", type);
diff --git a/services/surfaceflinger/DisplayHardware/FramebufferSurface.cpp b/services/surfaceflinger/DisplayHardware/FramebufferSurface.cpp
index 1b598f8..5b869e1 100644
--- a/services/surfaceflinger/DisplayHardware/FramebufferSurface.cpp
+++ b/services/surfaceflinger/DisplayHardware/FramebufferSurface.cpp
@@ -32,7 +32,6 @@
#include <hardware/hardware.h>
#include <gui/BufferItem.h>
#include <gui/BufferQueue.h>
-#include <gui/GraphicBufferAlloc.h>
#include <gui/Surface.h>
#include <ui/GraphicBuffer.h>
diff --git a/services/surfaceflinger/DisplayHardware/HWComposer.cpp b/services/surfaceflinger/DisplayHardware/HWComposer.cpp
index 7314127..40979c9 100644
--- a/services/surfaceflinger/DisplayHardware/HWComposer.cpp
+++ b/services/surfaceflinger/DisplayHardware/HWComposer.cpp
@@ -206,7 +206,7 @@
}
disp = DisplayDevice::DISPLAY_EXTERNAL;
}
- mEventHandler->onHotplugReceived(disp,
+ mEventHandler->onHotplugReceived(this, disp,
connected == HWC2::Connection::Connected);
}
diff --git a/services/surfaceflinger/DisplayHardware/HWComposer.h b/services/surfaceflinger/DisplayHardware/HWComposer.h
index 81f1619..78d0307 100644
--- a/services/surfaceflinger/DisplayHardware/HWComposer.h
+++ b/services/surfaceflinger/DisplayHardware/HWComposer.h
@@ -70,7 +70,7 @@
friend class HWComposer;
virtual void onVSyncReceived(
HWComposer* composer, int32_t disp, nsecs_t timestamp) = 0;
- virtual void onHotplugReceived(int32_t disp, bool connected) = 0;
+ virtual void onHotplugReceived(HWComposer* composer, int32_t disp, bool connected) = 0;
virtual void onInvalidateReceived(HWComposer* composer) = 0;
protected:
virtual ~EventHandler() {}
diff --git a/services/surfaceflinger/DisplayHardware/HWComposer_hwc1.cpp b/services/surfaceflinger/DisplayHardware/HWComposer_hwc1.cpp
index 5b5f1cf..dcb2913 100644
--- a/services/surfaceflinger/DisplayHardware/HWComposer_hwc1.cpp
+++ b/services/surfaceflinger/DisplayHardware/HWComposer_hwc1.cpp
@@ -315,7 +315,7 @@
queryDisplayProperties(disp);
// Do not teardown or recreate the primary display
if (disp != HWC_DISPLAY_PRIMARY) {
- mEventHandler.onHotplugReceived(disp, bool(connected));
+ mEventHandler.onHotplugReceived(this, disp, bool(connected));
}
}
diff --git a/services/surfaceflinger/DisplayHardware/HWComposer_hwc1.h b/services/surfaceflinger/DisplayHardware/HWComposer_hwc1.h
index f64d69a..4bc63bb 100644
--- a/services/surfaceflinger/DisplayHardware/HWComposer_hwc1.h
+++ b/services/surfaceflinger/DisplayHardware/HWComposer_hwc1.h
@@ -62,7 +62,7 @@
friend class HWComposer;
virtual void onVSyncReceived(
HWComposer* composer, int32_t disp, nsecs_t timestamp) = 0;
- virtual void onHotplugReceived(int disp, bool connected) = 0;
+ virtual void onHotplugReceived(HWComposer* composer, int disp, bool connected) = 0;
virtual void onInvalidateReceived(HWComposer* composer) = 0;
protected:
virtual ~EventHandler() {}
diff --git a/services/surfaceflinger/Layer.cpp b/services/surfaceflinger/Layer.cpp
index 027fae6..d044f37 100644
--- a/services/surfaceflinger/Layer.cpp
+++ b/services/surfaceflinger/Layer.cpp
@@ -167,7 +167,7 @@
// Creates a custom BufferQueue for SurfaceFlingerConsumer to use
sp<IGraphicBufferProducer> producer;
sp<IGraphicBufferConsumer> consumer;
- BufferQueue::createBufferQueue(&producer, &consumer, nullptr, true);
+ BufferQueue::createBufferQueue(&producer, &consumer, true);
mProducer = new MonitoredProducer(producer, mFlinger, this);
mSurfaceFlingerConsumer = new SurfaceFlingerConsumer(consumer, mTextureName, this);
mSurfaceFlingerConsumer->setConsumerUsageBits(getEffectiveUsage(0));
@@ -2617,6 +2617,21 @@
const auto& p = getParent();
if (p != nullptr) {
t = p->getTransform();
+
+ // If the parent is not using NATIVE_WINDOW_SCALING_MODE_FREEZE (e.g.
+ // it isFixedSize) then there may be additional scaling not accounted
+ // for in the transform. We need to mirror this scaling in child surfaces
+ // or we will break the contract where WM can treat child surfaces as
+ // pixels in the parent surface.
+ if (p->isFixedSize()) {
+ float sx = p->getDrawingState().active.w /
+ static_cast<float>(p->mActiveBuffer->getWidth());
+ float sy = p->getDrawingState().active.h /
+ static_cast<float>(p->mActiveBuffer->getHeight());
+ Transform extraParentScaling;
+ extraParentScaling.set(sx, 0, 0, sy);
+ t = t * extraParentScaling;
+ }
}
return t * getDrawingState().active.transform;
}
diff --git a/services/surfaceflinger/SurfaceFlinger.cpp b/services/surfaceflinger/SurfaceFlinger.cpp
index c72f8e0..746d3d9 100644
--- a/services/surfaceflinger/SurfaceFlinger.cpp
+++ b/services/surfaceflinger/SurfaceFlinger.cpp
@@ -45,7 +45,6 @@
#include <gui/GuiConfig.h>
#include <gui/IDisplayEventConnection.h>
#include <gui/Surface.h>
-#include <gui/GraphicBufferAlloc.h>
#include <ui/GraphicBufferAllocator.h>
#include <ui/PixelFormat.h>
@@ -340,12 +339,6 @@
return mBuiltinDisplays[id];
}
-sp<IGraphicBufferAlloc> SurfaceFlinger::createGraphicBufferAlloc()
-{
- sp<GraphicBufferAlloc> gba(new GraphicBufferAlloc());
- return gba;
-}
-
void SurfaceFlinger::bootFinished()
{
if (mStartBootAnimThread->join() != NO_ERROR) {
@@ -606,7 +599,7 @@
// make the GLContext current so that we can create textures when creating
// Layers (which may happens before we render something)
- getDefaultDisplayDevice()->makeCurrent(mEGLDisplay, mEGLContext);
+ getDefaultDisplayDeviceLocked()->makeCurrent(mEGLDisplay, mEGLContext);
mEventControlThread = new EventControlThread(this);
mEventControlThread->run("EventControl", PRIORITY_URGENT_DISPLAY);
@@ -799,10 +792,12 @@
ALOGE("%s : display is NULL", __func__);
return BAD_VALUE;
}
- sp<DisplayDevice> device(getDisplayDevice(display));
+
+ sp<const DisplayDevice> device(getDisplayDevice(display));
if (device != NULL) {
return device->getActiveConfig();
}
+
return BAD_VALUE;
}
@@ -890,7 +885,7 @@
}
android_color_mode_t SurfaceFlinger::getActiveColorMode(const sp<IBinder>& display) {
- sp<DisplayDevice> device(getDisplayDevice(display));
+ sp<const DisplayDevice> device(getDisplayDevice(display));
if (device != nullptr) {
return device->getActiveColorMode();
}
@@ -972,7 +967,7 @@
HdrCapabilities* outCapabilities) const {
Mutex::Autolock _l(mStateLock);
- sp<const DisplayDevice> displayDevice(getDisplayDevice(display));
+ sp<const DisplayDevice> displayDevice(getDisplayDeviceLocked(display));
if (displayDevice == nullptr) {
ALOGE("getHdrCapabilities: Invalid display %p", displayDevice.get());
return BAD_VALUE;
@@ -1151,55 +1146,59 @@
*compositorTiming = mCompositorTiming;
}
-void SurfaceFlinger::onHotplugReceived(int32_t disp, bool connected) {
+void SurfaceFlinger::createDefaultDisplayDevice() {
+ const int32_t type = DisplayDevice::DISPLAY_PRIMARY;
+ wp<IBinder> token = mBuiltinDisplays[type];
+
+ // All non-virtual displays are currently considered secure.
+ const bool isSecure = true;
+
+ sp<IGraphicBufferProducer> producer;
+ sp<IGraphicBufferConsumer> consumer;
+ BufferQueue::createBufferQueue(&producer, &consumer);
+
+ sp<FramebufferSurface> fbs = new FramebufferSurface(*mHwc, type, consumer);
+
+ bool hasWideColorModes = false;
+ std::vector<android_color_mode_t> modes = getHwComposer().getColorModes(type);
+ for (android_color_mode_t colorMode : modes) {
+ switch (colorMode) {
+ case HAL_COLOR_MODE_DISPLAY_P3:
+ case HAL_COLOR_MODE_ADOBE_RGB:
+ case HAL_COLOR_MODE_DCI_P3:
+ hasWideColorModes = true;
+ break;
+ default:
+ break;
+ }
+ }
+ sp<DisplayDevice> hw = new DisplayDevice(this, DisplayDevice::DISPLAY_PRIMARY, type, isSecure,
+ token, fbs, producer, mRenderEngine->getEGLConfig(),
+ hasWideColorModes && hasWideColorDisplay);
+ mDisplays.add(token, hw);
+ android_color_mode defaultColorMode = HAL_COLOR_MODE_NATIVE;
+ if (hasWideColorModes && hasWideColorDisplay) {
+ defaultColorMode = HAL_COLOR_MODE_SRGB;
+ }
+ setActiveColorModeInternal(hw, defaultColorMode);
+}
+
+void SurfaceFlinger::onHotplugReceived(HWComposer* composer, int32_t disp, bool connected) {
ALOGV("onHotplugReceived(%d, %s)", disp, connected ? "true" : "false");
+
+ if (composer->isUsingVrComposer()) {
+ // We handle initializing the primary display device for the VR
+ // window manager hwc explicitly at the time of transition.
+ if (disp != DisplayDevice::DISPLAY_PRIMARY) {
+ ALOGE("External displays are not supported by the vr hardware composer.");
+ }
+ return;
+ }
+
if (disp == DisplayDevice::DISPLAY_PRIMARY) {
Mutex::Autolock lock(mStateLock);
-
- // All non-virtual displays are currently considered secure.
- bool isSecure = true;
-
- int32_t type = DisplayDevice::DISPLAY_PRIMARY;
-
- // When we're using the vr composer, the assumption is that we've
- // already created the IBinder object for the primary display.
- if (!mHwc->isUsingVrComposer()) {
- createBuiltinDisplayLocked(DisplayDevice::DISPLAY_PRIMARY);
- }
-
- wp<IBinder> token = mBuiltinDisplays[type];
-
- sp<IGraphicBufferProducer> producer;
- sp<IGraphicBufferConsumer> consumer;
- BufferQueue::createBufferQueue(&producer, &consumer,
- new GraphicBufferAlloc());
-
- sp<FramebufferSurface> fbs = new FramebufferSurface(*mHwc,
- DisplayDevice::DISPLAY_PRIMARY, consumer);
-
- bool hasWideColorModes = false;
- std::vector<android_color_mode_t> modes = getHwComposer().getColorModes(type);
- for (android_color_mode_t colorMode : modes) {
- switch (colorMode) {
- case HAL_COLOR_MODE_DISPLAY_P3:
- case HAL_COLOR_MODE_ADOBE_RGB:
- case HAL_COLOR_MODE_DCI_P3:
- hasWideColorModes = true;
- break;
- default:
- break;
- }
- }
- sp<DisplayDevice> hw =
- new DisplayDevice(this, DisplayDevice::DISPLAY_PRIMARY, disp, isSecure, token, fbs,
- producer, mRenderEngine->getEGLConfig(),
- hasWideColorModes && hasWideColorDisplay);
- mDisplays.add(token, hw);
- android_color_mode defaultColorMode = HAL_COLOR_MODE_NATIVE;
- if (hasWideColorModes && hasWideColorDisplay) {
- defaultColorMode = HAL_COLOR_MODE_SRGB;
- }
- setActiveColorModeInternal(hw, defaultColorMode);
+ createBuiltinDisplayLocked(DisplayDevice::DISPLAY_PRIMARY);
+ createDefaultDisplayDevice();
} else {
auto type = DisplayDevice::DISPLAY_EXTERNAL;
Mutex::Autolock _l(mStateLock);
@@ -1241,7 +1240,8 @@
}
}
-void SurfaceFlinger::resetHwc() {
+// Note: it is assumed the caller holds |mStateLock| when this is called
+void SurfaceFlinger::resetHwcLocked() {
disableHardwareVsync(true);
clearHwcLayers(mDrawingState.layersSortedByZ);
clearHwcLayers(mCurrentState.layersSortedByZ);
@@ -1250,6 +1250,13 @@
// mCurrentState and mDrawingState and re-apply all changes when we make the
// transition.
mDrawingState.displays.clear();
+ // Release virtual display hwcId during vr mode transition.
+ for (size_t displayId = 0; displayId < mDisplays.size(); ++displayId) {
+ const sp<DisplayDevice>& displayDevice = mDisplays[displayId];
+ if (displayDevice->getDisplayType() == DisplayDevice::DISPLAY_VIRTUAL) {
+ displayDevice->disconnect(getHwComposer());
+ }
+ }
mDisplays.clear();
initializeDisplays();
}
@@ -1261,36 +1268,45 @@
if (vrFlingerRequestsDisplay == mHwc->isUsingVrComposer()) {
return;
}
+
if (vrFlingerRequestsDisplay && !mVrHwc) {
// Construct new HWComposer without holding any locks.
mVrHwc = new HWComposer(true);
+
+ // Set up the event handlers. This step is neccessary to initialize the internal state of
+ // the hardware composer object properly. Our callbacks are designed such that if they are
+ // triggered between now and the point where the display is properly re-initialized, they
+ // will not have any effect, so this is safe to do here, before the lock is aquired.
+ mVrHwc->setEventHandler(static_cast<HWComposer::EventHandler*>(this));
ALOGV("Vr HWC created");
}
- {
- Mutex::Autolock _l(mStateLock);
- if (vrFlingerRequestsDisplay) {
- resetHwc();
+ Mutex::Autolock _l(mStateLock);
- mHwc = mVrHwc;
- mVrFlinger->GrantDisplayOwnership();
- } else {
- mVrFlinger->SeizeDisplayOwnership();
+ if (vrFlingerRequestsDisplay) {
+ resetHwcLocked();
- resetHwc();
+ mHwc = mVrHwc;
+ mVrFlinger->GrantDisplayOwnership();
- mHwc = mRealHwc;
- enableHardwareVsync();
- }
+ } else {
+ mVrFlinger->SeizeDisplayOwnership();
- mVisibleRegionsDirty = true;
- invalidateHwcGeometry();
- android_atomic_or(1, &mRepaintEverything);
- setTransactionFlags(eDisplayTransactionNeeded);
+ resetHwcLocked();
+
+ mHwc = mRealHwc;
+ enableHardwareVsync();
}
- if (mVrHwc) {
- mVrHwc->setEventHandler(static_cast<HWComposer::EventHandler*>(this));
- }
+
+ mVisibleRegionsDirty = true;
+ invalidateHwcGeometry();
+
+ // Explicitly re-initialize the primary display. This is because some other
+ // parts of this class rely on the primary display always being available.
+ createDefaultDisplayDevice();
+
+ android_atomic_or(1, &mRepaintEverything);
+ setTransactionFlags(eDisplayTransactionNeeded);
}
void SurfaceFlinger::onMessageReceived(int32_t what) {
@@ -1500,7 +1516,8 @@
layer->releasePendingBuffer(dequeueReadyTime);
}
- const sp<const DisplayDevice> hw(getDefaultDisplayDevice());
+ // |mStateLock| not needed as we are on the main thread
+ const sp<const DisplayDevice> hw(getDefaultDisplayDeviceLocked());
std::shared_ptr<FenceTime> glCompositionDoneFenceTime;
if (mHwc->hasClientComposition(HWC_DISPLAY_PRIMARY)) {
@@ -1848,7 +1865,8 @@
mLastSwapBufferTime = systemTime() - now;
mDebugInSwapBuffers = 0;
- uint32_t flipCount = getDefaultDisplayDevice()->getPageFlipCount();
+ // |mStateLock| not needed as we are on the main thread
+ uint32_t flipCount = getDefaultDisplayDeviceLocked()->getPageFlipCount();
if (flipCount % LOG_FRAME_STATS_PERIOD == 0) {
logFrameStats();
}
@@ -1933,9 +1951,9 @@
// Call makeCurrent() on the primary display so we can
// be sure that nothing associated with this display
// is current.
- const sp<const DisplayDevice> defaultDisplay(getDefaultDisplayDevice());
+ const sp<const DisplayDevice> defaultDisplay(getDefaultDisplayDeviceLocked());
defaultDisplay->makeCurrent(mEGLDisplay, mEGLContext);
- sp<DisplayDevice> hw(getDisplayDevice(draw.keyAt(i)));
+ sp<DisplayDevice> hw(getDisplayDeviceLocked(draw.keyAt(i)));
if (hw != NULL)
hw->disconnect(getHwComposer());
if (draw[i].type < DisplayDevice::NUM_BUILTIN_DISPLAY_TYPES)
@@ -1955,7 +1973,7 @@
// recreating the DisplayDevice, so we just remove it
// from the drawing state, so that it get re-added
// below.
- sp<DisplayDevice> hw(getDisplayDevice(display));
+ sp<DisplayDevice> hw(getDisplayDeviceLocked(display));
if (hw != NULL)
hw->disconnect(getHwComposer());
mDisplays.removeItem(display);
@@ -1965,7 +1983,7 @@
continue;
}
- const sp<DisplayDevice> disp(getDisplayDevice(display));
+ const sp<DisplayDevice> disp(getDisplayDeviceLocked(display));
if (disp != NULL) {
if (state.layerStack != draw[i].layerStack) {
disp->setLayerStack(state.layerStack);
@@ -1994,8 +2012,7 @@
sp<IGraphicBufferProducer> producer;
sp<IGraphicBufferProducer> bqProducer;
sp<IGraphicBufferConsumer> bqConsumer;
- BufferQueue::createBufferQueue(&bqProducer, &bqConsumer,
- new GraphicBufferAlloc());
+ BufferQueue::createBufferQueue(&bqProducer, &bqConsumer);
int32_t hwcId = -1;
if (state.isVirtualDisplay()) {
@@ -2123,7 +2140,7 @@
// could be null when this layer is using a layerStack
// that is not visible on any display. Also can occur at
// screen off/on times.
- disp = getDefaultDisplayDevice();
+ disp = getDefaultDisplayDeviceLocked();
}
layer->updateTransformHint(disp);
@@ -2479,7 +2496,9 @@
ALOGW("DisplayDevice::makeCurrent failed. Aborting surface composition for display %s",
displayDevice->getDisplayName().string());
eglMakeCurrent(mEGLDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
- if(!getDefaultDisplayDevice()->makeCurrent(mEGLDisplay, mEGLContext)) {
+
+ // |mStateLock| not needed as we are on the main thread
+ if(!getDefaultDisplayDeviceLocked()->makeCurrent(mEGLDisplay, mEGLContext)) {
ALOGE("DisplayDevice::makeCurrent on default display failed. Aborting.");
}
return false;
@@ -3571,7 +3590,7 @@
colorizer.reset(result);
HWComposer& hwc(getHwComposer());
- sp<const DisplayDevice> hw(getDefaultDisplayDevice());
+ sp<const DisplayDevice> hw(getDefaultDisplayDeviceLocked());
colorizer.bold(result);
result.appendFormat("EGL implementation : %s\n",
@@ -3665,7 +3684,7 @@
// Just use the primary display so we have something to return
dpy = getBuiltInDisplay(DisplayDevice::DISPLAY_PRIMARY);
}
- return getDisplayDevice(dpy)->getVisibleLayersSortedByZ();
+ return getDisplayDeviceLocked(dpy)->getVisibleLayersSortedByZ();
}
bool SurfaceFlinger::startDdmConnection()
@@ -3800,7 +3819,6 @@
reply->writeInt32(mDebugDisableHWC);
return NO_ERROR;
case 1013: {
- Mutex::Autolock _l(mStateLock);
sp<const DisplayDevice> hw(getDefaultDisplayDevice());
reply->writeInt32(hw->getPageFlipCount());
return NO_ERROR;
@@ -4087,7 +4105,7 @@
}
virtual bool handler() {
Mutex::Autolock _l(flinger->mStateLock);
- sp<const DisplayDevice> hw(flinger->getDisplayDevice(display));
+ sp<const DisplayDevice> hw(flinger->getDisplayDeviceLocked(display));
result = flinger->captureScreenImplLocked(hw, producer,
sourceCrop, reqWidth, reqHeight, minLayerZ, maxLayerZ,
useIdentityTransform, rotation, isLocalScreenshot);
diff --git a/services/surfaceflinger/SurfaceFlinger.h b/services/surfaceflinger/SurfaceFlinger.h
index afb64ed..c01f701 100644
--- a/services/surfaceflinger/SurfaceFlinger.h
+++ b/services/surfaceflinger/SurfaceFlinger.h
@@ -76,7 +76,6 @@
class Client;
class DisplayEventConnection;
class EventThread;
-class IGraphicBufferAlloc;
class Layer;
class LayerDim;
class Surface;
@@ -185,7 +184,8 @@
// returns the default Display
sp<const DisplayDevice> getDefaultDisplayDevice() const {
- return getDisplayDevice(mBuiltinDisplays[DisplayDevice::DISPLAY_PRIMARY]);
+ Mutex::Autolock _l(mStateLock);
+ return getDefaultDisplayDeviceLocked();
}
// utility function to delete a texture on the main thread
@@ -257,7 +257,6 @@
*/
virtual sp<ISurfaceComposerClient> createConnection();
virtual sp<ISurfaceComposerClient> createScopedConnection(const sp<IGraphicBufferProducer>& gbp);
- virtual sp<IGraphicBufferAlloc> createGraphicBufferAlloc();
virtual sp<IBinder> createDisplay(const String8& displayName, bool secure);
virtual void destroyDisplay(const sp<IBinder>& display);
virtual sp<IBinder> getBuiltInDisplay(int32_t id);
@@ -307,7 +306,7 @@
* HWComposer::EventHandler interface
*/
virtual void onVSyncReceived(HWComposer* composer, int type, nsecs_t timestamp);
- virtual void onHotplugReceived(int disp, bool connected);
+ virtual void onHotplugReceived(HWComposer* composer, int disp, bool connected);
virtual void onInvalidateReceived(HWComposer* composer);
/* ------------------------------------------------------------------------
@@ -432,16 +431,33 @@
// Create an IBinder for a builtin display and add it to current state
void createBuiltinDisplayLocked(DisplayDevice::DisplayType type);
- // NOTE: can only be called from the main thread or with mStateLock held
+
sp<const DisplayDevice> getDisplayDevice(const wp<IBinder>& dpy) const {
+ Mutex::Autolock _l(mStateLock);
+ return getDisplayDeviceLocked(dpy);
+ }
+
+ sp<DisplayDevice> getDisplayDevice(const wp<IBinder>& dpy) {
+ Mutex::Autolock _l(mStateLock);
+ return getDisplayDeviceLocked(dpy);
+ }
+
+ // NOTE: can only be called from the main thread or with mStateLock held
+ sp<const DisplayDevice> getDisplayDeviceLocked(const wp<IBinder>& dpy) const {
return mDisplays.valueFor(dpy);
}
// NOTE: can only be called from the main thread or with mStateLock held
- sp<DisplayDevice> getDisplayDevice(const wp<IBinder>& dpy) {
+ sp<DisplayDevice> getDisplayDeviceLocked(const wp<IBinder>& dpy) {
return mDisplays.valueFor(dpy);
}
+ sp<const DisplayDevice> getDefaultDisplayDeviceLocked() const {
+ return getDisplayDeviceLocked(mBuiltinDisplays[DisplayDevice::DISPLAY_PRIMARY]);
+ }
+
+ void createDefaultDisplayDevice();
+
int32_t getDisplayType(const sp<IBinder>& display) {
if (!display.get()) return NAME_NOT_FOUND;
for (int i = 0; i < DisplayDevice::NUM_BUILTIN_DISPLAY_TYPES; ++i) {
@@ -549,7 +565,7 @@
* VrFlinger
*/
void clearHwcLayers(const LayerVector& layers);
- void resetHwc();
+ void resetHwcLocked();
// Check to see if we should handoff to vr flinger.
void updateVrFlinger();
diff --git a/services/surfaceflinger/SurfaceFlinger_hwc1.cpp b/services/surfaceflinger/SurfaceFlinger_hwc1.cpp
index 28dac11..02923ae 100644
--- a/services/surfaceflinger/SurfaceFlinger_hwc1.cpp
+++ b/services/surfaceflinger/SurfaceFlinger_hwc1.cpp
@@ -42,7 +42,6 @@
#include <gui/GuiConfig.h>
#include <gui/IDisplayEventConnection.h>
#include <gui/Surface.h>
-#include <gui/GraphicBufferAlloc.h>
#include <ui/GraphicBufferAllocator.h>
#include <ui/HdrCapabilities.h>
@@ -319,12 +318,6 @@
return mBuiltinDisplays[id];
}
-sp<IGraphicBufferAlloc> SurfaceFlinger::createGraphicBufferAlloc()
-{
- sp<GraphicBufferAlloc> gba(new GraphicBufferAlloc());
- return gba;
-}
-
void SurfaceFlinger::bootFinished()
{
if (mStartBootAnimThread->join() != NO_ERROR) {
@@ -564,8 +557,7 @@
sp<IGraphicBufferProducer> producer;
sp<IGraphicBufferConsumer> consumer;
- BufferQueue::createBufferQueue(&producer, &consumer,
- new GraphicBufferAlloc());
+ BufferQueue::createBufferQueue(&producer, &consumer);
sp<FramebufferSurface> fbs = new FramebufferSurface(*mHwc, i,
consumer);
@@ -587,7 +579,7 @@
// make the GLContext current so that we can create textures when creating Layers
// (which may happens before we render something)
- getDefaultDisplayDevice()->makeCurrent(mEGLDisplay, mEGLContext);
+ getDefaultDisplayDeviceLocked()->makeCurrent(mEGLDisplay, mEGLContext);
mEventControlThread = new EventControlThread(this);
mEventControlThread->run("EventControl", PRIORITY_URGENT_DISPLAY);
@@ -773,7 +765,7 @@
}
int SurfaceFlinger::getActiveConfig(const sp<IBinder>& display) {
- sp<DisplayDevice> device(getDisplayDevice(display));
+ sp<const DisplayDevice> device(getDisplayDevice(display));
if (device != NULL) {
return device->getActiveConfig();
}
@@ -1058,7 +1050,7 @@
*compositorTiming = mCompositorTiming;
}
-void SurfaceFlinger::onHotplugReceived(int type, bool connected) {
+void SurfaceFlinger::onHotplugReceived(HWComposer* /*composer*/, int type, bool connected) {
if (mEventThread == NULL) {
// This is a temporary workaround for b/7145521. A non-null pointer
// does not mean EventThread has finished initializing, so this
@@ -1644,9 +1636,9 @@
// Call makeCurrent() on the primary display so we can
// be sure that nothing associated with this display
// is current.
- const sp<const DisplayDevice> defaultDisplay(getDefaultDisplayDevice());
+ const sp<const DisplayDevice> defaultDisplay(getDefaultDisplayDeviceLocked());
defaultDisplay->makeCurrent(mEGLDisplay, mEGLContext);
- sp<DisplayDevice> hw(getDisplayDevice(draw.keyAt(i)));
+ sp<DisplayDevice> hw(getDisplayDeviceLocked(draw.keyAt(i)));
if (hw != NULL)
hw->disconnect(getHwComposer());
if (draw[i].type < DisplayDevice::NUM_BUILTIN_DISPLAY_TYPES)
@@ -1666,7 +1658,7 @@
// recreating the DisplayDevice, so we just remove it
// from the drawing state, so that it get re-added
// below.
- sp<DisplayDevice> hw(getDisplayDevice(display));
+ sp<DisplayDevice> hw(getDisplayDeviceLocked(display));
if (hw != NULL)
hw->disconnect(getHwComposer());
mDisplays.removeItem(display);
@@ -1676,7 +1668,7 @@
continue;
}
- const sp<DisplayDevice> disp(getDisplayDevice(display));
+ const sp<DisplayDevice> disp(getDisplayDeviceLocked(display));
if (disp != NULL) {
if (state.layerStack != draw[i].layerStack) {
disp->setLayerStack(state.layerStack);
@@ -1705,8 +1697,7 @@
sp<IGraphicBufferProducer> producer;
sp<IGraphicBufferProducer> bqProducer;
sp<IGraphicBufferConsumer> bqConsumer;
- BufferQueue::createBufferQueue(&bqProducer, &bqConsumer,
- new GraphicBufferAlloc());
+ BufferQueue::createBufferQueue(&bqProducer, &bqConsumer);
int32_t hwcDisplayId = -1;
if (state.isVirtualDisplay()) {
@@ -1832,7 +1823,7 @@
// could be null when this layer is using a layerStack
// that is not visible on any display. Also can occur at
// screen off/on times.
- disp = getDefaultDisplayDevice();
+ disp = getDefaultDisplayDeviceLocked();
}
layer->updateTransformHint(disp);
@@ -3240,7 +3231,7 @@
colorizer.reset(result);
HWComposer& hwc(getHwComposer());
- sp<const DisplayDevice> hw(getDefaultDisplayDevice());
+ sp<const DisplayDevice> hw(getDefaultDisplayDeviceLocked());
colorizer.bold(result);
result.appendFormat("EGL implementation : %s\n",
@@ -3316,7 +3307,7 @@
// Just use the primary display so we have something to return
dpy = getBuiltInDisplay(DisplayDevice::DISPLAY_PRIMARY);
}
- return getDisplayDevice(dpy)->getVisibleLayersSortedByZ();
+ return getDisplayDeviceLocked(dpy)->getVisibleLayersSortedByZ();
}
bool SurfaceFlinger::startDdmConnection()
@@ -3731,7 +3722,7 @@
}
virtual bool handler() {
Mutex::Autolock _l(flinger->mStateLock);
- sp<const DisplayDevice> hw(flinger->getDisplayDevice(display));
+ sp<const DisplayDevice> hw(flinger->getDisplayDeviceLocked(display));
result = flinger->captureScreenImplLocked(hw, producer,
sourceCrop, reqWidth, reqHeight, minLayerZ, maxLayerZ,
useIdentityTransform, rotation, isLocalScreenshot);
diff --git a/services/surfaceflinger/tests/Transaction_test.cpp b/services/surfaceflinger/tests/Transaction_test.cpp
index 441fc7e..7a8b4ab 100644
--- a/services/surfaceflinger/tests/Transaction_test.cpp
+++ b/services/surfaceflinger/tests/Transaction_test.cpp
@@ -909,4 +909,36 @@
}
}
+TEST_F(ChildLayerTest, ChildrenInheritNonTransformScalingFromParent) {
+ SurfaceComposerClient::openGlobalTransaction();
+ mChild->show();
+ mChild->setPosition(0, 0);
+ mFGSurfaceControl->setPosition(0, 0);
+ SurfaceComposerClient::closeGlobalTransaction(true);
+
+ {
+ ScreenCapture::captureScreen(&mCapture);
+ // We've positioned the child in the top left.
+ mCapture->expectChildColor(0, 0);
+ // But it's only 10x10.
+ mCapture->expectFGColor(10, 10);
+ }
+
+ SurfaceComposerClient::openGlobalTransaction();
+ mFGSurfaceControl->setOverrideScalingMode(NATIVE_WINDOW_SCALING_MODE_SCALE_TO_WINDOW);
+ // We cause scaling by 2.
+ mFGSurfaceControl->setSize(128, 128);
+ SurfaceComposerClient::closeGlobalTransaction();
+
+ {
+ ScreenCapture::captureScreen(&mCapture);
+ // We've positioned the child in the top left.
+ mCapture->expectChildColor(0, 0);
+ mCapture->expectChildColor(10, 10);
+ mCapture->expectChildColor(19, 19);
+ // And now it should be scaled all the way to 20x20
+ mCapture->expectFGColor(20, 20);
+ }
+}
+
}
diff --git a/services/vr/hardware_composer/Android.bp b/services/vr/hardware_composer/Android.bp
index b94d333..25bb30b 100644
--- a/services/vr/hardware_composer/Android.bp
+++ b/services/vr/hardware_composer/Android.bp
@@ -1,3 +1,51 @@
+cc_library_shared {
+ name: "libvr_hwc-hal",
+
+ srcs: [
+ "impl/vr_hwc.cpp",
+ "impl/vr_composer_client.cpp",
+ ],
+
+ static_libs: [
+ "libhwcomposer-client",
+ "libdisplay",
+ "libbufferhubqueue",
+ "libbufferhub",
+ "libpdx_default_transport",
+ ],
+
+ shared_libs: [
+ "android.frameworks.vr.composer@1.0",
+ "android.hardware.graphics.composer@2.1",
+ "libbase",
+ "libcutils",
+ "libfmq",
+ "libhardware",
+ "libhidlbase",
+ "libhidltransport",
+ "liblog",
+ "libsync",
+ "libui",
+ "libutils",
+ ],
+
+ export_static_lib_headers: [
+ "libhwcomposer-client",
+ ],
+
+ export_shared_lib_headers: [
+ "android.frameworks.vr.composer@1.0",
+ "android.hardware.graphics.composer@2.1",
+ ],
+
+ export_include_dirs: ["."],
+
+ cflags: [
+ "-DLOG_TAG=\"vr_hwc\"",
+ ],
+
+}
+
cc_library_static {
name: "libvr_hwc-binder",
srcs: [
@@ -12,11 +60,12 @@
export_aidl_headers: true,
},
export_include_dirs: ["aidl"],
+
shared_libs: [
"libbinder",
"libui",
"libutils",
- "libvrhwc",
+ "libvr_hwc-hal",
],
}
@@ -34,10 +83,10 @@
"liblog",
"libui",
"libutils",
- "libvrhwc",
+ "libvr_hwc-hal",
],
export_shared_lib_headers: [
- "libvrhwc",
+ "libvr_hwc-hal",
],
cflags: [
"-DLOG_TAG=\"vr_hwc\"",
@@ -65,7 +114,7 @@
"libhwbinder",
"libui",
"libutils",
- "libvrhwc",
+ "libvr_hwc-hal",
],
cflags: [
"-DLOG_TAG=\"vr_hwc\"",
diff --git a/services/vr/hardware_composer/aidl/android/dvr/parcelable_composer_frame.cpp b/services/vr/hardware_composer/aidl/android/dvr/parcelable_composer_frame.cpp
index 45eabca..db7d5dc 100644
--- a/services/vr/hardware_composer/aidl/android/dvr/parcelable_composer_frame.cpp
+++ b/services/vr/hardware_composer/aidl/android/dvr/parcelable_composer_frame.cpp
@@ -28,6 +28,26 @@
ret = parcel->writeBool(frame_.removed);
if (ret != OK) return ret;
+ ret = parcel->writeUint32(static_cast<uint32_t>(frame_.active_config));
+ if (ret != OK) return ret;
+
+ ret = parcel->writeUint32(static_cast<uint32_t>(frame_.color_mode));
+ if (ret != OK) return ret;
+
+ ret = parcel->writeUint32(static_cast<uint32_t>(frame_.power_mode));
+ if (ret != OK) return ret;
+
+ ret = parcel->writeUint32(static_cast<uint32_t>(frame_.vsync_enabled));
+ if (ret != OK) return ret;
+
+ ret = parcel->writeInt32(frame_.color_transform_hint);
+ if (ret != OK) return ret;
+
+ for(size_t i = 0; i < 16; i++) {
+ ret = parcel->writeFloat(frame_.color_transform[i]);
+ if (ret != OK) return ret;
+ }
+
std::vector<ParcelableComposerLayer> layers;
for (size_t i = 0; i < frame_.layers.size(); ++i)
layers.push_back(ParcelableComposerLayer(frame_.layers[i]));
@@ -50,6 +70,31 @@
ret = parcel->readBool(&frame_.removed);
if (ret != OK) return ret;
+ uint32_t value;
+ ret = parcel->readUint32(&value);
+ if (ret != OK) return ret;
+ frame_.active_config = static_cast<Config>(value);
+
+ ret = parcel->readUint32(&value);
+ if (ret != OK) return ret;
+ frame_.color_mode = static_cast<ColorMode>(value);
+
+ ret = parcel->readUint32(&value);
+ if (ret != OK) return ret;
+ frame_.power_mode = static_cast<IComposerClient::PowerMode>(value);
+
+ ret = parcel->readUint32(&value);
+ if (ret != OK) return ret;
+ frame_.vsync_enabled = static_cast<IComposerClient::Vsync>(value);
+
+ ret = parcel->readInt32(&frame_.color_transform_hint);
+ if (ret != OK) return ret;
+
+ for(size_t i = 0; i < 16; i++) {
+ ret = parcel->readFloat(&frame_.color_transform[i]);
+ if (ret != OK) return ret;
+ }
+
std::vector<ParcelableComposerLayer> layers;
ret = parcel->readParcelableVector(&layers);
if (ret != OK) return ret;
diff --git a/services/vr/hardware_composer/aidl/android/dvr/parcelable_composer_layer.cpp b/services/vr/hardware_composer/aidl/android/dvr/parcelable_composer_layer.cpp
index 15f63fa..c3621eb 100644
--- a/services/vr/hardware_composer/aidl/android/dvr/parcelable_composer_layer.cpp
+++ b/services/vr/hardware_composer/aidl/android/dvr/parcelable_composer_layer.cpp
@@ -66,6 +66,50 @@
ret = parcel->writeUint32(layer_.app_id);
if (ret != OK) return ret;
+ ret = parcel->writeUint32(layer_.z_order);
+ if (ret != OK) return ret;
+
+ ret = parcel->writeInt32(layer_.cursor_x);
+ if (ret != OK) return ret;
+
+ ret = parcel->writeInt32(layer_.cursor_y);
+ if (ret != OK) return ret;
+
+ uint32_t color = layer_.color.r |
+ (static_cast<uint32_t>(layer_.color.g) << 8) |
+ (static_cast<uint32_t>(layer_.color.b) << 16) |
+ (static_cast<uint32_t>(layer_.color.a) << 24);
+ ret = parcel->writeUint32(color);
+ if (ret != OK) return ret;
+
+ ret = parcel->writeInt32(layer_.dataspace);
+ if (ret != OK) return ret;
+
+ ret = parcel->writeInt32(layer_.transform);
+ if (ret != OK) return ret;
+
+ ret = parcel->writeUint32(static_cast<uint32_t>(layer_.visible_regions.size()));
+ if (ret != OK) return ret;
+
+ for (auto& rect: layer_.visible_regions) {
+ ret = parcel->writeInt32(rect.left);
+ ret = parcel->writeInt32(rect.top);
+ ret = parcel->writeInt32(rect.right);
+ ret = parcel->writeInt32(rect.bottom);
+ if (ret != OK) return ret;
+ }
+
+ ret = parcel->writeUint32(static_cast<uint32_t>(layer_.damaged_regions.size()));
+ if (ret != OK) return ret;
+
+ for (auto& rect: layer_.damaged_regions) {
+ ret = parcel->writeInt32(rect.left);
+ ret = parcel->writeInt32(rect.top);
+ ret = parcel->writeInt32(rect.right);
+ ret = parcel->writeInt32(rect.bottom);
+ if (ret != OK) return ret;
+ }
+
return OK;
}
@@ -125,6 +169,70 @@
ret = parcel->readUint32(&layer_.app_id);
if (ret != OK) return ret;
+ ret = parcel->readUint32(&layer_.z_order);
+ if (ret != OK) return ret;
+
+ ret = parcel->readInt32(&layer_.cursor_x);
+ if (ret != OK) return ret;
+
+ ret = parcel->readInt32(&layer_.cursor_y);
+ if (ret != OK) return ret;
+
+ uint32_t color;
+ ret = parcel->readUint32(&color);
+ if (ret != OK) return ret;
+ layer_.color.r = color & 0xFF;
+ layer_.color.g = (color >> 8) & 0xFF;
+ layer_.color.b = (color >> 16) & 0xFF;
+ layer_.color.a = (color >> 24) & 0xFF;
+
+ ret = parcel->readInt32(&layer_.dataspace);
+ if (ret != OK) return ret;
+
+ ret = parcel->readInt32(&layer_.transform);
+ if (ret != OK) return ret;
+
+ uint32_t size;
+ ret = parcel->readUint32(&size);
+ if (ret != OK) return ret;
+
+ for(size_t i = 0; i < size; i++) {
+ hwc_rect_t rect;
+ ret = parcel->readInt32(&rect.left);
+ if (ret != OK) return ret;
+
+ ret = parcel->readInt32(&rect.top);
+ if (ret != OK) return ret;
+
+ ret = parcel->readInt32(&rect.right);
+ if (ret != OK) return ret;
+
+ ret = parcel->readInt32(&rect.bottom);
+ if (ret != OK) return ret;
+
+ layer_.visible_regions.push_back(rect);
+ }
+
+ ret = parcel->readUint32(&size);
+ if (ret != OK) return ret;
+
+ for(size_t i = 0; i < size; i++) {
+ hwc_rect_t rect;
+ ret = parcel->readInt32(&rect.left);
+ if (ret != OK) return ret;
+
+ ret = parcel->readInt32(&rect.top);
+ if (ret != OK) return ret;
+
+ ret = parcel->readInt32(&rect.right);
+ if (ret != OK) return ret;
+
+ ret = parcel->readInt32(&rect.bottom);
+ if (ret != OK) return ret;
+
+ layer_.damaged_regions.push_back(rect);
+ }
+
return OK;
}
diff --git a/services/vr/vr_window_manager/composer/impl/vr_composer_client.cpp b/services/vr/hardware_composer/impl/vr_composer_client.cpp
similarity index 97%
rename from services/vr/vr_window_manager/composer/impl/vr_composer_client.cpp
rename to services/vr/hardware_composer/impl/vr_composer_client.cpp
index e0bdf1c..ae54e56 100644
--- a/services/vr/vr_window_manager/composer/impl/vr_composer_client.cpp
+++ b/services/vr/hardware_composer/impl/vr_composer_client.cpp
@@ -19,8 +19,8 @@
#include <hardware/gralloc1.h>
#include <log/log.h>
-#include "vr_hwc.h"
-#include "vr_composer_client.h"
+#include "impl/vr_hwc.h"
+#include "impl/vr_composer_client.h"
namespace android {
namespace dvr {
diff --git a/services/vr/vr_window_manager/composer/impl/vr_composer_client.h b/services/vr/hardware_composer/impl/vr_composer_client.h
similarity index 90%
rename from services/vr/vr_window_manager/composer/impl/vr_composer_client.h
rename to services/vr/hardware_composer/impl/vr_composer_client.h
index 8d601ab..1236be9 100644
--- a/services/vr/vr_window_manager/composer/impl/vr_composer_client.h
+++ b/services/vr/hardware_composer/impl/vr_composer_client.h
@@ -14,8 +14,8 @@
* limitations under the License.
*/
-#ifndef VR_WINDOW_MANAGER_COMPOSER_IMPL_VR_COMPOSER_CLIENT_H_
-#define VR_WINDOW_MANAGER_COMPOSER_IMPL_VR_COMPOSER_CLIENT_H_
+#ifndef ANDROID_DVR_HARDWARE_COMPOSER_IMPL_VR_COMPOSER_CLIENT_H
+#define ANDROID_DVR_HARDWARE_COMPOSER_IMPL_VR_COMPOSER_CLIENT_H
#include <android/frameworks/vr/composer/1.0/IVrComposerClient.h>
#include <ComposerClient.h>
@@ -68,4 +68,4 @@
} // namespace dvr
} // namespace android
-#endif // VR_WINDOW_MANAGER_COMPOSER_IMPL_VR_COMPOSER_CLIENT_H_
+#endif // ANDROID_DVR_HARDWARE_COMPOSER_IMPL_VR_COMPOSER_CLIENT_H
diff --git a/services/vr/vr_window_manager/composer/impl/vr_hwc.cpp b/services/vr/hardware_composer/impl/vr_hwc.cpp
similarity index 89%
rename from services/vr/vr_window_manager/composer/impl/vr_hwc.cpp
rename to services/vr/hardware_composer/impl/vr_hwc.cpp
index 5efc482..29983a7 100644
--- a/services/vr/vr_window_manager/composer/impl/vr_hwc.cpp
+++ b/services/vr/hardware_composer/impl/vr_hwc.cpp
@@ -13,14 +13,13 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-#include "vr_hwc.h"
+#include "impl/vr_hwc.h"
+#include <private/dvr/display_client.h>
#include <ui/Fence.h>
#include <mutex>
-#include <private/dvr/display_client.h>
-
#include "vr_composer_client.h"
using namespace android::hardware::graphics::common::V1_0;
@@ -132,7 +131,7 @@
std::vector<IComposerClient::Composition>* types) {
std::sort(layers_.begin(), layers_.end(),
[](const auto& lhs, const auto& rhs) {
- return lhs.z_order < rhs.z_order;
+ return lhs.info.z_order < rhs.info.z_order;
});
int first_client_layer = -1, last_client_layer = -1;
@@ -220,6 +219,12 @@
return last_frame_layers;
}
+void HwcDisplay::SetColorTransform(const float* matrix, int32_t hint) {
+ color_transform_hint_ = hint;
+ if (matrix)
+ memcpy(color_transform_, matrix, sizeof(color_transform_));
+}
+
////////////////////////////////////////////////////////////////////////////////
// VrHwcClient
@@ -397,40 +402,54 @@
Error VrHwc::setActiveConfig(Display display, Config config) {
std::lock_guard<std::mutex> guard(mutex_);
- if (!FindDisplay(display))
+ auto display_ptr = FindDisplay(display);
+ if (!display_ptr)
return Error::BAD_DISPLAY;
if (config != kDefaultConfigId)
return Error::BAD_CONFIG;
+ display_ptr->set_active_config(config);
return Error::NONE;
}
Error VrHwc::setColorMode(Display display, ColorMode mode) {
std::lock_guard<std::mutex> guard(mutex_);
- if (!FindDisplay(display))
+ auto display_ptr = FindDisplay(display);
+ if (!display_ptr)
return Error::BAD_DISPLAY;
+
+ display_ptr->set_color_mode(mode);
return Error::NONE;
}
Error VrHwc::setPowerMode(Display display, IComposerClient::PowerMode mode) {
std::lock_guard<std::mutex> guard(mutex_);
- if (!FindDisplay(display))
+ auto display_ptr = FindDisplay(display);
+ if (!display_ptr)
return Error::BAD_DISPLAY;
+
+ display_ptr->set_power_mode(mode);
return Error::NONE;
}
Error VrHwc::setVsyncEnabled(Display display, IComposerClient::Vsync enabled) {
std::lock_guard<std::mutex> guard(mutex_);
- if (!FindDisplay(display))
+ auto display_ptr = FindDisplay(display);
+ if (!display_ptr)
return Error::BAD_DISPLAY;
+
+ display_ptr->set_vsync_enabled(enabled);
return Error::NONE;
}
Error VrHwc::setColorTransform(Display display, const float* matrix,
int32_t hint) {
std::lock_guard<std::mutex> guard(mutex_);
- if (!FindDisplay(display))
+ auto display_ptr = FindDisplay(display);
+ if (!display_ptr)
return Error::BAD_DISPLAY;
+
+ display_ptr->SetColorTransform(matrix, hint);
return Error::NONE;
}
@@ -500,6 +519,13 @@
frame.display_id = display;
frame.display_width = display_ptr->width();
frame.display_height = display_ptr->height();
+ frame.active_config = display_ptr->active_config();
+ frame.power_mode = display_ptr->power_mode();
+ frame.vsync_enabled = display_ptr->vsync_enabled();
+ frame.color_transform_hint = display_ptr->color_transform_hint();
+ frame.color_mode = display_ptr->color_mode();
+ memcpy(frame.color_transform, display_ptr->color_transform(),
+ sizeof(frame.color_transform));
if (status != Error::NONE)
return status;
@@ -523,8 +549,16 @@
Error VrHwc::setLayerCursorPosition(Display display, Layer layer, int32_t x,
int32_t y) {
std::lock_guard<std::mutex> guard(mutex_);
- if (!FindDisplay(display))
+ auto display_ptr = FindDisplay(display);
+ if (!display_ptr)
return Error::BAD_DISPLAY;
+
+ HwcLayer* hwc_layer = display_ptr->GetLayer(layer);
+ if (!hwc_layer)
+ return Error::BAD_LAYER;
+
+ hwc_layer->info.cursor_x = x;
+ hwc_layer->info.cursor_y = y;
return Error::NONE;
}
@@ -550,8 +584,15 @@
Error VrHwc::setLayerSurfaceDamage(Display display, Layer layer,
const std::vector<hwc_rect_t>& damage) {
std::lock_guard<std::mutex> guard(mutex_);
- if (!FindDisplay(display))
+ auto display_ptr = FindDisplay(display);
+ if (!display_ptr)
return Error::BAD_DISPLAY;
+
+ HwcLayer* hwc_layer = display_ptr->GetLayer(layer);
+ if (!hwc_layer)
+ return Error::BAD_LAYER;
+
+ hwc_layer->info.damaged_regions = damage;
return Error::NONE;
}
@@ -574,8 +615,15 @@
Error VrHwc::setLayerColor(Display display, Layer layer,
IComposerClient::Color color) {
std::lock_guard<std::mutex> guard(mutex_);
- if (!FindDisplay(display))
+ auto display_ptr = FindDisplay(display);
+ if (!display_ptr)
return Error::BAD_DISPLAY;
+
+ HwcLayer* hwc_layer = display_ptr->GetLayer(layer);
+ if (!hwc_layer)
+ return Error::BAD_LAYER;
+
+ hwc_layer->info.color = color;
return Error::NONE;
}
@@ -598,8 +646,15 @@
Error VrHwc::setLayerDataspace(Display display, Layer layer,
int32_t dataspace) {
std::lock_guard<std::mutex> guard(mutex_);
- if (!FindDisplay(display))
+ auto display_ptr = FindDisplay(display);
+ if (!display_ptr)
return Error::BAD_DISPLAY;
+
+ HwcLayer* hwc_layer = display_ptr->GetLayer(layer);
+ if (!hwc_layer)
+ return Error::BAD_LAYER;
+
+ hwc_layer->info.dataspace = dataspace;
return Error::NONE;
}
@@ -662,16 +717,30 @@
Error VrHwc::setLayerTransform(Display display, Layer layer,
int32_t transform) {
std::lock_guard<std::mutex> guard(mutex_);
- if (!FindDisplay(display))
+ auto display_ptr = FindDisplay(display);
+ if (!display_ptr)
return Error::BAD_DISPLAY;
+
+ HwcLayer* hwc_layer = display_ptr->GetLayer(layer);
+ if (!hwc_layer)
+ return Error::BAD_LAYER;
+
+ hwc_layer->info.transform = transform;
return Error::NONE;
}
Error VrHwc::setLayerVisibleRegion(Display display, Layer layer,
const std::vector<hwc_rect_t>& visible) {
std::lock_guard<std::mutex> guard(mutex_);
- if (!FindDisplay(display))
+ auto display_ptr = FindDisplay(display);
+ if (!display_ptr)
return Error::BAD_DISPLAY;
+
+ HwcLayer* hwc_layer = display_ptr->GetLayer(layer);
+ if (!hwc_layer)
+ return Error::BAD_LAYER;
+
+ hwc_layer->info.visible_regions = visible;
return Error::NONE;
}
@@ -685,7 +754,7 @@
if (!hwc_layer)
return Error::BAD_LAYER;
- hwc_layer->z_order = z;
+ hwc_layer->info.z_order = z;
return Error::NONE;
}
diff --git a/services/vr/vr_window_manager/composer/impl/vr_hwc.h b/services/vr/hardware_composer/impl/vr_hwc.h
similarity index 86%
rename from services/vr/vr_window_manager/composer/impl/vr_hwc.h
rename to services/vr/hardware_composer/impl/vr_hwc.h
index 3da2fb8..df04208 100644
--- a/services/vr/vr_window_manager/composer/impl/vr_hwc.h
+++ b/services/vr/hardware_composer/impl/vr_hwc.h
@@ -13,8 +13,8 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-#ifndef VR_WINDOW_MANAGER_COMPOSER_IMPL_VR_HWC_H_
-#define VR_WINDOW_MANAGER_COMPOSER_IMPL_VR_HWC_H_
+#ifndef ANDROID_DVR_HARDWARE_COMPOSER_IMPL_VR_HWC_H
+#define ANDROID_DVR_HARDWARE_COMPOSER_IMPL_VR_HWC_H
#include <android-base/unique_fd.h>
#include <android/frameworks/vr/composer/1.0/IVrComposerClient.h>
@@ -56,8 +56,6 @@
using BlendMode =
hardware::graphics::composer::V2_1::IComposerClient::BlendMode;
- // TODO(dnicoara): Add all layer properties. For now just the basics to get
- // it going.
Layer id;
sp<GraphicBuffer> buffer;
sp<Fence> fence;
@@ -67,6 +65,14 @@
float alpha;
uint32_t type;
uint32_t app_id;
+ uint32_t z_order;
+ int32_t cursor_x;
+ int32_t cursor_y;
+ IComposerClient::Color color;
+ int32_t dataspace;
+ int32_t transform;
+ std::vector<hwc_rect_t> visible_regions;
+ std::vector<hwc_rect_t> damaged_regions;
};
struct Frame {
@@ -77,6 +83,12 @@
bool removed = false;
int32_t display_width;
int32_t display_height;
+ Config active_config;
+ ColorMode color_mode;
+ IComposerClient::PowerMode power_mode;
+ IComposerClient::Vsync vsync_enabled;
+ float color_transform[16];
+ int32_t color_transform_hint;
std::vector<ComposerLayer> layers;
};
@@ -104,7 +116,6 @@
}
Composition composition_type;
- uint32_t z_order;
ComposerView::ComposerLayer info;
IVrComposerClient::BufferMetadata buffer_metadata;
};
@@ -133,6 +144,24 @@
std::vector<Layer> UpdateLastFrameAndGetLastFrameLayers();
+ Config active_config() const { return active_config_; }
+ void set_active_config(Config config) { active_config_ = config; }
+
+ ColorMode color_mode() const { return color_mode_; }
+ void set_color_mode(ColorMode mode) { color_mode_ = mode; }
+
+ IComposerClient::PowerMode power_mode() const { return power_mode_; }
+ void set_power_mode(IComposerClient::PowerMode mode) { power_mode_ = mode; }
+
+ IComposerClient::Vsync vsync_enabled() const { return vsync_enabled_; }
+ void set_vsync_enabled(IComposerClient::Vsync vsync) {
+ vsync_enabled_ = vsync;
+ }
+
+ const float* color_transform() const { return color_transform_; }
+ int32_t color_transform_hint() const { return color_transform_hint_; }
+ void SetColorTransform(const float* matrix, int32_t hint);
+
private:
// The client target buffer and the associated fence.
sp<GraphicBuffer> buffer_;
@@ -150,6 +179,13 @@
int32_t width_;
int32_t height_;
+ Config active_config_;
+ ColorMode color_mode_;
+ IComposerClient::PowerMode power_mode_;
+ IComposerClient::Vsync vsync_enabled_;
+ float color_transform_[16];
+ int32_t color_transform_hint_;
+
HwcDisplay(const HwcDisplay&) = delete;
void operator=(const HwcDisplay&) = delete;
};
@@ -283,4 +319,4 @@
} // namespace dvr
} // namespace android
-#endif // VR_WINDOW_MANAGER_COMPOSER_IMPL_VR_HWC_H_
+#endif // ANDROID_DVR_HARDWARE_COMPOSER_IMPL_VR_HWC_H
diff --git a/services/vr/vr_window_manager/Android.bp b/services/vr/vr_window_manager/Android.bp
index 669426b..d7ddba1 100644
--- a/services/vr/vr_window_manager/Android.bp
+++ b/services/vr/vr_window_manager/Android.bp
@@ -12,8 +12,6 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-subdirs = [ "composer", ]
-
native_src = [
"application.cpp",
"controller_mesh.cpp",
@@ -49,7 +47,6 @@
shared_libs = [
"android.frameworks.vr.composer@1.0",
"android.hardware.graphics.composer@2.1",
- "libvrhwc",
"libbase",
"libbinder",
"libinput",
@@ -66,6 +63,7 @@
"libhidlbase",
"libhidltransport",
"liblog",
+ "libvr_hwc-hal",
]
cc_binary {
diff --git a/services/vr/vr_window_manager/composer/Android.bp b/services/vr/vr_window_manager/composer/Android.bp
deleted file mode 100644
index 1998749..0000000
--- a/services/vr/vr_window_manager/composer/Android.bp
+++ /dev/null
@@ -1,47 +0,0 @@
-cc_library_shared {
- name: "libvrhwc",
-
- srcs: [
- "impl/vr_composer_view.cpp",
- "impl/vr_hwc.cpp",
- "impl/vr_composer_client.cpp",
- ],
-
- static_libs: [
- "libhwcomposer-client",
- "libdisplay",
- "libbufferhubqueue",
- "libbufferhub",
- "libpdx_default_transport",
- ],
-
- shared_libs: [
- "android.frameworks.vr.composer@1.0",
- "android.hardware.graphics.composer@2.1",
- "libbase",
- "libcutils",
- "libfmq",
- "libhardware",
- "libhidlbase",
- "libhidltransport",
- "liblog",
- "libsync",
- "libui",
- "libutils",
- ],
-
- export_static_lib_headers: [
- "libhwcomposer-client",
- ],
-
- export_shared_lib_headers: [
- "android.frameworks.vr.composer@1.0",
- "android.hardware.graphics.composer@2.1",
- ],
-
- export_include_dirs: ["."],
-
- cflags: [
- "-DLOG_TAG=\"vrhwc\"",
- ],
-}
diff --git a/services/vr/vr_window_manager/composer/impl/vr_composer_view.cpp b/services/vr/vr_window_manager/composer/impl/vr_composer_view.cpp
deleted file mode 100644
index 299e8f1..0000000
--- a/services/vr/vr_window_manager/composer/impl/vr_composer_view.cpp
+++ /dev/null
@@ -1,28 +0,0 @@
-#include "vr_composer_view.h"
-
-namespace android {
-namespace dvr {
-
-VrComposerView::VrComposerView(
- std::unique_ptr<VrComposerView::Callback> callback)
- : composer_view_(nullptr), callback_(std::move(callback)) {}
-
-VrComposerView::~VrComposerView() {
- composer_view_->UnregisterObserver(this);
-}
-
-void VrComposerView::Initialize(ComposerView* composer_view) {
- composer_view_ = composer_view;
- composer_view_->RegisterObserver(this);
-}
-
-base::unique_fd VrComposerView::OnNewFrame(const ComposerView::Frame& frame) {
- std::lock_guard<std::mutex> guard(mutex_);
- if (!callback_.get())
- return base::unique_fd();
-
- return callback_->OnNewFrame(frame);
-}
-
-} // namespace dvr
-} // namespace android
diff --git a/services/vr/vr_window_manager/composer/impl/vr_composer_view.h b/services/vr/vr_window_manager/composer/impl/vr_composer_view.h
deleted file mode 100644
index 8c5ee1f..0000000
--- a/services/vr/vr_window_manager/composer/impl/vr_composer_view.h
+++ /dev/null
@@ -1,36 +0,0 @@
-#ifndef VR_WINDOW_MANAGER_COMPOSER_IMPL_VR_COMPOSER_VIEW_H_
-#define VR_WINDOW_MANAGER_COMPOSER_IMPL_VR_COMPOSER_VIEW_H_
-
-#include <memory>
-
-#include "vr_hwc.h"
-
-namespace android {
-namespace dvr {
-
-class VrComposerView : public ComposerView::Observer {
- public:
- class Callback {
- public:
- virtual ~Callback() = default;
- virtual base::unique_fd OnNewFrame(const ComposerView::Frame& frame) = 0;
- };
-
- VrComposerView(std::unique_ptr<Callback> callback);
- ~VrComposerView() override;
-
- void Initialize(ComposerView* composer_view);
-
- // ComposerView::Observer
- base::unique_fd OnNewFrame(const ComposerView::Frame& frame) override;
-
- private:
- ComposerView* composer_view_;
- std::unique_ptr<Callback> callback_;
- std::mutex mutex_;
-};
-
-} // namespace dvr
-} // namespace android
-
-#endif // VR_WINDOW_MANAGER_COMPOSER_IMPL_VR_COMPOSER_VIEW_H_
diff --git a/services/vr/vr_window_manager/composer_view/Android.bp_disable b/services/vr/vr_window_manager/composer_view/Android.bp_disable
deleted file mode 100644
index 1658154..0000000
--- a/services/vr/vr_window_manager/composer_view/Android.bp_disable
+++ /dev/null
@@ -1,29 +0,0 @@
-cc_binary {
- name: "vr_composer_view",
-
- srcs: ["vr_composer_view.cpp"],
-
- static_libs: [
- "libhwcomposer-client",
- ],
-
- shared_libs: [
- "android.dvr.composer@1.0",
- "android.hardware.graphics.composer@2.1",
- "libbase",
- "libbinder",
- "libhardware",
- "libhwbinder",
- "liblog",
- "libutils",
- "libvrhwc",
- ],
-
- cflags: [
- "-DLOG_TAG=\"vr_composer_view\"",
- ],
-
- init_rc: [
- "vr_composer_view.rc",
- ],
-}
diff --git a/services/vr/vr_window_manager/composer_view/vr_composer_view.cpp b/services/vr/vr_window_manager/composer_view/vr_composer_view.cpp
deleted file mode 100644
index 54dff3d..0000000
--- a/services/vr/vr_window_manager/composer_view/vr_composer_view.cpp
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * Copyright 2017 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 <binder/ProcessState.h>
-#include <hwbinder/IPCThreadState.h>
-#include <impl/vr_composer_view.h>
-#include <impl/vr_hwc.h>
-
-using namespace android;
-using namespace android::dvr;
-
-int main(int, char**) {
- android::ProcessState::self()->startThreadPool();
-
- const char instance[] = "vr_hwcomposer";
- sp<IComposer> service = HIDL_FETCH_IComposer(instance);
- LOG_ALWAYS_FATAL_IF(!service.get(), "Failed to get service");
- LOG_ALWAYS_FATAL_IF(service->isRemote(), "Service is remote");
-
- LOG_ALWAYS_FATAL_IF(service->registerAsService(instance) != ::android::OK,
- "Failed to register service");
-
- sp<IVrComposerView> composer_view = HIDL_FETCH_IVrComposerView(
- "DaydreamDisplay");
- LOG_ALWAYS_FATAL_IF(!composer_view.get(),
- "Failed to get vr_composer_view service");
- LOG_ALWAYS_FATAL_IF(composer_view->isRemote(),
- "vr_composer_view service is remote");
-
- composer_view->registerAsService("DaydreamDisplay");
-
- GetVrComposerViewFromIVrComposerView(composer_view.get())->Initialize(
- GetComposerViewFromIComposer(service.get()));
-
- android::hardware::ProcessState::self()->startThreadPool();
- android::hardware::IPCThreadState::self()->joinThreadPool();
-
- return 0;
-}
diff --git a/services/vr/vr_window_manager/composer_view/vr_composer_view.rc b/services/vr/vr_window_manager/composer_view/vr_composer_view.rc
deleted file mode 100644
index bd9982b..0000000
--- a/services/vr/vr_window_manager/composer_view/vr_composer_view.rc
+++ /dev/null
@@ -1,5 +0,0 @@
-service vr_composer_view /system/bin/vr_composer_view
- class core
- user system
- group system graphics
- writepid /dev/cpuset/system/tasks
diff --git a/services/vr/vr_window_manager/hwc_callback.cpp b/services/vr/vr_window_manager/hwc_callback.cpp
index 43f5042..28e97ff 100644
--- a/services/vr/vr_window_manager/hwc_callback.cpp
+++ b/services/vr/vr_window_manager/hwc_callback.cpp
@@ -32,6 +32,15 @@
} // namespace
+void HwcCallback::HwcLayer::PrintLayer() {
+ ALOGI("appid=%d, type=%d, alpha=%.2f, cursor=%dx%d, color=%02X%02X%02X%02X, "
+ "crop=%.1f,%.1f,%.1f,%.1f, display=%d,%d,%d,%d, dataspace=%d, "
+ "transform=%d", appid, type, alpha, cursor_x, cursor_y, color.r, color.g,
+ color.b, color.a, crop.left, crop.top, crop.right, crop.bottom,
+ display_frame.left, display_frame.right, display_frame.top,
+ display_frame.bottom, dataspace, transform);
+}
+
HwcCallback::HwcCallback(Client* client) : client_(client) {
}
@@ -54,6 +63,11 @@
.appid = layer.app_id,
.type = static_cast<HwcLayer::LayerType>(layer.type),
.alpha = layer.alpha,
+ .cursor_x = layer.cursor_x,
+ .cursor_y = layer.cursor_y,
+ .color = layer.color,
+ .dataspace = layer.dataspace,
+ .transform = layer.transform,
};
}
diff --git a/services/vr/vr_window_manager/hwc_callback.h b/services/vr/vr_window_manager/hwc_callback.h
index f1f91a1..259c4ac 100644
--- a/services/vr/vr_window_manager/hwc_callback.h
+++ b/services/vr/vr_window_manager/hwc_callback.h
@@ -3,15 +3,13 @@
#include <android/dvr/BnVrComposerCallback.h>
#include <android-base/unique_fd.h>
+#include <impl/vr_hwc.h>
#include <deque>
#include <functional>
#include <mutex>
#include <vector>
-#include "impl/vr_composer_view.h"
-#include "impl/vr_hwc.h"
-
namespace android {
class Fence;
@@ -65,6 +63,8 @@
}
}
+ void PrintLayer();
+
sp<Fence> fence;
sp<GraphicBuffer> buffer;
Rectf crop;
@@ -73,6 +73,11 @@
uint32_t appid;
LayerType type;
float alpha;
+ int32_t cursor_x;
+ int32_t cursor_y;
+ IComposerClient::Color color;
+ int32_t dataspace;
+ int32_t transform;
};
enum class FrameStatus {
diff --git a/services/vr/vr_window_manager/surface_flinger_view.cpp b/services/vr/vr_window_manager/surface_flinger_view.cpp
index aef23a1..b41de03 100644
--- a/services/vr/vr_window_manager/surface_flinger_view.cpp
+++ b/services/vr/vr_window_manager/surface_flinger_view.cpp
@@ -2,7 +2,6 @@
#include <android/dvr/IVrComposer.h>
#include <binder/IServiceManager.h>
-#include <impl/vr_composer_view.h>
#include <private/dvr/native_buffer.h>
#include "hwc_callback.h"
diff --git a/services/vr/vr_window_manager/vr_window_manager.cpp b/services/vr/vr_window_manager/vr_window_manager.cpp
index 9d7afe3..dd2cba7 100644
--- a/services/vr/vr_window_manager/vr_window_manager.cpp
+++ b/services/vr/vr_window_manager/vr_window_manager.cpp
@@ -2,7 +2,6 @@
#include <binder/IServiceManager.h>
#include <binder/ProcessState.h>
#include <hwbinder/IPCThreadState.h>
-#include <impl/vr_composer_view.h>
#include <impl/vr_hwc.h>
#include "shell_view.h"