Backed out changeset 6358a64e4f15 (bug 1236112) for windows video wpt failures

MozReview-Commit-ID: 6tovOHlvyak
This commit is contained in:
Wes Kocher 2016-03-08 16:23:04 -08:00
Родитель fc6187d378
Коммит 9a43697d65
4 изменённых файлов: 57 добавлений и 36 удалений

Просмотреть файл

@ -48,7 +48,6 @@
#include "TimeUnits.h"
#include "VideoSegment.h"
#include "VideoUtils.h"
#include "gfxPrefs.h"
namespace mozilla {
@ -2421,7 +2420,7 @@ MediaDecoderStateMachine::CheckFrameValidity(VideoData* aData)
MOZ_ASSERT(OnTaskQueue());
// Update corrupt-frames statistics
if (aData->mImage && !aData->mImage->IsValid() && !gfxPrefs::HardwareVideoDecodingForceEnabled()) {
if (aData->mImage && !aData->mImage->IsValid()) {
FrameStatistics& frameStats = *mFrameStats;
frameStats.NotifyCorruptFrame();
// If more than 10% of the last 30 frames have been corrupted, then try disabling

Просмотреть файл

@ -423,40 +423,12 @@ D3D9DXVA2Manager::CopyToImage(IMFSample* aSample,
getter_AddRefs(surface));
NS_ENSURE_TRUE(SUCCEEDED(hr), hr);
RefPtr<D3D9SurfaceImage> image = new D3D9SurfaceImage();
RefPtr<D3D9SurfaceImage> image = new D3D9SurfaceImage(mFirstFrame);
hr = image->AllocateAndCopy(mTextureClientAllocator, surface, aRegion);
NS_ENSURE_TRUE(SUCCEEDED(hr), hr);
// Flush the draw command now, so that by the time we come to draw this
// image, we're less likely to need to wait for the draw operation to
// complete.
RefPtr<IDirect3DQuery9> query;
hr = mDevice->CreateQuery(D3DQUERYTYPE_EVENT, getter_AddRefs(query));
NS_ENSURE_TRUE(SUCCEEDED(hr), hr);
hr = query->Issue(D3DISSUE_END);
NS_ENSURE_TRUE(SUCCEEDED(hr), hr);
bool valid = false;
int iterations = 0;
while (iterations < (mFirstFrame ? 100 : 10)) {
hr = query->GetData(nullptr, 0, D3DGETDATA_FLUSH);
if (hr == S_FALSE) {
Sleep(1);
iterations++;
continue;
}
if (hr == S_OK) {
valid = true;
}
break;
}
mFirstFrame = false;
if (!valid) {
image->Invalidate();
}
image.forget(aOutImage);
return S_OK;
}

Просмотреть файл

@ -15,10 +15,11 @@ namespace mozilla {
namespace layers {
D3D9SurfaceImage::D3D9SurfaceImage()
D3D9SurfaceImage::D3D9SurfaceImage(bool aIsFirstFrame)
: Image(nullptr, ImageFormat::D3D9_RGB32_TEXTURE)
, mSize(0, 0)
, mValid(false)
, mIsFirstFrame(aIsFirstFrame)
{}
D3D9SurfaceImage::~D3D9SurfaceImage()
@ -72,11 +73,52 @@ D3D9SurfaceImage::AllocateAndCopy(D3D9RecycleAllocator* aAllocator,
hr = device->StretchRect(surface, &src, textureSurface, nullptr, D3DTEXF_NONE);
NS_ENSURE_TRUE(SUCCEEDED(hr), hr);
// Flush the draw command now, so that by the time we come to draw this
// image, we're less likely to need to wait for the draw operation to
// complete.
RefPtr<IDirect3DQuery9> query;
hr = device->CreateQuery(D3DQUERYTYPE_EVENT, getter_AddRefs(query));
NS_ENSURE_TRUE(SUCCEEDED(hr), hr);
hr = query->Issue(D3DISSUE_END);
NS_ENSURE_TRUE(SUCCEEDED(hr), hr);
mTextureClient = textureClient;
mSize = aRegion.Size();
mQuery = query;
return S_OK;
}
bool
D3D9SurfaceImage::IsValid()
{
EnsureSynchronized();
return mValid;
}
void
D3D9SurfaceImage::EnsureSynchronized()
{
RefPtr<IDirect3DQuery9> query = mQuery;
if (!query) {
// Not setup, or already synchronized.
return;
}
int iterations = 0;
while (iterations < (mIsFirstFrame ? 100 : 10)) {
HRESULT hr = query->GetData(nullptr, 0, D3DGETDATA_FLUSH);
if (hr == S_FALSE) {
Sleep(1);
iterations++;
continue;
}
if (hr == S_OK) {
mValid = true;
}
break;
}
mQuery = nullptr;
}
const D3DSURFACE_DESC&
D3D9SurfaceImage::GetDesc() const
{
@ -94,6 +136,7 @@ D3D9SurfaceImage::GetTextureClient(CompositableClient* aClient)
{
MOZ_ASSERT(mTextureClient);
MOZ_ASSERT(mTextureClient->GetAllocator() == aClient->GetForwarder());
EnsureSynchronized();
return mTextureClient;
}
@ -110,6 +153,9 @@ D3D9SurfaceImage::GetAsSourceSurface()
return nullptr;
}
// Ensure that the texture is ready to be used.
EnsureSynchronized();
DXGID3D9TextureData* texData = static_cast<DXGID3D9TextureData*>(mTextureClient->GetInternalData());
// Readback the texture from GPU memory into system memory, so that
// we can copy it into the Cairo image. This is expensive.

Просмотреть файл

@ -47,7 +47,7 @@ protected:
// resource is ready to use.
class D3D9SurfaceImage : public Image {
public:
explicit D3D9SurfaceImage();
explicit D3D9SurfaceImage(bool aIsFirstFrame);
virtual ~D3D9SurfaceImage();
HRESULT AllocateAndCopy(D3D9RecycleAllocator* aAllocator,
@ -63,15 +63,19 @@ public:
virtual TextureClient* GetTextureClient(CompositableClient* aClient) override;
virtual bool IsValid() override { return mValid; }
void Invalidate() { mValid = false; }
virtual bool IsValid() override;
private:
// Blocks the calling thread until the copy operation started in SetData()
// is complete, whereupon the texture is safe to use.
void EnsureSynchronized();
gfx::IntSize mSize;
RefPtr<IDirect3DQuery9> mQuery;
RefPtr<TextureClient> mTextureClient;
bool mValid;
bool mIsFirstFrame;
};
} // namepace layers