diff options
| author | 2019-09-04 13:33:59 -0700 | |
|---|---|---|
| committer | 2019-09-04 13:33:59 -0700 | |
| commit | e199ca954dff7fdfb06e6280695d34a957ed5efc (patch) | |
| tree | 78be7fa3d9855c2a536e80ed4e7360845a968791 /libs/input/SpriteController.cpp | |
| parent | 1bc876bb5b2b8506fe5e47421456c36ba4eefdea (diff) | |
| parent | 9e89d13906739e856ed809ba81c32415770717c6 (diff) | |
DO NOT MERGE - Merge Android 10 into master
Bug: 139893257
Change-Id: I9e3c4fe5406c9913d50fe3b07d7f7cef7a246b96
Diffstat (limited to 'libs/input/SpriteController.cpp')
| -rw-r--r-- | libs/input/SpriteController.cpp | 28 | 
1 files changed, 21 insertions, 7 deletions
| diff --git a/libs/input/SpriteController.cpp b/libs/input/SpriteController.cpp index 173cd507d943..c1868d3a94d6 100644 --- a/libs/input/SpriteController.cpp +++ b/libs/input/SpriteController.cpp @@ -23,14 +23,10 @@  #include <utils/String8.h>  #include <gui/Surface.h> -// ToDo: Fix code to be warning free -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wunused-parameter"  #include <SkBitmap.h>  #include <SkCanvas.h>  #include <SkColor.h>  #include <SkPaint.h> -#pragma GCC diagnostic pop  #include <android/native_window.h> @@ -148,13 +144,16 @@ void SpriteController::doUpdateSprites() {          }      } -    // Resize sprites if needed. +    // Resize and/or reparent sprites if needed.      SurfaceComposerClient::Transaction t;      bool needApplyTransaction = false;      for (size_t i = 0; i < numSprites; i++) {          SpriteUpdate& update = updates.editItemAt(i); +        if (update.state.surfaceControl == nullptr) { +            continue; +        } -        if (update.state.surfaceControl != NULL && update.state.wantSurfaceVisible()) { +        if (update.state.wantSurfaceVisible()) {              int32_t desiredWidth = update.state.icon.bitmap.width();              int32_t desiredHeight = update.state.icon.bitmap.height();              if (update.state.surfaceWidth < desiredWidth @@ -174,6 +173,12 @@ void SpriteController::doUpdateSprites() {                  }              }          } + +        // If surface is a new one, we have to set right layer stack. +        if (update.surfaceChanged || update.state.dirty & DIRTY_DISPLAY_ID) { +            t.setLayerStack(update.state.surfaceControl, update.state.displayId); +            needApplyTransaction = true; +        }      }      if (needApplyTransaction) {          t.apply(); @@ -240,7 +245,7 @@ void SpriteController::doUpdateSprites() {          if (update.state.surfaceControl != NULL && (becomingVisible || becomingHidden                  || (wantSurfaceVisibleAndDrawn && (update.state.dirty & (DIRTY_ALPHA                          | DIRTY_POSITION | DIRTY_TRANSFORMATION_MATRIX | DIRTY_LAYER -                        | DIRTY_VISIBILITY | DIRTY_HOTSPOT))))) { +                        | DIRTY_VISIBILITY | DIRTY_HOTSPOT | DIRTY_DISPLAY_ID))))) {              needApplyTransaction = true;              if (wantSurfaceVisibleAndDrawn @@ -449,6 +454,15 @@ void SpriteController::SpriteImpl::setTransformationMatrix(      }  } +void SpriteController::SpriteImpl::setDisplayId(int32_t displayId) { +    AutoMutex _l(mController->mLock); + +    if (mLocked.state.displayId != displayId) { +        mLocked.state.displayId = displayId; +        invalidateLocked(DIRTY_DISPLAY_ID); +    } +} +  void SpriteController::SpriteImpl::invalidateLocked(uint32_t dirty) {      bool wasDirty = mLocked.state.dirty;      mLocked.state.dirty |= dirty; |