Bug 1040187 - Combine update regions properly when upload hasn't executed yet. r=nical, a=lmandel
authorBas Schouten <bschouten@mozilla.com>
Tue, 26 Aug 2014 13:06:17 +0000
changeset 216665 872fe12f9214
parent 216664 c81810e5f3a5
child 216666 09d840603713
push id3868
push userryanvm@gmail.com
push date2014-09-08 17:05 +0000
treeherdermozilla-beta@f9e4f36ba116 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersnical, lmandel
bugs1040187
milestone33.0
Bug 1040187 - Combine update regions properly when upload hasn't executed yet. r=nical, a=lmandel
gfx/layers/composite/TextureHost.cpp
--- a/gfx/layers/composite/TextureHost.cpp
+++ b/gfx/layers/composite/TextureHost.cpp
@@ -353,19 +353,22 @@ BufferTextureHost::BufferTextureHost(gfx
 
 BufferTextureHost::~BufferTextureHost()
 {}
 
 void
 BufferTextureHost::Updated(const nsIntRegion* aRegion)
 {
   ++mUpdateSerial;
-  if (aRegion) {
+  // If the last frame wasn't uploaded yet, and we -don't- have a partial update,
+  // we still need to update the full surface.
+  // XXX - Clean this up a little bit, this is a little confusing.
+  if (aRegion && ((mFirstSource && mFirstSource->GetUpdateSerial() == mUpdateSerial) || mPartialUpdate)) {
     mPartialUpdate = true;
-    mMaybeUpdatedRegion = *aRegion;
+    mMaybeUpdatedRegion = mMaybeUpdatedRegion.Or(mMaybeUpdatedRegion, *aRegion);
   } else {
     mPartialUpdate = false;
   }
   if (GetFlags() & TextureFlags::IMMEDIATE_UPLOAD) {
     DebugOnly<bool> result = MaybeUpload(mPartialUpdate ? &mMaybeUpdatedRegion : nullptr);
     NS_WARN_IF_FALSE(result, "Failed to upload a texture");
   }
 }
@@ -437,16 +440,22 @@ bool
 BufferTextureHost::MaybeUpload(nsIntRegion *aRegion)
 {
   if (mFirstSource && mFirstSource->GetUpdateSerial() == mUpdateSerial) {
     return true;
   }
   if (!Upload(aRegion)) {
     return false;
   }
+
+  // We no longer have an invalid region.
+  mPartialUpdate = false;
+  mMaybeUpdatedRegion.SetEmpty();
+
+  // If upload returns true we know mFirstSource is not null
   mFirstSource->SetUpdateSerial(mUpdateSerial);
   return true;
 }
 
 bool
 BufferTextureHost::Upload(nsIntRegion *aRegion)
 {
   if (!GetBuffer()) {