bool DeprecatedContentHostSingleBuffered::UpdateThebes(const ThebesBufferData& aData, const nsIntRegion& aUpdated, const nsIntRegion& aOldValidRegionBack, nsIntRegion* aUpdatedRegionBack) { aUpdatedRegionBack->SetEmpty(); if (!mDeprecatedTextureHost && !mNewFrontHost) { mInitialised = false; return true; } if (mNewFrontHost) { DestroyFrontHost(); mDeprecatedTextureHost = mNewFrontHost; mNewFrontHost = nullptr; if (mNewFrontHostOnWhite) { mDeprecatedTextureHostOnWhite = mNewFrontHostOnWhite; mNewFrontHostOnWhite = nullptr; } } MOZ_ASSERT(mDeprecatedTextureHost); MOZ_ASSERT(!mNewFrontHostOnWhite, "New white host without a new black?"); // updated is in screen coordinates. Convert it to buffer coordinates. nsIntRegion destRegion(aUpdated); destRegion.MoveBy(-aData.rect().TopLeft()); // Correct for rotation destRegion.MoveBy(aData.rotation()); IntSize size = aData.rect().Size().ToIntSize(); nsIntRect destBounds = destRegion.GetBounds(); destRegion.MoveBy((destBounds.x >= size.width) ? -size.width : 0, (destBounds.y >= size.height) ? -size.height : 0); // We can get arbitrary bad regions from an untrusted client, // which we need to be resilient to. See bug 967330. if((destBounds.x % size.width) + destBounds.width > size.width || (destBounds.y % size.height) + destBounds.height > size.height) { NS_ERROR("updated region lies across rotation boundaries!"); return false; } mDeprecatedTextureHost->Update(*mDeprecatedTextureHost->LockSurfaceDescriptor(), &destRegion); if (mDeprecatedTextureHostOnWhite) { mDeprecatedTextureHostOnWhite->Update(*mDeprecatedTextureHostOnWhite->LockSurfaceDescriptor(), &destRegion); } mInitialised = true; mBufferRect = aData.rect(); mBufferRotation = aData.rotation(); return true; }
bool DeprecatedContentHostDoubleBuffered::UpdateThebes(const ThebesBufferData& aData, const nsIntRegion& aUpdated, const nsIntRegion& aOldValidRegionBack, nsIntRegion* aUpdatedRegionBack) { if (!mDeprecatedTextureHost && !mNewFrontHost) { mInitialised = false; *aUpdatedRegionBack = aUpdated; return true; } if (mNewFrontHost) { DestroyFrontHost(); mDeprecatedTextureHost = mNewFrontHost; mNewFrontHost = nullptr; if (mNewFrontHostOnWhite) { mDeprecatedTextureHostOnWhite = mNewFrontHostOnWhite; mNewFrontHostOnWhite = nullptr; } } MOZ_ASSERT(mDeprecatedTextureHost); MOZ_ASSERT(!mNewFrontHostOnWhite, "New white host without a new black?"); MOZ_ASSERT(mBackHost); RefPtr<DeprecatedTextureHost> oldFront = mDeprecatedTextureHost; mDeprecatedTextureHost = mBackHost; mBackHost = oldFront; oldFront = mDeprecatedTextureHostOnWhite; mDeprecatedTextureHostOnWhite = mBackHostOnWhite; mBackHostOnWhite = oldFront; mDeprecatedTextureHost->Update(*mDeprecatedTextureHost->LockSurfaceDescriptor()); if (mDeprecatedTextureHostOnWhite) { mDeprecatedTextureHostOnWhite->Update(*mDeprecatedTextureHostOnWhite->LockSurfaceDescriptor()); } mInitialised = true; mBufferRect = aData.rect(); mBufferRotation = aData.rotation(); *aUpdatedRegionBack = aUpdated; // Save the current valid region of our front buffer, because if // we're double buffering, it's going to be the valid region for the // next back buffer sent back to the renderer. // // NB: we rely here on the fact that mValidRegion is initialized to // empty, and that the first time Swap() is called we don't have a // valid front buffer that we're going to return to content. mValidRegionForNextBackBuffer = aOldValidRegionBack; return true; }
void DeprecatedContentHostSingleBuffered::UpdateThebes(const ThebesBufferData& aData, const nsIntRegion& aUpdated, const nsIntRegion& aOldValidRegionBack, nsIntRegion* aUpdatedRegionBack) { aUpdatedRegionBack->SetEmpty(); if (!mDeprecatedTextureHost && !mNewFrontHost) { mInitialised = false; return; } if (mNewFrontHost) { DestroyFrontHost(); mDeprecatedTextureHost = mNewFrontHost; mNewFrontHost = nullptr; if (mNewFrontHostOnWhite) { mDeprecatedTextureHostOnWhite = mNewFrontHostOnWhite; mNewFrontHostOnWhite = nullptr; } } MOZ_ASSERT(mDeprecatedTextureHost); MOZ_ASSERT(!mNewFrontHostOnWhite, "New white host without a new black?"); // updated is in screen coordinates. Convert it to buffer coordinates. nsIntRegion destRegion(aUpdated); destRegion.MoveBy(-aData.rect().TopLeft()); // Correct for rotation destRegion.MoveBy(aData.rotation()); gfxIntSize size = aData.rect().Size(); nsIntRect destBounds = destRegion.GetBounds(); destRegion.MoveBy((destBounds.x >= size.width) ? -size.width : 0, (destBounds.y >= size.height) ? -size.height : 0); // There's code to make sure that updated regions don't cross rotation // boundaries, so assert here that this is the case MOZ_ASSERT((destBounds.x % size.width) + destBounds.width <= size.width, "updated region lies across rotation boundaries!"); MOZ_ASSERT((destBounds.y % size.height) + destBounds.height <= size.height, "updated region lies across rotation boundaries!"); mDeprecatedTextureHost->Update(*mDeprecatedTextureHost->LockSurfaceDescriptor(), &destRegion); if (mDeprecatedTextureHostOnWhite) { mDeprecatedTextureHostOnWhite->Update(*mDeprecatedTextureHostOnWhite->LockSurfaceDescriptor(), &destRegion); } mInitialised = true; mBufferRect = aData.rect(); mBufferRotation = aData.rotation(); }
DeprecatedContentHostDoubleBuffered::~DeprecatedContentHostDoubleBuffered() { DestroyTextures(); DestroyFrontHost(); }
ContentHostSingleBuffered::~ContentHostSingleBuffered() { DestroyTextures(); DestroyFrontHost(); }