mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-11 12:25:53 +00:00
Backed out 3 changesets (bug 1212323) for WinXP debug crashes CLOSED TREE
Backed out changeset 7215ed1cfcef (bug 1212323) Backed out changeset bd7599dcee0d (bug 1212323) Backed out changeset 228267494daa (bug 1212323) --HG-- extra : commitid : C8ZtL47yMj1
This commit is contained in:
parent
b9d77f5943
commit
4c1c8ea235
@ -106,7 +106,6 @@
|
||||
#include "HTMLImageElement.h"
|
||||
#include "mozilla/css/ImageLoader.h"
|
||||
#include "mozilla/layers/APZCTreeManager.h" // for layers::ZoomToRectBehavior
|
||||
#include "mozilla/dom/Promise.h"
|
||||
|
||||
#ifdef XP_WIN
|
||||
#undef GetClassName
|
||||
@ -2151,29 +2150,26 @@ nsDOMWindowUtils::GetLayerManagerRemote(bool* retval)
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDOMWindowUtils::GetSupportsHardwareH264Decoding(JS::MutableHandle<JS::Value> aPromise)
|
||||
nsDOMWindowUtils::GetSupportsHardwareH264Decoding(nsAString& aRetval)
|
||||
{
|
||||
nsCOMPtr<nsPIDOMWindow> window = do_QueryReferent(mWindow);
|
||||
NS_ENSURE_STATE(window);
|
||||
nsCOMPtr<nsIGlobalObject> parentObject = do_QueryInterface(window);
|
||||
NS_ENSURE_STATE(parentObject);
|
||||
#ifdef MOZ_FMP4
|
||||
nsCOMPtr<nsIWidget> widget = GetWidget();
|
||||
NS_ENSURE_STATE(widget);
|
||||
if (!widget)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
LayerManager *mgr = widget->GetLayerManager();
|
||||
NS_ENSURE_STATE(mgr);
|
||||
RefPtr<Promise> promise =
|
||||
MP4Decoder::IsVideoAccelerated(mgr->GetCompositorBackendType(), parentObject);
|
||||
NS_ENSURE_STATE(promise);
|
||||
aPromise.setObject(*promise->GetWrapper());
|
||||
#else
|
||||
ErrorResult rv;
|
||||
RefPtr<Promise> promise = Promise::Create(parentObject, rv);
|
||||
if (rv.Failed()) {
|
||||
return rv.StealNSResult();
|
||||
if (!mgr)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
nsCString failureReason;
|
||||
if (MP4Decoder::IsVideoAccelerated(mgr->GetCompositorBackendType(), failureReason)) {
|
||||
aRetval.AssignLiteral("Yes");
|
||||
} else {
|
||||
aRetval.AssignLiteral("No; ");
|
||||
AppendUTF8toUTF16(failureReason, aRetval);
|
||||
}
|
||||
promise.MaybeResolve(NS_LITERAL_STRING("No; Compiled without MP4 support."));
|
||||
aPromise.setObject(*promise->GetWrapper());
|
||||
#else
|
||||
aRetval.AssignLiteral("No; Compiled without MP4 support.");
|
||||
#endif
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -49,7 +49,7 @@ interface nsIJSRAIIHelper;
|
||||
interface nsIContentPermissionRequest;
|
||||
interface nsIObserver;
|
||||
|
||||
[scriptable, uuid(46b44e33-13c2-4eb3-bf80-76a4e0857ccc)]
|
||||
[scriptable, uuid(ca6a458c-82e7-4979-886e-6d214eac6f0b)]
|
||||
interface nsIDOMWindowUtils : nsISupports {
|
||||
|
||||
/**
|
||||
@ -1334,12 +1334,11 @@ interface nsIDOMWindowUtils : nsISupports {
|
||||
readonly attribute boolean layerManagerRemote;
|
||||
|
||||
/**
|
||||
* Returns a Promise that will be resolved with a string once the capabilities
|
||||
* of the h264 decoder have been determined.
|
||||
* Success does not mean that all h264 video decoding will be done
|
||||
* True if we can initialize a hardware-backed h264 decoder for a simple
|
||||
* test video, does not mean that all h264 video decoding will be done
|
||||
* in hardware.
|
||||
*/
|
||||
readonly attribute jsval supportsHardwareH264Decoding;
|
||||
readonly attribute AString supportsHardwareH264Decoding;
|
||||
|
||||
/**
|
||||
* Record (and return) frame-intervals for frames which were presented
|
||||
|
@ -182,46 +182,23 @@ MP4Decoder::IsEnabled()
|
||||
return Preferences::GetBool("media.mp4.enabled");
|
||||
}
|
||||
|
||||
// sTestH264ExtraData represents the content of the avcC atom found in
|
||||
// an AVC1 h264 video. It contains the H264 SPS and PPS NAL.
|
||||
// the structure of the avcC atom is as follow:
|
||||
// write(0x1); // version, always 1
|
||||
// write(sps[0].data[1]); // profile
|
||||
// write(sps[0].data[2]); // compatibility
|
||||
// write(sps[0].data[3]); // level
|
||||
// write(0xFC | 3); // reserved (6 bits), NULA length size - 1 (2 bits)
|
||||
// write(0xE0 | 1); // reserved (3 bits), num of SPS (5 bits)
|
||||
// write_word(sps[0].size); // 2 bytes for length of SPS
|
||||
// for(size_t i=0 ; i < sps[0].size ; ++i)
|
||||
// write(sps[0].data[i]); // data of SPS
|
||||
// write(&b, pps.size()); // num of PPS
|
||||
// for(size_t i=0 ; i < pps.size() ; ++i) {
|
||||
// write_word(pps[i].size); // 2 bytes for length of PPS
|
||||
// for(size_t j=0 ; j < pps[i].size ; ++j)
|
||||
// write(pps[i].data[j]); // data of PPS
|
||||
// }
|
||||
// }
|
||||
// here we have a h264 Baseline, 640x360
|
||||
// We use a 640x360 extradata, as some video framework (Apple VT) will never
|
||||
// attempt to use hardware decoding for small videos.
|
||||
static const uint8_t sTestH264ExtraData[] = {
|
||||
0x01, 0x42, 0xc0, 0x1e, 0xff, 0xe1, 0x00, 0x17, 0x67, 0x42,
|
||||
0xc0, 0x1e, 0xbb, 0x40, 0x50, 0x17, 0xfc, 0xb8, 0x08, 0x80,
|
||||
0x00, 0x00, 0x32, 0x00, 0x00, 0x0b, 0xb5, 0x07, 0x8b, 0x17,
|
||||
0x50, 0x01, 0x00, 0x04, 0x68, 0xce, 0x32, 0xc8
|
||||
0x01, 0x64, 0x00, 0x0a, 0xff, 0xe1, 0x00, 0x17, 0x67, 0x64,
|
||||
0x00, 0x0a, 0xac, 0xd9, 0x44, 0x26, 0x84, 0x00, 0x00, 0x03,
|
||||
0x00, 0x04, 0x00, 0x00, 0x03, 0x00, 0xc8, 0x3c, 0x48, 0x96,
|
||||
0x58, 0x01, 0x00, 0x06, 0x68, 0xeb, 0xe3, 0xcb, 0x22, 0xc0
|
||||
};
|
||||
|
||||
static already_AddRefed<MediaDataDecoder>
|
||||
CreateTestH264Decoder(layers::LayersBackend aBackend,
|
||||
VideoInfo& aConfig,
|
||||
FlushableTaskQueue* aTaskQueue)
|
||||
VideoInfo& aConfig)
|
||||
{
|
||||
aConfig.mMimeType = "video/avc";
|
||||
aConfig.mId = 1;
|
||||
aConfig.mDuration = 40000;
|
||||
aConfig.mMediaTime = 0;
|
||||
aConfig.mDisplay = nsIntSize(640, 360);
|
||||
aConfig.mImage = nsIntRect(0, 0, 640, 360);
|
||||
aConfig.mDisplay = nsIntSize(64, 64);
|
||||
aConfig.mImage = nsIntRect(0, 0, 64, 64);
|
||||
aConfig.mExtraData = new MediaByteBuffer();
|
||||
aConfig.mExtraData->AppendElements(sTestH264ExtraData,
|
||||
MOZ_ARRAY_LENGTH(sTestH264ExtraData));
|
||||
@ -230,60 +207,23 @@ CreateTestH264Decoder(layers::LayersBackend aBackend,
|
||||
|
||||
RefPtr<PDMFactory> platform = new PDMFactory();
|
||||
RefPtr<MediaDataDecoder> decoder(
|
||||
platform->CreateDecoder(aConfig, aTaskQueue, nullptr, aBackend, nullptr));
|
||||
platform->CreateDecoder(aConfig, nullptr, nullptr, aBackend, nullptr));
|
||||
|
||||
return decoder.forget();
|
||||
}
|
||||
|
||||
/* static */ already_AddRefed<dom::Promise>
|
||||
MP4Decoder::IsVideoAccelerated(layers::LayersBackend aBackend, nsIGlobalObject* aParent)
|
||||
/* static */ bool
|
||||
MP4Decoder::IsVideoAccelerated(layers::LayersBackend aBackend, nsACString& aFailureReason)
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
|
||||
ErrorResult rv;
|
||||
RefPtr<dom::Promise> promise;
|
||||
promise = dom::Promise::Create(aParent, rv);
|
||||
if (rv.Failed()) {
|
||||
rv.SuppressException();
|
||||
return nullptr;
|
||||
}
|
||||
RefPtr<FlushableTaskQueue> taskQueue =
|
||||
new FlushableTaskQueue(GetMediaThreadPool(MediaThreadType::PLATFORM_DECODER));
|
||||
VideoInfo config;
|
||||
RefPtr<MediaDataDecoder> decoder(CreateTestH264Decoder(aBackend, config, taskQueue));
|
||||
RefPtr<MediaDataDecoder> decoder(CreateTestH264Decoder(aBackend, config));
|
||||
if (!decoder) {
|
||||
promise->MaybeResolve(NS_LITERAL_STRING("No; Failed to create H264 decoder"));
|
||||
return promise.forget();
|
||||
aFailureReason.AssignLiteral("Failed to create H264 decoder");
|
||||
return false;
|
||||
}
|
||||
|
||||
decoder->Init()
|
||||
->Then(AbstractThread::MainThread(), __func__,
|
||||
[promise, decoder, taskQueue] (TrackInfo::TrackType aTrack) {
|
||||
nsCString failureReason;
|
||||
bool ok = decoder->IsHardwareAccelerated(failureReason);
|
||||
nsAutoString result;
|
||||
if (ok) {
|
||||
result.AssignLiteral("Yes");
|
||||
} else {
|
||||
result.AssignLiteral("No");
|
||||
if (failureReason.Length()) {
|
||||
result.AppendLiteral("; ");
|
||||
AppendUTF8toUTF16(failureReason, result);
|
||||
}
|
||||
}
|
||||
promise->MaybeResolve(result);
|
||||
decoder->Shutdown();
|
||||
taskQueue->BeginShutdown();
|
||||
taskQueue->AwaitShutdownAndIdle();
|
||||
},
|
||||
[promise, decoder, taskQueue] (MediaDataDecoder::DecoderFailureReason aResult) {
|
||||
promise->MaybeResolve(NS_LITERAL_STRING("No; Failed to initialize H264 decoder"));
|
||||
decoder->Shutdown();
|
||||
taskQueue->BeginShutdown();
|
||||
taskQueue->AwaitShutdownAndIdle();
|
||||
});
|
||||
|
||||
return promise.forget();
|
||||
bool result = decoder->IsHardwareAccelerated(aFailureReason);
|
||||
decoder->Shutdown();
|
||||
return result;
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -8,7 +8,6 @@
|
||||
|
||||
#include "MediaDecoder.h"
|
||||
#include "MediaFormatReader.h"
|
||||
#include "mozilla/dom/Promise.h"
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
@ -39,8 +38,7 @@ public:
|
||||
// Returns true if the MP4 backend is preffed on.
|
||||
static bool IsEnabled();
|
||||
|
||||
static already_AddRefed<dom::Promise>
|
||||
IsVideoAccelerated(layers::LayersBackend aBackend, nsIGlobalObject* aParent);
|
||||
static bool IsVideoAccelerated(layers::LayersBackend aBackend, nsACString& aReason);
|
||||
|
||||
void GetMozDebugReaderData(nsAString& aString) override;
|
||||
|
||||
|
@ -318,13 +318,6 @@ var dataProviders = {
|
||||
}
|
||||
catch (e) {}
|
||||
|
||||
let promises = [];
|
||||
// done will be called upon all pending promises being resolved.
|
||||
// add your pending promise to promises when adding new ones.
|
||||
function completed() {
|
||||
Promise.all(promises).then(() => done(data));
|
||||
}
|
||||
|
||||
data.numTotalWindows = 0;
|
||||
data.numAcceleratedWindows = 0;
|
||||
let winEnumer = Services.ww.getWindowEnumerator();
|
||||
@ -340,6 +333,7 @@ var dataProviders = {
|
||||
data.numTotalWindows++;
|
||||
data.windowLayerManagerType = winUtils.layerManagerType;
|
||||
data.windowLayerManagerRemote = winUtils.layerManagerRemote;
|
||||
data.supportsHardwareH264 = winUtils.supportsHardwareH264Decoding;
|
||||
}
|
||||
catch (e) {
|
||||
continue;
|
||||
@ -348,16 +342,6 @@ var dataProviders = {
|
||||
data.numAcceleratedWindows++;
|
||||
}
|
||||
|
||||
let winUtils = Services.wm.getMostRecentWindow("").
|
||||
QueryInterface(Ci.nsIInterfaceRequestor).
|
||||
getInterface(Ci.nsIDOMWindowUtils)
|
||||
data.supportsHardwareH264 = "Unknown";
|
||||
let promise = winUtils.supportsHardwareH264Decoding;
|
||||
promise.then(function(v) {
|
||||
data.supportsHardwareH264 = v;
|
||||
});
|
||||
promises.push(promise);
|
||||
|
||||
if (!data.numAcceleratedWindows && gfxInfo) {
|
||||
let win = AppConstants.platform == "win";
|
||||
let feature = win ? gfxInfo.FEATURE_DIRECT3D_9_LAYERS :
|
||||
@ -366,7 +350,7 @@ var dataProviders = {
|
||||
}
|
||||
|
||||
if (!gfxInfo) {
|
||||
completed();
|
||||
done(data);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -464,7 +448,7 @@ var dataProviders = {
|
||||
}
|
||||
}
|
||||
|
||||
completed();
|
||||
done(data);
|
||||
},
|
||||
|
||||
javaScript: function javaScript(done) {
|
||||
|
Loading…
Reference in New Issue
Block a user