diff --git a/gfx/layers/Makefile.in b/gfx/layers/Makefile.in index 8d73b9adf5a..daef4cd5942 100644 --- a/gfx/layers/Makefile.in +++ b/gfx/layers/Makefile.in @@ -102,7 +102,6 @@ CPPSRCS += \ ImageLayerD3D9.cpp \ ColorLayerD3D9.cpp \ CanvasLayerD3D9.cpp \ - ShadowBufferD3D9.cpp \ DeviceManagerD3D9.cpp \ Nv3DVUtils.cpp \ $(NULL) diff --git a/gfx/layers/d3d9/CanvasLayerD3D9.cpp b/gfx/layers/d3d9/CanvasLayerD3D9.cpp index 55386c54f31..bed48101e8d 100644 --- a/gfx/layers/d3d9/CanvasLayerD3D9.cpp +++ b/gfx/layers/d3d9/CanvasLayerD3D9.cpp @@ -36,17 +36,12 @@ * * ***** END LICENSE BLOCK ***** */ - -#include "mozilla/layers/PLayers.h" -#include "mozilla/layers/ShadowLayers.h" -#include "ShadowBufferD3D9.h" +#include "CanvasLayerD3D9.h" #include "gfxImageSurface.h" #include "gfxWindowsSurface.h" #include "gfxWindowsPlatform.h" -#include "CanvasLayerD3D9.h" - namespace mozilla { namespace layers { @@ -98,14 +93,14 @@ CanvasLayerD3D9::UpdateSurface() if (mGLContext) { // WebGL reads entire surface. - LockTextureRectD3D9 textureLock(mTexture); - if (!textureLock.HasLock()) { + D3DLOCKED_RECT r; + HRESULT hr = mTexture->LockRect(0, &r, NULL, 0); + + if (FAILED(hr)) { NS_WARNING("Failed to lock CanvasLayer texture."); return; } - D3DLOCKED_RECT r = textureLock.GetLockRect(); - PRUint8 *destination; if (r.Pitch != mBounds.width * 4) { destination = new PRUint8[mBounds.width * mBounds.height * 4]; @@ -148,6 +143,7 @@ CanvasLayerD3D9::UpdateSurface() } delete [] destination; } + mTexture->UnlockRect(0); } else if (mSurface) { RECT r; r.left = mBounds.x; @@ -155,14 +151,14 @@ CanvasLayerD3D9::UpdateSurface() r.right = mBounds.XMost(); r.bottom = mBounds.YMost(); - LockTextureRectD3D9 textureLock(mTexture); - if (!textureLock.HasLock()) { + D3DLOCKED_RECT lockedRect; + HRESULT hr = mTexture->LockRect(0, &lockedRect, &r, 0); + + if (FAILED(hr)) { NS_WARNING("Failed to lock CanvasLayer texture."); return; } - D3DLOCKED_RECT lockedRect = textureLock.GetLockRect(); - nsRefPtr sourceSurface; if (mSurface->GetType() == gfxASurface::SurfaceTypeWin32) { @@ -172,6 +168,7 @@ CanvasLayerD3D9::UpdateSurface() if (sourceSurface->Format() != gfxASurface::ImageFormatARGB32 && sourceSurface->Format() != gfxASurface::ImageFormatRGB24) { + mTexture->UnlockRect(0); return; } } else { @@ -198,6 +195,7 @@ CanvasLayerD3D9::UpdateSurface() mBounds.width * 4); } + mTexture->UnlockRect(0); } } @@ -289,99 +287,5 @@ CanvasLayerD3D9::CreateTexture() } } -ShadowCanvasLayerD3D9::ShadowCanvasLayerD3D9(LayerManagerD3D9* aManager) - : ShadowCanvasLayer(aManager, nsnull) - , LayerD3D9(aManager) - , mNeedsYFlip(PR_FALSE) -{ - mImplData = static_cast(this); -} - -ShadowCanvasLayerD3D9::~ShadowCanvasLayerD3D9() -{} - -void -ShadowCanvasLayerD3D9::Initialize(const Data& aData) -{ - NS_RUNTIMEABORT("Non-shadow layer API unexpectedly used for shadow layer"); -} - -void -ShadowCanvasLayerD3D9::Init(const SurfaceDescriptor& aNewFront, - const nsIntSize& aSize, bool needYFlip) -{ - - if (!mBuffer) { - mBuffer = new ShadowBufferD3D9(this); - } - - mNeedsYFlip = needYFlip; -} - -void -ShadowCanvasLayerD3D9::Swap(const SurfaceDescriptor& aNewFront, - SurfaceDescriptor* aNewBack) -{ - NS_ASSERTION(aNewFront.type() == SharedImage::TSurfaceDescriptor, - "ShadowCanvasLayerD3D9::Swap expected SharedImage surface"); - - nsRefPtr surf = - ShadowLayerForwarder::OpenDescriptor(aNewFront); - - if (mBuffer) { - mBuffer->Upload(surf, GetVisibleRegion().GetBounds()); - } - - *aNewBack = aNewFront; -} - -void -ShadowCanvasLayerD3D9::DestroyFrontBuffer() -{ - Destroy(); -} - -void -ShadowCanvasLayerD3D9::Disconnect() -{ - Destroy(); -} - -void -ShadowCanvasLayerD3D9::Destroy() -{ - mBuffer = nsnull; -} - -void -ShadowCanvasLayerD3D9::CleanResources() -{ - Destroy(); -} - -void -ShadowCanvasLayerD3D9::LayerManagerDestroyed() -{ - mD3DManager->deviceManager()->mLayersWithResources.RemoveElement(this); - mD3DManager = nsnull; -} - -Layer* -ShadowCanvasLayerD3D9::GetLayer() -{ - return this; -} - -void -ShadowCanvasLayerD3D9::RenderLayer() -{ - if (!mBuffer) { - return; - } - - mBuffer->RenderTo(mD3DManager, GetEffectiveVisibleRegion()); -} - - } /* namespace layers */ } /* namespace mozilla */ diff --git a/gfx/layers/d3d9/CanvasLayerD3D9.h b/gfx/layers/d3d9/CanvasLayerD3D9.h index 7637ced4880..d3efc49e761 100644 --- a/gfx/layers/d3d9/CanvasLayerD3D9.h +++ b/gfx/layers/d3d9/CanvasLayerD3D9.h @@ -39,15 +39,13 @@ #ifndef GFX_CANVASLAYERD3D9_H #define GFX_CANVASLAYERD3D9_H -#include "LayerManagerD3D9.h" -#include "GLContext.h" -#include "gfxASurface.h" +#include "LayerManagerD3D9.h" +#include "GLContext.h" +#include "gfxASurface.h" namespace mozilla { namespace layers { -class ShadowBufferD3D9; - class THEBES_API CanvasLayerD3D9 : public CanvasLayer, public LayerD3D9 @@ -93,42 +91,6 @@ protected: PRPackedBool mHasAlpha; }; -// NB: eventually we'll have separate shadow canvas2d and shadow -// canvas3d layers, but currently they look the same from the -// perspective of the compositor process -class ShadowCanvasLayerD3D9 : public ShadowCanvasLayer, - public LayerD3D9 -{ -public: - ShadowCanvasLayerD3D9(LayerManagerD3D9* aManager); - virtual ~ShadowCanvasLayerD3D9(); - - // CanvasLayer impl - virtual void Initialize(const Data& aData); - virtual void Init(const SurfaceDescriptor& aNewFront, const nsIntSize& aSize, bool needYFlip); - - // This isn't meaningful for shadow canvas. - virtual void Updated(const nsIntRect&) {} - - // ShadowCanvasLayer impl - virtual void Swap(const SurfaceDescriptor& aNewFront, - SurfaceDescriptor* aNewBack); - virtual void DestroyFrontBuffer(); - virtual void Disconnect(); - - virtual void Destroy(); - - // LayerD3D9 implementation - virtual Layer* GetLayer(); - virtual void RenderLayer(); - virtual void CleanResources(); - virtual void LayerManagerDestroyed(); - -private: - PRPackedBool mNeedsYFlip; - nsRefPtr mBuffer; -}; - } /* layers */ } /* mozilla */ #endif /* GFX_CANVASLAYERD3D9_H */ diff --git a/gfx/layers/d3d9/ColorLayerD3D9.cpp b/gfx/layers/d3d9/ColorLayerD3D9.cpp index ab69873a8c5..fa1d3ba4f75 100644 --- a/gfx/layers/d3d9/ColorLayerD3D9.cpp +++ b/gfx/layers/d3d9/ColorLayerD3D9.cpp @@ -47,15 +47,15 @@ ColorLayerD3D9::GetLayer() return this; } -static void -RenderColorLayerD3D9(ColorLayer* aLayer, LayerManagerD3D9 *aManager) +void +ColorLayerD3D9::RenderLayer() { // XXX we might be able to improve performance by using // IDirect3DDevice9::Clear - nsIntRect visibleRect = aLayer->GetEffectiveVisibleRegion().GetBounds(); + nsIntRect visibleRect = mVisibleRegion.GetBounds(); - aManager->device()->SetVertexShaderConstantF( + device()->SetVertexShaderConstantF( CBvLayerQuad, ShaderConstantRect(visibleRect.x, visibleRect.y, @@ -63,36 +63,23 @@ RenderColorLayerD3D9(ColorLayer* aLayer, LayerManagerD3D9 *aManager) visibleRect.height), 1); - const gfx3DMatrix& transform = aLayer->GetEffectiveTransform(); - aManager->device()->SetVertexShaderConstantF(CBmLayerTransform, &transform._11, 4); + const gfx3DMatrix& transform = GetEffectiveTransform(); + device()->SetVertexShaderConstantF(CBmLayerTransform, &transform._11, 4); - gfxRGBA layerColor(aLayer->GetColor()); float color[4]; - float opacity = aLayer->GetEffectiveOpacity() * layerColor.a; + float opacity = GetEffectiveOpacity() * mColor.a; // output color is premultiplied, so we need to adjust all channels. // mColor is not premultiplied. - color[0] = (float)(layerColor.r * opacity); - color[1] = (float)(layerColor.g * opacity); - color[2] = (float)(layerColor.b * opacity); + color[0] = (float)(mColor.r * opacity); + color[1] = (float)(mColor.g * opacity); + color[2] = (float)(mColor.b * opacity); color[3] = (float)(opacity); - aManager->device()->SetPixelShaderConstantF(0, color, 1); + device()->SetPixelShaderConstantF(0, color, 1); - aManager->SetShaderMode(DeviceManagerD3D9::SOLIDCOLORLAYER); + mD3DManager->SetShaderMode(DeviceManagerD3D9::SOLIDCOLORLAYER); - aManager->device()->DrawPrimitive(D3DPT_TRIANGLESTRIP, 0, 2); -} - -void -ColorLayerD3D9::RenderLayer() -{ - return RenderColorLayerD3D9(this, mD3DManager); -} - -void -ShadowColorLayerD3D9::RenderLayer() -{ - return RenderColorLayerD3D9(this, mD3DManager); + device()->DrawPrimitive(D3DPT_TRIANGLESTRIP, 0, 2); } } /* layers */ diff --git a/gfx/layers/d3d9/ColorLayerD3D9.h b/gfx/layers/d3d9/ColorLayerD3D9.h index db826c21094..6756ec95f9d 100644 --- a/gfx/layers/d3d9/ColorLayerD3D9.h +++ b/gfx/layers/d3d9/ColorLayerD3D9.h @@ -61,26 +61,6 @@ public: virtual void RenderLayer(); }; -class ShadowColorLayerD3D9 : public ShadowColorLayer, - public LayerD3D9 -{ -public: - ShadowColorLayerD3D9(LayerManagerD3D9 *aManager) - : ShadowColorLayer(aManager, NULL) - , LayerD3D9(aManager) - { - mImplData = static_cast(this); - } - ~ShadowColorLayerD3D9() { Destroy(); } - - // LayerOGL Implementation - virtual Layer* GetLayer() { return this; } - - virtual void Destroy() { } - - virtual void RenderLayer(); -}; - } /* layers */ } /* mozilla */ diff --git a/gfx/layers/d3d9/ContainerLayerD3D9.cpp b/gfx/layers/d3d9/ContainerLayerD3D9.cpp index 16f58a0ac5b..cc8fe252231 100644 --- a/gfx/layers/d3d9/ContainerLayerD3D9.cpp +++ b/gfx/layers/d3d9/ContainerLayerD3D9.cpp @@ -44,26 +44,39 @@ namespace mozilla { namespace layers { -template -static void -ContainerInsertAfter(Container* aContainer, Layer* aChild, Layer* aAfter) +ContainerLayerD3D9::ContainerLayerD3D9(LayerManagerD3D9 *aManager) + : ContainerLayer(aManager, NULL) + , LayerD3D9(aManager) { - aChild->SetParent(aContainer); + mImplData = static_cast(this); +} + +ContainerLayerD3D9::~ContainerLayerD3D9() +{ + while (mFirstChild) { + RemoveChild(mFirstChild); + } +} + +void +ContainerLayerD3D9::InsertAfter(Layer* aChild, Layer* aAfter) +{ + aChild->SetParent(this); if (!aAfter) { - Layer *oldFirstChild = aContainer->GetFirstChild(); - aContainer->mFirstChild = aChild; + Layer *oldFirstChild = GetFirstChild(); + mFirstChild = aChild; aChild->SetNextSibling(oldFirstChild); aChild->SetPrevSibling(nsnull); if (oldFirstChild) { oldFirstChild->SetPrevSibling(aChild); } else { - aContainer->mLastChild = aChild; + mLastChild = aChild; } NS_ADDREF(aChild); - aContainer->DidInsertChild(aChild); + DidInsertChild(aChild); return; } - for (Layer *child = aContainer->GetFirstChild(); + for (Layer *child = GetFirstChild(); child; child = child->GetNextSibling()) { if (aAfter == child) { Layer *oldNextSibling = child->GetNextSibling(); @@ -72,37 +85,36 @@ ContainerInsertAfter(Container* aContainer, Layer* aChild, Layer* aAfter) if (oldNextSibling) { oldNextSibling->SetPrevSibling(aChild); } else { - aContainer->mLastChild = aChild; + mLastChild = aChild; } aChild->SetPrevSibling(child); NS_ADDREF(aChild); - aContainer->DidInsertChild(aChild); + DidInsertChild(aChild); return; } } NS_WARNING("Failed to find aAfter layer!"); } -template -static void -ContainerRemoveChild(Container* aContainer, Layer* aChild) +void +ContainerLayerD3D9::RemoveChild(Layer *aChild) { - if (aContainer->GetFirstChild() == aChild) { - aContainer->mFirstChild = aContainer->GetFirstChild()->GetNextSibling(); - if (aContainer->mFirstChild) { - aContainer->mFirstChild->SetPrevSibling(nsnull); + if (GetFirstChild() == aChild) { + mFirstChild = GetFirstChild()->GetNextSibling(); + if (mFirstChild) { + mFirstChild->SetPrevSibling(nsnull); } else { - aContainer->mLastChild = nsnull; + mLastChild = nsnull; } aChild->SetNextSibling(nsnull); aChild->SetPrevSibling(nsnull); aChild->SetParent(nsnull); - aContainer->DidRemoveChild(aChild); + DidRemoveChild(aChild); NS_RELEASE(aChild); return; } Layer *lastChild = nsnull; - for (Layer *child = aContainer->GetFirstChild(); child; + for (Layer *child = GetFirstChild(); child; child = child->GetNextSibling()) { if (child == aChild) { // We're sure this is not our first child. So lastChild != NULL. @@ -110,12 +122,12 @@ ContainerRemoveChild(Container* aContainer, Layer* aChild) if (child->GetNextSibling()) { child->GetNextSibling()->SetPrevSibling(lastChild); } else { - aContainer->mLastChild = lastChild; + mLastChild = lastChild; } child->SetNextSibling(nsnull); child->SetPrevSibling(nsnull); child->SetParent(nsnull); - aContainer->DidRemoveChild(aChild); + DidRemoveChild(aChild); NS_RELEASE(aChild); return; } @@ -123,12 +135,27 @@ ContainerRemoveChild(Container* aContainer, Layer* aChild) } } +Layer* +ContainerLayerD3D9::GetLayer() +{ + return this; +} + +LayerD3D9* +ContainerLayerD3D9::GetFirstChildD3D9() +{ + if (!mFirstChild) { + return nsnull; + } + return static_cast(mFirstChild->ImplData()); +} + static inline LayerD3D9* -GetNextSibling(LayerD3D9* aLayer) +GetNextSiblingD3D9(LayerD3D9* aLayer) { Layer* layer = aLayer->GetLayer()->GetNextSibling(); return layer ? static_cast(layer-> - ImplData()) + ImplData()) : nsnull; } @@ -142,19 +169,8 @@ HasOpaqueAncestorLayer(Layer* aLayer) return PR_FALSE; } -static inline LayerD3D9* -GetNextSiblingD3D9(LayerD3D9* aLayer) -{ - Layer* layer = aLayer->GetLayer()->GetNextSibling(); - return layer ? static_cast(layer-> - ImplData()) - : nsnull; -} - -template -static void -ContainerRender(Container* aContainer, - LayerManagerD3D9* aManager) +void +ContainerLayerD3D9::RenderLayer() { nsRefPtr previousRenderTarget; nsRefPtr renderTexture; @@ -163,7 +179,7 @@ ContainerRender(Container* aContainer, float oldViewMatrix[4][4]; RECT containerD3D9ClipRect; - aManager->device()->GetScissorRect(&containerD3D9ClipRect); + device()->GetScissorRect(&containerD3D9ClipRect); // Convert scissor to an nsIntRect. RECT's are exclusive on the bottom and // right values. nsIntRect oldScissor(containerD3D9ClipRect.left, @@ -172,35 +188,34 @@ ContainerRender(Container* aContainer, containerD3D9ClipRect.bottom - containerD3D9ClipRect.top); ReadbackProcessor readback; - readback.BuildUpdates(aContainer); + readback.BuildUpdates(this); - nsIntRect visibleRect = aContainer->GetEffectiveVisibleRegion().GetBounds(); - PRBool useIntermediate = aContainer->UseIntermediateSurface(); + nsIntRect visibleRect = mVisibleRegion.GetBounds(); + PRBool useIntermediate = UseIntermediateSurface(); - aContainer->mSupportsComponentAlphaChildren = PR_FALSE; + mSupportsComponentAlphaChildren = PR_FALSE; if (useIntermediate) { - aManager->device()->GetRenderTarget(0, getter_AddRefs(previousRenderTarget)); - aManager->device()->CreateTexture(visibleRect.width, visibleRect.height, 1, + device()->GetRenderTarget(0, getter_AddRefs(previousRenderTarget)); + device()->CreateTexture(visibleRect.width, visibleRect.height, 1, D3DUSAGE_RENDERTARGET, D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, getter_AddRefs(renderTexture), NULL); nsRefPtr renderSurface; renderTexture->GetSurfaceLevel(0, getter_AddRefs(renderSurface)); - aManager->device()->SetRenderTarget(0, renderSurface); + device()->SetRenderTarget(0, renderSurface); - if (aContainer->mVisibleRegion.GetNumRects() == 1 && - (aContainer->GetContentFlags() & aContainer->CONTENT_OPAQUE)) { + if (mVisibleRegion.GetNumRects() == 1 && (GetContentFlags() & CONTENT_OPAQUE)) { // don't need a background, we're going to paint all opaque stuff - aContainer->mSupportsComponentAlphaChildren = PR_TRUE; + mSupportsComponentAlphaChildren = PR_TRUE; } else { - const gfx3DMatrix& transform3D = aContainer->GetEffectiveTransform(); + const gfx3DMatrix& transform3D = GetEffectiveTransform(); gfxMatrix transform; // If we have an opaque ancestor layer, then we can be sure that // all the pixels we draw into are either opaque already or will be // covered by something opaque. Otherwise copying up the background is // not safe. HRESULT hr = E_FAIL; - if (HasOpaqueAncestorLayer(aContainer) && + if (HasOpaqueAncestorLayer(this) && transform3D.Is2D(&transform) && !transform.HasNonIntegerTranslation()) { // Copy background up from below RECT dest = { 0, 0, visibleRect.width, visibleRect.height }; @@ -208,23 +223,20 @@ ContainerRender(Container* aContainer, ::OffsetRect(&src, visibleRect.x + PRInt32(transform.x0), visibleRect.y + PRInt32(transform.y0)); - hr = aManager->device()-> + hr = device()-> StretchRect(previousRenderTarget, &src, renderSurface, &dest, D3DTEXF_NONE); } if (hr == S_OK) { - aContainer->mSupportsComponentAlphaChildren = PR_TRUE; + mSupportsComponentAlphaChildren = PR_TRUE; } else { - aManager->device()-> - Clear(0, 0, D3DCLEAR_TARGET, D3DCOLOR_RGBA(0, 0, 0, 0), 0, 0); + device()->Clear(0, 0, D3DCLEAR_TARGET, D3DCOLOR_RGBA(0, 0, 0, 0), 0, 0); } } - aManager->device()-> - GetVertexShaderConstantF(CBvRenderTargetOffset, previousRenderTargetOffset, 1); + device()->GetVertexShaderConstantF(CBvRenderTargetOffset, previousRenderTargetOffset, 1); renderTargetOffset[0] = (float)visibleRect.x; renderTargetOffset[1] = (float)visibleRect.y; - aManager->device()-> - SetVertexShaderConstantF(CBvRenderTargetOffset, renderTargetOffset, 1); + device()->SetVertexShaderConstantF(CBvRenderTargetOffset, renderTargetOffset, 1); gfx3DMatrix viewMatrix; /* @@ -236,21 +248,17 @@ ContainerRender(Container* aContainer, viewMatrix._41 = -1.0f; viewMatrix._42 = 1.0f; - aManager->device()-> - GetVertexShaderConstantF(CBmProjection, &oldViewMatrix[0][0], 4); - aManager->device()-> - SetVertexShaderConstantF(CBmProjection, &viewMatrix._11, 4); + device()->GetVertexShaderConstantF(CBmProjection, &oldViewMatrix[0][0], 4); + device()->SetVertexShaderConstantF(CBmProjection, &viewMatrix._11, 4); } else { - aContainer->mSupportsComponentAlphaChildren = - (aContainer->GetContentFlags() & aContainer->CONTENT_OPAQUE) || - (aContainer->mParent && - aContainer->mParent->SupportsComponentAlphaChildren()); + mSupportsComponentAlphaChildren = (GetContentFlags() & CONTENT_OPAQUE) || + (mParent && mParent->SupportsComponentAlphaChildren()); } /* * Render this container's contents. */ - for (LayerD3D9* layerToRender = aContainer->GetFirstChildD3D9(); + for (LayerD3D9* layerToRender = GetFirstChildD3D9(); layerToRender != nsnull; layerToRender = GetNextSiblingD3D9(layerToRender)) { @@ -269,86 +277,38 @@ ContainerRender(Container* aContainer, d3drect.top = scissorRect.y; d3drect.right = scissorRect.x + scissorRect.width; d3drect.bottom = scissorRect.y + scissorRect.height; - aManager->device()->SetScissorRect(&d3drect); + device()->SetScissorRect(&d3drect); - if (layerToRender->GetLayer()->GetType() == aContainer->TYPE_THEBES) { + if (layerToRender->GetLayer()->GetType() == TYPE_THEBES) { static_cast(layerToRender)->RenderThebesLayer(&readback); } else { layerToRender->RenderLayer(); } } - aManager->device()->SetScissorRect(&containerD3D9ClipRect); + device()->SetScissorRect(&containerD3D9ClipRect); if (useIntermediate) { - aManager->device()->SetRenderTarget(0, previousRenderTarget); - aManager->device()->SetVertexShaderConstantF(CBvRenderTargetOffset, previousRenderTargetOffset, 1); - aManager->device()->SetVertexShaderConstantF(CBmProjection, &oldViewMatrix[0][0], 4); + device()->SetRenderTarget(0, previousRenderTarget); + device()->SetVertexShaderConstantF(CBvRenderTargetOffset, previousRenderTargetOffset, 1); + device()->SetVertexShaderConstantF(CBmProjection, &oldViewMatrix[0][0], 4); - aManager->device()->SetVertexShaderConstantF(CBvLayerQuad, + device()->SetVertexShaderConstantF(CBvLayerQuad, ShaderConstantRect(visibleRect.x, visibleRect.y, visibleRect.width, visibleRect.height), 1); - aContainer->SetShaderTransformAndOpacity(); + SetShaderTransformAndOpacity(); - aManager->SetShaderMode(DeviceManagerD3D9::RGBALAYER); + mD3DManager->SetShaderMode(DeviceManagerD3D9::RGBALAYER); - aManager->device()->SetTexture(0, renderTexture); - aManager->device()->DrawPrimitive(D3DPT_TRIANGLESTRIP, 0, 2); + device()->SetTexture(0, renderTexture); + device()->DrawPrimitive(D3DPT_TRIANGLESTRIP, 0, 2); } } - -ContainerLayerD3D9::ContainerLayerD3D9(LayerManagerD3D9 *aManager) - : ContainerLayer(aManager, NULL) - , LayerD3D9(aManager) -{ - mImplData = static_cast(this); -} - -ContainerLayerD3D9::~ContainerLayerD3D9() -{ - while (mFirstChild) { - RemoveChild(mFirstChild); - } -} - -void -ContainerLayerD3D9::InsertAfter(Layer* aChild, Layer* aAfter) -{ - ContainerInsertAfter(this, aChild, aAfter); -} - -void -ContainerLayerD3D9::RemoveChild(Layer *aChild) -{ - ContainerRemoveChild(this, aChild); -} - -Layer* -ContainerLayerD3D9::GetLayer() -{ - return this; -} - -LayerD3D9* -ContainerLayerD3D9::GetFirstChildD3D9() -{ - if (!mFirstChild) { - return nsnull; - } - return static_cast(mFirstChild->ImplData()); -} - -void -ContainerLayerD3D9::RenderLayer() -{ - ContainerRender(this, mD3DManager); -} - void ContainerLayerD3D9::LayerManagerDestroyed() { @@ -358,52 +318,5 @@ ContainerLayerD3D9::LayerManagerDestroyed() } } -ShadowContainerLayerD3D9::ShadowContainerLayerD3D9(LayerManagerD3D9 *aManager) - : ShadowContainerLayer(aManager, NULL) - , LayerD3D9(aManager) -{ - mImplData = static_cast(this); -} - -ShadowContainerLayerD3D9::~ShadowContainerLayerD3D9() -{ - Destroy(); -} - -void -ShadowContainerLayerD3D9::InsertAfter(Layer* aChild, Layer* aAfter) -{ - ContainerInsertAfter(this, aChild, aAfter); -} - -void -ShadowContainerLayerD3D9::RemoveChild(Layer *aChild) -{ - ContainerRemoveChild(this, aChild); -} - -void -ShadowContainerLayerD3D9::Destroy() -{ - while (mFirstChild) { - RemoveChild(mFirstChild); - } -} - -LayerD3D9* -ShadowContainerLayerD3D9::GetFirstChildD3D9() -{ - if (!mFirstChild) { - return nsnull; - } - return static_cast(mFirstChild->ImplData()); -} - -void -ShadowContainerLayerD3D9::RenderLayer() -{ - ContainerRender(this, mD3DManager); -} - } /* layers */ } /* mozilla */ diff --git a/gfx/layers/d3d9/ContainerLayerD3D9.h b/gfx/layers/d3d9/ContainerLayerD3D9.h index 3f39608366d..eb40740cf62 100644 --- a/gfx/layers/d3d9/ContainerLayerD3D9.h +++ b/gfx/layers/d3d9/ContainerLayerD3D9.h @@ -43,24 +43,10 @@ namespace mozilla { namespace layers { - -template -static void ContainerInsertAfter(Container* aContainer, Layer* aChild, Layer* aAfter); -template -static void ContainerRemoveChild(Container* aContainer, Layer* aChild); -template -static void ContainerRender(Container* aContainer, LayerManagerD3D9* aManager); class ContainerLayerD3D9 : public ContainerLayer, public LayerD3D9 { - template - friend void ContainerInsertAfter(Container* aContainer, Layer* aChild, Layer* aAfter); - template - friend void ContainerRemoveChild(Container* aContainer, Layer* aChild); - template - friend void ContainerRender(Container* aContainer, LayerManagerD3D9* aManager); - public: ContainerLayerD3D9(LayerManagerD3D9 *aManager); ~ContainerLayerD3D9(); @@ -89,39 +75,6 @@ public: } }; -class ShadowContainerLayerD3D9 : public ShadowContainerLayer, - public LayerD3D9 -{ - template - friend void ContainerInsertAfter(Container* aContainer, Layer* aChild, Layer* aAfter); - template - friend void ContainerRemoveChild(Container* aContainer, Layer* aChild); - template - friend void ContainerRender(Container* aContainer, LayerManagerD3D9* aManager); - -public: - ShadowContainerLayerD3D9(LayerManagerD3D9 *aManager); - ~ShadowContainerLayerD3D9(); - - void InsertAfter(Layer* aChild, Layer* aAfter); - - void RemoveChild(Layer* aChild); - - // LayerD3D9 Implementation - virtual Layer* GetLayer() { return this; } - - virtual void Destroy(); - - LayerD3D9* GetFirstChildD3D9(); - - virtual void RenderLayer(); - - virtual void ComputeEffectiveTransforms(const gfx3DMatrix& aTransformToSurface) - { - DefaultComputeEffectiveTransforms(aTransformToSurface); - } -}; - } /* layers */ } /* mozilla */ diff --git a/gfx/layers/d3d9/ImageLayerD3D9.cpp b/gfx/layers/d3d9/ImageLayerD3D9.cpp index 198bc1dbb2d..75ff6e378bd 100644 --- a/gfx/layers/d3d9/ImageLayerD3D9.cpp +++ b/gfx/layers/d3d9/ImageLayerD3D9.cpp @@ -35,14 +35,7 @@ * * ***** END LICENSE BLOCK ***** */ -#include "mozilla/layers/PLayers.h" -#include "mozilla/layers/ShadowLayers.h" -#include "ShadowBufferD3D9.h" -#include "gfxSharedImageSurface.h" - #include "ImageLayerD3D9.h" -#include "ThebesLayerD3D9.h" -#include "gfxPlatform.h" #include "gfxImageSurface.h" #include "yuv_convert.h" #include "nsIServiceManager.h" @@ -650,147 +643,5 @@ CairoImageD3D9::GetAsSurface() return surface.forget(); } -ShadowImageLayerD3D9::ShadowImageLayerD3D9(LayerManagerD3D9* aManager) - : ShadowImageLayer(aManager, nsnull) - , LayerD3D9(aManager) -{ - mImplData = static_cast(this); -} - -ShadowImageLayerD3D9::~ShadowImageLayerD3D9() -{} - -PRBool -ShadowImageLayerD3D9::Init(const SharedImage& aFront, - const nsIntSize& aSize) -{ - if (aFront.type() == SharedImage::TSurfaceDescriptor) { - SurfaceDescriptor desc = aFront.get_SurfaceDescriptor(); - nsRefPtr surf = - ShadowLayerForwarder::OpenDescriptor(desc); - - if (!mBuffer) { - mBuffer = new ShadowBufferD3D9(this); - } - return !!mBuffer; - } else { - if (!mYCbCrImage) { - mYCbCrImage = new PlanarYCbCrImageD3D9(); - } - return !!mYCbCrImage; - } -} - -void -ShadowImageLayerD3D9::Swap(const SharedImage& aNewFront, SharedImage* aNewBack) -{ - - if (aNewFront.type() == SharedImage::TSurfaceDescriptor) { - nsRefPtr surf = - ShadowLayerForwarder::OpenDescriptor(aNewFront.get_SurfaceDescriptor()); - - if (mBuffer) { - mBuffer->Upload(surf, GetVisibleRegion().GetBounds()); - } - } else { - - const YUVImage& yuv = aNewFront.get_YUVImage(); - - nsRefPtr surfY = - gfxSharedImageSurface::Open(yuv.Ydata()); - nsRefPtr surfU = - gfxSharedImageSurface::Open(yuv.Udata()); - nsRefPtr surfV = - gfxSharedImageSurface::Open(yuv.Vdata()); - - PlanarYCbCrImage::Data data; - data.mYChannel = surfY->Data(); - data.mYStride = surfY->Stride(); - data.mYSize = surfY->GetSize(); - data.mCbChannel = surfU->Data(); - data.mCrChannel = surfV->Data(); - data.mCbCrStride = surfU->Stride(); - data.mCbCrSize = surfU->GetSize(); - data.mPicSize = surfY->GetSize(); - data.mPicX = 0; - data.mPicY = 0; - - mYCbCrImage->SetData(data); - - } - - *aNewBack = aNewFront; -} - -void -ShadowImageLayerD3D9::DestroyFrontBuffer() -{ - Destroy(); -} - -void -ShadowImageLayerD3D9::Disconnect() -{ - Destroy(); -} - -void -ShadowImageLayerD3D9::Destroy() -{ - mBuffer = nsnull; - mYCbCrImage = nsnull; -} - -Layer* -ShadowImageLayerD3D9::GetLayer() -{ - return this; -} - -void -ShadowImageLayerD3D9::RenderLayer() -{ - if (mBuffer) { - mBuffer->RenderTo(mD3DManager, GetEffectiveVisibleRegion()); - } else if (mYCbCrImage) { - if (!mYCbCrImage->HasData()) { - return; - } - - mYCbCrImage->AllocateTextures(device()); - - SetShaderTransformAndOpacity(); - - device()->SetVertexShaderConstantF(CBvLayerQuad, - ShaderConstantRect(0, - 0, - mYCbCrImage->mSize.width, - mYCbCrImage->mSize.height), - 1); - - mD3DManager->SetShaderMode(DeviceManagerD3D9::YCBCRLAYER); - - /* - * Send 3d control data and metadata - */ - if (mD3DManager->GetNv3DVUtils()) { - // TODO Add 3D support - } - - // Linear scaling is default here, adhering to mFilter is difficult since - // presumably even with point filtering we'll still want chroma upsampling - // to be linear. In the current approach we can't. - device()->SetTexture(0, mYCbCrImage->mYTexture); - device()->SetTexture(1, mYCbCrImage->mCbTexture); - device()->SetTexture(2, mYCbCrImage->mCrTexture); - - device()->DrawPrimitive(D3DPT_TRIANGLESTRIP, 0, 2); - } else { - NS_ERROR("Unexpected image format."); - } - -} - - } /* layers */ } /* mozilla */ diff --git a/gfx/layers/d3d9/ImageLayerD3D9.h b/gfx/layers/d3d9/ImageLayerD3D9.h index fe52bdf5a2d..4c067ffded6 100644 --- a/gfx/layers/d3d9/ImageLayerD3D9.h +++ b/gfx/layers/d3d9/ImageLayerD3D9.h @@ -45,8 +45,6 @@ namespace mozilla { namespace layers { -class ShadowBufferD3D9; - class THEBES_API ImageContainerD3D9 : public ImageContainer { public: @@ -175,34 +173,6 @@ private: LayerManagerD3D9 *mManager; }; -class ShadowImageLayerD3D9 : public ShadowImageLayer, - public LayerD3D9 -{ -public: - ShadowImageLayerD3D9(LayerManagerD3D9* aManager); - virtual ~ShadowImageLayerD3D9(); - - // ShadowImageLayer impl - virtual PRBool Init(const SharedImage& aFront, const nsIntSize& aSize); - - virtual void Swap(const SharedImage& aFront, SharedImage* aNewBack); - - virtual void DestroyFrontBuffer(); - - virtual void Disconnect(); - - // LayerD3D9 impl - virtual void Destroy(); - - virtual Layer* GetLayer(); - - virtual void RenderLayer(); - -private: - nsRefPtr mBuffer; - nsRefPtr mYCbCrImage; -}; - } /* layers */ } /* mozilla */ #endif /* GFX_IMAGELAYERD3D9_H */ diff --git a/gfx/layers/d3d9/LayerManagerD3D9.cpp b/gfx/layers/d3d9/LayerManagerD3D9.cpp index 0abf629e228..bf645dff6ee 100644 --- a/gfx/layers/d3d9/LayerManagerD3D9.cpp +++ b/gfx/layers/d3d9/LayerManagerD3D9.cpp @@ -245,56 +245,6 @@ LayerManagerD3D9::CreateImageContainer() return container.forget(); } -already_AddRefed -LayerManagerD3D9::CreateShadowThebesLayer() -{ - if (LayerManagerD3D9::mDestroyed) { - NS_WARNING("Call on destroyed layer manager"); - return nsnull; - } - return nsRefPtr(new ShadowThebesLayerD3D9(this)).forget(); -} - -already_AddRefed -LayerManagerD3D9::CreateShadowContainerLayer() -{ - if (LayerManagerD3D9::mDestroyed) { - NS_WARNING("Call on destroyed layer manager"); - return nsnull; - } - return nsRefPtr(new ShadowContainerLayerD3D9(this)).forget(); -} - -already_AddRefed -LayerManagerD3D9::CreateShadowImageLayer() -{ - if (LayerManagerD3D9::mDestroyed) { - NS_WARNING("Call on destroyed layer manager"); - return nsnull; - } - return nsRefPtr(new ShadowImageLayerD3D9(this)).forget(); -} - -already_AddRefed -LayerManagerD3D9::CreateShadowColorLayer() -{ - if (LayerManagerD3D9::mDestroyed) { - NS_WARNING("Call on destroyed layer manager"); - return nsnull; - } - return nsRefPtr(new ShadowColorLayerD3D9(this)).forget(); -} - -already_AddRefed -LayerManagerD3D9::CreateShadowCanvasLayer() -{ - if (LayerManagerD3D9::mDestroyed) { - NS_WARNING("Call on destroyed layer manager"); - return nsnull; - } - return nsRefPtr(new ShadowCanvasLayerD3D9(this)).forget(); -} - void ReleaseTexture(void *texture) { static_cast(texture)->Release(); diff --git a/gfx/layers/d3d9/LayerManagerD3D9.h b/gfx/layers/d3d9/LayerManagerD3D9.h index 38dfb7eb11c..7db39487518 100644 --- a/gfx/layers/d3d9/LayerManagerD3D9.h +++ b/gfx/layers/d3d9/LayerManagerD3D9.h @@ -40,8 +40,6 @@ #include "Layers.h" -#include "mozilla/layers/ShadowLayers.h" - #include #include @@ -90,7 +88,7 @@ struct ShaderConstantRect * This is the LayerManager used for Direct3D 9. For now this will render on * the main thread. */ -class THEBES_API LayerManagerD3D9 : public ShadowLayerManager { +class THEBES_API LayerManagerD3D9 : public LayerManager { public: LayerManagerD3D9(nsIWidget *aWidget); virtual ~LayerManagerD3D9(); @@ -155,12 +153,6 @@ public: virtual already_AddRefed CreateImageContainer(); - virtual already_AddRefed CreateShadowThebesLayer(); - virtual already_AddRefed CreateShadowContainerLayer(); - virtual already_AddRefed CreateShadowImageLayer(); - virtual already_AddRefed CreateShadowColorLayer(); - virtual already_AddRefed CreateShadowCanvasLayer(); - virtual LayersBackend GetBackendType() { return LAYERS_D3D9; } virtual void GetBackendName(nsAString& name) { name.AssignLiteral("Direct3D 9"); } bool DeviceWasRemoved() { return deviceManager()->DeviceWasRemoved(); } @@ -291,40 +283,6 @@ protected: LayerManagerD3D9 *mD3DManager; }; -/* - * RAII helper for locking D3D9 textures. - */ -class LockTextureRectD3D9 -{ -public: - LockTextureRectD3D9(IDirect3DTexture9* aTexture) - : mTexture(aTexture) - { - mLockResult = mTexture->LockRect(0, &mR, NULL, 0); - } - - ~LockTextureRectD3D9() - { - mTexture->UnlockRect(0); - } - - bool HasLock() { - return SUCCEEDED(mLockResult); - } - - D3DLOCKED_RECT GetLockRect() - { - return mR; - } -private: - LockTextureRectD3D9 (const LockTextureRectD3D9&); - LockTextureRectD3D9& operator= (const LockTextureRectD3D9&); - - IDirect3DTexture9* mTexture; - D3DLOCKED_RECT mR; - HRESULT mLockResult; -}; - } /* layers */ } /* mozilla */ diff --git a/gfx/layers/d3d9/ShadowBufferD3D9.cpp b/gfx/layers/d3d9/ShadowBufferD3D9.cpp deleted file mode 100644 index a9109db2f13..00000000000 --- a/gfx/layers/d3d9/ShadowBufferD3D9.cpp +++ /dev/null @@ -1,118 +0,0 @@ -/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 4 -*- - * ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is Mozilla Corporation code. - * - * The Initial Developer of the Original Code is Mozilla Foundation. - * Portions created by the Initial Developer are Copyright (C) 2011 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * Benoit Girard - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -#include "LayerManagerD3D9.h" -#include "ShadowBufferD3D9.h" - -#include "gfxWindowsSurface.h" -#include "gfxWindowsPlatform.h" - - -namespace mozilla { -namespace layers { - -void -ShadowBufferD3D9::Upload(gfxASurface* aUpdate, - const nsIntRect& aVisibleRect) -{ - - gfxIntSize size = aUpdate->GetSize(); - - if (GetSize() != nsIntSize(size.width, size.height)) { - mLayer->device()->CreateTexture(size.width, size.height, 1, - D3DUSAGE_DYNAMIC, - D3DFMT_A8R8G8B8, - D3DPOOL_DEFAULT, getter_AddRefs(mTexture), NULL); - - mTextureRect = aVisibleRect; - } - - LockTextureRectD3D9 textureLock(mTexture); - if (!textureLock.HasLock()) { - NS_WARNING("Failed to lock ShadowBufferD3D9 texture."); - return; - } - - D3DLOCKED_RECT r = textureLock.GetLockRect(); - - nsRefPtr imgSurface = - new gfxImageSurface((unsigned char *)r.pBits, - GetSize(), - r.Pitch, - gfxASurface::ImageFormatARGB32); - - nsRefPtr context = new gfxContext(imgSurface); - context->SetSource(aUpdate); - context->SetOperator(gfxContext::OPERATOR_SOURCE); - context->Paint(); - - imgSurface = NULL; -} - -void -ShadowBufferD3D9::RenderTo(LayerManagerD3D9 *aD3DManager, - const nsIntRegion& aVisibleRegion) -{ - mLayer->SetShaderTransformAndOpacity(); - - aD3DManager->SetShaderMode(DeviceManagerD3D9::RGBALAYER); - mLayer->device()->SetTexture(0, mTexture); - - nsIntRegionRectIterator iter(aVisibleRegion); - - const nsIntRect *iterRect; - while ((iterRect = iter.Next())) { - mLayer->device()->SetVertexShaderConstantF(CBvLayerQuad, - ShaderConstantRect(iterRect->x, - iterRect->y, - iterRect->width, - iterRect->height), - 1); - - mLayer->device()->SetVertexShaderConstantF(CBvTextureCoords, - ShaderConstantRect( - (float)(iterRect->x - mTextureRect.x) / (float)mTextureRect.width, - (float)(iterRect->y - mTextureRect.y) / (float)mTextureRect.height, - (float)iterRect->width / (float)mTextureRect.width, - (float)iterRect->height / (float)mTextureRect.height), 1); - - mLayer->device()->DrawPrimitive(D3DPT_TRIANGLESTRIP, 0, 2); - } -} - -} /* namespace layers */ -} /* namespace mozilla */ diff --git a/gfx/layers/d3d9/ShadowBufferD3D9.h b/gfx/layers/d3d9/ShadowBufferD3D9.h deleted file mode 100644 index 4f23d838e14..00000000000 --- a/gfx/layers/d3d9/ShadowBufferD3D9.h +++ /dev/null @@ -1,77 +0,0 @@ -/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 4 -*- - * ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is Mozilla Corporation code. - * - * The Initial Developer of the Original Code is Mozilla Foundation. - * Portions created by the Initial Developer are Copyright (C) 2011 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * Benoit Girard - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -#ifndef GFX_SHADOWBUFFERD3D9_H -#define GFX_SHADOWBUFFERD3D9_H - -#include "LayerManagerD3D9.h" - -namespace mozilla { -namespace layers { - -class LayerManagerD3D9; -class LayerD3D9; - -class ShadowBufferD3D9 -{ - NS_INLINE_DECL_REFCOUNTING(ShadowBufferD3D9) -public: - - ShadowBufferD3D9(LayerD3D9* aLayer) - : mLayer(aLayer) - { - } - virtual ~ShadowBufferD3D9() {} - - void Upload(gfxASurface* aUpdate, const nsIntRect& aVisibleRect); - - void RenderTo(LayerManagerD3D9 *aD3DManager, const nsIntRegion& aVisibleRegion); - - nsIntSize GetSize() { - if (mTexture) - return nsIntSize(mTextureRect.Width(), mTextureRect.Height()); - return nsIntSize(0, 0); - } -protected: - nsRefPtr mTexture; - nsIntRect mTextureRect; - LayerD3D9* mLayer; -}; - -} /* layers */ -} /* mozilla */ -#endif /* GFX_SHADOWBUFFERD3D9_H */ diff --git a/gfx/layers/d3d9/ThebesLayerD3D9.cpp b/gfx/layers/d3d9/ThebesLayerD3D9.cpp index b34ecfc416b..3dc2e310129 100644 --- a/gfx/layers/d3d9/ThebesLayerD3D9.cpp +++ b/gfx/layers/d3d9/ThebesLayerD3D9.cpp @@ -35,10 +35,6 @@ * * ***** END LICENSE BLOCK ***** */ -#include "mozilla/layers/PLayers.h" -#include "mozilla/layers/ShadowLayers.h" -#include "ShadowBufferD3D9.h" - #include "ThebesLayerD3D9.h" #include "gfxPlatform.h" @@ -520,13 +516,8 @@ ThebesLayerD3D9::DrawRegion(nsIntRegion &aRegion, SurfaceMode aMode, break; case SURFACE_SINGLE_CHANNEL_ALPHA: { - LockTextureRectD3D9 textureLock(tmpTexture); - if (!textureLock.HasLock()) { - NS_WARNING("Failed to lock ThebesLayer tmpTexture texture."); - return; - } - - D3DLOCKED_RECT r = textureLock.GetLockRect(); + D3DLOCKED_RECT r; + tmpTexture->LockRect(0, &r, NULL, 0); nsRefPtr imgSurface = new gfxImageSurface((unsigned char *)r.pBits, @@ -543,6 +534,8 @@ ThebesLayerD3D9::DrawRegion(nsIntRegion &aRegion, SurfaceMode aMode, imgSurface = NULL; + tmpTexture->UnlockRect(0); + srcTextures.AppendElement(tmpTexture); destTextures.AppendElement(mTexture); break; @@ -608,95 +601,5 @@ ThebesLayerD3D9::CreateNewTextures(const gfxIntSize &aSize, } } -ShadowThebesLayerD3D9::ShadowThebesLayerD3D9(LayerManagerD3D9 *aManager) - : ShadowThebesLayer(aManager, nsnull) - , LayerD3D9(aManager) -{ - mImplData = static_cast(this); -} - -ShadowThebesLayerD3D9::~ShadowThebesLayerD3D9() -{} - -void -ShadowThebesLayerD3D9::SetFrontBuffer(const OptionalThebesBuffer& aNewFront, - const nsIntRegion& aValidRegion) -{ - if (!mBuffer) { - mBuffer = new ShadowBufferD3D9(this); - } - - NS_ASSERTION(OptionalThebesBuffer::Tnull_t == aNewFront.type(), - "Only one system-memory buffer expected"); -} - -void -ShadowThebesLayerD3D9::Swap(const ThebesBuffer& aNewFront, - const nsIntRegion& aUpdatedRegion, - ThebesBuffer* aNewBack, - nsIntRegion* aNewBackValidRegion, - OptionalThebesBuffer* aReadOnlyFront, - nsIntRegion* aFrontUpdatedRegion) -{ - if (mBuffer) { - nsRefPtr surf = ShadowLayerForwarder::OpenDescriptor(aNewFront.buffer()); - mBuffer->Upload(surf, GetVisibleRegion().GetBounds()); - } - - *aNewBack = aNewFront; - *aNewBackValidRegion = mValidRegion; - *aReadOnlyFront = null_t(); - aFrontUpdatedRegion->SetEmpty(); -} - -void -ShadowThebesLayerD3D9::DestroyFrontBuffer() -{ - mBuffer = nsnull; -} - -void -ShadowThebesLayerD3D9::Disconnect() -{ - mBuffer = nsnull; -} - -Layer* -ShadowThebesLayerD3D9::GetLayer() -{ - return this; -} - -PRBool -ShadowThebesLayerD3D9::IsEmpty() -{ - return !mBuffer; -} - -void -ShadowThebesLayerD3D9::RenderThebesLayer() -{ - if (!mBuffer) { - return; - } - NS_ABORT_IF_FALSE(mBuffer, "should have a buffer here"); - - mBuffer->RenderTo(mD3DManager, GetEffectiveVisibleRegion()); -} - -void -ShadowThebesLayerD3D9::CleanResources() -{ - mBuffer = nsnull; - mValidRegion.SetEmpty(); -} - -void -ShadowThebesLayerD3D9::LayerManagerDestroyed() -{ - mD3DManager->deviceManager()->mLayersWithResources.RemoveElement(this); - mD3DManager = nsnull; -} - } /* namespace layers */ } /* namespace mozilla */ diff --git a/gfx/layers/d3d9/ThebesLayerD3D9.h b/gfx/layers/d3d9/ThebesLayerD3D9.h index f75eb5f104e..9bbf1257f2c 100644 --- a/gfx/layers/d3d9/ThebesLayerD3D9.h +++ b/gfx/layers/d3d9/ThebesLayerD3D9.h @@ -47,7 +47,6 @@ namespace mozilla { namespace layers { class ReadbackProcessor; -class ShadowBufferD3D9; class ThebesLayerD3D9 : public ThebesLayer, public LayerD3D9 @@ -113,37 +112,6 @@ private: const nsIntRegion &aCopyRegion, nsIntRegion* aValidRegion); }; -class ShadowThebesLayerD3D9 : public ShadowThebesLayer, - public LayerD3D9 -{ -public: - ShadowThebesLayerD3D9(LayerManagerD3D9 *aManager); - virtual ~ShadowThebesLayerD3D9(); - - // ShadowThebesLayer impl - virtual void SetFrontBuffer(const OptionalThebesBuffer& aNewFront, - const nsIntRegion& aValidRegion); - virtual void - Swap(const ThebesBuffer& aNewFront, const nsIntRegion& aUpdatedRegion, - ThebesBuffer* aNewBack, nsIntRegion* aNewBackValidRegion, - OptionalThebesBuffer* aReadOnlyFront, nsIntRegion* aFrontUpdatedRegion); - virtual void DestroyFrontBuffer(); - - virtual void Disconnect(); - - // LayerD3D9 impl - Layer* GetLayer(); - virtual PRBool IsEmpty(); - virtual void RenderLayer() { RenderThebesLayer(); } - virtual void CleanResources(); - virtual void LayerManagerDestroyed(); - - void RenderThebesLayer(); - -private: - nsRefPtr mBuffer; -}; - } /* layers */ } /* mozilla */ #endif /* GFX_THEBESLAYERD3D9_H */ diff --git a/gfx/layers/opengl/CanvasLayerOGL.cpp b/gfx/layers/opengl/CanvasLayerOGL.cpp index abb332a9d87..8d1dea3ea43 100644 --- a/gfx/layers/opengl/CanvasLayerOGL.cpp +++ b/gfx/layers/opengl/CanvasLayerOGL.cpp @@ -35,9 +35,6 @@ * * ***** END LICENSE BLOCK ***** */ -#include "mozilla/layers/PLayers.h" -#include "mozilla/layers/ShadowLayers.h" - #include "gfxSharedImageSurface.h" #include "CanvasLayerOGL.h" diff --git a/gfx/layers/opengl/CanvasLayerOGL.h b/gfx/layers/opengl/CanvasLayerOGL.h index 7ec2a8ddce4..2ac38f62312 100644 --- a/gfx/layers/opengl/CanvasLayerOGL.h +++ b/gfx/layers/opengl/CanvasLayerOGL.h @@ -38,6 +38,8 @@ #ifndef GFX_CANVASLAYEROGL_H #define GFX_CANVASLAYEROGL_H +#include "mozilla/layers/PLayers.h" +#include "mozilla/layers/ShadowLayers.h" #include "LayerManagerOGL.h" #include "gfxASurface.h" diff --git a/layout/ipc/RenderFrameParent.cpp b/layout/ipc/RenderFrameParent.cpp index ee8209c97c7..e106f9ef1d4 100644 --- a/layout/ipc/RenderFrameParent.cpp +++ b/layout/ipc/RenderFrameParent.cpp @@ -42,7 +42,6 @@ #include "BasicLayers.h" #include "LayerManagerOGL.h" -#include "LayerManagerD3D9.h" #include "RenderFrameParent.h" #include "gfx3DMatrix.h" @@ -724,10 +723,6 @@ RenderFrameParent::AllocPLayers() LayerManagerOGL* lmo = static_cast(lm); return new ShadowLayersParent(lmo); } - case LayerManager::LAYERS_D3D9: { - LayerManagerD3D9* lmd3d9 = static_cast(lm); - return new ShadowLayersParent(lmd3d9); - } default: { NS_WARNING("shadow layers no sprechen D3D backend yet"); return nsnull;