зеркало из https://github.com/mozilla/gecko-dev.git
Bypass DecomposeIntoNoRepeatRects when possible. (bug 1396507 part 3, r=mattwoodrow)
--HG-- extra : rebase_source : 7e251cceb9b380b3fbe090090ded085a6b83df50
This commit is contained in:
Родитель
43bdfcc4d2
Коммит
7723f663ea
|
@ -1093,6 +1093,17 @@ MLGDeviceD3D11::InitSamplerStates()
|
|||
"Could not create linear clamp to zero sampler (%x)", hr);
|
||||
}
|
||||
}
|
||||
{
|
||||
CD3D11_SAMPLER_DESC desc = CD3D11_SAMPLER_DESC(CD3D11_DEFAULT());
|
||||
desc.AddressU = D3D11_TEXTURE_ADDRESS_WRAP;
|
||||
desc.AddressV = D3D11_TEXTURE_ADDRESS_WRAP;
|
||||
desc.AddressW = D3D11_TEXTURE_ADDRESS_WRAP;
|
||||
HRESULT hr = mDevice->CreateSamplerState(&desc, getter_AddRefs(mSamplerStates[SamplerMode::LinearRepeat]));
|
||||
if (FAILED(hr)) {
|
||||
return Fail("FEATURE_FAILURE_LINEAR_CLAMP_ZERO_SAMPLER",
|
||||
"Could not create linear clamp to zero sampler (%x)", hr);
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
CD3D11_SAMPLER_DESC desc = CD3D11_SAMPLER_DESC(CD3D11_DEFAULT());
|
||||
|
|
|
@ -238,21 +238,6 @@ MLGDevice::SetPSTexture(uint32_t aSlot, TextureSource* aSource)
|
|||
SetPSTextures(aSlot, 1, &aSource);
|
||||
}
|
||||
|
||||
static inline SamplerMode
|
||||
FilterToSamplerMode(gfx::SamplingFilter aFilter)
|
||||
{
|
||||
switch (aFilter) {
|
||||
case gfx::SamplingFilter::POINT:
|
||||
return SamplerMode::Point;
|
||||
case gfx::SamplingFilter::LINEAR:
|
||||
case gfx::SamplingFilter::GOOD:
|
||||
return SamplerMode::LinearClamp;
|
||||
default:
|
||||
MOZ_ASSERT_UNREACHABLE("Unknown sampler mode");
|
||||
return SamplerMode::LinearClamp;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
MLGDevice::SetSamplerMode(uint32_t aIndex, gfx::SamplingFilter aFilter)
|
||||
{
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
#define mozilla_gfx_layers_mlgpu_MLGDeviceTypes_h
|
||||
|
||||
#include "mozilla/TypedEnumBits.h"
|
||||
#include "mozilla/gfx/Types.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace layers {
|
||||
|
@ -47,6 +48,8 @@ enum class SamplerMode
|
|||
LinearClamp = 0,
|
||||
// Linear filter, clamped to transparent pixels.
|
||||
LinearClampToZero,
|
||||
// Linear filter, wrap edges.
|
||||
LinearRepeat,
|
||||
// Point filter, clamped to border.
|
||||
Point,
|
||||
MaxModes
|
||||
|
@ -104,6 +107,21 @@ MOZ_MAKE_ENUM_CLASS_BITWISE_OPERATORS(MLGRenderTargetFlags);
|
|||
// seems to cause a stack overflow >= 20 rects. We cap to 12 for now.
|
||||
static const size_t kMaxClearViewRects = 12;
|
||||
|
||||
static inline SamplerMode
|
||||
FilterToSamplerMode(gfx::SamplingFilter aFilter)
|
||||
{
|
||||
switch (aFilter) {
|
||||
case gfx::SamplingFilter::POINT:
|
||||
return SamplerMode::Point;
|
||||
case gfx::SamplingFilter::LINEAR:
|
||||
case gfx::SamplingFilter::GOOD:
|
||||
return SamplerMode::LinearClamp;
|
||||
default:
|
||||
MOZ_ASSERT_UNREACHABLE("Unknown sampler mode");
|
||||
return SamplerMode::LinearClamp;
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace layers
|
||||
} // namespace mozilla
|
||||
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
|
||||
#include "LayerManagerMLGPU.h"
|
||||
#include "mozilla/layers/ContentHost.h"
|
||||
#include "MLGDeviceTypes.h"
|
||||
#include "nsRegionFwd.h"
|
||||
#include <functional>
|
||||
|
||||
|
@ -49,6 +50,14 @@ public:
|
|||
ContentHostTexture* GetContentHost() const {
|
||||
return mHost;
|
||||
}
|
||||
SamplerMode GetSamplerMode() {
|
||||
// Note that when resamping, we must break the texture coordinates into
|
||||
// no-repeat rects. When we have simple integer translations we can
|
||||
// simply wrap around the edge of the buffer texture.
|
||||
return MayResample()
|
||||
? SamplerMode::LinearClamp
|
||||
: SamplerMode::LinearRepeat;
|
||||
}
|
||||
|
||||
// This can return a different region than GetShadowVisibleRegion or
|
||||
// GetLocalVisibleRegion, since we make sure to clamp it to the
|
||||
|
|
|
@ -451,21 +451,24 @@ TexturedRenderPass::TexturedRenderPass(FrameBuilder* aBuilder, const ItemInfo& a
|
|||
TexturedRenderPass::Info::Info(const ItemInfo& aItem, PaintedLayerMLGPU* aLayer)
|
||||
: item(aItem),
|
||||
textureSize(aLayer->GetTexture()->GetSize()),
|
||||
destOrigin(aLayer->GetContentHost()->GetOriginOffset())
|
||||
destOrigin(aLayer->GetContentHost()->GetOriginOffset()),
|
||||
decomposeIntoNoRepeatRects(aLayer->MayResample())
|
||||
{
|
||||
}
|
||||
|
||||
TexturedRenderPass::Info::Info(const ItemInfo& aItem, TexturedLayerMLGPU* aLayer)
|
||||
: item(aItem),
|
||||
textureSize(aLayer->GetTexture()->GetSize()),
|
||||
scale(aLayer->GetPictureScale())
|
||||
scale(aLayer->GetPictureScale()),
|
||||
decomposeIntoNoRepeatRects(false)
|
||||
{
|
||||
}
|
||||
|
||||
TexturedRenderPass::Info::Info(const ItemInfo& aItem, ContainerLayerMLGPU* aLayer)
|
||||
: item(aItem),
|
||||
textureSize(aLayer->GetTargetSize()),
|
||||
destOrigin(aLayer->GetTargetOffset())
|
||||
destOrigin(aLayer->GetTargetOffset()),
|
||||
decomposeIntoNoRepeatRects(false)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -535,16 +538,25 @@ TexturedRenderPass::AddClippedItem(Txn& aTxn,
|
|||
textureCoords.SetHeight(-textureCoords.Height());
|
||||
}
|
||||
|
||||
Rect layerRects[4];
|
||||
Rect textureRects[4];
|
||||
size_t numRects =
|
||||
DecomposeIntoNoRepeatRects(aDrawRect, textureCoords, &layerRects, &textureRects);
|
||||
|
||||
for (size_t i = 0; i < numRects; i++) {
|
||||
TexturedTraits traits(aInfo.item, layerRects[i], textureRects[i]);
|
||||
if (!aInfo.decomposeIntoNoRepeatRects) {
|
||||
// Fast, normal case, we can use the texture coordinates as-s and the caller
|
||||
// will use a repeat sampler if needed.
|
||||
TexturedTraits traits(aInfo.item, aDrawRect, textureCoords);
|
||||
if (!aTxn.Add(traits)) {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
Rect layerRects[4];
|
||||
Rect textureRects[4];
|
||||
size_t numRects =
|
||||
DecomposeIntoNoRepeatRects(aDrawRect, textureCoords, &layerRects, &textureRects);
|
||||
|
||||
for (size_t i = 0; i < numRects; i++) {
|
||||
TexturedTraits traits(aInfo.item, layerRects[i], textureRects[i]);
|
||||
if (!aTxn.Add(traits)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -561,17 +573,17 @@ SingleTexturePass::AddToPass(LayerMLGPU* aLayer, ItemInfo& aItem)
|
|||
{
|
||||
RefPtr<TextureSource> texture;
|
||||
|
||||
gfx::SamplingFilter filter;
|
||||
SamplerMode sampler;
|
||||
TextureFlags flags = TextureFlags::NO_FLAGS;
|
||||
if (PaintedLayerMLGPU* paintedLayer = aLayer->AsPaintedLayerMLGPU()) {
|
||||
if (paintedLayer->HasComponentAlpha()) {
|
||||
return false;
|
||||
}
|
||||
texture = paintedLayer->GetTexture();
|
||||
filter = SamplingFilter::LINEAR;
|
||||
sampler = paintedLayer->GetSamplerMode();
|
||||
} else if (TexturedLayerMLGPU* texLayer = aLayer->AsTexturedLayerMLGPU()) {
|
||||
texture = texLayer->GetTexture();
|
||||
filter = texLayer->GetSamplingFilter();
|
||||
sampler = FilterToSamplerMode(texLayer->GetSamplingFilter());
|
||||
TextureHost* host = texLayer->GetImageHost()->CurrentTextureHost();
|
||||
flags = host->GetFlags();
|
||||
} else {
|
||||
|
@ -586,7 +598,7 @@ SingleTexturePass::AddToPass(LayerMLGPU* aLayer, ItemInfo& aItem)
|
|||
if (texture != mTexture) {
|
||||
return false;
|
||||
}
|
||||
if (mFilter != filter) {
|
||||
if (mSamplerMode != sampler) {
|
||||
return false;
|
||||
}
|
||||
if (mOpacity != opacity) {
|
||||
|
@ -595,7 +607,7 @@ SingleTexturePass::AddToPass(LayerMLGPU* aLayer, ItemInfo& aItem)
|
|||
// Note: premultiplied, origin-bottom-left are already implied by the texture source.
|
||||
} else {
|
||||
mTexture = texture;
|
||||
mFilter = filter;
|
||||
mSamplerMode = sampler;
|
||||
mOpacity = opacity;
|
||||
mTextureFlags = flags;
|
||||
}
|
||||
|
@ -638,7 +650,7 @@ SingleTexturePass::SetupPipeline()
|
|||
}
|
||||
|
||||
mDevice->SetPSTexture(0, mTexture);
|
||||
mDevice->SetSamplerMode(kDefaultSamplerSlot, mFilter);
|
||||
mDevice->SetSamplerMode(kDefaultSamplerSlot, mSamplerMode);
|
||||
switch (mTexture.get()->GetFormat()) {
|
||||
case SurfaceFormat::B8G8R8A8:
|
||||
case SurfaceFormat::R8G8B8A8:
|
||||
|
@ -711,7 +723,7 @@ ComponentAlphaPass::SetupPipeline()
|
|||
mDevice->SetPixelShader(PixelShaderID::ComponentAlphaVertex);
|
||||
}
|
||||
|
||||
mDevice->SetSamplerMode(kDefaultSamplerSlot, SamplerMode::LinearClamp);
|
||||
mDevice->SetSamplerMode(kDefaultSamplerSlot, mAssignedLayer->GetSamplerMode());
|
||||
mDevice->SetPSTextures(0, 2, textures);
|
||||
}
|
||||
|
||||
|
@ -733,7 +745,7 @@ VideoRenderPass::AddToPass(LayerMLGPU* aLayer, ItemInfo& aItem)
|
|||
RefPtr<TextureHost> host = layer->GetImageHost()->CurrentTextureHost();
|
||||
RefPtr<TextureSource> source = layer->GetTexture();
|
||||
float opacity = layer->GetComputedOpacity();
|
||||
SamplingFilter filter = layer->GetSamplingFilter();
|
||||
SamplerMode sampler = FilterToSamplerMode(layer->GetSamplingFilter());
|
||||
|
||||
if (mHost) {
|
||||
if (mHost != host) {
|
||||
|
@ -745,14 +757,14 @@ VideoRenderPass::AddToPass(LayerMLGPU* aLayer, ItemInfo& aItem)
|
|||
if (mOpacity != opacity) {
|
||||
return false;
|
||||
}
|
||||
if (mFilter != filter) {
|
||||
if (mSamplerMode != sampler) {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
mHost = host;
|
||||
mTexture = source;
|
||||
mOpacity = opacity;
|
||||
mFilter = filter;
|
||||
mSamplerMode = sampler;
|
||||
}
|
||||
MOZ_ASSERT(!mTexture->AsBigImageIterator());
|
||||
MOZ_ASSERT(!(mHost->GetFlags() & TextureFlags::NON_PREMULTIPLIED));
|
||||
|
@ -819,7 +831,7 @@ VideoRenderPass::SetupPipeline()
|
|||
break;
|
||||
}
|
||||
|
||||
mDevice->SetSamplerMode(kDefaultSamplerSlot, mFilter);
|
||||
mDevice->SetSamplerMode(kDefaultSamplerSlot, mSamplerMode);
|
||||
mDevice->SetPSConstantBuffer(1, ps1);
|
||||
}
|
||||
|
||||
|
|
|
@ -301,6 +301,7 @@ protected:
|
|||
gfx::IntSize textureSize;
|
||||
gfx::Point destOrigin;
|
||||
Maybe<gfx::Size> scale;
|
||||
bool decomposeIntoNoRepeatRects;
|
||||
};
|
||||
|
||||
// Add a set of draw rects based on a visible region. The texture size and
|
||||
|
@ -400,7 +401,7 @@ private:
|
|||
|
||||
private:
|
||||
RefPtr<TextureSource> mTexture;
|
||||
gfx::SamplingFilter mFilter;
|
||||
SamplerMode mSamplerMode;
|
||||
float mOpacity;
|
||||
};
|
||||
|
||||
|
@ -446,7 +447,7 @@ private:
|
|||
private:
|
||||
RefPtr<TextureHost> mHost;
|
||||
RefPtr<TextureSource> mTexture;
|
||||
gfx::SamplingFilter mFilter;
|
||||
SamplerMode mSamplerMode;
|
||||
float mOpacity;
|
||||
};
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче