From 08da0bf17caeb564d7fe7a0b08b057df2f8ca45e Mon Sep 17 00:00:00 2001 From: Jesse Hall Date: Tue, 31 Jul 2012 12:16:31 -0700 Subject: Revert "Minimal changes to support multi-display HWC" This reverts commit bddd724b178b1263c16e41b564165fcd0e93ff83 Change-Id: Ib7db20b5b3de4779b6e173473a33976ae398abd4 --- opengl/tests/hwc/hwcColorEquiv.cpp | 12 ++--- opengl/tests/hwc/hwcCommit.cpp | 4 +- opengl/tests/hwc/hwcRects.cpp | 8 ++- opengl/tests/hwc/hwcStress.cpp | 8 ++- opengl/tests/hwc/hwcTestLib.cpp | 16 +++--- opengl/tests/hwc/hwcTestLib.h | 10 ++-- .../surfaceflinger/DisplayHardware/HWComposer.cpp | 62 +++++++--------------- .../surfaceflinger/DisplayHardware/HWComposer.h | 4 +- 8 files changed, 47 insertions(+), 77 deletions(-) diff --git a/opengl/tests/hwc/hwcColorEquiv.cpp b/opengl/tests/hwc/hwcColorEquiv.cpp index 160906d..ab5277e 100644 --- a/opengl/tests/hwc/hwcColorEquiv.cpp +++ b/opengl/tests/hwc/hwcColorEquiv.cpp @@ -344,9 +344,9 @@ main(int argc, char *argv[]) hwcTestFillColorHBlend(equivFrame.get(), refFormat->format, startRefColor, endRefColor); - hwc_display_contents_1_t *list; - size_t size = sizeof(hwc_display_contents_1_t) + numFrames * sizeof(hwc_layer_1_t); - if ((list = (hwc_display_contents_1_t *) calloc(1, size)) == NULL) { + hwc_layer_list_1_t *list; + size_t size = sizeof(hwc_layer_list_1_t) + numFrames * sizeof(hwc_layer_1_t); + if ((list = (hwc_layer_list_1_t *) calloc(1, size)) == NULL) { testPrintE("Allocate list failed"); exit(11); } @@ -383,7 +383,7 @@ main(int argc, char *argv[]) // Perform prepare operation if (verbose) { testPrintI("Prepare:"); hwcTestDisplayList(list); } - hwcDevice->prepare(hwcDevice, 1, &list); + hwcDevice->prepare(hwcDevice, list); if (verbose) { testPrintI("Post Prepare:"); hwcTestDisplayListPrepareModifiable(list); @@ -393,9 +393,7 @@ main(int argc, char *argv[]) list->flags &= ~HWC_GEOMETRY_CHANGED; if (verbose) {hwcTestDisplayListHandles(list); } - list->dpy = dpy; - list->sur = surface; - hwcDevice->set(hwcDevice, 1, &list); + hwcDevice->set(hwcDevice, dpy, surface, list); testDelay(endDelay); diff --git a/opengl/tests/hwc/hwcCommit.cpp b/opengl/tests/hwc/hwcCommit.cpp index 3681fbb..d4873d8 100644 --- a/opengl/tests/hwc/hwcCommit.cpp +++ b/opengl/tests/hwc/hwcCommit.cpp @@ -1397,7 +1397,7 @@ void Rational::double2Rational(double f, Range nRange, Range dRange, // Given a list of rectangles, determine how many HWC will commit to render uint32_t numOverlays(list& rectList) { - hwc_display_contents_1_t *hwcList; + hwc_layer_list_1_t *hwcList; list > buffers; hwcList = hwcTestCreateLayerList(rectList.size()); @@ -1430,7 +1430,7 @@ uint32_t numOverlays(list& rectList) // Perform prepare operation if (verbose) { testPrintI("Prepare:"); hwcTestDisplayList(hwcList); } - hwcDevice->prepare(hwcDevice, 1, &hwcList); + hwcDevice->prepare(hwcDevice, hwcList); if (verbose) { testPrintI("Post Prepare:"); hwcTestDisplayListPrepareModifiable(hwcList); diff --git a/opengl/tests/hwc/hwcRects.cpp b/opengl/tests/hwc/hwcRects.cpp index ec0403f..e2f0039 100644 --- a/opengl/tests/hwc/hwcRects.cpp +++ b/opengl/tests/hwc/hwcRects.cpp @@ -307,7 +307,7 @@ main(int argc, char *argv[]) } // Create list of frames - hwc_display_contents_1_t *list; + hwc_layer_list_1_t *list; list = hwcTestCreateLayerList(rectangle.size()); if (list == NULL) { testPrintE("hwcTestCreateLayerList failed"); @@ -329,7 +329,7 @@ main(int argc, char *argv[]) // Perform prepare operation if (verbose) { testPrintI("Prepare:"); hwcTestDisplayList(list); } - hwcDevice->prepare(hwcDevice, 1, &list); + hwcDevice->prepare(hwcDevice, list); if (verbose) { testPrintI("Post Prepare:"); hwcTestDisplayListPrepareModifiable(list); @@ -341,9 +341,7 @@ main(int argc, char *argv[]) // Perform the set operation(s) if (verbose) {testPrintI("Set:"); } if (verbose) { hwcTestDisplayListHandles(list); } - list->dpy = dpy; - list->sur = surface; - hwcDevice->set(hwcDevice, 1, &list); + hwcDevice->set(hwcDevice, dpy, surface, list); testDelay(endDelay); diff --git a/opengl/tests/hwc/hwcStress.cpp b/opengl/tests/hwc/hwcStress.cpp index 3e8ea8d..ccc7328 100644 --- a/opengl/tests/hwc/hwcStress.cpp +++ b/opengl/tests/hwc/hwcStress.cpp @@ -409,7 +409,7 @@ main(int argc, char *argv[]) // generated for this pass. srand48(pass); - hwc_display_contents_1_t *list; + hwc_layer_list_1_t *list; list = hwcTestCreateLayerList(testRandMod(frames.size()) + 1); if (list == NULL) { testPrintE("hwcTestCreateLayerList failed"); @@ -478,7 +478,7 @@ main(int argc, char *argv[]) // Perform prepare operation if (verbose) { testPrintI("Prepare:"); hwcTestDisplayList(list); } - hwcDevice->prepare(hwcDevice, 1, &list); + hwcDevice->prepare(hwcDevice, list); if (verbose) { testPrintI("Post Prepare:"); hwcTestDisplayListPrepareModifiable(list); @@ -491,9 +491,7 @@ main(int argc, char *argv[]) if (verbose) {testPrintI("Set:"); } for (unsigned int n1 = 0; n1 < numSet; n1++) { if (verbose) { hwcTestDisplayListHandles(list); } - list->dpy = dpy; - list->sur = surface; - hwcDevice->set(hwcDevice, 1, &list); + hwcDevice->set(hwcDevice, dpy, surface, list); // Prandomly select a new set of handles for (unsigned int n1 = 0; n1 < list->numHwLayers; n1++) { diff --git a/opengl/tests/hwc/hwcTestLib.cpp b/opengl/tests/hwc/hwcTestLib.cpp index d567e6e..c6dbe9d 100644 --- a/opengl/tests/hwc/hwcTestLib.cpp +++ b/opengl/tests/hwc/hwcTestLib.cpp @@ -399,12 +399,12 @@ const char *hwcTestGraphicFormat2str(uint32_t format) * Dynamically creates layer list with numLayers worth * of hwLayers entries. */ -hwc_display_contents_1_t *hwcTestCreateLayerList(size_t numLayers) +hwc_layer_list_1_t *hwcTestCreateLayerList(size_t numLayers) { - hwc_display_contents_1_t *list; + hwc_layer_list_1_t *list; - size_t size = sizeof(hwc_display_contents_1_t) + numLayers * sizeof(hwc_layer_1_t); - if ((list = (hwc_display_contents_1_t *) calloc(1, size)) == NULL) { + size_t size = sizeof(hwc_layer_list_1_t) + numLayers * sizeof(hwc_layer_1_t); + if ((list = (hwc_layer_list_1_t *) calloc(1, size)) == NULL) { return NULL; } list->flags = HWC_GEOMETRY_CHANGED; @@ -417,13 +417,13 @@ hwc_display_contents_1_t *hwcTestCreateLayerList(size_t numLayers) * hwcTestFreeLayerList * Frees memory previous allocated via hwcTestCreateLayerList(). */ -void hwcTestFreeLayerList(hwc_display_contents_1_t *list) +void hwcTestFreeLayerList(hwc_layer_list_1_t *list) { free(list); } // Display the settings of the layer list pointed to by list -void hwcTestDisplayList(hwc_display_contents_1_t *list) +void hwcTestDisplayList(hwc_layer_list_1_t *list) { testPrintI(" flags: %#x%s", list->flags, (list->flags & HWC_GEOMETRY_CHANGED) ? " GEOMETRY_CHANGED" : ""); @@ -494,7 +494,7 @@ void hwcTestDisplayList(hwc_display_contents_1_t *list) * Displays the portions of a list that are meant to be modified by * a prepare call. */ -void hwcTestDisplayListPrepareModifiable(hwc_display_contents_1_t *list) +void hwcTestDisplayListPrepareModifiable(hwc_layer_list_1_t *list) { uint32_t numOverlays = 0; for (unsigned int layer = 0; layer < list->numHwLayers; layer++) { @@ -522,7 +522,7 @@ void hwcTestDisplayListPrepareModifiable(hwc_display_contents_1_t *list) * * Displays the handles of all the graphic buffers in the list. */ -void hwcTestDisplayListHandles(hwc_display_contents_1_t *list) +void hwcTestDisplayListHandles(hwc_layer_list_1_t *list) { const unsigned int maxLayersPerLine = 6; diff --git a/opengl/tests/hwc/hwcTestLib.h b/opengl/tests/hwc/hwcTestLib.h index d7d5837..db3f5c1 100644 --- a/opengl/tests/hwc/hwcTestLib.h +++ b/opengl/tests/hwc/hwcTestLib.h @@ -113,11 +113,11 @@ const struct hwcTestGraphicFormat *hwcTestGraphicFormatLookup(uint32_t id); const char *hwcTestGraphicFormat2str(uint32_t format); std::string hwcTestRect2str(const struct hwc_rect& rect); -hwc_display_contents_1_t *hwcTestCreateLayerList(size_t numLayers); -void hwcTestFreeLayerList(hwc_display_contents_1_t *list); -void hwcTestDisplayList(hwc_display_contents_1_t *list); -void hwcTestDisplayListPrepareModifiable(hwc_display_contents_1_t *list); -void hwcTestDisplayListHandles(hwc_display_contents_1_t *list); +hwc_layer_list_1_t *hwcTestCreateLayerList(size_t numLayers); +void hwcTestFreeLayerList(hwc_layer_list_1_t *list); +void hwcTestDisplayList(hwc_layer_list_1_t *list); +void hwcTestDisplayListPrepareModifiable(hwc_layer_list_1_t *list); +void hwcTestDisplayListHandles(hwc_layer_list_1_t *list); uint32_t hwcTestColor2Pixel(uint32_t format, ColorFract color, float alpha); void hwcTestColorConvert(uint32_t fromFormat, uint32_t toFormat, diff --git a/services/surfaceflinger/DisplayHardware/HWComposer.cpp b/services/surfaceflinger/DisplayHardware/HWComposer.cpp index 8438159..0a633f0 100644 --- a/services/surfaceflinger/DisplayHardware/HWComposer.cpp +++ b/services/surfaceflinger/DisplayHardware/HWComposer.cpp @@ -57,12 +57,12 @@ namespace android { // can just use the v1.0 pointer without branches or casts. #if HWC_REMOVE_DEPRECATED_VERSIONS -// We need complete types to satisfy semantic checks, even though the code -// paths that use these won't get executed at runtime (and will likely be dead- -// code-eliminated). When we remove the code to support v0.3 we can remove +// We need complete types with to satisfy semantic checks, even though the +// code paths that use these won't get executed at runtime (and will likely be +// dead-code-eliminated). When we remove the code to support v0.3 we can remove // these as well. typedef hwc_layer_1_t hwc_layer_t; -typedef hwc_display_contents_1_t hwc_layer_list_t; +typedef hwc_layer_list_1_t hwc_layer_list_t; typedef hwc_composer_device_1_t hwc_composer_device_t; #endif @@ -80,7 +80,7 @@ static bool hwcHasVersion(const hwc_composer_device_1_t* hwc, uint32_t version) static size_t sizeofHwcLayerList(const hwc_composer_device_1_t* hwc, size_t numLayers) { if (hwcHasVersion(hwc, HWC_DEVICE_API_VERSION_1_0)) { - return sizeof(hwc_display_contents_1_t) + numLayers*sizeof(hwc_layer_1_t); + return sizeof(hwc_layer_list_1_t) + numLayers*sizeof(hwc_layer_1_t); } else { return sizeof(hwc_layer_list_t) + numLayers*sizeof(hwc_layer_t); } @@ -136,17 +136,11 @@ HWComposer::HWComposer( } if (mHwc) { - // always turn vsync off when we start - needVSyncThread = false; - if (hwcHasVersion(mHwc, HWC_DEVICE_API_VERSION_1_0)) { - mHwc->methods->eventControl(mHwc, 0, HWC_EVENT_VSYNC, 0); - } else if (hwcHasVersion(mHwc, HWC_DEVICE_API_VERSION_0_3)) { - hwc_composer_device_t* hwc0 = (hwc_composer_device_t*)mHwc; - err = hwc0->methods->eventControl(hwc0, HWC_EVENT_VSYNC, 0); - } else { - needVSyncThread = true; + if (hwcHasVersion(mHwc, HWC_DEVICE_API_VERSION_0_3)) { + // always turn vsync off when we start + mHwc->methods->eventControl(mHwc, HWC_EVENT_VSYNC, 0); + needVSyncThread = false; } - if (mHwc->registerProcs) { mCBContext->hwc = this; mCBContext->procs.invalidate = &hook_invalidate; @@ -200,12 +194,7 @@ void HWComposer::eventControl(int event, int enabled) { status_t err = NO_ERROR; if (mHwc && mHwc->common.version >= HWC_DEVICE_API_VERSION_0_3) { if (!mDebugForceFakeVSync) { - if (hwcHasVersion(mHwc, HWC_DEVICE_API_VERSION_1_0)) { - err = mHwc->methods->eventControl(mHwc, 0, event, enabled); - } else { - hwc_composer_device_t* hwc0 = (hwc_composer_device_t*)mHwc; - err = hwc0->methods->eventControl(hwc0, event, enabled); - } + err = mHwc->methods->eventControl(mHwc, event, enabled); // error here should not happen -- not sure what we should // do if it does. ALOGE_IF(err, "eventControl(%d, %d) failed %s", @@ -228,9 +217,8 @@ status_t HWComposer::createWorkList(size_t numLayers) { if (!mList || mCapacity < numLayers) { free(mList); size_t size = sizeofHwcLayerList(mHwc, numLayers); - mList = (hwc_display_contents_1_t*)malloc(size); + mList = (hwc_layer_list_1_t*)malloc(size); mCapacity = numLayers; - mList->flipFenceFd = -1; } mList->flags = HWC_GEOMETRY_CHANGED; mList->numHwLayers = numLayers; @@ -239,8 +227,7 @@ status_t HWComposer::createWorkList(size_t numLayers) { } status_t HWComposer::prepare() const { - int err = mHwc->prepare(mHwc, 1, - const_cast(&mList)); + int err = mHwc->prepare(mHwc, mList); if (err == NO_ERROR) { size_t numOVLayers = 0; size_t numFBLayers = 0; @@ -286,17 +273,9 @@ size_t HWComposer::getLayerCount(int type) const { status_t HWComposer::commit() const { int err = NO_ERROR; if (mHwc) { - if (mList) { - mList->dpy = mDpy; - mList->sur = mSur; - } - err = mHwc->set(mHwc, 1, const_cast(&mList)); + err = mHwc->set(mHwc, mDpy, mSur, mList); if (mList) { mList->flags &= ~HWC_GEOMETRY_CHANGED; - if (mList->flipFenceFd != -1) { - close(mList->flipFenceFd); - mList->flipFenceFd = -1; - } } } else { eglSwapBuffers(mDpy, mSur); @@ -306,20 +285,17 @@ status_t HWComposer::commit() const { status_t HWComposer::release() const { if (mHwc) { - if (hwcHasVersion(mHwc, HWC_DEVICE_API_VERSION_1_0)) { - mHwc->methods->eventControl(mHwc, 0, HWC_EVENT_VSYNC, 0); - } else if (hwcHasVersion(mHwc, HWC_DEVICE_API_VERSION_0_3)) { - hwc_composer_device_t* hwc0 = (hwc_composer_device_t*)mHwc; - hwc0->methods->eventControl(hwc0, HWC_EVENT_VSYNC, 0); + if (hwcHasVersion(mHwc, HWC_DEVICE_API_VERSION_0_3)) { + mHwc->methods->eventControl(mHwc, HWC_EVENT_VSYNC, 0); } - int err = mHwc->set(mHwc, 0, NULL); + int err = mHwc->set(mHwc, NULL, NULL, NULL); if (err < 0) { return (status_t)err; } if (hwcHasVersion(mHwc, HWC_DEVICE_API_VERSION_1_0)) { if (mHwc->methods && mHwc->methods->blank) { - err = mHwc->methods->blank(mHwc, 0, 1); + err = mHwc->methods->blank(mHwc, 1); } } return (status_t)err; @@ -331,7 +307,7 @@ status_t HWComposer::acquire() const { if (mHwc) { if (hwcHasVersion(mHwc, HWC_DEVICE_API_VERSION_1_0)) { if (mHwc->methods && mHwc->methods->blank) { - int err = mHwc->methods->blank(mHwc, 0, 0); + int err = mHwc->methods->blank(mHwc, 0); return (status_t)err; } } @@ -344,7 +320,7 @@ status_t HWComposer::disable() { if (mHwc) { free(mList); mList = NULL; - int err = mHwc->prepare(mHwc, 0, NULL); + int err = mHwc->prepare(mHwc, NULL); return (status_t)err; } return NO_ERROR; diff --git a/services/surfaceflinger/DisplayHardware/HWComposer.h b/services/surfaceflinger/DisplayHardware/HWComposer.h index 8771109..c2fff4f 100644 --- a/services/surfaceflinger/DisplayHardware/HWComposer.h +++ b/services/surfaceflinger/DisplayHardware/HWComposer.h @@ -36,7 +36,7 @@ extern "C" int clock_nanosleep(clockid_t clock_id, int flags, struct timespec *remain); struct hwc_composer_device_1; -struct hwc_display_contents_1; +struct hwc_layer_list_1; struct hwc_procs; namespace android { @@ -230,7 +230,7 @@ private: sp mFlinger; hw_module_t const* mModule; struct hwc_composer_device_1* mHwc; - struct hwc_display_contents_1* mList; + struct hwc_layer_list_1* mList; size_t mCapacity; mutable size_t mNumOVLayers; mutable size_t mNumFBLayers; -- cgit v1.1 From e5769db877e3ebc55195b4b53a95b51587d7b5b2 Mon Sep 17 00:00:00 2001 From: Mathias Agopian Date: Wed, 15 Aug 2012 13:46:03 -0700 Subject: we were mistakenly optimizing out SF's main transactions in some cases due to a typo, SF's main transaction was conditional to having a display transaction. more correct fix for 6970310 Bug: 6970310 Change-Id: Iafd8c4e02afa5db829cc1c65950cfcc74754c6af --- services/surfaceflinger/SurfaceFlinger.cpp | 55 ++++++++++++++++-------------- 1 file changed, 29 insertions(+), 26 deletions(-) diff --git a/services/surfaceflinger/SurfaceFlinger.cpp b/services/surfaceflinger/SurfaceFlinger.cpp index 3a802ff..9178dfc 100644 --- a/services/surfaceflinger/SurfaceFlinger.cpp +++ b/services/surfaceflinger/SurfaceFlinger.cpp @@ -891,8 +891,7 @@ void SurfaceFlinger::handleTransactionLocked(uint32_t transactionFlags) * (perform the transaction for each of them if needed) */ - const bool layersNeedTransaction = transactionFlags & eTraversalNeeded; - if (layersNeedTransaction) { + if (transactionFlags & eTraversalNeeded) { for (size_t i=0 ; i& layer = currentLayers[i]; uint32_t trFlags = layer->getTransactionFlags(eTransactionNeeded); @@ -905,7 +904,7 @@ void SurfaceFlinger::handleTransactionLocked(uint32_t transactionFlags) } /* - * Perform our own transaction if needed + * Perform display own transactions if needed */ if (transactionFlags & eDisplayTransactionNeeded) { @@ -978,31 +977,35 @@ void SurfaceFlinger::handleTransactionLocked(uint32_t transactionFlags) } } } + } - if (currentLayers.size() > mDrawingState.layersSortedByZ.size()) { - // layers have been added - mVisibleRegionsDirty = true; - } + /* + * Perform our own transaction if needed + */ - // some layers might have been removed, so - // we need to update the regions they're exposing. - if (mLayersRemoved) { - mLayersRemoved = false; - mVisibleRegionsDirty = true; - const LayerVector& previousLayers(mDrawingState.layersSortedByZ); - const size_t count = previousLayers.size(); - for (size_t i=0 ; i& layer(previousLayers[i]); - if (currentLayers.indexOf(layer) < 0) { - // this layer is not visible anymore - // TODO: we could traverse the tree from front to back and - // compute the actual visible region - // TODO: we could cache the transformed region - Layer::State front(layer->drawingState()); - Region visibleReg = front.transform.transform( - Region(Rect(front.active.w, front.active.h))); - invalidateLayerStack(front.layerStack, visibleReg); - } + if (currentLayers.size() > mDrawingState.layersSortedByZ.size()) { + // layers have been added + mVisibleRegionsDirty = true; + } + + // some layers might have been removed, so + // we need to update the regions they're exposing. + if (mLayersRemoved) { + mLayersRemoved = false; + mVisibleRegionsDirty = true; + const LayerVector& previousLayers(mDrawingState.layersSortedByZ); + const size_t count = previousLayers.size(); + for (size_t i=0 ; i& layer(previousLayers[i]); + if (currentLayers.indexOf(layer) < 0) { + // this layer is not visible anymore + // TODO: we could traverse the tree from front to back and + // compute the actual visible region + // TODO: we could cache the transformed region + Layer::State front(layer->drawingState()); + Region visibleReg = front.transform.transform( + Region(Rect(front.active.w, front.active.h))); + invalidateLayerStack(front.layerStack, visibleReg); } } } -- cgit v1.1