Mozilla Home
Privacy
Cookies
Legal
Bugzilla
Browse
Advanced Search
New Bug
Reports
Documentation
Log In
Log In with GitHub
or
Remember me
Browse
Advanced Search
New Bug
Reports
Documentation
Attachment 514069 Details for
Bug 635373
[patch]
better fix for D3D9 and D3D10
bug635373 (text/plain), 5.08 KB, created by
Robert O'Callahan (:roc) (email my personal email if necessary)
(
hide
)
Description:
better fix for D3D9 and D3D10
Filename:
MIME Type:
Creator:
Robert O'Callahan (:roc) (email my personal email if necessary)
Size:
5.08 KB
patch
obsolete
>From: Robert O'Callahan <robert@ocallahan.org> >Bug 635373. If we need to resample a ThebesLayer texture, make sure we make all the pixels of the texture valid in case they get sampled. r=bas > >diff --git a/gfx/layers/d3d10/ThebesLayerD3D10.cpp b/gfx/layers/d3d10/ThebesLayerD3D10.cpp >--- a/gfx/layers/d3d10/ThebesLayerD3D10.cpp >+++ b/gfx/layers/d3d10/ThebesLayerD3D10.cpp >@@ -249,31 +249,43 @@ ThebesLayerD3D10::Validate(ReadbackProce > } > mTextureRegion = mVisibleRegion; > > if (!mTexture || (mode == SURFACE_COMPONENT_ALPHA && !mTextureOnWhite)) { > CreateNewTextures(gfxIntSize(visibleRect.width, visibleRect.height), mode); > mValidRegion.SetEmpty(); > } > >- if (!mValidRegion.IsEqual(mVisibleRegion)) { >+ // If we have a transform that requires resampling of our texture, then >+ // we need to make sure we don't sample pixels that haven't been drawn. >+ // We clamp sample coordinates to the texture rect, but when the visible region >+ // doesn't fill the entire texture rect we need to make sure we draw all the >+ // pixels in the texture rect anyway in case they get sampled. >+ nsIntRegion neededRegion = mVisibleRegion; >+ gfxMatrix transform2d; >+ if (!GetEffectiveTransform().Is2D(&transform2d) || >+ transform2d.HasNonIntegerTranslation()) { >+ neededRegion = mTextureRegion.GetBounds(); >+ } >+ >+ if (!mValidRegion.IsEqual(neededRegion)) { > LayerManagerD3D10::CallbackInfo cbInfo = mD3DManager->GetCallbackInfo(); > if (!cbInfo.Callback) { > NS_ERROR("D3D10 should never need to update ThebesLayers in an empty transaction"); > return; > } > > /* We use the bounds of the visible region because we draw the bounds of > * this region when we draw this entire texture. We have to make sure that > * the areas that aren't filled with content get their background drawn. > * This is an issue for opaque surfaces, which otherwise won't get their > * background painted. > */ > nsIntRegion region; >- region.Sub(mVisibleRegion, mValidRegion); >+ region.Sub(neededRegion, mValidRegion); > > DrawRegion(region, mode); > > if (readbackUpdates.Length() > 0) { > CD3D10_TEXTURE2D_DESC desc(DXGI_FORMAT_B8G8R8A8_UNORM, > visibleRect.width, visibleRect.height, > 1, 1, 0, D3D10_USAGE_STAGING, > D3D10_CPU_ACCESS_READ); >@@ -284,17 +296,17 @@ ThebesLayerD3D10::Validate(ReadbackProce > > for (int i = 0; i < readbackUpdates.Length(); i++) { > mD3DManager->readbackManager()->PostTask(readbackTexture, > &readbackUpdates[i], > gfxPoint(visibleRect.x, visibleRect.y)); > } > } > >- mValidRegion = mVisibleRegion; >+ mValidRegion = neededRegion; > } > } > > void > ThebesLayerD3D10::LayerManagerDestroyed() > { > mD3DManager = nsnull; > } >diff --git a/gfx/layers/d3d9/ThebesLayerD3D9.cpp b/gfx/layers/d3d9/ThebesLayerD3D9.cpp >--- a/gfx/layers/d3d9/ThebesLayerD3D9.cpp >+++ b/gfx/layers/d3d9/ThebesLayerD3D9.cpp >@@ -221,36 +221,48 @@ ThebesLayerD3D9::RenderThebesLayer(Readb > } > > nsTArray<ReadbackProcessor::Update> readbackUpdates; > nsIntRegion readbackRegion; > if (aReadback && UsedForReadback()) { > aReadback->GetThebesLayerUpdates(this, &readbackUpdates, &readbackRegion); > } > >+ // If we have a transform that requires resampling of our texture, then >+ // we need to make sure we don't sample pixels that haven't been drawn. >+ // We clamp sample coordinates to the texture rect, but when the visible region >+ // doesn't fill the entire texture rect we need to make sure we draw all the >+ // pixels in the texture rect anyway in case they get sampled. >+ nsIntRegion neededRegion = mVisibleRegion; >+ gfxMatrix transform2d; >+ if (!GetEffectiveTransform().Is2D(&transform2d) || >+ transform2d.HasNonIntegerTranslation()) { >+ neededRegion = mTextureRect; >+ } >+ > // Because updates to D3D9 ThebesLayers are rendered with the CPU, we don't > // have to do readback from D3D9 surfaces. Instead we make sure that any area > // needed for readback is included in the drawRegion we ask layout to render. > // Then the readback areas we need can be copied out of the temporary > // destinationSurface in DrawRegion. > nsIntRegion drawRegion; >- drawRegion.Sub(mVisibleRegion, mValidRegion); >+ drawRegion.Sub(neededRegion, mValidRegion); > drawRegion.Or(drawRegion, readbackRegion); > // NS_ASSERTION(mVisibleRegion.Contains(region), "Bad readback region!"); > > if (!drawRegion.IsEmpty()) { > LayerManagerD3D9::CallbackInfo cbInfo = mD3DManager->GetCallbackInfo(); > if (!cbInfo.Callback) { > NS_ERROR("D3D9 should never need to update ThebesLayers in an empty transaction"); > return; > } > > DrawRegion(drawRegion, mode, readbackUpdates); > >- mValidRegion = mVisibleRegion; >+ mValidRegion = neededRegion; > } > > SetShaderTransformAndOpacity(); > > if (mode == SURFACE_COMPONENT_ALPHA) { > mD3DManager->SetShaderMode(DeviceManagerD3D9::COMPONENTLAYERPASS1); > device()->SetTexture(0, mTexture); > device()->SetTexture(1, mTextureOnWhite);
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
Flags:
roc
: review-
Actions:
View
|
Diff
|
Review
Attachments on
bug 635373
:
513923
|
513924
|
513926
| 514069 |
514078
|
514128
|
514129
|
514156
|
514449
|
514973
|
514974
|
522336