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 void RemoteDocAdded(DocAccessibleParent* aDoc);
static const nsTArray<DocAccessibleParent*>* TopLevelRemoteDocs()
{ return sRemoteDocuments; }
#ifdef DEBUG #ifdef DEBUG
bool IsProcessingRefreshDriverNotification() const; bool IsProcessingRefreshDriverNotification() const;
#endif #endif

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

@ -123,6 +123,10 @@ public:
const ProxyAccessible* GetAccessible(uintptr_t aID) const const ProxyAccessible* GetAccessible(uintptr_t aID) const
{ return const_cast<DocAccessibleParent*>(this)->GetAccessible(aID); } { 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: private:
class ProxyEntry : public PLDHashEntryHdr class ProxyEntry : public PLDHashEntryHdr

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

@ -1412,6 +1412,27 @@ GetAccessibleInSubtree(DocAccessible* aDoc, uint32_t aID)
} }
#endif #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* Accessible*
AccessibleWrap::GetXPAccessibleFor(const VARIANT& aVarChild) AccessibleWrap::GetXPAccessibleFor(const VARIANT& aVarChild)
{ {
@ -1422,33 +1443,32 @@ AccessibleWrap::GetXPAccessibleFor(const VARIANT& aVarChild)
if (aVarChild.lVal == CHILDID_SELF) if (aVarChild.lVal == CHILDID_SELF)
return this; return this;
if (IsProxy()) { if (IsProxy() ? Proxy()->MustPruneChildren() : nsAccUtils::MustPrune(this)) {
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.
return nullptr; return nullptr;
} }
if (nsAccUtils::MustPrune(this)) if (aVarChild.lVal > 0) {
return nullptr; // 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 // If lVal negative then it is treated as child ID and we should look for
// accessible through whole accessible subtree including subdocuments. // accessible through whole accessible subtree including subdocuments.
// Otherwise we treat lVal as index in parent. // Otherwise we treat lVal as index in parent.
// Convert child ID to unique ID.
if (aVarChild.lVal < 0) { // First handle the case that both this accessible and the id'd one are in
// Convert child ID to unique ID. // this process.
if (!IsProxy()) {
void* uniqueID = reinterpret_cast<void*>(-aVarChild.lVal); void* uniqueID = reinterpret_cast<void*>(-aVarChild.lVal);
DocAccessible* document = Document(); DocAccessible* document = Document();
Accessible* child = Accessible* child =
#ifdef _WIN64 #ifdef _WIN64
GetAccessibleInSubtree(document, static_cast<uint32_t>(aVarChild.lVal)); GetAccessibleInSubtree(document, static_cast<uint32_t>(aVarChild.lVal));
#else #else
document->GetAccessibleByUniqueIDInSubtree(uniqueID); document->GetAccessibleByUniqueIDInSubtree(uniqueID);
#endif #endif
@ -1466,12 +1486,65 @@ AccessibleWrap::GetXPAccessibleFor(const VARIANT& aVarChild)
parent = parent->Parent(); 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; return nullptr;
} }
// Gecko child indices are 0-based in contrast to indices used in MSAA. // Finally we need to handle the case that this accessible is in the main
return GetChildAt(aVarChild.lVal - 1); // 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 void

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

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

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

@ -12,7 +12,7 @@
#include "js/Debug.h" #include "js/Debug.h"
#include "js/TypeDecls.h" #include "js/TypeDecls.h"
#include "js/UbiNodeCensus.h" #include "js/UbiNodeCensus.h"
#include "js/UbiNodeTraverse.h" #include "js/UbiNodeBreadthFirst.h"
#include "mozilla/Attributes.h" #include "mozilla/Attributes.h"
#include "mozilla/devtools/AutoMemMap.h" #include "mozilla/devtools/AutoMemMap.h"
#include "mozilla/devtools/CoreDump.pb.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 # THE MOCK_METHOD2 macro from gtest triggers this clang warning and it's hard
# to work around, so we just ignore it. # to work around, so we just ignore it.
if CONFIG['CLANG_CXX']: if CONFIG['CLANG_CXX']:
CXXFLAGS += ['-Wno-error=inconsistent-missing-override'] CXXFLAGS += ['-Wno-inconsistent-missing-override']
FINAL_LIBRARY = 'xul-gtest' FINAL_LIBRARY = 'xul-gtest'

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

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

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

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

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

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

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

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

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

@ -195,6 +195,47 @@ public:
static bool ThreadsafeIsCallerChrome(); static bool ThreadsafeIsCallerChrome();
static bool IsCallerContentXBL(); 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 IsImageSrcSetDisabled();
static bool LookupBindingMember(JSContext* aCx, nsIContent *aContent, static bool LookupBindingMember(JSContext* aCx, nsIContent *aContent,

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

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

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

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

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

@ -2085,7 +2085,7 @@ nsGlobalWindow::SetInitialPrincipalToSubject()
MOZ_ASSERT(IsOuterWindow()); MOZ_ASSERT(IsOuterWindow());
// First, grab the subject principal. // 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, // Now, if we're about to use the system principal or an nsExpandedPrincipal,
// make sure we're not using it for a content docshell. // make sure we're not using it for a content docshell.
@ -4549,7 +4549,7 @@ nsGlobalWindow::GetOpenerWindowOuter()
nsGlobalWindow* win = static_cast<nsGlobalWindow*>(opener.get()); nsGlobalWindow* win = static_cast<nsGlobalWindow*>(opener.get());
// First, check if we were called from a privileged chrome script // 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... // Catch the case where we're chrome but the opener is not...
if (GetPrincipal() == nsContentUtils::GetSystemPrincipal() && if (GetPrincipal() == nsContentUtils::GetSystemPrincipal() &&
win->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 // Only chrome can change our fullscreen mode. Otherwise, the state
// can only be changed for DOM fullscreen. // can only be changed for DOM fullscreen.
if (aReason == eForFullscreenMode && !nsContentUtils::IsCallerChrome()) { if (aReason == eForFullscreenMode && !nsContentUtils::LegacyIsCallerChromeOrNativeCode()) {
return NS_OK; return NS_OK;
} }
@ -8249,7 +8249,7 @@ bool
nsGlobalWindow::CanSetProperty(const char *aPrefName) nsGlobalWindow::CanSetProperty(const char *aPrefName)
{ {
// Chrome can set any property. // Chrome can set any property.
if (nsContentUtils::IsCallerChrome()) { if (nsContentUtils::LegacyIsCallerChromeOrNativeCode()) {
return true; return true;
} }
@ -10054,6 +10054,7 @@ nsGlobalWindow::AddSystemEventListener(const nsAString& aType,
"explicit by making optional_argc non-zero."); "explicit by making optional_argc non-zero.");
if (IsOuterWindow() && mInnerWindow && if (IsOuterWindow() && mInnerWindow &&
!nsContentUtils::LegacyIsCallerNativeCode() &&
!nsContentUtils::CanCallerAccess(mInnerWindow)) { !nsContentUtils::CanCallerAccess(mInnerWindow)) {
return NS_ERROR_DOM_SECURITY_ERR; return NS_ERROR_DOM_SECURITY_ERR;
} }
@ -12181,7 +12182,7 @@ nsGlobalWindow::OpenInternal(const nsAString& aUrl, const nsAString& aName,
nsIPrincipal::APP_STATUS_INSTALLED; nsIPrincipal::APP_STATUS_INSTALLED;
} }
const bool checkForPopup = !nsContentUtils::IsCallerChrome() && const bool checkForPopup = !nsContentUtils::LegacyIsCallerChromeOrNativeCode() &&
!isApp && !aDialog && !WindowExists(aName, !aCalledNoScript); !isApp && !aDialog && !WindowExists(aName, !aCalledNoScript);
// Note: it's very important that this be an nsXPIDLCString, since we want // 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) { if (aRequest != mChannel) {
return NS_BINDING_ABORTED; return NS_BINDING_ABORTED;
@ -1183,7 +1183,7 @@ nsObjectLoadingContent::OnDataAvailable(nsIRequest *aRequest,
nsIInputStream *aInputStream, nsIInputStream *aInputStream,
uint64_t aOffset, uint32_t aCount) 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) { if (aRequest != mChannel) {
return NS_BINDING_ABORTED; return NS_BINDING_ABORTED;
@ -2825,7 +2825,8 @@ nsObjectLoadingContent::ScriptRequestPluginInstance(JSContext* aCx,
// so the ensuing expression is short-circuited. // so the ensuing expression is short-circuited.
MOZ_ASSERT_IF(nsContentUtils::GetCurrentJSContext(), MOZ_ASSERT_IF(nsContentUtils::GetCurrentJSContext(),
aCx == nsContentUtils::GetCurrentJSContext()); aCx == nsContentUtils::GetCurrentJSContext());
bool callerIsContentJS = (!nsContentUtils::IsCallerChrome() && bool callerIsContentJS = (nsContentUtils::GetCurrentJSContext() &&
!nsContentUtils::IsCallerChrome() &&
!nsContentUtils::IsCallerContentXBL() && !nsContentUtils::IsCallerContentXBL() &&
JS_IsRunning(aCx)); JS_IsRunning(aCx));

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

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

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

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

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

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

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

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

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

@ -58,7 +58,7 @@ public:
void Invalidate(); void Invalidate();
// Call these on any thread. // Call these on any thread.
void SetCurrentFrame(const gfxIntSize& aIntrinsicSize, Image* aImage); void SetCurrentFrame(const gfx::IntSize& aIntrinsicSize, Image* aImage);
void ClearCurrentFrame(); void ClearCurrentFrame();
void RateLimit(bool aLimit); 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); 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; return true;
} }

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

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

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

@ -33,7 +33,7 @@ public:
dom::HTMLCanvasElement* aCanvas, dom::HTMLCanvasElement* aCanvas,
imgIRequest* aRequest, imgIRequest* aRequest,
SourceSurface* aSource, SourceSurface* aSource,
const gfxIntSize& aSize); const gfx::IntSize& aSize);
/** /**
* Check whether aImage has recently been drawn into aCanvas. If we return * 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 // protect against too-large surfaces that will cause allocation
// or overflow issues // 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)) { 0xffff)) {
error.Throw(NS_ERROR_FAILURE); error.Throw(NS_ERROR_FAILURE);
return; return;
@ -4976,7 +4976,7 @@ CanvasRenderingContext2D::AsyncDrawXULElement(nsXULElement& elem,
// protect against too-large surfaces that will cause allocation // protect against too-large surfaces that will cause allocation
// or overflow issues // or overflow issues
if (!gfxASurface::CheckSurfaceSize(gfxIntSize(w, h), 0xffff)) { if (!gfxASurface::CheckSurfaceSize(gfx::IntSize(w, h), 0xffff)) {
error.Throw(NS_ERROR_FAILURE); error.Throw(NS_ERROR_FAILURE);
return; return;
} }
@ -5401,7 +5401,7 @@ CanvasRenderingContext2D::PutImageData_explicit(int32_t x, int32_t y, uint32_t w
uint32_t copyWidth = dirtyRect.Width(); uint32_t copyWidth = dirtyRect.Width();
uint32_t copyHeight = dirtyRect.Height(); uint32_t copyHeight = dirtyRect.Height();
nsRefPtr<gfxImageSurface> imgsurf = new gfxImageSurface(gfxIntSize(copyWidth, copyHeight), nsRefPtr<gfxImageSurface> imgsurf = new gfxImageSurface(gfx::IntSize(copyWidth, copyHeight),
gfxImageFormat::ARGB32, gfxImageFormat::ARGB32,
false); false);
if (!imgsurf || imgsurf->CairoStatus()) { if (!imgsurf || imgsurf->CairoStatus()) {

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

@ -217,6 +217,7 @@ WebGLContext::WebGLContext()
, mBypassShaderValidation(false) , mBypassShaderValidation(false)
, mGLMaxSamples(1) , mGLMaxSamples(1)
, mNeedsFakeNoAlpha(false) , mNeedsFakeNoAlpha(false)
, mNeedsFakeNoDepth(false)
, mNeedsFakeNoStencil(false) , mNeedsFakeNoStencil(false)
{ {
mGeneration = 0; mGeneration = 0;
@ -253,6 +254,7 @@ WebGLContext::WebGLContext()
mDitherEnabled = 1; mDitherEnabled = 1;
mRasterizerDiscardEnabled = 0; // OpenGL ES 3.0 spec p244 mRasterizerDiscardEnabled = 0; // OpenGL ES 3.0 spec p244
mScissorTestEnabled = 0; mScissorTestEnabled = 0;
mDepthTestEnabled = 0;
mStencilTestEnabled = 0; mStencilTestEnabled = 0;
// initialize some GL values: we're going to get them from the GL and use them as the sizes of arrays, // 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; 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 static void
PopulateCapFallbackQueue(const SurfaceCaps& baseCaps, PopulateCapFallbackQueue(const gl::SurfaceCaps& baseCaps,
std::queue<SurfaceCaps>* out_fallbackCaps) std::queue<gl::SurfaceCaps>* out_fallbackCaps)
{ {
out_fallbackCaps->push(baseCaps); out_fallbackCaps->push(baseCaps);
@ -651,7 +555,7 @@ PopulateCapFallbackQueue(const SurfaceCaps& baseCaps,
// The user basically doesn't have to handle if this fails, they // The user basically doesn't have to handle if this fails, they
// just get reduced quality. // just get reduced quality.
if (baseCaps.antialias) { if (baseCaps.antialias) {
SurfaceCaps nextCaps(baseCaps); gl::SurfaceCaps nextCaps(baseCaps);
nextCaps.antialias = false; nextCaps.antialias = false;
PopulateCapFallbackQueue(nextCaps, out_fallbackCaps); PopulateCapFallbackQueue(nextCaps, out_fallbackCaps);
} }
@ -660,25 +564,22 @@ PopulateCapFallbackQueue(const SurfaceCaps& baseCaps,
// depth. However, the client app will need to handle if this // depth. However, the client app will need to handle if this
// doesn't work. // doesn't work.
if (baseCaps.stencil) { if (baseCaps.stencil) {
SurfaceCaps nextCaps(baseCaps); gl::SurfaceCaps nextCaps(baseCaps);
nextCaps.stencil = false; nextCaps.stencil = false;
PopulateCapFallbackQueue(nextCaps, out_fallbackCaps); PopulateCapFallbackQueue(nextCaps, out_fallbackCaps);
} }
if (baseCaps.depth) { if (baseCaps.depth) {
SurfaceCaps nextCaps(baseCaps); gl::SurfaceCaps nextCaps(baseCaps);
nextCaps.depth = false; nextCaps.depth = false;
PopulateCapFallbackQueue(nextCaps, out_fallbackCaps); PopulateCapFallbackQueue(nextCaps, out_fallbackCaps);
} }
} }
static bool static gl::SurfaceCaps
CreateOffscreen(GLContext* gl, const WebGLContextOptions& options, BaseCaps(const WebGLContextOptions& options, WebGLContext* webgl)
const nsCOMPtr<nsIGfxInfo>& gfxInfo, WebGLContext* webgl,
layers::LayersBackend layersBackend,
layers::ISurfaceAllocator* surfAllocator)
{ {
SurfaceCaps baseCaps; gl::SurfaceCaps baseCaps;
baseCaps.color = true; baseCaps.color = true;
baseCaps.alpha = options.alpha; baseCaps.alpha = options.alpha;
@ -691,29 +592,36 @@ CreateOffscreen(GLContext* gl, const WebGLContextOptions& options,
if (!baseCaps.alpha) if (!baseCaps.alpha)
baseCaps.premultAlpha = true; 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 // we should really have this behind a
// |gfxPlatform::GetPlatform()->GetScreenDepth() == 16| check, but // |gfxPlatform::GetPlatform()->GetScreenDepth() == 16| check, but
// for now it's just behind a pref for testing/evaluation. // for now it's just behind a pref for testing/evaluation.
baseCaps.bpp16 = Preferences::GetBool("webgl.prefer-16bpp", false); baseCaps.bpp16 = Preferences::GetBool("webgl.prefer-16bpp", false);
#ifdef MOZ_WIDGET_GONK #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 #endif
// Done with baseCaps construction. // Done with baseCaps construction.
bool forceAllowAA = Preferences::GetBool("webgl.msaa-force", false); bool forceAllowAA = Preferences::GetBool("webgl.msaa-force", false);
nsCOMPtr<nsIGfxInfo> gfxInfo = services::GetGfxInfo();
if (!forceAllowAA && if (!forceAllowAA &&
IsFeatureInBlacklist(gfxInfo, nsIGfxInfo::FEATURE_WEBGL_MSAA)) IsFeatureInBlacklist(gfxInfo, nsIGfxInfo::FEATURE_WEBGL_MSAA))
{ {
@ -722,62 +630,149 @@ CreateOffscreen(GLContext* gl, const WebGLContextOptions& options,
baseCaps.antialias = false; 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); PopulateCapFallbackQueue(baseCaps, &fallbackCaps);
bool created = false; gl = nullptr;
while (!fallbackCaps.empty()) { while (!fallbackCaps.empty()) {
SurfaceCaps& caps = fallbackCaps.front(); gl::SurfaceCaps& caps = fallbackCaps.front();
created = CreateOffscreenWithCaps(gl, caps); gl = fnCreateGL(caps, flags, this);
if (created) if (gl)
break; break;
fallbackCaps.pop(); fallbackCaps.pop();
} }
if (!gl)
return false;
return created; if (!InitAndValidateGL()) {
gl = nullptr;
return false;
}
return true;
} }
bool 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; if (PR_GetEnv("MOZ_WEBGL_FORCE_OPENGL"))
#ifdef MOZ_WIDGET_GONK disableANGLE = true;
nsIWidget* docWidget = nsContentUtils::WidgetForDocument(mCanvasElement->OwnerDoc());
if (docWidget) { gl::CreateContextFlags flags = gl::CreateContextFlags::NONE;
layers::LayerManager* layerManager = docWidget->GetLayerManager(); if (forceEnabled) flags |= gl::CreateContextFlags::FORCE_ENABLE_HARDWARE;
if (layerManager) { if (!IsWebGL2()) flags |= gl::CreateContextFlags::REQUIRE_COMPAT_PROFILE;
// XXX we really want "AsSurfaceAllocator" here for generality
layers::ShadowLayerForwarder* forwarder = layerManager->AsShadowForwarder(); const gl::SurfaceCaps baseCaps = BaseCaps(mOptions, this);
if (forwarder)
surfAllocator = static_cast<layers::ISurfaceAllocator*>(forwarder); MOZ_ASSERT(!gl);
}
if (preferEGL) {
if (CreateAndInitGLWith(CreateGLWithEGL, baseCaps, flags))
return true;
} }
#endif
CreateContextFlags flags = forceEnabled ? CreateContextFlags::FORCE_ENABLE_HARDWARE : MOZ_ASSERT(!gl);
CreateContextFlags::NONE;
gl = CreateHeadlessGL(flags, gfxInfo, this); if (!disableANGLE) {
if (CreateAndInitGLWith(CreateGLWithANGLE, baseCaps, flags))
return true;
}
do { MOZ_ASSERT(!gl);
if (!gl)
break;
if (!CreateOffscreen(gl, mOptions, gfxInfo, this,
GetCompositorBackendType(), surfAllocator))
break;
if (!InitAndValidateGL())
break;
if (CreateAndInitGLWith(CreateGLWithDefault, baseCaps, flags))
return true; return true;
} while (false);
MOZ_ASSERT(!gl);
gl = nullptr; gl = nullptr;
return false; return false;
} }
@ -941,12 +936,15 @@ WebGLContext::SetDimensions(int32_t signedWidth, int32_t signedHeight)
bool forceEnabled = Preferences::GetBool("webgl.force-enabled", false); bool forceEnabled = Preferences::GetBool("webgl.force-enabled", false);
ScopedGfxFeatureReporter reporter("WebGL", forceEnabled); ScopedGfxFeatureReporter reporter("WebGL", forceEnabled);
if (!CreateOffscreenGL(forceEnabled)) { MOZ_ASSERT(!gl);
if (!CreateAndInitGL(forceEnabled)) {
GenerateWarning("WebGL creation failed."); GenerateWarning("WebGL creation failed.");
return NS_ERROR_FAILURE; return NS_ERROR_FAILURE;
} }
MOZ_ASSERT(gl); MOZ_ASSERT(gl);
MOZ_ASSERT_IF(mOptions.alpha, gl->Caps().alpha);
if (!ResizeBackbuffer(width, height)) { if (!ResizeBackbuffer(width, height)) {
GenerateWarning("Initializing WebGL backbuffer failed."); GenerateWarning("Initializing WebGL backbuffer failed.");
return NS_ERROR_FAILURE; return NS_ERROR_FAILURE;
@ -965,14 +963,20 @@ WebGLContext::SetDimensions(int32_t signedWidth, int32_t signedHeight)
if (!mOptions.alpha && gl->Caps().alpha) if (!mOptions.alpha && gl->Caps().alpha)
mNeedsFakeNoAlpha = true; mNeedsFakeNoAlpha = true;
// ANGLE doesn't quite handle this properly. if (!mOptions.depth && gl->Caps().depth)
if (gl->Caps().depth && !gl->Caps().stencil && gl->IsANGLE()) mNeedsFakeNoDepth = true;
if (!mOptions.stencil && gl->Caps().stencil)
mNeedsFakeNoStencil = true; mNeedsFakeNoStencil = true;
} }
// Update mOptions. // Update mOptions.
mOptions.depth = gl->Caps().depth; if (!gl->Caps().depth)
mOptions.stencil = gl->Caps().stencil; mOptions.depth = false;
if (!gl->Caps().stencil)
mOptions.stencil = false;
mOptions.antialias = gl->Caps().antialias; mOptions.antialias = gl->Caps().antialias;
MakeContextCurrent(); MakeContextCurrent();
@ -998,10 +1002,16 @@ WebGLContext::SetDimensions(int32_t signedWidth, int32_t signedHeight)
mShouldPresent = true; mShouldPresent = true;
MOZ_ASSERT(gl->Caps().color); MOZ_ASSERT(gl->Caps().color);
MOZ_ASSERT_IF(!mNeedsFakeNoAlpha, gl->Caps().alpha == mOptions.alpha); MOZ_ASSERT_IF(!mNeedsFakeNoAlpha, gl->Caps().alpha == mOptions.alpha);
MOZ_ASSERT_IF(mNeedsFakeNoAlpha, !mOptions.alpha && gl->Caps().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().antialias == mOptions.antialias);
MOZ_ASSERT(gl->Caps().preserve == mOptions.preserveDrawingBuffer); MOZ_ASSERT(gl->Caps().preserve == mOptions.preserveDrawingBuffer);
@ -1876,6 +1886,7 @@ RoundedToNextMultipleOf(CheckedUint32 x, CheckedUint32 y)
WebGLContext::ScopedMaskWorkaround::ScopedMaskWorkaround(WebGLContext& webgl) WebGLContext::ScopedMaskWorkaround::ScopedMaskWorkaround(WebGLContext& webgl)
: mWebGL(webgl) : mWebGL(webgl)
, mFakeNoAlpha(ShouldFakeNoAlpha(webgl)) , mFakeNoAlpha(ShouldFakeNoAlpha(webgl))
, mFakeNoDepth(ShouldFakeNoDepth(webgl))
, mFakeNoStencil(ShouldFakeNoStencil(webgl)) , mFakeNoStencil(ShouldFakeNoStencil(webgl))
{ {
if (mFakeNoAlpha) { if (mFakeNoAlpha) {
@ -1884,6 +1895,9 @@ WebGLContext::ScopedMaskWorkaround::ScopedMaskWorkaround(WebGLContext& webgl)
mWebGL.mColorWriteMask[2], mWebGL.mColorWriteMask[2],
false); false);
} }
if (mFakeNoDepth) {
mWebGL.gl->fDisable(LOCAL_GL_DEPTH_TEST);
}
if (mFakeNoStencil) { if (mFakeNoStencil) {
mWebGL.gl->fDisable(LOCAL_GL_STENCIL_TEST); mWebGL.gl->fDisable(LOCAL_GL_STENCIL_TEST);
} }
@ -1897,6 +1911,9 @@ WebGLContext::ScopedMaskWorkaround::~ScopedMaskWorkaround()
mWebGL.mColorWriteMask[2], mWebGL.mColorWriteMask[2],
mWebGL.mColorWriteMask[3]); mWebGL.mColorWriteMask[3]);
} }
if (mFakeNoDepth) {
mWebGL.gl->fEnable(LOCAL_GL_DEPTH_TEST);
}
if (mFakeNoStencil) { if (mFakeNoStencil) {
mWebGL.gl->fEnable(LOCAL_GL_STENCIL_TEST); mWebGL.gl->fEnable(LOCAL_GL_STENCIL_TEST);
} }

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

@ -8,6 +8,7 @@
#include <stdarg.h> #include <stdarg.h>
#include "GLContextTypes.h"
#include "GLDefs.h" #include "GLDefs.h"
#include "mozilla/Attributes.h" #include "mozilla/Attributes.h"
#include "mozilla/CheckedInt.h" #include "mozilla/CheckedInt.h"
@ -24,6 +25,7 @@
#include "nsLayoutUtils.h" #include "nsLayoutUtils.h"
#include "nsTArray.h" #include "nsTArray.h"
#include "nsWrapperCache.h" #include "nsWrapperCache.h"
#include "SurfaceTypes.h"
#ifdef XP_MACOSX #ifdef XP_MACOSX
#include "ForceDiscreteGPUHelperCGL.h" #include "ForceDiscreteGPUHelperCGL.h"
@ -812,6 +814,7 @@ private:
realGLboolean mDitherEnabled; realGLboolean mDitherEnabled;
realGLboolean mRasterizerDiscardEnabled; realGLboolean mRasterizerDiscardEnabled;
realGLboolean mScissorTestEnabled; realGLboolean mScissorTestEnabled;
realGLboolean mDepthTestEnabled;
realGLboolean mStencilTestEnabled; realGLboolean mStencilTestEnabled;
bool ValidateCapabilityEnum(GLenum cap, const char* info); bool ValidateCapabilityEnum(GLenum cap, const char* info);
@ -1153,11 +1156,19 @@ public:
protected: protected:
bool InitWebGL2(); 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) // Validation functions (implemented in WebGLContextValidate.cpp)
bool CreateOffscreenGL(bool forceEnabled);
bool InitAndValidateGL(); bool InitAndValidateGL();
bool ResizeBackbuffer(uint32_t width, uint32_t height);
bool ValidateBlendEquationEnum(GLenum cap, const char* info); bool ValidateBlendEquationEnum(GLenum cap, const char* info);
bool ValidateBlendFuncDstEnum(GLenum mode, const char* info); bool ValidateBlendFuncDstEnum(GLenum mode, const char* info);
bool ValidateBlendFuncSrcEnum(GLenum mode, const char* info); bool ValidateBlendFuncSrcEnum(GLenum mode, const char* info);
@ -1443,11 +1454,13 @@ protected:
uint64_t mLastUseIndex; uint64_t mLastUseIndex;
bool mNeedsFakeNoAlpha; bool mNeedsFakeNoAlpha;
bool mNeedsFakeNoDepth;
bool mNeedsFakeNoStencil; bool mNeedsFakeNoStencil;
struct ScopedMaskWorkaround { struct ScopedMaskWorkaround {
WebGLContext& mWebGL; WebGLContext& mWebGL;
const bool mFakeNoAlpha; const bool mFakeNoAlpha;
const bool mFakeNoDepth;
const bool mFakeNoStencil; const bool mFakeNoStencil;
static bool ShouldFakeNoAlpha(WebGLContext& webgl) { static bool ShouldFakeNoAlpha(WebGLContext& webgl) {
@ -1458,6 +1471,13 @@ protected:
webgl.mColorWriteMask[3] != false; 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) { static bool ShouldFakeNoStencil(WebGLContext& webgl) {
// We should only be doing this if we're about to draw to the backbuffer. // We should only be doing this if we're about to draw to the backbuffer.
return !webgl.mBoundDrawFramebuffer && 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_MAX_TEXTURE_IMAGE_UNITS:
case LOCAL_GL_RED_BITS: case LOCAL_GL_RED_BITS:
case LOCAL_GL_GREEN_BITS: case LOCAL_GL_GREEN_BITS:
case LOCAL_GL_BLUE_BITS: case LOCAL_GL_BLUE_BITS: {
case LOCAL_GL_DEPTH_BITS: {
GLint i = 0; GLint i = 0;
gl->fGetIntegerv(pname, &i); gl->fGetIntegerv(pname, &i);
return JS::Int32Value(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: { case LOCAL_GL_ALPHA_BITS: {
GLint i = 0; GLint i = 0;
if (!mNeedsFakeNoAlpha) { if (!mNeedsFakeNoAlpha) {
@ -622,6 +628,8 @@ realGLboolean*
WebGLContext::GetStateTrackingSlot(GLenum cap) WebGLContext::GetStateTrackingSlot(GLenum cap)
{ {
switch (cap) { switch (cap) {
case LOCAL_GL_DEPTH_TEST:
return &mDepthTestEnabled;
case LOCAL_GL_DITHER: case LOCAL_GL_DITHER:
return &mDitherEnabled; return &mDitherEnabled;
case LOCAL_GL_RASTERIZER_DISCARD: case LOCAL_GL_RASTERIZER_DISCARD:

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

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

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

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

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

@ -36,6 +36,7 @@
#include "mozilla/dom/TouchEvent.h" #include "mozilla/dom/TouchEvent.h"
#include "mozilla/dom/TransitionEvent.h" #include "mozilla/dom/TransitionEvent.h"
#include "mozilla/dom/WheelEvent.h" #include "mozilla/dom/WheelEvent.h"
#include "mozilla/dom/WorkerPrivate.h"
#include "mozilla/dom/XULCommandEvent.h" #include "mozilla/dom/XULCommandEvent.h"
#include "mozilla/EventDispatcher.h" #include "mozilla/EventDispatcher.h"
#include "mozilla/EventListenerManager.h" #include "mozilla/EventListenerManager.h"
@ -709,7 +710,9 @@ EventDispatcher::DispatchDOMEvent(nsISupports* aTarget,
if (!dontResetTrusted) { if (!dontResetTrusted) {
//Check security state to determine if dispatcher is trusted //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, return EventDispatcher::Dispatch(aTarget, aPresContext, innerEvent,

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

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

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

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

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

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

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

@ -1417,7 +1417,7 @@ HTMLInputElement::GetValueInternal(nsAString& aValue) const
return NS_OK; return NS_OK;
case VALUE_MODE_FILENAME: case VALUE_MODE_FILENAME:
if (nsContentUtils::IsCallerChrome()) { if (nsContentUtils::LegacyIsCallerChromeOrNativeCode()) {
#ifndef MOZ_CHILD_PERMISSIONS #ifndef MOZ_CHILD_PERMISSIONS
aValue.Assign(mFirstFilePath); aValue.Assign(mFirstFilePath);
#else #else
@ -2994,7 +2994,7 @@ HTMLInputElement::DispatchSelectEvent(nsPresContext* aPresContext)
// If already handling select event, don't dispatch a second. // If already handling select event, don't dispatch a second.
if (!mHandlingSelectEvent) { if (!mHandlingSelectEvent) {
WidgetEvent event(nsContentUtils::IsCallerChrome(), eFormSelect); WidgetEvent event(nsContentUtils::LegacyIsCallerChromeOrNativeCode(), eFormSelect);
mHandlingSelectEvent = true; mHandlingSelectEvent = true;
EventDispatcher::Dispatch(static_cast<nsIContent*>(this), 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 // Detect if user has interacted with element by seeking so that
// play will not be blocked when initiated by a script. // play will not be blocked when initiated by a script.
if (EventStateManager::IsHandlingUserInput() || nsContentUtils::IsCallerChrome()) { if (EventStateManager::IsHandlingUserInput() || nsContentUtils::LegacyIsCallerChromeOrNativeCode()) {
mHasUserInteraction = true; mHasUserInteraction = true;
} }
@ -3042,7 +3042,7 @@ public:
if (!mElement) { if (!mElement) {
return; return;
} }
gfxIntSize size; gfx::IntSize size;
{ {
MutexAutoLock lock(mMutex); MutexAutoLock lock(mMutex);
size = mInitialSize; size = mInitialSize;
@ -3056,13 +3056,13 @@ public:
const MediaSegment& aQueuedMedia) override const MediaSegment& aQueuedMedia) override
{ {
MutexAutoLock lock(mMutex); MutexAutoLock lock(mMutex);
if (mInitialSize != gfxIntSize(0,0) || if (mInitialSize != gfx::IntSize(0,0) ||
aQueuedMedia.GetType() != MediaSegment::VIDEO) { aQueuedMedia.GetType() != MediaSegment::VIDEO) {
return; return;
} }
const VideoSegment& video = static_cast<const VideoSegment&>(aQueuedMedia); const VideoSegment& video = static_cast<const VideoSegment&>(aQueuedMedia);
for (VideoSegment::ConstChunkIterator c(video); !c.IsEnded(); c.Next()) { 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(); mInitialSize = c->mFrame.GetIntrinsicSize();
nsCOMPtr<nsIRunnable> event = nsCOMPtr<nsIRunnable> event =
NS_NewRunnableMethod(this, &StreamSizeListener::ReceivedSize); NS_NewRunnableMethod(this, &StreamSizeListener::ReceivedSize);
@ -3077,7 +3077,7 @@ private:
// mMutex protects the fields below; they can be accessed on any thread // mMutex protects the fields below; they can be accessed on any thread
Mutex mMutex; Mutex mMutex;
gfxIntSize mInitialSize; gfx::IntSize mInitialSize;
}; };
class HTMLMediaElement::MediaStreamTracksAvailableCallback: class HTMLMediaElement::MediaStreamTracksAvailableCallback:

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

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

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

@ -2929,7 +2929,7 @@ nsHTMLDocument::SetDesignMode(const nsAString & aDesignMode)
void void
nsHTMLDocument::SetDesignMode(const nsAString& aDesignMode, ErrorResult& rv) 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); rv.Throw(NS_ERROR_DOM_PROP_ACCESS_DENIED);
return; return;
} }

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

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

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

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

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

@ -2727,7 +2727,7 @@ ContentParent::RecvSetClipboard(const IPCDataTransfer& aDataTransfer,
item.flavor().EqualsLiteral(kPNGImageMime) || item.flavor().EqualsLiteral(kPNGImageMime) ||
item.flavor().EqualsLiteral(kGIFImageMime)) { item.flavor().EqualsLiteral(kGIFImageMime)) {
const IPCDataTransferImage& imageDetails = item.imageDetails(); 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) { if (!size.width || !size.height) {
return true; 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::NativeThreadId from "mozilla/dom/TabMessageUtils.h";
using mozilla::dom::quota::PersistenceType from "mozilla/dom/quota/PersistenceType.h"; using mozilla::dom::quota::PersistenceType from "mozilla/dom/quota/PersistenceType.h";
using mozilla::hal::ProcessPriority from "mozilla/HalTypes.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::TabId from "mozilla/dom/ipc/IdType.h";
using mozilla::dom::ContentParentId from "mozilla/dom/ipc/IdType.h"; using mozilla::dom::ContentParentId from "mozilla/dom/ipc/IdType.h";
using struct LookAndFeelInt from "mozilla/widget/WidgetMessageUtils.h"; using struct LookAndFeelInt from "mozilla/widget/WidgetMessageUtils.h";
@ -546,7 +546,7 @@ child:
// nsIPermissionManager messages // nsIPermissionManager messages
AddPermission(Permission permission); AddPermission(Permission permission);
ScreenSizeChanged(gfxIntSize size); ScreenSizeChanged(IntSize size);
Volumes(VolumeInfo[] volumes); Volumes(VolumeInfo[] volumes);

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

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

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

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

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

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

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

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

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

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

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

@ -79,7 +79,7 @@ nsresult AndroidMediaReader::ReadMetadata(MediaInfo* aInfo,
mInitialFrame = frameSize; mInitialFrame = frameSize;
VideoFrameContainer* container = mDecoder->GetVideoFrameContainer(); VideoFrameContainer* container = mDecoder->GetVideoFrameContainer();
if (container) { 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 static bool
ShouldTrialCreateGMP(const nsAString& aKeySystem) ShouldTrialCreateGMP(const nsAString& aKeySystem)
{ {
// Trial create where the CDM has a decoder; // Trial create where the CDM has a Windows Media Foundation decoder.
// * ClearKey and Primetime on Windows Vista and later.
// * Primetime on MacOSX Lion and later.
return
Preferences::GetBool("media.gmp.trial-create.enabled", false) &&
#ifdef XP_WIN #ifdef XP_WIN
IsVistaOrLater(); return Preferences::GetBool("media.gmp.trial-create.enabled", false) &&
#elif defined(XP_MACOSX) aKeySystem.EqualsLiteral("org.w3.clearkey") &&
aKeySystem.EqualsLiteral("com.adobe.primetime") && IsVistaOrLater();
nsCocoaFeatures::OnLionOrLater();
#else #else
false; return false;
#endif #endif
} }

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

@ -59,42 +59,12 @@ MediaKeys::MediaKeys(nsPIDOMWindow* aParent,
this, NS_ConvertUTF16toUTF8(mKeySystem).get()); 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() MediaKeys::~MediaKeys()
{ {
Shutdown(); Shutdown();
EME_LOG("MediaKeys[%p] destroyed", this); 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 void
MediaKeys::Terminated() MediaKeys::Terminated()
{ {
@ -102,8 +72,14 @@ MediaKeys::Terminated()
KeySessionHashMap keySessions; KeySessionHashMap keySessions;
// Remove entries during iteration will screw it. Make a copy first. // Remove entries during iteration will screw it. Make a copy first.
mKeySessions.Enumerate(&CopySessions, &keySessions); for (auto iter = mKeySessions.Iter(); !iter.Done(); iter.Next()) {
keySessions.Enumerate(&CloseSessions, nullptr); 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(); keySessions.Clear();
MOZ_ASSERT(mKeySessions.Count() == 0); MOZ_ASSERT(mKeySessions.Count() == 0);
@ -125,7 +101,12 @@ MediaKeys::Shutdown()
nsRefPtr<MediaKeys> kungFuDeathGrip = this; 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(); mPromises.Clear();
} }

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

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

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

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

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

@ -311,20 +311,16 @@ GMPServiceChild::GetBridgedGMPContentParent(ProcessId aOtherPid,
mContentParents.Get(aOtherPid, aGMPContentParent); 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 void
GMPServiceChild::RemoveGMPContentParent(GMPContentParent* aGMPContentParent) 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 static PLDHashOperator

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

@ -240,7 +240,7 @@ void OggReader::SetupTargetTheora(TheoraState* aTheoraState)
VideoFrameContainer* container = mDecoder->GetVideoFrameContainer(); VideoFrameContainer* container = mDecoder->GetVideoFrameContainer();
if (container) { 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. // Copy Theora info data for time computations on other threads.

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

@ -744,7 +744,7 @@ MediaCodecReader::HandleResourceAllocated()
VideoFrameContainer* container = mDecoder->GetVideoFrameContainer(); VideoFrameContainer* container = mDecoder->GetVideoFrameContainer();
if (container) { if (container) {
container->ClearCurrentFrame( 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(); 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 void
MediaCodecReader::ReleaseAllTextureClients() MediaCodecReader::ReleaseAllTextureClients()
{ {
@ -884,7 +858,17 @@ MediaCodecReader::ReleaseAllTextureClients()
} }
printf_stderr("All TextureClients should be released already"); 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(); mTextureClientIndexes.Clear();
} }

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

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

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

@ -307,7 +307,7 @@ void MediaOmxReader::HandleResourceAllocated()
mInitialFrame = frameSize; mInitialFrame = frameSize;
VideoFrameContainer* container = mDecoder->GetVideoFrameContainer(); VideoFrameContainer* container = mDecoder->GetVideoFrameContainer();
if (container) { 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; 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 { class EMEDecryptor : public MediaDataDecoder {
public: public:
@ -107,7 +98,11 @@ public:
nsresult Flush() override { nsresult Flush() override {
MOZ_ASSERT(mTaskQueue->IsCurrentThreadIn()); MOZ_ASSERT(mTaskQueue->IsCurrentThreadIn());
MOZ_ASSERT(!mIsShutdown); 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(); nsresult rv = mDecoder->Flush();
unused << NS_WARN_IF(NS_FAILED(rv)); unused << NS_WARN_IF(NS_FAILED(rv));
mSamplesWaitingForKey->Flush(); mSamplesWaitingForKey->Flush();
@ -117,7 +112,11 @@ public:
nsresult Drain() override { nsresult Drain() override {
MOZ_ASSERT(mTaskQueue->IsCurrentThreadIn()); MOZ_ASSERT(mTaskQueue->IsCurrentThreadIn());
MOZ_ASSERT(!mIsShutdown); 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(); nsresult rv = mDecoder->Drain();
unused << NS_WARN_IF(NS_FAILED(rv)); unused << NS_WARN_IF(NS_FAILED(rv));
return rv; return rv;

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

@ -100,7 +100,7 @@ public:
LOCAL_EGL_NONE, LOCAL_EGL_NONE 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, EGLImage eglImage = sEGLLibrary.fCreateImage(EGL_DISPLAY(), eglContext,
LOCAL_EGL_GL_TEXTURE_2D_KHR, LOCAL_EGL_GL_TEXTURE_2D_KHR,
(EGLClientBuffer)tex, attribs); (EGLClientBuffer)tex, attribs);

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

@ -83,26 +83,21 @@ class OriginKeyStore : public nsISupports
return NS_OK; 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) void Clear(int64_t aSinceWhen)
{ {
// Avoid int64_t* <-> void* casting offset // Avoid int64_t* <-> void* casting offset
OriginKey since(nsCString(), aSinceWhen / PR_USEC_PER_SEC); 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; mPersistCount = 0;
} }

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

@ -141,25 +141,6 @@ MediaSystemResourceService::ReleaseResource(media::MediaSystemResourceManagerPar
UpdateRequests(aResourceType); 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 void
MediaSystemResourceService::ReleaseResource(media::MediaSystemResourceManagerParent* aParent) MediaSystemResourceService::ReleaseResource(media::MediaSystemResourceManagerParent* aParent)
{ {
@ -169,8 +150,11 @@ MediaSystemResourceService::ReleaseResource(media::MediaSystemResourceManagerPar
return; return;
} }
ReleaseResourceData data = { this, aParent }; for (auto iter = mResources.Iter(); !iter.Done(); iter.Next()) {
mResources.Enumerate(ReleaseResourceForKey, &data); const uint32_t& key = iter.Key();
RemoveRequests(aParent, static_cast<MediaSystemResourceType>(key));
UpdateRequests(static_cast<MediaSystemResourceType>(key));
}
} }
void void

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

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

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

@ -501,40 +501,8 @@ nsPicoService::GetServiceType(SpeechServiceType* aServiceType)
return NS_OK; return NS_OK;
} }
struct VoiceTraverserData
{
nsPicoService* mService;
nsSynthVoiceRegistry* mRegistry;
};
// private methods // 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 void
nsPicoService::Init() nsPicoService::Init()
{ {
@ -617,8 +585,28 @@ nsPicoService::Init()
void void
nsPicoService::RegisterVoices() nsPicoService::RegisterVoices()
{ {
VoiceTraverserData data = { this, nsSynthVoiceRegistry::GetInstance() }; nsSynthVoiceRegistry* registry = nsSynthVoiceRegistry::GetInstance();
mVoices.Enumerate(PicoAddVoiceTraverser, &data);
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; mInitialized = true;
} }

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

@ -71,6 +71,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=870022
function runTest(iframe) { function runTest(iframe) {
var doc = iframe.contentDocument; var doc = iframe.contentDocument;
var win = iframe.contentWindow;
var img = doc.querySelector("img"); var img = doc.querySelector("img");
var source = doc.querySelector("source"); 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.sizes, undefined, "sizes should not be visible on <source>");
is(source.srcset, undefined, "srcset 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 imgSizesDesc = Object.getOwnPropertyDescriptor(win.HTMLImageElement.prototype, "sizes");
var sourceSizesDesc = Object.getOwnPropertyDescriptor(HTMLSourceElement.prototype, "sizes"); var sourceSizesDesc = Object.getOwnPropertyDescriptor(win.HTMLSourceElement.prototype, "sizes");
var sourceSrcsetDesc = Object.getOwnPropertyDescriptor(HTMLSourceElement.prototype, "srcset"); var sourceSrcsetDesc = Object.getOwnPropertyDescriptor(win.HTMLSourceElement.prototype, "srcset");
is(imgSizesDesc, undefined, "HTMLImageElement should know nothing of sizes"); is(imgSizesDesc, undefined, "HTMLImageElement should know nothing of sizes");
is(sourceSizesDesc, undefined, "HTMLSourceElement should know nothing of sizes"); is(sourceSizesDesc, undefined, "HTMLSourceElement should know nothing of sizes");
is(sourceSrcsetDesc, undefined, "HTMLSourceElement should know nothing of srcset"); 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> <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=870021">Mozilla Bug 870021</a>
<div id="imgContainer"> <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> </div>
<script type="application/javascript"> <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 // Ensure that disabling the pref works as expected
SpecialPowers.pushPrefEnv({'set': [[ "dom.image.srcset.enabled", false ]] }, function() { SpecialPowers.pushPrefEnv({'set': [[ "dom.image.srcset.enabled", false ]] }, function() {
var container = document.querySelector("#imgContainer"); var container = document.querySelector("#imgContainer");
// We want to re-create the element with the pref disabled to ensure
// webIDL attributes are not attached var img = document.createElement("img");
container.innerHTML = container.innerHTML + " "; img.setAttribute("src", "http://example.com/tests/image/test/mochitest/blue.png");
var img = container.querySelector("img"); img.setAttribute("srcset", "http://example.com/tests/image/test/mochitest/big.png");
container.insertBefore(img, container.firstChild);
img.addEventListener("load", function imgLoad() { img.addEventListener("load", function imgLoad() {
img.removeEventListener("load", imgLoad); img.removeEventListener("load", imgLoad);
runTest(); runTest();

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

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

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

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

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

@ -135,7 +135,8 @@ nsXULCommandDispatcher::GetFocusedElement(nsIDOMElement** aElement)
CallQueryInterface(focusedContent, aElement); CallQueryInterface(focusedContent, aElement);
// Make sure the caller can access the focused element. // 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 // 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 // to mean "there is no focused element," so to be clear, throw an
// exception. // exception.

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

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

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

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

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

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

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

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

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

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

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

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

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

@ -9,7 +9,6 @@
#include "GLContextTypes.h" #include "GLContextTypes.h"
#include "nsAutoPtr.h" #include "nsAutoPtr.h"
#include "SurfaceTypes.h" #include "SurfaceTypes.h"
#include "mozilla/TypedEnumBits.h"
#include "nsSize.h" // for gfx::IntSize (needed by GLContextProviderImpl.h below) #include "nsSize.h" // for gfx::IntSize (needed by GLContextProviderImpl.h below)
@ -18,16 +17,6 @@ class nsIWidget;
namespace mozilla { namespace mozilla {
namespace gl { 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 #define IN_GL_CONTEXT_PROVIDER_H
// Null is always there // Null is always there
@ -36,47 +25,45 @@ MOZ_MAKE_ENUM_CLASS_BITWISE_OPERATORS(CreateContextFlags)
#undef GL_CONTEXT_PROVIDER_NAME #undef GL_CONTEXT_PROVIDER_NAME
#ifdef XP_WIN #ifdef XP_WIN
#define GL_CONTEXT_PROVIDER_NAME GLContextProviderWGL #define GL_CONTEXT_PROVIDER_NAME GLContextProviderWGL
#include "GLContextProviderImpl.h" #include "GLContextProviderImpl.h"
#undef GL_CONTEXT_PROVIDER_NAME #undef GL_CONTEXT_PROVIDER_NAME
#define GL_CONTEXT_PROVIDER_DEFAULT GLContextProviderWGL #define GL_CONTEXT_PROVIDER_DEFAULT GLContextProviderWGL
#define DEFAULT_IMPL WGL #define DEFAULT_IMPL WGL
#endif #endif
#ifdef XP_MACOSX #ifdef XP_MACOSX
#define GL_CONTEXT_PROVIDER_NAME GLContextProviderCGL #define GL_CONTEXT_PROVIDER_NAME GLContextProviderCGL
#include "GLContextProviderImpl.h" #include "GLContextProviderImpl.h"
#undef GL_CONTEXT_PROVIDER_NAME #undef GL_CONTEXT_PROVIDER_NAME
#define GL_CONTEXT_PROVIDER_DEFAULT GLContextProviderCGL #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 #endif
#if defined(ANDROID) || defined(XP_WIN)
#define GL_CONTEXT_PROVIDER_NAME GLContextProviderEGL #define GL_CONTEXT_PROVIDER_NAME GLContextProviderEGL
#include "GLContextProviderImpl.h" #include "GLContextProviderImpl.h"
#undef GL_CONTEXT_PROVIDER_NAME #undef GL_CONTEXT_PROVIDER_NAME
#ifndef GL_CONTEXT_PROVIDER_DEFAULT #ifndef GL_CONTEXT_PROVIDER_DEFAULT
#define GL_CONTEXT_PROVIDER_DEFAULT GLContextProviderEGL #define GL_CONTEXT_PROVIDER_DEFAULT GLContextProviderEGL
#endif
#endif #endif
#ifdef MOZ_GL_PROVIDER #ifdef MOZ_GL_PROVIDER
#define GL_CONTEXT_PROVIDER_NAME MOZ_GL_PROVIDER #define GL_CONTEXT_PROVIDER_NAME MOZ_GL_PROVIDER
#include "GLContextProviderImpl.h" #include "GLContextProviderImpl.h"
#undef GL_CONTEXT_PROVIDER_NAME #undef GL_CONTEXT_PROVIDER_NAME
#define GL_CONTEXT_PROVIDER_DEFAULT MOZ_GL_PROVIDER #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
#endif #endif
#ifdef GL_CONTEXT_PROVIDER_DEFAULT #ifdef GL_CONTEXT_PROVIDER_DEFAULT
typedef GL_CONTEXT_PROVIDER_DEFAULT GLContextProvider; typedef GL_CONTEXT_PROVIDER_DEFAULT GLContextProvider;
#else #else
typedef GLContextProviderNull GLContextProvider; typedef GLContextProviderNull GLContextProvider;
#endif #endif
#undef IN_GL_CONTEXT_PROVIDER_H #undef IN_GL_CONTEXT_PROVIDER_H

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

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

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

@ -3,116 +3,108 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this * 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/. */ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "mozilla/ArrayUtils.h" #if defined(MOZ_WIDGET_GTK)
#include <gdk/gdkx.h>
#include "GLContextEGL.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) #if defined(XP_UNIX)
#ifdef MOZ_WIDGET_GONK
#include "libdisplay/GonkDisplay.h"
#include "nsWindow.h"
#include "nsScreenManagerGonk.h"
#endif
#ifdef MOZ_WIDGET_GTK #ifdef ANDROID
#include <gdk/gdkx.h> /* from widget */
// we're using default display for now #ifdef MOZ_WIDGET_ANDROID
#define GET_NATIVE_WINDOW(aWidget) (EGLNativeWindowType)GDK_WINDOW_XID((GdkWindow *) aWidget->GetNativeData(NS_NATIVE_WINDOW)) #include "AndroidBridge.h"
#elif defined(MOZ_WIDGET_QT) #endif
#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
#if defined(ANDROID) #include <android/log.h>
/* from widget */ #define LOG(args...) __android_log_print(ANDROID_LOG_INFO, "Gonk" , ## args)
#if defined(MOZ_WIDGET_ANDROID)
#include "AndroidBridge.h"
#endif
#include <android/log.h> #ifdef MOZ_WIDGET_GONK
#define LOG(args...) __android_log_print(ANDROID_LOG_INFO, "Gonk" , ## args) #include "cutils/properties.h"
#include <ui/GraphicBuffer.h>
# if defined(MOZ_WIDGET_GONK) using namespace android;
# include "cutils/properties.h" #endif
# include <ui/GraphicBuffer.h> #endif
using namespace android; #define GLES2_LIB "libGLESv2.so"
# endif #define GLES2_LIB2 "libGLESv2.so.2"
#endif
#define GLES2_LIB "libGLESv2.so"
#define GLES2_LIB2 "libGLESv2.so.2"
#elif defined(XP_WIN) #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 #include <windows.h>
#define WIN32_LEAN_AND_MEAN 1
#endif
#include <windows.h> // a little helper
class AutoDestroyHWND {
// a little helper public:
class AutoDestroyHWND { AutoDestroyHWND(HWND aWnd = nullptr)
public: : mWnd(aWnd)
AutoDestroyHWND(HWND aWnd = nullptr) {
: mWnd(aWnd)
{
}
~AutoDestroyHWND() {
if (mWnd) {
::DestroyWindow(mWnd);
} }
}
operator HWND() { ~AutoDestroyHWND() {
return mWnd; if (mWnd) {
} ::DestroyWindow(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; 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 #else
#error "Platform not recognized"
#error "Platform not recognized"
#endif #endif
#include "mozilla/Preferences.h"
#include "gfxUtils.h"
#include "gfxFailure.h"
#include "gfxASurface.h" #include "gfxASurface.h"
#include "gfxCrashReporterUtils.h"
#include "gfxFailure.h"
#include "gfxPlatform.h" #include "gfxPlatform.h"
#include "gfxUtils.h"
#include "GLBlitHelper.h"
#include "GLContextEGL.h"
#include "GLContextProvider.h" #include "GLContextProvider.h"
#include "GLLibraryEGL.h" #include "GLLibraryEGL.h"
#include "TextureImageEGL.h" #include "mozilla/ArrayUtils.h"
#include "mozilla/Preferences.h"
#include "nsDebug.h" #include "nsDebug.h"
#include "nsThreadUtils.h"
#include "nsIWidget.h" #include "nsIWidget.h"
#include "nsThreadUtils.h"
#include "gfxCrashReporterUtils.h"
#include "ScopedGLHelpers.h" #include "ScopedGLHelpers.h"
#include "GLBlitHelper.h" #include "TextureImageEGL.h"
using namespace mozilla::gfx; using namespace mozilla::gfx;
@ -190,18 +182,16 @@ DestroySurface(EGLSurface oldSurface) {
static EGLSurface static EGLSurface
CreateSurfaceForWindow(nsIWidget* widget, const EGLConfig& config) { 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(); mozilla::AndroidBridge::Bridge()->RegisterCompositor();
newSurface = mozilla::AndroidBridge::Bridge()->CreateEGLSurfaceForCompositor(); newSurface = mozilla::AndroidBridge::Bridge()->CreateEGLSurfaceForCompositor();
if (newSurface == EGL_NO_SURFACE) { #else
return EGL_NO_SURFACE;
}
#else
MOZ_ASSERT(widget != nullptr); MOZ_ASSERT(widget != nullptr);
newSurface = sEGLLibrary.fCreateWindowSurface(EGL_DISPLAY(), config, GET_NATIVE_WINDOW(widget), 0); newSurface = sEGLLibrary.fCreateWindowSurface(EGL_DISPLAY(), config,
#endif GET_NATIVE_WINDOW(widget), 0);
#endif
return newSurface; return newSurface;
} }
@ -215,8 +205,8 @@ GLContextEGL::GLContextEGL(
: GLContext(caps, shareContext, isOffscreen) : GLContext(caps, shareContext, isOffscreen)
, mConfig(config) , mConfig(config)
, mSurface(surface) , mSurface(surface)
, mSurfaceOverride(EGL_NO_SURFACE)
, mContext(context) , mContext(context)
, mSurfaceOverride(EGL_NO_SURFACE)
, mThebesSurface(nullptr) , mThebesSurface(nullptr)
, mBound(false) , mBound(false)
, mIsPBuffer(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. // If we get here, then by definition we know that we want to get a new surface.
ReleaseSurface(); ReleaseSurface();
mSurface = mozilla::gl::CreateSurfaceForWindow(nullptr, mConfig); // the nullptr here is where we assume Android. mSurface = mozilla::gl::CreateSurfaceForWindow(nullptr, mConfig); // the nullptr here is where we assume Android.
if (mSurface == EGL_NO_SURFACE) { if (!mSurface) {
return false; return false;
} }
return MakeCurrent(true); return MakeCurrent(true);
@ -490,6 +480,10 @@ GLContextEGL::CreateSurfaceForWindow(nsIWidget* aWidget)
} }
EGLSurface surface = mozilla::gl::CreateSurfaceForWindow(aWidget, config); EGLSurface surface = mozilla::gl::CreateSurfaceForWindow(aWidget, config);
if (!surface) {
MOZ_CRASH("Failed to create EGLSurface for window!\n");
return nullptr;
}
return surface; return surface;
} }
@ -780,8 +774,7 @@ GLContextProviderEGL::CreateForWindow(nsIWidget *aWidget)
} }
EGLSurface surface = mozilla::gl::CreateSurfaceForWindow(aWidget, config); EGLSurface surface = mozilla::gl::CreateSurfaceForWindow(aWidget, config);
if (!surface) {
if (surface == EGL_NO_SURFACE) {
MOZ_CRASH("Failed to create EGLSurface!\n"); MOZ_CRASH("Failed to create EGLSurface!\n");
return nullptr; return nullptr;
} }
@ -839,60 +832,144 @@ GLContextProviderEGL::DestroyEGLSurface(EGLSurface surface)
} }
#endif // defined(ANDROID) #endif // defined(ANDROID)
already_AddRefed<GLContextEGL> static void
GLContextEGL::CreateEGLPBufferOffscreenContext(const mozilla::gfx::IntSize& size) FillContextAttribs(bool alpha, bool depth, bool stencil, bool bpp16,
nsTArray<EGLint>* out)
{ {
EGLConfig config; out->AppendElement(LOCAL_EGL_SURFACE_TYPE);
EGLSurface surface; out->AppendElement(LOCAL_EGL_PBUFFER_BIT);
const EGLint numConfigs = 1; // We only need one. out->AppendElement(LOCAL_EGL_RENDERABLE_TYPE);
EGLConfig configs[numConfigs]; 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; EGLint foundConfigs = 0;
if (!sEGLLibrary.fChooseConfig(EGL_DISPLAY(), if (!egl->fChooseConfig(egl->Display(), configAttribs, configs, kMaxConfigs,
kEGLConfigAttribsOffscreenPBuffer, &foundConfigs)
configs, numConfigs,
&foundConfigs)
|| foundConfigs == 0) || 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; return nullptr;
} }
// We absolutely don't care, so just pick the first one.
config = configs[0];
if (GLContext::ShouldSpew()) if (GLContext::ShouldSpew())
sEGLLibrary.DumpEGLConfig(config); sEGLLibrary.DumpEGLConfig(config);
mozilla::gfx::IntSize pbSize(size); mozilla::gfx::IntSize pbSize(size);
surface = GLContextEGL::CreatePBufferSurfaceTryingPowerOfTwo(config, EGLSurface surface = GLContextEGL::CreatePBufferSurfaceTryingPowerOfTwo(config,
LOCAL_EGL_NONE, LOCAL_EGL_NONE,
pbSize); pbSize);
if (!surface) { if (!surface) {
NS_WARNING("Failed to create PBuffer for context!"); NS_WARNING("Failed to create PBuffer for context!");
return nullptr; return nullptr;
} }
SurfaceCaps dummyCaps = SurfaceCaps::Any();
nsRefPtr<GLContextEGL> glContext = RefPtr<GLContextEGL> gl = GLContextEGL::CreateGLContext(configCaps, nullptr, true,
GLContextEGL::CreateGLContext(dummyCaps, config, surface);
nullptr, true, if (!gl) {
config, surface);
if (!glContext) {
NS_WARNING("Failed to create GLContext from PBuffer"); NS_WARNING("Failed to create GLContext from PBuffer");
sEGLLibrary.fDestroySurface(EGL_DISPLAY(), surface); sEGLLibrary.fDestroySurface(sEGLLibrary.Display(), surface);
return nullptr; return nullptr;
} }
if (!glContext->Init()) { if (!gl->Init()) {
NS_WARNING("Failed to initialize GLContext!"); NS_WARNING("Failed to initialize GLContext!");
// GLContextEGL::dtor will destroy |surface| for us. // GLContextEGL::dtor will destroy |surface| for us.
return nullptr; return nullptr;
} }
return glContext.forget(); return gl.forget();
} }
already_AddRefed<GLContextEGL> /*static*/ already_AddRefed<GLContextEGL>
GLContextEGL::CreateEGLPixmapOffscreenContext(const mozilla::gfx::IntSize& size) GLContextEGL::CreateEGLPixmapOffscreenContext(const mozilla::gfx::IntSize& size)
{ {
gfxASurface *thebesSurface = nullptr; gfxASurface *thebesSurface = nullptr;
@ -932,49 +1009,77 @@ GLContextEGL::CreateEGLPixmapOffscreenContext(const mozilla::gfx::IntSize& size)
return glContext.forget(); return glContext.forget();
} }
already_AddRefed<GLContext> /*static*/ already_AddRefed<GLContext>
GLContextProviderEGL::CreateHeadless(CreateContextFlags flags) 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; return nullptr;
}
mozilla::gfx::IntSize dummySize = mozilla::gfx::IntSize(16, 16); mozilla::gfx::IntSize dummySize = mozilla::gfx::IntSize(16, 16);
nsRefPtr<GLContext> glContext; SurfaceCaps dummyCaps = SurfaceCaps::Any();
glContext = GLContextEGL::CreateEGLPBufferOffscreenContext(dummySize); return GLContextEGL::CreateEGLPBufferOffscreenContext(dummySize, dummyCaps);
if (!glContext)
return nullptr;
return glContext.forget();
} }
// Under EGL, on Android, pbuffers are supported fine, though // Under EGL, on Android, pbuffers are supported fine, though
// often without the ability to texture from them directly. // often without the ability to texture from them directly.
already_AddRefed<GLContext> /*static*/ already_AddRefed<GLContext>
GLContextProviderEGL::CreateOffscreen(const mozilla::gfx::IntSize& size, GLContextProviderEGL::CreateOffscreen(const mozilla::gfx::IntSize& size,
const SurfaceCaps& caps, const SurfaceCaps& minCaps,
CreateContextFlags flags) CreateContextFlags flags)
{ {
nsRefPtr<GLContext> glContext = CreateHeadless(flags); bool forceEnableHardware = bool(flags & CreateContextFlags::FORCE_ENABLE_HARDWARE);
if (!glContext) if (!sEGLLibrary.EnsureInitialized(forceEnableHardware))
return nullptr; 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 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) // 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 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) // and 3) each EGL context eats 750k on B2G (bug 813783)
GLContext* /*static*/ GLContext*
GLContextProviderEGL::GetGlobalContext() GLContextProviderEGL::GetGlobalContext()
{ {
return nullptr; return nullptr;
} }
void /*static*/ void
GLContextProviderEGL::Shutdown() GLContextProviderEGL::Shutdown()
{ {
} }

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

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

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

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

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

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

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

@ -7,6 +7,7 @@
#define GLCONTEXT_TYPES_H_ #define GLCONTEXT_TYPES_H_
#include "GLTypes.h" #include "GLTypes.h"
#include "mozilla/TypedEnumBits.h"
namespace mozilla { namespace mozilla {
namespace gl { namespace gl {
@ -43,6 +44,16 @@ struct GLFormats
GLsizei samples; 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 gl */
} /* namespace mozilla */ } /* namespace mozilla */

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

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

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

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

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

@ -21,6 +21,7 @@ typedef XID GLXContextID;
typedef XID GLXWindow; typedef XID GLXWindow;
typedef XID GLXPbuffer; typedef XID GLXPbuffer;
// end of stuff from glx.h // end of stuff from glx.h
#include "prenv.h"
struct PRLibrary; struct PRLibrary;
class gfxASurface; class gfxASurface;
@ -108,6 +109,12 @@ public:
bool SupportsTextureFromPixmap(gfxASurface* aSurface); bool SupportsTextureFromPixmap(gfxASurface* aSurface);
bool IsATI() { return mIsATI; } bool IsATI() { return mIsATI; }
bool GLXVersionCheck(int aMajor, int aMinor); 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: private:

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

@ -41,17 +41,14 @@ CreatePBufferSurface(GLLibraryEGL* egl,
} }
/*static*/ UniquePtr<SharedSurface_ANGLEShareHandle> /*static*/ UniquePtr<SharedSurface_ANGLEShareHandle>
SharedSurface_ANGLEShareHandle::Create(GLContext* gl, SharedSurface_ANGLEShareHandle::Create(GLContext* gl, EGLConfig config,
EGLContext context, EGLConfig config,
const gfx::IntSize& size, bool hasAlpha) const gfx::IntSize& size, bool hasAlpha)
{ {
GLLibraryEGL* egl = &sEGLLibrary; GLLibraryEGL* egl = &sEGLLibrary;
MOZ_ASSERT(egl); MOZ_ASSERT(egl);
MOZ_ASSERT(egl->IsExtensionSupported( MOZ_ASSERT(egl->IsExtensionSupported(
GLLibraryEGL::ANGLE_surface_d3d_texture_2d_share_handle)); GLLibraryEGL::ANGLE_surface_d3d_texture_2d_share_handle));
MOZ_ASSERT(config);
if (!context || !config)
return nullptr;
EGLDisplay display = egl->Display(); EGLDisplay display = egl->Display();
EGLSurface pbuffer = CreatePBufferSurface(egl, display, config, size); EGLSurface pbuffer = CreatePBufferSurface(egl, display, config, size);
@ -82,8 +79,8 @@ SharedSurface_ANGLEShareHandle::Create(GLContext* gl,
} }
typedef SharedSurface_ANGLEShareHandle ptrT; typedef SharedSurface_ANGLEShareHandle ptrT;
UniquePtr<ptrT> ret( new ptrT(gl, egl, size, hasAlpha, context, UniquePtr<ptrT> ret( new ptrT(gl, egl, size, hasAlpha, pbuffer, shareHandle,
pbuffer, shareHandle, keyedMutex, fence) ); keyedMutex, fence) );
return Move(ret); return Move(ret);
} }
@ -97,7 +94,6 @@ SharedSurface_ANGLEShareHandle::SharedSurface_ANGLEShareHandle(GLContext* gl,
GLLibraryEGL* egl, GLLibraryEGL* egl,
const gfx::IntSize& size, const gfx::IntSize& size,
bool hasAlpha, bool hasAlpha,
EGLContext context,
EGLSurface pbuffer, EGLSurface pbuffer,
HANDLE shareHandle, HANDLE shareHandle,
const RefPtr<IDXGIKeyedMutex>& keyedMutex, const RefPtr<IDXGIKeyedMutex>& keyedMutex,
@ -109,7 +105,6 @@ SharedSurface_ANGLEShareHandle::SharedSurface_ANGLEShareHandle(GLContext* gl,
hasAlpha, hasAlpha,
true) true)
, mEGL(egl) , mEGL(egl)
, mContext(context)
, mPBuffer(pbuffer) , mPBuffer(pbuffer)
, mShareHandle(shareHandle) , mShareHandle(shareHandle)
, mKeyedMutex(keyedMutex) , mKeyedMutex(keyedMutex)
@ -281,137 +276,6 @@ SharedSurface_ANGLEShareHandle::ToSurfaceDescriptor(layers::SurfaceDescriptor* c
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// Factory // 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> /*static*/ UniquePtr<SurfaceFactory_ANGLEShareHandle>
SurfaceFactory_ANGLEShareHandle::Create(GLContext* gl, const SurfaceCaps& caps, SurfaceFactory_ANGLEShareHandle::Create(GLContext* gl, const SurfaceCaps& caps,
const RefPtr<layers::ISurfaceAllocator>& allocator, const RefPtr<layers::ISurfaceAllocator>& allocator,
@ -425,13 +289,10 @@ SurfaceFactory_ANGLEShareHandle::Create(GLContext* gl, const SurfaceCaps& caps,
if (!egl->IsExtensionSupported(ext)) if (!egl->IsExtensionSupported(ext))
return nullptr; return nullptr;
bool success; EGLConfig config = GLContextEGL::Cast(gl)->mConfig;
typedef SurfaceFactory_ANGLEShareHandle ptrT; typedef SurfaceFactory_ANGLEShareHandle ptrT;
UniquePtr<ptrT> ret( new ptrT(gl, caps, allocator, flags, egl, &success) ); UniquePtr<ptrT> ret( new ptrT(gl, caps, allocator, flags, egl, config) );
if (!success)
return nullptr;
return Move(ret); return Move(ret);
} }
@ -440,22 +301,12 @@ SurfaceFactory_ANGLEShareHandle::SurfaceFactory_ANGLEShareHandle(GLContext* gl,
const RefPtr<layers::ISurfaceAllocator>& allocator, const RefPtr<layers::ISurfaceAllocator>& allocator,
const layers::TextureFlags& flags, const layers::TextureFlags& flags,
GLLibraryEGL* egl, GLLibraryEGL* egl,
bool* const out_success) EGLConfig config)
: SurfaceFactory(SharedSurfaceType::EGLSurfaceANGLE, gl, caps, allocator, flags) : SurfaceFactory(SharedSurfaceType::EGLSurfaceANGLE, gl, caps, allocator, flags)
, mProdGL(gl) , mProdGL(gl)
, mEGL(egl) , mEGL(egl)
{ , mConfig(config)
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;
}
} /* namespace gl */ } /* namespace gl */
} /* namespace mozilla */ } /* namespace mozilla */

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

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

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

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

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

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

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

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

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

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

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

@ -46,7 +46,7 @@ static void DrawDebugOverlay(mozilla::gfx::DrawTarget* dt, int x, int y, int wid
// Draw border // Draw border
c.NewPath(); 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.Rectangle(gfxRect(0, 0, width, height));
c.Stroke(); c.Stroke();
@ -63,12 +63,12 @@ static void DrawDebugOverlay(mozilla::gfx::DrawTarget* dt, int x, int y, int wid
int textWidth = extents.width + 6; int textWidth = extents.width + 6;
c.NewPath(); 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.Rectangle(gfxRect(gfxPoint(2,2),gfxSize(textWidth, 30)));
c.Fill(); c.Fill();
c.NewPath(); 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.Rectangle(gfxRect(gfxPoint(2,2),gfxSize(textWidth, 30)));
c.Stroke(); c.Stroke();

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