Bug 160095. Don't crash trying to print documents using -moz-opacity. r+sr=bzbarsky.

This commit is contained in:
roc+%cs.cmu.edu 2004-09-29 01:36:46 +00:00
parent bf57384387
commit 5dee51751d

View File

@ -1296,13 +1296,14 @@ void nsViewManager::RenderViews(nsView *aRootView, nsIRenderingContext& aRC,
if (element->mFlags & PUSH_FILTER) { if (element->mFlags & PUSH_FILTER) {
NS_ASSERTION(aRCSurface, NS_ASSERTION(aRCSurface,
"Cannot support translucent elements with doublebuffering disabled"); "Cannot support translucent elements with doublebuffering disabled");
if (aRCSurface) {
// Save current buffer on the stack and start rendering into a new // Save current buffer on the stack and start rendering into a new
// offscreen buffer // offscreen buffer
filterStack.AppendElement(buffers); filterStack.AppendElement(buffers);
buffers = CreateBlendingBuffers(&aRC, PR_FALSE, nsnull, buffers = CreateBlendingBuffers(&aRC, PR_FALSE, nsnull,
(element->mFlags & VIEW_TRANSPARENT) != 0, (element->mFlags & VIEW_TRANSPARENT) != 0,
element->mBounds); element->mBounds);
}
} }
if (element->mFlags & VIEW_RENDERED) { if (element->mFlags & VIEW_RENDERED) {
@ -1320,33 +1321,35 @@ void nsViewManager::RenderViews(nsView *aRootView, nsIRenderingContext& aRC,
} }
if (element->mFlags & POP_FILTER) { if (element->mFlags & POP_FILTER) {
// Pop the last buffer off the stack and composite the current buffer into if (aRCSurface) {
// the last buffer // Pop the last buffer off the stack and composite the current buffer into
BlendingBuffers* doneBuffers = buffers; // the last buffer
buffers = NS_STATIC_CAST(BlendingBuffers*, BlendingBuffers* doneBuffers = buffers;
filterStack.ElementAt(filterStack.Count() - 1)); buffers = NS_STATIC_CAST(BlendingBuffers*,
filterStack.RemoveElementAt(filterStack.Count() - 1); filterStack.ElementAt(filterStack.Count() - 1));
filterStack.RemoveElementAt(filterStack.Count() - 1);
// perform the blend itself.
nsRect damageRectInPixels = element->mBounds; // perform the blend itself.
damageRectInPixels -= buffers->mOffset; nsRect damageRectInPixels = element->mBounds;
damageRectInPixels *= mTwipsToPixels; damageRectInPixels -= buffers->mOffset;
if (damageRectInPixels.width > 0 && damageRectInPixels.height > 0) { damageRectInPixels *= mTwipsToPixels;
nsIRenderingContext* targets[2] = { buffers->mBlackCX, buffers->mWhiteCX }; if (damageRectInPixels.width > 0 && damageRectInPixels.height > 0) {
for (int j = 0; j < 2; j++) { nsIRenderingContext* targets[2] = { buffers->mBlackCX, buffers->mWhiteCX };
if (targets[j]) { for (int j = 0; j < 2; j++) {
mBlender->Blend(0, 0, if (targets[j]) {
damageRectInPixels.width, damageRectInPixels.height, mBlender->Blend(0, 0,
doneBuffers->mBlackCX, targets[j], damageRectInPixels.width, damageRectInPixels.height,
damageRectInPixels.x, damageRectInPixels.y, doneBuffers->mBlackCX, targets[j],
element->mView->GetOpacity(), doneBuffers->mWhiteCX, damageRectInPixels.x, damageRectInPixels.y,
NS_RGB(0, 0, 0), NS_RGB(255, 255, 255)); element->mView->GetOpacity(), doneBuffers->mWhiteCX,
NS_RGB(0, 0, 0), NS_RGB(255, 255, 255));
}
} }
} }
// probably should recycle these so we don't eat the cost of graphics memory
// allocation
delete doneBuffers;
} }
// probably should recycle these so we don't eat the cost of graphics memory
// allocation
delete doneBuffers;
} }
if (element->mFlags & POP_CLIP) { if (element->mFlags & POP_CLIP) {
PopState(RCs, 2); PopState(RCs, 2);