am e4d51bb2: Merge changes I8851617a,Ie1b6f244,I70cab912,Ibd23e30d into eclair

Merge commit 'e4d51bb2a9706a08c3160eb39e076a89c225257c' into eclair-plus-aosp

* commit 'e4d51bb2a9706a08c3160eb39e076a89c225257c':
  fix [2152247] Windows sometimes drawn scaled up.
  invalidate the surface when the physical changes
  introduce the notion of the requested size in the Layer state
  remove unused code
This commit is contained in:
Mathias Agopian
2009-09-30 14:31:22 -07:00
committed by Android Git Automerger
4 changed files with 75 additions and 45 deletions

View File

@@ -294,8 +294,8 @@ sp<SurfaceBuffer> Layer::requestBuffer(int index, int usage)
this, index, w, h, strerror(-err)); this, index, w, h, strerror(-err));
} else { } else {
LOGD_IF(DEBUG_RESIZE, LOGD_IF(DEBUG_RESIZE,
"Layer::requestBuffer(this=%p), index=%d, w=%d, h=%d", "Layer::requestBuffer(this=%p), index=%d, w=%d, h=%d, handle=%p",
this, index, w, h); this, index, w, h, buffer->handle);
} }
if (err == NO_ERROR && buffer->handle != 0) { if (err == NO_ERROR && buffer->handle != 0) {
@@ -318,22 +318,18 @@ uint32_t Layer::doTransaction(uint32_t flags)
const Layer::State& front(drawingState()); const Layer::State& front(drawingState());
const Layer::State& temp(currentState()); const Layer::State& temp(currentState());
// Index of the back buffer if ((front.requested_w != temp.requested_w) ||
const bool backbufferChanged = (front.w != temp.w) || (front.h != temp.h); (front.requested_h != temp.requested_h)) {
if (backbufferChanged) {
// the size changed, we need to ask our client to request a new buffer // the size changed, we need to ask our client to request a new buffer
LOGD_IF(DEBUG_RESIZE, LOGD_IF(DEBUG_RESIZE,
"resize (layer=%p), requested (%dx%d), " "resize (layer=%p), requested (%dx%d), "
"drawing (%d,%d), (%dx%d), (%dx%d)", "drawing (%d,%d), (%dx%d), (%dx%d)",
this, int(temp.w), int(temp.h), this,
int(drawingState().w), int(drawingState().h), int(temp.requested_w), int(temp.requested_h),
int(front.requested_w), int(front.requested_h),
int(mBuffers[0]->getWidth()), int(mBuffers[0]->getHeight()), int(mBuffers[0]->getWidth()), int(mBuffers[0]->getHeight()),
int(mBuffers[1]->getWidth()), int(mBuffers[1]->getHeight())); int(mBuffers[1]->getWidth()), int(mBuffers[1]->getHeight()));
// record the new size, form this point on, when the client request a
// buffer, it'll get the new size.
setDrawingSize(temp.w, temp.h);
// we're being resized and there is a freeze display request, // we're being resized and there is a freeze display request,
// acquire a freeze lock, so that the screen stays put // acquire a freeze lock, so that the screen stays put
// until we've redrawn at the new size; this is to avoid // until we've redrawn at the new size; this is to avoid
@@ -346,9 +342,16 @@ uint32_t Layer::doTransaction(uint32_t flags)
} }
} }
// recompute the visible region // this will make sure LayerBase::doTransaction doesn't update
flags |= Layer::eVisibleRegion; // the drawing state's size
this->contentDirty = true; Layer::State& editDraw(mDrawingState);
editDraw.requested_w = temp.requested_w;
editDraw.requested_h = temp.requested_h;
// record the new size, form this point on, when the client request a
// buffer, it'll get the new size.
setDrawingSize(temp.requested_w, temp.requested_h);
// all buffers need reallocation // all buffers need reallocation
lcblk->reallocate(); lcblk->reallocate();
} }
@@ -392,11 +395,35 @@ void Layer::lockPageFlip(bool& recomputeVisibleRegions)
const Region dirty(lcblk->getDirtyRegion(buf)); const Region dirty(lcblk->getDirtyRegion(buf));
mPostedDirtyRegion = dirty.intersect( newFrontBuffer->getBounds() ); mPostedDirtyRegion = dirty.intersect( newFrontBuffer->getBounds() );
const Layer::State& front(drawingState()); const Layer::State& front(drawingState());
if (newFrontBuffer->getWidth() == front.w && if (newFrontBuffer->getWidth() == front.requested_w &&
newFrontBuffer->getHeight() ==front.h) { newFrontBuffer->getHeight() == front.requested_h)
mFreezeLock.clear(); {
if ((front.w != front.requested_w) ||
(front.h != front.requested_h))
{
// Here we pretend the transaction happened by updating the
// current and drawing states. Drawing state is only accessed
// in this thread, no need to have it locked
Layer::State& editDraw(mDrawingState);
editDraw.w = editDraw.requested_w;
editDraw.h = editDraw.requested_h;
// We also need to update the current state so that we don't
// end-up doing too much work during the next transaction.
// NOTE: We actually don't need hold the transaction lock here
// because State::w and State::h are only accessed from
// this thread
Layer::State& editTemp(currentState());
editTemp.w = editDraw.w;
editTemp.h = editDraw.h;
// recompute visible region
recomputeVisibleRegions = true;
// we now have the correct size, unfreeze the screen
mFreezeLock.clear();
}
} }
// FIXME: signal an event if we have more buffers waiting // FIXME: signal an event if we have more buffers waiting

View File

@@ -83,26 +83,22 @@ void LayerBase::initStates(uint32_t w, uint32_t h, uint32_t flags)
if (flags & ISurfaceComposer::eNonPremultiplied) if (flags & ISurfaceComposer::eNonPremultiplied)
mPremultipliedAlpha = false; mPremultipliedAlpha = false;
mCurrentState.z = 0; mCurrentState.z = 0;
mCurrentState.w = w; mCurrentState.w = w;
mCurrentState.h = h; mCurrentState.h = h;
mCurrentState.alpha = 0xFF; mCurrentState.requested_w = w;
mCurrentState.flags = layerFlags; mCurrentState.requested_h = h;
mCurrentState.sequence = 0; mCurrentState.alpha = 0xFF;
mCurrentState.flags = layerFlags;
mCurrentState.sequence = 0;
mCurrentState.transform.set(0, 0); mCurrentState.transform.set(0, 0);
// drawing state & current state are identical // drawing state & current state are identical
mDrawingState = mCurrentState; mDrawingState = mCurrentState;
} }
void LayerBase::commitTransaction(bool skipSize) { void LayerBase::commitTransaction() {
const uint32_t w = mDrawingState.w;
const uint32_t h = mDrawingState.h;
mDrawingState = mCurrentState; mDrawingState = mCurrentState;
if (skipSize) {
mDrawingState.w = w;
mDrawingState.h = h;
}
} }
void LayerBase::forceVisibilityTransaction() { void LayerBase::forceVisibilityTransaction() {
// this can be called without SurfaceFlinger.mStateLock, but if we // this can be called without SurfaceFlinger.mStateLock, but if we
@@ -138,10 +134,10 @@ bool LayerBase::setLayer(uint32_t z) {
return true; return true;
} }
bool LayerBase::setSize(uint32_t w, uint32_t h) { bool LayerBase::setSize(uint32_t w, uint32_t h) {
if (mCurrentState.w == w && mCurrentState.h == h) if (mCurrentState.requested_w == w && mCurrentState.requested_h == h)
return false; return false;
mCurrentState.w = w; mCurrentState.requested_w = w;
mCurrentState.h = h; mCurrentState.requested_h = h;
requestTransaction(); requestTransaction();
return true; return true;
} }
@@ -198,13 +194,25 @@ uint32_t LayerBase::doTransaction(uint32_t flags)
const Layer::State& front(drawingState()); const Layer::State& front(drawingState());
const Layer::State& temp(currentState()); const Layer::State& temp(currentState());
if (temp.sequence != front.sequence) { if ((front.requested_w != temp.requested_w) ||
(front.requested_h != temp.requested_h)) {
// resize the layer, set the physical size to the requested size
Layer::State& editTemp(currentState());
editTemp.w = temp.requested_w;
editTemp.h = temp.requested_h;
}
if ((front.w != temp.w) || (front.h != temp.h)) {
// invalidate and recompute the visible regions if needed // invalidate and recompute the visible regions if needed
flags |= eVisibleRegion; flags |= Layer::eVisibleRegion;
this->contentDirty = true; this->contentDirty = true;
} }
if (temp.sequence != front.sequence) { if (temp.sequence != front.sequence) {
// invalidate and recompute the visible regions if needed
flags |= eVisibleRegion;
this->contentDirty = true;
const bool linearFiltering = mUseLinearFiltering; const bool linearFiltering = mUseLinearFiltering;
mUseLinearFiltering = false; mUseLinearFiltering = false;
if (!(mFlags & DisplayHardware::SLOW_CONFIG)) { if (!(mFlags & DisplayHardware::SLOW_CONFIG)) {
@@ -217,7 +225,7 @@ uint32_t LayerBase::doTransaction(uint32_t flags)
} }
// Commit the transaction // Commit the transaction
commitTransaction(flags & eRestartTransaction); commitTransaction();
return flags; return flags;
} }

View File

@@ -88,6 +88,8 @@ public:
struct State { struct State {
uint32_t w; uint32_t w;
uint32_t h; uint32_t h;
uint32_t requested_w;
uint32_t requested_h;
uint32_t z; uint32_t z;
uint8_t alpha; uint8_t alpha;
uint8_t flags; uint8_t flags;
@@ -107,7 +109,7 @@ public:
bool setTransparentRegionHint(const Region& opaque); bool setTransparentRegionHint(const Region& opaque);
bool setFlags(uint8_t flags, uint8_t mask); bool setFlags(uint8_t flags, uint8_t mask);
void commitTransaction(bool skipSize); void commitTransaction();
bool requestTransaction(); bool requestTransaction();
void forceVisibilityTransaction(); void forceVisibilityTransaction();
@@ -211,7 +213,6 @@ public:
enum { // flags for doTransaction() enum { // flags for doTransaction()
eVisibleRegion = 0x00000002, eVisibleRegion = 0x00000002,
eRestartTransaction = 0x00000008
}; };

View File

@@ -594,12 +594,6 @@ void SurfaceFlinger::handleTransactionLocked(
const uint32_t flags = layer->doTransaction(0); const uint32_t flags = layer->doTransaction(0);
if (flags & Layer::eVisibleRegion) if (flags & Layer::eVisibleRegion)
mVisibleRegionsDirty = true; mVisibleRegionsDirty = true;
if (flags & Layer::eRestartTransaction) {
// restart the transaction, but back-off a little
layer->setTransactionFlags(eTransactionNeeded);
setTransactionFlags(eTraversalNeeded, ms2ns(8));
}
} }
} }