From e9e5023ac149c9724925ab1be45ab70133ba7304 Mon Sep 17 00:00:00 2001 From: Bas Schouten Date: Wed, 29 Dec 2010 19:22:18 +0000 Subject: [PATCH] Bug 604452: Default to linear upscaling in D3D9 layers and adhere to mFiler. r=bjacob a=blocking-final --- gfx/layers/d3d9/CanvasLayerD3D9.cpp | 8 ++++++++ gfx/layers/d3d9/DeviceManagerD3D9.cpp | 6 ++++++ gfx/layers/d3d9/ImageLayerD3D9.cpp | 17 +++++++++++------ 3 files changed, 25 insertions(+), 6 deletions(-) diff --git a/gfx/layers/d3d9/CanvasLayerD3D9.cpp b/gfx/layers/d3d9/CanvasLayerD3D9.cpp index d2d5c533a44..a3b70a17286 100644 --- a/gfx/layers/d3d9/CanvasLayerD3D9.cpp +++ b/gfx/layers/d3d9/CanvasLayerD3D9.cpp @@ -250,6 +250,10 @@ CanvasLayerD3D9::RenderLayer() mD3DManager->SetShaderMode(DeviceManagerD3D9::RGBALAYER); + if (mFilter == gfxPattern::FILTER_NEAREST) { + device()->SetSamplerState(0, D3DSAMP_MAGFILTER, D3DTEXF_POINT); + device()->SetSamplerState(0, D3DSAMP_MINFILTER, D3DTEXF_POINT); + } if (!mDataIsPremultiplied) { device()->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA); device()->SetRenderState(D3DRS_SEPARATEALPHABLENDENABLE, TRUE); @@ -260,6 +264,10 @@ CanvasLayerD3D9::RenderLayer() device()->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_ONE); device()->SetRenderState(D3DRS_SEPARATEALPHABLENDENABLE, FALSE); } + if (mFilter == gfxPattern::FILTER_NEAREST) { + device()->SetSamplerState(0, D3DSAMP_MAGFILTER, D3DTEXF_LINEAR); + device()->SetSamplerState(0, D3DSAMP_MINFILTER, D3DTEXF_LINEAR); + } } void diff --git a/gfx/layers/d3d9/DeviceManagerD3D9.cpp b/gfx/layers/d3d9/DeviceManagerD3D9.cpp index d07c151ac03..3c2731f098e 100644 --- a/gfx/layers/d3d9/DeviceManagerD3D9.cpp +++ b/gfx/layers/d3d9/DeviceManagerD3D9.cpp @@ -436,6 +436,12 @@ DeviceManagerD3D9::SetupRenderState() mDevice->SetRenderState(D3DRS_SRCBLENDALPHA, D3DBLEND_ONE); mDevice->SetRenderState(D3DRS_DESTBLENDALPHA, D3DBLEND_INVSRCALPHA); mDevice->SetRenderState(D3DRS_BLENDOPALPHA, D3DBLENDOP_ADD); + mDevice->SetSamplerState(0, D3DSAMP_MAGFILTER, D3DTEXF_LINEAR); + mDevice->SetSamplerState(0, D3DSAMP_MINFILTER, D3DTEXF_LINEAR); + mDevice->SetSamplerState(1, D3DSAMP_MAGFILTER, D3DTEXF_LINEAR); + mDevice->SetSamplerState(1, D3DSAMP_MINFILTER, D3DTEXF_LINEAR); + mDevice->SetSamplerState(2, D3DSAMP_MAGFILTER, D3DTEXF_LINEAR); + mDevice->SetSamplerState(2, D3DSAMP_MINFILTER, D3DTEXF_LINEAR); mDevice->SetSamplerState(0, D3DSAMP_ADDRESSU, D3DTADDRESS_CLAMP); mDevice->SetSamplerState(0, D3DSAMP_ADDRESSV, D3DTADDRESS_CLAMP); mDevice->SetSamplerState(1, D3DSAMP_ADDRESSU, D3DTADDRESS_CLAMP); diff --git a/gfx/layers/d3d9/ImageLayerD3D9.cpp b/gfx/layers/d3d9/ImageLayerD3D9.cpp index c1cc1076d3b..2ae7b568a8e 100644 --- a/gfx/layers/d3d9/ImageLayerD3D9.cpp +++ b/gfx/layers/d3d9/ImageLayerD3D9.cpp @@ -313,15 +313,12 @@ ImageLayerD3D9::RenderLayer() } } + // 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, yuvImage->mYTexture); - device()->SetSamplerState(0, D3DSAMP_MAGFILTER, D3DTEXF_LINEAR); - device()->SetSamplerState(0, D3DSAMP_MINFILTER, D3DTEXF_LINEAR); device()->SetTexture(1, yuvImage->mCbTexture); - device()->SetSamplerState(1, D3DSAMP_MAGFILTER, D3DTEXF_LINEAR); - device()->SetSamplerState(1, D3DSAMP_MINFILTER, D3DTEXF_LINEAR); device()->SetTexture(2, yuvImage->mCrTexture); - device()->SetSamplerState(2, D3DSAMP_MAGFILTER, D3DTEXF_LINEAR); - device()->SetSamplerState(2, D3DSAMP_MINFILTER, D3DTEXF_LINEAR); device()->DrawPrimitive(D3DPT_TRIANGLESTRIP, 0, 2); @@ -353,8 +350,16 @@ ImageLayerD3D9::RenderLayer() mD3DManager->SetShaderMode(DeviceManagerD3D9::RGBLAYER); } + if (mFilter == gfxPattern::FILTER_NEAREST) { + device()->SetSamplerState(0, D3DSAMP_MAGFILTER, D3DTEXF_POINT); + device()->SetSamplerState(0, D3DSAMP_MINFILTER, D3DTEXF_POINT); + } device()->SetTexture(0, cairoImage->GetOrCreateTexture()); device()->DrawPrimitive(D3DPT_TRIANGLESTRIP, 0, 2); + if (mFilter == gfxPattern::FILTER_NEAREST) { + device()->SetSamplerState(0, D3DSAMP_MAGFILTER, D3DTEXF_LINEAR); + device()->SetSamplerState(0, D3DSAMP_MINFILTER, D3DTEXF_LINEAR); + } } }