Bug 1565255 - Backout Bug 1552734 r=nical

Since Bug 1531898 fix, fix of Bug 1552734 is not necessary anymore. The backout reduces memory usage.

Differential Revision: https://phabricator.services.mozilla.com/D38257

--HG--
extra : moz-landing-system : lando
This commit is contained in:
sotaro 2019-07-17 14:10:47 +00:00
parent 2e9f346e73
commit d596757662
4 changed files with 21 additions and 73 deletions

View File

@ -24,40 +24,39 @@ D3D11YCbCrImage::D3D11YCbCrImage()
D3D11YCbCrImage::~D3D11YCbCrImage() {}
/* static */
already_AddRefed<TextureClient>
D3D11YCbCrImage::CreateAndCopyDataToDXGIYCbCrTextureData(
KnowsCompositor* aAllocator, ImageContainer* aContainer,
const PlanarYCbCrData& aData) {
if (!aAllocator || !aContainer) {
return nullptr;
}
bool D3D11YCbCrImage::SetData(KnowsCompositor* aAllocator,
ImageContainer* aContainer,
const PlanarYCbCrData& aData) {
mPictureRect = IntRect(aData.mPicX, aData.mPicY, aData.mPicSize.width,
aData.mPicSize.height);
mYSize = aData.mYSize;
mCbCrSize = aData.mCbCrSize;
mColorDepth = aData.mColorDepth;
mColorSpace = aData.mYUVColorSpace;
D3D11YCbCrRecycleAllocator* allocator =
aContainer->GetD3D11YCbCrRecycleAllocator(aAllocator);
if (!allocator) {
return nullptr;
return false;
}
RefPtr<ID3D11Device> device = gfx::DeviceManagerDx::Get()->GetImageDevice();
if (!device) {
return nullptr;
return false;
}
RefPtr<TextureClient> textureClient;
{
DXGIYCbCrTextureAllocationHelper helper(aData, TextureFlags::DEFAULT,
device);
textureClient = allocator->CreateOrRecycle(helper);
mTextureClient = allocator->CreateOrRecycle(helper);
}
if (!textureClient) {
return nullptr;
if (!mTextureClient) {
return false;
}
DXGIYCbCrTextureData* data =
textureClient->GetInternalData()->AsDXGIYCbCrTextureData();
mTextureClient->GetInternalData()->AsDXGIYCbCrTextureData();
ID3D11Texture2D* textureY = data->GetD3D11Texture(0);
ID3D11Texture2D* textureCb = data->GetD3D11Texture(1);
@ -68,12 +67,12 @@ D3D11YCbCrImage::CreateAndCopyDataToDXGIYCbCrTextureData(
if (FAILED(hr) || !mt) {
gfxCriticalError() << "Multithread safety interface not supported. " << hr;
return nullptr;
return false;
}
if (!mt->GetMultithreadProtected()) {
gfxCriticalError() << "Device used not marked as multithread-safe.";
return nullptr;
return false;
}
D3D11MTAutoEnter mtAutoEnter(mt.forget());
@ -82,7 +81,7 @@ D3D11YCbCrImage::CreateAndCopyDataToDXGIYCbCrTextureData(
device->GetImmediateContext(getter_AddRefs(ctx));
if (!ctx) {
gfxCriticalError() << "Failed to get immediate context.";
return nullptr;
return false;
}
AutoLockD3D11Texture lockY(textureY);
@ -98,25 +97,6 @@ D3D11YCbCrImage::CreateAndCopyDataToDXGIYCbCrTextureData(
aData.mCbCrStride,
aData.mCbCrStride * aData.mCbCrSize.height);
return textureClient.forget();
}
bool D3D11YCbCrImage::SetData(KnowsCompositor* aAllocator,
ImageContainer* aContainer,
const PlanarYCbCrData& aData) {
mPictureRect = IntRect(aData.mPicX, aData.mPicY, aData.mPicSize.width,
aData.mPicSize.height);
mYSize = aData.mYSize;
mCbCrSize = aData.mCbCrSize;
mColorDepth = aData.mColorDepth;
mColorSpace = aData.mYUVColorSpace;
mTextureClient =
CreateAndCopyDataToDXGIYCbCrTextureData(aAllocator, aContainer, aData);
if (!mTextureClient) {
return false;
}
return true;
}

View File

@ -59,11 +59,6 @@ class D3D11YCbCrImage : public Image {
D3D11YCbCrImage();
virtual ~D3D11YCbCrImage();
static already_AddRefed<TextureClient>
CreateAndCopyDataToDXGIYCbCrTextureData(KnowsCompositor* aAllocator,
ImageContainer* aContainer,
const PlanarYCbCrData& aData);
// Copies the surface into a sharable texture's surface, and initializes
// the image.
bool SetData(KnowsCompositor* aAllocator, ImageContainer* aContainer,

View File

@ -34,11 +34,6 @@
#include "nsISupportsImpl.h" // for Image::Release, etc
#include "nsRect.h" // for mozilla::gfx::IntRect
#ifdef XP_WIN
# include "mozilla/WindowsVersion.h"
# include "mozilla/layers/D3D11YCbCrImage.h"
#endif
namespace mozilla {
namespace layers {
@ -96,8 +91,7 @@ void ImageClientSingle::FlushAllImages() {
/* static */
already_AddRefed<TextureClient> ImageClient::CreateTextureClientForImage(
Image* aImage, KnowsCompositor* aKnowsCompositor,
ImageContainer* aContainer) {
Image* aImage, KnowsCompositor* aKnowsCompositor) {
RefPtr<TextureClient> texture;
if (aImage->GetFormat() == ImageFormat::PLANAR_YCBCR) {
PlanarYCbCrImage* ycbcr = static_cast<PlanarYCbCrImage*>(aImage);
@ -105,26 +99,6 @@ already_AddRefed<TextureClient> ImageClient::CreateTextureClientForImage(
if (!data) {
return nullptr;
}
#if XP_WIN
// We disable this code path on Windows version earlier of Windows 8 due to
// intermittent crashes with old drivers. See bug 1405110.
// DXGIYCbCrTextureData can only handle YCbCr images using 3 non-interleaved
// planes non-zero mSkip value indicates that one of the plane would be
// interleaved.
if (IsWin8OrLater() && XRE_IsContentProcess() && aKnowsCompositor &&
aKnowsCompositor->SupportsD3D11() &&
aKnowsCompositor->GetTextureForwarder() &&
aKnowsCompositor->GetTextureForwarder()->UsesImageBridge() &&
aContainer && data->mYSkip == 0 && data->mCbSkip == 0 &&
data->mCrSkip == 0) {
texture = D3D11YCbCrImage::CreateAndCopyDataToDXGIYCbCrTextureData(
aKnowsCompositor, aContainer, *data);
if (texture) {
return texture.forget();
}
}
#endif
texture = TextureClient::CreateForYCbCr(
aKnowsCompositor, data->mYSize, data->mYStride, data->mCbCrSize,
data->mCbCrStride, data->mStereoMode, data->mColorDepth,
@ -246,7 +220,7 @@ bool ImageClientSingle::UpdateImage(ImageContainer* aContainer,
// Slow path, we should not be hitting it very often and if we do it means
// we are using an Image class that is not backed by textureClient and we
// should fix it.
texture = CreateTextureClientForImage(image, GetForwarder(), aContainer);
texture = CreateTextureClientForImage(image, GetForwarder());
}
if (!texture) {

View File

@ -71,8 +71,7 @@ class ImageClient : public CompositableClient {
virtual ImageClientSingle* AsImageClientSingle() { return nullptr; }
static already_AddRefed<TextureClient> CreateTextureClientForImage(
Image* aImage, KnowsCompositor* aForwarder,
ImageContainer* aContainer = nullptr);
Image* aImage, KnowsCompositor* aForwarder);
uint32_t GetLastUpdateGenerationCounter() {
return mLastUpdateGenerationCounter;