Merge inbound to central, a=merge CLOSED TREE

MozReview-Commit-ID: CBL7SUEUGKV
This commit is contained in:
Wes Kocher 2017-07-19 17:29:56 -07:00
commit b5bcc4905e
193 changed files with 4031 additions and 3168 deletions

View file

@ -674,7 +674,13 @@ DocAccessibleParent::SendParentCOMProxy()
IAccessibleHolder::COMPtrType ptr(rawNative);
IAccessibleHolder holder(Move(ptr));
Unused << PDocAccessibleParent::SendParentCOMProxy(holder);
if (!PDocAccessibleParent::SendParentCOMProxy(holder)) {
return;
}
#if defined(MOZ_CONTENT_SANDBOX)
mParentProxyStream = Move(holder.GetPreservedStream());
#endif // defined(MOZ_CONTENT_SANDBOX)
}
void

View file

@ -236,7 +236,11 @@ private:
#if defined(XP_WIN)
// The handle associated with the emulated window that contains this document
HWND mEmulatedWindowHandle;
#endif
#if defined(MOZ_CONTENT_SANDBOX)
mscom::PreservedStreamPtr mParentProxyStream;
#endif // defined(MOZ_CONTENT_SANDBOX)
#endif // defined(XP_WIN)
/*
* Conceptually this is a map from IDs to proxies, but we store the ID in the

View file

@ -13,6 +13,8 @@ skip-if = !e10s # Tab spinner is e10s only.
[browser_tabSwitchPrintPreview.js]
skip-if = os == 'mac'
[browser_navigatePinnedTab.js]
[browser_new_file_whitelisted_http_tab.js]
skip-if = !e10s # Test only relevant for e10s.
[browser_new_web_tab_in_file_process_pref.js]
skip-if = !e10s # Pref and test only relevant for e10s.
[browser_opened_file_tab_navigated_to_web.js]

View file

@ -0,0 +1,27 @@
/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
/* vim: set ft=javascript ts=2 et sw=2 tw=80: */
const TEST_HTTP = "http://example.org/";
// Test for bug 1378377.
add_task(async function() {
// Set prefs to ensure file content process.
await SpecialPowers.pushPrefEnv(
{set: [["browser.tabs.remote.separateFileUriProcess", true]]});
await BrowserTestUtils.withNewTab(TEST_HTTP, async function(fileBrowser) {
is(fileBrowser.remoteType, E10SUtils.WEB_REMOTE_TYPE,
"Check that tab normally has web remote type.");
});
// Set prefs to whitelist TEST_HTTP for file:// URI use.
await SpecialPowers.pushPrefEnv(
{set: [["capability.policy.policynames", "allowFileURI"],
["capability.policy.allowFileURI.sites", TEST_HTTP],
["capability.policy.allowFileURI.checkloaduri.enabled", "allAccess"]]});
await BrowserTestUtils.withNewTab(TEST_HTTP, async function(fileBrowser) {
is(fileBrowser.remoteType, E10SUtils.FILE_REMOTE_TYPE,
"Check that tab now has file remote type.");
});
});

View file

@ -47,6 +47,13 @@ const LARGE_ALLOCATION_REMOTE_TYPE = "webLargeAllocation";
const DEFAULT_REMOTE_TYPE = WEB_REMOTE_TYPE;
function validatedWebRemoteType(aPreferredRemoteType, aTargetUri, aCurrentUri) {
// If the domain is whitelisted to allow it to use file:// URIs, then we have
// to run it in a file content process, in case it uses file:// sub-resources.
const sm = Services.scriptSecurityManager;
if (sm.inFileURIWhitelist(aTargetUri)) {
return FILE_REMOTE_TYPE;
}
if (!aPreferredRemoteType) {
return WEB_REMOTE_TYPE;
}
@ -60,7 +67,6 @@ function validatedWebRemoteType(aPreferredRemoteType, aTargetUri, aCurrentUri) {
// If aCurrentUri is passed then we should only allow FILE_REMOTE_TYPE
// when it is same origin as target.
if (aCurrentUri) {
const sm = Services.scriptSecurityManager;
try {
// checkSameOriginURI throws when not same origin.
sm.checkSameOriginURI(aCurrentUri, aTargetUri, false);

View file

@ -126,6 +126,13 @@ interface nsIScriptSecurityManager : nsISupports
in AUTF8String uri,
in unsigned long flags);
/**
* Returns true if the URI is from a domain that is white-listed through
* prefs to be allowed to use file:// URIs.
* @param aUri the URI to be tested
*/
bool inFileURIWhitelist(in nsIURI aUri);
///////////////// Principals ///////////////////////
/**

View file

@ -941,10 +941,10 @@ nsScriptSecurityManager::CheckLoadURIFlags(nsIURI *aSourceURI,
if (hasFlags) {
// Allow domains that were whitelisted in the prefs. In 99.9% of cases,
// this array is empty.
for (nsIURI* uri : EnsureFileURIWhitelist()) {
if (EqualOrSubdomain(aSourceURI, uri)) {
return NS_OK;
}
bool isWhitelisted;
MOZ_ALWAYS_SUCCEEDS(InFileURIWhitelist(aSourceURI, &isWhitelisted));
if (isWhitelisted) {
return NS_OK;
}
// Allow chrome://
@ -1096,6 +1096,23 @@ nsScriptSecurityManager::CheckLoadURIStrWithPrincipal(nsIPrincipal* aPrincipal,
return rv;
}
NS_IMETHODIMP
nsScriptSecurityManager::InFileURIWhitelist(nsIURI* aUri, bool* aResult)
{
MOZ_ASSERT(aUri);
MOZ_ASSERT(aResult);
*aResult = false;
for (nsIURI* uri : EnsureFileURIWhitelist()) {
if (EqualOrSubdomain(aUri, uri)) {
*aResult = true;
return NS_OK;
}
}
return NS_OK;
}
///////////////// Principals ///////////////////////
NS_IMETHODIMP

View file

@ -33,10 +33,10 @@
/* Style */
.notificationbox .notification {
background-color: InfoBackground;
color: var(--theme-body-color-alt);
background-color: var(--theme-body-background);
text-shadow: none;
border-top: 1px solid ThreeDShadow;
border-bottom: 1px solid ThreeDShadow;
border-bottom: 1px solid var(--theme-splitter-color);
}
.notificationbox .notification[data-type="info"] {

View file

@ -55,6 +55,10 @@ CustomElementCallback::Call()
mArgs.name, mArgs.oldValue, mArgs.newValue, rv);
break;
}
// If callbacks throw exceptions, it'll be handled and reported in
// Lifecycle*Callback::Call function.
rv.SuppressException();
}
void
@ -88,26 +92,12 @@ CustomElementData::CustomElementData(nsIAtom* aType)
CustomElementData::CustomElementData(nsIAtom* aType, State aState)
: mType(aType)
, mCurrentCallback(-1)
, mElementIsBeingCreated(false)
, mCreatedCallbackInvoked(true)
, mAssociatedMicroTask(-1)
, mState(aState)
{
}
void
CustomElementData::RunCallbackQueue()
{
// Note: It's possible to re-enter this method.
while (static_cast<uint32_t>(++mCurrentCallback) < mCallbackQueue.Length()) {
mCallbackQueue[mCurrentCallback]->Call();
}
mCallbackQueue.Clear();
mCurrentCallback = -1;
}
//-----------------------------------------------------
// CustomElementRegistry
@ -124,7 +114,7 @@ NS_IMPL_CYCLE_COLLECTION_UNLINK_END
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(CustomElementRegistry)
for (auto iter = tmp->mCustomDefinitions.Iter(); !iter.Done(); iter.Next()) {
nsAutoPtr<LifecycleCallbacks>& callbacks = iter.UserData()->mCallbacks;
auto& callbacks = iter.UserData()->mCallbacks;
if (callbacks->mAttributeChangedCallback.WasPassed()) {
NS_CYCLE_COLLECTION_NOTE_EDGE_NAME(cb,
@ -188,43 +178,6 @@ CustomElementRegistry::IsCustomElementEnabled(JSContext* aCx, JSObject* aObject)
nsContentUtils::IsWebComponentsEnabled();
}
/* static */ void
CustomElementRegistry::ProcessTopElementQueue()
{
MOZ_ASSERT(nsContentUtils::IsSafeToRunScript());
nsTArray<RefPtr<CustomElementData>>& stack = *sProcessingStack;
uint32_t firstQueue = stack.LastIndexOf((CustomElementData*) nullptr);
for (uint32_t i = firstQueue + 1; i < stack.Length(); ++i) {
// Callback queue may have already been processed in an earlier
// element queue or in an element queue that was popped
// off more recently.
if (stack[i]->mAssociatedMicroTask != -1) {
stack[i]->RunCallbackQueue();
stack[i]->mAssociatedMicroTask = -1;
}
}
// If this was actually the base element queue, don't bother trying to pop
// the first "queue" marker (sentinel).
if (firstQueue != 0) {
stack.SetLength(firstQueue);
} else {
// Don't pop sentinel for base element queue.
stack.SetLength(1);
}
}
/* static */ void
CustomElementRegistry::XPCOMShutdown()
{
sProcessingStack.reset();
}
/* static */ Maybe<nsTArray<RefPtr<CustomElementData>>>
CustomElementRegistry::sProcessingStack;
CustomElementRegistry::CustomElementRegistry(nsPIDOMWindowInner* aWindow)
: mWindow(aWindow)
, mIsCustomDefinitionRunning(false)
@ -234,12 +187,6 @@ CustomElementRegistry::CustomElementRegistry(nsPIDOMWindowInner* aWindow)
MOZ_ALWAYS_TRUE(mConstructors.init());
mozilla::HoldJSObjects(this);
if (!sProcessingStack) {
sProcessingStack.emplace();
// Add the base queue sentinel to the processing stack.
sProcessingStack->AppendElement((CustomElementData*) nullptr);
}
}
CustomElementRegistry::~CustomElementRegistry()
@ -343,14 +290,15 @@ CustomElementRegistry::SetupCustomElement(Element* aElement,
// Enqueuing the created callback will set the CustomElementData on the
// element, causing prototype swizzling to occur in Element::WrapObject.
EnqueueLifecycleCallback(nsIDocument::eCreated, aElement, nullptr, definition);
// We make it synchronously for createElement/createElementNS in order to
// pass tests. It'll be removed when we deprecate custom elements v0.
SyncInvokeReactions(nsIDocument::eCreated, aElement, definition);
}
void
CustomElementRegistry::EnqueueLifecycleCallback(nsIDocument::ElementCallbackType aType,
Element* aCustomElement,
LifecycleCallbackArgs* aArgs,
CustomElementDefinition* aDefinition)
UniquePtr<CustomElementCallback>
CustomElementRegistry::CreateCustomElementCallback(
nsIDocument::ElementCallbackType aType, Element* aCustomElement,
LifecycleCallbackArgs* aArgs, CustomElementDefinition* aDefinition)
{
RefPtr<CustomElementData> elementData = aCustomElement->GetCustomElementData();
MOZ_ASSERT(elementData, "CustomElementData should exist");
@ -369,7 +317,7 @@ CustomElementRegistry::EnqueueLifecycleCallback(nsIDocument::ElementCallbackType
if (!definition || definition->mLocalName != info->NameAtom()) {
// Trying to enqueue a callback for an element that is not
// a custom element. We are done, nothing to do.
return;
return nullptr;
}
}
@ -403,7 +351,7 @@ CustomElementRegistry::EnqueueLifecycleCallback(nsIDocument::ElementCallbackType
// If there is no such callback, stop.
if (!func) {
return;
return nullptr;
}
if (aType == nsIDocument::eCreated) {
@ -411,55 +359,62 @@ CustomElementRegistry::EnqueueLifecycleCallback(nsIDocument::ElementCallbackType
} else if (!elementData->mCreatedCallbackInvoked) {
// Callbacks other than created callback must not be enqueued
// until after the created callback has been invoked.
return;
return nullptr;
}
// Add CALLBACK to ELEMENT's callback queue.
CustomElementCallback* callback = new CustomElementCallback(aCustomElement,
aType,
func,
elementData);
// Ownership of callback is taken by mCallbackQueue.
elementData->mCallbackQueue.AppendElement(callback);
auto callback =
MakeUnique<CustomElementCallback>(aCustomElement, aType, func, elementData);
if (aArgs) {
callback->SetArgs(*aArgs);
}
if (!elementData->mElementIsBeingCreated) {
CustomElementData* lastData =
sProcessingStack->SafeLastElement(nullptr);
return Move(callback);
}
// A new element queue needs to be pushed if the queue at the
// top of the stack is associated with another microtask level.
bool shouldPushElementQueue =
(!lastData || lastData->mAssociatedMicroTask <
static_cast<int32_t>(nsContentUtils::MicroTaskLevel()));
// Push a new element queue onto the processing stack when appropriate
// (when we enter a new microtask).
if (shouldPushElementQueue) {
// Push a sentinel value on the processing stack to mark the
// boundary between the element queues.
sProcessingStack->AppendElement((CustomElementData*) nullptr);
}
sProcessingStack->AppendElement(elementData);
elementData->mAssociatedMicroTask =
static_cast<int32_t>(nsContentUtils::MicroTaskLevel());
// Add a script runner to pop and process the element queue at
// the top of the processing stack.
if (shouldPushElementQueue) {
// Lifecycle callbacks enqueued by user agent implementation
// should be invoked prior to returning control back to script.
// Create a script runner to process the top of the processing
// stack as soon as it is safe to run script.
nsCOMPtr<nsIRunnable> runnable = NS_NewRunnableFunction(
"dom::CustomElementRegistry::EnqueueLifecycleCallback",
&CustomElementRegistry::ProcessTopElementQueue);
nsContentUtils::AddScriptRunner(runnable);
}
void
CustomElementRegistry::SyncInvokeReactions(nsIDocument::ElementCallbackType aType,
Element* aCustomElement,
CustomElementDefinition* aDefinition)
{
auto callback = CreateCustomElementCallback(aType, aCustomElement, nullptr,
aDefinition);
if (!callback) {
return;
}
UniquePtr<CustomElementReaction> reaction(Move(
MakeUnique<CustomElementCallbackReaction>(this, aDefinition,
Move(callback))));
RefPtr<SyncInvokeReactionRunnable> runnable =
new SyncInvokeReactionRunnable(Move(reaction), aCustomElement);
nsContentUtils::AddScriptRunner(runnable);
}
void
CustomElementRegistry::EnqueueLifecycleCallback(nsIDocument::ElementCallbackType aType,
Element* aCustomElement,
LifecycleCallbackArgs* aArgs,
CustomElementDefinition* aDefinition)
{
auto callback =
CreateCustomElementCallback(aType, aCustomElement, aArgs, aDefinition);
if (!callback) {
return;
}
DocGroup* docGroup = mWindow->GetDocGroup();
if (!docGroup) {
return;
}
CustomElementReactionsStack* reactionsStack =
docGroup->CustomElementReactionsStack();
reactionsStack->EnqueueCallbackReaction(this, aCustomElement, aDefinition,
Move(callback));
}
void
@ -943,6 +898,16 @@ CustomElementReactionsStack::EnqueueUpgradeReaction(CustomElementRegistry* aRegi
Enqueue(aElement, new CustomElementUpgradeReaction(aRegistry, aDefinition));
}
void
CustomElementReactionsStack::EnqueueCallbackReaction(CustomElementRegistry* aRegistry,
Element* aElement,
CustomElementDefinition* aDefinition,
UniquePtr<CustomElementCallback> aCustomElementCallback)
{
Enqueue(aElement, new CustomElementCallbackReaction(aRegistry, aDefinition,
Move(aCustomElementCallback)));
}
void
CustomElementReactionsStack::Enqueue(Element* aElement,
CustomElementReaction* aReaction)
@ -984,6 +949,7 @@ CustomElementReactionsStack::InvokeBackupQueue()
void
CustomElementReactionsStack::InvokeReactions(ElementQueue& aElementQueue)
{
// Note: It's possible to re-enter this method.
for (uint32_t i = 0; i < aElementQueue.Length(); ++i) {
nsCOMPtr<Element> element = do_QueryReferent(aElementQueue[i]);
@ -994,10 +960,14 @@ CustomElementReactionsStack::InvokeReactions(ElementQueue& aElementQueue)
RefPtr<CustomElementData> elementData = element->GetCustomElementData();
MOZ_ASSERT(elementData, "CustomElementData should exist");
nsTArray<nsAutoPtr<CustomElementReaction>>& reactions =
elementData->mReactionQueue;
auto& reactions = elementData->mReactionQueue;
for (uint32_t j = 0; j < reactions.Length(); ++j) {
reactions.ElementAt(j)->Invoke(element);
// Transfer the ownership of the entry due to reentrant invocation of
// this funciton. The entry will be removed when bug 1379573 is landed.
auto reaction(Move(reactions.ElementAt(j)));
if (reaction) {
reaction->Invoke(element);
}
}
reactions.Clear();
}
@ -1032,5 +1002,14 @@ CustomElementUpgradeReaction::Invoke(Element* aElement)
mRegistry->Upgrade(aElement, mDefinition);
}
//-----------------------------------------------------
// CustomElementCallbackReaction
/* virtual */ void
CustomElementCallbackReaction::Invoke(Element* aElement)
{
mCustomElementCallback->Call();
}
} // namespace dom
} // namespace mozilla

View file

@ -85,23 +85,14 @@ struct CustomElementData
explicit CustomElementData(nsIAtom* aType);
CustomElementData(nsIAtom* aType, State aState);
// Objects in this array are transient and empty after each microtask
// checkpoint.
nsTArray<nsAutoPtr<CustomElementCallback>> mCallbackQueue;
// Custom element type, for <button is="x-button"> or <x-button>
// this would be x-button.
nsCOMPtr<nsIAtom> mType;
// The callback that is next to be processed upon calling RunCallbackQueue.
int32_t mCurrentCallback;
// Element is being created flag as described in the custom elements spec.
bool mElementIsBeingCreated;
// Flag to determine if the created callback has been invoked, thus it
// determines if other callbacks can be enqueued.
bool mCreatedCallbackInvoked;
// The microtask level associated with the callbacks in the callback queue,
// it is used to determine if a new queue needs to be pushed onto the
// processing stack.
int32_t mAssociatedMicroTask;
// Custom element state as described in the custom element spec.
State mState;
// custom element reaction queue as described in the custom element spec.
@ -110,10 +101,7 @@ struct CustomElementData
// appended, removed, or replaced.
// There are 3 reactions in reaction queue when doing upgrade operation,
// e.g., create an element, insert a node.
AutoTArray<nsAutoPtr<CustomElementReaction>, 3> mReactionQueue;
// Empties the callback queue.
void RunCallbackQueue();
AutoTArray<UniquePtr<CustomElementReaction>, 3> mReactionQueue;
private:
virtual ~CustomElementData() {}
@ -143,7 +131,7 @@ struct CustomElementDefinition
JS::Heap<JSObject *> mPrototype;
// The lifecycle callbacks to call for this custom element.
nsAutoPtr<mozilla::dom::LifecycleCallbacks> mCallbacks;
UniquePtr<mozilla::dom::LifecycleCallbacks> mCallbacks;
// A construction stack.
// TODO: Bug 1287348 - Implement construction stack for upgrading an element
@ -164,10 +152,13 @@ public:
: mRegistry(aRegistry)
, mDefinition(aDefinition)
{
};
}
virtual ~CustomElementReaction() = default;
virtual void Invoke(Element* aElement) = 0;
virtual void Traverse(nsCycleCollectionTraversalCallback& aCb) const
{
}
protected:
CustomElementRegistry* mRegistry;
@ -187,6 +178,27 @@ private:
virtual void Invoke(Element* aElement) override;
};
class CustomElementCallbackReaction final : public CustomElementReaction
{
public:
CustomElementCallbackReaction(CustomElementRegistry* aRegistry,
CustomElementDefinition* aDefinition,
UniquePtr<CustomElementCallback> aCustomElementCallback)
: CustomElementReaction(aRegistry, aDefinition)
, mCustomElementCallback(Move(aCustomElementCallback))
{
}
virtual void Traverse(nsCycleCollectionTraversalCallback& aCb) const override
{
mCustomElementCallback->Traverse(aCb);
}
private:
virtual void Invoke(Element* aElement) override;
UniquePtr<CustomElementCallback> mCustomElementCallback;
};
// https://html.spec.whatwg.org/multipage/scripting.html#custom-element-reactions-stack
class CustomElementReactionsStack
{
@ -212,6 +224,15 @@ public:
Element* aElement,
CustomElementDefinition* aDefinition);
/**
* Enqueue a custom element callback reaction
* https://html.spec.whatwg.org/multipage/scripting.html#enqueue-a-custom-element-callback-reaction
*/
void EnqueueCallbackReaction(CustomElementRegistry* aRegistry,
Element* aElement,
CustomElementDefinition* aDefinition,
UniquePtr<CustomElementCallback> aCustomElementCallback);
// [CEReactions] Before executing the algorithm's steps
// Push a new element queue onto the custom element reactions stack.
void CreateAndPushElementQueue();
@ -280,10 +301,6 @@ public:
static bool IsCustomElementEnabled(JSContext* aCx = nullptr,
JSObject* aObject = nullptr);
static void ProcessTopElementQueue();
static void XPCOMShutdown();
explicit CustomElementRegistry(nsPIDOMWindowInner* aWindow);
/**
@ -316,6 +333,13 @@ public:
private:
~CustomElementRegistry();
UniquePtr<CustomElementCallback> CreateCustomElementCallback(
nsIDocument::ElementCallbackType aType, Element* aCustomElement,
LifecycleCallbackArgs* aArgs, CustomElementDefinition* aDefinition);
void SyncInvokeReactions(nsIDocument::ElementCallbackType aType,
Element* aCustomElement,
CustomElementDefinition* aDefinition);
/**
* Registers an unresolved custom element that is a candidate for
* upgrade when the definition is registered via registerElement.
@ -362,14 +386,6 @@ private:
nsCOMPtr<nsPIDOMWindowInner> mWindow;
// Array representing the processing stack in the custom elements
// specification. The processing stack is conceptually a stack of
// element queues. Each queue is represented by a sequence of
// CustomElementData in this array, separated by nullptr that
// represent the boundaries of the items in the stack. The first
// queue in the stack is the base element queue.
static mozilla::Maybe<nsTArray<RefPtr<CustomElementData>>> sProcessingStack;
// It is used to prevent reentrant invocations of element definition.
bool mIsCustomDefinitionRunning;
@ -392,6 +408,28 @@ private:
CustomElementRegistry* mRegistry;
};
class SyncInvokeReactionRunnable : public mozilla::Runnable {
public:
SyncInvokeReactionRunnable(
UniquePtr<CustomElementReaction> aReaction, Element* aCustomElement)
: Runnable(
"dom::CustomElementRegistry::SyncInvokeReactionRunnable")
, mReaction(Move(aReaction))
, mCustomElement(aCustomElement)
{
}
NS_IMETHOD Run() override
{
mReaction->Invoke(mCustomElement);
return NS_OK;
}
private:
UniquePtr<CustomElementReaction> mReaction;
Element* mCustomElement;
};
public:
nsISupports* GetParentObject() const;

View file

@ -714,8 +714,10 @@ FragmentOrElement::nsDOMSlots::Traverse(nsCycleCollectionTraversalCallback &cb)
if (mExtendedSlots->mCustomElementData) {
for (uint32_t i = 0;
i < mExtendedSlots->mCustomElementData->mCallbackQueue.Length(); i++) {
mExtendedSlots->mCustomElementData->mCallbackQueue[i]->Traverse(cb);
i < mExtendedSlots->mCustomElementData->mReactionQueue.Length(); i++) {
if (mExtendedSlots->mCustomElementData->mReactionQueue[i]) {
mExtendedSlots->mCustomElementData->mReactionQueue[i]->Traverse(cb);
}
}
}

View file

@ -25,6 +25,7 @@ namespace mozilla {
class AbstractThread;
class ThrottledEventQueue;
namespace dom {
class TabChild;
// Two browsing contexts are considered "related" if they are reachable from one
// another through window.opener, window.parent, or window.frames. This is the

View file

@ -3762,11 +3762,12 @@ nsContentUtils::GetImageFromContent(nsIImageLoadingContent* aContent,
//static
already_AddRefed<imgRequestProxy>
nsContentUtils::GetStaticRequest(imgRequestProxy* aRequest)
nsContentUtils::GetStaticRequest(nsIDocument* aLoadingDocument,
imgRequestProxy* aRequest)
{
NS_ENSURE_TRUE(aRequest, nullptr);
RefPtr<imgRequestProxy> retval;
aRequest->GetStaticRequest(getter_AddRefs(retval));
aRequest->GetStaticRequest(aLoadingDocument, getter_AddRefs(retval));
return retval.forget();
}

View file

@ -801,7 +801,8 @@ public:
/**
* Helper method to call imgIRequest::GetStaticRequest.
*/
static already_AddRefed<imgRequestProxy> GetStaticRequest(imgRequestProxy* aRequest);
static already_AddRefed<imgRequestProxy> GetStaticRequest(nsIDocument* aLoadingDocument,
imgRequestProxy* aRequest);
/**
* Method that decides whether a content node is draggable

View file

@ -4126,6 +4126,12 @@ nsIDocument::GetRootElement() const
mCachedRootElement : GetRootElementInternal();
}
nsIContent*
nsIDocument::GetUnfocusedKeyEventTarget()
{
return GetRootElement();
}
Element*
nsDocument::GetRootElementInternal() const
{

View file

@ -938,6 +938,12 @@ public:
*/
Element* GetRootElement() const;
/**
* Gets the event target to dispatch key events to if there is no focused
* content in the document.
*/
virtual nsIContent* GetUnfocusedKeyEventTarget();
/**
* Retrieve information about the viewport as a data structure.
* This will return information in the viewport META data section

View file

@ -81,13 +81,25 @@ interface nsIImageLoadingContent : imgINotificationObserver
*
* @throws NS_ERROR_OUT_OF_MEMORY
*/
void addObserver(in imgINotificationObserver aObserver);
[notxpcom] nsresult addNativeObserver(in imgINotificationObserver aObserver);
/**
* Used to unregister an image decoder observer.
*
* @param aObserver the observer to unregister
*/
[notxpcom] nsresult removeNativeObserver(in imgINotificationObserver aObserver);
/**
* Same as addNativeObserver but intended for scripted observers or observers
* from another or without a document.
*/
void addObserver(in imgINotificationObserver aObserver);
/**
* Same as removeNativeObserver but intended for scripted observers or
* observers from another or without a document.
*/
void removeObserver(in imgINotificationObserver aObserver);
/**

View file

@ -123,6 +123,8 @@ nsImageLoadingContent::~nsImageLoadingContent()
"DestroyImageLoadingContent not called");
NS_ASSERTION(!mObserverList.mObserver && !mObserverList.mNext,
"Observers still registered?");
NS_ASSERTION(mScriptedObservers.IsEmpty(),
"Scripted observers still registered?");
}
/*
@ -387,7 +389,7 @@ ReplayImageStatus(imgIRequest* aRequest, imgINotificationObserver* aObserver)
}
NS_IMETHODIMP
nsImageLoadingContent::AddObserver(imgINotificationObserver* aObserver)
nsImageLoadingContent::AddNativeObserver(imgINotificationObserver* aObserver)
{
NS_ENSURE_ARG_POINTER(aObserver);
@ -416,7 +418,7 @@ nsImageLoadingContent::AddObserver(imgINotificationObserver* aObserver)
}
NS_IMETHODIMP
nsImageLoadingContent::RemoveObserver(imgINotificationObserver* aObserver)
nsImageLoadingContent::RemoveNativeObserver(imgINotificationObserver* aObserver)
{
NS_ENSURE_ARG_POINTER(aObserver);
@ -449,6 +451,157 @@ nsImageLoadingContent::RemoveObserver(imgINotificationObserver* aObserver)
return NS_OK;
}
NS_IMETHODIMP
nsImageLoadingContent::AddObserver(imgINotificationObserver* aObserver)
{
NS_ENSURE_ARG_POINTER(aObserver);
nsresult rv = NS_OK;
RefPtr<imgRequestProxy> currentReq;
if (mCurrentRequest) {
// Scripted observers may not belong to the same document as us, so when we
// create the imgRequestProxy, we shouldn't use any. This allows the request
// to dispatch notifications from the correct scheduler group.
rv = mCurrentRequest->Clone(aObserver, nullptr, getter_AddRefs(currentReq));
if (NS_FAILED(rv)) {
return rv;
}
}
RefPtr<imgRequestProxy> pendingReq;
if (mPendingRequest) {
// See above for why we don't use the loading document.
rv = mPendingRequest->Clone(aObserver, nullptr, getter_AddRefs(pendingReq));
if (NS_FAILED(rv)) {
mCurrentRequest->CancelAndForgetObserver(NS_BINDING_ABORTED);
return rv;
}
}
mScriptedObservers.AppendElement(
new ScriptedImageObserver(aObserver, Move(currentReq), Move(pendingReq)));
return rv;
}
NS_IMETHODIMP
nsImageLoadingContent::RemoveObserver(imgINotificationObserver* aObserver)
{
NS_ENSURE_ARG_POINTER(aObserver);
if (NS_WARN_IF(mScriptedObservers.IsEmpty())) {
return NS_OK;
}
RefPtr<ScriptedImageObserver> observer;
auto i = mScriptedObservers.Length();
do {
--i;
if (mScriptedObservers[i]->mObserver == aObserver) {
observer = Move(mScriptedObservers[i]);
mScriptedObservers.RemoveElementAt(i);
break;
}
} while(i > 0);
if (NS_WARN_IF(!observer)) {
return NS_OK;
}
// If the cancel causes a mutation, it will be harmless, because we have
// already removed the observer from the list.
observer->CancelRequests();
return NS_OK;
}
void
nsImageLoadingContent::ClearScriptedRequests(int32_t aRequestType, nsresult aReason)
{
if (MOZ_LIKELY(mScriptedObservers.IsEmpty())) {
return;
}
nsTArray<RefPtr<ScriptedImageObserver>> observers(mScriptedObservers);
auto i = observers.Length();
do {
--i;
RefPtr<imgRequestProxy> req;
switch (aRequestType) {
case CURRENT_REQUEST:
req = Move(observers[i]->mCurrentRequest);
break;
case PENDING_REQUEST:
req = Move(observers[i]->mPendingRequest);
break;
default:
NS_ERROR("Unknown request type");
return;
}
if (req) {
req->CancelAndForgetObserver(aReason);
}
} while (i > 0);
}
void
nsImageLoadingContent::CloneScriptedRequests(imgRequestProxy* aRequest)
{
MOZ_ASSERT(aRequest);
if (MOZ_LIKELY(mScriptedObservers.IsEmpty())) {
return;
}
bool current;
if (aRequest == mCurrentRequest) {
current = true;
} else if (aRequest == mPendingRequest) {
current = false;
} else {
MOZ_ASSERT_UNREACHABLE("Unknown request type");
return;
}
nsTArray<RefPtr<ScriptedImageObserver>> observers(mScriptedObservers);
auto i = observers.Length();
do {
--i;
ScriptedImageObserver* observer = observers[i];
RefPtr<imgRequestProxy>& req = current ? observer->mCurrentRequest
: observer->mPendingRequest;
if (NS_WARN_IF(req)) {
MOZ_ASSERT_UNREACHABLE("Should have cancelled original request");
req->CancelAndForgetObserver(NS_BINDING_ABORTED);
req = nullptr;
}
nsresult rv = aRequest->Clone(observer->mObserver, nullptr, getter_AddRefs(req));
Unused << NS_WARN_IF(NS_FAILED(rv));
} while (i > 0);
}
void
nsImageLoadingContent::MakePendingScriptedRequestsCurrent()
{
if (MOZ_LIKELY(mScriptedObservers.IsEmpty())) {
return;
}
nsTArray<RefPtr<ScriptedImageObserver>> observers(mScriptedObservers);
auto i = observers.Length();
do {
--i;
ScriptedImageObserver* observer = observers[i];
if (observer->mCurrentRequest) {
observer->mCurrentRequest->CancelAndForgetObserver(NS_BINDING_ABORTED);
}
observer->mCurrentRequest = Move(observer->mPendingRequest);
} while (i > 0);
}
already_AddRefed<imgIRequest>
nsImageLoadingContent::GetRequest(int32_t aRequestType,
ErrorResult& aError)
@ -633,6 +786,7 @@ nsImageLoadingContent::LoadImageWithChannel(nsIChannel* aChannel,
nsresult rv = loader->
LoadImageWithChannel(aChannel, this, doc, aListener, getter_AddRefs(req));
if (NS_SUCCEEDED(rv)) {
CloneScriptedRequests(req);
TrackImage(req);
ResetAnimationIfNeeded();
return NS_OK;
@ -910,6 +1064,7 @@ nsImageLoadingContent::LoadImage(nsIURI* aNewURI,
aDocument->ForgetImagePreload(aNewURI);
if (NS_SUCCEEDED(rv)) {
CloneScriptedRequests(req);
TrackImage(req);
ResetAnimationIfNeeded();
@ -1083,8 +1238,9 @@ nsImageLoadingContent::UseAsPrimaryRequest(imgRequestProxy* aRequest,
// Clone the request we were given.
RefPtr<imgRequestProxy>& req = PrepareNextRequest(aImageLoadType);
nsresult rv = aRequest->Clone(this, getter_AddRefs(req));
nsresult rv = aRequest->SyncClone(this, GetOurOwnerDoc(), getter_AddRefs(req));
if (NS_SUCCEEDED(rv)) {
CloneScriptedRequests(req);
TrackImage(req);
} else {
MOZ_ASSERT(!req, "Shouldn't have non-null request here");
@ -1334,6 +1490,7 @@ nsImageLoadingContent::MakePendingRequestCurrent()
: eImageLoadType_Normal;
PrepareCurrentRequest(loadType) = mPendingRequest;
MakePendingScriptedRequestsCurrent();
mPendingRequest = nullptr;
mCurrentRequestFlags = mPendingRequestFlags;
mPendingRequestFlags = 0;
@ -1363,6 +1520,7 @@ nsImageLoadingContent::ClearCurrentRequest(nsresult aReason,
// Clean up the request.
UntrackImage(mCurrentRequest, aNonvisibleAction);
ClearScriptedRequests(CURRENT_REQUEST, aReason);
mCurrentRequest->CancelAndForgetObserver(aReason);
mCurrentRequest = nullptr;
mCurrentRequestFlags = 0;
@ -1381,6 +1539,7 @@ nsImageLoadingContent::ClearPendingRequest(nsresult aReason,
&mPendingRequestRegistered);
UntrackImage(mPendingRequest, aNonvisibleAction);
ClearScriptedRequests(PENDING_REQUEST, aReason);
mPendingRequest->CancelAndForgetObserver(aReason);
mPendingRequest = nullptr;
mPendingRequestFlags = 0;
@ -1568,7 +1727,12 @@ nsImageLoadingContent::UntrackImage(imgIRequest* aImage,
void
nsImageLoadingContent::CreateStaticImageClone(nsImageLoadingContent* aDest) const
{
aDest->mCurrentRequest = nsContentUtils::GetStaticRequest(mCurrentRequest);
aDest->ClearScriptedRequests(CURRENT_REQUEST, NS_BINDING_ABORTED);
aDest->mCurrentRequest =
nsContentUtils::GetStaticRequest(aDest->GetOurOwnerDoc(), mCurrentRequest);
if (aDest->mCurrentRequest) {
aDest->CloneScriptedRequests(aDest->mCurrentRequest);
}
aDest->TrackImage(aDest->mCurrentRequest);
aDest->mForcedImageState = mForcedImageState;
aDest->mImageBlockingStatus = mImageBlockingStatus;
@ -1600,6 +1764,38 @@ nsImageLoadingContent::ImageObserver::~ImageObserver()
NS_CONTENT_DELETE_LIST_MEMBER(ImageObserver, this, mNext);
}
nsImageLoadingContent::ScriptedImageObserver::ScriptedImageObserver(imgINotificationObserver* aObserver,
RefPtr<imgRequestProxy>&& aCurrentRequest,
RefPtr<imgRequestProxy>&& aPendingRequest)
: mObserver(aObserver)
, mCurrentRequest(aCurrentRequest)
, mPendingRequest(aPendingRequest)
{ }
nsImageLoadingContent::ScriptedImageObserver::~ScriptedImageObserver()
{
// We should have cancelled any requests before getting released.
DebugOnly<bool> cancel = CancelRequests();
MOZ_ASSERT(!cancel, "Still have requests in ~ScriptedImageObserver!");
}
bool
nsImageLoadingContent::ScriptedImageObserver::CancelRequests()
{
bool cancelled = false;
if (mCurrentRequest) {
mCurrentRequest->CancelAndForgetObserver(NS_BINDING_ABORTED);
mCurrentRequest = nullptr;
cancelled = true;
}
if (mPendingRequest) {
mPendingRequest->CancelAndForgetObserver(NS_BINDING_ABORTED);
mPendingRequest = nullptr;
cancelled = true;
}
return cancelled;
}
// Only HTMLInputElement.h overrides this for <img> tags
// all other subclasses use this one, i.e. ignore referrer attributes
mozilla::net::ReferrerPolicy

View file

@ -225,7 +225,7 @@ protected:
private:
/**
* Struct used to manage the image observers.
* Struct used to manage the native image observers.
*/
struct ImageObserver {
explicit ImageObserver(imgINotificationObserver* aObserver);
@ -235,6 +235,26 @@ private:
ImageObserver* mNext;
};
/**
* Struct used to manage the scripted/XPCOM image observers.
*/
class ScriptedImageObserver final {
public:
NS_INLINE_DECL_REFCOUNTING(ScriptedImageObserver)
ScriptedImageObserver(imgINotificationObserver* aObserver,
RefPtr<imgRequestProxy>&& aCurrentRequest,
RefPtr<imgRequestProxy>&& aPendingRequest);
bool CancelRequests();
nsCOMPtr<imgINotificationObserver> mObserver;
RefPtr<imgRequestProxy> mCurrentRequest;
RefPtr<imgRequestProxy> mPendingRequest;
private:
~ScriptedImageObserver();
};
/**
* Struct to report state changes
*/
@ -402,6 +422,24 @@ protected:
nsCOMPtr<nsIURI> mCurrentURI;
private:
/**
* Clones the given "current" or "pending" request for each scripted observer.
*/
void CloneScriptedRequests(imgRequestProxy* aRequest);
/**
* Cancels and nulls-out the "current" or "pending" requests if they exist
* for each scripted observer.
*/
void ClearScriptedRequests(int32_t aRequestType, nsresult aReason);
/**
* Moves the "pending" request into the "current" request for each scripted
* observer. If there is an existing "current" request, it will cancel it
* first.
*/
void MakePendingScriptedRequestsCurrent();
/**
* Typically we will have only one observer (our frame in the screen
* prescontext), so we want to only make space for one and to
@ -412,6 +450,13 @@ private:
*/
ImageObserver mObserverList;
/**
* Typically we will have no scripted observers, as this is only used by
* chrome, legacy extensions, and some mochitests. An empty array reserves
* minimal memory.
*/
nsTArray<RefPtr<ScriptedImageObserver>> mScriptedObservers;
/**
* When mIsImageStateForced is true, this holds the ImageState that we'll
* return in ImageState().

View file

@ -10,8 +10,8 @@
namespace mozilla {
namespace dom {
class HTMLImageElementOrHTMLCanvasElementOrHTMLVideoElementOrImageBitmap;
typedef HTMLImageElementOrHTMLCanvasElementOrHTMLVideoElementOrImageBitmap
class HTMLImageElementOrSVGImageElementOrHTMLCanvasElementOrHTMLVideoElementOrImageBitmap;
typedef HTMLImageElementOrSVGImageElementOrHTMLCanvasElementOrHTMLVideoElementOrImageBitmap
CanvasImageSource;
/*

View file

@ -107,6 +107,7 @@
#include "mozilla/dom/CanvasPath.h"
#include "mozilla/dom/HTMLImageElement.h"
#include "mozilla/dom/HTMLVideoElement.h"
#include "mozilla/dom/SVGImageElement.h"
#include "mozilla/dom/SVGMatrix.h"
#include "mozilla/dom/TextMetrics.h"
#include "mozilla/dom/SVGMatrix.h"
@ -2529,10 +2530,10 @@ CanvasRenderingContext2D::CreatePattern(const CanvasImageSource& aSource,
return nullptr;
}
Element* htmlElement;
Element* element;
if (aSource.IsHTMLCanvasElement()) {
HTMLCanvasElement* canvas = &aSource.GetAsHTMLCanvasElement();
htmlElement = canvas;
element = canvas;
nsIntSize size = canvas->GetSize();
if (size.width == 0 || size.height == 0) {
@ -2557,7 +2558,7 @@ CanvasRenderingContext2D::CreatePattern(const CanvasImageSource& aSource,
}
RefPtr<CanvasPattern> pat =
new CanvasPattern(this, srcSurf, repeatMode, htmlElement->NodePrincipal(), canvas->IsWriteOnly(), false);
new CanvasPattern(this, srcSurf, repeatMode, element->NodePrincipal(), canvas->IsWriteOnly(), false);
return pat.forget();
}
@ -2568,11 +2569,19 @@ CanvasRenderingContext2D::CreatePattern(const CanvasImageSource& aSource,
return nullptr;
}
htmlElement = img;
element = img;
} else if (aSource.IsSVGImageElement()) {
SVGImageElement* img = &aSource.GetAsSVGImageElement();
if (img->IntrinsicState().HasState(NS_EVENT_STATE_BROKEN)) {
aError.Throw(NS_ERROR_DOM_INVALID_STATE_ERR);
return nullptr;
}
element = img;
} else if (aSource.IsHTMLVideoElement()) {
auto& video = aSource.GetAsHTMLVideoElement();
video.MarkAsContentSource(mozilla::dom::HTMLVideoElement::CallerAPI::CREATE_PATTERN);
htmlElement = &video;
element = &video;
} else {
// Special case for ImageBitmap
ImageBitmap& imgBitmap = aSource.GetAsImageBitmap();
@ -2611,7 +2620,7 @@ CanvasRenderingContext2D::CreatePattern(const CanvasImageSource& aSource,
// The canvas spec says that createPattern should use the first frame
// of animated images
nsLayoutUtils::SurfaceFromElementResult res =
nsLayoutUtils::SurfaceFromElement(htmlElement,
nsLayoutUtils::SurfaceFromElement(element,
nsLayoutUtils::SFE_WANT_FIRST_FRAME_IF_IMAGE, mTarget);
if (!res.GetSourceSurface()) {
@ -5177,6 +5186,9 @@ CanvasRenderingContext2D::DrawImage(const CanvasImageSource& aImage,
if (aImage.IsHTMLImageElement()) {
HTMLImageElement* img = &aImage.GetAsHTMLImageElement();
element = img;
} else if (aImage.IsSVGImageElement()) {
SVGImageElement* img = &aImage.GetAsSVGImageElement();
element = img;
} else {
HTMLVideoElement* video = &aImage.GetAsHTMLVideoElement();
video->MarkAsContentSource(mozilla::dom::HTMLVideoElement::CallerAPI::DRAW_IMAGE);

View file

@ -40,8 +40,8 @@ class SourceSurface;
} // namespace gl
namespace dom {
class HTMLImageElementOrHTMLCanvasElementOrHTMLVideoElementOrImageBitmap;
typedef HTMLImageElementOrHTMLCanvasElementOrHTMLVideoElementOrImageBitmap CanvasImageSource;
class HTMLImageElementOrSVGImageElementOrHTMLCanvasElementOrHTMLVideoElementOrImageBitmap;
typedef HTMLImageElementOrSVGImageElementOrHTMLCanvasElementOrHTMLVideoElementOrImageBitmap CanvasImageSource;
class ImageData;
class StringOrCanvasGradientOrCanvasPattern;
class OwningStringOrCanvasGradientOrCanvasPattern;

View file

@ -10,6 +10,7 @@
#include "GLContext.h"
#include "nsString.h"
#include "nsContentUtils.h"
#include "mozilla/Preferences.h"
#include "mozilla/dom/BindingDeclarations.h"
#include "AccessCheck.h"
@ -146,7 +147,8 @@ WebGLContext::IsExtensionSupported(WebGLExtensionID ext) const
gl->IsExtensionSupported(gl::GLContext::EXT_texture_sRGB);
case WebGLExtensionID::WEBGL_debug_renderer_info:
return Preferences::GetBool("webgl.enable-debug-renderer-info", false);
case WebGLExtensionID::WEBGL_debug_shaders:
return !nsContentUtils::ShouldResistFingerprinting();
case WebGLExtensionID::WEBGL_lose_context:
// We always support this extension.
return true;

View file

@ -279,12 +279,6 @@ WebGLShader::GetShaderSource(nsAString* out) const
void
WebGLShader::GetShaderTranslatedSource(nsAString* out) const
{
if (!mCompilationSuccessful) {
mContext->ErrorInvalidOperation("getShaderTranslatedSource: Shader has"
" not been successfully compiled.");
return;
}
out->SetIsVoid(false);
CopyASCIItoUTF16(mTranslatedSource, *out);
}

View file

@ -32,7 +32,7 @@ var defaultExts = [
['OES_vertex_array_object' , [ENSURE , FORBID ]],
['WEBGL_compressed_texture_s3tc' , [MACHINE_SPECIFIC, MACHINE_SPECIFIC]],
['WEBGL_debug_renderer_info' , [ENSURE , ENSURE ]],
['WEBGL_debug_shaders' , [FORBID , FORBID ]],
['WEBGL_debug_shaders' , [ENSURE , ENSURE ]],
['WEBGL_depth_texture' , [MACHINE_SPECIFIC, FORBID ]],
['WEBGL_draw_buffers' , [MACHINE_SPECIFIC, FORBID ]],
['WEBGL_lose_context' , [ENSURE , ENSURE ]],

View file

@ -24,7 +24,7 @@ function TestExt(gl, name) {
}
// Privileged extensions:
TestExt(gl, 'WEBGL_debug_shaders');
TestExt(gl, 'MOZ_debug');
})();
</script>

View file

@ -121,7 +121,7 @@ ImageListener::OnStartRequest(nsIRequest* request, nsISupports *ctxt)
nsCOMPtr<nsIImageLoadingContent> imageLoader = do_QueryInterface(imgDoc->mImageContent);
NS_ENSURE_TRUE(imageLoader, NS_ERROR_UNEXPECTED);
imageLoader->AddObserver(imgDoc);
imageLoader->AddNativeObserver(imgDoc);
imgDoc->mObservingImageLoader = true;
imageLoader->LoadImageWithChannel(channel, getter_AddRefs(mNextStream));
}
@ -232,7 +232,7 @@ ImageDocument::Destroy()
if (mObservingImageLoader) {
nsCOMPtr<nsIImageLoadingContent> imageLoader = do_QueryInterface(mImageContent);
if (imageLoader) {
imageLoader->RemoveObserver(this);
imageLoader->RemoveNativeObserver(this);
}
}

View file

@ -883,6 +883,15 @@ nsHTMLDocument::SetCompatibilityMode(nsCompatibility aMode)
}
}
nsIContent*
nsHTMLDocument::GetUnfocusedKeyEventTarget()
{
if (nsGenericHTMLElement* body = GetBody()) {
return body;
}
return nsDocument::GetUnfocusedKeyEventTarget();
}
//
// nsIDOMHTMLDocument interface implementation
//

View file

@ -74,6 +74,8 @@ public:
return mWriteLevel != uint32_t(0);
}
virtual nsIContent* GetUnfocusedKeyEventTarget() override;
virtual nsContentList* GetForms() override;
virtual nsContentList* GetFormControls() override;

View file

@ -1618,11 +1618,14 @@ ScriptLoader::AttemptAsyncScriptCompile(ScriptLoadRequest* aRequest)
return rv;
}
size_t len = aRequest->IsSource()
? aRequest->mScriptText.length()
: aRequest->mScriptBytecode.length();
if (!JS::CanCompileOffThread(cx, options, len)) {
return NS_ERROR_FAILURE;
if (aRequest->IsSource()) {
if (!JS::CanCompileOffThread(cx, options, aRequest->mScriptText.length())) {
return NS_ERROR_FAILURE;
}
} else {
if (!JS::CanDecodeOffThread(cx, options, aRequest->mScriptBytecode.length())) {
return NS_ERROR_FAILURE;
}
}
RefPtr<NotifyOffThreadScriptLoadCompletedRunnable> runnable =

View file

@ -28,7 +28,8 @@ function testChangeAttributeInCreatedCallback() {
createdCallbackCalled = true;
is(attributeChangedCallbackCalled, false, "Attribute changed callback should not have been called prior to setting the attribute.");
this.setAttribute("foo", "bar");
is(attributeChangedCallbackCalled, false, "While element is being created, element should not be added to the current element callback queue.");
is(attributeChangedCallbackCalled, true, "While element is being created, element should be added to the current element callback queue.");
runNextTest();
};
p.attributeChangedCallback = function(name, oldValue, newValue) {
@ -36,7 +37,6 @@ function testChangeAttributeInCreatedCallback() {
is(attributeChangedCallbackCalled, false, "attributeChanged callback should only be called once in this tests.");
is(newValue, "bar", "The new value should be 'bar'");
attributeChangedCallbackCalled = true;
runNextTest();
};
document.registerElement("x-one", { prototype: p });

View file

@ -27,6 +27,9 @@ dictionary HitRegionOptions {
};
typedef (HTMLImageElement or
SVGImageElement) HTMLOrSVGImageElement;
typedef (HTMLOrSVGImageElement or
HTMLCanvasElement or
HTMLVideoElement or
ImageBitmap) CanvasImageSource;

View file

@ -17,7 +17,7 @@ interface ShadowRoot : DocumentFragment
HTMLCollection getElementsByTagName(DOMString localName);
HTMLCollection getElementsByTagNameNS(DOMString? namespace, DOMString localName);
HTMLCollection getElementsByClassName(DOMString classNames);
[SetterThrows,TreatNullAs=EmptyString]
[CEReactions, SetterThrows, TreatNullAs=EmptyString]
attribute DOMString innerHTML;
readonly attribute Element host;
readonly attribute ShadowRoot? olderShadowRoot;

View file

@ -158,8 +158,8 @@ nsXBLPrototypeHandler::TryConvertToKeyboardShortcut(
}
// Convert the modifiers
Modifiers modifiersMask = GetModifiers();
Modifiers modifiers = GetModifiersMask();
Modifiers modifiersMask = GetModifiersMask();
Modifiers modifiers = GetModifiers();
// Mask away any bits that won't be compared
modifiers &= modifiersMask;

View file

@ -21,6 +21,7 @@ struct D3D11DeviceStatus
bool textureSharingWorks;
uint32_t featureLevel;
DxgiAdapterDesc adapter;
int32_t sequenceNumber;
};
struct DevicePrefs

View file

@ -70,7 +70,7 @@ AppendToString(std::stringstream& aStream, const nsRect& r,
}
void
AppendToString(std::stringstream& aStream, const WrColor& c,
AppendToString(std::stringstream& aStream, const wr::ColorF& c,
const char* pfx, const char* sfx)
{
aStream << pfx;
@ -81,18 +81,18 @@ AppendToString(std::stringstream& aStream, const WrColor& c,
}
void
AppendToString(std::stringstream& aStream, const WrRect& r,
AppendToString(std::stringstream& aStream, const wr::LayoutRect& r,
const char* pfx, const char* sfx)
{
aStream << pfx;
aStream << nsPrintfCString(
"(x=%f, y=%f, w=%f, h=%f)",
r.x, r.y, r.width, r.height).get();
r.origin.x, r.origin.y, r.size.width, r.size.height).get();
aStream << sfx;
}
void
AppendToString(std::stringstream& aStream, const WrSize& s,
AppendToString(std::stringstream& aStream, const wr::LayoutSize& s,
const char* pfx, const char* sfx)
{
aStream << pfx;

View file

@ -18,11 +18,14 @@
#include "nsRegion.h" // for nsRegion, nsIntRegion
#include "nscore.h" // for nsACString, etc
struct WrColor;
struct WrRect;
struct WrSize;
namespace mozilla {
namespace wr {
struct ColorF;
struct LayoutRect;
struct LayoutSize;
} // namespace wr
namespace gfx {
template <class units, class F> struct RectTyped;
} // namespace gfx
@ -92,15 +95,15 @@ AppendToString(std::stringstream& aStream, const mozilla::gfx::IntRectTyped<T>&
}
void
AppendToString(std::stringstream& aStream, const WrColor& c,
AppendToString(std::stringstream& aStream, const wr::ColorF& c,
const char* pfx="", const char* sfx="");
void
AppendToString(std::stringstream& aStream, const WrRect& r,
AppendToString(std::stringstream& aStream, const wr::LayoutRect& r,
const char* pfx="", const char* sfx="");
void
AppendToString(std::stringstream& aStream, const WrSize& s,
AppendToString(std::stringstream& aStream, const wr::LayoutSize& s,
const char* pfx="", const char* sfx="");
void

View file

@ -447,7 +447,7 @@ APZCTreeManager::UpdateHitTestingTree(uint64_t aRootLayerTreeId,
bool
APZCTreeManager::PushStateToWR(wr::WebRenderAPI* aWrApi,
const TimeStamp& aSampleTime,
nsTArray<WrTransformProperty>& aTransformArray)
nsTArray<wr::WrTransformProperty>& aTransformArray)
{
APZThreadUtils::AssertOnCompositorThread();
MOZ_ASSERT(aWrApi);
@ -463,7 +463,7 @@ APZCTreeManager::PushStateToWR(wr::WebRenderAPI* aWrApi,
bool activeAnimations = false;
uint64_t lastLayersId = -1;
WrPipelineId lastPipelineId;
wr::WrPipelineId lastPipelineId;
// We iterate backwards here because the HitTestingTreeNode is optimized
// for backwards iteration. The equivalent code in AsyncCompositionManager
@ -507,7 +507,7 @@ APZCTreeManager::PushStateToWR(wr::WebRenderAPI* aWrApi,
// scroll delta here, we want to negate the translation.
ParentLayerPoint asyncScrollDelta = -layerTranslation;
aWrApi->UpdateScrollPosition(lastPipelineId, apzc->GetGuid().mScrollId,
wr::ToWrPoint(asyncScrollDelta));
wr::ToLayoutPoint(asyncScrollDelta));
apzc->ReportCheckerboard(aSampleTime);
activeAnimations |= apzc->AdvanceAnimations(aSampleTime);

View file

@ -25,13 +25,12 @@
#include "mozilla/layers/AndroidDynamicToolbarAnimator.h"
#endif // defined(MOZ_WIDGET_ANDROID)
struct WrTransformProperty;
namespace mozilla {
class MultiTouchInput;
namespace wr {
class WebRenderAPI;
struct WrTransformProperty;
}
namespace layers {
@ -179,7 +178,7 @@ public:
*/
bool PushStateToWR(wr::WebRenderAPI* aWrApi,
const TimeStamp& aSampleTime,
nsTArray<WrTransformProperty>& aTransformArray);
nsTArray<wr::WrTransformProperty>& aTransformArray);
/**
* Walk the tree of APZCs and flushes the repaint requests for all the APZCS

View file

@ -94,8 +94,9 @@ FocusTarget::FocusTarget(nsIPresShell* aRootPresShell,
// Key events can be retargeted to a child PresShell when there is an iframe
nsCOMPtr<nsIPresShell> presShell = GetRetargetEventPresShell(aRootPresShell);
nsCOMPtr<nsIDocument> document = presShell->GetDocument();
if (!presShell) {
if (!presShell || !document) {
FT_LOG("Creating nil target with seq=%" PRIu64 " (can't find retargeted presshell)\n",
aFocusSequenceNumber);
@ -103,16 +104,31 @@ FocusTarget::FocusTarget(nsIPresShell* aRootPresShell,
return;
}
// Get the content that should be scrolled for this PresShell, which is
// the current focused element or the current DOM selection
nsCOMPtr<nsIContent> scrollTarget = presShell->GetContentForScrolling();
// Find the focused content and use it to determine whether there are key event
// listeners or whether key events will be targeted at a different process
// through a remote browser.
nsCOMPtr<nsIContent> focusedContent = presShell->GetFocusedContentInOurWindow();
// Collect event listener information so we can track what is potentially focus
// changing
mFocusHasKeyEventListeners = HasListenersForKeyEvents(scrollTarget);
// Check if there are key event listeners that could prevent default or change
// the focus or selection of the page.
mFocusHasKeyEventListeners =
HasListenersForKeyEvents(focusedContent ? focusedContent.get()
: document->GetUnfocusedKeyEventTarget());
// Check if the scroll target is a remote browser
if (TabParent* browserParent = TabParent::GetFrom(scrollTarget)) {
// Check if the focused element is content editable or if the document
// is in design mode.
if (IsEditableNode(focusedContent) ||
IsEditableNode(document)) {
FT_LOG("Creating nil target with seq=%" PRIu64 ", kl=%d (disabling for editable node)\n",
aFocusSequenceNumber,
static_cast<int>(mFocusHasKeyEventListeners));
mType = FocusTarget::eNone;
return;
}
// Check if the focused element is a remote browser
if (TabParent* browserParent = TabParent::GetFrom(focusedContent)) {
RenderFrameParent* rfp = browserParent->GetRenderFrame();
// The globally focused element for scrolling is in a remote layer tree
@ -135,24 +151,29 @@ FocusTarget::FocusTarget(nsIPresShell* aRootPresShell,
return;
}
// If the focus isn't on a remote browser then check for scrollable targets
if (IsEditableNode(scrollTarget) ||
IsEditableNode(presShell->GetDocument())) {
FT_LOG("Creating nil target with seq=%" PRIu64 ", kl=%d (disabling for editable node)\n",
aFocusSequenceNumber,
mFocusHasKeyEventListeners);
// The content to scroll is either the focused element or the focus node of
// the selection. It's difficult to determine if an element is an interactive
// element requiring async keyboard scrolling to be disabled. So we only
// allow async key scrolling based on the selection, which doesn't have
// this problem and is more common.
if (focusedContent) {
FT_LOG("Creating nil target with seq=%" PRIu64 ", kl=%d (disabling for focusing an element)\n",
mFocusHasKeyEventListeners,
aFocusSequenceNumber);
mType = FocusTarget::eNone;
return;
}
nsCOMPtr<nsIContent> selectedContent = presShell->GetSelectedContentForScrolling();
// Gather the scrollable frames that would be scrolled in each direction
// for this scroll target
nsIScrollableFrame* horizontal =
presShell->GetScrollableFrameToScrollForContent(scrollTarget.get(),
presShell->GetScrollableFrameToScrollForContent(selectedContent.get(),
nsIPresShell::eHorizontal);
nsIScrollableFrame* vertical =
presShell->GetScrollableFrameToScrollForContent(scrollTarget.get(),
presShell->GetScrollableFrameToScrollForContent(selectedContent.get(),
nsIPresShell::eVertical);
// We might have the globally focused element for scrolling. Gather a ViewID for

View file

@ -516,7 +516,9 @@ ClientLayerManager::DidComposite(uint64_t aTransactionId,
if (listener) {
listener->DidCompositeWindow(aTransactionId, aCompositeStart, aCompositeEnd);
}
mTransactionIdAllocator->NotifyTransactionCompleted(aTransactionId);
if (mTransactionIdAllocator) {
mTransactionIdAllocator->NotifyTransactionCompleted(aTransactionId);
}
}
// These observers fire whether or not we were in a transaction.

View file

@ -133,8 +133,8 @@ GPUVideoTextureHost::AddWRImage(wr::WebRenderAPI* aAPI,
void
GPUVideoTextureHost::PushExternalImage(wr::DisplayListBuilder& aBuilder,
const WrRect& aBounds,
const WrRect& aClip,
const wr::LayoutRect& aBounds,
const wr::LayoutRect& aClip,
wr::ImageRendering aFilter,
Range<const wr::ImageKey>& aImageKeys)
{

View file

@ -56,8 +56,8 @@ public:
const wr::ExternalImageId& aExtID) override;
virtual void PushExternalImage(wr::DisplayListBuilder& aBuilder,
const WrRect& aBounds,
const WrRect& aClip,
const wr::LayoutRect& aBounds,
const wr::LayoutRect& aClip,
wr::ImageRendering aFilter,
Range<const wr::ImageKey>& aImageKeys) override;

View file

@ -607,25 +607,25 @@ BufferTextureHost::AddWRImage(wr::WebRenderAPI* aAPI,
aAPI->AddExternalImage(aImageKeys[0],
yDescriptor,
aExtID,
WrExternalImageBufferType::ExternalBuffer,
wr::WrExternalImageBufferType::ExternalBuffer,
0);
aAPI->AddExternalImage(aImageKeys[1],
cbcrDescriptor,
aExtID,
WrExternalImageBufferType::ExternalBuffer,
wr::WrExternalImageBufferType::ExternalBuffer,
1);
aAPI->AddExternalImage(aImageKeys[2],
cbcrDescriptor,
aExtID,
WrExternalImageBufferType::ExternalBuffer,
wr::WrExternalImageBufferType::ExternalBuffer,
2);
}
}
void
BufferTextureHost::PushExternalImage(wr::DisplayListBuilder& aBuilder,
const WrRect& aBounds,
const WrRect& aClip,
const wr::LayoutRect& aBounds,
const wr::LayoutRect& aClip,
wr::ImageRendering aFilter,
Range<const wr::ImageKey>& aImageKeys)
{
@ -639,7 +639,7 @@ BufferTextureHost::PushExternalImage(wr::DisplayListBuilder& aBuilder,
aImageKeys[0],
aImageKeys[1],
aImageKeys[2],
WrYuvColorSpace::Rec601,
wr::WrYuvColorSpace::Rec601,
aFilter);
}
}

View file

@ -643,8 +643,8 @@ public:
// Put all necessary WR commands into DisplayListBuilder for this textureHost rendering.
virtual void PushExternalImage(wr::DisplayListBuilder& aBuilder,
const WrRect& aBounds,
const WrRect& aClip,
const wr::LayoutRect& aBounds,
const wr::LayoutRect& aClip,
wr::ImageRendering aFilter,
Range<const wr::ImageKey>& aKeys)
{
@ -749,8 +749,8 @@ public:
const wr::ExternalImageId& aExtID) override;
virtual void PushExternalImage(wr::DisplayListBuilder& aBuilder,
const WrRect& aBounds,
const WrRect& aClip,
const wr::LayoutRect& aBounds,
const wr::LayoutRect& aClip,
wr::ImageRendering aFilter,
Range<const wr::ImageKey>& aImageKeys) override;

View file

@ -984,8 +984,8 @@ DXGITextureHostD3D11::AddWRImage(wr::WebRenderAPI* aAPI,
void
DXGITextureHostD3D11::PushExternalImage(wr::DisplayListBuilder& aBuilder,
const WrRect& aBounds,
const WrRect& aClip,
const wr::LayoutRect& aBounds,
const wr::LayoutRect& aClip,
wr::ImageRendering aFilter,
Range<const wr::ImageKey>& aImageKeys)
{
@ -1151,8 +1151,8 @@ DXGIYCbCrTextureHostD3D11::AddWRImage(wr::WebRenderAPI* aAPI,
void
DXGIYCbCrTextureHostD3D11::PushExternalImage(wr::DisplayListBuilder& aBuilder,
const WrRect& aBounds,
const WrRect& aClip,
const wr::LayoutRect& aBounds,
const wr::LayoutRect& aClip,
wr::ImageRendering aFilter,
Range<const wr::ImageKey>& aImageKeys)
{

View file

@ -331,8 +331,8 @@ public:
const wr::ExternalImageId& aExtID) override;
virtual void PushExternalImage(wr::DisplayListBuilder& aBuilder,
const WrRect& aBounds,
const WrRect& aClip,
const wr::LayoutRect& aBounds,
const wr::LayoutRect& aClip,
wr::ImageRendering aFilter,
Range<const wr::ImageKey>& aImageKeys) override;
@ -392,8 +392,8 @@ public:
const wr::ExternalImageId& aExtID) override;
virtual void PushExternalImage(wr::DisplayListBuilder& aBuilder,
const WrRect& aBounds,
const WrRect& aClip,
const wr::LayoutRect& aBounds,
const wr::LayoutRect& aClip,
wr::ImageRendering aFilter,
Range<const wr::ImageKey>& aImageKeys) override;

View file

@ -213,6 +213,8 @@ public:
virtual mozilla::ipc::IPCResult RecvStartFrameTimeRecording(const int32_t& aBufferSize, uint32_t* aOutStartIndex) override;
virtual mozilla::ipc::IPCResult RecvStopFrameTimeRecording(const uint32_t& aStartIndex, InfallibleTArray<float>* intervals) override;
virtual mozilla::ipc::IPCResult RecvCheckContentOnlyTDR(const uint32_t& sequenceNum, bool* isContentOnlyTDR) override { return IPC_OK(); }
// Unused for chrome <-> compositor communication (which this class does).
// @see CrossProcessCompositorBridgeParent::RecvRequestNotifyAfterRemotePaint
virtual mozilla::ipc::IPCResult RecvRequestNotifyAfterRemotePaint() override { return IPC_OK(); };

View file

@ -10,6 +10,9 @@
#include "base/message_loop.h" // for MessageLoop
#include "base/task.h" // for CancelableTask, etc
#include "base/thread.h" // for Thread
#ifdef XP_WIN
#include "mozilla/gfx/DeviceManagerDx.h"// for DeviceManagerDx
#endif
#include "mozilla/ipc/Transport.h" // for Transport
#include "mozilla/layers/AnimationHelper.h" // for CompositorAnimationStorage
#include "mozilla/layers/APZCTreeManager.h" // for APZCTreeManager
@ -276,6 +279,29 @@ CrossProcessCompositorBridgeParent::RecvMapAndNotifyChildCreated(const uint64_t&
return IPC_FAIL_NO_REASON(this);
}
mozilla::ipc::IPCResult
CrossProcessCompositorBridgeParent::RecvCheckContentOnlyTDR(const uint32_t& sequenceNum,
bool* isContentOnlyTDR)
{
*isContentOnlyTDR = false;
#ifdef XP_WIN
ContentDeviceData compositor;
DeviceManagerDx* dm = DeviceManagerDx::Get();
// Check that the D3D11 device sequence numbers match.
D3D11DeviceStatus status;
dm->ExportDeviceInfo(&status);
if (sequenceNum == status.sequenceNumber() && !dm->HasDeviceReset()) {
*isContentOnlyTDR = true;
}
#endif
return IPC_OK();
};
void
CrossProcessCompositorBridgeParent::ShadowLayersUpdated(
LayerTransactionParent* aLayerTree,

View file

@ -58,6 +58,8 @@ public:
virtual mozilla::ipc::IPCResult RecvStartFrameTimeRecording(const int32_t& aBufferSize, uint32_t* aOutStartIndex) override { return IPC_OK(); }
virtual mozilla::ipc::IPCResult RecvStopFrameTimeRecording(const uint32_t& aStartIndex, InfallibleTArray<float>* intervals) override { return IPC_OK(); }
virtual mozilla::ipc::IPCResult RecvCheckContentOnlyTDR(const uint32_t& sequenceNum, bool* isContentOnlyTDR) override;
virtual mozilla::ipc::IPCResult RecvClearApproximatelyVisibleRegions(const uint64_t& aLayersId,
const uint32_t& aPresShellId) override;

View file

@ -252,6 +252,9 @@ parent:
sync PWebRenderBridge(PipelineId pipelineId, LayoutDeviceIntSize aSize)
returns (TextureFactoryIdentifier textureFactoryIdentifier, uint32_t idNamespace); //XXX: use the WrIdNamespace type
sync CheckContentOnlyTDR(uint32_t sequenceNum)
returns (bool isContentOnlyTDR);
child:
// Send back Compositor Frame Metrics from APZCs so tiled layers can
// update progressively.

View file

@ -23,7 +23,7 @@ using mozilla::wr::ExternalImageId from "mozilla/webrender/WebRenderTypes.h";
using mozilla::wr::ImageKey from "mozilla/webrender/WebRenderTypes.h";
using mozilla::wr::FontKey from "mozilla/webrender/WebRenderTypes.h";
using mozilla::wr::PipelineId from "mozilla/webrender/WebRenderTypes.h";
using WrBuiltDisplayListDescriptor from "mozilla/webrender/webrender_ffi.h";
using mozilla::wr::BuiltDisplayListDescriptor from "mozilla/webrender/webrender_ffi.h";
using mozilla::layers::WebRenderScrollData from "mozilla/layers/WebRenderScrollData.h";
namespace mozilla {
@ -55,10 +55,10 @@ parent:
async DeleteFont(FontKey aFontKey);
async DPBegin(IntSize aSize);
async DPEnd(IntSize aSize, WebRenderParentCommand[] commands, OpDestroy[] toDestroy, uint64_t fwdTransactionId, uint64_t transactionId,
WrSize aContentSize, ByteBuffer aDL, WrBuiltDisplayListDescriptor aDLDesc,
LayoutSize aContentSize, ByteBuffer aDL, BuiltDisplayListDescriptor aDLDesc,
WebRenderScrollData aScrollData, uint32_t idNameSpace);
sync DPSyncEnd(IntSize aSize, WebRenderParentCommand[] commands, OpDestroy[] toDestroy, uint64_t fwdTransactionId, uint64_t transactionId,
WrSize aContentSize, ByteBuffer aDL, WrBuiltDisplayListDescriptor aDLDesc,
LayoutSize aContentSize, ByteBuffer aDL, BuiltDisplayListDescriptor aDLDesc,
WebRenderScrollData aScrollData, uint32_t idNameSpace);
async ParentCommands(WebRenderParentCommand[] commands);
sync DPGetSnapshot(PTexture texture);

View file

@ -9,10 +9,10 @@ include LayersSurfaces;
include LayersMessages;
include protocol PTexture;
using WrSize from "mozilla/webrender/webrender_ffi.h";
using WrImageRendering from "mozilla/webrender/webrender_ffi.h";
using WrMixBlendMode from "mozilla/webrender/webrender_ffi.h";
using MaybeImageMask from "mozilla/webrender/WebRenderTypes.h";
using mozilla::wr::LayoutSize from "mozilla/webrender/webrender_ffi.h";
using mozilla::wr::ImageRendering from "mozilla/webrender/webrender_ffi.h";
using mozilla::wr::MixBlendMode from "mozilla/webrender/webrender_ffi.h";
using mozilla::wr::MaybeImageMask from "mozilla/webrender/WebRenderTypes.h";
using mozilla::wr::ExternalImageId from "mozilla/webrender/WebRenderTypes.h";
using mozilla::wr::ImageKey from "mozilla/webrender/WebRenderTypes.h";
using mozilla::wr::PipelineId from "mozilla/webrender/WebRenderTypes.h";
@ -51,8 +51,8 @@ struct OpUpdateAsyncImagePipeline {
LayerRect scBounds;
Matrix4x4 scTransform;
MaybeIntSize scaleToSize;
WrImageRendering filter;
WrMixBlendMode mixBlendMode;
ImageRendering filter;
MixBlendMode mixBlendMode;
};
union WebRenderParentCommand {

View file

@ -178,7 +178,7 @@ MacIOSurfaceTextureHostOGL::AddWRImage(wr::WebRenderAPI* aAPI,
aAPI->AddExternalImage(aImageKeys[0],
descriptor,
aExtID,
WrExternalImageBufferType::TextureRectHandle,
wr::WrExternalImageBufferType::TextureRectHandle,
0);
break;
}
@ -193,7 +193,7 @@ MacIOSurfaceTextureHostOGL::AddWRImage(wr::WebRenderAPI* aAPI,
aAPI->AddExternalImage(aImageKeys[0],
descriptor,
aExtID,
WrExternalImageBufferType::TextureRectHandle,
wr::WrExternalImageBufferType::TextureRectHandle,
0);
break;
}
@ -207,12 +207,12 @@ MacIOSurfaceTextureHostOGL::AddWRImage(wr::WebRenderAPI* aAPI,
aAPI->AddExternalImage(aImageKeys[0],
descriptor0,
aExtID,
WrExternalImageBufferType::TextureRectHandle,
wr::WrExternalImageBufferType::TextureRectHandle,
0);
aAPI->AddExternalImage(aImageKeys[1],
descriptor1,
aExtID,
WrExternalImageBufferType::TextureRectHandle,
wr::WrExternalImageBufferType::TextureRectHandle,
1);
break;
}
@ -224,8 +224,8 @@ MacIOSurfaceTextureHostOGL::AddWRImage(wr::WebRenderAPI* aAPI,
void
MacIOSurfaceTextureHostOGL::PushExternalImage(wr::DisplayListBuilder& aBuilder,
const WrRect& aBounds,
const WrRect& aClip,
const wr::LayoutRect& aBounds,
const wr::LayoutRect& aClip,
wr::ImageRendering aFilter,
Range<const wr::ImageKey>& aImageKeys)
{
@ -245,7 +245,7 @@ MacIOSurfaceTextureHostOGL::PushExternalImage(wr::DisplayListBuilder& aBuilder,
aBuilder.PushYCbCrInterleavedImage(aBounds,
aClip,
aImageKeys[0],
WrYuvColorSpace::Rec601,
wr::WrYuvColorSpace::Rec601,
aFilter);
break;
}
@ -256,7 +256,7 @@ MacIOSurfaceTextureHostOGL::PushExternalImage(wr::DisplayListBuilder& aBuilder,
aClip,
aImageKeys[0],
aImageKeys[1],
WrYuvColorSpace::Rec601,
wr::WrYuvColorSpace::Rec601,
aFilter);
break;
}

View file

@ -75,8 +75,8 @@ public:
const wr::ExternalImageId& aExtID) override;
virtual void PushExternalImage(wr::DisplayListBuilder& aBuilder,
const WrRect& aBounds,
const WrRect& aClip,
const wr::LayoutRect& aBounds,
const wr::LayoutRect& aClip,
wr::ImageRendering aFilter,
Range<const wr::ImageKey>& aImageKeys) override;

View file

@ -71,8 +71,8 @@ ScrollingLayersHelper::ScrollingLayersHelper(WebRenderLayer* aLayer,
// bounds.
contentRect.MoveTo(clipBounds.TopLeft());
mBuilder->PushScrollLayer(fm.GetScrollId(),
aStackingContext.ToRelativeWrRect(contentRect),
aStackingContext.ToRelativeWrRect(clipBounds));
aStackingContext.ToRelativeLayoutRect(contentRect),
aStackingContext.ToRelativeLayoutRect(clipBounds));
}
// The scrolled clip on the layer is "inside" all of the scrollable metadatas
@ -120,10 +120,10 @@ ScrollingLayersHelper::PushLayerLocalClip(const StackingContextHelper& aStacking
clip = Some(layer->GetLocalTransformTyped().TransformBounds(mLayer->Bounds()));
}
if (clip) {
Maybe<WrImageMask> mask = mLayer->BuildWrMaskLayer(aStackingContext);
Maybe<wr::WrImageMask> mask = mLayer->BuildWrMaskLayer(aStackingContext);
LayerRect clipRect = ViewAs<LayerPixel>(clip.ref(),
PixelCastJustification::MovingDownToChildren);
mBuilder->PushClip(aStackingContext.ToRelativeWrRect(clipRect), mask.ptrOr(nullptr));
mBuilder->PushClip(aStackingContext.ToRelativeLayoutRect(clipRect), mask.ptrOr(nullptr));
mPushedLayerLocalClip = true;
}
}
@ -134,14 +134,14 @@ ScrollingLayersHelper::PushLayerClip(const LayerClip& aClip,
{
LayerRect clipRect = IntRectToRect(ViewAs<LayerPixel>(aClip.GetClipRect(),
PixelCastJustification::MovingDownToChildren));
Maybe<WrImageMask> mask;
Maybe<wr::WrImageMask> mask;
if (Maybe<size_t> maskLayerIndex = aClip.GetMaskLayerIndex()) {
Layer* maskLayer = mLayer->GetLayer()->GetAncestorMaskLayerAt(maskLayerIndex.value());
WebRenderLayer* maskWrLayer = WebRenderLayer::ToWebRenderLayer(maskLayer);
// TODO: check this transform is correct in all cases
mask = maskWrLayer->RenderMaskLayer(aSc, maskLayer->GetTransform());
}
mBuilder->PushClip(aSc.ToRelativeWrRect(clipRect), mask.ptrOr(nullptr));
mBuilder->PushClip(aSc.ToRelativeLayoutRect(clipRect), mask.ptrOr(nullptr));
}
ScrollingLayersHelper::~ScrollingLayersHelper()

View file

@ -24,10 +24,10 @@ StackingContextHelper::StackingContextHelper(const StackingContextHelper& aParen
uint64_t aAnimationsId,
float* aOpacityPtr,
gfx::Matrix4x4* aTransformPtr,
const nsTArray<WrFilterOp>& aFilters)
const nsTArray<wr::WrFilterOp>& aFilters)
: mBuilder(&aBuilder)
{
WrRect scBounds = aParentSC.ToRelativeWrRect(aBoundForSC);
wr::LayoutRect scBounds = aParentSC.ToRelativeLayoutRect(aBoundForSC);
if (aTransformPtr) {
mTransform = *aTransformPtr;
}
@ -36,9 +36,9 @@ StackingContextHelper::StackingContextHelper(const StackingContextHelper& aParen
aAnimationsId,
aOpacityPtr,
aTransformPtr,
WrTransformStyle::Flat,
wr::TransformStyle::Flat,
// TODO: set correct blend mode.
wr::ToWrMixBlendMode(gfx::CompositionOp::OP_OVER),
wr::ToMixBlendMode(gfx::CompositionOp::OP_OVER),
aFilters);
mOrigin = aOrigin;
@ -48,18 +48,18 @@ StackingContextHelper::StackingContextHelper(const StackingContextHelper& aParen
wr::DisplayListBuilder& aBuilder,
WebRenderLayer* aLayer,
const Maybe<gfx::Matrix4x4>& aTransform,
const nsTArray<WrFilterOp>& aFilters)
const nsTArray<wr::WrFilterOp>& aFilters)
: mBuilder(&aBuilder)
{
WrRect scBounds = aParentSC.ToRelativeWrRect(aLayer->BoundsForStackingContext());
wr::LayoutRect scBounds = aParentSC.ToRelativeLayoutRect(aLayer->BoundsForStackingContext());
Layer* layer = aLayer->GetLayer();
mTransform = aTransform.valueOr(layer->GetTransform());
float opacity = 1.0f;
mBuilder->PushStackingContext(scBounds, 0, &opacity,
mTransform.IsIdentity() ? nullptr : &mTransform,
WrTransformStyle::Flat,
wr::ToWrMixBlendMode(layer->GetMixBlendMode()),
wr::TransformStyle::Flat,
wr::ToMixBlendMode(layer->GetMixBlendMode()),
aFilters);
mOrigin = aLayer->Bounds().TopLeft();
}
@ -70,10 +70,10 @@ StackingContextHelper::StackingContextHelper(const StackingContextHelper& aParen
uint64_t aAnimationsId,
float* aOpacityPtr,
gfx::Matrix4x4* aTransformPtr,
const nsTArray<WrFilterOp>& aFilters)
const nsTArray<wr::WrFilterOp>& aFilters)
: mBuilder(&aBuilder)
{
WrRect scBounds = aParentSC.ToRelativeWrRect(aLayer->BoundsForStackingContext());
wr::LayoutRect scBounds = aParentSC.ToRelativeLayoutRect(aLayer->BoundsForStackingContext());
if (aTransformPtr) {
mTransform = *aTransformPtr;
}
@ -82,8 +82,8 @@ StackingContextHelper::StackingContextHelper(const StackingContextHelper& aParen
aAnimationsId,
aOpacityPtr,
aTransformPtr,
WrTransformStyle::Flat,
wr::ToWrMixBlendMode(aLayer->GetLayer()->GetMixBlendMode()),
wr::TransformStyle::Flat,
wr::ToMixBlendMode(aLayer->GetLayer()->GetMixBlendMode()),
aFilters);
mOrigin = aLayer->Bounds().TopLeft();
}
@ -95,28 +95,28 @@ StackingContextHelper::~StackingContextHelper()
}
}
WrRect
StackingContextHelper::ToRelativeWrRect(const LayerRect& aRect) const
wr::LayoutRect
StackingContextHelper::ToRelativeLayoutRect(const LayerRect& aRect) const
{
return wr::ToWrRect(aRect - mOrigin);
return wr::ToLayoutRect(aRect - mOrigin);
}
WrRect
StackingContextHelper::ToRelativeWrRect(const LayoutDeviceRect& aRect) const
wr::LayoutRect
StackingContextHelper::ToRelativeLayoutRect(const LayoutDeviceRect& aRect) const
{
return wr::ToWrRect(ViewAs<LayerPixel>(aRect, PixelCastJustification::WebRenderHasUnitResolution) - mOrigin);
return wr::ToLayoutRect(ViewAs<LayerPixel>(aRect, PixelCastJustification::WebRenderHasUnitResolution) - mOrigin);
}
WrPoint
StackingContextHelper::ToRelativeWrPoint(const LayerPoint& aPoint) const
wr::LayoutPoint
StackingContextHelper::ToRelativeLayoutPoint(const LayerPoint& aPoint) const
{
return wr::ToWrPoint(aPoint - mOrigin);
return wr::ToLayoutPoint(aPoint - mOrigin);
}
WrRect
StackingContextHelper::ToRelativeWrRectRounded(const LayoutDeviceRect& aRect) const
wr::LayoutRect
StackingContextHelper::ToRelativeLayoutRectRounded(const LayoutDeviceRect& aRect) const
{
return wr::ToWrRect(RoundedToInt(ViewAs<LayerPixel>(aRect, PixelCastJustification::WebRenderHasUnitResolution) - mOrigin));
return wr::ToLayoutRect(RoundedToInt(ViewAs<LayerPixel>(aRect, PixelCastJustification::WebRenderHasUnitResolution) - mOrigin));
}
} // namespace layers

View file

@ -32,7 +32,7 @@ public:
wr::DisplayListBuilder& aBuilder,
WebRenderLayer* aLayer,
const Maybe<gfx::Matrix4x4>& aTransform = Nothing(),
const nsTArray<WrFilterOp>& aFilters = nsTArray<WrFilterOp>());
const nsTArray<wr::WrFilterOp>& aFilters = nsTArray<wr::WrFilterOp>());
// Alternate constructor which invokes the version of PushStackingContext
// for animations.
StackingContextHelper(const StackingContextHelper& aParentSC,
@ -41,7 +41,7 @@ public:
uint64_t aAnimationsId,
float* aOpacityPtr,
gfx::Matrix4x4* aTransformPtr,
const nsTArray<WrFilterOp>& aFilters = nsTArray<WrFilterOp>());
const nsTArray<wr::WrFilterOp>& aFilters = nsTArray<wr::WrFilterOp>());
// The constructor for layers-free mode.
StackingContextHelper(const StackingContextHelper& aParentSC,
wr::DisplayListBuilder& aBuilder,
@ -50,7 +50,7 @@ public:
uint64_t aAnimationsId,
float* aOpacityPtr,
gfx::Matrix4x4* aTransformPtr,
const nsTArray<WrFilterOp>& aFilters = nsTArray<WrFilterOp>());
const nsTArray<wr::WrFilterOp>& aFilters = nsTArray<wr::WrFilterOp>());
// This version of the constructor should only be used at the root level
// of the tree, so that we have a StackingContextHelper to pass down into
// the RenderLayer traversal, but don't actually want it to push a stacking
@ -61,19 +61,19 @@ public:
~StackingContextHelper();
// When this StackingContextHelper is in scope, this function can be used
// to convert a rect from the layer system's coordinate space to a WrRect
// to convert a rect from the layer system's coordinate space to a LayoutRect
// that is relative to the stacking context. This is useful because most
// things that are pushed inside the stacking context need to be relative
// to the stacking context.
// We allow passing in a LayoutDeviceRect for convenience because in a lot of
// cases with WebRender display item generate the layout device space is the
// same as the layer space. (TODO: try to make this more explicit somehow).
WrRect ToRelativeWrRect(const LayerRect& aRect) const;
WrRect ToRelativeWrRect(const LayoutDeviceRect& aRect) const;
wr::LayoutRect ToRelativeLayoutRect(const LayerRect& aRect) const;
wr::LayoutRect ToRelativeLayoutRect(const LayoutDeviceRect& aRect) const;
// Same but for points
WrPoint ToRelativeWrPoint(const LayerPoint& aPoint) const;
wr::LayoutPoint ToRelativeLayoutPoint(const LayerPoint& aPoint) const;
// Same but rounds the rectangle to ints after transforming.
WrRect ToRelativeWrRectRounded(const LayoutDeviceRect& aRect) const;
wr::LayoutRect ToRelativeLayoutRectRounded(const LayoutDeviceRect& aRect) const;
private:
wr::DisplayListBuilder* mBuilder;

View file

@ -108,7 +108,7 @@ WebRenderBridgeChild::DPEnd(wr::DisplayListBuilder &aBuilder,
MOZ_ASSERT(mIsInTransaction);
wr::BuiltDisplayList dl;
WrSize contentSize;
wr::LayoutSize contentSize;
aBuilder.Finalize(contentSize, dl);
ByteBuffer dlData(Move(dl.dl));
@ -206,27 +206,27 @@ WebRenderBridgeChild::PushGlyphs(wr::DisplayListBuilder& aBuilder, const nsTArra
MOZ_ASSERT(aFont);
MOZ_ASSERT(!aGlyphs.IsEmpty());
WrFontKey key = GetFontKeyForScaledFont(aFont);
wr::WrFontKey key = GetFontKeyForScaledFont(aFont);
MOZ_ASSERT(key.mNamespace && key.mHandle);
for (size_t i = 0; i < aGlyphs.Length(); i++) {
GlyphArray glyph_array = aGlyphs[i];
nsTArray<gfx::Glyph>& glyphs = glyph_array.glyphs();
nsTArray<WrGlyphInstance> wr_glyph_instances;
nsTArray<wr::GlyphInstance> wr_glyph_instances;
wr_glyph_instances.SetLength(glyphs.Length());
for (size_t j = 0; j < glyphs.Length(); j++) {
wr_glyph_instances[j].index = glyphs[j].mIndex;
wr_glyph_instances[j].point = aSc.ToRelativeWrPoint(
wr_glyph_instances[j].point = aSc.ToRelativeLayoutPoint(
LayerPoint::FromUnknownPoint(glyphs[j].mPosition));
}
aBuilder.PushText(aSc.ToRelativeWrRect(aBounds),
aSc.ToRelativeWrRect(aClip),
aBuilder.PushText(aSc.ToRelativeLayoutRect(aBounds),
aSc.ToRelativeLayoutRect(aClip),
glyph_array.color().value(),
key,
Range<const WrGlyphInstance>(wr_glyph_instances.Elements(), wr_glyph_instances.Length()),
Range<const wr::GlyphInstance>(wr_glyph_instances.Elements(), wr_glyph_instances.Length()),
aFont->GetSize());
}

View file

@ -96,9 +96,9 @@ public:
mIdNamespace = aIdNamespace;
}
WrImageKey GetNextImageKey()
wr::WrImageKey GetNextImageKey()
{
return WrImageKey{ GetNamespace(), GetNextResourceId() };
return wr::WrImageKey{ GetNamespace(), GetNextResourceId() };
}
void PushGlyphs(wr::DisplayListBuilder& aBuilder, const nsTArray<GlyphArray>& aGlyphs,

View file

@ -400,9 +400,9 @@ WebRenderBridgeParent::HandleDPEnd(const gfx::IntSize& aSize,
InfallibleTArray<OpDestroy>&& aToDestroy,
const uint64_t& aFwdTransactionId,
const uint64_t& aTransactionId,
const WrSize& aContentSize,
const ByteBuffer& dl,
const WrBuiltDisplayListDescriptor& dlDesc,
const wr::LayoutSize& aContentSize,
const wr::ByteBuffer& dl,
const wr::BuiltDisplayListDescriptor& dlDesc,
const WebRenderScrollData& aScrollData,
const uint32_t& aIdNameSpace)
{
@ -480,7 +480,7 @@ WebRenderBridgeParent::UpdateAPZ()
}
bool
WebRenderBridgeParent::PushAPZStateToWR(nsTArray<WrTransformProperty>& aTransformArray)
WebRenderBridgeParent::PushAPZStateToWR(nsTArray<wr::WrTransformProperty>& aTransformArray)
{
CompositorBridgeParent* cbp = GetRootCompositorBridgeParent();
if (!cbp) {
@ -513,9 +513,9 @@ WebRenderBridgeParent::RecvDPEnd(const gfx::IntSize& aSize,
InfallibleTArray<OpDestroy>&& aToDestroy,
const uint64_t& aFwdTransactionId,
const uint64_t& aTransactionId,
const WrSize& aContentSize,
const ByteBuffer& dl,
const WrBuiltDisplayListDescriptor& dlDesc,
const wr::LayoutSize& aContentSize,
const wr::ByteBuffer& dl,
const wr::BuiltDisplayListDescriptor& dlDesc,
const WebRenderScrollData& aScrollData,
const uint32_t& aIdNameSpace)
{
@ -533,9 +533,9 @@ WebRenderBridgeParent::RecvDPSyncEnd(const gfx::IntSize &aSize,
InfallibleTArray<OpDestroy>&& aToDestroy,
const uint64_t& aFwdTransactionId,
const uint64_t& aTransactionId,
const WrSize& aContentSize,
const ByteBuffer& dl,
const WrBuiltDisplayListDescriptor& dlDesc,
const wr::LayoutSize& aContentSize,
const wr::ByteBuffer& dl,
const wr::BuiltDisplayListDescriptor& dlDesc,
const WebRenderScrollData& aScrollData,
const uint32_t& aIdNameSpace)
{
@ -656,8 +656,8 @@ WebRenderBridgeParent::ProcessWebRenderParentCommands(InfallibleTArray<WebRender
void
WebRenderBridgeParent::ProcessWebRenderCommands(const gfx::IntSize &aSize,
InfallibleTArray<WebRenderParentCommand>& aCommands, const wr::Epoch& aEpoch,
const WrSize& aContentSize, const ByteBuffer& dl,
const WrBuiltDisplayListDescriptor& dlDesc,
const wr::LayoutSize& aContentSize, const wr::ByteBuffer& dl,
const wr::BuiltDisplayListDescriptor& dlDesc,
const uint32_t& aIdNameSpace)
{
mCompositableHolder->SetCompositionTime(TimeStamp::Now());
@ -1057,8 +1057,8 @@ WebRenderBridgeParent::AdvanceAnimations()
}
void
WebRenderBridgeParent::SampleAnimations(nsTArray<WrOpacityProperty>& aOpacityArray,
nsTArray<WrTransformProperty>& aTransformArray)
WebRenderBridgeParent::SampleAnimations(nsTArray<wr::WrOpacityProperty>& aOpacityArray,
nsTArray<wr::WrTransformProperty>& aTransformArray)
{
AdvanceAnimations();
@ -1096,8 +1096,8 @@ WebRenderBridgeParent::CompositeToTarget(gfx::DrawTarget* aTarget, const gfx::In
}
bool scheduleComposite = false;
nsTArray<WrOpacityProperty> opacityArray;
nsTArray<WrTransformProperty> transformArray;
nsTArray<wr::WrOpacityProperty> opacityArray;
nsTArray<wr::WrTransformProperty> transformArray;
mCompositableHolder->SetCompositionTime(TimeStamp::Now());
mCompositableHolder->ApplyAsyncImages(mApi);

View file

@ -98,9 +98,9 @@ public:
InfallibleTArray<OpDestroy>&& aToDestroy,
const uint64_t& aFwdTransactionId,
const uint64_t& aTransactionId,
const WrSize& aContentSize,
const ByteBuffer& dl,
const WrBuiltDisplayListDescriptor& dlDesc,
const wr::LayoutSize& aContentSize,
const wr::ByteBuffer& dl,
const wr::BuiltDisplayListDescriptor& dlDesc,
const WebRenderScrollData& aScrollData,
const uint32_t& aIdNameSpace) override;
mozilla::ipc::IPCResult RecvDPSyncEnd(const gfx::IntSize& aSize,
@ -108,9 +108,9 @@ public:
InfallibleTArray<OpDestroy>&& aToDestroy,
const uint64_t& aFwdTransactionId,
const uint64_t& aTransactionId,
const WrSize& aContentSize,
const ByteBuffer& dl,
const WrBuiltDisplayListDescriptor& dlDesc,
const wr::LayoutSize& aContentSize,
const wr::ByteBuffer& dl,
const wr::BuiltDisplayListDescriptor& dlDesc,
const WebRenderScrollData& aScrollData,
const uint32_t& aIdNameSpace) override;
mozilla::ipc::IPCResult RecvParentCommands(nsTArray<WebRenderParentCommand>&& commands) override;
@ -217,9 +217,9 @@ private:
void ProcessWebRenderCommands(const gfx::IntSize &aSize,
InfallibleTArray<WebRenderParentCommand>& commands,
const wr::Epoch& aEpoch,
const WrSize& aContentSize,
const ByteBuffer& dl,
const WrBuiltDisplayListDescriptor& dlDesc,
const wr::LayoutSize& aContentSize,
const wr::ByteBuffer& dl,
const wr::BuiltDisplayListDescriptor& dlDesc,
const uint32_t& aIdNameSpace);
void ClearResources();
uint64_t GetChildLayerObserverEpoch() const { return mChildLayerObserverEpoch; }
@ -229,16 +229,16 @@ private:
InfallibleTArray<OpDestroy>&& aToDestroy,
const uint64_t& aFwdTransactionId,
const uint64_t& aTransactionId,
const WrSize& aContentSize,
const ByteBuffer& dl,
const WrBuiltDisplayListDescriptor& dlDesc,
const wr::LayoutSize& aContentSize,
const wr::ByteBuffer& dl,
const wr::BuiltDisplayListDescriptor& dlDesc,
const WebRenderScrollData& aScrollData,
const uint32_t& aIdNameSpace);
mozilla::ipc::IPCResult HandleShutdown();
void AdvanceAnimations();
void SampleAnimations(nsTArray<WrOpacityProperty>& aOpacityArray,
nsTArray<WrTransformProperty>& aTransformArray);
void SampleAnimations(nsTArray<wr::WrOpacityProperty>& aOpacityArray,
nsTArray<wr::WrTransformProperty>& aTransformArray);
CompositorBridgeParent* GetRootCompositorBridgeParent() const;
@ -246,7 +246,7 @@ private:
// animation is in effect and we need to schedule another composition.
// If scrollbars need their transforms updated, the provided aTransformArray
// is populated with the property update details.
bool PushAPZStateToWR(nsTArray<WrTransformProperty>& aTransformArray);
bool PushAPZStateToWR(nsTArray<wr::WrTransformProperty>& aTransformArray);
// Helper method to get an APZC reference from a scroll id. Uses the layers
// id of this bridge, and may return null if the APZC wasn't found.

View file

@ -83,11 +83,11 @@ WebRenderCanvasLayer::RenderLayer(wr::DisplayListBuilder& aBuilder,
Stringify(filter).c_str());
}
WrImageKey key = GetImageKey();
wr::WrImageKey key = GetImageKey();
WrBridge()->AddWebRenderParentCommand(OpAddExternalImage(mExternalImageId.value(), key));
WrManager()->AddImageKeyForDiscard(key);
WrRect r = sc.ToRelativeWrRect(rect);
wr::LayoutRect r = sc.ToRelativeLayoutRect(rect);
aBuilder.PushImage(r, r, filter, key);
}

View file

@ -28,8 +28,8 @@ WebRenderColorLayer::RenderLayer(wr::DisplayListBuilder& aBuilder,
LayerRect rect = Bounds();
DumpLayerInfo("ColorLayer", rect);
WrRect r = sc.ToRelativeWrRect(rect);
aBuilder.PushRect(r, r, wr::ToWrColor(mColor));
wr::LayoutRect r = sc.ToRelativeLayoutRect(rect);
aBuilder.PushRect(r, r, wr::ToColorF(mColor));
}
} // namespace layers

View file

@ -19,8 +19,8 @@ WebRenderCompositableHolder::AsyncImagePipelineHolder::AsyncImagePipelineHolder(
: mInitialised(false)
, mIsChanged(false)
, mUseExternalImage(false)
, mFilter(WrImageRendering::Auto)
, mMixBlendMode(WrMixBlendMode::Normal)
, mFilter(wr::ImageRendering::Auto)
, mMixBlendMode(wr::MixBlendMode::Normal)
{}
WebRenderCompositableHolder::WebRenderCompositableHolder(uint32_t aIdNamespace)
@ -135,8 +135,8 @@ WebRenderCompositableHolder::UpdateAsyncImagePipeline(const wr::PipelineId& aPip
const LayerRect& aScBounds,
const gfx::Matrix4x4& aScTransform,
const gfx::MaybeIntSize& aScaleToSize,
const WrImageRendering& aFilter,
const WrMixBlendMode& aMixBlendMode)
const wr::ImageRendering& aFilter,
const wr::MixBlendMode& aMixBlendMode)
{
if (mDestroyed) {
return;
@ -264,20 +264,20 @@ WebRenderCompositableHolder::ApplyAsyncImages(wr::WebRenderAPI* aApi)
continue;
}
WrSize contentSize { holder->mScBounds.width, holder->mScBounds.height };
wr::LayoutSize contentSize { holder->mScBounds.width, holder->mScBounds.height };
wr::DisplayListBuilder builder(pipelineId, contentSize);
if (!keys.IsEmpty()) {
MOZ_ASSERT(holder->mCurrentTexture.get());
float opacity = 1.0f;
builder.PushStackingContext(wr::ToWrRect(holder->mScBounds),
builder.PushStackingContext(wr::ToLayoutRect(holder->mScBounds),
0,
&opacity,
holder->mScTransform.IsIdentity() ? nullptr : &holder->mScTransform,
WrTransformStyle::Flat,
wr::TransformStyle::Flat,
holder->mMixBlendMode,
nsTArray<WrFilterOp>());
nsTArray<wr::WrFilterOp>());
LayerRect rect(0, 0, holder->mCurrentTexture->GetSize().width, holder->mCurrentTexture->GetSize().height);
if (holder->mScaleToSize.isSome()) {
@ -288,15 +288,15 @@ WebRenderCompositableHolder::ApplyAsyncImages(wr::WebRenderAPI* aApi)
MOZ_ASSERT(holder->mCurrentTexture->AsWebRenderTextureHost());
Range<const wr::ImageKey> range_keys(&keys[0], keys.Length());
holder->mCurrentTexture->PushExternalImage(builder,
wr::ToWrRect(rect),
wr::ToWrRect(rect),
wr::ToLayoutRect(rect),
wr::ToLayoutRect(rect),
holder->mFilter,
range_keys);
HoldExternalImage(pipelineId, epoch, holder->mCurrentTexture->AsWebRenderTextureHost());
} else {
MOZ_ASSERT(keys.Length() == 1);
builder.PushImage(wr::ToWrRect(rect),
wr::ToWrRect(rect),
builder.PushImage(wr::ToLayoutRect(rect),
wr::ToLayoutRect(rect),
holder->mFilter,
keys[0]);
}
@ -304,7 +304,7 @@ WebRenderCompositableHolder::ApplyAsyncImages(wr::WebRenderAPI* aApi)
}
wr::BuiltDisplayList dl;
WrSize builderContentSize;
wr::LayoutSize builderContentSize;
builder.Finalize(builderContentSize, dl);
aApi->SetRootDisplayList(gfx::Color(0.f, 0.f, 0.f, 0.f), epoch, LayerSize(holder->mScBounds.width, holder->mScBounds.height),
pipelineId, builderContentSize,

View file

@ -75,8 +75,8 @@ public:
const LayerRect& aScBounds,
const gfx::Matrix4x4& aScTransform,
const gfx::MaybeIntSize& aScaleToSize,
const WrImageRendering& aFilter,
const WrMixBlendMode& aMixBlendMode);
const wr::ImageRendering& aFilter,
const wr::MixBlendMode& aMixBlendMode);
void ApplyAsyncImages(wr::WebRenderAPI* aApi);
private:
@ -117,8 +117,8 @@ private:
LayerRect mScBounds;
gfx::Matrix4x4 mScTransform;
gfx::MaybeIntSize mScaleToSize;
WrImageRendering mFilter;
WrMixBlendMode mMixBlendMode;
wr::ImageRendering mFilter;
wr::MixBlendMode mMixBlendMode;
RefPtr<WebRenderImageHost> mImageHost;
CompositableTextureHostRef mCurrentTexture;
nsTArray<wr::ImageKey> mKeys;

View file

@ -114,7 +114,7 @@ WebRenderContainerLayer::RenderLayer(wr::DisplayListBuilder& aBuilder,
transformForSC = nullptr;
}
nsTArray<WrFilterOp> filters;
nsTArray<wr::WrFilterOp> filters;
for (const CSSFilter& filter : this->GetFilterChain()) {
filters.AppendElement(wr::ToWrFilterOp(filter));
}
@ -150,7 +150,7 @@ WebRenderRefLayer::RenderLayer(wr::DisplayListBuilder& aBuilder,
PixelCastJustification::MovingDownToChildren);
DumpLayerInfo("RefLayer", rect);
WrRect r = aSc.ToRelativeWrRect(rect);
wr::LayoutRect r = aSc.ToRelativeLayoutRect(rect);
aBuilder.PushIFrame(r, wr::AsPipelineId(mId));
}

View file

@ -34,7 +34,7 @@ WebRenderDisplayItemLayer::RenderLayer(wr::DisplayListBuilder& aBuilder,
ScrollingLayersHelper scroller(this, aBuilder, aSc);
if (mItem) {
WrSize contentSize; // this won't actually be used by anything
wr::LayoutSize contentSize; // this won't actually be used by anything
wr::DisplayListBuilder builder(WrBridge()->GetPipeline(), contentSize);
// We might have recycled this layer. Throw away the old commands.
mParentCommands.Clear();

View file

@ -167,7 +167,7 @@ WebRenderImageLayer::RenderLayer(wr::DisplayListBuilder& aBuilder,
PixelCastJustification::MovingDownToChildren);
DumpLayerInfo("Image Layer async", rect);
WrRect r = aSc.ToRelativeWrRect(rect);
wr::LayoutRect r = aSc.ToRelativeLayoutRect(rect);
aBuilder.PushIFrame(r, mPipelineId.ref());
gfx::Matrix4x4 scTransform = GetTransform();
@ -185,7 +185,7 @@ WebRenderImageLayer::RenderLayer(wr::DisplayListBuilder& aBuilder,
}
LayerRect scBounds = BoundsForStackingContext();
wr::ImageRendering filter = wr::ToImageRendering(mSamplingFilter);
wr::MixBlendMode mixBlendMode = wr::ToWrMixBlendMode(GetMixBlendMode());
wr::MixBlendMode mixBlendMode = wr::ToMixBlendMode(GetMixBlendMode());
WrBridge()->AddWebRenderParentCommand(OpUpdateAsyncImagePipeline(mPipelineId.value(),
scBounds,
@ -231,11 +231,11 @@ WebRenderImageLayer::RenderLayer(wr::DisplayListBuilder& aBuilder,
GetLayer(),
Stringify(filter).c_str());
}
WrRect r = sc.ToRelativeWrRect(rect);
wr::LayoutRect r = sc.ToRelativeLayoutRect(rect);
aBuilder.PushImage(r, r, filter, mKey.value());
}
Maybe<WrImageMask>
Maybe<wr::WrImageMask>
WebRenderImageLayer::RenderMaskLayer(const StackingContextHelper& aSc,
const gfx::Matrix4x4& aTransform)
{
@ -283,10 +283,10 @@ WebRenderImageLayer::RenderMaskLayer(const StackingContextHelper& aSc,
}
gfx::IntSize size = image->GetSize();
WrImageMask imageMask;
wr::WrImageMask imageMask;
imageMask.image = mKey.value();
Rect maskRect = aTransform.TransformBounds(Rect(0, 0, size.width, size.height));
imageMask.rect = aSc.ToRelativeWrRect(ViewAs<LayerPixel>(maskRect));
imageMask.rect = aSc.ToRelativeLayoutRect(ViewAs<LayerPixel>(maskRect));
imageMask.repeat = false;
return Some(imageMask);
}

View file

@ -33,8 +33,8 @@ public:
Layer* GetLayer() override { return this; }
void RenderLayer(wr::DisplayListBuilder& aBuilder,
const StackingContextHelper& aSc) override;
Maybe<WrImageMask> RenderMaskLayer(const StackingContextHelper& aSc,
const gfx::Matrix4x4& aTransform) override;
Maybe<wr::WrImageMask> RenderMaskLayer(const StackingContextHelper& aSc,
const gfx::Matrix4x4& aTransform) override;
protected:
CompositableType GetImageClientType();

View file

@ -31,16 +31,16 @@ WebRenderLayer::WrBridge()
return WrManager()->WrBridge();
}
WrImageKey
wr::WrImageKey
WebRenderLayer::GetImageKey()
{
WrImageKey key;
wr::WrImageKey key;
key.mNamespace = WrBridge()->GetNamespace();
key.mHandle = WrBridge()->GetNextResourceId();
return key;
}
Maybe<WrImageMask>
Maybe<wr::WrImageMask>
WebRenderLayer::BuildWrMaskLayer(const StackingContextHelper& aRelativeTo)
{
if (GetLayer()->GetMaskLayer()) {
@ -111,7 +111,7 @@ WebRenderLayer::UpdateImageKey(ImageClientSingle* aImageClient,
WrManager()->AddImageKeyForDiscard(aOldKey.value());
}
WrImageKey key = GetImageKey();
wr::WrImageKey key = GetImageKey();
WrBridge()->AddWebRenderParentCommand(OpAddExternalImage(aExternalImageId, key));
return Some(key);
}
@ -126,7 +126,7 @@ WebRenderLayer::DumpLayerInfo(const char* aLayerType, const LayerRect& aRect)
Layer* layer = GetLayer();
Matrix4x4 transform = layer->GetTransform();
LayerRect bounds = Bounds();
WrMixBlendMode mixBlendMode = wr::ToWrMixBlendMode(GetLayer()->GetMixBlendMode());
wr::MixBlendMode mixBlendMode = wr::ToMixBlendMode(GetLayer()->GetMixBlendMode());
printf_stderr("%s %p using bounds=%s, transform=%s, rect=%s, clip=%s, mix-blend-mode=%s\n",
aLayerType,

View file

@ -26,7 +26,7 @@ public:
virtual Layer* GetLayer() = 0;
virtual void RenderLayer(wr::DisplayListBuilder& aBuilder,
const StackingContextHelper& aSc) = 0;
virtual Maybe<WrImageMask> RenderMaskLayer(const StackingContextHelper& aSc,
virtual Maybe<wr::WrImageMask> RenderMaskLayer(const StackingContextHelper& aSc,
const gfx::Matrix4x4& aTransform)
{
MOZ_ASSERT(false);
@ -47,7 +47,7 @@ public:
WebRenderLayerManager* WrManager();
WebRenderBridgeChild* WrBridge();
WrImageKey GetImageKey();
wr::WrImageKey GetImageKey();
LayerRect Bounds();
LayerRect BoundsForStackingContext();
@ -57,7 +57,7 @@ public:
// that we want this mask to be relative to. This is usually the stacking
// context of the *parent* layer of |this|, because that is what the mask
// is relative to in the layer tree.
Maybe<WrImageMask> BuildWrMaskLayer(const StackingContextHelper& aRelativeTo);
Maybe<wr::WrImageMask> BuildWrMaskLayer(const StackingContextHelper& aRelativeTo);
protected:
BoundsTransformMatrix BoundsTransform();

View file

@ -311,7 +311,7 @@ WebRenderLayerManager::PushImage(nsDisplayItem* aItem,
}
wr::ImageRendering filter = wr::ImageRendering::Auto;
auto r = aSc.ToRelativeWrRect(aRect);
auto r = aSc.ToRelativeLayoutRect(aRect);
aBuilder.PushImage(r, r, filter, key.value());
return true;
@ -438,7 +438,7 @@ WebRenderLayerManager::PushItemAsImage(nsDisplayItem* aItem,
MOZ_ASSERT(fallbackData->GetKey());
WrRect dest = aSc.ToRelativeWrRect(imageRect + offset);
wr::LayoutRect dest = aSc.ToRelativeLayoutRect(imageRect + offset);
aBuilder.PushImage(dest,
dest,
wr::ImageRendering::Auto,
@ -482,7 +482,7 @@ WebRenderLayerManager::EndTransactionInternal(DrawPaintedLayerCallback aCallback
}
DiscardCompositorAnimations();
WrSize contentSize { (float)size.width, (float)size.height };
wr::LayoutSize contentSize { (float)size.width, (float)size.height };
wr::DisplayListBuilder builder(WrBridge()->GetPipeline(), contentSize);
if (mEndTransactionWithoutLayers) {

View file

@ -106,26 +106,26 @@ struct ParamTraits<mozilla::wr::PipelineId>
};
template<>
struct ParamTraits<WrImageFormat>
struct ParamTraits<mozilla::wr::ImageFormat>
: public ContiguousEnumSerializer<
WrImageFormat,
WrImageFormat::Invalid,
WrImageFormat::Sentinel>
mozilla::wr::ImageFormat,
mozilla::wr::ImageFormat::Invalid,
mozilla::wr::ImageFormat::Sentinel>
{
};
template<>
struct ParamTraits<WrSize>
struct ParamTraits<mozilla::wr::LayoutSize>
{
static void
Write(Message* aMsg, const WrSize& aParam)
Write(Message* aMsg, const mozilla::wr::LayoutSize& aParam)
{
WriteParam(aMsg, aParam.width);
WriteParam(aMsg, aParam.height);
}
static bool
Read(const Message* aMsg, PickleIterator* aIter, WrSize* aResult)
Read(const Message* aMsg, PickleIterator* aIter, mozilla::wr::LayoutSize* aResult)
{
return ReadParam(aMsg, aIter, &aResult->width)
&& ReadParam(aMsg, aIter, &aResult->height);
@ -133,39 +133,39 @@ struct ParamTraits<WrSize>
};
template<>
struct ParamTraits<WrRect>
struct ParamTraits<mozilla::wr::LayoutRect>
{
static void
Write(Message* aMsg, const WrRect& aParam)
Write(Message* aMsg, const mozilla::wr::LayoutRect& aParam)
{
WriteParam(aMsg, aParam.x);
WriteParam(aMsg, aParam.y);
WriteParam(aMsg, aParam.width);
WriteParam(aMsg, aParam.height);
WriteParam(aMsg, aParam.origin.x);
WriteParam(aMsg, aParam.origin.y);
WriteParam(aMsg, aParam.size.width);
WriteParam(aMsg, aParam.size.height);
}
static bool
Read(const Message* aMsg, PickleIterator* aIter, WrRect* aResult)
Read(const Message* aMsg, PickleIterator* aIter, mozilla::wr::LayoutRect* aResult)
{
return ReadParam(aMsg, aIter, &aResult->x)
&& ReadParam(aMsg, aIter, &aResult->y)
&& ReadParam(aMsg, aIter, &aResult->width)
&& ReadParam(aMsg, aIter, &aResult->height);
return ReadParam(aMsg, aIter, &aResult->origin.x)
&& ReadParam(aMsg, aIter, &aResult->origin.y)
&& ReadParam(aMsg, aIter, &aResult->size.width)
&& ReadParam(aMsg, aIter, &aResult->size.height);
}
};
template<>
struct ParamTraits<WrPoint>
struct ParamTraits<mozilla::wr::LayoutPoint>
{
static void
Write(Message* aMsg, const WrPoint& aParam)
Write(Message* aMsg, const mozilla::wr::LayoutPoint& aParam)
{
WriteParam(aMsg, aParam.x);
WriteParam(aMsg, aParam.y);
}
static bool
Read(const Message* aMsg, PickleIterator* aIter, WrPoint* aResult)
Read(const Message* aMsg, PickleIterator* aIter, mozilla::wr::LayoutPoint* aResult)
{
return ReadParam(aMsg, aIter, &aResult->x) &&
ReadParam(aMsg, aIter, &aResult->y);
@ -173,10 +173,10 @@ struct ParamTraits<WrPoint>
};
template<>
struct ParamTraits<WrImageMask>
struct ParamTraits<mozilla::wr::WrImageMask>
{
static void
Write(Message* aMsg, const WrImageMask& aParam)
Write(Message* aMsg, const mozilla::wr::WrImageMask& aParam)
{
WriteParam(aMsg, aParam.image);
WriteParam(aMsg, aParam.rect);
@ -184,7 +184,7 @@ struct ParamTraits<WrImageMask>
}
static bool
Read(const Message* aMsg, PickleIterator* aIter, WrImageMask* aResult)
Read(const Message* aMsg, PickleIterator* aIter, mozilla::wr::WrImageMask* aResult)
{
return ReadParam(aMsg, aIter, &aResult->image)
&& ReadParam(aMsg, aIter, &aResult->rect)
@ -193,35 +193,35 @@ struct ParamTraits<WrImageMask>
};
template<>
struct ParamTraits<WrImageRendering>
struct ParamTraits<mozilla::wr::ImageRendering>
: public ContiguousEnumSerializer<
WrImageRendering,
WrImageRendering::Auto,
WrImageRendering::Sentinel>
mozilla::wr::ImageRendering,
mozilla::wr::ImageRendering::Auto,
mozilla::wr::ImageRendering::Sentinel>
{
};
template<>
struct ParamTraits<WrMixBlendMode>
struct ParamTraits<mozilla::wr::MixBlendMode>
: public ContiguousEnumSerializer<
WrMixBlendMode,
WrMixBlendMode::Normal,
WrMixBlendMode::Sentinel>
mozilla::wr::MixBlendMode,
mozilla::wr::MixBlendMode::Normal,
mozilla::wr::MixBlendMode::Sentinel>
{
};
template<>
struct ParamTraits<WrBuiltDisplayListDescriptor>
struct ParamTraits<mozilla::wr::BuiltDisplayListDescriptor>
{
static void
Write(Message* aMsg, const WrBuiltDisplayListDescriptor& aParam)
Write(Message* aMsg, const mozilla::wr::BuiltDisplayListDescriptor& aParam)
{
WriteParam(aMsg, aParam.builder_start_time);
WriteParam(aMsg, aParam.builder_finish_time);
}
static bool
Read(const Message* aMsg, PickleIterator* aIter, WrBuiltDisplayListDescriptor* aResult)
Read(const Message* aMsg, PickleIterator* aIter, mozilla::wr::BuiltDisplayListDescriptor* aResult)
{
return ReadParam(aMsg, aIter, &aResult->builder_start_time)
&& ReadParam(aMsg, aIter, &aResult->builder_finish_time);

View file

@ -99,11 +99,11 @@ WebRenderPaintedLayer::CreateWebRenderDisplayList(wr::DisplayListBuilder& aBuild
LayerRect rect = Bounds();
DumpLayerInfo("PaintedLayer", rect);
WrImageKey key = GetImageKey();
wr::WrImageKey key = GetImageKey();
WrBridge()->AddWebRenderParentCommand(OpAddExternalImage(mExternalImageId.value(), key));
WrManager()->AddImageKeyForDiscard(key);
WrRect r = sc.ToRelativeWrRect(rect);
wr::LayoutRect r = sc.ToRelativeLayoutRect(rect);
aBuilder.PushImage(r, r, wr::ImageRendering::Auto, key);
}

View file

@ -88,8 +88,8 @@ WebRenderPaintedLayerBlob::RenderLayer(wr::DisplayListBuilder& aBuilder,
LayerRect rect = Bounds();
DumpLayerInfo("PaintedLayer", rect);
aBuilder.PushImage(sc.ToRelativeWrRect(LayerRect(mImageBounds)),
sc.ToRelativeWrRect(rect),
aBuilder.PushImage(sc.ToRelativeLayoutRect(LayerRect(mImageBounds)),
sc.ToRelativeLayoutRect(rect),
wr::ImageRendering::Auto, mImageKey.value());
}

View file

@ -62,7 +62,7 @@ public:
void RenderLayer(wr::DisplayListBuilder& aBuilder,
const StackingContextHelper& aSc) override;
private:
Maybe<WrImageKey> mImageKey;
Maybe<wr::WrImageKey> mImageKey;
LayerIntRect mImageBounds;
};

View file

@ -178,8 +178,8 @@ WebRenderTextureHost::AddWRImage(wr::WebRenderAPI* aAPI,
void
WebRenderTextureHost::PushExternalImage(wr::DisplayListBuilder& aBuilder,
const WrRect& aBounds,
const WrRect& aClip,
const wr::LayoutRect& aBounds,
const wr::LayoutRect& aClip,
wr::ImageRendering aFilter,
Range<const wr::ImageKey>& aImageKeys)
{

View file

@ -73,8 +73,8 @@ public:
const wr::ExternalImageId& aExtID) override;
virtual void PushExternalImage(wr::DisplayListBuilder& aBuilder,
const WrRect& aBounds,
const WrRect& aClip,
const wr::LayoutRect& aBounds,
const wr::LayoutRect& aClip,
wr::ImageRendering aFilter,
Range<const wr::ImageKey>& aImageKeys) override;

View file

@ -71,7 +71,7 @@ WebRenderImageData::UpdateImageKey(ImageContainer* aContainer, bool aForceUpdate
mWRManager->AddImageKeyForDiscard(mKey.value());
}
WrImageKey key = WrBridge()->GetNextImageKey();
wr::WrImageKey key = WrBridge()->GetNextImageKey();
mWRManager->WrBridge()->AddWebRenderParentCommand(OpAddExternalImage(mExternalImageId.value(), key));
mKey = Some(key);
@ -93,8 +93,8 @@ WebRenderImageData::CreateAsyncImageWebRenderCommands(mozilla::wr::DisplayListBu
const LayerRect& aSCBounds,
const Matrix4x4& aSCTransform,
const MaybeIntSize& aScaleToSize,
const WrImageRendering& aFilter,
const WrMixBlendMode& aMixBlendMode)
const wr::ImageRendering& aFilter,
const wr::MixBlendMode& aMixBlendMode)
{
MOZ_ASSERT(aContainer->IsAsync());
if (!mPipelineId) {
@ -114,7 +114,7 @@ WebRenderImageData::CreateAsyncImageWebRenderCommands(mozilla::wr::DisplayListBu
// context need to be done manually and pushed over to the parent side,
// where it will be done when we build the display list for the iframe.
// That happens in WebRenderCompositableHolder.
WrRect r = aSc.ToRelativeWrRect(aBounds);
wr::LayoutRect r = aSc.ToRelativeLayoutRect(aBounds);
aBuilder.PushIFrame(r, mPipelineId.ref());
WrBridge()->AddWebRenderParentCommand(OpUpdateAsyncImagePipeline(mPipelineId.value(),

View file

@ -67,8 +67,8 @@ public:
const LayerRect& aSCBounds,
const gfx::Matrix4x4& aSCTransform,
const gfx::MaybeIntSize& aScaleToSize,
const WrImageRendering& aFilter,
const WrMixBlendMode& aMixBlendMode);
const wr::ImageRendering& aFilter,
const wr::MixBlendMode& aMixBlendMode);
void CreateImageClientIfNeeded();

View file

@ -174,11 +174,6 @@ DeviceManagerDx::ImportDeviceInfo(const D3D11DeviceStatus& aDeviceStatus)
void
DeviceManagerDx::ExportDeviceInfo(D3D11DeviceStatus* aOut)
{
// Even though the parent process might not own the compositor, we still
// populate DeviceManagerDx with device statistics (for simplicity).
// That means it still gets queried for compositor information.
MOZ_ASSERT(XRE_IsParentProcess() || XRE_GetProcessType() == GeckoProcessType_GPU);
if (mDeviceStatus) {
*aOut = mDeviceStatus.value();
}
@ -322,6 +317,20 @@ DeviceManagerDx::CreateCompositorDeviceHelper(
return true;
}
// Note that it's enough for us to just use a counter for a unique ID,
// even though the counter isn't synchronized between processes. If we
// start in the GPU process and wind up in the parent process, the
// whole graphics stack is blown away anyway. But just in case, we
// make gpu process IDs negative and parent process IDs positive.
static inline int32_t
GetNextDeviceCounter()
{
static int32_t sDeviceCounter = 0;
return XRE_IsGPUProcess()
? --sDeviceCounter
: ++sDeviceCounter;
}
void
DeviceManagerDx::CreateCompositorDevice(FeatureState& d3d11)
{
@ -379,15 +388,18 @@ DeviceManagerDx::CreateCompositorDevice(FeatureState& d3d11)
D3D11Checks::WarnOnAdapterMismatch(device);
}
int featureLevel = device->GetFeatureLevel();
uint32_t featureLevel = device->GetFeatureLevel();
{
MutexAutoLock lock(mDeviceLock);
mCompositorDevice = device;
int32_t sequenceNumber = GetNextDeviceCounter();
mDeviceStatus = Some(D3D11DeviceStatus(
false,
textureSharingWorks,
featureLevel,
DxgiAdapterDesc::From(desc)));
DxgiAdapterDesc::From(desc),
sequenceNumber));
}
mCompositorDevice->SetExceptionMode(0);
}
@ -475,11 +487,14 @@ DeviceManagerDx::CreateWARPCompositorDevice()
{
MutexAutoLock lock(mDeviceLock);
mCompositorDevice = device;
int32_t sequenceNumber = GetNextDeviceCounter();
mDeviceStatus = Some(D3D11DeviceStatus(
true,
textureSharingWorks,
featureLevel,
nullAdapter));
nullAdapter,
sequenceNumber));
}
mCompositorDevice->SetExceptionMode(0);

View file

@ -501,6 +501,7 @@ private:
DECL_GFX_PREF(Live, "image.decode-immediately.enabled", ImageDecodeImmediatelyEnabled, bool, false);
DECL_GFX_PREF(Live, "image.downscale-during-decode.enabled", ImageDownscaleDuringDecodeEnabled, bool, true);
DECL_GFX_PREF(Live, "image.infer-src-animation.threshold-ms", ImageInferSrcAnimationThresholdMS, uint32_t, 2000);
DECL_GFX_PREF(Live, "image.layout_network_priority", ImageLayoutNetworkPriority, bool, true);
DECL_GFX_PREF(Once, "image.mem.decode_bytes_at_a_time", ImageMemDecodeBytesAtATime, uint32_t, 200000);
DECL_GFX_PREF(Live, "image.mem.discardable", ImageMemDiscardable, bool, false);
DECL_GFX_PREF(Once, "image.mem.animated.discardable", ImageMemAnimatedDiscardable, bool, false);

View file

@ -8,6 +8,7 @@
#include "cairo.h"
#include "mozilla/ArrayUtils.h"
#include "mozilla/layers/CompositorBridgeChild.h"
#include "gfxImageSurface.h"
#include "gfxWindowsSurface.h"
@ -20,6 +21,7 @@
#include "mozilla/WindowsVersion.h"
#include "nsServiceManagerUtils.h"
#include "nsTArray.h"
#include "nsThreadUtils.h"
#include "mozilla/Telemetry.h"
#include "GeckoProfiler.h"
@ -70,7 +72,7 @@
#include "gfxConfig.h"
#include "VsyncSource.h"
#include "DriverCrashGuard.h"
#include "mozilla/dom/ContentParent.h"
#include "mozilla/dom/ContentChild.h"
#include "mozilla/gfx/DeviceManagerDx.h"
#include "mozilla/layers/DeviceAttachmentsD3D11.h"
#include "D3D11Checks.h"
@ -894,12 +896,44 @@ gfxWindowsPlatform::SchedulePaintIfDeviceReset()
gfxCriticalNote << "(gfxWindowsPlatform) Detected device reset: " << (int)resetReason;
// Trigger an ::OnPaint for each window.
::EnumThreadWindows(GetCurrentThreadId(),
InvalidateWindowForDeviceReset,
0);
if (XRE_IsParentProcess()) {
// Trigger an ::OnPaint for each window.
::EnumThreadWindows(GetCurrentThreadId(),
InvalidateWindowForDeviceReset,
0);
} else {
NS_DispatchToMainThread(NS_NewRunnableFunction(
"gfx::gfxWindowsPlatform::SchedulePaintIfDeviceReset",
[]() -> void {
gfxWindowsPlatform::GetPlatform()->CheckForContentOnlyDeviceReset();
}
));
}
gfxCriticalNote << "(gfxWindowsPlatform) Finished device reset.";
gfxCriticalNote << "(gfxWindowsPlatform) scheduled device update.";
}
void
gfxWindowsPlatform::CheckForContentOnlyDeviceReset()
{
if (!DidRenderingDeviceReset()) {
return;
}
bool isContentOnlyTDR;
D3D11DeviceStatus status;
DeviceManagerDx::Get()->ExportDeviceInfo(&status);
CompositorBridgeChild::Get()->SendCheckContentOnlyTDR(
status.sequenceNumber(), &isContentOnlyTDR);
// The parent process doesn't know about the reset yet, or the reset is
// local to our device.
if (isContentOnlyTDR) {
gfxCriticalNote << "A content-only TDR is detected.";
dom::ContentChild* cc = dom::ContentChild::GetSingleton();
cc->RecvReinitRenderingForDeviceReset();
}
}
void

View file

@ -180,6 +180,7 @@ public:
bool DidRenderingDeviceReset(DeviceResetReason* aResetReason = nullptr) override;
void SchedulePaintIfDeviceReset() override;
void CheckForContentOnlyDeviceReset();
mozilla::gfx::BackendType GetContentBackendFor(mozilla::layers::LayersBackend aLayers) override;

View file

@ -90,14 +90,14 @@ static bool Moz2DRenderCallback(const Range<const uint8_t> aBlob,
extern "C" {
bool wr_moz2d_render_cb(const WrByteSlice blob,
bool wr_moz2d_render_cb(const mozilla::wr::ByteSlice blob,
uint32_t width, uint32_t height,
mozilla::wr::ImageFormat aFormat,
MutByteSlice output)
mozilla::wr::MutByteSlice output)
{
return mozilla::wr::Moz2DRenderCallback(mozilla::wr::ByteSliceToRange(blob),
mozilla::gfx::IntSize(width, height),
mozilla::wr::WrImageFormatToSurfaceFormat(aFormat),
mozilla::wr::ImageFormatToSurfaceFormat(aFormat),
mozilla::wr::MutByteSliceToRange(output));
}

View file

@ -190,12 +190,12 @@ RenderThread::RunEvent(wr::WindowId aWindowId, UniquePtr<RendererEvent> aEvent)
static void
NotifyDidRender(layers::CompositorBridgeParentBase* aBridge,
WrRenderedEpochs* aEpochs,
wr::WrRenderedEpochs* aEpochs,
TimeStamp aStart,
TimeStamp aEnd)
{
WrPipelineId pipeline;
WrEpoch epoch;
wr::WrPipelineId pipeline;
wr::WrEpoch epoch;
while (wr_rendered_epochs_next(aEpochs, &pipeline, &epoch)) {
aBridge->NotifyDidCompositeToPipeline(pipeline, epoch, aStart, aEnd);
}
@ -352,7 +352,7 @@ RenderThread::DeferredRenderTextureHostDestroy(RefPtr<RenderTextureHost>)
}
RenderTextureHost*
RenderThread::GetRenderTexture(WrExternalImageId aExternalImageId)
RenderThread::GetRenderTexture(wr::WrExternalImageId aExternalImageId)
{
MOZ_ASSERT(IsInRenderThread());
@ -376,13 +376,13 @@ WebRenderThreadPool::~WebRenderThreadPool()
extern "C" {
void wr_notifier_new_frame_ready(WrWindowId aWindowId)
void wr_notifier_new_frame_ready(mozilla::wr::WrWindowId aWindowId)
{
mozilla::wr::RenderThread::Get()->IncPendingFrameCount(aWindowId);
mozilla::wr::RenderThread::Get()->NewFrameReady(mozilla::wr::WindowId(aWindowId));
}
void wr_notifier_new_scroll_frame_ready(WrWindowId aWindowId, bool aCompositeNeeded)
void wr_notifier_new_scroll_frame_ready(mozilla::wr::WrWindowId aWindowId, bool aCompositeNeeded)
{
// It is not necessary to update rendering with new_scroll_frame_ready.
// WebRenderBridgeParent::CompositeToTarget() is implemented to call
@ -390,7 +390,7 @@ void wr_notifier_new_scroll_frame_ready(WrWindowId aWindowId, bool aCompositeNee
// See Bug 1377688.
}
void wr_notifier_external_event(WrWindowId aWindowId, size_t aRawEvent)
void wr_notifier_external_event(mozilla::wr::WrWindowId aWindowId, size_t aRawEvent)
{
mozilla::UniquePtr<mozilla::wr::RendererEvent> evt(
reinterpret_cast<mozilla::wr::RendererEvent*>(aRawEvent));

View file

@ -34,10 +34,10 @@ public:
~WebRenderThreadPool();
WrThreadPool* Raw() { return mThreadPool; }
wr::WrThreadPool* Raw() { return mThreadPool; }
protected:
WrThreadPool* mThreadPool;
wr::WrThreadPool* mThreadPool;
};

View file

@ -16,7 +16,7 @@
namespace mozilla {
namespace wr {
WrExternalImage LockExternalImage(void* aObj, WrExternalImageId aId, uint8_t aChannelIndex)
wr::WrExternalImage LockExternalImage(void* aObj, wr::WrExternalImageId aId, uint8_t aChannelIndex)
{
RendererOGL* renderer = reinterpret_cast<RendererOGL*>(aObj);
RenderTextureHost* texture = renderer->GetRenderTexture(aId);
@ -44,7 +44,7 @@ WrExternalImage LockExternalImage(void* aObj, WrExternalImageId aId, uint8_t aCh
}
}
void UnlockExternalImage(void* aObj, WrExternalImageId aId, uint8_t aChannelIndex)
void UnlockExternalImage(void* aObj, wr::WrExternalImageId aId, uint8_t aChannelIndex)
{
RendererOGL* renderer = reinterpret_cast<RendererOGL*>(aObj);
RenderTextureHost* texture = renderer->GetRenderTexture(aId);
@ -56,19 +56,19 @@ RendererOGL::RendererOGL(RefPtr<RenderThread>&& aThread,
RefPtr<gl::GLContext>&& aGL,
RefPtr<widget::CompositorWidget>&& aWidget,
wr::WindowId aWindowId,
WrRenderer* aWrRenderer,
wr::Renderer* aRenderer,
layers::CompositorBridgeParentBase* aBridge)
: mThread(aThread)
, mGL(aGL)
, mWidget(aWidget)
, mWrRenderer(aWrRenderer)
, mRenderer(aRenderer)
, mBridge(aBridge)
, mWindowId(aWindowId)
{
MOZ_ASSERT(mThread);
MOZ_ASSERT(mGL);
MOZ_ASSERT(mWidget);
MOZ_ASSERT(mWrRenderer);
MOZ_ASSERT(mRenderer);
MOZ_ASSERT(mBridge);
MOZ_COUNT_CTOR(RendererOGL);
}
@ -81,13 +81,13 @@ RendererOGL::~RendererOGL()
// Leak resources!
return;
}
wr_renderer_delete(mWrRenderer);
wr_renderer_delete(mRenderer);
}
WrExternalImageHandler
wr::WrExternalImageHandler
RendererOGL::GetExternalImageHandler()
{
return WrExternalImageHandler {
return wr::WrExternalImageHandler {
this,
LockExternalImage,
UnlockExternalImage,
@ -97,7 +97,7 @@ RendererOGL::GetExternalImageHandler()
void
RendererOGL::Update()
{
wr_renderer_update(mWrRenderer);
wr_renderer_update(mRenderer);
}
bool
@ -127,7 +127,7 @@ RendererOGL::Render()
// XXX set clear color if MOZ_WIDGET_ANDROID is defined.
auto size = mWidget->GetClientSize();
wr_renderer_render(mWrRenderer, size.width, size.height);
wr_renderer_render(mRenderer, size.width, size.height);
mGL->SwapBuffers();
mWidget->PostRender(&widgetContext);
@ -167,17 +167,17 @@ RendererOGL::Resume()
void
RendererOGL::SetProfilerEnabled(bool aEnabled)
{
wr_renderer_set_profiler_enabled(mWrRenderer, aEnabled);
wr_renderer_set_profiler_enabled(mRenderer, aEnabled);
}
WrRenderedEpochs*
wr::WrRenderedEpochs*
RendererOGL::FlushRenderedEpochs()
{
return wr_renderer_flush_rendered_epochs(mWrRenderer);
return wr_renderer_flush_rendered_epochs(mRenderer);
}
RenderTextureHost*
RendererOGL::GetRenderTexture(WrExternalImageId aExternalImageId)
RendererOGL::GetRenderTexture(wr::WrExternalImageId aExternalImageId)
{
return mThread->GetRenderTexture(aExternalImageId);
}

View file

@ -40,11 +40,11 @@ class RenderTextureHost;
/// on the render thread instead of the compositor thread.
class RendererOGL
{
friend WrExternalImage LockExternalImage(void* aObj, WrExternalImageId aId, uint8_t aChannelIndex);
friend void UnlockExternalImage(void* aObj, WrExternalImageId aId, uint8_t aChannelIndex);
friend wr::WrExternalImage LockExternalImage(void* aObj, wr::WrExternalImageId aId, uint8_t aChannelIndex);
friend void UnlockExternalImage(void* aObj, wr::WrExternalImageId aId, uint8_t aChannelIndex);
public:
WrExternalImageHandler GetExternalImageHandler();
wr::WrExternalImageHandler GetExternalImageHandler();
/// This can be called on the render thread only.
void Update();
@ -66,7 +66,7 @@ public:
RefPtr<gl::GLContext>&& aGL,
RefPtr<widget::CompositorWidget>&&,
wr::WindowId aWindowId,
WrRenderer* aWrRenderer,
wr::Renderer* aRenderer,
layers::CompositorBridgeParentBase* aBridge);
/// This can be called on the render thread only.
@ -77,18 +77,18 @@ public:
layers::CompositorBridgeParentBase* GetCompositorBridge() { return mBridge; }
WrRenderedEpochs* FlushRenderedEpochs();
wr::WrRenderedEpochs* FlushRenderedEpochs();
RenderTextureHost* GetRenderTexture(WrExternalImageId aExternalImageId);
RenderTextureHost* GetRenderTexture(wr::WrExternalImageId aExternalImageId);
WrRenderer* GetWrRenderer() { return mWrRenderer; }
wr::Renderer* GetRenderer() { return mRenderer; }
protected:
RefPtr<RenderThread> mThread;
RefPtr<gl::GLContext> mGL;
RefPtr<widget::CompositorWidget> mWidget;
WrRenderer* mWrRenderer;
wr::Renderer* mRenderer;
layers::CompositorBridgeParentBase* mBridge;
wr::WindowId mWindowId;
};

View file

@ -23,14 +23,14 @@ using layers::Stringify;
class NewRenderer : public RendererEvent
{
public:
NewRenderer(WrAPI** aApi, layers::CompositorBridgeParentBase* aBridge,
NewRenderer(wr::RenderApi** aApi, layers::CompositorBridgeParentBase* aBridge,
GLint* aMaxTextureSize,
bool* aUseANGLE,
RefPtr<widget::CompositorWidget>&& aWidget,
layers::SynchronousTask* aTask,
bool aEnableProfiler,
LayoutDeviceIntSize aSize)
: mWrApi(aApi)
: mRenderApi(aApi)
, mMaxTextureSize(aMaxTextureSize)
, mUseANGLE(aUseANGLE)
, mBridge(aBridge)
@ -70,10 +70,10 @@ public:
gl->fGetIntegerv(LOCAL_GL_MAX_TEXTURE_SIZE, mMaxTextureSize);
*mUseANGLE = gl->IsANGLE();
WrRenderer* wrRenderer = nullptr;
wr::Renderer* wrRenderer = nullptr;
if (!wr_window_new(aWindowId, mSize.width, mSize.height, gl.get(),
aRenderThread.ThreadPool().Raw(),
this->mEnableProfiler, mWrApi, &wrRenderer)) {
this->mEnableProfiler, mRenderApi, &wrRenderer)) {
// wr_window_new puts a message into gfxCriticalNote if it returns false
return;
}
@ -87,7 +87,7 @@ public:
wrRenderer,
mBridge);
if (wrRenderer && renderer) {
WrExternalImageHandler handler = renderer->GetExternalImageHandler();
wr::WrExternalImageHandler handler = renderer->GetExternalImageHandler();
wr_renderer_set_external_image_handler(wrRenderer, &handler);
}
@ -95,7 +95,7 @@ public:
}
private:
WrAPI** mWrApi;
wr::RenderApi** mRenderApi;
GLint* mMaxTextureSize;
bool* mUseANGLE;
layers::CompositorBridgeParentBase* mBridge;
@ -143,30 +143,30 @@ WebRenderAPI::Create(bool aEnableProfiler,
static uint64_t sNextId = 1;
auto id = NewWindowId(sNextId++);
WrAPI* wrApi = nullptr;
wr::RenderApi* renderApi = nullptr;
GLint maxTextureSize = 0;
bool useANGLE = false;
// Dispatch a synchronous task because the WrApi object needs to be created
// Dispatch a synchronous task because the RenderApi object needs to be created
// on the render thread. If need be we could delay waiting on this task until
// the next time we need to access the WrApi object.
// the next time we need to access the RenderApi object.
layers::SynchronousTask task("Create Renderer");
auto event = MakeUnique<NewRenderer>(&wrApi, aBridge, &maxTextureSize, &useANGLE,
auto event = MakeUnique<NewRenderer>(&renderApi, aBridge, &maxTextureSize, &useANGLE,
Move(aWidget), &task, aEnableProfiler, aSize);
RenderThread::Get()->RunEvent(id, Move(event));
task.Wait();
if (!wrApi) {
if (!renderApi) {
return nullptr;
}
return RefPtr<WebRenderAPI>(new WebRenderAPI(wrApi, id, maxTextureSize, useANGLE)).forget();
return RefPtr<WebRenderAPI>(new WebRenderAPI(renderApi, id, maxTextureSize, useANGLE)).forget();
}
WrIdNamespace
wr::WrIdNamespace
WebRenderAPI::GetNamespace() {
return wr_api_get_namespace(mWrApi);
return wr_api_get_namespace(mRenderApi);
}
WebRenderAPI::~WebRenderAPI()
@ -176,28 +176,28 @@ WebRenderAPI::~WebRenderAPI()
RunOnRenderThread(Move(event));
task.Wait();
wr_api_delete(mWrApi);
wr_api_delete(mRenderApi);
}
void
WebRenderAPI::UpdateScrollPosition(const WrPipelineId& aPipelineId,
WebRenderAPI::UpdateScrollPosition(const wr::WrPipelineId& aPipelineId,
const layers::FrameMetrics::ViewID& aScrollId,
const WrPoint& aScrollPosition)
const wr::LayoutPoint& aScrollPosition)
{
wr_scroll_layer_with_id(mWrApi, aPipelineId, aScrollId, aScrollPosition);
wr_scroll_layer_with_id(mRenderApi, aPipelineId, aScrollId, aScrollPosition);
}
void
WebRenderAPI::GenerateFrame()
{
wr_api_generate_frame(mWrApi);
wr_api_generate_frame(mRenderApi);
}
void
WebRenderAPI::GenerateFrame(const nsTArray<WrOpacityProperty>& aOpacityArray,
const nsTArray<WrTransformProperty>& aTransformArray)
WebRenderAPI::GenerateFrame(const nsTArray<wr::WrOpacityProperty>& aOpacityArray,
const nsTArray<wr::WrTransformProperty>& aTransformArray)
{
wr_api_generate_frame_with_properties(mWrApi,
wr_api_generate_frame_with_properties(mRenderApi,
aOpacityArray.IsEmpty() ?
nullptr : aOpacityArray.Elements(),
aOpacityArray.Length(),
@ -210,14 +210,14 @@ void
WebRenderAPI::SetRootDisplayList(gfx::Color aBgColor,
Epoch aEpoch,
LayerSize aViewportSize,
WrPipelineId pipeline_id,
const WrSize& content_size,
WrBuiltDisplayListDescriptor dl_descriptor,
wr::WrPipelineId pipeline_id,
const LayoutSize& content_size,
wr::BuiltDisplayListDescriptor dl_descriptor,
uint8_t *dl_data,
size_t dl_size)
{
wr_api_set_root_display_list(mWrApi,
ToWrColor(aBgColor),
wr_api_set_root_display_list(mRenderApi,
ToColorF(aBgColor),
aEpoch,
aViewportSize.width, aViewportSize.height,
pipeline_id,
@ -229,15 +229,15 @@ WebRenderAPI::SetRootDisplayList(gfx::Color aBgColor,
void
WebRenderAPI::ClearRootDisplayList(Epoch aEpoch,
WrPipelineId pipeline_id)
wr::WrPipelineId pipeline_id)
{
wr_api_clear_root_display_list(mWrApi, aEpoch, pipeline_id);
wr_api_clear_root_display_list(mRenderApi, aEpoch, pipeline_id);
}
void
WebRenderAPI::SetWindowParameters(LayoutDeviceIntSize size)
{
wr_api_set_window_parameters(mWrApi, size.width, size.height);
wr_api_set_window_parameters(mRenderApi, size.width, size.height);
}
void
@ -266,7 +266,7 @@ WebRenderAPI::Readback(gfx::IntSize size,
virtual void Run(RenderThread& aRenderThread, WindowId aWindowId) override
{
aRenderThread.UpdateAndRender(aWindowId);
wr_renderer_readback(aRenderThread.GetRenderer(aWindowId)->GetWrRenderer(),
wr_renderer_readback(aRenderThread.GetRenderer(aWindowId)->GetRenderer(),
mSize.width, mSize.height, mBuffer, mBufferSize);
layers::AutoCompleteTask complete(mTask);
}
@ -399,14 +399,14 @@ WebRenderAPI::WaitFlushed()
void
WebRenderAPI::SetRootPipeline(PipelineId aPipeline)
{
wr_api_set_root_pipeline(mWrApi, aPipeline);
wr_api_set_root_pipeline(mRenderApi, aPipeline);
}
void
WebRenderAPI::AddImage(ImageKey key, const ImageDescriptor& aDescriptor,
Range<uint8_t> aBytes)
{
wr_api_add_image(mWrApi,
wr_api_add_image(mRenderApi,
key,
&aDescriptor,
RangeToByteSlice(aBytes));
@ -416,7 +416,7 @@ void
WebRenderAPI::AddBlobImage(ImageKey key, const ImageDescriptor& aDescriptor,
Range<uint8_t> aBytes)
{
wr_api_add_blob_image(mWrApi,
wr_api_add_blob_image(mRenderApi,
key,
&aDescriptor,
RangeToByteSlice(aBytes));
@ -426,10 +426,10 @@ void
WebRenderAPI::AddExternalImage(ImageKey key,
const ImageDescriptor& aDescriptor,
ExternalImageId aExtID,
WrExternalImageBufferType aBufferType,
wr::WrExternalImageBufferType aBufferType,
uint8_t aChannelIndex)
{
wr_api_add_external_image(mWrApi,
wr_api_add_external_image(mRenderApi,
key,
&aDescriptor,
aExtID,
@ -442,7 +442,7 @@ WebRenderAPI::AddExternalImageBuffer(ImageKey key,
const ImageDescriptor& aDescriptor,
ExternalImageId aHandle)
{
wr_api_add_external_image_buffer(mWrApi,
wr_api_add_external_image_buffer(mRenderApi,
key,
&aDescriptor,
aHandle);
@ -453,7 +453,7 @@ WebRenderAPI::UpdateImageBuffer(ImageKey aKey,
const ImageDescriptor& aDescriptor,
Range<uint8_t> aBytes)
{
wr_api_update_image(mWrApi,
wr_api_update_image(mRenderApi,
aKey,
&aDescriptor,
RangeToByteSlice(aBytes));
@ -462,19 +462,19 @@ WebRenderAPI::UpdateImageBuffer(ImageKey aKey,
void
WebRenderAPI::DeleteImage(ImageKey aKey)
{
wr_api_delete_image(mWrApi, aKey);
wr_api_delete_image(mRenderApi, aKey);
}
void
WebRenderAPI::AddRawFont(wr::FontKey aKey, Range<uint8_t> aBytes, uint32_t aIndex)
{
wr_api_add_raw_font(mWrApi, aKey, &aBytes[0], aBytes.length(), aIndex);
wr_api_add_raw_font(mRenderApi, aKey, &aBytes[0], aBytes.length(), aIndex);
}
void
WebRenderAPI::DeleteFont(wr::FontKey aKey)
{
wr_api_delete_font(mWrApi, aKey);
wr_api_delete_font(mRenderApi, aKey);
}
class EnableProfiler : public RendererEvent
@ -514,11 +514,11 @@ void
WebRenderAPI::RunOnRenderThread(UniquePtr<RendererEvent> aEvent)
{
auto event = reinterpret_cast<uintptr_t>(aEvent.release());
wr_api_send_external_event(mWrApi, event);
wr_api_send_external_event(mRenderApi, event);
}
DisplayListBuilder::DisplayListBuilder(PipelineId aId,
const WrSize& aContentSize)
const wr::LayoutSize& aContentSize)
{
MOZ_COUNT_CTOR(DisplayListBuilder);
mWrState = wr_state_new(aId, aContentSize);
@ -543,7 +543,7 @@ DisplayListBuilder::End()
}
void
DisplayListBuilder::Finalize(WrSize& aOutContentSize,
DisplayListBuilder::Finalize(wr::LayoutSize& aOutContentSize,
BuiltDisplayList& aOutDisplayList)
{
wr_api_finalize_builder(mWrState,
@ -553,19 +553,19 @@ DisplayListBuilder::Finalize(WrSize& aOutContentSize,
}
void
DisplayListBuilder::PushStackingContext(const WrRect& aBounds,
DisplayListBuilder::PushStackingContext(const wr::LayoutRect& aBounds,
const uint64_t& aAnimationId,
const float* aOpacity,
const gfx::Matrix4x4* aTransform,
WrTransformStyle aTransformStyle,
const WrMixBlendMode& aMixBlendMode,
const nsTArray<WrFilterOp>& aFilters)
wr::TransformStyle aTransformStyle,
const wr::MixBlendMode& aMixBlendMode,
const nsTArray<wr::WrFilterOp>& aFilters)
{
WrMatrix matrix;
wr::LayoutTransform matrix;
if (aTransform) {
matrix = ToWrMatrix(*aTransform);
matrix = ToLayoutTransform(*aTransform);
}
const WrMatrix* maybeTransform = aTransform ? &matrix : nullptr;
const wr::LayoutTransform* maybeTransform = aTransform ? &matrix : nullptr;
WRDL_LOG("PushStackingContext b=%s t=%s\n", Stringify(aBounds).c_str(),
aTransform ? Stringify(*aTransform).c_str() : "none");
wr_dp_push_stacking_context(mWrState, aBounds, aAnimationId, aOpacity,
@ -581,14 +581,14 @@ DisplayListBuilder::PopStackingContext()
}
void
DisplayListBuilder::PushClip(const WrRect& aClipRect,
const WrImageMask* aMask)
DisplayListBuilder::PushClip(const wr::LayoutRect& aClipRect,
const wr::WrImageMask* aMask)
{
uint64_t clip_id = wr_dp_push_clip(mWrState, aClipRect, nullptr, 0, aMask);
WRDL_LOG("PushClip id=%" PRIu64 " r=%s m=%p b=%s\n", clip_id,
Stringify(aClipRect).c_str(), aMask,
aMask ? Stringify(aMask->rect).c_str() : "none");
mClipIdStack.push_back(WrClipId { clip_id });
mClipIdStack.push_back(wr::WrClipId { clip_id });
}
void
@ -609,8 +609,8 @@ DisplayListBuilder::PushBuiltDisplayList(BuiltDisplayList &dl)
void
DisplayListBuilder::PushScrollLayer(const layers::FrameMetrics::ViewID& aScrollId,
const WrRect& aContentRect,
const WrRect& aClipRect)
const wr::LayoutRect& aContentRect,
const wr::LayoutRect& aClipRect)
{
WRDL_LOG("PushScrollLayer id=%" PRIu64 " co=%s cl=%s\n",
aScrollId, Stringify(aContentRect).c_str(), Stringify(aClipRect).c_str());
@ -635,7 +635,7 @@ DisplayListBuilder::PopScrollLayer()
void
DisplayListBuilder::PushClipAndScrollInfo(const layers::FrameMetrics::ViewID& aScrollId,
const WrClipId* aClipId)
const wr::WrClipId* aClipId)
{
WRDL_LOG("PushClipAndScroll s=%" PRIu64 " c=%s\n", aScrollId,
aClipId ? Stringify(aClipId->id).c_str() : "none");
@ -651,9 +651,9 @@ DisplayListBuilder::PopClipAndScrollInfo()
}
void
DisplayListBuilder::PushRect(const WrRect& aBounds,
const WrRect& aClip,
const WrColor& aColor)
DisplayListBuilder::PushRect(const wr::LayoutRect& aBounds,
const wr::LayoutRect& aClip,
const wr::ColorF& aColor)
{
WRDL_LOG("PushRect b=%s cl=%s c=%s\n",
Stringify(aBounds).c_str(),
@ -663,14 +663,14 @@ DisplayListBuilder::PushRect(const WrRect& aBounds,
}
void
DisplayListBuilder::PushLinearGradient(const WrRect& aBounds,
const WrRect& aClip,
const WrPoint& aStartPoint,
const WrPoint& aEndPoint,
const nsTArray<WrGradientStop>& aStops,
wr::GradientExtendMode aExtendMode,
const WrSize aTileSize,
const WrSize aTileSpacing)
DisplayListBuilder::PushLinearGradient(const wr::LayoutRect& aBounds,
const wr::LayoutRect& aClip,
const wr::LayoutPoint& aStartPoint,
const wr::LayoutPoint& aEndPoint,
const nsTArray<wr::GradientStop>& aStops,
wr::ExtendMode aExtendMode,
const wr::LayoutSize aTileSize,
const wr::LayoutSize aTileSpacing)
{
wr_dp_push_linear_gradient(mWrState,
aBounds, aClip,
@ -681,14 +681,14 @@ DisplayListBuilder::PushLinearGradient(const WrRect& aBounds,
}
void
DisplayListBuilder::PushRadialGradient(const WrRect& aBounds,
const WrRect& aClip,
const WrPoint& aCenter,
const WrSize& aRadius,
const nsTArray<WrGradientStop>& aStops,
wr::GradientExtendMode aExtendMode,
const WrSize aTileSize,
const WrSize aTileSpacing)
DisplayListBuilder::PushRadialGradient(const wr::LayoutRect& aBounds,
const wr::LayoutRect& aClip,
const wr::LayoutPoint& aCenter,
const wr::LayoutSize& aRadius,
const nsTArray<wr::GradientStop>& aStops,
wr::ExtendMode aExtendMode,
const wr::LayoutSize aTileSize,
const wr::LayoutSize aTileSpacing)
{
wr_dp_push_radial_gradient(mWrState,
aBounds, aClip,
@ -699,22 +699,22 @@ DisplayListBuilder::PushRadialGradient(const WrRect& aBounds,
}
void
DisplayListBuilder::PushImage(const WrRect& aBounds,
const WrRect& aClip,
DisplayListBuilder::PushImage(const wr::LayoutRect& aBounds,
const wr::LayoutRect& aClip,
wr::ImageRendering aFilter,
wr::ImageKey aImage)
{
WrSize size;
size.width = aBounds.width;
size.height = aBounds.height;
wr::LayoutSize size;
size.width = aBounds.size.width;
size.height = aBounds.size.height;
PushImage(aBounds, aClip, size, size, aFilter, aImage);
}
void
DisplayListBuilder::PushImage(const WrRect& aBounds,
const WrRect& aClip,
const WrSize& aStretchSize,
const WrSize& aTileSpacing,
DisplayListBuilder::PushImage(const wr::LayoutRect& aBounds,
const wr::LayoutRect& aClip,
const wr::LayoutSize& aStretchSize,
const wr::LayoutSize& aTileSpacing,
wr::ImageRendering aFilter,
wr::ImageKey aImage)
{
@ -725,12 +725,12 @@ DisplayListBuilder::PushImage(const WrRect& aBounds,
}
void
DisplayListBuilder::PushYCbCrPlanarImage(const WrRect& aBounds,
const WrRect& aClip,
DisplayListBuilder::PushYCbCrPlanarImage(const wr::LayoutRect& aBounds,
const wr::LayoutRect& aClip,
wr::ImageKey aImageChannel0,
wr::ImageKey aImageChannel1,
wr::ImageKey aImageChannel2,
WrYuvColorSpace aColorSpace,
wr::WrYuvColorSpace aColorSpace,
wr::ImageRendering aRendering)
{
wr_dp_push_yuv_planar_image(mWrState,
@ -744,11 +744,11 @@ DisplayListBuilder::PushYCbCrPlanarImage(const WrRect& aBounds,
}
void
DisplayListBuilder::PushNV12Image(const WrRect& aBounds,
const WrRect& aClip,
DisplayListBuilder::PushNV12Image(const wr::LayoutRect& aBounds,
const wr::LayoutRect& aClip,
wr::ImageKey aImageChannel0,
wr::ImageKey aImageChannel1,
WrYuvColorSpace aColorSpace,
wr::WrYuvColorSpace aColorSpace,
wr::ImageRendering aRendering)
{
wr_dp_push_yuv_NV12_image(mWrState,
@ -761,10 +761,10 @@ DisplayListBuilder::PushNV12Image(const WrRect& aBounds,
}
void
DisplayListBuilder::PushYCbCrInterleavedImage(const WrRect& aBounds,
const WrRect& aClip,
DisplayListBuilder::PushYCbCrInterleavedImage(const wr::LayoutRect& aBounds,
const wr::LayoutRect& aClip,
wr::ImageKey aImageChannel0,
WrYuvColorSpace aColorSpace,
wr::WrYuvColorSpace aColorSpace,
wr::ImageRendering aRendering)
{
wr_dp_push_yuv_interleaved_image(mWrState,
@ -776,18 +776,18 @@ DisplayListBuilder::PushYCbCrInterleavedImage(const WrRect& aBounds,
}
void
DisplayListBuilder::PushIFrame(const WrRect& aBounds,
DisplayListBuilder::PushIFrame(const wr::LayoutRect& aBounds,
PipelineId aPipeline)
{
wr_dp_push_iframe(mWrState, aBounds, aPipeline);
}
void
DisplayListBuilder::PushBorder(const WrRect& aBounds,
const WrRect& aClip,
const WrBorderWidths& aWidths,
const Range<const WrBorderSide>& aSides,
const WrBorderRadius& aRadius)
DisplayListBuilder::PushBorder(const wr::LayoutRect& aBounds,
const wr::LayoutRect& aClip,
const wr::BorderWidths& aWidths,
const Range<const wr::BorderSide>& aSides,
const wr::BorderRadius& aRadius)
{
MOZ_ASSERT(aSides.length() == 4);
if (aSides.length() != 4) {
@ -798,14 +798,14 @@ DisplayListBuilder::PushBorder(const WrRect& aBounds,
}
void
DisplayListBuilder::PushBorderImage(const WrRect& aBounds,
const WrRect& aClip,
const WrBorderWidths& aWidths,
DisplayListBuilder::PushBorderImage(const wr::LayoutRect& aBounds,
const wr::LayoutRect& aClip,
const wr::BorderWidths& aWidths,
wr::ImageKey aImage,
const WrNinePatchDescriptor& aPatch,
const WrSideOffsets2Df32& aOutset,
const WrRepeatMode& aRepeatHorizontal,
const WrRepeatMode& aRepeatVertical)
const wr::NinePatchDescriptor& aPatch,
const wr::SideOffsets2D_f32& aOutset,
const wr::RepeatMode& aRepeatHorizontal,
const wr::RepeatMode& aRepeatVertical)
{
wr_dp_push_border_image(mWrState, aBounds, aClip,
aWidths, aImage, aPatch, aOutset,
@ -813,14 +813,14 @@ DisplayListBuilder::PushBorderImage(const WrRect& aBounds,
}
void
DisplayListBuilder::PushBorderGradient(const WrRect& aBounds,
const WrRect& aClip,
const WrBorderWidths& aWidths,
const WrPoint& aStartPoint,
const WrPoint& aEndPoint,
const nsTArray<WrGradientStop>& aStops,
wr::GradientExtendMode aExtendMode,
const WrSideOffsets2Df32& aOutset)
DisplayListBuilder::PushBorderGradient(const wr::LayoutRect& aBounds,
const wr::LayoutRect& aClip,
const wr::BorderWidths& aWidths,
const wr::LayoutPoint& aStartPoint,
const wr::LayoutPoint& aEndPoint,
const nsTArray<wr::GradientStop>& aStops,
wr::ExtendMode aExtendMode,
const wr::SideOffsets2D_f32& aOutset)
{
wr_dp_push_border_gradient(mWrState, aBounds, aClip,
aWidths, aStartPoint, aEndPoint,
@ -829,14 +829,14 @@ DisplayListBuilder::PushBorderGradient(const WrRect& aBounds,
}
void
DisplayListBuilder::PushBorderRadialGradient(const WrRect& aBounds,
const WrRect& aClip,
const WrBorderWidths& aWidths,
const WrPoint& aCenter,
const WrSize& aRadius,
const nsTArray<WrGradientStop>& aStops,
wr::GradientExtendMode aExtendMode,
const WrSideOffsets2Df32& aOutset)
DisplayListBuilder::PushBorderRadialGradient(const wr::LayoutRect& aBounds,
const wr::LayoutRect& aClip,
const wr::BorderWidths& aWidths,
const wr::LayoutPoint& aCenter,
const wr::LayoutSize& aRadius,
const nsTArray<wr::GradientStop>& aStops,
wr::ExtendMode aExtendMode,
const wr::SideOffsets2D_f32& aOutset)
{
wr_dp_push_border_radial_gradient(
mWrState, aBounds, aClip, aWidths, aCenter,
@ -845,30 +845,30 @@ DisplayListBuilder::PushBorderRadialGradient(const WrRect& aBounds,
}
void
DisplayListBuilder::PushText(const WrRect& aBounds,
const WrRect& aClip,
DisplayListBuilder::PushText(const wr::LayoutRect& aBounds,
const wr::LayoutRect& aClip,
const gfx::Color& aColor,
wr::FontKey aFontKey,
Range<const WrGlyphInstance> aGlyphBuffer,
Range<const wr::GlyphInstance> aGlyphBuffer,
float aGlyphSize)
{
wr_dp_push_text(mWrState, aBounds, aClip,
ToWrColor(aColor),
ToColorF(aColor),
aFontKey,
&aGlyphBuffer[0], aGlyphBuffer.length(),
aGlyphSize);
}
void
DisplayListBuilder::PushBoxShadow(const WrRect& aRect,
const WrRect& aClip,
const WrRect& aBoxBounds,
const WrPoint& aOffset,
const WrColor& aColor,
DisplayListBuilder::PushBoxShadow(const wr::LayoutRect& aRect,
const wr::LayoutRect& aClip,
const wr::LayoutRect& aBoxBounds,
const wr::LayoutVector2D& aOffset,
const wr::ColorF& aColor,
const float& aBlurRadius,
const float& aSpreadRadius,
const float& aBorderRadius,
const WrBoxShadowClipMode& aClipMode)
const wr::BoxShadowClipMode& aClipMode)
{
wr_dp_push_box_shadow(mWrState, aRect, aClip,
aBoxBounds, aOffset, aColor,
@ -876,7 +876,7 @@ DisplayListBuilder::PushBoxShadow(const WrRect& aRect,
aClipMode);
}
Maybe<WrClipId>
Maybe<wr::WrClipId>
DisplayListBuilder::TopmostClipId()
{
if (mClipIdStack.empty()) {

View file

@ -48,26 +48,26 @@ public:
wr::WindowId GetId() const { return mId; }
void UpdateScrollPosition(const WrPipelineId& aPipelineId,
void UpdateScrollPosition(const wr::WrPipelineId& aPipelineId,
const layers::FrameMetrics::ViewID& aScrollId,
const WrPoint& aScrollPosition);
const wr::LayoutPoint& aScrollPosition);
void GenerateFrame();
void GenerateFrame(const nsTArray<WrOpacityProperty>& aOpacityArray,
const nsTArray<WrTransformProperty>& aTransformArray);
void GenerateFrame(const nsTArray<wr::WrOpacityProperty>& aOpacityArray,
const nsTArray<wr::WrTransformProperty>& aTransformArray);
void SetWindowParameters(LayoutDeviceIntSize size);
void SetRootDisplayList(gfx::Color aBgColor,
Epoch aEpoch,
LayerSize aViewportSize,
WrPipelineId pipeline_id,
const WrSize& content_size,
WrBuiltDisplayListDescriptor dl_descriptor,
wr::WrPipelineId pipeline_id,
const wr::LayoutSize& content_size,
wr::BuiltDisplayListDescriptor dl_descriptor,
uint8_t *dl_data,
size_t dl_size);
void ClearRootDisplayList(Epoch aEpoch,
WrPipelineId pipeline_id);
wr::WrPipelineId pipeline_id);
void SetRootPipeline(wr::PipelineId aPipeline);
@ -107,13 +107,13 @@ public:
void Pause();
bool Resume();
WrIdNamespace GetNamespace();
wr::WrIdNamespace GetNamespace();
GLint GetMaxTextureSize() const { return mMaxTextureSize; }
bool GetUseANGLE() const { return mUseANGLE; }
protected:
WebRenderAPI(WrAPI* aRawApi, wr::WindowId aId, GLint aMaxTextureSize, bool aUseANGLE)
: mWrApi(aRawApi)
WebRenderAPI(wr::RenderApi* aRawApi, wr::WindowId aId, GLint aMaxTextureSize, bool aUseANGLE)
: mRenderApi(aRawApi)
, mId(aId)
, mMaxTextureSize(aMaxTextureSize)
, mUseANGLE(aUseANGLE)
@ -123,7 +123,7 @@ protected:
// Should be used only for shutdown handling
void WaitFlushed();
WrAPI* mWrApi;
wr::RenderApi* mRenderApi;
wr::WindowId mId;
GLint mMaxTextureSize;
bool mUseANGLE;
@ -138,7 +138,7 @@ protected:
class DisplayListBuilder {
public:
explicit DisplayListBuilder(wr::PipelineId aId,
const WrSize& aContentSize);
const wr::LayoutSize& aContentSize);
DisplayListBuilder(DisplayListBuilder&&) = default;
~DisplayListBuilder();
@ -146,162 +146,162 @@ public:
void Begin(const LayerIntSize& aSize);
void End();
void Finalize(WrSize& aOutContentSize,
void Finalize(wr::LayoutSize& aOutContentSize,
wr::BuiltDisplayList& aOutDisplayList);
void PushStackingContext(const WrRect& aBounds, // TODO: We should work with strongly typed rects
void PushStackingContext(const wr::LayoutRect& aBounds, // TODO: We should work with strongly typed rects
const uint64_t& aAnimationId,
const float* aOpacity,
const gfx::Matrix4x4* aTransform,
WrTransformStyle aTransformStyle,
const WrMixBlendMode& aMixBlendMode,
const nsTArray<WrFilterOp>& aFilters);
wr::TransformStyle aTransformStyle,
const wr::MixBlendMode& aMixBlendMode,
const nsTArray<wr::WrFilterOp>& aFilters);
void PopStackingContext();
void PushClip(const WrRect& aClipRect,
const WrImageMask* aMask);
void PushClip(const wr::LayoutRect& aClipRect,
const wr::WrImageMask* aMask);
void PopClip();
void PushBuiltDisplayList(wr::BuiltDisplayList &dl);
void PushScrollLayer(const layers::FrameMetrics::ViewID& aScrollId,
const WrRect& aContentRect, // TODO: We should work with strongly typed rects
const WrRect& aClipRect);
const wr::LayoutRect& aContentRect, // TODO: We should work with strongly typed rects
const wr::LayoutRect& aClipRect);
void PopScrollLayer();
void PushClipAndScrollInfo(const layers::FrameMetrics::ViewID& aScrollId,
const WrClipId* aClipId);
const wr::WrClipId* aClipId);
void PopClipAndScrollInfo();
void PushRect(const WrRect& aBounds,
const WrRect& aClip,
const WrColor& aColor);
void PushRect(const wr::LayoutRect& aBounds,
const wr::LayoutRect& aClip,
const wr::ColorF& aColor);
void PushLinearGradient(const WrRect& aBounds,
const WrRect& aClip,
const WrPoint& aStartPoint,
const WrPoint& aEndPoint,
const nsTArray<WrGradientStop>& aStops,
wr::GradientExtendMode aExtendMode,
const WrSize aTileSize,
const WrSize aTileSpacing);
void PushLinearGradient(const wr::LayoutRect& aBounds,
const wr::LayoutRect& aClip,
const wr::LayoutPoint& aStartPoint,
const wr::LayoutPoint& aEndPoint,
const nsTArray<wr::GradientStop>& aStops,
wr::ExtendMode aExtendMode,
const wr::LayoutSize aTileSize,
const wr::LayoutSize aTileSpacing);
void PushRadialGradient(const WrRect& aBounds,
const WrRect& aClip,
const WrPoint& aCenter,
const WrSize& aRadius,
const nsTArray<WrGradientStop>& aStops,
wr::GradientExtendMode aExtendMode,
const WrSize aTileSize,
const WrSize aTileSpacing);
void PushRadialGradient(const wr::LayoutRect& aBounds,
const wr::LayoutRect& aClip,
const wr::LayoutPoint& aCenter,
const wr::LayoutSize& aRadius,
const nsTArray<wr::GradientStop>& aStops,
wr::ExtendMode aExtendMode,
const wr::LayoutSize aTileSize,
const wr::LayoutSize aTileSpacing);
void PushImage(const WrRect& aBounds,
const WrRect& aClip,
void PushImage(const wr::LayoutRect& aBounds,
const wr::LayoutRect& aClip,
wr::ImageRendering aFilter,
wr::ImageKey aImage);
void PushImage(const WrRect& aBounds,
const WrRect& aClip,
const WrSize& aStretchSize,
const WrSize& aTileSpacing,
void PushImage(const wr::LayoutRect& aBounds,
const wr::LayoutRect& aClip,
const wr::LayoutSize& aStretchSize,
const wr::LayoutSize& aTileSpacing,
wr::ImageRendering aFilter,
wr::ImageKey aImage);
void PushYCbCrPlanarImage(const WrRect& aBounds,
const WrRect& aClip,
void PushYCbCrPlanarImage(const wr::LayoutRect& aBounds,
const wr::LayoutRect& aClip,
wr::ImageKey aImageChannel0,
wr::ImageKey aImageChannel1,
wr::ImageKey aImageChannel2,
WrYuvColorSpace aColorSpace,
wr::WrYuvColorSpace aColorSpace,
wr::ImageRendering aFilter);
void PushNV12Image(const WrRect& aBounds,
const WrRect& aClip,
void PushNV12Image(const wr::LayoutRect& aBounds,
const wr::LayoutRect& aClip,
wr::ImageKey aImageChannel0,
wr::ImageKey aImageChannel1,
WrYuvColorSpace aColorSpace,
wr::WrYuvColorSpace aColorSpace,
wr::ImageRendering aFilter);
void PushYCbCrInterleavedImage(const WrRect& aBounds,
const WrRect& aClip,
void PushYCbCrInterleavedImage(const wr::LayoutRect& aBounds,
const wr::LayoutRect& aClip,
wr::ImageKey aImageChannel0,
WrYuvColorSpace aColorSpace,
wr::WrYuvColorSpace aColorSpace,
wr::ImageRendering aFilter);
void PushIFrame(const WrRect& aBounds,
void PushIFrame(const wr::LayoutRect& aBounds,
wr::PipelineId aPipeline);
// XXX WrBorderSides are passed with Range.
// It is just to bypass compiler bug. See Bug 1357734.
void PushBorder(const WrRect& aBounds,
const WrRect& aClip,
const WrBorderWidths& aWidths,
const Range<const WrBorderSide>& aSides,
const WrBorderRadius& aRadius);
void PushBorder(const wr::LayoutRect& aBounds,
const wr::LayoutRect& aClip,
const wr::BorderWidths& aWidths,
const Range<const wr::BorderSide>& aSides,
const wr::BorderRadius& aRadius);
void PushBorderImage(const WrRect& aBounds,
const WrRect& aClip,
const WrBorderWidths& aWidths,
void PushBorderImage(const wr::LayoutRect& aBounds,
const wr::LayoutRect& aClip,
const wr::BorderWidths& aWidths,
wr::ImageKey aImage,
const WrNinePatchDescriptor& aPatch,
const WrSideOffsets2Df32& aOutset,
const WrRepeatMode& aRepeatHorizontal,
const WrRepeatMode& aRepeatVertical);
const wr::NinePatchDescriptor& aPatch,
const wr::SideOffsets2D_f32& aOutset,
const wr::RepeatMode& aRepeatHorizontal,
const wr::RepeatMode& aRepeatVertical);
void PushBorderGradient(const WrRect& aBounds,
const WrRect& aClip,
const WrBorderWidths& aWidths,
const WrPoint& aStartPoint,
const WrPoint& aEndPoint,
const nsTArray<WrGradientStop>& aStops,
wr::GradientExtendMode aExtendMode,
const WrSideOffsets2Df32& aOutset);
void PushBorderGradient(const wr::LayoutRect& aBounds,
const wr::LayoutRect& aClip,
const wr::BorderWidths& aWidths,
const wr::LayoutPoint& aStartPoint,
const wr::LayoutPoint& aEndPoint,
const nsTArray<wr::GradientStop>& aStops,
wr::ExtendMode aExtendMode,
const wr::SideOffsets2D_f32& aOutset);
void PushBorderRadialGradient(const WrRect& aBounds,
const WrRect& aClip,
const WrBorderWidths& aWidths,
const WrPoint& aCenter,
const WrSize& aRadius,
const nsTArray<WrGradientStop>& aStops,
wr::GradientExtendMode aExtendMode,
const WrSideOffsets2Df32& aOutset);
void PushBorderRadialGradient(const wr::LayoutRect& aBounds,
const wr::LayoutRect& aClip,
const wr::BorderWidths& aWidths,
const wr::LayoutPoint& aCenter,
const wr::LayoutSize& aRadius,
const nsTArray<wr::GradientStop>& aStops,
wr::ExtendMode aExtendMode,
const wr::SideOffsets2D_f32& aOutset);
void PushText(const WrRect& aBounds,
const WrRect& aClip,
void PushText(const wr::LayoutRect& aBounds,
const wr::LayoutRect& aClip,
const gfx::Color& aColor,
wr::FontKey aFontKey,
Range<const WrGlyphInstance> aGlyphBuffer,
Range<const wr::GlyphInstance> aGlyphBuffer,
float aGlyphSize);
void PushBoxShadow(const WrRect& aRect,
const WrRect& aClip,
const WrRect& aBoxBounds,
const WrPoint& aOffset,
const WrColor& aColor,
void PushBoxShadow(const wr::LayoutRect& aRect,
const wr::LayoutRect& aClip,
const wr::LayoutRect& aBoxBounds,
const wr::LayoutVector2D& aOffset,
const wr::ColorF& aColor,
const float& aBlurRadius,
const float& aSpreadRadius,
const float& aBorderRadius,
const WrBoxShadowClipMode& aClipMode);
const wr::BoxShadowClipMode& aClipMode);
// Returns the clip id that was most recently pushed with PushClip and that
// has not yet been popped with PopClip. Return Nothing() if the clip stack
// is empty.
Maybe<WrClipId> TopmostClipId();
Maybe<wr::WrClipId> TopmostClipId();
// Returns the scroll id that was pushed just before the given scroll id. This
// function returns Nothing() if the given scrollid has not been encountered,
// or if it is the rootmost scroll id (and therefore has no ancestor).
Maybe<layers::FrameMetrics::ViewID> ParentScrollIdFor(layers::FrameMetrics::ViewID aScrollId);
// Try to avoid using this when possible.
WrState* Raw() { return mWrState; }
wr::WrState* Raw() { return mWrState; }
protected:
WrState* mWrState;
wr::WrState* mWrState;
// Track the stack of clip ids and scroll layer ids that have been pushed
// (by PushClip and PushScrollLayer, respectively) and are still active.
// This is helpful for knowing e.g. what the ancestor scroll id of a particular
// scroll id is, and doing other "queries" of current state.
std::vector<WrClipId> mClipIdStack;
std::vector<wr::WrClipId> mClipIdStack;
std::vector<layers::FrameMetrics::ViewID> mScrollIdStack;
// Track the parent scroll id of each scroll id that we encountered.
@ -310,8 +310,8 @@ protected:
friend class WebRenderAPI;
};
Maybe<WrImageFormat>
SurfaceFormatToWrImageFormat(gfx::SurfaceFormat aFormat);
Maybe<wr::ImageFormat>
SurfaceFormatToImageFormat(gfx::SurfaceFormat aFormat);
} // namespace wr
} // namespace mozilla

View file

@ -17,22 +17,17 @@
#include "RoundedRect.h"
#include "nsStyleConsts.h"
typedef mozilla::Maybe<WrImageMask> MaybeImageMask;
namespace mozilla {
namespace wr {
typedef WrGradientExtendMode GradientExtendMode;
typedef WrMixBlendMode MixBlendMode;
typedef WrImageRendering ImageRendering;
typedef WrImageFormat ImageFormat;
typedef WrWindowId WindowId;
typedef WrPipelineId PipelineId;
typedef WrImageKey ImageKey;
typedef WrFontKey FontKey;
typedef WrEpoch Epoch;
typedef WrExternalImageId ExternalImageId;
typedef wr::WrWindowId WindowId;
typedef wr::WrPipelineId PipelineId;
typedef wr::WrImageKey ImageKey;
typedef wr::WrFontKey FontKey;
typedef wr::WrEpoch Epoch;
typedef wr::WrExternalImageId ExternalImageId;
typedef mozilla::Maybe<mozilla::wr::WrImageMask> MaybeImageMask;
typedef Maybe<ExternalImageId> MaybeExternalImageId;
inline WindowId NewWindowId(uint64_t aId) {
@ -47,32 +42,32 @@ inline Epoch NewEpoch(uint32_t aEpoch) {
return e;
}
inline Maybe<WrImageFormat>
SurfaceFormatToWrImageFormat(gfx::SurfaceFormat aFormat) {
inline Maybe<wr::ImageFormat>
SurfaceFormatToImageFormat(gfx::SurfaceFormat aFormat) {
switch (aFormat) {
case gfx::SurfaceFormat::R8G8B8X8:
// TODO: use RGBA + opaque flag
return Some(WrImageFormat::BGRA8);
return Some(wr::ImageFormat::BGRA8);
case gfx::SurfaceFormat::B8G8R8X8:
// TODO: WebRender will have a BGRA + opaque flag for this but does not
// have it yet (cf. issue #732).
case gfx::SurfaceFormat::B8G8R8A8:
return Some(WrImageFormat::BGRA8);
return Some(wr::ImageFormat::BGRA8);
case gfx::SurfaceFormat::B8G8R8:
return Some(WrImageFormat::RGB8);
return Some(wr::ImageFormat::RGB8);
case gfx::SurfaceFormat::A8:
return Some(WrImageFormat::A8);
return Some(wr::ImageFormat::A8);
case gfx::SurfaceFormat::R8G8:
return Some(WrImageFormat::RG8);
return Some(wr::ImageFormat::RG8);
case gfx::SurfaceFormat::UNKNOWN:
return Some(WrImageFormat::Invalid);
return Some(wr::ImageFormat::Invalid);
default:
return Nothing();
}
}
inline gfx::SurfaceFormat
WrImageFormatToSurfaceFormat(ImageFormat aFormat) {
ImageFormatToSurfaceFormat(ImageFormat aFormat) {
switch (aFormat) {
case ImageFormat::BGRA8:
return gfx::SurfaceFormat::B8G8R8A8;
@ -85,10 +80,10 @@ WrImageFormatToSurfaceFormat(ImageFormat aFormat) {
}
}
struct ImageDescriptor: public WrImageDescriptor {
struct ImageDescriptor: public wr::WrImageDescriptor {
ImageDescriptor(const gfx::IntSize& aSize, gfx::SurfaceFormat aFormat)
{
format = SurfaceFormatToWrImageFormat(aFormat).value();
format = wr::SurfaceFormatToImageFormat(aFormat).value();
width = aSize.width;
height = aSize.height;
stride = 0;
@ -97,7 +92,7 @@ struct ImageDescriptor: public WrImageDescriptor {
ImageDescriptor(const gfx::IntSize& aSize, uint32_t aByteStride, gfx::SurfaceFormat aFormat)
{
format = SurfaceFormatToWrImageFormat(aFormat).value();
format = wr::SurfaceFormatToImageFormat(aFormat).value();
width = aSize.width;
height = aSize.height;
stride = aByteStride;
@ -155,7 +150,7 @@ inline ImageRendering ToImageRendering(gfx::SamplingFilter aFilter)
: ImageRendering::Auto;
}
static inline MixBlendMode ToWrMixBlendMode(gfx::CompositionOp compositionOp)
static inline MixBlendMode ToMixBlendMode(gfx::CompositionOp compositionOp)
{
switch (compositionOp)
{
@ -194,9 +189,9 @@ static inline MixBlendMode ToWrMixBlendMode(gfx::CompositionOp compositionOp)
}
}
static inline WrColor ToWrColor(const gfx::Color& color)
static inline wr::ColorF ToColorF(const gfx::Color& color)
{
WrColor c;
wr::ColorF c;
c.r = color.r;
c.g = color.g;
c.b = color.b;
@ -205,152 +200,172 @@ static inline WrColor ToWrColor(const gfx::Color& color)
}
template<class T>
static inline WrPoint ToWrPoint(const gfx::PointTyped<T>& point)
static inline wr::LayoutPoint ToLayoutPoint(const gfx::PointTyped<T>& point)
{
WrPoint p;
wr::LayoutPoint p;
p.x = point.x;
p.y = point.y;
return p;
}
template<class T>
static inline WrPoint ToWrPoint(const gfx::IntPointTyped<T>& point)
static inline wr::LayoutPoint ToLayoutPoint(const gfx::IntPointTyped<T>& point)
{
return ToWrPoint(IntPointToPoint(point));
return ToLayoutPoint(IntPointToPoint(point));
}
static inline WrPoint ToWrPoint(const gfx::Point& point)
template<class T>
static inline wr::LayoutVector2D ToLayoutVector2D(const gfx::PointTyped<T>& point)
{
WrPoint p;
wr::LayoutVector2D p;
p.x = point.x;
p.y = point.y;
return p;
}
template<class T>
static inline WrRect ToWrRect(const gfx::RectTyped<T>& rect)
static inline wr::LayoutVector2D ToLayoutVector2D(const gfx::IntPointTyped<T>& point)
{
WrRect r;
r.x = rect.x;
r.y = rect.y;
r.width = rect.width;
r.height = rect.height;
return ToLayoutVector2D(IntPointToPoint(point));
}
template<class T>
static inline wr::LayoutRect ToLayoutRect(const gfx::RectTyped<T>& rect)
{
wr::LayoutRect r;
r.origin.x = rect.x;
r.origin.y = rect.y;
r.size.width = rect.width;
r.size.height = rect.height;
return r;
}
static inline WrRect ToWrRect(const gfxRect rect)
static inline wr::LayoutRect ToLayoutRect(const gfxRect rect)
{
WrRect r;
r.x = rect.x;
r.y = rect.y;
r.width = rect.width;
r.height = rect.height;
wr::LayoutRect r;
r.origin.x = rect.x;
r.origin.y = rect.y;
r.size.width = rect.width;
r.size.height = rect.height;
return r;
}
template<class T>
static inline WrRect ToWrRect(const gfx::IntRectTyped<T>& rect)
static inline wr::LayoutRect ToLayoutRect(const gfx::IntRectTyped<T>& rect)
{
return ToWrRect(IntRectToRect(rect));
return ToLayoutRect(IntRectToRect(rect));
}
template<class T>
static inline WrSize ToWrSize(const gfx::SizeTyped<T>& size)
static inline wr::LayoutSize ToLayoutSize(const gfx::SizeTyped<T>& size)
{
WrSize ls;
wr::LayoutSize ls;
ls.width = size.width;
ls.height = size.height;
return ls;
}
static inline WrComplexClipRegion ToWrComplexClipRegion(const RoundedRect& rect)
static inline wr::WrComplexClipRegion ToWrComplexClipRegion(const RoundedRect& rect)
{
WrComplexClipRegion ret;
ret.rect = ToWrRect(rect.rect);
ret.radii.top_left = ToWrSize(rect.corners.radii[mozilla::eCornerTopLeft]);
ret.radii.top_right = ToWrSize(rect.corners.radii[mozilla::eCornerTopRight]);
ret.radii.bottom_left = ToWrSize(rect.corners.radii[mozilla::eCornerBottomLeft]);
ret.radii.bottom_right = ToWrSize(rect.corners.radii[mozilla::eCornerBottomRight]);
wr::WrComplexClipRegion ret;
ret.rect = ToLayoutRect(rect.rect);
ret.radii.top_left = ToLayoutSize(rect.corners.radii[mozilla::eCornerTopLeft]);
ret.radii.top_right = ToLayoutSize(rect.corners.radii[mozilla::eCornerTopRight]);
ret.radii.bottom_left = ToLayoutSize(rect.corners.radii[mozilla::eCornerBottomLeft]);
ret.radii.bottom_right = ToLayoutSize(rect.corners.radii[mozilla::eCornerBottomRight]);
return ret;
}
template<class T>
static inline WrSize ToWrSize(const gfx::IntSizeTyped<T>& size)
static inline wr::LayoutSize ToLayoutSize(const gfx::IntSizeTyped<T>& size)
{
return ToWrSize(IntSizeToSize(size));
return ToLayoutSize(IntSizeToSize(size));
}
template<class S, class T>
static inline WrMatrix ToWrMatrix(const gfx::Matrix4x4Typed<S, T>& m)
static inline wr::LayoutTransform ToLayoutTransform(const gfx::Matrix4x4Typed<S, T>& m)
{
WrMatrix transform;
static_assert(sizeof(m.components) == sizeof(transform.values),
"Matrix components size mismatch!");
memcpy(transform.values, m.components, sizeof(transform.values));
wr::LayoutTransform transform;
transform.m11 = m._11;
transform.m12 = m._12;
transform.m13 = m._13;
transform.m14 = m._14;
transform.m21 = m._21;
transform.m22 = m._22;
transform.m23 = m._23;
transform.m24 = m._24;
transform.m31 = m._31;
transform.m32 = m._32;
transform.m33 = m._33;
transform.m34 = m._34;
transform.m41 = m._41;
transform.m42 = m._42;
transform.m43 = m._43;
transform.m44 = m._44;
return transform;
}
static inline WrBorderStyle ToWrBorderStyle(const uint8_t& style)
static inline wr::BorderStyle ToBorderStyle(const uint8_t& style)
{
switch (style) {
case NS_STYLE_BORDER_STYLE_NONE:
return WrBorderStyle::None;
return wr::BorderStyle::None;
case NS_STYLE_BORDER_STYLE_SOLID:
return WrBorderStyle::Solid;
return wr::BorderStyle::Solid;
case NS_STYLE_BORDER_STYLE_DOUBLE:
return WrBorderStyle::Double;
return wr::BorderStyle::Double;
case NS_STYLE_BORDER_STYLE_DOTTED:
return WrBorderStyle::Dotted;
return wr::BorderStyle::Dotted;
case NS_STYLE_BORDER_STYLE_DASHED:
return WrBorderStyle::Dashed;
return wr::BorderStyle::Dashed;
case NS_STYLE_BORDER_STYLE_HIDDEN:
return WrBorderStyle::Hidden;
return wr::BorderStyle::Hidden;
case NS_STYLE_BORDER_STYLE_GROOVE:
return WrBorderStyle::Groove;
return wr::BorderStyle::Groove;
case NS_STYLE_BORDER_STYLE_RIDGE:
return WrBorderStyle::Ridge;
return wr::BorderStyle::Ridge;
case NS_STYLE_BORDER_STYLE_INSET:
return WrBorderStyle::Inset;
return wr::BorderStyle::Inset;
case NS_STYLE_BORDER_STYLE_OUTSET:
return WrBorderStyle::Outset;
return wr::BorderStyle::Outset;
default:
MOZ_ASSERT(false);
}
return WrBorderStyle::None;
return wr::BorderStyle::None;
}
static inline WrBorderSide ToWrBorderSide(const gfx::Color& color, const uint8_t& style)
static inline wr::BorderSide ToBorderSide(const gfx::Color& color, const uint8_t& style)
{
WrBorderSide bs;
bs.color = ToWrColor(color);
bs.style = ToWrBorderStyle(style);
wr::BorderSide bs;
bs.color = ToColorF(color);
bs.style = ToBorderStyle(style);
return bs;
}
static inline WrBorderRadius ToWrUniformBorderRadius(const LayerSize& aSize)
static inline wr::BorderRadius ToUniformBorderRadius(const LayerSize& aSize)
{
WrBorderRadius br;
br.top_left = ToWrSize(aSize);
br.top_right = ToWrSize(aSize);
br.bottom_left = ToWrSize(aSize);
br.bottom_right = ToWrSize(aSize);
wr::BorderRadius br;
br.top_left = ToLayoutSize(aSize);
br.top_right = ToLayoutSize(aSize);
br.bottom_left = ToLayoutSize(aSize);
br.bottom_right = ToLayoutSize(aSize);
return br;
}
static inline WrBorderRadius ToWrBorderRadius(const LayerSize& topLeft, const LayerSize& topRight,
static inline wr::BorderRadius ToBorderRadius(const LayerSize& topLeft, const LayerSize& topRight,
const LayerSize& bottomLeft, const LayerSize& bottomRight)
{
WrBorderRadius br;
br.top_left = ToWrSize(topLeft);
br.top_right = ToWrSize(topRight);
br.bottom_left = ToWrSize(bottomLeft);
br.bottom_right = ToWrSize(bottomRight);
wr::BorderRadius br;
br.top_left = ToLayoutSize(topLeft);
br.top_right = ToLayoutSize(topRight);
br.bottom_left = ToLayoutSize(bottomLeft);
br.bottom_right = ToLayoutSize(bottomRight);
return br;
}
static inline WrBorderWidths ToWrBorderWidths(float top, float right, float bottom, float left)
static inline wr::BorderWidths ToBorderWidths(float top, float right, float bottom, float left)
{
WrBorderWidths bw;
wr::BorderWidths bw;
bw.top = top;
bw.right = right;
bw.bottom = bottom;
@ -358,19 +373,19 @@ static inline WrBorderWidths ToWrBorderWidths(float top, float right, float bott
return bw;
}
static inline WrNinePatchDescriptor ToWrNinePatchDescriptor(uint32_t width, uint32_t height,
const WrSideOffsets2Du32& slice)
static inline wr::NinePatchDescriptor ToNinePatchDescriptor(uint32_t width, uint32_t height,
const wr::SideOffsets2D_u32& slice)
{
WrNinePatchDescriptor patch;
NinePatchDescriptor patch;
patch.width = width;
patch.height = height;
patch.slice = slice;
return patch;
}
static inline WrSideOffsets2Du32 ToWrSideOffsets2Du32(uint32_t top, uint32_t right, uint32_t bottom, uint32_t left)
static inline wr::SideOffsets2D_u32 ToSideOffsets2D_u32(uint32_t top, uint32_t right, uint32_t bottom, uint32_t left)
{
WrSideOffsets2Du32 offset;
SideOffsets2D_u32 offset;
offset.top = top;
offset.right = right;
offset.bottom = bottom;
@ -378,9 +393,9 @@ static inline WrSideOffsets2Du32 ToWrSideOffsets2Du32(uint32_t top, uint32_t rig
return offset;
}
static inline WrSideOffsets2Df32 ToWrSideOffsets2Df32(float top, float right, float bottom, float left)
static inline wr::SideOffsets2D_f32 ToSideOffsets2D_f32(float top, float right, float bottom, float left)
{
WrSideOffsets2Df32 offset;
SideOffsets2D_f32 offset;
offset.top = top;
offset.right = right;
offset.bottom = bottom;
@ -388,56 +403,56 @@ static inline WrSideOffsets2Df32 ToWrSideOffsets2Df32(float top, float right, fl
return offset;
}
static inline WrRepeatMode ToWrRepeatMode(uint8_t repeatMode)
static inline wr::RepeatMode ToRepeatMode(uint8_t repeatMode)
{
switch (repeatMode) {
case NS_STYLE_BORDER_IMAGE_REPEAT_STRETCH:
return WrRepeatMode::Stretch;
return wr::RepeatMode::Stretch;
case NS_STYLE_BORDER_IMAGE_REPEAT_REPEAT:
return WrRepeatMode::Repeat;
return wr::RepeatMode::Repeat;
case NS_STYLE_BORDER_IMAGE_REPEAT_ROUND:
return WrRepeatMode::Round;
return wr::RepeatMode::Round;
case NS_STYLE_BORDER_IMAGE_REPEAT_SPACE:
return WrRepeatMode::Space;
return wr::RepeatMode::Space;
default:
MOZ_ASSERT(false);
}
return WrRepeatMode::Stretch;
return wr::RepeatMode::Stretch;
}
template<class S, class T>
static inline WrTransformProperty ToWrTransformProperty(uint64_t id,
const gfx::Matrix4x4Typed<S, T>& transform)
static inline wr::WrTransformProperty ToWrTransformProperty(uint64_t id,
const gfx::Matrix4x4Typed<S, T>& transform)
{
WrTransformProperty prop;
wr::WrTransformProperty prop;
prop.id = id;
prop.transform = ToWrMatrix(transform);
prop.transform = ToLayoutTransform(transform);
return prop;
}
static inline WrOpacityProperty ToWrOpacityProperty(uint64_t id, const float opacity)
static inline wr::WrOpacityProperty ToWrOpacityProperty(uint64_t id, const float opacity)
{
WrOpacityProperty prop;
wr::WrOpacityProperty prop;
prop.id = id;
prop.opacity = opacity;
return prop;
}
static inline WrComplexClipRegion ToWrComplexClipRegion(const WrRect& rect,
const LayerSize& size)
static inline wr::WrComplexClipRegion ToWrComplexClipRegion(const wr::LayoutRect& rect,
const LayerSize& size)
{
WrComplexClipRegion complex_clip;
wr::WrComplexClipRegion complex_clip;
complex_clip.rect = rect;
complex_clip.radii = wr::ToWrUniformBorderRadius(size);
complex_clip.radii = wr::ToUniformBorderRadius(size);
return complex_clip;
}
template<class T>
static inline WrComplexClipRegion ToWrComplexClipRegion(const gfx::RectTyped<T>& rect,
const LayerSize& size)
static inline wr::WrComplexClipRegion ToWrComplexClipRegion(const gfx::RectTyped<T>& rect,
const LayerSize& size)
{
return ToWrComplexClipRegion(wr::ToWrRect(rect), size);
return ToWrComplexClipRegion(wr::ToLayoutRect(rect), size);
}
// Whenever possible, use wr::ExternalImageId instead of manipulating uint64_t.
@ -452,29 +467,29 @@ static inline ExternalImageId ToExternalImageId(uint64_t aID)
return Id;
}
static inline WrExternalImage RawDataToWrExternalImage(const uint8_t* aBuff,
size_t size)
static inline wr::WrExternalImage RawDataToWrExternalImage(const uint8_t* aBuff,
size_t size)
{
return WrExternalImage {
WrExternalImageType::RawData,
return wr::WrExternalImage {
wr::WrExternalImageType::RawData,
0, 0.0f, 0.0f, 0.0f, 0.0f,
aBuff, size
};
}
static inline WrExternalImage NativeTextureToWrExternalImage(uint32_t aHandle,
float u0, float v0,
float u1, float v1)
static inline wr::WrExternalImage NativeTextureToWrExternalImage(uint32_t aHandle,
float u0, float v0,
float u1, float v1)
{
return WrExternalImage {
WrExternalImageType::NativeTexture,
return wr::WrExternalImage {
wr::WrExternalImageType::NativeTexture,
aHandle, u0, v0, u1, v1,
nullptr, 0
};
}
struct VecU8 {
WrVecU8 inner;
wr::WrVecU8 inner;
VecU8() {
SetEmpty();
}
@ -491,9 +506,9 @@ struct VecU8 {
return *this;
}
WrVecU8
wr::WrVecU8
Extract() {
WrVecU8 ret = inner;
wr::WrVecU8 ret = inner;
SetEmpty();
return ret;
}
@ -577,49 +592,49 @@ struct ByteBuffer
bool mOwned;
};
inline WrByteSlice RangeToByteSlice(mozilla::Range<uint8_t> aRange) {
return WrByteSlice { aRange.begin().get(), aRange.length() };
inline wr::ByteSlice RangeToByteSlice(mozilla::Range<uint8_t> aRange) {
return wr::ByteSlice { aRange.begin().get(), aRange.length() };
}
inline mozilla::Range<const uint8_t> ByteSliceToRange(WrByteSlice aWrSlice) {
inline mozilla::Range<const uint8_t> ByteSliceToRange(wr::ByteSlice aWrSlice) {
return mozilla::Range<const uint8_t>(aWrSlice.buffer, aWrSlice.len);
}
inline mozilla::Range<uint8_t> MutByteSliceToRange(MutByteSlice aWrSlice) {
inline mozilla::Range<uint8_t> MutByteSliceToRange(wr::MutByteSlice aWrSlice) {
return mozilla::Range<uint8_t>(aWrSlice.buffer, aWrSlice.len);
}
struct BuiltDisplayList {
VecU8 dl;
WrBuiltDisplayListDescriptor dl_desc;
wr::VecU8 dl;
wr::BuiltDisplayListDescriptor dl_desc;
};
static inline WrFilterOpType ToWrFilterOpType(const layers::CSSFilterType type) {
static inline wr::WrFilterOpType ToWrFilterOpType(const layers::CSSFilterType type) {
switch (type) {
case layers::CSSFilterType::BLUR:
return WrFilterOpType::Blur;
return wr::WrFilterOpType::Blur;
case layers::CSSFilterType::BRIGHTNESS:
return WrFilterOpType::Brightness;
return wr::WrFilterOpType::Brightness;
case layers::CSSFilterType::CONTRAST:
return WrFilterOpType::Contrast;
return wr::WrFilterOpType::Contrast;
case layers::CSSFilterType::GRAYSCALE:
return WrFilterOpType::Grayscale;
return wr::WrFilterOpType::Grayscale;
case layers::CSSFilterType::HUE_ROTATE:
return WrFilterOpType::HueRotate;
return wr::WrFilterOpType::HueRotate;
case layers::CSSFilterType::INVERT:
return WrFilterOpType::Invert;
return wr::WrFilterOpType::Invert;
case layers::CSSFilterType::OPACITY:
return WrFilterOpType::Opacity;
return wr::WrFilterOpType::Opacity;
case layers::CSSFilterType::SATURATE:
return WrFilterOpType::Saturate;
return wr::WrFilterOpType::Saturate;
case layers::CSSFilterType::SEPIA:
return WrFilterOpType::Sepia;
return wr::WrFilterOpType::Sepia;
}
MOZ_ASSERT_UNREACHABLE("Tried to convert unknown filter type.");
return WrFilterOpType::Grayscale;
return wr::WrFilterOpType::Grayscale;
}
static inline WrFilterOp ToWrFilterOp(const layers::CSSFilter& filter) {
static inline wr::WrFilterOp ToWrFilterOp(const layers::CSSFilter& filter) {
return {
ToWrFilterOpType(filter.type),
filter.argument,

View file

@ -12,10 +12,12 @@ braces = "SameLine"
line_length = 100
tab_width = 2
language = "C++"
namespaces = ["mozilla", "wr"]
[parse]
parse_deps = true
include = ["webrender", "webrender_api"]
expand = ["euclid"]
[fn]
prefix = "WR_INLINE"
@ -25,6 +27,7 @@ rename_args = "GeckoCase"
[struct]
derive_eq = true
generic_template_specialization = false
[enum]
add_sentinel = true

File diff suppressed because it is too large Load diff

View file

@ -1,5 +1,5 @@
use webrender_api::*;
use bindings::{WrByteSlice, MutByteSlice, wr_moz2d_render_cb};
use bindings::{ByteSlice, MutByteSlice, wr_moz2d_render_cb};
use rayon::ThreadPool;
use std::collections::hash_map::{HashMap, Entry};
@ -58,7 +58,7 @@ impl BlobImageRenderer for Moz2dImageRenderer {
let result = unsafe {
if wr_moz2d_render_cb(
WrByteSlice::new(&commands[..]),
ByteSlice::new(&commands[..]),
descriptor.width,
descriptor.height,
descriptor.format,

View file

@ -48,26 +48,4 @@ void* get_proc_address_from_glcontext(void* glcontext_ptr, const char* procname)
#undef WR_FUNC
#undef WR_DESTRUCTOR_SAFE_FUNC
struct WrGlyphArray
{
mozilla::gfx::Color color;
nsTArray<WrGlyphInstance> glyphs;
bool operator==(const WrGlyphArray& other) const
{
if (!(color == other.color) ||
(glyphs.Length() != other.glyphs.Length())) {
return false;
}
for (size_t i = 0; i < glyphs.Length(); i++) {
if (!(glyphs[i] == other.glyphs[i])) {
return false;
}
}
return true;
}
};
#endif // WR_h

View file

@ -2,7 +2,7 @@
* 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/. */
/* Generated with cbindgen:0.1.13 */
/* Generated with cbindgen:0.1.18 */
/* DO NOT MODIFY THIS MANUALLY! This file was generated using cbindgen.
* To generate this file:
@ -16,7 +16,10 @@
extern "C" {
enum class WrBorderStyle : uint32_t {
namespace mozilla {
namespace wr {
enum class BorderStyle : uint32_t {
None = 0,
Solid = 1,
Double = 2,
@ -31,7 +34,7 @@ enum class WrBorderStyle : uint32_t {
Sentinel /* this must be last for serialization purposes. */
};
enum class WrBoxShadowClipMode : uint32_t {
enum class BoxShadowClipMode : uint32_t {
None = 0,
Outset = 1,
Inset = 2,
@ -39,6 +42,69 @@ enum class WrBoxShadowClipMode : uint32_t {
Sentinel /* this must be last for serialization purposes. */
};
enum class ExtendMode : uint32_t {
Clamp = 0,
Repeat = 1,
Sentinel /* this must be last for serialization purposes. */
};
enum class ImageFormat : uint32_t {
Invalid = 0,
A8 = 1,
RGB8 = 2,
BGRA8 = 3,
RGBAF32 = 4,
RG8 = 5,
Sentinel /* this must be last for serialization purposes. */
};
enum class ImageRendering : uint32_t {
Auto = 0,
CrispEdges = 1,
Pixelated = 2,
Sentinel /* this must be last for serialization purposes. */
};
enum class MixBlendMode : uint32_t {
Normal = 0,
Multiply = 1,
Screen = 2,
Overlay = 3,
Darken = 4,
Lighten = 5,
ColorDodge = 6,
ColorBurn = 7,
HardLight = 8,
SoftLight = 9,
Difference = 10,
Exclusion = 11,
Hue = 12,
Saturation = 13,
Color = 14,
Luminosity = 15,
Sentinel /* this must be last for serialization purposes. */
};
enum class RepeatMode : uint32_t {
Stretch = 0,
Repeat = 1,
Round = 2,
Space = 3,
Sentinel /* this must be last for serialization purposes. */
};
enum class TransformStyle : uint32_t {
Flat = 0,
Preserve3D = 1,
Sentinel /* this must be last for serialization purposes. */
};
enum class WrExternalImageBufferType : uint32_t {
Texture2DHandle = 0,
TextureRectHandle = 1,
@ -69,69 +135,6 @@ enum class WrFilterOpType : uint32_t {
Sentinel /* this must be last for serialization purposes. */
};
enum class WrGradientExtendMode : uint32_t {
Clamp = 0,
Repeat = 1,
Sentinel /* this must be last for serialization purposes. */
};
enum class WrImageFormat : uint32_t {
Invalid = 0,
A8 = 1,
RGB8 = 2,
BGRA8 = 3,
RGBAF32 = 4,
RG8 = 5,
Sentinel /* this must be last for serialization purposes. */
};
enum class WrImageRendering : uint32_t {
Auto = 0,
CrispEdges = 1,
Pixelated = 2,
Sentinel /* this must be last for serialization purposes. */
};
enum class WrMixBlendMode : uint32_t {
Normal = 0,
Multiply = 1,
Screen = 2,
Overlay = 3,
Darken = 4,
Lighten = 5,
ColorDodge = 6,
ColorBurn = 7,
HardLight = 8,
SoftLight = 9,
Difference = 10,
Exclusion = 11,
Hue = 12,
Saturation = 13,
Color = 14,
Luminosity = 15,
Sentinel /* this must be last for serialization purposes. */
};
enum class WrRepeatMode : uint32_t {
Stretch = 0,
Repeat = 1,
Round = 2,
Space = 3,
Sentinel /* this must be last for serialization purposes. */
};
enum class WrTransformStyle : uint32_t {
Flat = 0,
Preserve3D = 1,
Sentinel /* this must be last for serialization purposes. */
};
enum class WrYuvColorSpace : uint32_t {
Rec601 = 0,
Rec709 = 1,
@ -139,12 +142,14 @@ enum class WrYuvColorSpace : uint32_t {
Sentinel /* this must be last for serialization purposes. */
};
struct WrAPI;
struct LayerPixel;
struct RenderApi;
struct Renderer;
struct WrRenderedEpochs;
struct WrRenderer;
struct WrState;
struct WrThreadPool;
@ -160,7 +165,7 @@ struct WrImageKey {
};
struct WrImageDescriptor {
WrImageFormat format;
ImageFormat format;
uint32_t width;
uint32_t height;
uint32_t stride;
@ -175,11 +180,11 @@ struct WrImageDescriptor {
}
};
struct WrByteSlice {
struct ByteSlice {
const uint8_t *buffer;
size_t len;
bool operator==(const WrByteSlice& aOther) const {
bool operator==(const ByteSlice& aOther) const {
return buffer == aOther.buffer &&
len == aOther.len;
}
@ -227,21 +232,21 @@ struct WrPipelineId {
}
};
struct WrSize {
struct LayoutSize {
float width;
float height;
bool operator==(const WrSize& aOther) const {
bool operator==(const LayoutSize& aOther) const {
return width == aOther.width &&
height == aOther.height;
}
};
struct WrBuiltDisplayListDescriptor {
struct BuiltDisplayListDescriptor {
uint64_t builder_start_time;
uint64_t builder_finish_time;
bool operator==(const WrBuiltDisplayListDescriptor& aOther) const {
bool operator==(const BuiltDisplayListDescriptor& aOther) const {
return builder_start_time == aOther.builder_start_time &&
builder_finish_time == aOther.builder_finish_time;
}
@ -269,13 +274,47 @@ struct WrOpacityProperty {
}
};
struct WrMatrix {
float values[16];
struct LayoutTransform {
float m11;
float m12;
float m13;
float m14;
float m21;
float m22;
float m23;
float m24;
float m31;
float m32;
float m33;
float m34;
float m41;
float m42;
float m43;
float m44;
bool operator==(const LayoutTransform& aOther) const {
return m11 == aOther.m11 &&
m12 == aOther.m12 &&
m13 == aOther.m13 &&
m14 == aOther.m14 &&
m21 == aOther.m21 &&
m22 == aOther.m22 &&
m23 == aOther.m23 &&
m24 == aOther.m24 &&
m31 == aOther.m31 &&
m32 == aOther.m32 &&
m33 == aOther.m33 &&
m34 == aOther.m34 &&
m41 == aOther.m41 &&
m42 == aOther.m42 &&
m43 == aOther.m43 &&
m44 == aOther.m44;
}
};
struct WrTransformProperty {
uint64_t id;
WrMatrix transform;
LayoutTransform transform;
};
struct WrIdNamespace {
@ -292,13 +331,13 @@ struct WrIdNamespace {
}
};
struct WrColor {
struct ColorF {
float r;
float g;
float b;
float a;
bool operator==(const WrColor& aOther) const {
bool operator==(const ColorF& aOther) const {
return r == aOther.r &&
g == aOther.g &&
b == aOther.b &&
@ -306,27 +345,43 @@ struct WrColor {
}
};
struct WrRect {
struct TypedPoint2D_f32__LayerPixel {
float x;
float y;
bool operator==(const TypedPoint2D_f32__LayerPixel& aOther) const {
return x == aOther.x &&
y == aOther.y;
}
};
struct TypedSize2D_f32__LayerPixel {
float width;
float height;
bool operator==(const WrRect& aOther) const {
return x == aOther.x &&
y == aOther.y &&
width == aOther.width &&
bool operator==(const TypedSize2D_f32__LayerPixel& aOther) const {
return width == aOther.width &&
height == aOther.height;
}
};
struct WrBorderWidths {
struct LayoutRect {
TypedPoint2D_f32__LayerPixel origin;
TypedSize2D_f32__LayerPixel size;
bool operator==(const LayoutRect& aOther) const {
return origin == aOther.origin &&
size == aOther.size;
}
};
struct BorderWidths {
float left;
float top;
float right;
float bottom;
bool operator==(const WrBorderWidths& aOther) const {
bool operator==(const BorderWidths& aOther) const {
return left == aOther.left &&
top == aOther.top &&
right == aOther.right &&
@ -334,23 +389,23 @@ struct WrBorderWidths {
}
};
struct WrBorderSide {
WrColor color;
WrBorderStyle style;
struct BorderSide {
ColorF color;
BorderStyle style;
bool operator==(const WrBorderSide& aOther) const {
bool operator==(const BorderSide& aOther) const {
return color == aOther.color &&
style == aOther.style;
}
};
struct WrBorderRadius {
WrSize top_left;
WrSize top_right;
WrSize bottom_left;
WrSize bottom_right;
struct BorderRadius {
LayoutSize top_left;
LayoutSize top_right;
LayoutSize bottom_left;
LayoutSize bottom_right;
bool operator==(const WrBorderRadius& aOther) const {
bool operator==(const BorderRadius& aOther) const {
return top_left == aOther.top_left &&
top_right == aOther.top_right &&
bottom_left == aOther.bottom_left &&
@ -358,33 +413,33 @@ struct WrBorderRadius {
}
};
struct WrPoint {
struct LayoutPoint {
float x;
float y;
bool operator==(const WrPoint& aOther) const {
bool operator==(const LayoutPoint& aOther) const {
return x == aOther.x &&
y == aOther.y;
}
};
struct WrGradientStop {
struct GradientStop {
float offset;
WrColor color;
ColorF color;
bool operator==(const WrGradientStop& aOther) const {
bool operator==(const GradientStop& aOther) const {
return offset == aOther.offset &&
color == aOther.color;
}
};
struct WrSideOffsets2Df32 {
struct SideOffsets2D_f32 {
float top;
float right;
float bottom;
float left;
bool operator==(const WrSideOffsets2Df32& aOther) const {
bool operator==(const SideOffsets2D_f32& aOther) const {
return top == aOther.top &&
right == aOther.right &&
bottom == aOther.bottom &&
@ -392,13 +447,13 @@ struct WrSideOffsets2Df32 {
}
};
struct WrSideOffsets2Du32 {
struct SideOffsets2D_u32 {
uint32_t top;
uint32_t right;
uint32_t bottom;
uint32_t left;
bool operator==(const WrSideOffsets2Du32& aOther) const {
bool operator==(const SideOffsets2D_u32& aOther) const {
return top == aOther.top &&
right == aOther.right &&
bottom == aOther.bottom &&
@ -406,21 +461,31 @@ struct WrSideOffsets2Du32 {
}
};
struct WrNinePatchDescriptor {
struct NinePatchDescriptor {
uint32_t width;
uint32_t height;
WrSideOffsets2Du32 slice;
SideOffsets2D_u32 slice;
bool operator==(const WrNinePatchDescriptor& aOther) const {
bool operator==(const NinePatchDescriptor& aOther) const {
return width == aOther.width &&
height == aOther.height &&
slice == aOther.slice;
}
};
struct LayoutVector2D {
float x;
float y;
bool operator==(const LayoutVector2D& aOther) const {
return x == aOther.x &&
y == aOther.y;
}
};
struct WrComplexClipRegion {
WrRect rect;
WrBorderRadius radii;
LayoutRect rect;
BorderRadius radii;
bool operator==(const WrComplexClipRegion& aOther) const {
return rect == aOther.rect &&
@ -430,7 +495,7 @@ struct WrComplexClipRegion {
struct WrImageMask {
WrImageKey image;
WrRect rect;
LayoutRect rect;
bool repeat;
bool operator==(const WrImageMask& aOther) const {
@ -450,11 +515,11 @@ struct WrFilterOp {
}
};
struct WrGlyphInstance {
struct GlyphInstance {
uint32_t index;
WrPoint point;
LayoutPoint point;
bool operator==(const WrGlyphInstance& aOther) const {
bool operator==(const GlyphInstance& aOther) const {
return index == aOther.index &&
point == aOther.point;
}
@ -530,14 +595,14 @@ struct WrExternalImageHandler {
*/
WR_INLINE
void wr_api_add_blob_image(WrAPI *aApi,
void wr_api_add_blob_image(RenderApi *aApi,
WrImageKey aImageKey,
const WrImageDescriptor *aDescriptor,
WrByteSlice aBytes)
ByteSlice aBytes)
WR_FUNC;
WR_INLINE
void wr_api_add_external_image(WrAPI *aApi,
void wr_api_add_external_image(RenderApi *aApi,
WrImageKey aImageKey,
const WrImageDescriptor *aDescriptor,
WrExternalImageId aExternalImageId,
@ -546,21 +611,21 @@ void wr_api_add_external_image(WrAPI *aApi,
WR_FUNC;
WR_INLINE
void wr_api_add_external_image_buffer(WrAPI *aApi,
void wr_api_add_external_image_buffer(RenderApi *aApi,
WrImageKey aImageKey,
const WrImageDescriptor *aDescriptor,
WrExternalImageId aExternalImageId)
WR_FUNC;
WR_INLINE
void wr_api_add_image(WrAPI *aApi,
void wr_api_add_image(RenderApi *aApi,
WrImageKey aImageKey,
const WrImageDescriptor *aDescriptor,
WrByteSlice aBytes)
ByteSlice aBytes)
WR_FUNC;
WR_INLINE
void wr_api_add_raw_font(WrAPI *aApi,
void wr_api_add_raw_font(RenderApi *aApi,
WrFontKey aKey,
uint8_t *aFontBuffer,
size_t aBufferSize,
@ -568,38 +633,38 @@ void wr_api_add_raw_font(WrAPI *aApi,
WR_FUNC;
WR_INLINE
void wr_api_clear_root_display_list(WrAPI *aApi,
void wr_api_clear_root_display_list(RenderApi *aApi,
WrEpoch aEpoch,
WrPipelineId aPipelineId)
WR_FUNC;
WR_INLINE
void wr_api_delete(WrAPI *aApi)
void wr_api_delete(RenderApi *aApi)
WR_DESTRUCTOR_SAFE_FUNC;
WR_INLINE
void wr_api_delete_font(WrAPI *aApi,
void wr_api_delete_font(RenderApi *aApi,
WrFontKey aKey)
WR_FUNC;
WR_INLINE
void wr_api_delete_image(WrAPI *aApi,
void wr_api_delete_image(RenderApi *aApi,
WrImageKey aKey)
WR_FUNC;
WR_INLINE
void wr_api_finalize_builder(WrState *aState,
WrSize *aContentSize,
WrBuiltDisplayListDescriptor *aDlDescriptor,
LayoutSize *aContentSize,
BuiltDisplayListDescriptor *aDlDescriptor,
WrVecU8 *aDlData)
WR_FUNC;
WR_INLINE
void wr_api_generate_frame(WrAPI *aApi)
void wr_api_generate_frame(RenderApi *aApi)
WR_FUNC;
WR_INLINE
void wr_api_generate_frame_with_properties(WrAPI *aApi,
void wr_api_generate_frame_with_properties(RenderApi *aApi,
const WrOpacityProperty *aOpacityArray,
size_t aOpacityCount,
const WrTransformProperty *aTransformArray,
@ -607,43 +672,43 @@ void wr_api_generate_frame_with_properties(WrAPI *aApi,
WR_FUNC;
WR_INLINE
WrIdNamespace wr_api_get_namespace(WrAPI *aApi)
WrIdNamespace wr_api_get_namespace(RenderApi *aApi)
WR_FUNC;
WR_INLINE
void wr_api_send_external_event(WrAPI *aApi,
void wr_api_send_external_event(RenderApi *aApi,
size_t aEvt)
WR_DESTRUCTOR_SAFE_FUNC;
WR_INLINE
void wr_api_set_root_display_list(WrAPI *aApi,
WrColor aColor,
void wr_api_set_root_display_list(RenderApi *aApi,
ColorF aColor,
WrEpoch aEpoch,
float aViewportWidth,
float aViewportHeight,
WrPipelineId aPipelineId,
WrSize aContentSize,
WrBuiltDisplayListDescriptor aDlDescriptor,
LayoutSize aContentSize,
BuiltDisplayListDescriptor aDlDescriptor,
uint8_t *aDlData,
size_t aDlSize)
WR_FUNC;
WR_INLINE
void wr_api_set_root_pipeline(WrAPI *aApi,
void wr_api_set_root_pipeline(RenderApi *aApi,
WrPipelineId aPipelineId)
WR_FUNC;
WR_INLINE
void wr_api_set_window_parameters(WrAPI *aApi,
void wr_api_set_window_parameters(RenderApi *aApi,
int32_t aWidth,
int32_t aHeight)
WR_FUNC;
WR_INLINE
void wr_api_update_image(WrAPI *aApi,
void wr_api_update_image(RenderApi *aApi,
WrImageKey aKey,
const WrImageDescriptor *aDescriptor,
WrByteSlice aBytes)
ByteSlice aBytes)
WR_FUNC;
WR_INLINE
@ -674,76 +739,76 @@ WR_FUNC;
WR_INLINE
void wr_dp_push_border(WrState *aState,
WrRect aRect,
WrRect aClip,
WrBorderWidths aWidths,
WrBorderSide aTop,
WrBorderSide aRight,
WrBorderSide aBottom,
WrBorderSide aLeft,
WrBorderRadius aRadius)
LayoutRect aRect,
LayoutRect aClip,
BorderWidths aWidths,
BorderSide aTop,
BorderSide aRight,
BorderSide aBottom,
BorderSide aLeft,
BorderRadius aRadius)
WR_FUNC;
WR_INLINE
void wr_dp_push_border_gradient(WrState *aState,
WrRect aRect,
WrRect aClip,
WrBorderWidths aWidths,
WrPoint aStartPoint,
WrPoint aEndPoint,
const WrGradientStop *aStops,
LayoutRect aRect,
LayoutRect aClip,
BorderWidths aWidths,
LayoutPoint aStartPoint,
LayoutPoint aEndPoint,
const GradientStop *aStops,
size_t aStopsCount,
WrGradientExtendMode aExtendMode,
WrSideOffsets2Df32 aOutset)
ExtendMode aExtendMode,
SideOffsets2D_f32 aOutset)
WR_FUNC;
WR_INLINE
void wr_dp_push_border_image(WrState *aState,
WrRect aRect,
WrRect aClip,
WrBorderWidths aWidths,
LayoutRect aRect,
LayoutRect aClip,
BorderWidths aWidths,
WrImageKey aImage,
WrNinePatchDescriptor aPatch,
WrSideOffsets2Df32 aOutset,
WrRepeatMode aRepeatHorizontal,
WrRepeatMode aRepeatVertical)
NinePatchDescriptor aPatch,
SideOffsets2D_f32 aOutset,
RepeatMode aRepeatHorizontal,
RepeatMode aRepeatVertical)
WR_FUNC;
WR_INLINE
void wr_dp_push_border_radial_gradient(WrState *aState,
WrRect aRect,
WrRect aClip,
WrBorderWidths aWidths,
WrPoint aCenter,
WrSize aRadius,
const WrGradientStop *aStops,
LayoutRect aRect,
LayoutRect aClip,
BorderWidths aWidths,
LayoutPoint aCenter,
LayoutSize aRadius,
const GradientStop *aStops,
size_t aStopsCount,
WrGradientExtendMode aExtendMode,
WrSideOffsets2Df32 aOutset)
ExtendMode aExtendMode,
SideOffsets2D_f32 aOutset)
WR_FUNC;
WR_INLINE
void wr_dp_push_box_shadow(WrState *aState,
WrRect aRect,
WrRect aClip,
WrRect aBoxBounds,
WrPoint aOffset,
WrColor aColor,
LayoutRect aRect,
LayoutRect aClip,
LayoutRect aBoxBounds,
LayoutVector2D aOffset,
ColorF aColor,
float aBlurRadius,
float aSpreadRadius,
float aBorderRadius,
WrBoxShadowClipMode aClipMode)
BoxShadowClipMode aClipMode)
WR_FUNC;
WR_INLINE
void wr_dp_push_built_display_list(WrState *aState,
WrBuiltDisplayListDescriptor aDlDescriptor,
BuiltDisplayListDescriptor aDlDescriptor,
WrVecU8 *aDlData)
WR_FUNC;
WR_INLINE
uint64_t wr_dp_push_clip(WrState *aState,
WrRect aRect,
LayoutRect aRect,
const WrComplexClipRegion *aComplex,
size_t aComplexCount,
const WrImageMask *aMask)
@ -757,111 +822,111 @@ WR_FUNC;
WR_INLINE
void wr_dp_push_iframe(WrState *aState,
WrRect aRect,
LayoutRect aRect,
WrPipelineId aPipelineId)
WR_FUNC;
WR_INLINE
void wr_dp_push_image(WrState *aState,
WrRect aBounds,
WrRect aClip,
WrSize aStretchSize,
WrSize aTileSpacing,
WrImageRendering aImageRendering,
LayoutRect aBounds,
LayoutRect aClip,
LayoutSize aStretchSize,
LayoutSize aTileSpacing,
ImageRendering aImageRendering,
WrImageKey aKey)
WR_FUNC;
WR_INLINE
void wr_dp_push_linear_gradient(WrState *aState,
WrRect aRect,
WrRect aClip,
WrPoint aStartPoint,
WrPoint aEndPoint,
const WrGradientStop *aStops,
LayoutRect aRect,
LayoutRect aClip,
LayoutPoint aStartPoint,
LayoutPoint aEndPoint,
const GradientStop *aStops,
size_t aStopsCount,
WrGradientExtendMode aExtendMode,
WrSize aTileSize,
WrSize aTileSpacing)
ExtendMode aExtendMode,
LayoutSize aTileSize,
LayoutSize aTileSpacing)
WR_FUNC;
WR_INLINE
void wr_dp_push_radial_gradient(WrState *aState,
WrRect aRect,
WrRect aClip,
WrPoint aCenter,
WrSize aRadius,
const WrGradientStop *aStops,
LayoutRect aRect,
LayoutRect aClip,
LayoutPoint aCenter,
LayoutSize aRadius,
const GradientStop *aStops,
size_t aStopsCount,
WrGradientExtendMode aExtendMode,
WrSize aTileSize,
WrSize aTileSpacing)
ExtendMode aExtendMode,
LayoutSize aTileSize,
LayoutSize aTileSpacing)
WR_FUNC;
WR_INLINE
void wr_dp_push_rect(WrState *aState,
WrRect aRect,
WrRect aClip,
WrColor aColor)
LayoutRect aRect,
LayoutRect aClip,
ColorF aColor)
WR_FUNC;
WR_INLINE
void wr_dp_push_scroll_layer(WrState *aState,
uint64_t aScrollId,
WrRect aContentRect,
WrRect aClipRect)
LayoutRect aContentRect,
LayoutRect aClipRect)
WR_FUNC;
WR_INLINE
void wr_dp_push_stacking_context(WrState *aState,
WrRect aBounds,
LayoutRect aBounds,
uint64_t aAnimationId,
const float *aOpacity,
const WrMatrix *aTransform,
WrTransformStyle aTransformStyle,
WrMixBlendMode aMixBlendMode,
const LayoutTransform *aTransform,
TransformStyle aTransformStyle,
MixBlendMode aMixBlendMode,
const WrFilterOp *aFilters,
size_t aFilterCount)
WR_FUNC;
WR_INLINE
void wr_dp_push_text(WrState *aState,
WrRect aBounds,
WrRect aClip,
WrColor aColor,
LayoutRect aBounds,
LayoutRect aClip,
ColorF aColor,
WrFontKey aFontKey,
const WrGlyphInstance *aGlyphs,
const GlyphInstance *aGlyphs,
uint32_t aGlyphCount,
float aGlyphSize)
WR_FUNC;
WR_INLINE
void wr_dp_push_yuv_NV12_image(WrState *aState,
WrRect aBounds,
WrRect aClip,
LayoutRect aBounds,
LayoutRect aClip,
WrImageKey aImageKey0,
WrImageKey aImageKey1,
WrYuvColorSpace aColorSpace,
WrImageRendering aImageRendering)
ImageRendering aImageRendering)
WR_FUNC;
WR_INLINE
void wr_dp_push_yuv_interleaved_image(WrState *aState,
WrRect aBounds,
WrRect aClip,
LayoutRect aBounds,
LayoutRect aClip,
WrImageKey aImageKey0,
WrYuvColorSpace aColorSpace,
WrImageRendering aImageRendering)
ImageRendering aImageRendering)
WR_FUNC;
WR_INLINE
void wr_dp_push_yuv_planar_image(WrState *aState,
WrRect aBounds,
WrRect aClip,
LayoutRect aBounds,
LayoutRect aClip,
WrImageKey aImageKey0,
WrImageKey aImageKey1,
WrImageKey aImageKey2,
WrYuvColorSpace aColorSpace,
WrImageRendering aImageRendering)
ImageRendering aImageRendering)
WR_FUNC;
WR_INLINE
@ -875,21 +940,21 @@ bool wr_rendered_epochs_next(WrRenderedEpochs *aPipelineEpochs,
WR_FUNC;
WR_INLINE
bool wr_renderer_current_epoch(WrRenderer *aRenderer,
bool wr_renderer_current_epoch(Renderer *aRenderer,
WrPipelineId aPipelineId,
WrEpoch *aOutEpoch)
WR_FUNC;
WR_INLINE
void wr_renderer_delete(WrRenderer *aRenderer)
void wr_renderer_delete(Renderer *aRenderer)
WR_DESTRUCTOR_SAFE_FUNC;
WR_INLINE
WrRenderedEpochs *wr_renderer_flush_rendered_epochs(WrRenderer *aRenderer)
WrRenderedEpochs *wr_renderer_flush_rendered_epochs(Renderer *aRenderer)
WR_FUNC;
WR_INLINE
void wr_renderer_readback(WrRenderer *aRenderer,
void wr_renderer_readback(Renderer *aRenderer,
uint32_t aWidth,
uint32_t aHeight,
uint8_t *aDstBuffer,
@ -897,30 +962,30 @@ void wr_renderer_readback(WrRenderer *aRenderer,
WR_FUNC;
WR_INLINE
void wr_renderer_render(WrRenderer *aRenderer,
void wr_renderer_render(Renderer *aRenderer,
uint32_t aWidth,
uint32_t aHeight)
WR_FUNC;
WR_INLINE
void wr_renderer_set_external_image_handler(WrRenderer *aRenderer,
void wr_renderer_set_external_image_handler(Renderer *aRenderer,
WrExternalImageHandler *aExternalImageHandler)
WR_FUNC;
WR_INLINE
void wr_renderer_set_profiler_enabled(WrRenderer *aRenderer,
void wr_renderer_set_profiler_enabled(Renderer *aRenderer,
bool aEnabled)
WR_FUNC;
WR_INLINE
void wr_renderer_update(WrRenderer *aRenderer)
void wr_renderer_update(Renderer *aRenderer)
WR_FUNC;
WR_INLINE
void wr_scroll_layer_with_id(WrAPI *aApi,
void wr_scroll_layer_with_id(RenderApi *aApi,
WrPipelineId aPipelineId,
uint64_t aScrollId,
WrPoint aNewScrollOrigin)
LayoutPoint aNewScrollOrigin)
WR_FUNC;
WR_INLINE
@ -929,7 +994,7 @@ WR_DESTRUCTOR_SAFE_FUNC;
WR_INLINE
WrState *wr_state_new(WrPipelineId aPipelineId,
WrSize aContentSize)
LayoutSize aContentSize)
WR_FUNC;
WR_INLINE
@ -951,10 +1016,13 @@ bool wr_window_new(WrWindowId aWindowId,
void *aGlContext,
WrThreadPool *aThreadPool,
bool aEnableProfiler,
WrAPI **aOutApi,
WrRenderer **aOutRenderer)
RenderApi **aOutApi,
Renderer **aOutRenderer)
WR_FUNC;
} // namespace wr
} // namespace mozilla
} // extern "C"
/* DO NOT MODIFY THIS MANUALLY! This file was generated using cbindgen.

View file

@ -13,6 +13,8 @@
#include "RasterImage.h"
#include "SurfaceCache.h"
#include "mozilla/SystemGroup.h"
namespace mozilla {
using gfx::IntRect;
@ -23,11 +25,47 @@ namespace image {
// Helpers for sending notifications to the image associated with a decoder.
///////////////////////////////////////////////////////////////////////////////
/* static */ void
void
IDecodingTask::EnsureHasEventTarget(NotNull<RasterImage*> aImage)
{
if (!mEventTarget) {
// We determine the event target as late as possible, at the first dispatch
// time, because the observers bound to an imgRequest will affect it.
// We cache it rather than query for the event target each time because the
// event target can change. We don't want to risk events being executed in
// a different order than they are dispatched, which can happen if we
// selected scheduler groups which have no ordering guarantees relative to
// each other (e.g. it moves from scheduler group A for doc group DA to
// scheduler group B for doc group DB due to changing observers -- if we
// dispatched the first event on A, and the second on B, we don't know which
// will execute first.)
RefPtr<ProgressTracker> tracker = aImage->GetProgressTracker();
if (tracker) {
mEventTarget = tracker->GetEventTarget();
} else {
mEventTarget = SystemGroup::EventTargetFor(TaskCategory::Other);
}
}
}
bool
IDecodingTask::IsOnEventTarget() const
{
// This is essentially equivalent to NS_IsOnMainThread() because all of the
// event targets are for the main thread (although perhaps with a different
// label / scheduler group). The observers in ProgressTracker may have
// different event targets from this, so this is just a best effort guess.
bool current = false;
mEventTarget->IsOnCurrentThread(&current);
return current;
}
void
IDecodingTask::NotifyProgress(NotNull<RasterImage*> aImage,
NotNull<Decoder*> aDecoder)
{
MOZ_ASSERT(aDecoder->HasProgress() && !aDecoder->IsMetadataDecode());
EnsureHasEventTarget(aImage);
// Capture the decoder's state. If we need to notify asynchronously, it's
// important that we don't wait until the lambda actually runs to capture the
@ -42,7 +80,7 @@ IDecodingTask::NotifyProgress(NotNull<RasterImage*> aImage,
SurfaceFlags surfaceFlags = aDecoder->GetSurfaceFlags();
// Synchronously notify if we can.
if (NS_IsMainThread() && !(decoderFlags & DecoderFlags::ASYNC_NOTIFY)) {
if (IsOnEventTarget() && !(decoderFlags & DecoderFlags::ASYNC_NOTIFY)) {
aImage->NotifyProgress(progress, invalidRect, frameCount,
decoderFlags, surfaceFlags);
return;
@ -50,20 +88,21 @@ IDecodingTask::NotifyProgress(NotNull<RasterImage*> aImage,
// We're forced to notify asynchronously.
NotNull<RefPtr<RasterImage>> image = aImage;
NS_DispatchToMainThread(NS_NewRunnableFunction(
"IDecodingTask::NotifyProgress",
[=]() -> void {
mEventTarget->Dispatch(NS_NewRunnableFunction(
"IDecodingTask::NotifyProgress",
[=]() -> void {
image->NotifyProgress(progress, invalidRect, frameCount,
decoderFlags, surfaceFlags);
}));
}), NS_DISPATCH_NORMAL);
}
/* static */ void
void
IDecodingTask::NotifyDecodeComplete(NotNull<RasterImage*> aImage,
NotNull<Decoder*> aDecoder)
{
MOZ_ASSERT(aDecoder->HasError() || !aDecoder->InFrame(),
"Decode complete in the middle of a frame?");
EnsureHasEventTarget(aImage);
// Capture the decoder's state.
DecoderFinalStatus finalStatus = aDecoder->FinalStatus();
@ -76,7 +115,7 @@ IDecodingTask::NotifyDecodeComplete(NotNull<RasterImage*> aImage,
SurfaceFlags surfaceFlags = aDecoder->GetSurfaceFlags();
// Synchronously notify if we can.
if (NS_IsMainThread() && !(decoderFlags & DecoderFlags::ASYNC_NOTIFY)) {
if (IsOnEventTarget() && !(decoderFlags & DecoderFlags::ASYNC_NOTIFY)) {
aImage->NotifyDecodeComplete(finalStatus, metadata, telemetry, progress,
invalidRect, frameCount, decoderFlags,
surfaceFlags);
@ -85,13 +124,13 @@ IDecodingTask::NotifyDecodeComplete(NotNull<RasterImage*> aImage,
// We're forced to notify asynchronously.
NotNull<RefPtr<RasterImage>> image = aImage;
NS_DispatchToMainThread(NS_NewRunnableFunction(
"IDecodingTask::NotifyDecodeComplete",
[=]() -> void {
mEventTarget->Dispatch(NS_NewRunnableFunction(
"IDecodingTask::NotifyDecodeComplete",
[=]() -> void {
image->NotifyDecodeComplete(finalStatus, metadata, telemetry, progress,
invalidRect, frameCount, decoderFlags,
surfaceFlags);
}));
}), NS_DISPATCH_NORMAL);
}

View file

@ -50,15 +50,22 @@ public:
void Resume() override;
protected:
virtual ~IDecodingTask() { }
/// Notify @aImage of @aDecoder's progress.
static void NotifyProgress(NotNull<RasterImage*> aImage,
NotNull<Decoder*> aDecoder);
void NotifyProgress(NotNull<RasterImage*> aImage,
NotNull<Decoder*> aDecoder);
/// Notify @aImage that @aDecoder has finished.
static void NotifyDecodeComplete(NotNull<RasterImage*> aImage,
NotNull<Decoder*> aDecoder);
void NotifyDecodeComplete(NotNull<RasterImage*> aImage,
NotNull<Decoder*> aDecoder);
virtual ~IDecodingTask() { }
private:
void EnsureHasEventTarget(NotNull<RasterImage*> aImage);
bool IsOnEventTarget() const;
nsCOMPtr<nsIEventTarget> mEventTarget;
};

Some files were not shown because too many files have changed in this diff Show more