@@ -57,7 +57,7 @@ Layer::Layer(SurfaceFlinger* flinger,
5757 mSecure(false ),
5858 mTextureManager(),
5959 mBufferManager(mTextureManager ),
60- mWidth(0 ), mHeight(0 ), mFixedSize(false )
60+ mWidth(0 ), mHeight(0 ), mNeedsScaling( false ), mFixedSize(false )
6161{
6262}
6363
@@ -216,13 +216,10 @@ void Layer::reloadTexture(const Region& dirty)
216216
217217void Layer::drawForSreenShot () const
218218{
219- bool currentFixedSize = mFixedSize ;
220- bool currentBlending = mNeedsBlending ;
221- const_cast <Layer*>(this )->mFixedSize = false ;
222- const_cast <Layer*>(this )->mFixedSize = true ;
219+ const bool currentFiltering = mNeedsFiltering ;
220+ const_cast <Layer*>(this )->mNeedsFiltering = true ;
223221 LayerBase::drawForSreenShot ();
224- const_cast <Layer*>(this )->mFixedSize = currentFixedSize;
225- const_cast <Layer*>(this )->mNeedsBlending = currentBlending;
222+ const_cast <Layer*>(this )->mNeedsFiltering = currentFiltering;
226223}
227224
228225void Layer::onDraw (const Region& clip) const
@@ -260,11 +257,10 @@ void Layer::onDraw(const Region& clip) const
260257bool Layer::needsFiltering () const
261258{
262259 if (!(mFlags & DisplayHardware::SLOW_CONFIG)) {
263- // NOTE: there is a race here, because mFixedSize is updated in a
264- // binder transaction. however, it doesn't really matter since it is
265- // evaluated each time we draw. To be perfectly correct, this flag
266- // would have to be associated with a buffer.
267- if (mFixedSize )
260+ // if our buffer is not the same size than ourselves,
261+ // we need filtering.
262+ Mutex::Autolock _l (mLock );
263+ if (mNeedsScaling )
268264 return true ;
269265 }
270266 return LayerBase::needsFiltering ();
@@ -321,6 +317,7 @@ sp<GraphicBuffer> Layer::requestBuffer(int index,
321317 Mutex::Autolock _l (mLock );
322318
323319 // zero means default
320+ mFixedSize = reqWidth && reqHeight;
324321 if (!reqFormat) reqFormat = mFormat ;
325322 if (!reqWidth) reqWidth = mWidth ;
326323 if (!reqHeight) reqHeight = mHeight ;
@@ -334,6 +331,7 @@ sp<GraphicBuffer> Layer::requestBuffer(int index,
334331 mReqWidth = reqWidth;
335332 mReqHeight = reqHeight;
336333 mReqFormat = reqFormat;
334+ mNeedsScaling = mWidth != mReqWidth || mHeight != mReqHeight ;
337335
338336 lcblk->reallocateAllExcept (index);
339337 }
@@ -457,6 +455,7 @@ void Layer::setBufferSize(uint32_t w, uint32_t h) {
457455 Mutex::Autolock _l (mLock );
458456 mWidth = w;
459457 mHeight = h;
458+ mNeedsScaling = mWidth != mReqWidth || mHeight != mReqHeight ;
460459}
461460
462461bool Layer::isFixedSize () const {
0 commit comments