merge mozilla-inbound to mozilla-central a=merge

This commit is contained in:
Carsten "Tomcat" Book 2015-09-25 14:39:34 +02:00
Родитель 36f030b0fa d9d5ae984a
Коммит e7d6f7ce2c
181 изменённых файлов: 2425 добавлений и 1415 удалений

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

@ -87,6 +87,9 @@ public:
*/
static void RemoteDocAdded(DocAccessibleParent* aDoc);
static const nsTArray<DocAccessibleParent*>* TopLevelRemoteDocs()
{ return sRemoteDocuments; }
#ifdef DEBUG
bool IsProcessingRefreshDriverNotification() const;
#endif

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

@ -123,6 +123,10 @@ public:
const ProxyAccessible* GetAccessible(uintptr_t aID) const
{ return const_cast<DocAccessibleParent*>(this)->GetAccessible(aID); }
size_t ChildDocCount() const { return mChildDocs.Length(); }
const DocAccessibleParent* ChildDocAt(size_t aIdx) const
{ return mChildDocs[aIdx]; }
private:
class ProxyEntry : public PLDHashEntryHdr

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

@ -1412,6 +1412,27 @@ GetAccessibleInSubtree(DocAccessible* aDoc, uint32_t aID)
}
#endif
static AccessibleWrap*
GetProxiedAccessibleInSubtree(const DocAccessibleParent* aDoc, uint32_t aID)
{
auto wrapper = static_cast<DocProxyAccessibleWrap*>(WrapperFor(aDoc));
AccessibleWrap* child = wrapper->GetAccessibleByID(aID);
if (child) {
return child;
}
size_t childDocs = aDoc->ChildDocCount();
for (size_t i = 0; i < childDocs; i++) {
const DocAccessibleParent* childDoc = aDoc->ChildDocAt(i);
child = GetProxiedAccessibleInSubtree(childDoc, aID);
if (child) {
return child;
}
}
return nullptr;
}
Accessible*
AccessibleWrap::GetXPAccessibleFor(const VARIANT& aVarChild)
{
@ -1422,33 +1443,32 @@ AccessibleWrap::GetXPAccessibleFor(const VARIANT& aVarChild)
if (aVarChild.lVal == CHILDID_SELF)
return this;
if (IsProxy()) {
if (Proxy()->MustPruneChildren())
return nullptr;
if (aVarChild.lVal > 0)
return WrapperFor(Proxy()->ChildAt(aVarChild.lVal - 1));
// XXX Don't implement negative child ids for now because annoying, and
// doesn't seem to be speced.
if (IsProxy() ? Proxy()->MustPruneChildren() : nsAccUtils::MustPrune(this)) {
return nullptr;
}
if (nsAccUtils::MustPrune(this))
return nullptr;
if (aVarChild.lVal > 0) {
// Gecko child indices are 0-based in contrast to indices used in MSAA.
if (IsProxy()) {
return WrapperFor(Proxy()->ChildAt(aVarChild.lVal - 1));
} else {
return GetChildAt(aVarChild.lVal - 1);
}
}
// If lVal negative then it is treated as child ID and we should look for
// accessible through whole accessible subtree including subdocuments.
// Otherwise we treat lVal as index in parent.
if (aVarChild.lVal < 0) {
// Convert child ID to unique ID.
// Convert child ID to unique ID.
// First handle the case that both this accessible and the id'd one are in
// this process.
if (!IsProxy()) {
void* uniqueID = reinterpret_cast<void*>(-aVarChild.lVal);
DocAccessible* document = Document();
Accessible* child =
#ifdef _WIN64
GetAccessibleInSubtree(document, static_cast<uint32_t>(aVarChild.lVal));
GetAccessibleInSubtree(document, static_cast<uint32_t>(aVarChild.lVal));
#else
document->GetAccessibleByUniqueIDInSubtree(uniqueID);
#endif
@ -1466,12 +1486,65 @@ AccessibleWrap::GetXPAccessibleFor(const VARIANT& aVarChild)
parent = parent->Parent();
}
}
// Now see about the case that both this accessible and the target one are
// proxied.
uint32_t id = aVarChild.lVal;
if (IsProxy()) {
DocAccessibleParent* proxyDoc = Proxy()->Document();
AccessibleWrap* wrapper = GetProxiedAccessibleInSubtree(proxyDoc, id);
MOZ_ASSERT(wrapper->IsProxy());
ProxyAccessible* parent = wrapper->Proxy();
while (parent && parent != proxyDoc) {
if (parent == this->Proxy()) {
return wrapper;
}
parent = parent->Parent();
}
return nullptr;
}
// Gecko child indices are 0-based in contrast to indices used in MSAA.
return GetChildAt(aVarChild.lVal - 1);
// Finally we need to handle the case that this accessible is in the main
// process, but the target is proxied. This is the case when the target
// accessible is in a child document of this one.
DocAccessibleParent* proxyDoc = nullptr;
DocAccessible* doc = Document();
const nsTArray<DocAccessibleParent*>* remoteDocs =
DocManager::TopLevelRemoteDocs();
if (!remoteDocs) {
return nullptr;
}
size_t docCount = remoteDocs->Length();
for (size_t i = 0; i < docCount; i++) {
Accessible* outerDoc = remoteDocs->ElementAt(i)->OuterDocOfRemoteBrowser();
if (!outerDoc) {
continue;
}
if (outerDoc->Document() != doc) {
continue;
}
Accessible* parent = outerDoc;
while (parent && parent != doc) {
if (parent == this) {
AccessibleWrap* proxyWrapper =
GetProxiedAccessibleInSubtree(remoteDocs->ElementAt(i), id);
if (proxyWrapper) {
return proxyWrapper;
}
}
parent = parent->Parent();
}
}
return nullptr;
}
void

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

@ -232,7 +232,7 @@ protected:
};
static inline AccessibleWrap*
WrapperFor(ProxyAccessible* aProxy)
WrapperFor(const ProxyAccessible* aProxy)
{
return reinterpret_cast<AccessibleWrap*>(aProxy->GetWrapper());
}

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

@ -12,7 +12,7 @@
#include "js/Debug.h"
#include "js/TypeDecls.h"
#include "js/UbiNodeCensus.h"
#include "js/UbiNodeTraverse.h"
#include "js/UbiNodeBreadthFirst.h"
#include "mozilla/Attributes.h"
#include "mozilla/devtools/AutoMemMap.h"
#include "mozilla/devtools/CoreDump.pb.h"

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

@ -24,6 +24,6 @@ UNIFIED_SOURCES = [
# THE MOCK_METHOD2 macro from gtest triggers this clang warning and it's hard
# to work around, so we just ignore it.
if CONFIG['CLANG_CXX']:
CXXFLAGS += ['-Wno-error=inconsistent-missing-override']
CXXFLAGS += ['-Wno-inconsistent-missing-override']
FINAL_LIBRARY = 'xul-gtest'

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

@ -1508,7 +1508,7 @@ nsDocShell::LoadURI(nsIURI* aURI,
}
if (!owner && !inheritOwner && !ownerIsExplicit) {
// See if there's system or chrome JS code running
inheritOwner = nsContentUtils::IsCallerChrome();
inheritOwner = nsContentUtils::LegacyIsCallerChromeOrNativeCode();
}
if (aLoadFlags & LOAD_FLAGS_DISALLOW_INHERIT_OWNER) {

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

@ -276,7 +276,7 @@ ScrollbarsProp::GetVisible(ErrorResult& aRv)
void
ScrollbarsProp::SetVisible(bool aVisible, ErrorResult& aRv)
{
if (!nsContentUtils::IsCallerChrome()) {
if (!nsContentUtils::LegacyIsCallerChromeOrNativeCode()) {
return;
}

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

@ -705,7 +705,7 @@ BlobImplBase::GetMozFullPath(nsAString& aFileName, ErrorResult& aRv) const
aFileName.Truncate();
if (NS_IsMainThread()) {
if (nsContentUtils::IsCallerChrome()) {
if (nsContentUtils::LegacyIsCallerChromeOrNativeCode()) {
GetMozFullPathInternal(aFileName, aRv);
}

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

@ -1955,9 +1955,6 @@ nsContentUtils::CheckSameOrigin(const nsINode* aTrustedNode,
{
MOZ_ASSERT(aTrustedNode);
MOZ_ASSERT(unTrustedNode);
if (IsCallerChrome()) {
return NS_OK;
}
/*
* Get hold of each node's principal
@ -2713,7 +2710,7 @@ nsContentUtils::SubjectPrincipal()
MOZ_ASSERT(NS_IsMainThread());
JSContext* cx = GetCurrentJSContext();
if (!cx) {
return GetSystemPrincipal();
MOZ_CRASH("Accessing the Subject Principal without an AutoJSAPI on the stack is forbidden");
}
JSCompartment *compartment = js::GetContextCompartment(cx);

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

@ -195,6 +195,47 @@ public:
static bool ThreadsafeIsCallerChrome();
static bool IsCallerContentXBL();
// In the traditional Gecko architecture, both C++ code and untrusted JS code
// needed to rely on the same XPCOM method/getter/setter to get work done.
// This required lots of security checks in the various exposed methods, which
// in turn created difficulty in determining whether the caller was script
// (whose access needed to be checked) and internal C++ platform code (whose
// access did not need to be checked). To address this problem, Gecko had a
// convention whereby the absence of script on the stack was interpretted as
// "System Caller" and always granted unfettered access.
//
// Unfortunately, this created a bunch of footguns. For example, when the
// implementation of a DOM method wanted to perform a privileged
// sub-operation, it needed to "hide" the presence of script on the stack in
// order for that sub-operation to be allowed. Additionally, if script could
// trigger an API entry point to be invoked in some asynchronous way without
// script on the stack, it could potentially perform privilege escalation.
//
// In the modern world, untrusted script should interact with the platform
// exclusively over WebIDL APIs, and platform code has a lot more flexibility
// in deciding whether or not to use XPCOM. This gives us the flexibility to
// do something better.
//
// Going forward, APIs should be designed such that any security checks that
// ask the question "is my caller allowed to do this?" should live in WebIDL
// API entry points, with a separate method provided for internal callers
// that just want to get the job done.
//
// To enforce this and catch bugs, nsContentUtils::SubjectPrincipal will crash
// if it is invoked without script on the stack. To land that transition, it
// was necessary to go through and whitelist a bunch of callers that were
// depending on the old behavior. Those callers should be fixed up, and these
// methods should not be used by new code without review from bholley or bz.
static bool LegacyIsCallerNativeCode() { return !GetCurrentJSContext(); }
static bool LegacyIsCallerChromeOrNativeCode() { return LegacyIsCallerNativeCode() || IsCallerChrome(); }
static nsIPrincipal* SubjectPrincipalOrSystemIfNativeCaller()
{
if (!GetCurrentJSContext()) {
return GetSystemPrincipal();
}
return SubjectPrincipal();
}
static bool IsImageSrcSetDisabled();
static bool LookupBindingMember(JSContext* aCx, nsIContent *aContent,

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

@ -410,7 +410,7 @@ nsDOMWindowUtils::SetDisplayPortMarginsForElement(float aLeftMargin,
nsIDOMElement* aElement,
uint32_t aPriority)
{
MOZ_RELEASE_ASSERT(nsContentUtils::IsCallerChrome());
MOZ_RELEASE_ASSERT(nsContentUtils::LegacyIsCallerChromeOrNativeCode());
nsIPresShell* presShell = GetPresShell();
if (!presShell) {
@ -481,7 +481,7 @@ nsDOMWindowUtils::SetDisplayPortBaseForElement(int32_t aX,
NS_IMETHODIMP
nsDOMWindowUtils::SetResolution(float aResolution)
{
if (!nsContentUtils::IsCallerChrome()) {
if (!nsContentUtils::LegacyIsCallerChromeOrNativeCode()) {
return NS_ERROR_DOM_SECURITY_ERR;
}
@ -547,7 +547,7 @@ nsDOMWindowUtils::GetIsResolutionSet(bool* aIsResolutionSet) {
NS_IMETHODIMP
nsDOMWindowUtils::SetIsFirstPaint(bool aIsFirstPaint)
{
if (!nsContentUtils::IsCallerChrome()) {
if (!nsContentUtils::LegacyIsCallerChromeOrNativeCode()) {
return NS_ERROR_DOM_SECURITY_ERR;
}
@ -562,7 +562,7 @@ nsDOMWindowUtils::SetIsFirstPaint(bool aIsFirstPaint)
NS_IMETHODIMP
nsDOMWindowUtils::GetIsFirstPaint(bool *aIsFirstPaint)
{
if (!nsContentUtils::IsCallerChrome()) {
if (!nsContentUtils::LegacyIsCallerChromeOrNativeCode()) {
return NS_ERROR_DOM_SECURITY_ERR;
}
@ -577,7 +577,7 @@ nsDOMWindowUtils::GetIsFirstPaint(bool *aIsFirstPaint)
NS_IMETHODIMP
nsDOMWindowUtils::GetPresShellId(uint32_t *aPresShellId)
{
MOZ_RELEASE_ASSERT(nsContentUtils::IsCallerChrome());
MOZ_RELEASE_ASSERT(nsContentUtils::LegacyIsCallerChromeOrNativeCode());
nsIPresShell* presShell = GetPresShell();
if (presShell) {
@ -1036,7 +1036,7 @@ nsDOMWindowUtils::SendNativeKeyEvent(int32_t aNativeKeyboardLayout,
const nsAString& aUnmodifiedCharacters,
nsIObserver* aObserver)
{
MOZ_RELEASE_ASSERT(nsContentUtils::IsCallerChrome());
MOZ_RELEASE_ASSERT(nsContentUtils::LegacyIsCallerChromeOrNativeCode());
// get the widget to send the event to
nsCOMPtr<nsIWidget> widget = GetWidget();
@ -1722,7 +1722,9 @@ nsDOMWindowUtils::GetBoundsWithoutFlushing(nsIDOMElement *aElement,
NS_IMETHODIMP
nsDOMWindowUtils::GetRootBounds(nsIDOMClientRect** aResult)
{
MOZ_RELEASE_ASSERT(nsContentUtils::IsCallerChrome());
// Unfortunately, this is called from AndroidBridge.cpp and the logic here is
// nontrivial, so we need to allow non-scripted callers.
MOZ_RELEASE_ASSERT(nsContentUtils::LegacyIsCallerChromeOrNativeCode());
nsIDocument* doc = GetDocument();
NS_ENSURE_STATE(doc);
@ -3150,7 +3152,7 @@ nsDOMWindowUtils::GetPlugins(JSContext* cx, JS::MutableHandle<JS::Value> aPlugin
NS_IMETHODIMP
nsDOMWindowUtils::SetScrollPositionClampingScrollPortSize(float aWidth, float aHeight)
{
MOZ_RELEASE_ASSERT(nsContentUtils::IsCallerChrome());
MOZ_RELEASE_ASSERT(nsContentUtils::LegacyIsCallerChromeOrNativeCode());
if (!(aWidth >= 0.0 && aHeight >= 0.0)) {
return NS_ERROR_ILLEGAL_VALUE;

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

@ -1221,7 +1221,7 @@ nsFocusManager::SetFocusInner(nsIContent* aNewContent, int32_t aFlags,
}
bool subsumes = false;
focusedPrincipal->Subsumes(newPrincipal, &subsumes);
if (!subsumes && !nsContentUtils::IsCallerChrome()) {
if (!subsumes && !nsContentUtils::LegacyIsCallerChromeOrNativeCode()) {
NS_WARNING("Not allowed to focus the new window!");
return;
}
@ -1275,7 +1275,7 @@ nsFocusManager::SetFocusInner(nsIContent* aNewContent, int32_t aFlags,
// * isn't called by trusted event (i.e., called by untrusted event or by js)
// * the focus is moved to another document's element
// we need to check the permission.
if (sendFocusEvent && mFocusedContent &&
if (sendFocusEvent && mFocusedContent && !nsContentUtils::LegacyIsCallerNativeCode() &&
mFocusedContent->OwnerDoc() != aNewContent->OwnerDoc()) {
// If the caller cannot access the current focused node, the caller should
// not be able to steal focus from it. E.g., When the current focused node
@ -1453,8 +1453,10 @@ nsFocusManager::AdjustWindowFocus(nsPIDOMWindow* aWindow,
// When aCheckPermission is true, we should check whether the caller can
// access the window or not. If it cannot access, we should stop the
// adjusting.
if (aCheckPermission && !nsContentUtils::CanCallerAccess(window))
if (aCheckPermission && !nsContentUtils::LegacyIsCallerNativeCode() &&
!nsContentUtils::CanCallerAccess(window)) {
break;
}
window->SetFocusedNode(frameElement);
}

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

@ -2085,7 +2085,7 @@ nsGlobalWindow::SetInitialPrincipalToSubject()
MOZ_ASSERT(IsOuterWindow());
// First, grab the subject principal.
nsCOMPtr<nsIPrincipal> newWindowPrincipal = nsContentUtils::SubjectPrincipal();
nsCOMPtr<nsIPrincipal> newWindowPrincipal = nsContentUtils::SubjectPrincipalOrSystemIfNativeCaller();
// Now, if we're about to use the system principal or an nsExpandedPrincipal,
// make sure we're not using it for a content docshell.
@ -4549,7 +4549,7 @@ nsGlobalWindow::GetOpenerWindowOuter()
nsGlobalWindow* win = static_cast<nsGlobalWindow*>(opener.get());
// First, check if we were called from a privileged chrome script
if (nsContentUtils::IsCallerChrome()) {
if (nsContentUtils::LegacyIsCallerChromeOrNativeCode()) {
// Catch the case where we're chrome but the opener is not...
if (GetPrincipal() == nsContentUtils::GetSystemPrincipal() &&
win->GetPrincipal() != nsContentUtils::GetSystemPrincipal()) {
@ -6513,7 +6513,7 @@ nsGlobalWindow::SetFullscreenInternal(FullscreenReason aReason,
// Only chrome can change our fullscreen mode. Otherwise, the state
// can only be changed for DOM fullscreen.
if (aReason == eForFullscreenMode && !nsContentUtils::IsCallerChrome()) {
if (aReason == eForFullscreenMode && !nsContentUtils::LegacyIsCallerChromeOrNativeCode()) {
return NS_OK;
}
@ -8249,7 +8249,7 @@ bool
nsGlobalWindow::CanSetProperty(const char *aPrefName)
{
// Chrome can set any property.
if (nsContentUtils::IsCallerChrome()) {
if (nsContentUtils::LegacyIsCallerChromeOrNativeCode()) {
return true;
}
@ -10054,6 +10054,7 @@ nsGlobalWindow::AddSystemEventListener(const nsAString& aType,
"explicit by making optional_argc non-zero.");
if (IsOuterWindow() && mInnerWindow &&
!nsContentUtils::LegacyIsCallerNativeCode() &&
!nsContentUtils::CanCallerAccess(mInnerWindow)) {
return NS_ERROR_DOM_SECURITY_ERR;
}
@ -12181,7 +12182,7 @@ nsGlobalWindow::OpenInternal(const nsAString& aUrl, const nsAString& aName,
nsIPrincipal::APP_STATUS_INSTALLED;
}
const bool checkForPopup = !nsContentUtils::IsCallerChrome() &&
const bool checkForPopup = !nsContentUtils::LegacyIsCallerChromeOrNativeCode() &&
!isApp && !aDialog && !WindowExists(aName, !aCalledNoScript);
// Note: it's very important that this be an nsXPIDLCString, since we want

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

@ -1156,7 +1156,7 @@ nsObjectLoadingContent::OnStopRequest(nsIRequest *aRequest,
}
}
NS_ENSURE_TRUE(nsContentUtils::IsCallerChrome(), NS_ERROR_NOT_AVAILABLE);
NS_ENSURE_TRUE(nsContentUtils::LegacyIsCallerChromeOrNativeCode(), NS_ERROR_NOT_AVAILABLE);
if (aRequest != mChannel) {
return NS_BINDING_ABORTED;
@ -1183,7 +1183,7 @@ nsObjectLoadingContent::OnDataAvailable(nsIRequest *aRequest,
nsIInputStream *aInputStream,
uint64_t aOffset, uint32_t aCount)
{
NS_ENSURE_TRUE(nsContentUtils::IsCallerChrome(), NS_ERROR_NOT_AVAILABLE);
NS_ENSURE_TRUE(nsContentUtils::LegacyIsCallerChromeOrNativeCode(), NS_ERROR_NOT_AVAILABLE);
if (aRequest != mChannel) {
return NS_BINDING_ABORTED;
@ -2825,7 +2825,8 @@ nsObjectLoadingContent::ScriptRequestPluginInstance(JSContext* aCx,
// so the ensuing expression is short-circuited.
MOZ_ASSERT_IF(nsContentUtils::GetCurrentJSContext(),
aCx == nsContentUtils::GetCurrentJSContext());
bool callerIsContentJS = (!nsContentUtils::IsCallerChrome() &&
bool callerIsContentJS = (nsContentUtils::GetCurrentJSContext() &&
!nsContentUtils::IsCallerChrome() &&
!nsContentUtils::IsCallerContentXBL() &&
JS_IsRunning(aCx));

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

@ -1138,7 +1138,8 @@ nsRange::IsValidBoundary(nsINode* aNode)
void
nsRange::SetStart(nsINode& aNode, uint32_t aOffset, ErrorResult& aRv)
{
if (!nsContentUtils::CanCallerAccess(&aNode)) {
if (!nsContentUtils::LegacyIsCallerNativeCode() &&
!nsContentUtils::CanCallerAccess(&aNode)) {
aRv.Throw(NS_ERROR_DOM_SECURITY_ERR);
return;
}
@ -1190,7 +1191,8 @@ nsRange::SetStart(nsINode* aParent, int32_t aOffset)
void
nsRange::SetStartBefore(nsINode& aNode, ErrorResult& aRv)
{
if (!nsContentUtils::CanCallerAccess(&aNode)) {
if (!nsContentUtils::LegacyIsCallerNativeCode() &&
!nsContentUtils::CanCallerAccess(&aNode)) {
aRv.Throw(NS_ERROR_DOM_SECURITY_ERR);
return;
}
@ -1215,7 +1217,8 @@ nsRange::SetStartBefore(nsIDOMNode* aSibling)
void
nsRange::SetStartAfter(nsINode& aNode, ErrorResult& aRv)
{
if (!nsContentUtils::CanCallerAccess(&aNode)) {
if (!nsContentUtils::LegacyIsCallerNativeCode() &&
!nsContentUtils::CanCallerAccess(&aNode)) {
aRv.Throw(NS_ERROR_DOM_SECURITY_ERR);
return;
}
@ -1240,7 +1243,8 @@ nsRange::SetStartAfter(nsIDOMNode* aSibling)
void
nsRange::SetEnd(nsINode& aNode, uint32_t aOffset, ErrorResult& aRv)
{
if (!nsContentUtils::CanCallerAccess(&aNode)) {
if (!nsContentUtils::LegacyIsCallerNativeCode() &&
!nsContentUtils::CanCallerAccess(&aNode)) {
aRv.Throw(NS_ERROR_DOM_SECURITY_ERR);
return;
}
@ -1291,7 +1295,8 @@ nsRange::SetEnd(nsINode* aParent, int32_t aOffset)
void
nsRange::SetEndBefore(nsINode& aNode, ErrorResult& aRv)
{
if (!nsContentUtils::CanCallerAccess(&aNode)) {
if (!nsContentUtils::LegacyIsCallerNativeCode() &&
!nsContentUtils::CanCallerAccess(&aNode)) {
aRv.Throw(NS_ERROR_DOM_SECURITY_ERR);
return;
}
@ -1316,7 +1321,8 @@ nsRange::SetEndBefore(nsIDOMNode* aSibling)
void
nsRange::SetEndAfter(nsINode& aNode, ErrorResult& aRv)
{
if (!nsContentUtils::CanCallerAccess(&aNode)) {
if (!nsContentUtils::LegacyIsCallerNativeCode() &&
!nsContentUtils::CanCallerAccess(&aNode)) {
aRv.Throw(NS_ERROR_DOM_SECURITY_ERR);
return;
}
@ -1367,7 +1373,8 @@ nsRange::SelectNode(nsIDOMNode* aN)
void
nsRange::SelectNode(nsINode& aNode, ErrorResult& aRv)
{
if (!nsContentUtils::CanCallerAccess(&aNode)) {
if (!nsContentUtils::LegacyIsCallerNativeCode() &&
!nsContentUtils::CanCallerAccess(&aNode)) {
aRv.Throw(NS_ERROR_DOM_SECURITY_ERR);
return;
}
@ -1403,7 +1410,8 @@ nsRange::SelectNodeContents(nsIDOMNode* aN)
void
nsRange::SelectNodeContents(nsINode& aNode, ErrorResult& aRv)
{
if (!nsContentUtils::CanCallerAccess(&aNode)) {
if (!nsContentUtils::LegacyIsCallerNativeCode() &&
!nsContentUtils::CanCallerAccess(&aNode)) {
aRv.Throw(NS_ERROR_DOM_SECURITY_ERR);
return;
}
@ -2451,7 +2459,8 @@ nsRange::InsertNode(nsIDOMNode* aNode)
void
nsRange::InsertNode(nsINode& aNode, ErrorResult& aRv)
{
if (!nsContentUtils::CanCallerAccess(&aNode)) {
if (!nsContentUtils::LegacyIsCallerNativeCode() &&
!nsContentUtils::CanCallerAccess(&aNode)) {
aRv.Throw(NS_ERROR_DOM_SECURITY_ERR);
return;
}
@ -2548,7 +2557,8 @@ nsRange::SurroundContents(nsIDOMNode* aNewParent)
void
nsRange::SurroundContents(nsINode& aNewParent, ErrorResult& aRv)
{
if (!nsContentUtils::CanCallerAccess(&aNewParent)) {
if (!nsContentUtils::LegacyIsCallerNativeCode() &&
!nsContentUtils::CanCallerAccess(&aNewParent)) {
aRv.Throw(NS_ERROR_DOM_SECURITY_ERR);
return;
}

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

@ -2700,8 +2700,7 @@ nsXMLHttpRequest::Send(nsIVariant* aVariant, const Nullable<RequestBody>& aBody)
nsAutoCString contentType;
if (NS_FAILED(httpChannel->
GetRequestHeader(NS_LITERAL_CSTRING("Content-Type"),
contentType)) ||
contentType.IsEmpty()) {
contentType))) {
contentType = defaultContentType;
if (!charset.IsEmpty()) {

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

@ -67,7 +67,7 @@ CallbackObject::CallSetup::CallSetup(CallbackObject* aCallback,
// do anything that might perturb the relevant state.
nsIPrincipal* webIDLCallerPrincipal = nullptr;
if (aIsJSImplementedWebIDL) {
webIDLCallerPrincipal = nsContentUtils::SubjectPrincipal();
webIDLCallerPrincipal = nsContentUtils::SubjectPrincipalOrSystemIfNativeCaller();
}
// We need to produce a useful JSContext here. Ideally one that the callback

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

@ -137,7 +137,7 @@ CameraPreviewMediaStream::RateLimit(bool aLimit)
}
void
CameraPreviewMediaStream::SetCurrentFrame(const gfxIntSize& aIntrinsicSize, Image* aImage)
CameraPreviewMediaStream::SetCurrentFrame(const gfx::IntSize& aIntrinsicSize, Image* aImage)
{
{
MutexAutoLock lock(mMutex);

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

@ -58,7 +58,7 @@ public:
void Invalidate();
// Call these on any thread.
void SetCurrentFrame(const gfxIntSize& aIntrinsicSize, Image* aImage);
void SetCurrentFrame(const gfx::IntSize& aIntrinsicSize, Image* aImage);
void ClearCurrentFrame();
void RateLimit(bool aLimit);

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

@ -311,7 +311,7 @@ DOMCameraControlListener::OnNewPreviewFrame(layers::Image* aImage, uint32_t aWid
{
DOM_CAMERA_LOGI("OnNewPreviewFrame: got %d x %d frame\n", aWidth, aHeight);
mStream->SetCurrentFrame(gfxIntSize(aWidth, aHeight), aImage);
mStream->SetCurrentFrame(gfx::IntSize(aWidth, aHeight), aImage);
return true;
}

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

@ -53,7 +53,7 @@ struct ImageCacheEntryData {
// Value
nsCOMPtr<imgIRequest> mRequest;
RefPtr<SourceSurface> mSourceSurface;
gfxIntSize mSize;
IntSize mSize;
nsExpirationState mState;
};
@ -237,7 +237,7 @@ CanvasImageCache::NotifyDrawImage(Element* aImage,
HTMLCanvasElement* aCanvas,
imgIRequest* aRequest,
SourceSurface* aSource,
const gfxIntSize& aSize)
const IntSize& aSize)
{
if (!gImageCache) {
gImageCache = new ImageCache();

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

@ -33,7 +33,7 @@ public:
dom::HTMLCanvasElement* aCanvas,
imgIRequest* aRequest,
SourceSurface* aSource,
const gfxIntSize& aSize);
const gfx::IntSize& aSize);
/**
* Check whether aImage has recently been drawn into aCanvas. If we return

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

@ -4787,7 +4787,7 @@ CanvasRenderingContext2D::DrawWindow(nsGlobalWindow& window, double x,
{
// protect against too-large surfaces that will cause allocation
// or overflow issues
if (!gfxASurface::CheckSurfaceSize(gfxIntSize(int32_t(w), int32_t(h)),
if (!gfxASurface::CheckSurfaceSize(gfx::IntSize(int32_t(w), int32_t(h)),
0xffff)) {
error.Throw(NS_ERROR_FAILURE);
return;
@ -4976,7 +4976,7 @@ CanvasRenderingContext2D::AsyncDrawXULElement(nsXULElement& elem,
// protect against too-large surfaces that will cause allocation
// or overflow issues
if (!gfxASurface::CheckSurfaceSize(gfxIntSize(w, h), 0xffff)) {
if (!gfxASurface::CheckSurfaceSize(gfx::IntSize(w, h), 0xffff)) {
error.Throw(NS_ERROR_FAILURE);
return;
}
@ -5401,7 +5401,7 @@ CanvasRenderingContext2D::PutImageData_explicit(int32_t x, int32_t y, uint32_t w
uint32_t copyWidth = dirtyRect.Width();
uint32_t copyHeight = dirtyRect.Height();
nsRefPtr<gfxImageSurface> imgsurf = new gfxImageSurface(gfxIntSize(copyWidth, copyHeight),
nsRefPtr<gfxImageSurface> imgsurf = new gfxImageSurface(gfx::IntSize(copyWidth, copyHeight),
gfxImageFormat::ARGB32,
false);
if (!imgsurf || imgsurf->CairoStatus()) {

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

@ -217,6 +217,7 @@ WebGLContext::WebGLContext()
, mBypassShaderValidation(false)
, mGLMaxSamples(1)
, mNeedsFakeNoAlpha(false)
, mNeedsFakeNoDepth(false)
, mNeedsFakeNoStencil(false)
{
mGeneration = 0;
@ -253,6 +254,7 @@ WebGLContext::WebGLContext()
mDitherEnabled = 1;
mRasterizerDiscardEnabled = 0; // OpenGL ES 3.0 spec p244
mScissorTestEnabled = 0;
mDepthTestEnabled = 0;
mStencilTestEnabled = 0;
// initialize some GL values: we're going to get them from the GL and use them as the sizes of arrays,
@ -543,107 +545,9 @@ HasAcceleratedLayers(const nsCOMPtr<nsIGfxInfo>& gfxInfo)
return false;
}
static already_AddRefed<GLContext>
CreateHeadlessNativeGL(CreateContextFlags flags, const nsCOMPtr<nsIGfxInfo>& gfxInfo,
WebGLContext* webgl)
{
if (!(flags & CreateContextFlags::FORCE_ENABLE_HARDWARE) &&
IsFeatureInBlacklist(gfxInfo, nsIGfxInfo::FEATURE_WEBGL_OPENGL))
{
webgl->GenerateWarning("Refused to create native OpenGL context"
" because of blacklisting.");
return nullptr;
}
nsRefPtr<GLContext> gl = gl::GLContextProvider::CreateHeadless(flags);
if (!gl) {
webgl->GenerateWarning("Error during native OpenGL init.");
return nullptr;
}
MOZ_ASSERT(!gl->IsANGLE());
return gl.forget();
}
// Note that we have a separate call for ANGLE and EGL, even though
// right now, we get ANGLE implicitly by using EGL on Windows.
// Eventually, we want to be able to pick ANGLE-EGL or native EGL.
static already_AddRefed<GLContext>
CreateHeadlessANGLE(CreateContextFlags flags, const nsCOMPtr<nsIGfxInfo>& gfxInfo,
WebGLContext* webgl)
{
nsRefPtr<GLContext> gl;
#ifdef XP_WIN
gl = gl::GLContextProviderEGL::CreateHeadless(flags);
if (!gl) {
webgl->GenerateWarning("Error during ANGLE OpenGL init.");
return nullptr;
}
MOZ_ASSERT(gl->IsANGLE());
#endif
return gl.forget();
}
static already_AddRefed<GLContext>
CreateHeadlessEGL(CreateContextFlags flags, WebGLContext* webgl)
{
nsRefPtr<GLContext> gl;
#ifdef ANDROID
gl = gl::GLContextProviderEGL::CreateHeadless(flags);
if (!gl) {
webgl->GenerateWarning("Error during EGL OpenGL init.");
return nullptr;
}
MOZ_ASSERT(!gl->IsANGLE());
#endif
return gl.forget();
}
static already_AddRefed<GLContext>
CreateHeadlessGL(CreateContextFlags flags, const nsCOMPtr<nsIGfxInfo>& gfxInfo,
WebGLContext* webgl)
{
bool preferEGL = PR_GetEnv("MOZ_WEBGL_PREFER_EGL");
bool disableANGLE = Preferences::GetBool("webgl.disable-angle", false);
if (PR_GetEnv("MOZ_WEBGL_FORCE_OPENGL"))
disableANGLE = true;
if (!webgl->IsWebGL2()) {
flags |= CreateContextFlags::REQUIRE_COMPAT_PROFILE;
}
nsRefPtr<GLContext> gl;
if (preferEGL)
gl = CreateHeadlessEGL(flags, webgl);
if (!gl && !disableANGLE) {
gl = CreateHeadlessANGLE(flags, gfxInfo, webgl);
}
if (!gl) {
gl = CreateHeadlessNativeGL(flags, gfxInfo, webgl);
}
return gl.forget();
}
// Try to create a dummy offscreen with the given caps.
static bool
CreateOffscreenWithCaps(GLContext* gl, const SurfaceCaps& caps)
{
gfx::IntSize dummySize(16, 16);
return gl->InitOffscreen(dummySize, caps);
}
static void
PopulateCapFallbackQueue(const SurfaceCaps& baseCaps,
std::queue<SurfaceCaps>* out_fallbackCaps)
PopulateCapFallbackQueue(const gl::SurfaceCaps& baseCaps,
std::queue<gl::SurfaceCaps>* out_fallbackCaps)
{
out_fallbackCaps->push(baseCaps);
@ -651,7 +555,7 @@ PopulateCapFallbackQueue(const SurfaceCaps& baseCaps,
// The user basically doesn't have to handle if this fails, they
// just get reduced quality.
if (baseCaps.antialias) {
SurfaceCaps nextCaps(baseCaps);
gl::SurfaceCaps nextCaps(baseCaps);
nextCaps.antialias = false;
PopulateCapFallbackQueue(nextCaps, out_fallbackCaps);
}
@ -660,25 +564,22 @@ PopulateCapFallbackQueue(const SurfaceCaps& baseCaps,
// depth. However, the client app will need to handle if this
// doesn't work.
if (baseCaps.stencil) {
SurfaceCaps nextCaps(baseCaps);
gl::SurfaceCaps nextCaps(baseCaps);
nextCaps.stencil = false;
PopulateCapFallbackQueue(nextCaps, out_fallbackCaps);
}
if (baseCaps.depth) {
SurfaceCaps nextCaps(baseCaps);
gl::SurfaceCaps nextCaps(baseCaps);
nextCaps.depth = false;
PopulateCapFallbackQueue(nextCaps, out_fallbackCaps);
}
}
static bool
CreateOffscreen(GLContext* gl, const WebGLContextOptions& options,
const nsCOMPtr<nsIGfxInfo>& gfxInfo, WebGLContext* webgl,
layers::LayersBackend layersBackend,
layers::ISurfaceAllocator* surfAllocator)
static gl::SurfaceCaps
BaseCaps(const WebGLContextOptions& options, WebGLContext* webgl)
{
SurfaceCaps baseCaps;
gl::SurfaceCaps baseCaps;
baseCaps.color = true;
baseCaps.alpha = options.alpha;
@ -691,29 +592,36 @@ CreateOffscreen(GLContext* gl, const WebGLContextOptions& options,
if (!baseCaps.alpha)
baseCaps.premultAlpha = true;
if (gl->IsANGLE() ||
(gl->GetContextType() == GLContextType::GLX &&
layersBackend == LayersBackend::LAYERS_OPENGL))
{
// We can't use no-alpha formats on ANGLE yet because of:
// https://code.google.com/p/angleproject/issues/detail?id=764
// GLX only supports GL_RGBA pixmaps as well. Since we can't blit from
// an RGB FB to GLX's RGBA FB, force RGBA when surface sharing.
baseCaps.alpha = true;
}
// we should really have this behind a
// |gfxPlatform::GetPlatform()->GetScreenDepth() == 16| check, but
// for now it's just behind a pref for testing/evaluation.
baseCaps.bpp16 = Preferences::GetBool("webgl.prefer-16bpp", false);
#ifdef MOZ_WIDGET_GONK
baseCaps.surfaceAllocator = surfAllocator;
do {
auto canvasElement = webgl->GetCanvas();
auto ownerDoc = canvasElement->OwnerDoc();
nsIWidget* docWidget = nsContentUtils::WidgetForDocument(ownerDoc);
if (!docWidget)
break;
layers::LayerManager* layerManager = docWidget->GetLayerManager();
if (!layerManager)
break;
// XXX we really want "AsSurfaceAllocator" here for generality
layers::ShadowLayerForwarder* forwarder = layerManager->AsShadowForwarder();
if (!forwarder)
break;
baseCaps.surfaceAllocator = static_cast<layers::ISurfaceAllocator*>(forwarder);
} while (false);
#endif
// Done with baseCaps construction.
bool forceAllowAA = Preferences::GetBool("webgl.msaa-force", false);
nsCOMPtr<nsIGfxInfo> gfxInfo = services::GetGfxInfo();
if (!forceAllowAA &&
IsFeatureInBlacklist(gfxInfo, nsIGfxInfo::FEATURE_WEBGL_MSAA))
{
@ -722,62 +630,149 @@ CreateOffscreen(GLContext* gl, const WebGLContextOptions& options,
baseCaps.antialias = false;
}
std::queue<SurfaceCaps> fallbackCaps;
return baseCaps;
}
////////////////////////////////////////
static already_AddRefed<gl::GLContext>
CreateGLWithEGL(const gl::SurfaceCaps& caps, gl::CreateContextFlags flags,
WebGLContext* webgl)
{
RefPtr<GLContext> gl;
#ifndef XP_MACOSX // Mac doesn't have GLContextProviderEGL.
gfx::IntSize dummySize(16, 16);
gl = gl::GLContextProviderEGL::CreateOffscreen(dummySize, caps,
flags);
if (!gl) {
webgl->GenerateWarning("Error during EGL OpenGL init.");
return nullptr;
}
if (gl->IsANGLE())
return nullptr;
#endif // XP_MACOSX
return gl.forget();
}
static already_AddRefed<GLContext>
CreateGLWithANGLE(const gl::SurfaceCaps& caps, gl::CreateContextFlags flags,
WebGLContext* webgl)
{
RefPtr<GLContext> gl;
#ifdef XP_WIN
gfx::IntSize dummySize(16, 16);
gl = gl::GLContextProviderEGL::CreateOffscreen(dummySize, caps, flags);
if (!gl) {
webgl->GenerateWarning("Error during ANGLE OpenGL init.");
return nullptr;
}
if (!gl->IsANGLE())
return nullptr;
#endif
return gl.forget();
}
static already_AddRefed<gl::GLContext>
CreateGLWithDefault(const gl::SurfaceCaps& caps, gl::CreateContextFlags flags,
WebGLContext* webgl)
{
nsCOMPtr<nsIGfxInfo> gfxInfo = services::GetGfxInfo();
if (!(flags & CreateContextFlags::FORCE_ENABLE_HARDWARE) &&
IsFeatureInBlacklist(gfxInfo, nsIGfxInfo::FEATURE_WEBGL_OPENGL))
{
webgl->GenerateWarning("Refused to create native OpenGL context because of"
" blacklisting.");
return nullptr;
}
gfx::IntSize dummySize(16, 16);
RefPtr<GLContext> gl = gl::GLContextProvider::CreateOffscreen(dummySize, caps, flags);
if (!gl) {
webgl->GenerateWarning("Error during native OpenGL init.");
return nullptr;
}
if (gl->IsANGLE())
return nullptr;
return gl.forget();
}
////////////////////////////////////////
bool
WebGLContext::CreateAndInitGLWith(FnCreateGL_T fnCreateGL,
const gl::SurfaceCaps& baseCaps,
gl::CreateContextFlags flags)
{
MOZ_ASSERT(!gl);
std::queue<gl::SurfaceCaps> fallbackCaps;
PopulateCapFallbackQueue(baseCaps, &fallbackCaps);
bool created = false;
gl = nullptr;
while (!fallbackCaps.empty()) {
SurfaceCaps& caps = fallbackCaps.front();
gl::SurfaceCaps& caps = fallbackCaps.front();
created = CreateOffscreenWithCaps(gl, caps);
if (created)
gl = fnCreateGL(caps, flags, this);
if (gl)
break;
fallbackCaps.pop();
}
if (!gl)
return false;
return created;
if (!InitAndValidateGL()) {
gl = nullptr;
return false;
}
return true;
}
bool
WebGLContext::CreateOffscreenGL(bool forceEnabled)
WebGLContext::CreateAndInitGL(bool forceEnabled)
{
nsCOMPtr<nsIGfxInfo> gfxInfo = services::GetGfxInfo();
bool preferEGL = PR_GetEnv("MOZ_WEBGL_PREFER_EGL");
bool disableANGLE = Preferences::GetBool("webgl.disable-angle", false);
layers::ISurfaceAllocator* surfAllocator = nullptr;
#ifdef MOZ_WIDGET_GONK
nsIWidget* docWidget = nsContentUtils::WidgetForDocument(mCanvasElement->OwnerDoc());
if (docWidget) {
layers::LayerManager* layerManager = docWidget->GetLayerManager();
if (layerManager) {
// XXX we really want "AsSurfaceAllocator" here for generality
layers::ShadowLayerForwarder* forwarder = layerManager->AsShadowForwarder();
if (forwarder)
surfAllocator = static_cast<layers::ISurfaceAllocator*>(forwarder);
}
if (PR_GetEnv("MOZ_WEBGL_FORCE_OPENGL"))
disableANGLE = true;
gl::CreateContextFlags flags = gl::CreateContextFlags::NONE;
if (forceEnabled) flags |= gl::CreateContextFlags::FORCE_ENABLE_HARDWARE;
if (!IsWebGL2()) flags |= gl::CreateContextFlags::REQUIRE_COMPAT_PROFILE;
const gl::SurfaceCaps baseCaps = BaseCaps(mOptions, this);
MOZ_ASSERT(!gl);
if (preferEGL) {
if (CreateAndInitGLWith(CreateGLWithEGL, baseCaps, flags))
return true;
}
#endif
CreateContextFlags flags = forceEnabled ? CreateContextFlags::FORCE_ENABLE_HARDWARE :
CreateContextFlags::NONE;
MOZ_ASSERT(!gl);
gl = CreateHeadlessGL(flags, gfxInfo, this);
if (!disableANGLE) {
if (CreateAndInitGLWith(CreateGLWithANGLE, baseCaps, flags))
return true;
}
do {
if (!gl)
break;
if (!CreateOffscreen(gl, mOptions, gfxInfo, this,
GetCompositorBackendType(), surfAllocator))
break;
if (!InitAndValidateGL())
break;
MOZ_ASSERT(!gl);
if (CreateAndInitGLWith(CreateGLWithDefault, baseCaps, flags))
return true;
} while (false);
MOZ_ASSERT(!gl);
gl = nullptr;
return false;
}
@ -941,12 +936,15 @@ WebGLContext::SetDimensions(int32_t signedWidth, int32_t signedHeight)
bool forceEnabled = Preferences::GetBool("webgl.force-enabled", false);
ScopedGfxFeatureReporter reporter("WebGL", forceEnabled);
if (!CreateOffscreenGL(forceEnabled)) {
MOZ_ASSERT(!gl);
if (!CreateAndInitGL(forceEnabled)) {
GenerateWarning("WebGL creation failed.");
return NS_ERROR_FAILURE;
}
MOZ_ASSERT(gl);
MOZ_ASSERT_IF(mOptions.alpha, gl->Caps().alpha);
if (!ResizeBackbuffer(width, height)) {
GenerateWarning("Initializing WebGL backbuffer failed.");
return NS_ERROR_FAILURE;
@ -965,14 +963,20 @@ WebGLContext::SetDimensions(int32_t signedWidth, int32_t signedHeight)
if (!mOptions.alpha && gl->Caps().alpha)
mNeedsFakeNoAlpha = true;
// ANGLE doesn't quite handle this properly.
if (gl->Caps().depth && !gl->Caps().stencil && gl->IsANGLE())
if (!mOptions.depth && gl->Caps().depth)
mNeedsFakeNoDepth = true;
if (!mOptions.stencil && gl->Caps().stencil)
mNeedsFakeNoStencil = true;
}
// Update mOptions.
mOptions.depth = gl->Caps().depth;
mOptions.stencil = gl->Caps().stencil;
if (!gl->Caps().depth)
mOptions.depth = false;
if (!gl->Caps().stencil)
mOptions.stencil = false;
mOptions.antialias = gl->Caps().antialias;
MakeContextCurrent();
@ -998,10 +1002,16 @@ WebGLContext::SetDimensions(int32_t signedWidth, int32_t signedHeight)
mShouldPresent = true;
MOZ_ASSERT(gl->Caps().color);
MOZ_ASSERT_IF(!mNeedsFakeNoAlpha, gl->Caps().alpha == mOptions.alpha);
MOZ_ASSERT_IF(mNeedsFakeNoAlpha, !mOptions.alpha && gl->Caps().alpha);
MOZ_ASSERT(gl->Caps().depth == mOptions.depth);
MOZ_ASSERT(gl->Caps().stencil == mOptions.stencil);
MOZ_ASSERT_IF(!mNeedsFakeNoDepth, gl->Caps().depth == mOptions.depth);
MOZ_ASSERT_IF(mNeedsFakeNoDepth, !mOptions.depth && gl->Caps().depth);
MOZ_ASSERT_IF(!mNeedsFakeNoStencil, gl->Caps().stencil == mOptions.stencil);
MOZ_ASSERT_IF(mNeedsFakeNoStencil, !mOptions.stencil && gl->Caps().stencil);
MOZ_ASSERT(gl->Caps().antialias == mOptions.antialias);
MOZ_ASSERT(gl->Caps().preserve == mOptions.preserveDrawingBuffer);
@ -1876,6 +1886,7 @@ RoundedToNextMultipleOf(CheckedUint32 x, CheckedUint32 y)
WebGLContext::ScopedMaskWorkaround::ScopedMaskWorkaround(WebGLContext& webgl)
: mWebGL(webgl)
, mFakeNoAlpha(ShouldFakeNoAlpha(webgl))
, mFakeNoDepth(ShouldFakeNoDepth(webgl))
, mFakeNoStencil(ShouldFakeNoStencil(webgl))
{
if (mFakeNoAlpha) {
@ -1884,6 +1895,9 @@ WebGLContext::ScopedMaskWorkaround::ScopedMaskWorkaround(WebGLContext& webgl)
mWebGL.mColorWriteMask[2],
false);
}
if (mFakeNoDepth) {
mWebGL.gl->fDisable(LOCAL_GL_DEPTH_TEST);
}
if (mFakeNoStencil) {
mWebGL.gl->fDisable(LOCAL_GL_STENCIL_TEST);
}
@ -1897,6 +1911,9 @@ WebGLContext::ScopedMaskWorkaround::~ScopedMaskWorkaround()
mWebGL.mColorWriteMask[2],
mWebGL.mColorWriteMask[3]);
}
if (mFakeNoDepth) {
mWebGL.gl->fEnable(LOCAL_GL_DEPTH_TEST);
}
if (mFakeNoStencil) {
mWebGL.gl->fEnable(LOCAL_GL_STENCIL_TEST);
}

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

@ -8,6 +8,7 @@
#include <stdarg.h>
#include "GLContextTypes.h"
#include "GLDefs.h"
#include "mozilla/Attributes.h"
#include "mozilla/CheckedInt.h"
@ -24,6 +25,7 @@
#include "nsLayoutUtils.h"
#include "nsTArray.h"
#include "nsWrapperCache.h"
#include "SurfaceTypes.h"
#ifdef XP_MACOSX
#include "ForceDiscreteGPUHelperCGL.h"
@ -812,6 +814,7 @@ private:
realGLboolean mDitherEnabled;
realGLboolean mRasterizerDiscardEnabled;
realGLboolean mScissorTestEnabled;
realGLboolean mDepthTestEnabled;
realGLboolean mStencilTestEnabled;
bool ValidateCapabilityEnum(GLenum cap, const char* info);
@ -1153,11 +1156,19 @@ public:
protected:
bool InitWebGL2();
bool CreateAndInitGL(bool forceEnabled);
bool ResizeBackbuffer(uint32_t width, uint32_t height);
typedef already_AddRefed<gl::GLContext> FnCreateGL_T(const gl::SurfaceCaps& caps,
gl::CreateContextFlags flags,
WebGLContext* webgl);
bool CreateAndInitGLWith(FnCreateGL_T fnCreateGL, const gl::SurfaceCaps& baseCaps,
gl::CreateContextFlags flags);
// -------------------------------------------------------------------------
// Validation functions (implemented in WebGLContextValidate.cpp)
bool CreateOffscreenGL(bool forceEnabled);
bool InitAndValidateGL();
bool ResizeBackbuffer(uint32_t width, uint32_t height);
bool ValidateBlendEquationEnum(GLenum cap, const char* info);
bool ValidateBlendFuncDstEnum(GLenum mode, const char* info);
bool ValidateBlendFuncSrcEnum(GLenum mode, const char* info);
@ -1443,11 +1454,13 @@ protected:
uint64_t mLastUseIndex;
bool mNeedsFakeNoAlpha;
bool mNeedsFakeNoDepth;
bool mNeedsFakeNoStencil;
struct ScopedMaskWorkaround {
WebGLContext& mWebGL;
const bool mFakeNoAlpha;
const bool mFakeNoDepth;
const bool mFakeNoStencil;
static bool ShouldFakeNoAlpha(WebGLContext& webgl) {
@ -1458,6 +1471,13 @@ protected:
webgl.mColorWriteMask[3] != false;
}
static bool ShouldFakeNoDepth(WebGLContext& webgl) {
// We should only be doing this if we're about to draw to the backbuffer.
return !webgl.mBoundDrawFramebuffer &&
webgl.mNeedsFakeNoDepth &&
webgl.mDepthTestEnabled;
}
static bool ShouldFakeNoStencil(WebGLContext& webgl) {
// We should only be doing this if we're about to draw to the backbuffer.
return !webgl.mBoundDrawFramebuffer &&

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

@ -360,12 +360,18 @@ WebGLContext::GetParameter(JSContext* cx, GLenum pname, ErrorResult& rv)
case LOCAL_GL_MAX_TEXTURE_IMAGE_UNITS:
case LOCAL_GL_RED_BITS:
case LOCAL_GL_GREEN_BITS:
case LOCAL_GL_BLUE_BITS:
case LOCAL_GL_DEPTH_BITS: {
case LOCAL_GL_BLUE_BITS: {
GLint i = 0;
gl->fGetIntegerv(pname, &i);
return JS::Int32Value(i);
}
case LOCAL_GL_DEPTH_BITS: {
GLint i = 0;
if (!mNeedsFakeNoDepth) {
gl->fGetIntegerv(pname, &i);
}
return JS::Int32Value(i);
}
case LOCAL_GL_ALPHA_BITS: {
GLint i = 0;
if (!mNeedsFakeNoAlpha) {
@ -622,6 +628,8 @@ realGLboolean*
WebGLContext::GetStateTrackingSlot(GLenum cap)
{
switch (cap) {
case LOCAL_GL_DEPTH_TEST:
return &mDepthTestEnabled;
case LOCAL_GL_DITHER:
return &mDitherEnabled;
case LOCAL_GL_RASTERIZER_DISCARD:

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

@ -1175,6 +1175,7 @@ WebGLContext::AssertCachedState()
}
// Draw state
MOZ_ASSERT(gl->fIsEnabled(LOCAL_GL_DEPTH_TEST) == mDepthTestEnabled);
MOZ_ASSERT(gl->fIsEnabled(LOCAL_GL_DITHER) == mDitherEnabled);
MOZ_ASSERT_IF(IsWebGL2(),
gl->fIsEnabled(LOCAL_GL_RASTERIZER_DISCARD) == mRasterizerDiscardEnabled);

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

@ -904,7 +904,7 @@ Event::GetScreenCoords(nsPresContext* aPresContext,
WidgetEvent* aEvent,
LayoutDeviceIntPoint aPoint)
{
if (!nsContentUtils::IsCallerChrome() &&
if (!nsContentUtils::LegacyIsCallerChromeOrNativeCode() &&
nsContentUtils::ResistFingerprinting()) {
// When resisting fingerprinting, return client coordinates instead.
CSSIntPoint clientCoords = GetClientCoords(aPresContext, aEvent, aPoint, CSSIntPoint(0, 0));

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

@ -36,6 +36,7 @@
#include "mozilla/dom/TouchEvent.h"
#include "mozilla/dom/TransitionEvent.h"
#include "mozilla/dom/WheelEvent.h"
#include "mozilla/dom/WorkerPrivate.h"
#include "mozilla/dom/XULCommandEvent.h"
#include "mozilla/EventDispatcher.h"
#include "mozilla/EventListenerManager.h"
@ -709,7 +710,9 @@ EventDispatcher::DispatchDOMEvent(nsISupports* aTarget,
if (!dontResetTrusted) {
//Check security state to determine if dispatcher is trusted
aDOMEvent->SetTrusted(nsContentUtils::ThreadsafeIsCallerChrome());
bool trusted = NS_IsMainThread() ? nsContentUtils::LegacyIsCallerChromeOrNativeCode()
: mozilla::dom::workers::IsCurrentThreadRunningChromeWorker();
aDOMEvent->SetTrusted(trusted);
}
return EventDispatcher::Dispatch(aTarget, aPresContext, innerEvent,

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

@ -93,6 +93,7 @@ Touch::GetTarget() const
{
nsCOMPtr<nsIContent> content = do_QueryInterface(mTarget);
if (content && content->ChromeOnlyAccess() &&
!nsContentUtils::LegacyIsCallerNativeCode() &&
!nsContentUtils::CanAccessNativeAnon()) {
return content->FindFirstNonChromeOnlyAccessContent();
}

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

@ -7,6 +7,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=607464
<title>Test for Bug 607464</title>
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<script type="text/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
<script type="text/javascript" src="/tests/gfx/layers/apz/test/mochitest/apz_test_utils.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
</head>
<body>
@ -63,7 +64,9 @@ function runTest() {
}
}, true);
scrollDown150PxWithPixelScrolling(scrollbox);
flushApzRepaints(function() {
scrollDown150PxWithPixelScrolling(scrollbox);
}, win);
}, win);
}

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

@ -1419,7 +1419,7 @@ Geolocation::GetCurrentPosition(GeoPositionCallback& callback,
return NS_OK;
}
if (!mOwner && !nsContentUtils::IsCallerChrome()) {
if (!mOwner && !nsContentUtils::LegacyIsCallerChromeOrNativeCode()) {
return NS_ERROR_FAILURE;
}
@ -1442,7 +1442,7 @@ Geolocation::GetCurrentPositionReady(nsGeolocationRequest* aRequest)
return NS_OK;
}
if (!nsContentUtils::IsCallerChrome()) {
if (!nsContentUtils::LegacyIsCallerChromeOrNativeCode()) {
return NS_ERROR_FAILURE;
}
@ -1513,7 +1513,7 @@ Geolocation::WatchPosition(GeoPositionCallback& aCallback,
return NS_OK;
}
if (!mOwner && !nsContentUtils::IsCallerChrome()) {
if (!mOwner && !nsContentUtils::LegacyIsCallerChromeOrNativeCode()) {
return NS_ERROR_FAILURE;
}
@ -1535,7 +1535,7 @@ Geolocation::WatchPositionReady(nsGeolocationRequest* aRequest)
return NS_OK;
}
if (!nsContentUtils::IsCallerChrome()) {
if (!nsContentUtils::LegacyIsCallerChromeOrNativeCode()) {
return NS_ERROR_FAILURE;
}

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

@ -1417,7 +1417,7 @@ HTMLInputElement::GetValueInternal(nsAString& aValue) const
return NS_OK;
case VALUE_MODE_FILENAME:
if (nsContentUtils::IsCallerChrome()) {
if (nsContentUtils::LegacyIsCallerChromeOrNativeCode()) {
#ifndef MOZ_CHILD_PERMISSIONS
aValue.Assign(mFirstFilePath);
#else
@ -2994,7 +2994,7 @@ HTMLInputElement::DispatchSelectEvent(nsPresContext* aPresContext)
// If already handling select event, don't dispatch a second.
if (!mHandlingSelectEvent) {
WidgetEvent event(nsContentUtils::IsCallerChrome(), eFormSelect);
WidgetEvent event(nsContentUtils::LegacyIsCallerChromeOrNativeCode(), eFormSelect);
mHandlingSelectEvent = true;
EventDispatcher::Dispatch(static_cast<nsIContent*>(this),

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

@ -1472,7 +1472,7 @@ HTMLMediaElement::Seek(double aTime,
// Detect if user has interacted with element by seeking so that
// play will not be blocked when initiated by a script.
if (EventStateManager::IsHandlingUserInput() || nsContentUtils::IsCallerChrome()) {
if (EventStateManager::IsHandlingUserInput() || nsContentUtils::LegacyIsCallerChromeOrNativeCode()) {
mHasUserInteraction = true;
}
@ -3042,7 +3042,7 @@ public:
if (!mElement) {
return;
}
gfxIntSize size;
gfx::IntSize size;
{
MutexAutoLock lock(mMutex);
size = mInitialSize;
@ -3056,13 +3056,13 @@ public:
const MediaSegment& aQueuedMedia) override
{
MutexAutoLock lock(mMutex);
if (mInitialSize != gfxIntSize(0,0) ||
if (mInitialSize != gfx::IntSize(0,0) ||
aQueuedMedia.GetType() != MediaSegment::VIDEO) {
return;
}
const VideoSegment& video = static_cast<const VideoSegment&>(aQueuedMedia);
for (VideoSegment::ConstChunkIterator c(video); !c.IsEnded(); c.Next()) {
if (c->mFrame.GetIntrinsicSize() != gfxIntSize(0,0)) {
if (c->mFrame.GetIntrinsicSize() != gfx::IntSize(0,0)) {
mInitialSize = c->mFrame.GetIntrinsicSize();
nsCOMPtr<nsIRunnable> event =
NS_NewRunnableMethod(this, &StreamSizeListener::ReceivedSize);
@ -3077,7 +3077,7 @@ private:
// mMutex protects the fields below; they can be accessed on any thread
Mutex mMutex;
gfxIntSize mInitialSize;
gfx::IntSize mInitialSize;
};
class HTMLMediaElement::MediaStreamTracksAvailableCallback:

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

@ -2792,7 +2792,8 @@ nsGenericHTMLElement::GetEditor(nsIEditor** aEditor)
{
*aEditor = nullptr;
if (!nsContentUtils::IsCallerChrome()) {
// See also HTMLTextFieldAccessible::GetEditor.
if (!nsContentUtils::LegacyIsCallerChromeOrNativeCode()) {
return NS_ERROR_DOM_SECURITY_ERR;
}

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

@ -2929,7 +2929,7 @@ nsHTMLDocument::SetDesignMode(const nsAString & aDesignMode)
void
nsHTMLDocument::SetDesignMode(const nsAString& aDesignMode, ErrorResult& rv)
{
if (!nsContentUtils::SubjectPrincipal()->Subsumes(NodePrincipal())) {
if (!nsContentUtils::LegacyIsCallerNativeCode() && !nsContentUtils::SubjectPrincipal()->Subsumes(NodePrincipal())) {
rv.Throw(NS_ERROR_DOM_PROP_ACCESS_DENIED);
return;
}

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

@ -2177,7 +2177,7 @@ ContentChild::RecvAddPermission(const IPC::Permission& permission)
}
bool
ContentChild::RecvScreenSizeChanged(const gfxIntSize& size)
ContentChild::RecvScreenSizeChanged(const gfx::IntSize& size)
{
#ifdef ANDROID
mScreenSize = size;

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

@ -332,7 +332,7 @@ public:
virtual bool RecvAddPermission(const IPC::Permission& permission) override;
virtual bool RecvScreenSizeChanged(const gfxIntSize &size) override;
virtual bool RecvScreenSizeChanged(const gfx::IntSize &size) override;
virtual bool RecvFlushMemory(const nsString& reason) override;
@ -407,7 +407,7 @@ public:
virtual bool RecvEndDragSession(const bool& aDoneDrag,
const bool& aUserCancelled) override;
#ifdef ANDROID
gfxIntSize GetScreenSize() { return mScreenSize; }
gfx::IntSize GetScreenSize() { return mScreenSize; }
#endif
// Get the directory for IndexedDB files. We query the parent for this and
@ -502,7 +502,7 @@ private:
AppInfo mAppInfo;
#ifdef ANDROID
gfxIntSize mScreenSize;
gfx::IntSize mScreenSize;
#endif
bool mIsForApp;

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

@ -2727,7 +2727,7 @@ ContentParent::RecvSetClipboard(const IPCDataTransfer& aDataTransfer,
item.flavor().EqualsLiteral(kPNGImageMime) ||
item.flavor().EqualsLiteral(kGIFImageMime)) {
const IPCDataTransferImage& imageDetails = item.imageDetails();
const gfxIntSize size(imageDetails.width(), imageDetails.height());
const gfx::IntSize size(imageDetails.width(), imageDetails.height());
if (!size.width || !size.height) {
return true;
}

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

@ -84,7 +84,7 @@ using struct mozilla::void_t from "ipc/IPCMessageUtils.h";
using mozilla::dom::NativeThreadId from "mozilla/dom/TabMessageUtils.h";
using mozilla::dom::quota::PersistenceType from "mozilla/dom/quota/PersistenceType.h";
using mozilla::hal::ProcessPriority from "mozilla/HalTypes.h";
using gfxIntSize from "nsSize.h";
using mozilla::gfx::IntSize from "mozilla/gfx/2D.h";
using mozilla::dom::TabId from "mozilla/dom/ipc/IdType.h";
using mozilla::dom::ContentParentId from "mozilla/dom/ipc/IdType.h";
using struct LookAndFeelInt from "mozilla/widget/WidgetMessageUtils.h";
@ -546,7 +546,7 @@ child:
// nsIPermissionManager messages
AddPermission(Permission permission);
ScreenSizeChanged(gfxIntSize size);
ScreenSizeChanged(IntSize size);
Volumes(VolumeInfo[] volumes);

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

@ -1979,7 +1979,7 @@ TabParent::RecvSetCustomCursor(const nsCString& aCursorData,
}
if (mTabSetsCursor) {
const gfxIntSize size(aWidth, aHeight);
const gfx::IntSize size(aWidth, aHeight);
mozilla::RefPtr<gfx::DataSourceSurface> customCursor = new mozilla::gfx::SourceSurfaceRawData();
mozilla::gfx::SourceSurfaceRawData* raw = static_cast<mozilla::gfx::SourceSurfaceRawData*>(customCursor.get());

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

@ -29,7 +29,7 @@ VideoFrameContainer::VideoFrameContainer(dom::HTMLMediaElement* aElement,
VideoFrameContainer::~VideoFrameContainer()
{}
void VideoFrameContainer::SetCurrentFrame(const gfxIntSize& aIntrinsicSize,
void VideoFrameContainer::SetCurrentFrame(const gfx::IntSize& aIntrinsicSize,
Image* aImage,
const TimeStamp& aTargetTime)
{
@ -44,14 +44,14 @@ void VideoFrameContainer::SetCurrentFrame(const gfxIntSize& aIntrinsicSize,
}
}
void VideoFrameContainer::SetCurrentFrames(const gfxIntSize& aIntrinsicSize,
void VideoFrameContainer::SetCurrentFrames(const gfx::IntSize& aIntrinsicSize,
const nsTArray<ImageContainer::NonOwningImage>& aImages)
{
MutexAutoLock lock(mMutex);
SetCurrentFramesLocked(aIntrinsicSize, aImages);
}
void VideoFrameContainer::SetCurrentFramesLocked(const gfxIntSize& aIntrinsicSize,
void VideoFrameContainer::SetCurrentFramesLocked(const gfx::IntSize& aIntrinsicSize,
const nsTArray<ImageContainer::NonOwningImage>& aImages)
{
mMutex.AssertCurrentThreadOwns();

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

@ -42,11 +42,11 @@ public:
already_AddRefed<ImageContainer> aContainer);
// Call on any thread
B2G_ACL_EXPORT void SetCurrentFrame(const gfxIntSize& aIntrinsicSize, Image* aImage,
B2G_ACL_EXPORT void SetCurrentFrame(const gfx::IntSize& aIntrinsicSize, Image* aImage,
const TimeStamp& aTargetTime);
void SetCurrentFrames(const gfxIntSize& aIntrinsicSize,
void SetCurrentFrames(const gfx::IntSize& aIntrinsicSize,
const nsTArray<ImageContainer::NonOwningImage>& aImages);
void ClearCurrentFrame(const gfxIntSize& aIntrinsicSize)
void ClearCurrentFrame(const gfx::IntSize& aIntrinsicSize)
{
SetCurrentFrames(aIntrinsicSize, nsTArray<ImageContainer::NonOwningImage>());
}
@ -79,7 +79,7 @@ public:
void ForgetElement() { mElement = nullptr; }
protected:
void SetCurrentFramesLocked(const gfxIntSize& aIntrinsicSize,
void SetCurrentFramesLocked(const gfx::IntSize& aIntrinsicSize,
const nsTArray<ImageContainer::NonOwningImage>& aImages);
// Non-addreffed pointer to the element. The element calls ForgetElement
@ -94,7 +94,7 @@ protected:
// This can differ from the Image's actual size when the media resource
// specifies that the Image should be stretched to have the correct aspect
// ratio.
gfxIntSize mIntrinsicSize;
gfx::IntSize mIntrinsicSize;
// We maintain our own mFrameID which is auto-incremented at every
// SetCurrentFrame() or NewFrameID() call.
ImageContainer::FrameID mFrameID;

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

@ -14,7 +14,7 @@ namespace mozilla {
using namespace layers;
VideoFrame::VideoFrame(already_AddRefed<Image>& aImage,
const gfxIntSize& aIntrinsicSize)
const gfx::IntSize& aIntrinsicSize)
: mImage(aImage), mIntrinsicSize(aIntrinsicSize), mForceBlack(false)
{}
@ -28,7 +28,7 @@ VideoFrame::~VideoFrame()
void
VideoFrame::SetNull() {
mImage = nullptr;
mIntrinsicSize = gfxIntSize(0, 0);
mIntrinsicSize = gfx::IntSize(0, 0);
}
void
@ -41,7 +41,7 @@ VideoFrame::TakeFrom(VideoFrame* aFrame)
#if !defined(MOZILLA_XPCOMRT_API)
/* static */ already_AddRefed<Image>
VideoFrame::CreateBlackImage(const gfxIntSize& aSize)
VideoFrame::CreateBlackImage(const gfx::IntSize& aSize)
{
nsRefPtr<ImageContainer> container;
nsRefPtr<Image> image;

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

@ -30,7 +30,7 @@ public:
typedef mozilla::layers::Image Image;
#endif
VideoFrame(already_AddRefed<Image>& aImage, const gfxIntSize& aIntrinsicSize);
VideoFrame(already_AddRefed<Image>& aImage, const gfx::IntSize& aIntrinsicSize);
VideoFrame();
~VideoFrame();
@ -48,13 +48,13 @@ public:
Image* GetImage() const { return mImage; }
void SetForceBlack(bool aForceBlack) { mForceBlack = aForceBlack; }
bool GetForceBlack() const { return mForceBlack; }
const gfxIntSize& GetIntrinsicSize() const { return mIntrinsicSize; }
const gfx::IntSize& GetIntrinsicSize() const { return mIntrinsicSize; }
void SetNull();
void TakeFrom(VideoFrame* aFrame);
#if !defined(MOZILLA_XPCOMRT_API)
// Create a planar YCbCr black image.
static already_AddRefed<Image> CreateBlackImage(const gfxIntSize& aSize);
static already_AddRefed<Image> CreateBlackImage(const gfx::IntSize& aSize);
#endif // !defined(MOZILLA_XPCOMRT_API)
protected:
@ -62,7 +62,7 @@ protected:
// still have an intrinsic size in this case.
nsRefPtr<Image> mImage;
// The desired size to render the video frame at.
gfxIntSize mIntrinsicSize;
gfx::IntSize mIntrinsicSize;
bool mForceBlack;
};

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

@ -79,7 +79,7 @@ nsresult AndroidMediaReader::ReadMetadata(MediaInfo* aInfo,
mInitialFrame = frameSize;
VideoFrameContainer* container = mDecoder->GetVideoFrameContainer();
if (container) {
container->ClearCurrentFrame(gfxIntSize(displaySize.width, displaySize.height));
container->ClearCurrentFrame(IntSize(displaySize.width, displaySize.height));
}
}

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

@ -78,18 +78,13 @@ MediaKeySystemAccessManager::Request(DetailedPromise* aPromise,
static bool
ShouldTrialCreateGMP(const nsAString& aKeySystem)
{
// Trial create where the CDM has a decoder;
// * ClearKey and Primetime on Windows Vista and later.
// * Primetime on MacOSX Lion and later.
return
Preferences::GetBool("media.gmp.trial-create.enabled", false) &&
// Trial create where the CDM has a Windows Media Foundation decoder.
#ifdef XP_WIN
IsVistaOrLater();
#elif defined(XP_MACOSX)
aKeySystem.EqualsLiteral("com.adobe.primetime") &&
nsCocoaFeatures::OnLionOrLater();
return Preferences::GetBool("media.gmp.trial-create.enabled", false) &&
aKeySystem.EqualsLiteral("org.w3.clearkey") &&
IsVistaOrLater();
#else
false;
return false;
#endif
}

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

@ -59,42 +59,12 @@ MediaKeys::MediaKeys(nsPIDOMWindow* aParent,
this, NS_ConvertUTF16toUTF8(mKeySystem).get());
}
static PLDHashOperator
RejectPromises(const uint32_t& aKey,
nsRefPtr<dom::DetailedPromise>& aPromise,
void* aClosure)
{
aPromise->MaybeReject(NS_ERROR_DOM_INVALID_STATE_ERR,
NS_LITERAL_CSTRING("Promise still outstanding at MediaKeys shutdown"));
((MediaKeys*)aClosure)->Release();
return PL_DHASH_NEXT;
}
MediaKeys::~MediaKeys()
{
Shutdown();
EME_LOG("MediaKeys[%p] destroyed", this);
}
static PLDHashOperator
CopySessions(const nsAString& aKey,
nsRefPtr<MediaKeySession>& aSession,
void* aClosure)
{
KeySessionHashMap* p = static_cast<KeySessionHashMap*>(aClosure);
p->Put(aSession->GetSessionId(), aSession);
return PL_DHASH_NEXT;
}
static PLDHashOperator
CloseSessions(const nsAString& aKey,
nsRefPtr<MediaKeySession>& aSession,
void* aClosure)
{
aSession->OnClosed();
return PL_DHASH_NEXT;
}
void
MediaKeys::Terminated()
{
@ -102,8 +72,14 @@ MediaKeys::Terminated()
KeySessionHashMap keySessions;
// Remove entries during iteration will screw it. Make a copy first.
mKeySessions.Enumerate(&CopySessions, &keySessions);
keySessions.Enumerate(&CloseSessions, nullptr);
for (auto iter = mKeySessions.Iter(); !iter.Done(); iter.Next()) {
nsRefPtr<MediaKeySession>& session = iter.Data();
keySessions.Put(session->GetSessionId(), session);
}
for (auto iter = keySessions.Iter(); !iter.Done(); iter.Next()) {
nsRefPtr<MediaKeySession>& session = iter.Data();
session->OnClosed();
}
keySessions.Clear();
MOZ_ASSERT(mKeySessions.Count() == 0);
@ -125,7 +101,12 @@ MediaKeys::Shutdown()
nsRefPtr<MediaKeys> kungFuDeathGrip = this;
mPromises.Enumerate(&RejectPromises, this);
for (auto iter = mPromises.Iter(); !iter.Done(); iter.Next()) {
nsRefPtr<dom::DetailedPromise>& promise = iter.Data();
promise->MaybeReject(NS_ERROR_DOM_INVALID_STATE_ERR,
NS_LITERAL_CSTRING("Promise still outstanding at MediaKeys shutdown"));
Release();
}
mPromises.Clear();
}

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

@ -197,7 +197,7 @@ VideoTrackEncoder::NotifyQueuedTrackChanges(MediaStreamGraph* aGraph,
VideoChunk chunk = *iter;
if (!chunk.IsNull()) {
gfx::IntSize imgsize = chunk.mFrame.GetImage()->GetSize();
gfxIntSize intrinsicSize = chunk.mFrame.GetIntrinsicSize();
gfx::IntSize intrinsicSize = chunk.mFrame.GetIntrinsicSize();
nsresult rv = Init(imgsize.width, imgsize.height,
intrinsicSize.width, intrinsicSize.height,
aGraph->GraphRate());

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

@ -251,7 +251,7 @@ nsresult VP8TrackEncoder::PrepareRawFrame(VideoChunk &aChunk)
nsRefPtr<Image> img;
if (aChunk.mFrame.GetForceBlack() || aChunk.IsNull()) {
if (!mMuteFrame) {
mMuteFrame = VideoFrame::CreateBlackImage(gfxIntSize(mFrameWidth, mFrameHeight));
mMuteFrame = VideoFrame::CreateBlackImage(gfx::IntSize(mFrameWidth, mFrameHeight));
MOZ_ASSERT(mMuteFrame);
}
img = mMuteFrame;

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

@ -311,20 +311,16 @@ GMPServiceChild::GetBridgedGMPContentParent(ProcessId aOtherPid,
mContentParents.Get(aOtherPid, aGMPContentParent);
}
static PLDHashOperator
FindAndRemoveGMPContentParent(const uint64_t& aKey,
nsRefPtr<GMPContentParent>& aData,
void* aUserArg)
{
return aData == aUserArg ?
(PLDHashOperator)(PL_DHASH_STOP | PL_DHASH_REMOVE) :
PL_DHASH_NEXT;
}
void
GMPServiceChild::RemoveGMPContentParent(GMPContentParent* aGMPContentParent)
{
mContentParents.Enumerate(FindAndRemoveGMPContentParent, aGMPContentParent);
for (auto iter = mContentParents.Iter(); !iter.Done(); iter.Next()) {
nsRefPtr<GMPContentParent>& parent = iter.Data();
if (parent == aGMPContentParent) {
iter.Remove();
break;
}
}
}
static PLDHashOperator

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

@ -240,7 +240,7 @@ void OggReader::SetupTargetTheora(TheoraState* aTheoraState)
VideoFrameContainer* container = mDecoder->GetVideoFrameContainer();
if (container) {
container->ClearCurrentFrame(gfxIntSize(displaySize.width, displaySize.height));
container->ClearCurrentFrame(IntSize(displaySize.width, displaySize.height));
}
// Copy Theora info data for time computations on other threads.

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

@ -744,7 +744,7 @@ MediaCodecReader::HandleResourceAllocated()
VideoFrameContainer* container = mDecoder->GetVideoFrameContainer();
if (container) {
container->ClearCurrentFrame(
gfxIntSize(mInfo.mVideo.mDisplay.width, mInfo.mVideo.mDisplay.height));
gfx::IntSize(mInfo.mVideo.mDisplay.width, mInfo.mVideo.mDisplay.height));
}
nsRefPtr<MetadataHolder> metadata = new MetadataHolder();
@ -847,32 +847,6 @@ MediaCodecReader::WaitFenceAndReleaseOutputBuffer()
}
}
PLDHashOperator
MediaCodecReader::ReleaseTextureClient(TextureClient* aClient,
size_t& aIndex,
void* aUserArg)
{
nsRefPtr<MediaCodecReader> reader = static_cast<MediaCodecReader*>(aUserArg);
MOZ_ASSERT(reader, "reader should not be nullptr in ReleaseTextureClient()");
return reader->ReleaseTextureClient(aClient, aIndex);
}
PLDHashOperator
MediaCodecReader::ReleaseTextureClient(TextureClient* aClient,
size_t& aIndex)
{
MOZ_ASSERT(aClient, "TextureClient should be a valid pointer");
aClient->ClearRecycleCallback();
if (mVideoTrack.mCodec != nullptr) {
mVideoTrack.mCodec->releaseOutputBuffer(aIndex);
}
return PL_DHASH_REMOVE;
}
void
MediaCodecReader::ReleaseAllTextureClients()
{
@ -884,7 +858,17 @@ MediaCodecReader::ReleaseAllTextureClients()
}
printf_stderr("All TextureClients should be released already");
mTextureClientIndexes.Enumerate(MediaCodecReader::ReleaseTextureClient, this);
for (auto iter = mTextureClientIndexes.Iter(); !iter.Done(); iter.Next()) {
TextureClient* client = iter.Key();
size_t& index = iter.Data();
client->ClearRecycleCallback();
if (mVideoTrack.mCodec != nullptr) {
mVideoTrack.mCodec->releaseOutputBuffer(index);
}
iter.Remove();
}
mTextureClientIndexes.Clear();
}

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

@ -397,11 +397,6 @@ private:
void WaitFenceAndReleaseOutputBuffer();
void ReleaseRecycledTextureClients();
static PLDHashOperator ReleaseTextureClient(TextureClient* aClient,
size_t& aIndex,
void* aUserArg);
PLDHashOperator ReleaseTextureClient(TextureClient* aClient,
size_t& aIndex);
void ReleaseAllTextureClients();

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

@ -307,7 +307,7 @@ void MediaOmxReader::HandleResourceAllocated()
mInitialFrame = frameSize;
VideoFrameContainer* container = mDecoder->GetVideoFrameContainer();
if (container) {
container->ClearCurrentFrame(gfxIntSize(displaySize.width, displaySize.height));
container->ClearCurrentFrame(IntSize(displaySize.width, displaySize.height));
}
}

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

@ -19,15 +19,6 @@ namespace mozilla {
typedef MozPromiseRequestHolder<CDMProxy::DecryptPromise> DecryptPromiseRequestHolder;
static PLDHashOperator
DropDecryptPromises(MediaRawData* aKey,
nsAutoPtr<DecryptPromiseRequestHolder>& aData,
void* aUserArg)
{
aData->DisconnectIfExists();
return PL_DHASH_REMOVE;
}
class EMEDecryptor : public MediaDataDecoder {
public:
@ -107,7 +98,11 @@ public:
nsresult Flush() override {
MOZ_ASSERT(mTaskQueue->IsCurrentThreadIn());
MOZ_ASSERT(!mIsShutdown);
mDecrypts.Enumerate(&DropDecryptPromises, nullptr);
for (auto iter = mDecrypts.Iter(); !iter.Done(); iter.Next()) {
nsAutoPtr<DecryptPromiseRequestHolder>& holder = iter.Data();
holder->DisconnectIfExists();
iter.Remove();
}
nsresult rv = mDecoder->Flush();
unused << NS_WARN_IF(NS_FAILED(rv));
mSamplesWaitingForKey->Flush();
@ -117,7 +112,11 @@ public:
nsresult Drain() override {
MOZ_ASSERT(mTaskQueue->IsCurrentThreadIn());
MOZ_ASSERT(!mIsShutdown);
mDecrypts.Enumerate(&DropDecryptPromises, nullptr);
for (auto iter = mDecrypts.Iter(); !iter.Done(); iter.Next()) {
nsAutoPtr<DecryptPromiseRequestHolder>& holder = iter.Data();
holder->DisconnectIfExists();
iter.Remove();
}
nsresult rv = mDecoder->Drain();
unused << NS_WARN_IF(NS_FAILED(rv));
return rv;

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

@ -100,7 +100,7 @@ public:
LOCAL_EGL_NONE, LOCAL_EGL_NONE
};
EGLContext eglContext = static_cast<GLContextEGL*>(mGLContext.get())->GetEGLContext();
EGLContext eglContext = static_cast<GLContextEGL*>(mGLContext.get())->mContext;
EGLImage eglImage = sEGLLibrary.fCreateImage(EGL_DISPLAY(), eglContext,
LOCAL_EGL_GL_TEXTURE_2D_KHR,
(EGLClientBuffer)tex, attribs);

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

@ -83,26 +83,21 @@ class OriginKeyStore : public nsISupports
return NS_OK;
}
static PLDHashOperator
HashCleaner(const nsACString& aOrigin, nsAutoPtr<OriginKey>& aOriginKey,
void *aUserArg)
{
OriginKey* since = static_cast<OriginKey*>(aUserArg);
LOG((((aOriginKey->mSecondsStamp >= since->mSecondsStamp)?
"%s: REMOVE %lld >= %lld" :
"%s: KEEP %lld < %lld"),
__FUNCTION__, aOriginKey->mSecondsStamp, since->mSecondsStamp));
return (aOriginKey->mSecondsStamp >= since->mSecondsStamp)?
PL_DHASH_REMOVE : PL_DHASH_NEXT;
}
void Clear(int64_t aSinceWhen)
{
// Avoid int64_t* <-> void* casting offset
OriginKey since(nsCString(), aSinceWhen / PR_USEC_PER_SEC);
mKeys.Enumerate(HashCleaner, &since);
for (auto iter = mKeys.Iter(); !iter.Done(); iter.Next()) {
nsAutoPtr<OriginKey>& originKey = iter.Data();
LOG((((originKey->mSecondsStamp >= since.mSecondsStamp)?
"%s: REMOVE %lld >= %lld" :
"%s: KEEP %lld < %lld"),
__FUNCTION__, originKey->mSecondsStamp, since.mSecondsStamp));
if (originKey->mSecondsStamp >= since.mSecondsStamp) {
iter.Remove();
}
}
mPersistCount = 0;
}

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

@ -141,25 +141,6 @@ MediaSystemResourceService::ReleaseResource(media::MediaSystemResourceManagerPar
UpdateRequests(aResourceType);
}
struct ReleaseResourceData
{
MediaSystemResourceService* mSelf;
media::MediaSystemResourceManagerParent* mParent;
};
/*static*/PLDHashOperator
MediaSystemResourceService::ReleaseResourceForKey(const uint32_t& aKey,
nsAutoPtr<MediaSystemResource>& aData,
void* aClosure)
{
ReleaseResourceData* closure = static_cast<ReleaseResourceData*>(aClosure);
closure->mSelf->RemoveRequests(closure->mParent, static_cast<MediaSystemResourceType>(aKey));
closure->mSelf->UpdateRequests(static_cast<MediaSystemResourceType>(aKey));
return PLDHashOperator::PL_DHASH_NEXT;
}
void
MediaSystemResourceService::ReleaseResource(media::MediaSystemResourceManagerParent* aParent)
{
@ -169,8 +150,11 @@ MediaSystemResourceService::ReleaseResource(media::MediaSystemResourceManagerPar
return;
}
ReleaseResourceData data = { this, aParent };
mResources.Enumerate(ReleaseResourceForKey, &data);
for (auto iter = mResources.Iter(); !iter.Done(); iter.Next()) {
const uint32_t& key = iter.Key();
RemoveRequests(aParent, static_cast<MediaSystemResourceType>(key));
UpdateRequests(static_cast<MediaSystemResourceType>(key));
}
}
void

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

@ -77,10 +77,6 @@ private:
void UpdateRequests(MediaSystemResourceType aResourceType);
static PLDHashOperator ReleaseResourceForKey(const uint32_t& aKey,
nsAutoPtr<MediaSystemResource>& aData,
void* aClosure);
bool mDestroyed;
nsClassHashtable<nsUint32HashKey, MediaSystemResource> mResources;

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

@ -501,40 +501,8 @@ nsPicoService::GetServiceType(SpeechServiceType* aServiceType)
return NS_OK;
}
struct VoiceTraverserData
{
nsPicoService* mService;
nsSynthVoiceRegistry* mRegistry;
};
// private methods
static PLDHashOperator
PicoAddVoiceTraverser(const nsAString& aUri,
nsRefPtr<PicoVoice>& aVoice,
void* aUserArg)
{
// If we are missing either a language or a voice resource, it is invalid.
if (aVoice->mTaFile.IsEmpty() || aVoice->mSgFile.IsEmpty()) {
return PL_DHASH_REMOVE;
}
VoiceTraverserData* data = static_cast<VoiceTraverserData*>(aUserArg);
nsAutoString name;
name.AssignLiteral("Pico ");
name.Append(aVoice->mLanguage);
// This service is multi-threaded and can handle more than one utterance at a
// time before previous utterances end. So, aQueuesUtterances == false
DebugOnly<nsresult> rv =
data->mRegistry->AddVoice(
data->mService, aUri, name, aVoice->mLanguage, true, false);
NS_WARN_IF_FALSE(NS_SUCCEEDED(rv), "Failed to add voice");
return PL_DHASH_NEXT;
}
void
nsPicoService::Init()
{
@ -617,8 +585,28 @@ nsPicoService::Init()
void
nsPicoService::RegisterVoices()
{
VoiceTraverserData data = { this, nsSynthVoiceRegistry::GetInstance() };
mVoices.Enumerate(PicoAddVoiceTraverser, &data);
nsSynthVoiceRegistry* registry = nsSynthVoiceRegistry::GetInstance();
for (auto iter = mVoices.Iter(); !iter.Done(); iter.Next()) {
const nsAString& uri = iter.Key();
nsRefPtr<PicoVoice>& voice = iter.Data();
// If we are missing either a language or a voice resource, it is invalid.
if (voice->mTaFile.IsEmpty() || voice->mSgFile.IsEmpty()) {
iter.Remove();
continue;
}
nsAutoString name;
name.AssignLiteral("Pico ");
name.Append(voice->mLanguage);
// This service is multi-threaded and can handle more than one utterance at a
// time before previous utterances end. So, aQueuesUtterances == false
DebugOnly<nsresult> rv =
registry->AddVoice(this, uri, name, voice->mLanguage, true, false);
NS_WARN_IF_FALSE(NS_SUCCEEDED(rv), "Failed to add voice");
}
mInitialized = true;
}

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

@ -28,7 +28,7 @@ static ANPEGLContext anp_opengl_acquireContext(NPP instance) {
return nullptr;
context->MakeCurrent();
return GLContextEGL::Cast(context)->GetEGLContext();
return GLContextEGL::Cast(context)->mContext;
}
static ANPTextureInfo anp_opengl_lockTexture(NPP instance) {

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

@ -2587,7 +2587,7 @@ void nsPluginInstanceOwner::Paint(gfxContext* aContext,
aFrameRect.width != pluginSurface->Width() ||
aFrameRect.height != pluginSurface->Height()) {
pluginSurface = new gfxImageSurface(gfxIntSize(aFrameRect.width, aFrameRect.height),
pluginSurface = new gfxImageSurface(gfx::IntSize(aFrameRect.width, aFrameRect.height),
gfxImageFormat::ARGB32);
if (!pluginSurface)
return;

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

@ -22,7 +22,7 @@ using NPCoordinateSpace from "npapi.h";
using NPNVariable from "npapi.h";
using mozilla::plugins::NativeWindowHandle from "mozilla/plugins/PluginMessageUtils.h";
using gfxSurfaceType from "gfxTypes.h";
using gfxIntSize from "nsSize.h";
using mozilla::gfx::IntSize from "mozilla/gfx/2D.h";
using struct mozilla::null_t from "ipc/IPCMessageUtils.h";
using mozilla::plugins::WindowsSharedMemoryHandle from "mozilla/plugins/PluginMessageUtils.h";
using mozilla::layers::SurfaceDescriptorX11 from "gfxipc/ShadowLayerUtils.h";
@ -189,7 +189,7 @@ parent:
returns (SurfaceDescriptor prevSurface);
async PPluginSurface(WindowsSharedMemoryHandle handle,
gfxIntSize size,
IntSize size,
bool transparent);
intr NPN_PushPopupsEnabledState(bool aState);

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

@ -2861,8 +2861,7 @@ PluginInstanceChild::CreateOptSurface(void)
Visual* defaultVisual = DefaultVisualOfScreen(screen);
mCurrentSurface =
gfxXlibSurface::Create(screen, defaultVisual,
gfxIntSize(mWindow.width,
mWindow.height));
IntSize(mWindow.width, mWindow.height));
return mCurrentSurface != nullptr;
}
@ -2873,8 +2872,7 @@ PluginInstanceChild::CreateOptSurface(void)
}
mCurrentSurface =
gfxXlibSurface::Create(screen, xfmt,
gfxIntSize(mWindow.width,
mWindow.height));
IntSize(mWindow.width, mWindow.height));
return mCurrentSurface != nullptr;
}
#endif
@ -2898,7 +2896,7 @@ PluginInstanceChild::CreateOptSurface(void)
// Make common shmem implementation working for any platform
mCurrentSurface =
gfxSharedImageSurface::CreateUnsafe(this, gfxIntSize(mWindow.width, mWindow.height), format);
gfxSharedImageSurface::CreateUnsafe(this, IntSize(mWindow.width, mWindow.height), format);
return !!mCurrentSurface;
}
@ -2966,7 +2964,7 @@ PluginInstanceChild::EnsureCurrentBuffer(void)
{
#ifndef XP_DARWIN
nsIntRect toInvalidate(0, 0, 0, 0);
gfxIntSize winSize = gfxIntSize(mWindow.width, mWindow.height);
IntSize winSize = IntSize(mWindow.width, mWindow.height);
if (mBackground && mBackground->GetSize() != winSize) {
// It would be nice to keep the old background here, but doing
@ -2978,7 +2976,7 @@ PluginInstanceChild::EnsureCurrentBuffer(void)
}
if (mCurrentSurface) {
gfxIntSize surfSize = mCurrentSurface->GetSize();
IntSize surfSize = mCurrentSurface->GetSize();
if (winSize != surfSize ||
(mBackground && !CanPaintOnBackground()) ||
(mBackground &&
@ -3309,7 +3307,7 @@ PluginInstanceChild::PaintRectWithAlphaExtraction(const nsIntRect& aRect,
nsRefPtr<gfxImageSurface> whiteImage;
nsRefPtr<gfxImageSurface> blackImage;
gfxRect targetRect(rect.x, rect.y, rect.width, rect.height);
gfxIntSize targetSize(rect.width, rect.height);
IntSize targetSize(rect.width, rect.height);
gfxPoint deviceOffset = -targetRect.TopLeft();
// We always use a temporary "white image"
@ -3487,7 +3485,7 @@ PluginInstanceChild::ShowPluginFrame()
// Fix up old invalidations that might have been made when our
// surface was a different size
gfxIntSize surfaceSize = mCurrentSurface->GetSize();
IntSize surfaceSize = mCurrentSurface->GetSize();
rect.IntersectRect(rect,
nsIntRect(0, 0, surfaceSize.width, surfaceSize.height));
@ -3749,7 +3747,7 @@ PluginInstanceChild::RecvUpdateBackground(const SurfaceDescriptor& aBackground,
return false;
}
gfxIntSize bgSize = mBackground->GetSize();
IntSize bgSize = mBackground->GetSize();
mAccumulatedInvalidRect.UnionRect(mAccumulatedInvalidRect,
nsIntRect(0, 0, bgSize.width, bgSize.height));
AsyncShowPluginFrame();
@ -3786,7 +3784,7 @@ PluginInstanceChild::RecvPPluginBackgroundDestroyerConstructor(
// alpha values. (We should be notified of that invalidation soon
// too, but we don't assume that here.)
if (mBackground) {
gfxIntSize bgsize = mBackground->GetSize();
IntSize bgsize = mBackground->GetSize();
mAccumulatedInvalidRect.UnionRect(
nsIntRect(0, 0, bgsize.width, bgsize.height), mAccumulatedInvalidRect);

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

@ -113,7 +113,7 @@ protected:
virtual PPluginSurfaceChild*
AllocPPluginSurfaceChild(const WindowsSharedMemoryHandle&,
const gfxIntSize&, const bool&) override {
const gfx::IntSize&, const bool&) override {
return new PPluginSurfaceChild();
}

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

@ -726,7 +726,7 @@ nsresult
PluginInstanceParent::GetImageSize(nsIntSize* aSize)
{
if (mFrontSurface) {
gfxIntSize size = mFrontSurface->GetSize();
mozilla::gfx::IntSize size = mFrontSurface->GetSize();
*aSize = nsIntSize(size.width, size.height);
return NS_OK;
}
@ -795,7 +795,7 @@ PluginInstanceParent::BeginUpdateBackground(const nsIntRect& aRect,
}
}
gfxIntSize sz = mBackground->GetSize();
mozilla::gfx::IntSize sz = mBackground->GetSize();
#ifdef DEBUG
MOZ_ASSERT(nsIntRect(0, 0, sz.width, sz.height).Contains(aRect),
"Update outside of background area");
@ -852,7 +852,7 @@ PluginInstanceParent::CreateBackground(const nsIntSize& aSize)
Screen* screen = DefaultScreenOfDisplay(DefaultXDisplay());
Visual* visual = DefaultVisualOfScreen(screen);
mBackground = gfxXlibSurface::Create(screen, visual,
gfxIntSize(aSize.width, aSize.height));
mozilla::gfx::IntSize(aSize.width, aSize.height));
return !!mBackground;
#elif defined(XP_WIN)
@ -861,7 +861,7 @@ PluginInstanceParent::CreateBackground(const nsIntSize& aSize)
mBackground =
gfxSharedImageSurface::CreateUnsafe(
this,
gfxIntSize(aSize.width, aSize.height),
mozilla::gfx::IntSize(aSize.width, aSize.height),
gfxImageFormat::RGB24);
return !!mBackground;
#else
@ -1600,7 +1600,7 @@ PluginInstanceParent::GetActorForNPObject(NPObject* aObject)
PPluginSurfaceParent*
PluginInstanceParent::AllocPPluginSurfaceParent(const WindowsSharedMemoryHandle& handle,
const gfxIntSize& size,
const mozilla::gfx::IntSize& size,
const bool& transparent)
{
#ifdef XP_WIN

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

@ -169,7 +169,7 @@ public:
virtual PPluginSurfaceParent*
AllocPPluginSurfaceParent(const WindowsSharedMemoryHandle& handle,
const gfxIntSize& size,
const mozilla::gfx::IntSize& size,
const bool& transparent) override;
virtual bool

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

@ -12,7 +12,7 @@ namespace mozilla {
namespace plugins {
PluginSurfaceParent::PluginSurfaceParent(const WindowsSharedMemoryHandle& handle,
const gfxIntSize& size,
const gfx::IntSize& size,
bool transparent)
{
SharedDIBSurface* dibsurf = new SharedDIBSurface();

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

@ -23,7 +23,7 @@ class PluginSurfaceParent : public PPluginSurfaceParent
{
public:
PluginSurfaceParent(const WindowsSharedMemoryHandle& handle,
const gfxIntSize& size,
const gfx::IntSize& size,
const bool transparent);
~PluginSurfaceParent();

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

@ -3575,7 +3575,7 @@ QuotaManager::GetInfoForChrome(nsACString* aGroup,
bool* aIsApp)
{
MOZ_ASSERT(NS_IsMainThread());
MOZ_ASSERT(nsContentUtils::IsCallerChrome());
MOZ_ASSERT(nsContentUtils::LegacyIsCallerChromeOrNativeCode());
if (aGroup) {
ChromeOrigin(*aGroup);

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

@ -71,6 +71,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=870022
function runTest(iframe) {
var doc = iframe.contentDocument;
var win = iframe.contentWindow;
var img = doc.querySelector("img");
var source = doc.querySelector("source");
@ -78,9 +79,9 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=870022
is(source.sizes, undefined, "sizes should not be visible on <source>");
is(source.srcset, undefined, "srcset should not be visible on <source>");
var imgSizesDesc = Object.getOwnPropertyDescriptor(HTMLImageElement.prototype, "sizes");
var sourceSizesDesc = Object.getOwnPropertyDescriptor(HTMLSourceElement.prototype, "sizes");
var sourceSrcsetDesc = Object.getOwnPropertyDescriptor(HTMLSourceElement.prototype, "srcset");
var imgSizesDesc = Object.getOwnPropertyDescriptor(win.HTMLImageElement.prototype, "sizes");
var sourceSizesDesc = Object.getOwnPropertyDescriptor(win.HTMLSourceElement.prototype, "sizes");
var sourceSrcsetDesc = Object.getOwnPropertyDescriptor(win.HTMLSourceElement.prototype, "srcset");
is(imgSizesDesc, undefined, "HTMLImageElement should know nothing of sizes");
is(sourceSizesDesc, undefined, "HTMLSourceElement should know nothing of sizes");
is(sourceSrcsetDesc, undefined, "HTMLSourceElement should know nothing of srcset");

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

@ -12,8 +12,6 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=870021
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=870021">Mozilla Bug 870021</a>
<div id="imgContainer">
<img src="http://example.com/tests/image/test/mochitest/blue.png"
srcset="http://example.com/tests/image/test/mochitest/big.png">
</div>
<script type="application/javascript">
@ -28,10 +26,11 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=870021
// Ensure that disabling the pref works as expected
SpecialPowers.pushPrefEnv({'set': [[ "dom.image.srcset.enabled", false ]] }, function() {
var container = document.querySelector("#imgContainer");
// We want to re-create the element with the pref disabled to ensure
// webIDL attributes are not attached
container.innerHTML = container.innerHTML + " ";
var img = container.querySelector("img");
var img = document.createElement("img");
img.setAttribute("src", "http://example.com/tests/image/test/mochitest/blue.png");
img.setAttribute("srcset", "http://example.com/tests/image/test/mochitest/big.png");
container.insertBefore(img, container.firstChild);
img.addEventListener("load", function imgLoad() {
img.removeEventListener("load", imgLoad);
runTest();

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

@ -101,7 +101,9 @@ XPathExpression::EvaluateWithContext(nsINode& aContextNode,
return nullptr;
}
if (!nsContentUtils::CanCallerAccess(&aContextNode)) {
if (!nsContentUtils::LegacyIsCallerNativeCode() &&
!nsContentUtils::CanCallerAccess(&aContextNode))
{
aRv.Throw(NS_ERROR_DOM_SECURITY_ERR);
return nullptr;
}

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

@ -598,7 +598,8 @@ txMozillaXSLTProcessor::ImportStylesheet(nsIDOMNode *aStyle)
NS_ENSURE_TRUE(!mStylesheetDocument && !mStylesheet,
NS_ERROR_NOT_IMPLEMENTED);
if (!nsContentUtils::CanCallerAccess(aStyle)) {
nsCOMPtr<nsINode> node = do_QueryInterface(aStyle);
if (!node || !nsContentUtils::SubjectPrincipalOrSystemIfNativeCaller()->Subsumes(node->NodePrincipal())) {
return NS_ERROR_DOM_SECURITY_ERR;
}
@ -713,8 +714,13 @@ txMozillaXSLTProcessor::TransformToFragment(nsIDOMNode *aSource,
NS_ENSURE_ARG_POINTER(aResult);
NS_ENSURE_SUCCESS(mCompileResult, mCompileResult);
if (!nsContentUtils::CanCallerAccess(aSource) ||
!nsContentUtils::CanCallerAccess(aOutput)) {
nsCOMPtr<nsINode> node = do_QueryInterface(aSource);
nsCOMPtr<nsIDocument> doc = do_QueryInterface(aOutput);
NS_ENSURE_TRUE(node && doc, NS_ERROR_DOM_SECURITY_ERR);
nsIPrincipal* subject = nsContentUtils::SubjectPrincipalOrSystemIfNativeCaller();
if (!subject->Subsumes(node->NodePrincipal()) ||
!subject->Subsumes(doc->NodePrincipal()))
{
return NS_ERROR_DOM_SECURITY_ERR;
}

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

@ -135,7 +135,8 @@ nsXULCommandDispatcher::GetFocusedElement(nsIDOMElement** aElement)
CallQueryInterface(focusedContent, aElement);
// Make sure the caller can access the focused element.
if (!nsContentUtils::CanCallerAccess(*aElement)) {
nsCOMPtr<nsINode> node = do_QueryInterface(*aElement);
if (!node || !nsContentUtils::SubjectPrincipalOrSystemIfNativeCaller()->Subsumes(node->NodePrincipal())) {
// XXX This might want to return null, but we use that return value
// to mean "there is no focused element," so to be clear, throw an
// exception.

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

@ -237,7 +237,7 @@ nsCommandManager::GetControllerForCommand(const char* aCommand,
// check if we're in content or chrome
// if we're not chrome we must have a target window or we bail
if (!nsContentUtils::IsCallerChrome()) {
if (!nsContentUtils::LegacyIsCallerChromeOrNativeCode()) {
if (!aTargetWindow) {
return rv;
}

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

@ -593,7 +593,7 @@ nsWindowWatcher::OpenWindowInternal(nsIDOMWindow* aParent,
do_GetService(NS_SCRIPTSECURITYMANAGER_CONTRACTID));
bool isCallerChrome =
nsContentUtils::IsCallerChrome() && !openedFromRemoteTab;
nsContentUtils::LegacyIsCallerChromeOrNativeCode() && !openedFromRemoteTab;
dom::AutoJSAPI jsapiChromeGuard;
@ -1514,7 +1514,7 @@ nsWindowWatcher::CalculateChromeFlags(nsIDOMWindow* aParent,
bool openedFromContentScript =
aOpenedFromRemoteTab ? aCalledFromJS
: !nsContentUtils::IsCallerChrome();
: !nsContentUtils::LegacyIsCallerChromeOrNativeCode();
/* This function has become complicated since browser windows and
dialogs diverged. The difference is, browser windows assume all

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

@ -23,7 +23,7 @@ CreateEGLImage(GLContext* gl, GLuint tex)
MOZ_ASSERT(DoesEGLContextSupportSharingWithEGLImage(gl));
EGLClientBuffer clientBuffer = (EGLClientBuffer)((uint64_t)tex);
EGLContext eglContext = GLContextEGL::Cast(gl)->GetEGLContext();
EGLContext eglContext = GLContextEGL::Cast(gl)->mContext;
EGLImage image = sEGLLibrary.fCreateImage(EGL_DISPLAY(),
eglContext,
LOCAL_EGL_GL_TEXTURE_2D,
@ -42,7 +42,7 @@ EGLImageWrapper::Create(GLContext* gl, GLuint tex)
GLLibraryEGL& library = sEGLLibrary;
EGLDisplay display = EGL_DISPLAY();
EGLContext eglContext = GLContextEGL::Cast(gl)->GetEGLContext();
EGLContext eglContext = GLContextEGL::Cast(gl)->mContext;
EGLClientBuffer clientBuffer = (EGLClientBuffer)((uint64_t)tex);
EGLImage image = library.fCreateImage(display,
eglContext,

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

@ -306,7 +306,6 @@ GLContext::GLContext(const SurfaceCaps& caps,
mRenderer(GLRenderer::Other),
mHasRobustness(false),
mTopError(LOCAL_GL_NO_ERROR),
mLocalErrorScope(nullptr),
mSharedContext(sharedContext),
mCaps(caps),
mScreen(nullptr),

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

@ -7,12 +7,13 @@
#ifndef GLCONTEXT_H_
#define GLCONTEXT_H_
#include <stdio.h>
#include <stdint.h>
#include <ctype.h>
#include <map>
#include <bitset>
#include <ctype.h>
#include <stdint.h>
#include <stdio.h>
#include <map>
#include <queue>
#include <stack>
#ifdef DEBUG
#include <string.h>
@ -619,7 +620,7 @@ public:
class LocalErrorScope;
private:
LocalErrorScope* mLocalErrorScope;
std::stack<const LocalErrorScope*> mLocalErrorScopeStack;
public:
class LocalErrorScope {
@ -632,8 +633,7 @@ public:
: mGL(gl)
, mHasBeenChecked(false)
{
MOZ_ASSERT(!mGL.mLocalErrorScope);
mGL.mLocalErrorScope = this;
mGL.mLocalErrorScopeStack.push(this);
mGL.FlushErrors();
@ -653,10 +653,10 @@ public:
MOZ_ASSERT(mGL.fGetError() == LOCAL_GL_NO_ERROR);
mGL.mTopError = mOldTop;
MOZ_ASSERT(mGL.mLocalErrorScopeStack.top() == this);
mGL.mLocalErrorScopeStack.pop();
MOZ_ASSERT(mGL.mLocalErrorScope == this);
mGL.mLocalErrorScope = nullptr;
mGL.mTopError = mOldTop;
}
};
@ -738,7 +738,7 @@ private:
}
if (err != LOCAL_GL_NO_ERROR &&
!mLocalErrorScope)
!mLocalErrorScopeStack.size())
{
printf_stderr("[gl:%p] %s: Generated unexpected %s error."
" (0x%04x)\n", this, funcName,

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

@ -92,16 +92,12 @@ public:
// for the lifetime of this context.
void HoldSurface(gfxASurface *aSurf);
EGLContext GetEGLContext() {
return mContext;
}
EGLSurface GetEGLSurface() {
EGLSurface GetEGLSurface() const {
return mSurface;
}
EGLDisplay GetEGLDisplay() {
return EGL_DISPLAY();
EGLDisplay GetEGLDisplay() const {
return sEGLLibrary.Display();
}
bool BindTex2DOffscreen(GLContext *aOffscreen);
@ -112,15 +108,20 @@ public:
CreateEGLPixmapOffscreenContext(const gfx::IntSize& size);
static already_AddRefed<GLContextEGL>
CreateEGLPBufferOffscreenContext(const gfx::IntSize& size);
CreateEGLPBufferOffscreenContext(const gfx::IntSize& size,
const SurfaceCaps& minCaps);
protected:
friend class GLContextProviderEGL;
EGLConfig mConfig;
public:
const EGLConfig mConfig;
protected:
EGLSurface mSurface;
public:
const EGLContext mContext;
protected:
EGLSurface mSurfaceOverride;
EGLContext mContext;
nsRefPtr<gfxASurface> mThebesSurface;
bool mBound;

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

@ -9,7 +9,6 @@
#include "GLContextTypes.h"
#include "nsAutoPtr.h"
#include "SurfaceTypes.h"
#include "mozilla/TypedEnumBits.h"
#include "nsSize.h" // for gfx::IntSize (needed by GLContextProviderImpl.h below)
@ -18,16 +17,6 @@ class nsIWidget;
namespace mozilla {
namespace gl {
enum class CreateContextFlags : int8_t {
NONE = 0,
REQUIRE_COMPAT_PROFILE = 1 << 0,
// Force the use of hardware backed GL, don't allow software implementations.
FORCE_ENABLE_HARDWARE = 1 << 1,
/* Don't force discrete GPU to be used (if applicable) */
ALLOW_OFFLINE_RENDERER = 1 << 2,
};
MOZ_MAKE_ENUM_CLASS_BITWISE_OPERATORS(CreateContextFlags)
#define IN_GL_CONTEXT_PROVIDER_H
// Null is always there
@ -36,47 +25,45 @@ MOZ_MAKE_ENUM_CLASS_BITWISE_OPERATORS(CreateContextFlags)
#undef GL_CONTEXT_PROVIDER_NAME
#ifdef XP_WIN
#define GL_CONTEXT_PROVIDER_NAME GLContextProviderWGL
#include "GLContextProviderImpl.h"
#undef GL_CONTEXT_PROVIDER_NAME
#define GL_CONTEXT_PROVIDER_DEFAULT GLContextProviderWGL
#define DEFAULT_IMPL WGL
#define GL_CONTEXT_PROVIDER_NAME GLContextProviderWGL
#include "GLContextProviderImpl.h"
#undef GL_CONTEXT_PROVIDER_NAME
#define GL_CONTEXT_PROVIDER_DEFAULT GLContextProviderWGL
#define DEFAULT_IMPL WGL
#endif
#ifdef XP_MACOSX
#define GL_CONTEXT_PROVIDER_NAME GLContextProviderCGL
#include "GLContextProviderImpl.h"
#undef GL_CONTEXT_PROVIDER_NAME
#define GL_CONTEXT_PROVIDER_DEFAULT GLContextProviderCGL
#define GL_CONTEXT_PROVIDER_NAME GLContextProviderCGL
#include "GLContextProviderImpl.h"
#undef GL_CONTEXT_PROVIDER_NAME
#define GL_CONTEXT_PROVIDER_DEFAULT GLContextProviderCGL
#endif
#if defined(MOZ_X11)
#define GL_CONTEXT_PROVIDER_NAME GLContextProviderGLX
#include "GLContextProviderImpl.h"
#undef GL_CONTEXT_PROVIDER_NAME
#define GL_CONTEXT_PROVIDER_DEFAULT GLContextProviderGLX
#endif
#if defined(ANDROID) || defined(XP_WIN)
#define GL_CONTEXT_PROVIDER_NAME GLContextProviderEGL
#include "GLContextProviderImpl.h"
#undef GL_CONTEXT_PROVIDER_NAME
#ifndef GL_CONTEXT_PROVIDER_DEFAULT
#define GL_CONTEXT_PROVIDER_DEFAULT GLContextProviderEGL
#endif
#define GL_CONTEXT_PROVIDER_DEFAULT GLContextProviderEGL
#endif
#ifdef MOZ_GL_PROVIDER
#define GL_CONTEXT_PROVIDER_NAME MOZ_GL_PROVIDER
#include "GLContextProviderImpl.h"
#undef GL_CONTEXT_PROVIDER_NAME
#define GL_CONTEXT_PROVIDER_DEFAULT MOZ_GL_PROVIDER
#endif
#if defined(MOZ_X11) && !defined(GL_CONTEXT_PROVIDER_DEFAULT)
#define GL_CONTEXT_PROVIDER_NAME GLContextProviderGLX
#include "GLContextProviderImpl.h"
#undef GL_CONTEXT_PROVIDER_NAME
#define GL_CONTEXT_PROVIDER_DEFAULT GLContextProviderGLX
#define GL_CONTEXT_PROVIDER_NAME MOZ_GL_PROVIDER
#include "GLContextProviderImpl.h"
#undef GL_CONTEXT_PROVIDER_NAME
#define GL_CONTEXT_PROVIDER_DEFAULT MOZ_GL_PROVIDER
#endif
#ifdef GL_CONTEXT_PROVIDER_DEFAULT
typedef GL_CONTEXT_PROVIDER_DEFAULT GLContextProvider;
typedef GL_CONTEXT_PROVIDER_DEFAULT GLContextProvider;
#else
typedef GLContextProviderNull GLContextProvider;
typedef GLContextProviderNull GLContextProvider;
#endif
#undef IN_GL_CONTEXT_PROVIDER_H

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

@ -317,16 +317,17 @@ GLContextProviderCGL::CreateHeadless(CreateContextFlags flags)
already_AddRefed<GLContext>
GLContextProviderCGL::CreateOffscreen(const IntSize& size,
const SurfaceCaps& caps,
const SurfaceCaps& minCaps,
CreateContextFlags flags)
{
nsRefPtr<GLContext> glContext = CreateHeadless(flags);
if (!glContext->InitOffscreen(size, caps)) {
NS_WARNING("Failed during InitOffscreen.");
RefPtr<GLContext> gl = CreateHeadless(flags);
if (!gl)
return nullptr;
}
return glContext.forget();
if (!gl->InitOffscreen(size, minCaps))
return nullptr;
return gl.forget();
}
static nsRefPtr<GLContext> gGlobalContext;

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

@ -3,116 +3,108 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "mozilla/ArrayUtils.h"
#include "GLContextEGL.h"
#if defined(MOZ_WIDGET_GTK)
#include <gdk/gdkx.h>
// we're using default display for now
#define GET_NATIVE_WINDOW(aWidget) ((EGLNativeWindowType)GDK_WINDOW_XID((GdkWindow*)aWidget->GetNativeData(NS_NATIVE_WINDOW)))
#elif defined(MOZ_WIDGET_QT)
#define GET_NATIVE_WINDOW(aWidget) ((EGLNativeWindowType)aWidget->GetNativeData(NS_NATIVE_SHAREABLE_WINDOW))
#else
#define GET_NATIVE_WINDOW(aWidget) ((EGLNativeWindowType)aWidget->GetNativeData(NS_NATIVE_WINDOW))
#endif
#if defined(XP_UNIX)
#ifdef MOZ_WIDGET_GONK
#include "libdisplay/GonkDisplay.h"
#include "nsWindow.h"
#include "nsScreenManagerGonk.h"
#endif
#ifdef MOZ_WIDGET_GTK
#include <gdk/gdkx.h>
// we're using default display for now
#define GET_NATIVE_WINDOW(aWidget) (EGLNativeWindowType)GDK_WINDOW_XID((GdkWindow *) aWidget->GetNativeData(NS_NATIVE_WINDOW))
#elif defined(MOZ_WIDGET_QT)
#define GET_NATIVE_WINDOW(aWidget) (EGLNativeWindowType)(aWidget->GetNativeData(NS_NATIVE_SHAREABLE_WINDOW))
#elif defined(MOZ_WIDGET_GONK)
#define GET_NATIVE_WINDOW(aWidget) ((EGLNativeWindowType)aWidget->GetNativeData(NS_NATIVE_WINDOW))
#include "libdisplay/GonkDisplay.h"
#include "nsWindow.h"
#include "nsScreenManagerGonk.h"
#endif
#ifdef ANDROID
/* from widget */
#ifdef MOZ_WIDGET_ANDROID
#include "AndroidBridge.h"
#endif
#if defined(ANDROID)
/* from widget */
#if defined(MOZ_WIDGET_ANDROID)
#include "AndroidBridge.h"
#endif
#include <android/log.h>
#define LOG(args...) __android_log_print(ANDROID_LOG_INFO, "Gonk" , ## args)
#include <android/log.h>
#define LOG(args...) __android_log_print(ANDROID_LOG_INFO, "Gonk" , ## args)
#ifdef MOZ_WIDGET_GONK
#include "cutils/properties.h"
#include <ui/GraphicBuffer.h>
# if defined(MOZ_WIDGET_GONK)
# include "cutils/properties.h"
# include <ui/GraphicBuffer.h>
using namespace android;
#endif
#endif
using namespace android;
# endif
#endif
#define GLES2_LIB "libGLESv2.so"
#define GLES2_LIB2 "libGLESv2.so.2"
#define GLES2_LIB "libGLESv2.so"
#define GLES2_LIB2 "libGLESv2.so.2"
#elif defined(XP_WIN)
#include "nsIFile.h"
#include "nsIFile.h"
#define GLES2_LIB "libGLESv2.dll"
#define GLES2_LIB "libGLESv2.dll"
#ifndef WIN32_LEAN_AND_MEAN
#define WIN32_LEAN_AND_MEAN 1
#endif
#ifndef WIN32_LEAN_AND_MEAN
#define WIN32_LEAN_AND_MEAN 1
#endif
#include <windows.h>
#include <windows.h>
// a little helper
class AutoDestroyHWND {
public:
AutoDestroyHWND(HWND aWnd = nullptr)
: mWnd(aWnd)
{
}
~AutoDestroyHWND() {
if (mWnd) {
::DestroyWindow(mWnd);
// a little helper
class AutoDestroyHWND {
public:
AutoDestroyHWND(HWND aWnd = nullptr)
: mWnd(aWnd)
{
}
}
operator HWND() {
return mWnd;
}
HWND forget() {
HWND w = mWnd;
mWnd = nullptr;
return w;
}
HWND operator=(HWND aWnd) {
if (mWnd && mWnd != aWnd) {
::DestroyWindow(mWnd);
~AutoDestroyHWND() {
if (mWnd) {
::DestroyWindow(mWnd);
}
}
mWnd = aWnd;
return mWnd;
}
HWND mWnd;
};
operator HWND() {
return mWnd;
}
HWND forget() {
HWND w = mWnd;
mWnd = nullptr;
return w;
}
HWND operator=(HWND aWnd) {
if (mWnd && mWnd != aWnd) {
::DestroyWindow(mWnd);
}
mWnd = aWnd;
return mWnd;
}
HWND mWnd;
};
#else
#error "Platform not recognized"
#error "Platform not recognized"
#endif
#include "mozilla/Preferences.h"
#include "gfxUtils.h"
#include "gfxFailure.h"
#include "gfxASurface.h"
#include "gfxCrashReporterUtils.h"
#include "gfxFailure.h"
#include "gfxPlatform.h"
#include "gfxUtils.h"
#include "GLBlitHelper.h"
#include "GLContextEGL.h"
#include "GLContextProvider.h"
#include "GLLibraryEGL.h"
#include "TextureImageEGL.h"
#include "mozilla/ArrayUtils.h"
#include "mozilla/Preferences.h"
#include "nsDebug.h"
#include "nsThreadUtils.h"
#include "nsIWidget.h"
#include "gfxCrashReporterUtils.h"
#include "nsThreadUtils.h"
#include "ScopedGLHelpers.h"
#include "GLBlitHelper.h"
#include "TextureImageEGL.h"
using namespace mozilla::gfx;
@ -190,18 +182,16 @@ DestroySurface(EGLSurface oldSurface) {
static EGLSurface
CreateSurfaceForWindow(nsIWidget* widget, const EGLConfig& config) {
EGLSurface newSurface = EGL_NO_SURFACE;
EGLSurface newSurface = nullptr;
#ifdef MOZ_WIDGET_ANDROID
#ifdef MOZ_WIDGET_ANDROID
mozilla::AndroidBridge::Bridge()->RegisterCompositor();
newSurface = mozilla::AndroidBridge::Bridge()->CreateEGLSurfaceForCompositor();
if (newSurface == EGL_NO_SURFACE) {
return EGL_NO_SURFACE;
}
#else
#else
MOZ_ASSERT(widget != nullptr);
newSurface = sEGLLibrary.fCreateWindowSurface(EGL_DISPLAY(), config, GET_NATIVE_WINDOW(widget), 0);
#endif
newSurface = sEGLLibrary.fCreateWindowSurface(EGL_DISPLAY(), config,
GET_NATIVE_WINDOW(widget), 0);
#endif
return newSurface;
}
@ -215,8 +205,8 @@ GLContextEGL::GLContextEGL(
: GLContext(caps, shareContext, isOffscreen)
, mConfig(config)
, mSurface(surface)
, mSurfaceOverride(EGL_NO_SURFACE)
, mContext(context)
, mSurfaceOverride(EGL_NO_SURFACE)
, mThebesSurface(nullptr)
, mBound(false)
, mIsPBuffer(false)
@ -425,7 +415,7 @@ GLContextEGL::RenewSurface() {
// If we get here, then by definition we know that we want to get a new surface.
ReleaseSurface();
mSurface = mozilla::gl::CreateSurfaceForWindow(nullptr, mConfig); // the nullptr here is where we assume Android.
if (mSurface == EGL_NO_SURFACE) {
if (!mSurface) {
return false;
}
return MakeCurrent(true);
@ -490,6 +480,10 @@ GLContextEGL::CreateSurfaceForWindow(nsIWidget* aWidget)
}
EGLSurface surface = mozilla::gl::CreateSurfaceForWindow(aWidget, config);
if (!surface) {
MOZ_CRASH("Failed to create EGLSurface for window!\n");
return nullptr;
}
return surface;
}
@ -780,8 +774,7 @@ GLContextProviderEGL::CreateForWindow(nsIWidget *aWidget)
}
EGLSurface surface = mozilla::gl::CreateSurfaceForWindow(aWidget, config);
if (surface == EGL_NO_SURFACE) {
if (!surface) {
MOZ_CRASH("Failed to create EGLSurface!\n");
return nullptr;
}
@ -839,60 +832,144 @@ GLContextProviderEGL::DestroyEGLSurface(EGLSurface surface)
}
#endif // defined(ANDROID)
already_AddRefed<GLContextEGL>
GLContextEGL::CreateEGLPBufferOffscreenContext(const mozilla::gfx::IntSize& size)
static void
FillContextAttribs(bool alpha, bool depth, bool stencil, bool bpp16,
nsTArray<EGLint>* out)
{
EGLConfig config;
EGLSurface surface;
out->AppendElement(LOCAL_EGL_SURFACE_TYPE);
out->AppendElement(LOCAL_EGL_PBUFFER_BIT);
const EGLint numConfigs = 1; // We only need one.
EGLConfig configs[numConfigs];
out->AppendElement(LOCAL_EGL_RENDERABLE_TYPE);
out->AppendElement(LOCAL_EGL_OPENGL_ES2_BIT);
out->AppendElement(LOCAL_EGL_RED_SIZE);
if (bpp16) {
out->AppendElement(alpha ? 4 : 5);
} else {
out->AppendElement(8);
}
out->AppendElement(LOCAL_EGL_GREEN_SIZE);
if (bpp16) {
out->AppendElement(alpha ? 4 : 6);
} else {
out->AppendElement(8);
}
out->AppendElement(LOCAL_EGL_BLUE_SIZE);
if (bpp16) {
out->AppendElement(alpha ? 4 : 5);
} else {
out->AppendElement(8);
}
out->AppendElement(LOCAL_EGL_ALPHA_SIZE);
if (alpha) {
out->AppendElement(bpp16 ? 4 : 8);
} else {
out->AppendElement(0);
}
out->AppendElement(LOCAL_EGL_DEPTH_SIZE);
out->AppendElement(depth ? 16 : 0);
out->AppendElement(LOCAL_EGL_STENCIL_SIZE);
out->AppendElement(stencil ? 8 : 0);
// EGL_ATTRIBS_LIST_SAFE_TERMINATION_WORKING_AROUND_BUGS
out->AppendElement(LOCAL_EGL_NONE);
out->AppendElement(0);
out->AppendElement(0);
out->AppendElement(0);
}
static GLint
GetAttrib(GLLibraryEGL* egl, EGLConfig config, EGLint attrib)
{
EGLint bits = 0;
egl->fGetConfigAttrib(egl->Display(), config, attrib, &bits);
MOZ_ASSERT(egl->fGetError() == LOCAL_EGL_SUCCESS);
return bits;
}
static EGLConfig
ChooseConfig(GLLibraryEGL* egl, const SurfaceCaps& minCaps,
SurfaceCaps* const out_configCaps)
{
nsTArray<EGLint> configAttribList;
FillContextAttribs(minCaps.alpha, minCaps.depth, minCaps.stencil, minCaps.bpp16,
&configAttribList);
const EGLint* configAttribs = configAttribList.Elements();
// We're guaranteed to get at least minCaps, and the sorting dictated by the spec for
// eglChooseConfig reasonably assures that a reasonable 'best' config is on top.
const EGLint kMaxConfigs = 1;
EGLConfig configs[kMaxConfigs];
EGLint foundConfigs = 0;
if (!sEGLLibrary.fChooseConfig(EGL_DISPLAY(),
kEGLConfigAttribsOffscreenPBuffer,
configs, numConfigs,
&foundConfigs)
if (!egl->fChooseConfig(egl->Display(), configAttribs, configs, kMaxConfigs,
&foundConfigs)
|| foundConfigs == 0)
{
NS_WARNING("No EGL Config for minimal PBuffer!");
return EGL_NO_CONFIG;
}
EGLConfig config = configs[0];
*out_configCaps = minCaps; // Pick up any preserve, etc.
out_configCaps->color = true;
out_configCaps->alpha = bool(GetAttrib(egl, config, LOCAL_EGL_ALPHA_SIZE));
out_configCaps->depth = bool(GetAttrib(egl, config, LOCAL_EGL_DEPTH_SIZE));
out_configCaps->stencil = bool(GetAttrib(egl, config, LOCAL_EGL_STENCIL_SIZE));
out_configCaps->bpp16 = (GetAttrib(egl, config, LOCAL_EGL_RED_SIZE) < 8);
return config;
}
/*static*/ already_AddRefed<GLContextEGL>
GLContextEGL::CreateEGLPBufferOffscreenContext(const mozilla::gfx::IntSize& size,
const SurfaceCaps& minCaps)
{
SurfaceCaps configCaps;
EGLConfig config = ChooseConfig(&sEGLLibrary, minCaps, &configCaps);
if (config == EGL_NO_CONFIG) {
NS_WARNING("Failed to find a compatible config.");
return nullptr;
}
// We absolutely don't care, so just pick the first one.
config = configs[0];
if (GLContext::ShouldSpew())
sEGLLibrary.DumpEGLConfig(config);
mozilla::gfx::IntSize pbSize(size);
surface = GLContextEGL::CreatePBufferSurfaceTryingPowerOfTwo(config,
LOCAL_EGL_NONE,
pbSize);
EGLSurface surface = GLContextEGL::CreatePBufferSurfaceTryingPowerOfTwo(config,
LOCAL_EGL_NONE,
pbSize);
if (!surface) {
NS_WARNING("Failed to create PBuffer for context!");
return nullptr;
}
SurfaceCaps dummyCaps = SurfaceCaps::Any();
nsRefPtr<GLContextEGL> glContext =
GLContextEGL::CreateGLContext(dummyCaps,
nullptr, true,
config, surface);
if (!glContext) {
RefPtr<GLContextEGL> gl = GLContextEGL::CreateGLContext(configCaps, nullptr, true,
config, surface);
if (!gl) {
NS_WARNING("Failed to create GLContext from PBuffer");
sEGLLibrary.fDestroySurface(EGL_DISPLAY(), surface);
sEGLLibrary.fDestroySurface(sEGLLibrary.Display(), surface);
return nullptr;
}
if (!glContext->Init()) {
if (!gl->Init()) {
NS_WARNING("Failed to initialize GLContext!");
// GLContextEGL::dtor will destroy |surface| for us.
return nullptr;
}
return glContext.forget();
return gl.forget();
}
already_AddRefed<GLContextEGL>
/*static*/ already_AddRefed<GLContextEGL>
GLContextEGL::CreateEGLPixmapOffscreenContext(const mozilla::gfx::IntSize& size)
{
gfxASurface *thebesSurface = nullptr;
@ -932,49 +1009,77 @@ GLContextEGL::CreateEGLPixmapOffscreenContext(const mozilla::gfx::IntSize& size)
return glContext.forget();
}
already_AddRefed<GLContext>
/*static*/ already_AddRefed<GLContext>
GLContextProviderEGL::CreateHeadless(CreateContextFlags flags)
{
if (!sEGLLibrary.EnsureInitialized(bool(flags & CreateContextFlags::FORCE_ENABLE_HARDWARE))) {
bool forceEnableHardware = bool(flags & CreateContextFlags::FORCE_ENABLE_HARDWARE);
if (!sEGLLibrary.EnsureInitialized(forceEnableHardware))
return nullptr;
}
mozilla::gfx::IntSize dummySize = mozilla::gfx::IntSize(16, 16);
nsRefPtr<GLContext> glContext;
glContext = GLContextEGL::CreateEGLPBufferOffscreenContext(dummySize);
if (!glContext)
return nullptr;
return glContext.forget();
SurfaceCaps dummyCaps = SurfaceCaps::Any();
return GLContextEGL::CreateEGLPBufferOffscreenContext(dummySize, dummyCaps);
}
// Under EGL, on Android, pbuffers are supported fine, though
// often without the ability to texture from them directly.
already_AddRefed<GLContext>
/*static*/ already_AddRefed<GLContext>
GLContextProviderEGL::CreateOffscreen(const mozilla::gfx::IntSize& size,
const SurfaceCaps& caps,
const SurfaceCaps& minCaps,
CreateContextFlags flags)
{
nsRefPtr<GLContext> glContext = CreateHeadless(flags);
if (!glContext)
bool forceEnableHardware = bool(flags & CreateContextFlags::FORCE_ENABLE_HARDWARE);
if (!sEGLLibrary.EnsureInitialized(forceEnableHardware))
return nullptr;
if (!glContext->InitOffscreen(size, caps))
bool canOffscreenUseHeadless = true;
if (sEGLLibrary.IsANGLE()) {
// ANGLE needs to use PBuffers.
canOffscreenUseHeadless = false;
}
RefPtr<GLContext> gl;
SurfaceCaps offscreenCaps = minCaps;
if (canOffscreenUseHeadless) {
gl = CreateHeadless(flags);
if (!gl)
return nullptr;
} else {
SurfaceCaps minBackbufferCaps = minCaps;
if (minCaps.antialias) {
minBackbufferCaps.antialias = false;
minBackbufferCaps.depth = false;
minBackbufferCaps.stencil = false;
}
gl = GLContextEGL::CreateEGLPBufferOffscreenContext(size, minBackbufferCaps);
if (!gl)
return nullptr;
offscreenCaps = gl->Caps();
if (minCaps.antialias) {
offscreenCaps.depth = minCaps.depth;
offscreenCaps.stencil = minCaps.stencil;
}
}
if (!gl->InitOffscreen(size, offscreenCaps))
return nullptr;
return glContext.forget();
return gl.forget();
}
// Don't want a global context on Android as 1) share groups across 2 threads fail on many Tegra drivers (bug 759225)
// and 2) some mobile devices have a very strict limit on global number of GL contexts (bug 754257)
// and 3) each EGL context eats 750k on B2G (bug 813783)
GLContext*
/*static*/ GLContext*
GLContextProviderEGL::GetGlobalContext()
{
return nullptr;
}
void
/*static*/ void
GLContextProviderEGL::Shutdown()
{
}

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

@ -1130,75 +1130,96 @@ GLContextProviderGLX::CreateForWindow(nsIWidget *aWidget)
return glContext.forget();
}
static already_AddRefed<GLContextGLX>
CreateOffscreenPixmapContext(const IntSize& size)
static bool
ChooseConfig(GLXLibrary* glx, Display* display, int screen, const SurfaceCaps& minCaps,
ScopedXFree<GLXFBConfig>* const out_scopedConfigArr,
GLXFBConfig* const out_config, int* const out_visid)
{
GLXLibrary& glx = sGLXLibrary;
if (!glx.EnsureInitialized()) {
return nullptr;
}
ScopedXFree<GLXFBConfig>& scopedConfigArr = *out_scopedConfigArr;
Display *display = DefaultXDisplay();
int xscreen = DefaultScreen(display);
if (minCaps.antialias)
return false;
int attribs[] = {
LOCAL_GLX_DRAWABLE_TYPE, LOCAL_GLX_PIXMAP_BIT,
LOCAL_GLX_X_RENDERABLE, True,
LOCAL_GLX_RED_SIZE, 8,
LOCAL_GLX_GREEN_SIZE, 8,
LOCAL_GLX_BLUE_SIZE, 8,
LOCAL_GLX_ALPHA_SIZE, minCaps.alpha ? 8 : 0,
LOCAL_GLX_DEPTH_SIZE, minCaps.depth ? 16 : 0,
LOCAL_GLX_STENCIL_SIZE, minCaps.stencil ? 8 : 0,
0
};
int numConfigs = 0;
scopedConfigArr = glx->xChooseFBConfig(display, screen, attribs, &numConfigs);
if (!scopedConfigArr || !numConfigs)
return false;
ScopedXFree<GLXFBConfig> cfgs;
cfgs = glx.xChooseFBConfig(display,
xscreen,
attribs,
&numConfigs);
if (!cfgs) {
return nullptr;
}
// Issues with glxChooseFBConfig selection and sorting:
// * ALPHA_SIZE is sorted as 'largest total RGBA bits first'. If we don't request
// alpha bits, we'll probably get RGBA anyways, since 32 is more than 24.
// * DEPTH_SIZE is sorted largest first, including for `0` inputs.
// * STENCIL_SIZE is smallest first, but it might return `8` even though we ask for
// `0`.
MOZ_ASSERT(numConfigs > 0,
"glXChooseFBConfig() failed to match our requested format and "
"violated its spec!");
int visid = None;
int chosenIndex = 0;
// For now, we don't care about these. We *will* care when we do XPixmap sharing.
for (int i = 0; i < numConfigs; ++i) {
int dtype;
GLXFBConfig curConfig = scopedConfigArr[i];
if (glx.xGetFBConfigAttrib(display, cfgs[i], LOCAL_GLX_DRAWABLE_TYPE, &dtype) != Success
|| !(dtype & LOCAL_GLX_PIXMAP_BIT))
{
continue;
}
if (glx.xGetFBConfigAttrib(display, cfgs[i], LOCAL_GLX_VISUAL_ID, &visid) != Success
|| visid == 0)
int visid;
if (glx->xGetFBConfigAttrib(display, curConfig, LOCAL_GLX_VISUAL_ID, &visid)
!= Success)
{
continue;
}
chosenIndex = i;
break;
if (!visid)
continue;
*out_config = curConfig;
*out_visid = visid;
return true;
}
if (!visid) {
NS_WARNING("glXChooseFBConfig() didn't give us any configs with visuals!");
return false;
}
static already_AddRefed<GLContextGLX>
CreateOffscreenPixmapContext(const IntSize& size, const SurfaceCaps& minCaps)
{
GLXLibrary* glx = &sGLXLibrary;
if (!glx->EnsureInitialized())
return nullptr;
Display* display = DefaultXDisplay();
int screen = DefaultScreen(display);
ScopedXFree<GLXFBConfig> scopedConfigArr;
GLXFBConfig config;
int visid;
if (!ChooseConfig(glx, display, screen, minCaps, &scopedConfigArr, &config, &visid)) {
NS_WARNING("Failed to find a compatible config.");
return nullptr;
}
Visual *visual;
Visual* visual;
int depth;
FindVisualAndDepth(display, visid, &visual, &depth);
ScopedXErrorHandler xErrorHandler;
GLXPixmap glxpixmap = 0;
bool error = false;
IntSize dummySize(16, 16);
nsRefPtr<gfxXlibSurface> xsurface = gfxXlibSurface::Create(DefaultScreenOfDisplay(display),
visual,
dummySize);
if (xsurface->CairoStatus() != 0) {
ScopedXErrorHandler xErrorHandler;
bool error = false;
// Must be declared before goto:
Drawable drawable;
GLXPixmap pixmap;
gfx::IntSize dummySize(16, 16);
RefPtr<gfxXlibSurface> surface = gfxXlibSurface::Create(DefaultScreenOfDisplay(display),
visual,
dummySize);
if (surface->CairoStatus() != 0) {
error = true;
goto DONE_CREATING_PIXMAP;
}
@ -1206,73 +1227,60 @@ CreateOffscreenPixmapContext(const IntSize& size)
// Handle slightly different signature between glXCreatePixmap and
// its pre-GLX-1.3 extension equivalent (though given the ABI, we
// might not need to).
if (glx.GLXVersionCheck(1, 3)) {
glxpixmap = glx.xCreatePixmap(display,
cfgs[chosenIndex],
xsurface->XDrawable(),
nullptr);
drawable = surface->XDrawable();
if (glx->GLXVersionCheck(1, 3)) {
pixmap = glx->xCreatePixmap(display, config, drawable, nullptr);
} else {
glxpixmap = glx.xCreateGLXPixmapWithConfig(display,
cfgs[chosenIndex],
xsurface->
XDrawable());
pixmap = glx->xCreateGLXPixmapWithConfig(display, config, drawable);
}
if (glxpixmap == 0) {
if (pixmap == 0) {
error = true;
}
DONE_CREATING_PIXMAP:
nsRefPtr<GLContextGLX> glContext;
bool serverError = xErrorHandler.SyncAndGetError(display);
if (error || serverError)
return nullptr;
if (!error && // earlier recorded error
!serverError)
{
// We might have an alpha channel, but it doesn't matter.
SurfaceCaps dummyCaps = SurfaceCaps::Any();
GLContextGLX* shareContext = GetGlobalContextGLX();
glContext = GLContextGLX::CreateGLContext(dummyCaps,
shareContext,
true,
display,
glxpixmap,
cfgs[chosenIndex],
true,
xsurface);
}
return glContext.forget();
GLContextGLX* shareContext = GetGlobalContextGLX();
return GLContextGLX::CreateGLContext(minCaps, shareContext, true, display, pixmap,
config, true, surface);
}
already_AddRefed<GLContext>
/*static*/ already_AddRefed<GLContext>
GLContextProviderGLX::CreateHeadless(CreateContextFlags)
{
IntSize dummySize = IntSize(16, 16);
nsRefPtr<GLContext> glContext = CreateOffscreenPixmapContext(dummySize);
if (!glContext)
return nullptr;
return glContext.forget();
SurfaceCaps dummyCaps = SurfaceCaps::Any();
return CreateOffscreenPixmapContext(dummySize, dummyCaps);
}
already_AddRefed<GLContext>
/*static*/ already_AddRefed<GLContext>
GLContextProviderGLX::CreateOffscreen(const IntSize& size,
const SurfaceCaps& caps,
const SurfaceCaps& minCaps,
CreateContextFlags flags)
{
nsRefPtr<GLContext> glContext = CreateHeadless(flags);
if (!glContext)
SurfaceCaps minBackbufferCaps = minCaps;
if (minCaps.antialias) {
minBackbufferCaps.antialias = false;
minBackbufferCaps.depth = false;
minBackbufferCaps.stencil = false;
}
RefPtr<GLContext> gl;
gl = CreateOffscreenPixmapContext(size, minBackbufferCaps);
if (!gl)
return nullptr;
if (!glContext->InitOffscreen(size, caps))
if (!gl->InitOffscreen(size, minCaps))
return nullptr;
return glContext.forget();
return gl.forget();
}
GLContext*
/*static*/ GLContext*
GLContextProviderGLX::GetGlobalContext()
{
static bool checkedContextSharing = false;
@ -1293,17 +1301,19 @@ GLContextProviderGLX::GetGlobalContext()
triedToCreateContext = true;
IntSize dummySize = IntSize(16, 16);
SurfaceCaps dummyCaps = SurfaceCaps::Any();
// StaticPtr doesn't support assignments from already_AddRefed,
// so use a temporary nsRefPtr to make the reference counting
// fall out correctly.
nsRefPtr<GLContext> holder = CreateOffscreenPixmapContext(dummySize);
RefPtr<GLContext> holder;
holder = CreateOffscreenPixmapContext(dummySize, dummyCaps);
gGlobalContext = holder;
}
return gGlobalContext;
}
void
/*static*/ void
GLContextProviderGLX::Shutdown()
{
gGlobalContext = nullptr;

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

@ -54,16 +54,18 @@ public:
* resource sharing can be avoided on the target platform, it will
* be, in order to isolate the offscreen context.
*
* @param size The initial size of this offscreen context.
* @param caps The SurfaceCaps for this offscreen context.
* @param flags The set of CreateContextFlags to be used for this
* offscreen context.
* @param size The initial size of this offscreen context.
* @param minCaps The required SurfaceCaps for this offscreen context. The resulting
* context *may* have more/better caps than requested, but it cannot
* have fewer/worse caps than requested.
* @param flags The set of CreateContextFlags to be used for this
* offscreen context.
*
* @return Context to use for offscreen rendering
*/
static already_AddRefed<GLContext>
CreateOffscreen(const mozilla::gfx::IntSize& size,
const SurfaceCaps& caps,
const SurfaceCaps& minCaps,
CreateContextFlags flags);
// Just create a context. We'll add offscreen stuff ourselves.

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

@ -606,7 +606,7 @@ CreateWindowOffscreenContext()
return glContext.forget();
}
already_AddRefed<GLContext>
/*static*/ already_AddRefed<GLContext>
GLContextProviderWGL::CreateHeadless(CreateContextFlags)
{
if (!sWGLLib.EnsureInitialized()) {
@ -639,24 +639,24 @@ GLContextProviderWGL::CreateHeadless(CreateContextFlags)
return retGL.forget();
}
already_AddRefed<GLContext>
/*static*/ already_AddRefed<GLContext>
GLContextProviderWGL::CreateOffscreen(const IntSize& size,
const SurfaceCaps& caps,
const SurfaceCaps& minCaps,
CreateContextFlags flags)
{
nsRefPtr<GLContext> glContext = CreateHeadless(flags);
if (!glContext)
RefPtr<GLContext> gl = CreateHeadless(flags);
if (!gl)
return nullptr;
if (!glContext->InitOffscreen(size, caps))
if (!gl->InitOffscreen(size, minCaps))
return nullptr;
return glContext.forget();
return gl.forget();
}
static nsRefPtr<GLContextWGL> gGlobalContext;
GLContext *
/*static*/ GLContext*
GLContextProviderWGL::GetGlobalContext()
{
if (!sWGLLib.EnsureInitialized()) {
@ -684,7 +684,7 @@ GLContextProviderWGL::GetGlobalContext()
return static_cast<GLContext*>(gGlobalContext);
}
void
/*static*/ void
GLContextProviderWGL::Shutdown()
{
gGlobalContext = nullptr;

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

@ -7,6 +7,7 @@
#define GLCONTEXT_TYPES_H_
#include "GLTypes.h"
#include "mozilla/TypedEnumBits.h"
namespace mozilla {
namespace gl {
@ -43,6 +44,16 @@ struct GLFormats
GLsizei samples;
};
enum class CreateContextFlags : int8_t {
NONE = 0,
REQUIRE_COMPAT_PROFILE = 1 << 0,
// Force the use of hardware backed GL, don't allow software implementations.
FORCE_ENABLE_HARDWARE = 1 << 1,
/* Don't force discrete GPU to be used (if applicable) */
ALLOW_OFFLINE_RENDERER = 1 << 2,
};
MOZ_MAKE_ENUM_CLASS_BITWISE_OPERATORS(CreateContextFlags)
} /* namespace gl */
} /* namespace mozilla */

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

@ -17,40 +17,32 @@
#include <bitset>
#include <vector>
#if defined(XP_WIN)
#ifdef XP_WIN
#ifndef WIN32_LEAN_AND_MEAN
#define WIN32_LEAN_AND_MEAN 1
#endif
#ifndef WIN32_LEAN_AND_MEAN
#define WIN32_LEAN_AND_MEAN 1
#endif
#include <windows.h>
typedef HDC EGLNativeDisplayType;
typedef HBITMAP EGLNativePixmapType;
typedef HWND EGLNativeWindowType;
#define GET_NATIVE_WINDOW(aWidget) ((EGLNativeWindowType)aWidget->GetNativeData(NS_NATIVE_WINDOW))
#include <windows.h>
typedef HDC EGLNativeDisplayType;
typedef HBITMAP EGLNativePixmapType;
typedef HWND EGLNativeWindowType;
#else
typedef void *EGLNativeDisplayType;
typedef void *EGLNativePixmapType;
typedef void *EGLNativeWindowType;
typedef void* EGLNativeDisplayType;
typedef void* EGLNativePixmapType;
typedef void* EGLNativeWindowType;
#ifdef ANDROID
// We only need to explicitly dlopen egltrace
// on android as we can use LD_PRELOAD or other tricks
// on other platforms. We look for it in /data/local
// as that's writeable by all users
//
// This should really go in GLLibraryEGL.cpp but we currently reference
// APITRACE_LIB in GLContextProviderEGL.cpp. Further refactoring
// will come in subsequent patches on Bug 732865
#define APITRACE_LIB "/data/local/tmp/egltrace.so"
#ifdef MOZ_WIDGET_ANDROID
#endif // MOZ_WIDGET_ANDROID
#endif // ANDROID
#ifdef ANDROID
// We only need to explicitly dlopen egltrace
// on android as we can use LD_PRELOAD or other tricks
// on other platforms. We look for it in /data/local
// as that's writeable by all users
//
// This should really go in GLLibraryEGL.cpp but we currently reference
// APITRACE_LIB in GLContextProviderEGL.cpp. Further refactoring
// will come in subsequent patches on Bug 732865
#define APITRACE_LIB "/data/local/tmp/egltrace.so"
#endif
#endif
#if defined(MOZ_X11)

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

@ -486,9 +486,16 @@ GLScreenBuffer::Swap(const gfx::IntSize& size)
//uint32_t srcPixel = ReadPixel(src);
//uint32_t destPixel = ReadPixel(dest);
//printf_stderr("Before: src: 0x%08x, dest: 0x%08x\n", srcPixel, destPixel);
#ifdef DEBUG
GLContext::LocalErrorScope errorScope(*mGL);
#endif
SharedSurface::ProdCopy(src, dest, mFactory.get());
#ifdef DEBUG
MOZ_ASSERT(!errorScope.GetError());
#endif
//srcPixel = ReadPixel(src);
//destPixel = ReadPixel(dest);
//printf_stderr("After: src: 0x%08x, dest: 0x%08x\n", srcPixel, destPixel);

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

@ -21,6 +21,7 @@ typedef XID GLXContextID;
typedef XID GLXWindow;
typedef XID GLXPbuffer;
// end of stuff from glx.h
#include "prenv.h"
struct PRLibrary;
class gfxASurface;
@ -108,6 +109,12 @@ public:
bool SupportsTextureFromPixmap(gfxASurface* aSurface);
bool IsATI() { return mIsATI; }
bool GLXVersionCheck(int aMajor, int aMinor);
bool UseSurfaceSharing() {
// Disable surface sharing due to issues with compatible FBConfigs on
// NVIDIA drivers as described in bug 1193015.
static bool useSharing = PR_GetEnv("MOZ_GLX_USE_SURFACE_SHARING");
return mUseTextureFromPixmap && useSharing;
}
private:

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

@ -41,17 +41,14 @@ CreatePBufferSurface(GLLibraryEGL* egl,
}
/*static*/ UniquePtr<SharedSurface_ANGLEShareHandle>
SharedSurface_ANGLEShareHandle::Create(GLContext* gl,
EGLContext context, EGLConfig config,
SharedSurface_ANGLEShareHandle::Create(GLContext* gl, EGLConfig config,
const gfx::IntSize& size, bool hasAlpha)
{
GLLibraryEGL* egl = &sEGLLibrary;
MOZ_ASSERT(egl);
MOZ_ASSERT(egl->IsExtensionSupported(
GLLibraryEGL::ANGLE_surface_d3d_texture_2d_share_handle));
if (!context || !config)
return nullptr;
MOZ_ASSERT(config);
EGLDisplay display = egl->Display();
EGLSurface pbuffer = CreatePBufferSurface(egl, display, config, size);
@ -82,8 +79,8 @@ SharedSurface_ANGLEShareHandle::Create(GLContext* gl,
}
typedef SharedSurface_ANGLEShareHandle ptrT;
UniquePtr<ptrT> ret( new ptrT(gl, egl, size, hasAlpha, context,
pbuffer, shareHandle, keyedMutex, fence) );
UniquePtr<ptrT> ret( new ptrT(gl, egl, size, hasAlpha, pbuffer, shareHandle,
keyedMutex, fence) );
return Move(ret);
}
@ -97,7 +94,6 @@ SharedSurface_ANGLEShareHandle::SharedSurface_ANGLEShareHandle(GLContext* gl,
GLLibraryEGL* egl,
const gfx::IntSize& size,
bool hasAlpha,
EGLContext context,
EGLSurface pbuffer,
HANDLE shareHandle,
const RefPtr<IDXGIKeyedMutex>& keyedMutex,
@ -109,7 +105,6 @@ SharedSurface_ANGLEShareHandle::SharedSurface_ANGLEShareHandle(GLContext* gl,
hasAlpha,
true)
, mEGL(egl)
, mContext(context)
, mPBuffer(pbuffer)
, mShareHandle(shareHandle)
, mKeyedMutex(keyedMutex)
@ -281,137 +276,6 @@ SharedSurface_ANGLEShareHandle::ToSurfaceDescriptor(layers::SurfaceDescriptor* c
////////////////////////////////////////////////////////////////////////////////
// Factory
static void
FillPBufferAttribs_ByBits(nsTArray<EGLint>& aAttrs,
int redBits, int greenBits,
int blueBits, int alphaBits,
int depthBits, int stencilBits)
{
aAttrs.Clear();
#if defined(A1) || defined(A2)
#error The temp-macro names we want are already defined.
#endif
#define A1(_x) do { aAttrs.AppendElement(_x); } while (0)
#define A2(_x,_y) do { A1(_x); A1(_y); } while (0)
A2(LOCAL_EGL_RENDERABLE_TYPE, LOCAL_EGL_OPENGL_ES2_BIT);
A2(LOCAL_EGL_SURFACE_TYPE, LOCAL_EGL_PBUFFER_BIT);
A2(LOCAL_EGL_RED_SIZE, redBits);
A2(LOCAL_EGL_GREEN_SIZE, greenBits);
A2(LOCAL_EGL_BLUE_SIZE, blueBits);
A2(LOCAL_EGL_ALPHA_SIZE, alphaBits);
A2(LOCAL_EGL_DEPTH_SIZE, depthBits);
A2(LOCAL_EGL_STENCIL_SIZE, stencilBits);
A1(LOCAL_EGL_NONE);
#undef A1
#undef A2
}
static void
FillPBufferAttribs_BySizes(nsTArray<EGLint>& attribs,
bool bpp16, bool hasAlpha,
int depthBits, int stencilBits)
{
int red = 0;
int green = 0;
int blue = 0;
int alpha = 0;
if (bpp16) {
if (hasAlpha) {
red = green = blue = alpha = 4;
} else {
red = 5;
green = 6;
blue = 5;
}
} else {
red = green = blue = 8;
if (hasAlpha)
alpha = 8;
}
FillPBufferAttribs_ByBits(attribs, red, green, blue, alpha, depthBits,
stencilBits);
}
static bool
DoesAttribBitsMatchCapBool(GLLibraryEGL* egl, EGLConfig config, EGLint attrib,
bool capBool)
{
EGLint bits = 0;
egl->fGetConfigAttrib(egl->Display(), config, attrib, &bits);
MOZ_ASSERT(egl->fGetError() == LOCAL_EGL_SUCCESS);
bool hasBits = !!bits;
return hasBits == capBool;
}
static EGLConfig
ChooseConfig(GLContext* gl, GLLibraryEGL* egl, const SurfaceCaps& caps)
{
MOZ_ASSERT(egl);
MOZ_ASSERT(caps.color);
// We might want 24-bit depth, but we're only (fairly) sure to get 16-bit.
int depthBits = caps.depth ? 16 : 0;
int stencilBits = caps.stencil ? 8 : 0;
// Ok, now we have everything.
nsTArray<EGLint> attribs(32);
FillPBufferAttribs_BySizes(attribs, caps.bpp16, caps.alpha, depthBits,
stencilBits);
// Time to try to get this config:
EGLConfig configs[64];
int numConfigs = sizeof(configs)/sizeof(EGLConfig);
int foundConfigs = 0;
if (!egl->fChooseConfig(egl->Display(), attribs.Elements(), configs,
numConfigs, &foundConfigs) ||
!foundConfigs)
{
NS_WARNING("No configs found for the requested formats.");
return EGL_NO_CONFIG;
}
// The requests passed to ChooseConfig are treated as minimums. If you ask
// for 0 bits of alpha, we might still get 8 bits.
EGLConfig config = EGL_NO_CONFIG;
for (int i = 0; i < foundConfigs; i++) {
EGLConfig cur = configs[i];
if (!DoesAttribBitsMatchCapBool(egl, cur, LOCAL_EGL_ALPHA_SIZE,
caps.alpha) ||
!DoesAttribBitsMatchCapBool(egl, cur, LOCAL_EGL_DEPTH_SIZE,
caps.depth) ||
!DoesAttribBitsMatchCapBool(egl, cur, LOCAL_EGL_STENCIL_SIZE,
caps.stencil))
{
continue;
}
config = cur;
break;
}
if (config == EGL_NO_CONFIG) {
NS_WARNING("No acceptable EGLConfig found.");
return EGL_NO_CONFIG;
}
if (gl->DebugMode()) {
egl->DumpEGLConfig(config);
}
return config;
}
/*static*/ UniquePtr<SurfaceFactory_ANGLEShareHandle>
SurfaceFactory_ANGLEShareHandle::Create(GLContext* gl, const SurfaceCaps& caps,
const RefPtr<layers::ISurfaceAllocator>& allocator,
@ -425,13 +289,10 @@ SurfaceFactory_ANGLEShareHandle::Create(GLContext* gl, const SurfaceCaps& caps,
if (!egl->IsExtensionSupported(ext))
return nullptr;
bool success;
EGLConfig config = GLContextEGL::Cast(gl)->mConfig;
typedef SurfaceFactory_ANGLEShareHandle ptrT;
UniquePtr<ptrT> ret( new ptrT(gl, caps, allocator, flags, egl, &success) );
if (!success)
return nullptr;
UniquePtr<ptrT> ret( new ptrT(gl, caps, allocator, flags, egl, config) );
return Move(ret);
}
@ -440,22 +301,12 @@ SurfaceFactory_ANGLEShareHandle::SurfaceFactory_ANGLEShareHandle(GLContext* gl,
const RefPtr<layers::ISurfaceAllocator>& allocator,
const layers::TextureFlags& flags,
GLLibraryEGL* egl,
bool* const out_success)
EGLConfig config)
: SurfaceFactory(SharedSurfaceType::EGLSurfaceANGLE, gl, caps, allocator, flags)
, mProdGL(gl)
, mEGL(egl)
{
MOZ_ASSERT(out_success);
*out_success = false;
mContext = GLContextEGL::Cast(mProdGL)->GetEGLContext();
mConfig = ChooseConfig(mProdGL, mEGL, mReadCaps);
if (mConfig == EGL_NO_CONFIG)
return;
MOZ_ASSERT(mConfig && mContext);
*out_success = true;
}
, mConfig(config)
{ }
} /* namespace gl */
} /* namespace mozilla */

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

@ -23,7 +23,6 @@ class SharedSurface_ANGLEShareHandle
{
public:
static UniquePtr<SharedSurface_ANGLEShareHandle> Create(GLContext* gl,
EGLContext context,
EGLConfig config,
const gfx::IntSize& size,
bool hasAlpha);
@ -36,7 +35,6 @@ public:
protected:
GLLibraryEGL* const mEGL;
const EGLContext mContext;
const EGLSurface mPBuffer;
public:
const HANDLE mShareHandle;
@ -51,7 +49,6 @@ protected:
GLLibraryEGL* egl,
const gfx::IntSize& size,
bool hasAlpha,
EGLContext context,
EGLSurface pbuffer,
HANDLE shareHandle,
const RefPtr<IDXGIKeyedMutex>& keyedMutex,
@ -94,8 +91,7 @@ class SurfaceFactory_ANGLEShareHandle
protected:
GLContext* const mProdGL;
GLLibraryEGL* const mEGL;
EGLContext mContext;
EGLConfig mConfig;
const EGLConfig mConfig;
public:
static UniquePtr<SurfaceFactory_ANGLEShareHandle> Create(GLContext* gl,
@ -107,13 +103,11 @@ protected:
SurfaceFactory_ANGLEShareHandle(GLContext* gl, const SurfaceCaps& caps,
const RefPtr<layers::ISurfaceAllocator>& allocator,
const layers::TextureFlags& flags, GLLibraryEGL* egl,
bool* const out_success);
EGLConfig config);
virtual UniquePtr<SharedSurface> CreateShared(const gfx::IntSize& size) override {
bool hasAlpha = mReadCaps.alpha;
return SharedSurface_ANGLEShareHandle::Create(mProdGL,
mContext, mConfig,
size, hasAlpha);
return SharedSurface_ANGLEShareHandle::Create(mProdGL, mConfig, size, hasAlpha);
}
};

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

@ -220,7 +220,7 @@ SurfaceFactory_EGLImage::Create(GLContext* prodGL, const SurfaceCaps& caps,
const RefPtr<layers::ISurfaceAllocator>& allocator,
const layers::TextureFlags& flags)
{
EGLContext context = GLContextEGL::Cast(prodGL)->GetEGLContext();
EGLContext context = GLContextEGL::Cast(prodGL)->mContext;
typedef SurfaceFactory_EGLImage ptrT;
UniquePtr<ptrT> ret;

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

@ -71,7 +71,7 @@ if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'windows':
'WGLLibrary.h',
]
UNIFIED_SOURCES += [
'GLContextProviderEGL.cpp',
'GLContextProviderWGL.cpp',
'SharedSurfaceANGLE.cpp',
]
if CONFIG['MOZ_ENABLE_SKIA_GPU']:
@ -113,10 +113,6 @@ elif gl_provider == 'GLX':
EXPORTS += [
'SharedSurfaceGLX.h'
]
else:
UNIFIED_SOURCES += [
'GLContextProvider%s.cpp' % gl_provider,
]
UNIFIED_SOURCES += [
'AndroidNativeWindow.cpp',
@ -127,6 +123,7 @@ UNIFIED_SOURCES += [
'GLBlitHelper.cpp',
'GLContext.cpp',
'GLContextFeatures.cpp',
'GLContextProviderEGL.cpp',
'GLContextTypes.cpp',
'GLDebugUtils.cpp',
'GLLibraryEGL.cpp',

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

@ -584,7 +584,7 @@ BasicLayerManager::FlashWidgetUpdateArea(gfxContext *aContext)
float r = float(rand()) / RAND_MAX;
float g = float(rand()) / RAND_MAX;
float b = float(rand()) / RAND_MAX;
aContext->SetColor(gfxRGBA(r, g, b, 0.2));
aContext->SetColor(Color(r, g, b, 0.2f));
aContext->Paint();
}
}
@ -1004,10 +1004,9 @@ BasicLayerManager::PaintLayer(gfxContext* aTarget,
gfxRect destRect;
#ifdef DEBUG
if (aLayer->GetDebugColorIndex() != 0) {
gfxRGBA color((aLayer->GetDebugColorIndex() & 1) ? 1.0 : 0.0,
(aLayer->GetDebugColorIndex() & 2) ? 1.0 : 0.0,
(aLayer->GetDebugColorIndex() & 4) ? 1.0 : 0.0,
1.0);
Color color((aLayer->GetDebugColorIndex() & 1) ? 1.f : 0.f,
(aLayer->GetDebugColorIndex() & 2) ? 1.f : 0.f,
(aLayer->GetDebugColorIndex() & 4) ? 1.f : 0.f);
nsRefPtr<gfxContext> temp = new gfxContext(untransformedDT, Point(bounds.x, bounds.y));
temp->SetColor(color);

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

@ -92,7 +92,7 @@ ClientCanvasLayer::Initialize(const Data& aData)
#elif defined(MOZ_WIDGET_GONK)
factory = MakeUnique<SurfaceFactory_Gralloc>(mGLContext, caps, forwarder, mFlags);
#elif defined(GL_PROVIDER_GLX)
if (sGLXLibrary.UseTextureFromPixmap())
if (sGLXLibrary.UseSurfaceSharing())
factory = SurfaceFactory_GLXDrawable::Create(mGLContext, caps, forwarder, mFlags);
#else
if (mGLContext->GetContextType() == GLContextType::EGL) {

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

@ -46,7 +46,7 @@ static void DrawDebugOverlay(mozilla::gfx::DrawTarget* dt, int x, int y, int wid
// Draw border
c.NewPath();
c.SetDeviceColor(gfxRGBA(0.0, 0.0, 0.0, 1.0));
c.SetDeviceColor(Color(0.f, 0.f, 0.f));
c.Rectangle(gfxRect(0, 0, width, height));
c.Stroke();
@ -63,12 +63,12 @@ static void DrawDebugOverlay(mozilla::gfx::DrawTarget* dt, int x, int y, int wid
int textWidth = extents.width + 6;
c.NewPath();
c.SetDeviceColor(gfxRGBA(0.0, 0.0, 0.0, 1.0));
c.SetDeviceColor(Color(0.f, 0.f, 0.f));
c.Rectangle(gfxRect(gfxPoint(2,2),gfxSize(textWidth, 30)));
c.Fill();
c.NewPath();
c.SetDeviceColor(gfxRGBA(1.0, 0.0, 0.0, 1.0));
c.SetDeviceColor(Color(1.0, 0.0, 0.0));
c.Rectangle(gfxRect(gfxPoint(2,2),gfxSize(textWidth, 30)));
c.Stroke();

Некоторые файлы не были показаны из-за слишком большого количества измененных файлов Показать больше