Use view::Surface instead of IGBPs in OutputConfiguration
We are currently limiting the use of IGBPs outside of libgui to allow for
further development of bufferqueues without external breakages. More
information at go/warren-buffers.
BYPASS_IGBP_IGBC_API_REASON: this CL is part of the migration.
Bug: 342197849
Test: atest android.hardware.cts.CameraTest
Flag: com.android.graphics.libgui.flags.wb_libcameraservice
Change-Id: I308eac2a11aceff7d598f3b14cfc87dfe4a1a767
diff --git a/camera/camera2/OutputConfiguration.cpp b/camera/camera2/OutputConfiguration.cpp
index a89d7ca..f67214b 100644
--- a/camera/camera2/OutputConfiguration.cpp
+++ b/camera/camera2/OutputConfiguration.cpp
@@ -37,9 +37,8 @@
const int OutputConfiguration::ROTATION_0 = 0;
const int OutputConfiguration::INVALID_SET_ID = -1;
-const std::vector<sp<IGraphicBufferProducer>>&
- OutputConfiguration::getGraphicBufferProducers() const {
- return mGbps;
+const std::vector<ParcelableSurfaceType>& OutputConfiguration::getSurfaces() const {
+ return mSurfaces;
}
int OutputConfiguration::getRotation() const {
@@ -102,24 +101,23 @@
return mMirrorMode;
}
-int OutputConfiguration::getMirrorMode(sp<IGraphicBufferProducer> surface) const {
+int OutputConfiguration::getMirrorMode(ParcelableSurfaceType surface) const {
if (!flags::mirror_mode_shared_surfaces()) {
return mMirrorMode;
}
- if (mGbps.size() != mMirrorModeForProducers.size()) {
- ALOGE("%s: mGbps size doesn't match mMirrorModeForProducers: %zu vs %zu",
- __FUNCTION__, mGbps.size(), mMirrorModeForProducers.size());
+ if (mSurfaces.size() != mMirrorModeForProducers.size()) {
+ ALOGE("%s: mSurfaces size doesn't match mMirrorModeForProducers: %zu vs %zu",
+ __FUNCTION__, mSurfaces.size(), mMirrorModeForProducers.size());
return mMirrorMode;
}
// Use per-producer mirror mode if available.
- for (size_t i = 0; i < mGbps.size(); i++) {
- if (mGbps[i] == surface) {
+ for (size_t i = 0; i < mSurfaces.size(); i++) {
+ if (mSurfaces[i] == surface) {
return mMirrorModeForProducers[i];
}
}
-
// For surface that doesn't belong to this output configuration, use
// mMirrorMode as default.
ALOGW("%s: Surface doesn't belong to this OutputConfiguration!", __FUNCTION__);
@@ -144,9 +142,9 @@
bool OutputConfiguration::isComplete() const {
return !((mSurfaceType == SURFACE_TYPE_MEDIA_RECORDER ||
- mSurfaceType == SURFACE_TYPE_MEDIA_CODEC ||
- mSurfaceType == SURFACE_TYPE_IMAGE_READER) &&
- mGbps.empty());
+ mSurfaceType == SURFACE_TYPE_MEDIA_CODEC ||
+ mSurfaceType == SURFACE_TYPE_IMAGE_READER) &&
+ mSurfaces.empty());
}
OutputConfiguration::OutputConfiguration() :
@@ -348,7 +346,7 @@
ALOGV("%s: OutputConfiguration: %p, name %s", __FUNCTION__,
surface.graphicBufferProducer.get(),
toString8(surface.name).c_str());
- mGbps.push_back(surface.graphicBufferProducer);
+ mSurfaces.push_back(flagtools::toParcelableSurfaceType(surface));
}
mSensorPixelModesUsed = std::move(sensorPixelModesUsed);
@@ -369,10 +367,10 @@
return err;
}
-OutputConfiguration::OutputConfiguration(sp<IGraphicBufferProducer>& gbp, int rotation,
+OutputConfiguration::OutputConfiguration(ParcelableSurfaceType& surface, int rotation,
const std::string& physicalId,
int surfaceSetID, bool isShared) {
- mGbps.push_back(gbp);
+ mSurfaces.push_back(surface);
mRotation = rotation;
mSurfaceSetID = surfaceSetID;
mIsDeferred = false;
@@ -392,17 +390,17 @@
}
OutputConfiguration::OutputConfiguration(
- const std::vector<sp<IGraphicBufferProducer>>& gbps,
+ const std::vector<ParcelableSurfaceType>& surfaces,
int rotation, const std::string& physicalCameraId, int surfaceSetID, int surfaceType,
int width, int height, bool isShared)
- : mGbps(gbps), mRotation(rotation), mSurfaceSetID(surfaceSetID), mSurfaceType(surfaceType),
- mWidth(width), mHeight(height), mIsDeferred(false), mIsShared(isShared),
- mPhysicalCameraId(physicalCameraId), mIsMultiResolution(false),
+ : mSurfaces(surfaces), mRotation(rotation), mSurfaceSetID(surfaceSetID),
+ mSurfaceType(surfaceType), mWidth(width), mHeight(height), mIsDeferred(false),
+ mIsShared(isShared), mPhysicalCameraId(physicalCameraId), mIsMultiResolution(false),
mDynamicRangeProfile(ANDROID_REQUEST_AVAILABLE_DYNAMIC_RANGE_PROFILES_MAP_STANDARD),
mColorSpace(ANDROID_REQUEST_AVAILABLE_COLOR_SPACE_PROFILES_MAP_UNSPECIFIED),
mStreamUseCase(ANDROID_SCALER_AVAILABLE_STREAM_USE_CASES_DEFAULT),
mTimestampBase(TIMESTAMP_BASE_DEFAULT),
- mMirrorMode(MIRROR_MODE_AUTO), mMirrorModeForProducers(gbps.size(), mMirrorMode),
+ mMirrorMode(MIRROR_MODE_AUTO), mMirrorModeForProducers(surfaces.size(), mMirrorMode),
mUseReadoutTimestamp(false), mFormat(HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED),
mDataspace(0), mUsage(0) { }
@@ -432,14 +430,18 @@
err = parcel->writeInt32(mIsShared ? 1 : 0);
if (err != OK) return err;
+#if WB_LIBCAMERASERVICE_WITH_DEPENDENCIES
+ err = parcel->writeParcelableVector(mSurfaces);
+#else
std::vector<view::Surface> surfaceShims;
- for (auto& gbp : mGbps) {
+ for (auto& gbp : mSurfaces) {
view::Surface surfaceShim;
surfaceShim.name = String16("unknown_name"); // name of surface
surfaceShim.graphicBufferProducer = gbp;
surfaceShims.push_back(surfaceShim);
}
err = parcel->writeParcelableVector(surfaceShims);
+#endif
if (err != OK) return err;
String16 physicalCameraId = toString16(mPhysicalCameraId);
@@ -513,10 +515,9 @@
return false;
}
-bool OutputConfiguration::gbpsEqual(const OutputConfiguration& other) const {
- const std::vector<sp<IGraphicBufferProducer> >& otherGbps =
- other.getGraphicBufferProducers();
- return simpleVectorsEqual(otherGbps, mGbps);
+bool OutputConfiguration::surfacesEqual(const OutputConfiguration& other) const {
+ const std::vector<ParcelableSurfaceType>& otherSurfaces = other.getSurfaces();
+ return simpleVectorsEqual(otherSurfaces, mSurfaces);
}
bool OutputConfiguration::sensorPixelModesUsedEqual(const OutputConfiguration& other) const {
@@ -527,7 +528,6 @@
bool OutputConfiguration::mirrorModesEqual(const OutputConfiguration& other) const {
const std::vector<int>& otherMirrorModes = other.getMirrorModes();
return simpleVectorsEqual(otherMirrorModes, mMirrorModeForProducers);
-
}
bool OutputConfiguration::sensorPixelModesUsedLessThan(const OutputConfiguration& other) const {
@@ -540,17 +540,16 @@
return simpleVectorsLessThan(mMirrorModeForProducers, otherMirrorModes);
}
-bool OutputConfiguration::gbpsLessThan(const OutputConfiguration& other) const {
- const std::vector<sp<IGraphicBufferProducer> >& otherGbps =
- other.getGraphicBufferProducers();
+bool OutputConfiguration::surfacesLessThan(const OutputConfiguration& other) const {
+ const std::vector<ParcelableSurfaceType>& otherSurfaces = other.getSurfaces();
- if (mGbps.size() != otherGbps.size()) {
- return mGbps.size() < otherGbps.size();
+ if (mSurfaces.size() != otherSurfaces.size()) {
+ return mSurfaces.size() < otherSurfaces.size();
}
- for (size_t i = 0; i < mGbps.size(); i++) {
- if (mGbps[i] != otherGbps[i]) {
- return mGbps[i] < otherGbps[i];
+ for (size_t i = 0; i < mSurfaces.size(); i++) {
+ if (mSurfaces[i] != otherSurfaces[i]) {
+ return mSurfaces[i] < otherSurfaces[i];
}
}