File tree Expand file tree Collapse file tree 1 file changed +22
-3
lines changed
Expand file tree Collapse file tree 1 file changed +22
-3
lines changed Original file line number Diff line number Diff line change @@ -281,9 +281,28 @@ void Layer::onDraw(const Region& clip) const
281281 GLuint textureName = mTextures [index].name ;
282282 if (UNLIKELY (textureName == -1LU)) {
283283 // the texture has not been created yet, this Layer has
284- // in fact never been drawn into. this happens frequently with
285- // SurfaceView.
286- clearWithOpenGL (clip);
284+ // in fact never been drawn into. This happens frequently with
285+ // SurfaceView because the WindowManager can't know when the client
286+ // has drawn the first time.
287+
288+ // If there is nothing under us, we paint the screen in black, otherwise
289+ // we just skip this update.
290+
291+ // figure out if there is something below us
292+ Region under;
293+ const SurfaceFlinger::LayerVector& drawingLayers (mFlinger ->mDrawingState .layersSortedByZ );
294+ const size_t count = drawingLayers.size ();
295+ for (size_t i=0 ; i<count ; ++i) {
296+ const sp<LayerBase>& layer (drawingLayers[i]);
297+ if (layer.get () == static_cast <LayerBase const *>(this ))
298+ break ;
299+ under.orSelf (layer->visibleRegionScreen );
300+ }
301+ // if not everything below us is covered, we plug the holes!
302+ Region holes (clip.subtract (under));
303+ if (!holes.isEmpty ()) {
304+ clearWithOpenGL (holes);
305+ }
287306 return ;
288307 }
289308 drawWithOpenGL (clip, mTextures [index]);
You can’t perform that action at this time.
0 commit comments