diff options
author | Mathias Agopian <mathias@google.com> | 2011-08-30 15:02:41 -0700 |
---|---|---|
committer | Mathias Agopian <mathias@google.com> | 2011-08-30 15:31:51 -0700 |
commit | ce8e0baeff412f3581f39d0361156037386f4ecb (patch) | |
tree | af33ad3d0e3dbcc0027d0e3df6c2b141c4758cd0 /services/surfaceflinger | |
parent | 32901b4fec5db9a137add68f0f38518636593668 (diff) | |
download | frameworks_base-ce8e0baeff412f3581f39d0361156037386f4ecb.zip frameworks_base-ce8e0baeff412f3581f39d0361156037386f4ecb.tar.gz frameworks_base-ce8e0baeff412f3581f39d0361156037386f4ecb.tar.bz2 |
fix display artifacts in preview screen in timelapse video mode
We were not updating the h/w composer state when the buffer size
changed.
We also didn't update the h/w composer state when the transformation
matrix changed (which is related to the above issue, since it would
probably change when the buffer size changes).
Also moved updating the crop to setGeometry(), since we decided
that the "crop" change requires the GEOMETRY_CHANGED flag (ie:
not need to do this every frame)
Bug: 5238473
Change-Id: Ia7b47e145b48581b568d89d9aa2c14ff778be862
Diffstat (limited to 'services/surfaceflinger')
-rw-r--r-- | services/surfaceflinger/Layer.cpp | 53 | ||||
-rw-r--r-- | services/surfaceflinger/LayerBase.cpp | 9 |
2 files changed, 39 insertions, 23 deletions
diff --git a/services/surfaceflinger/Layer.cpp b/services/surfaceflinger/Layer.cpp index f8925b8..edbc7b0 100644 --- a/services/surfaceflinger/Layer.cpp +++ b/services/surfaceflinger/Layer.cpp @@ -212,19 +212,6 @@ void Layer::setGeometry(hwc_layer_t* hwcl) } else { hwcl->transform = finalTransform; } -} - -void Layer::setPerFrameData(hwc_layer_t* hwcl) { - const sp<GraphicBuffer>& buffer(mActiveBuffer); - if (buffer == NULL) { - // this can happen if the client never drew into this layer yet, - // or if we ran out of memory. In that case, don't let - // HWC handle it. - hwcl->flags |= HWC_SKIP_LAYER; - hwcl->handle = NULL; - } else { - hwcl->handle = buffer->handle; - } if (isCropped()) { hwcl->sourceCrop.left = mCurrentCrop.left; @@ -232,6 +219,7 @@ void Layer::setPerFrameData(hwc_layer_t* hwcl) { hwcl->sourceCrop.right = mCurrentCrop.right; hwcl->sourceCrop.bottom = mCurrentCrop.bottom; } else { + const sp<GraphicBuffer>& buffer(mActiveBuffer); hwcl->sourceCrop.left = 0; hwcl->sourceCrop.top = 0; if (buffer != NULL) { @@ -244,6 +232,19 @@ void Layer::setPerFrameData(hwc_layer_t* hwcl) { } } +void Layer::setPerFrameData(hwc_layer_t* hwcl) { + const sp<GraphicBuffer>& buffer(mActiveBuffer); + if (buffer == NULL) { + // this can happen if the client never drew into this layer yet, + // or if we ran out of memory. In that case, don't let + // HWC handle it. + hwcl->flags |= HWC_SKIP_LAYER; + hwcl->handle = NULL; + } else { + hwcl->handle = buffer->handle; + } +} + void Layer::onDraw(const Region& clip) const { if (CC_UNLIKELY(mActiveBuffer == 0)) { @@ -416,8 +417,7 @@ void Layer::lockPageFlip(bool& recomputeVisibleRegions) return; } - mActiveBuffer = mSurfaceTexture->getCurrentBuffer(); - mSurfaceTexture->getTransformMatrix(mTextureMatrix); + sp<GraphicBuffer> newFrontBuffer(mSurfaceTexture->getCurrentBuffer()); const Rect crop(mSurfaceTexture->getCurrentCrop()); const uint32_t transform(mSurfaceTexture->getCurrentTransform()); @@ -432,7 +432,23 @@ void Layer::lockPageFlip(bool& recomputeVisibleRegions) mFlinger->invalidateHwcGeometry(); } - mCurrentOpacity = getOpacityForFormat(mActiveBuffer->format); + GLfloat textureMatrix[16]; + mSurfaceTexture->getTransformMatrix(textureMatrix); + if (memcmp(textureMatrix, mTextureMatrix, sizeof(textureMatrix))) { + memcpy(mTextureMatrix, textureMatrix, sizeof(textureMatrix)); + mFlinger->invalidateHwcGeometry(); + } + + uint32_t bufWidth = newFrontBuffer->getWidth(); + uint32_t bufHeight = newFrontBuffer->getHeight(); + if (mActiveBuffer != NULL) { + if (bufWidth != uint32_t(mActiveBuffer->width) || + bufHeight != uint32_t(mActiveBuffer->height)) { + mFlinger->invalidateHwcGeometry(); + } + } + + mCurrentOpacity = getOpacityForFormat(newFrontBuffer->format); if (oldOpacity != isOpaque()) { recomputeVisibleRegions = true; } @@ -446,15 +462,14 @@ void Layer::lockPageFlip(bool& recomputeVisibleRegions) // FIXME: mPostedDirtyRegion = dirty & bounds mPostedDirtyRegion.set(front.w, front.h); + // update active buffer + mActiveBuffer = newFrontBuffer; if ((front.w != front.requested_w) || (front.h != front.requested_h)) { // check that we received a buffer of the right size // (Take the buffer's orientation into account) - sp<GraphicBuffer> newFrontBuffer(mActiveBuffer); - uint32_t bufWidth = newFrontBuffer->getWidth(); - uint32_t bufHeight = newFrontBuffer->getHeight(); if (mCurrentTransform & Transform::ROT_90) { swap(bufWidth, bufHeight); } diff --git a/services/surfaceflinger/LayerBase.cpp b/services/surfaceflinger/LayerBase.cpp index 4cc245a..6a5c8e5 100644 --- a/services/surfaceflinger/LayerBase.cpp +++ b/services/surfaceflinger/LayerBase.cpp @@ -335,17 +335,18 @@ void LayerBase::setGeometry(hwc_layer_t* hwcl) reinterpret_cast<hwc_rect_t const *>( visibleRegionScreen.getArray( &hwcl->visibleRegionScreen.numRects)); -} -void LayerBase::setPerFrameData(hwc_layer_t* hwcl) { - hwcl->compositionType = HWC_FRAMEBUFFER; - hwcl->handle = NULL; hwcl->sourceCrop.left = 0; hwcl->sourceCrop.top = 0; hwcl->sourceCrop.right = mTransformedBounds.width(); hwcl->sourceCrop.bottom = mTransformedBounds.height(); } +void LayerBase::setPerFrameData(hwc_layer_t* hwcl) { + hwcl->compositionType = HWC_FRAMEBUFFER; + hwcl->handle = NULL; +} + void LayerBase::setFiltering(bool filtering) { mFiltering = filtering; |