Compare commits

...
93 Commits
Author SHA1 Message Date
Moonchild e1daeef183 [network] Hold mutex when accessing mSecurityInfo. 2021-01-27 10:52:32 +00:00
Moonchild f77c7a36b7 [DOM] Store weak pointer to next parents. 2021-01-26 23:16:22 +00:00
Moonchild 8fd57ace20 [DOM] Try to avoid slow shrinking GC during sync calls 2021-01-26 22:42:46 +00:00
Moonchild 2836e51466 [webaudio] Fix up ReverbInputBuffer's writeIndex. 2021-01-26 14:55:48 +00:00
Moonchild 3661ecee11 [WebRTC] Improve SDP parser error handling. 2021-01-26 13:59:19 +00:00
Moonchild 2f9e27a306 [js] Add AutoEnterOOMUnsafeRegion to JS_TransplantObject.
Transplanting objects is inherently oom-unsafe, so add
`AutoEnterOOMUnsafeRegion` to `JS_TransplantObject()` and annotate crashes
accordingly if they do happen.
2021-01-26 12:28:25 +00:00
Moonchild 3a8b4ad00a Fix rooting hazard in ImageBitmap::CreateInternal by avoiding movable data. 2021-01-26 11:49:35 +00:00
Moonchild c1dd23bd83 [layout, XUL] Avoid accessing invalidated frame. 2021-01-26 09:56:37 +00:00
Matt A. Tobin dd932e0011 Merge branch 'presentation-cleanup' 2021-01-25 18:26:58 -05:00
Moonchild 874330d453 Issue #1719 - Make <menuitem> pref-controlled and disable by default.
Resolves #1719
2021-01-25 23:18:58 +00:00
Matt A. Tobin 7702d1f3fa Issue #1390 - Clean up presentation api leftovers 2021-01-25 17:38:49 -05:00
Moonchild 1126548dee Issue #1319 - Resolve RELEASE_OR_BETA questions in all.js
- Enabled SVG transform-box property. I've tested this extensively including the
bug that prevented Mozilla from shipping until 55 which does not seem to apply
to us (most likely a stylo issue). Should be good to go.
- Moved the getRootNode pref to a better place (no change)
- Enabled inputmode property for forms. This is n/a for physical keyboards but
should improve the experience for soft keyboards that can pop up various forms
of input (e.g. numeric) depending on the mode indicated. According to BZ this is
feature complete at our level but was problematic for Android which we don't
have support for anyway.
- Restricted crashing on insecure input of text to debug only.
- Enabled shutting down the async OSFile worker if not used for 30 seconds to
be more conscientious about resource use.
- Enabled blocking of autoplay of media in the background by default, since it
is a saner default to have for the OOBE and is commonly a desired setting by
users (see forum).
- Disabled the storage manager API by default. This fine-grained control over
stored website data is already handled by various extensions and we don't have
the front-end support for it. Assuming this was necessary for Mozilla due to
limited access of WebExtensions to this kind of data.
2021-01-23 12:42:53 +00:00
Moonchild 411ccb0e49 Issue #1630 - Enable W3C pointer events by default.
Resolves #1630
2021-01-19 10:04:24 +00:00
Matt A. Tobin 75286e68d7 [Media] Enable AV1 by default if built 2021-01-18 14:56:32 -05:00
Moonchild 22e78108bd Issue #1715 - Handle errors when initializing print settings from the printer
fails due to a bad printer name or O.S. error.

Resolves #1715
2021-01-18 18:07:28 +00:00
Moonchild c77d06c0c4 Merge pull request 'Selectively enable and pref the DOM Web Animations API' (#1714) from 1689 into master
Reviewed-on: https://repo.palemoon.org/MoonchildProductions/UXP/pulls/1714
2021-01-18 09:41:05 +00:00
Moonchild 82fb08c650 Bump platform version for added features. 2021-01-16 14:29:01 +00:00
Moonchild b3d380b4ea Issue #1689 - Part 5: Enable DOM Animations API except the preffed-off parts.
This enables the DOM Animations API core functions with the exception of those
parts that are either unimplemented or not ready for use, which have been
preffed off in this issue's previous parts.

Also tag #1319 for enabling a previous RELEASE_OR_BETA shielded API.
2021-01-14 19:04:25 +00:00
Moonchild abc58d2ed0 Issue #1689 - Part 4: Add a preference for {Document,Element}.getAnimations()
This is probably the last thing we will ship (if ever) since it needs the most
spec and implementation work for arbitrary use that is pretty far into a corner.
2021-01-14 17:43:44 +00:00
Moonchild 931314ef61 Issue #1689 - Part 3: Add a preference for animation composite modes.
This feature should not be shipped until the various definitions of addition for
each additive property are properly specified and then implemented accordingly.

Unlike other patches in this series, compositing is not frequently used
internally so there is no need to enable this by default for chrome callers.
2021-01-14 17:41:30 +00:00
Moonchild 407c86641a Issue #1689 - Part 2: Add a preference for implicit keyframes
This preference controls whether authors are allowed to specify animations
without a 0% or 100% keyframe.

We intend to ship this but it isn't implemented yet (needs a follow-up) but this
preference acts as a safeguard in case we discover we need to disable it once
it's implemented.
2021-01-14 16:05:53 +00:00
Moonchild b0fe759f03 Issue #1689 - Part 1: Add pref for DOM Animation timelines API
Default false, no intent to ship for web content. Always enabled for Chrome.
2021-01-14 14:46:52 +00:00
Moonchild 5158142779 Merge pull request 'Add scrollbar-width CSS spec' (#1707) from 1705 into master
Reviewed-on: https://repo.palemoon.org/MoonchildProductions/UXP/pulls/1707
2021-01-13 00:25:23 +00:00
Moonchild 0939fde1a4 Issue #1705 - Part 9b: Revert overzealous changes on Mac (cocoa). 2021-01-12 13:07:40 +00:00
Matt A. Tobin 7023db88ca Issue #1624 - Fix slot access intrinsics for objects with > 16 reserved slots
Also flips ion inlining pref back on
2021-01-11 09:31:44 -05:00
Moonchild 59ef3f4eda Issue #1705 - Part 9: Implement scrollbar-width:thin on Mac (cocoa). 2021-01-09 23:21:36 +00:00
Moonchild ecc771848f Issue #1705 - Part 8: Implement scrollbar-width:thin on GTK. 2021-01-09 23:20:31 +00:00
Moonchild 382fe423e5 Issue #1705 - Part 7: Implement scrollbar-width:thin on Windows. 2021-01-09 23:19:35 +00:00
Moonchild c0db767c25 Issue #1710 - Check for triggering principal URI in FTP subresource check.
Resolves #1710
2021-01-09 19:19:39 +00:00
Moonchild 764e13c912 Issue #1705 - Part 6: Remove scrollbarbutton min-{width|height} rule from theme.
This would interfere with implementing thin scrollbars.

Almost all widgets provide a non-overridable size for scrollbar buttons, so it
makes no sense to specify min size for them. It is probably(?) a layout bug that
min size properties can override the value returned by GetMinimumWidgetSize
even if aIsOverridable is set to false, but removing this rule is simpler than
locating and fixing the issue in layout code ;)
2021-01-08 14:40:49 +00:00
Moonchild c05bca3168 Issue #1705 - Part 5: Implement scrollbar-width:none for all target platforms. 2021-01-08 14:15:50 +00:00
Moonchild c1825acab0 Merge pull request 'Add modern FreeBSD support' (#1706) from OlCe1/UXP:FreeBSD-support-reformatted into master
Reviewed-on: https://repo.palemoon.org/MoonchildProductions/UXP/pulls/1706
2021-01-07 21:26:47 +00:00
Olivier Certner 5d95844f49 Revert "Issue #1699 - Part 3a: mozjemalloc: Memory barriers on 'malloc_initialized'"
This reverts commit f76695c1ce.

SUSv4 specifies that 'pthread_create' acts as a (full) memory barrier, so
barriers here are not necessary.
2021-01-07 20:28:40 +01:00
Olivier Certner 3e2dcaf7f2 Issue #1699 - Part 3c: mozjemalloc: FreeBSD: Ensure early initialization
This guarantees that initialization is done in a single-thread context.
2021-01-07 17:49:14 +01:00
Olivier Certner 91f7c9d30e Issue #1699 - Part 3b: mozjemalloc: Bootstrap allocator, early diversion for FreeBSD
Coded a simple memory allocator meant to be used during jemalloc bootstrap
(malloc_init_hard()). Although protected by "#ifdef __FreeBSD__", it is not
FreeBSD-specific: Any POSIX platform could use it.

Hook it so that it is used in place of jemalloc's own routines while
malloc_init_hard() is executing or memory for mutexes is being
allocated. Currently, 'malloc', 'calloc', '*memalign' and 'free' are diverted
during init or lock initializations.

Details are quite complex, see the big comment block starting with "There are
several problematic interactions between FreeBSD's libthr and this jemalloc."
for more explanations.

Also replaced ad-hoc BSD code to determine the number of CPUs with 'sysconf',
which is POSIX-compliant (and supported on modern BSDs).
2021-01-07 17:49:14 +01:00
Olivier Certner f76695c1ce Issue #1699 - Part 3a: mozjemalloc: Memory barriers on 'malloc_initialized'
The barriers are here to make sure that setting 'malloc_initialized' at end of
init must be noticed later by any thread running on a different core. They are
in theory necessary in the absence of an explicit pthread lock.

What could happen is that the thread doing the initialization later spawns
other threads that could not have the updated 'malloc_initialized' value,
leading to a second initialization. This is dependent on whether OSes force a
full memory barrier before the new thread is run, which I don't know, and don't
want to bother.

This was done for FreeBSD only, for the sake of robustness. In theory, this
would be needed on Windows too.
2021-01-07 17:34:03 +01:00
Olivier Certner da217348d9 Issue #1699 - Part 2: libevent: Remove 'evutil_secure_rng_add_bytes'
In fact, this is a security threat.

This function calls 'arc4random_addrandom', which was removed from the
reference implementation 7 years go [1], on the ground that this was in fact an
internal interface which is almost impossible to use correctly. This update has
since then been propagated to other implementations (e.g., FreeBSD, IllumOS,
Android).

Do this for all platforms, since 'evutil_secure_rng_add_bytes' is not even used
in the current tree, and for the reason stated above, should never be.

Related bugs at Mozilla and libevent: Links [2] and [3] below.

[1] http://marc.info/?l=openbsd-cvs&m=138238762705209&w=2
[2] https://bugzilla.mozilla.org/show_bug.cgi?id=931354
[3] https://sourceforge.net/p/levent/bugs/320/
2021-01-07 17:02:06 +01:00
Olivier Certner 87aa6b2300 Issue #1699 - Part 1: python/psutil: Support recent FreeBSD versions
'sysctl' interface to currently opened connections changed in FreeBSD 12.

Drop support for FreeBSD < 9, these are very old and unsupported versions.
2021-01-07 17:02:05 +01:00
Moonchild 65da2431f9 Issue #1705 - Part 4: Add scrollbar-width CSS keyword to CSS parser.
This should be all parts needed to add a brand new enum keyword including
getting the computed style from it...
2021-01-06 23:57:26 +00:00
Moonchild 0e6a9cc60a Issue #1705 - Part 3: Rename ScrollbarStyles to ScrollStyles.
ScrollbarStyles contains values of overflow, (over)scroll-behavior, etc.
The only one which is marginally related to scroll _bars_ is overflow, which can
be used to hide scrollbar (by making an element not scrollable) or enforce the
scrollbar to display.

It makes more sense to be called ScrollStyles as it's mainly concerning behavior
of scrolling, not scrollbars. Also, with the addition of scrollbar width
properties, the current name can be confusing.
2021-01-06 16:31:36 +00:00
Moonchild 4681e04dc5 Issue #1705 - Part 2: Add a ShowScrollbar enum to be used in ScrollReflowInput.
Overflow properties have two purposes:
1. controlling whether the scrollbar should be shown;
2. controlling whether the content is scrollable.

However, with the scrollbar-width property being added, scrollability and
presence of a scrollbar are no longer tied together.
This patch makes a separation between the value of overflow and the presence of
a scrollbar by making it clear that for ScrollReflowInput, we only care about
whether scrollbar should be shown.
This should make it easier to write the logic involving presence of the
scrollbar based on webdev choice.
2021-01-06 12:48:38 +00:00
Moonchild e16ed489a4 Issue #1705 - Part 1: Rename nsChangeHint_CSSOverflowChange to *ScrollbarChange.
Prepare for scrollbar-width which should trigger the same kind of change.
2021-01-06 10:35:21 +00:00
Moonchild 5af0c434b9 Merge branch '61' 2021-01-04 11:29:47 +00:00
Matt A. Tobin 1a4abb5d97 Issue #61 - Add missing external symbols for gkmedias when WebRTC is built 2021-01-04 03:43:58 -05:00
Matt A. Tobin 3f1ed03579 Issue #61 - Add missing external symbol cubeb_set_log_callback to gkmedias symbols.def 2021-01-03 23:41:17 -05:00
Matt A. Tobin 46ca396f8c Issue #61 - Add configure option for non-windows platforms
Windows will ALWAYS have this enabled but we eventually want all target operating systems to use this as well but that will require more work
2021-01-03 23:40:35 -05:00
Moonchild 39cebe99e2 Issue #61 - Place Skia in libxul
Skia does some nasty things that break with DLL calls like having virtual dtors
without a body definition (and it's honestly surprising that it even builds to
begin with the way it's done, but apparently they use some linking symbol voodoo
to work around that in dependent classes).
Not wanting to have to pull Google code apart to try and fix that for something
we're only using for canvas anyway, it's better to just let Skia reside in
libxul instead.
2021-01-03 21:45:04 +00:00
Moonchild b713575ca4 Issue #61 - Add missing #endif in symbols file 2021-01-03 21:41:19 +00:00
Matt A. Tobin a625decfc9 [NSS hotpatch] Hard disable AVX2 in NSS Build System
This should be ported to the NSS repo
2021-01-03 03:11:22 -05:00
Moonchild 84fa3f9f72 Redundant code path cleanup (#1702)
Remove various obsolete configure options.
Remove Adjust SDK install tracking filth.
Remove redundant code paths in old-configure
This also optimizes linker use
Remove redundant conditional blocks.
Rewrite span.h without constexpr use.
2021-01-02 19:27:13 +00:00
Moonchild babeb5c556 Issue #61 - Reinstate buildability with shared gkmedias dll
This fully works for splitting gkmedias.dll back out from xul with one exception
which is Skia throwing undefined externals when linking gkmedias.
2021-01-02 13:35:39 +00:00
Moonchild 0bb464bfc1 Issue #1053 - Part 2b: Remove android from /layout reftests
Also cleans up some other obsolete checks and stylo reftest lists.
2020-12-31 22:46:09 +00:00
Moonchild e011a048e4 Issue #1053 - Part 3b: Remove AndroidSurfaceTexture and Android media decoder
interface.
2020-12-27 13:11:19 +00:00
Moonchild 8d4456c797 Issue #1053 - Part 3a: Remove Android conditionals from /gfx 2020-12-27 06:58:56 +00:00
Moonchild ae2a160348 Issue #1053 - Part 2a: Remove android from /layout (partial)
This removes android code from base, build, forms, generic, inspector, style,
printing, tools and xul.
2020-12-26 10:16:55 +00:00
Moonchild 9f004841a2 Issue #1053 - Part 1c: Remove references to mobile/android targets and paths 2020-12-25 23:29:47 +00:00
Moonchild 62568d94d5 Issue #1681 - Hard-code FLAC media type association for .flac
We don't support AAC outside of OMX at the moment, so oops.
2020-12-24 13:35:26 +00:00
Moonchild 837432de64 Revert "Issue #1681 - Hard-code FLAC and AAC media type associations for .flac and .aac"
This reverts commit a8e90975d0.
2020-12-24 13:34:22 +00:00
Moonchild a8e90975d0 Issue #1681 - Hard-code FLAC and AAC media type associations for .flac and .aac 2020-12-24 13:30:53 +00:00
Moonchild 6ae313b51c Clobber for NSS update. 2020-12-23 22:24:08 +00:00
Moonchild ae775e493b Issue #1693 - Additional configuration for NSS lib update.
The Seed and RC2 components are completely obsolete, so we shouldn't build them.
AVX2 for Chacha20-Poly1305 would fall outside of our platform sysreqs, and has a
build system issue with non-MSVC flags being passed (needs more research, also a
recent change around NSS 3.53 when the makefile destruction happened)
2020-12-23 19:45:11 +00:00
Moonchild 029bcfe189 Issue #1693 - Update NSS to 3.59.1.1
This updates to MoonchildProductions/NSS@bd49b2b88 in the repo created for our
consumption of the library.
2020-12-23 19:02:52 +00:00
Moonchild 149d2ffa77 Issue #1693 - Update NSPR to 4.29 2020-12-23 19:01:09 +00:00
Moonchild 25b6703e95 Issue #1701 - Implement Intl.PluralRules API 2020-12-22 20:32:56 +00:00
Moonchild 911cbcd1af Issue #1700 - Apply background color instead of inset shadow for findbar input.
This changes the toolkit theme for Linux and Windows (Mac already did this) to
style the input textbox on the findbar with -moz-appearance:none so as to give
us styling control (as opposed to using a native widget style) and apply a
neutral style to it.
Also ensures Mac remains readable in case of poorly contrasting text.
2020-12-21 16:24:37 +00:00
Moonchild 05569cb6d1 Revert "Issue #1686 - Align a keybinding definition with the others"
This reverts commit 85dc118aac.
2020-12-20 19:48:50 +00:00
Moonchild 8500ebf532 Merge pull request 'Reinstate the performance timing code removed in error' (#1698) from adesh/UXP:fix-performace-api into master
Reviewed-on: https://repo.palemoon.org/MoonchildProductions/UXP/pulls/1698
2020-12-16 15:36:19 +00:00
adesh 0187d3e4e7 Issue #1697 - Reinstate the performance timing code removed in error.
This was a fallout from pull request #929.
2020-12-16 06:31:31 -05:00
Moonchild 408477a87a Revert "Issue #1695 - Add clamping to websocket polling timeouts."
As of [da0c073a7] we no longer need this workaround because the issue is avoided
with proper sleep/wake logic restored.

This reverts commit 2fa993b563.
2020-12-16 06:42:42 +00:00
Moonchild da0c073a74 Issue #1695 - Restore Sleep/Wake timer that was erroneously removed.
This was fallout from PR #929 for Issue #21
2020-12-16 06:39:51 +00:00
Moonchild 78f114fc42 [toolkit] Handle corner case confusion of downloaded files without extension.
See code comment for details.
2020-12-15 11:33:29 +00:00
Moonchild ac4c22f096 Issue #1696 - Propagate flex sizes to the table wrapper
This avoids overlapping of table styled elements inside flexboxes as used on
some websites.

Resolves #1696
2020-12-15 10:30:06 +00:00
Moonchild 3c0236666e [network] Update port blacklist.
See BZ bugs 1674735, 1677047, 1677940 and 1676868 for details.
2020-12-15 09:04:21 +00:00
Moonchild 2fa993b563 Issue #1695 - Add clamping to websocket polling timeouts. 2020-12-12 12:41:26 +00:00
Moonchild 4281fcc163 Revert "Issue #1391 - Disable DOM Filesystem/dirpicker APIs by default."
This reverts commit 45a976a5f1.
2020-12-08 17:26:30 +00:00
Moonchild 6b45065f14 Issue #1695 - Fix socket timeout logic. 2020-12-08 17:19:01 +00:00
Moonchild 6cb00e2cfd Issue #1694 - Part 2: Use scriptabledateformat for Update History display. 2020-12-04 16:41:24 +00:00
Moonchild 16a1ff22a3 Issue #1694 - Part 1: Use scriptabledateformat for the Cookie Accept dialog. 2020-12-04 16:37:02 +00:00
Moonchild fd576c4270 Issue #1624 - flip the inlining pref.
The default is now set to the more stable but slower global setting.
2020-12-03 18:33:35 +00:00
Moonchild 7fda700f92 Nuke erroneously added vim line. 2020-12-03 17:52:32 +00:00
Moonchild 1a21b52692 Issue #1624 - Make ion inlining optimizations a pref.
This also adds it to JS_SetGlobalJitCompilerOption()
2020-12-03 13:56:36 +00:00
Moonchild 7f619fa9bf Merge branch 'nss-patch-work' 2020-12-01 22:47:40 +00:00
Moonchild b668164260 Issue #1624 - Globally disable inlining optimizations in the JS JIT compiler. 2020-12-01 22:46:55 +00:00
Moonchild 433ed209ba Revert "Issue #1624 - Exclude function scopes from Ion compilation."
This reverts commit bb31c1c65e.
2020-12-01 22:39:36 +00:00
Moonchild b1bbc9286d Merge pull request 'Fix macOS version detection above 10.15 and update blocklist support to 11.0' (#1692) from dbsoft/UXP:Big_Sur_Version into master
Reviewed-on: https://repo.palemoon.org/MoonchildProductions/UXP/pulls/1692
2020-12-01 22:27:41 +00:00
Brian Smith e43b01e58b Issue #1690 - Part 2: Update MacOS Blocklist support from 10.13 to 11.0.
Changes based on Mozilla bug 1678061.
2020-12-01 15:46:38 -06:00
Moonchild 1683d012e2 Clobber for NSS update. 2020-12-01 15:33:00 +00:00
Moonchild 958205f4da [NSS] Version and build bump 2020-12-01 14:20:15 +00:00
Moonchild cca3b9062d [NSS] Update root certificates. 2020-12-01 14:19:59 +00:00
Moonchild bb31c1c65e Issue #1624 - Exclude function scopes from Ion compilation.
This seems to work around the problem with the compiled code stack for in-line
declared JS module code. Not optimal, for sure, but better than having to kill
Ion compilation outright.
2020-11-30 16:53:49 +00:00
Moonchild 060e3eb0c8 Revert "Issue #1691 - Part 1: Provide a way of associating a private value with a script"
This reverts commit 15914ec578.
2020-11-28 10:18:10 +00:00
Moonchild 15914ec578 Issue #1691 - Part 1: Provide a way of associating a private value with a script
or module.

This is a prerequisite for dynamic import
2020-11-27 15:47:49 +00:00
Brian Smith b1ac886a98 Issue #1690 - Part 1: Fix MacOS version detection above 10.15.
Changes based on Mozilla bug 1616404 but supporting back to 10.7.
2020-11-23 08:18:34 -06:00
1396 changed files with 512189 additions and 50022 deletions

No files matched your search

-22
View File
@@ -187,28 +187,6 @@ devtools/client/framework/test/code_ugly*
devtools/server/tests/unit/babel_and_browserify_script_with_source_map.js
devtools/server/tests/unit/setBreakpoint*
# mobile/android/ exclusions
mobile/android/tests/
# Uses `#filter substitution`
mobile/android/b2gdroid/app/b2gdroid.js
mobile/android/app/mobile.js
mobile/android/chrome/content/healthreport-prefs.js
# Uses `#expand`
mobile/android/chrome/content/about.js
# Not much JS to lint and non-standard at that
mobile/android/installer/
mobile/android/locales/
# Non-standard `(catch ex if ...)`
mobile/android/chrome/content/browser.js
mobile/android/components/Snippets.js
# Bug 1178739: Ignore this file as a quick fix for "Illegal yield expression"
mobile/android/modules/HomeProvider.jsm
# services/ exclusions
# Uses `#filter substitution`
-3
View File
@@ -91,9 +91,6 @@ GPATH
# Git clone directory for updating web-platform-tests
testing/web-platform/sync/
# Android Gradle artifacts.
mobile/android/gradle/.gradle
# XCode project cruft
embedding/ios/GoannaEmbed/GoannaEmbed.xcodeproj/project.xcworkspace/xcuserdata
embedding/ios/GoannaEmbed/GoannaEmbed.xcodeproj/xcuserdata
+2 -1
View File
@@ -22,4 +22,5 @@
# changes to stick? As of bug 928195, this shouldn't be necessary! Please
# don't change CLOBBER for WebIDL changes any more.
Clobber for CSS flow-root implementation
Clobber for NSS update
+5 -26
View File
@@ -64,9 +64,7 @@ this.AccessFu = { // jshint ignore:line
if (this._enabled) {
this._disable();
}
if (Utils.MozBuildApp === 'mobile/android') {
Services.obs.removeObserver(this, 'Accessibility:Settings');
} else if (Utils.win.navigator.mozSettings) {
if (Utils.win.navigator.mozSettings) {
Utils.win.navigator.mozSettings.removeObserver(
SCREENREADER_SETTING, this.handleEvent);
}
@@ -585,11 +583,7 @@ var Output = {
get androidBridge() {
delete this.androidBridge;
if (Utils.MozBuildApp === 'mobile/android') {
this.androidBridge = Services.androidBridge;
} else {
this.androidBridge = null;
}
this.androidBridge = null;
return this.androidBridge;
},
@@ -815,12 +809,6 @@ var Input = {
target.blur();
}
}
if (Utils.MozBuildApp == 'mobile/android') {
// Return focus to native Android browser chrome.
Services.androidBridge.handleGeckoMessage(
{ type: 'ToggleChrome:Focus' });
}
break;
case aEvent.DOM_VK_RETURN:
if (this.editState.editing) {
@@ -837,18 +825,9 @@ var Input = {
},
moveToPoint: function moveToPoint(aRule, aX, aY) {
// XXX: Bug 1013408 - There is no alignment between the chrome window's
// viewport size and the content viewport size in Android. This makes
// sending mouse events beyond its bounds impossible.
if (Utils.MozBuildApp === 'mobile/android') {
let mm = Utils.getMessageManager(Utils.CurrentBrowser);
mm.sendAsyncMessage('AccessFu:MoveToPoint',
{rule: aRule, x: aX, y: aY, origin: 'top'});
} else {
let win = Utils.win;
Utils.winUtils.sendMouseEvent('mousemove',
aX - win.mozInnerScreenX, aY - win.mozInnerScreenY, 0, 0, 0);
}
let win = Utils.win;
Utils.winUtils.sendMouseEvent('mousemove',
aX - win.mozInnerScreenX, aY - win.mozInnerScreenY, 0, 0, 0);
},
moveCursor: function moveCursor(aAction, aRule, aInputType, aAdjustRange) {
+1 -3
View File
@@ -76,8 +76,6 @@ const EDGE = 0.1;
const TIMEOUT_MULTIPLIER = 1;
// A single pointer down/up sequence periodically precedes the tripple swipe
// gesture on Android. This delay acounts for that.
const IS_ANDROID = Utils.MozBuildApp === 'mobile/android' &&
Utils.AndroidSdkVersion >= 14;
/**
* A point object containing distance travelled data.
@@ -206,7 +204,7 @@ this.GestureTracker = { // jshint ignore:line
if (aDetail.type !== 'pointerdown') {
return;
}
let GestureConstructor = aGesture || (IS_ANDROID ? DoubleTap : Tap);
let GestureConstructor = aGesture || Tap;
this._create(GestureConstructor);
this._update(aDetail, aTimeStamp);
},
-1
View File
@@ -680,7 +680,6 @@ this.Presentation = { // jshint ignore:line
get presenters() {
delete this.presenters;
let presenterMap = {
'mobile/android': [VisualPresenter, AndroidPresenter],
'b2g': [VisualPresenter, B2GPresenter],
'browser': [VisualPresenter, B2GPresenter, AndroidPresenter]
};
+1 -3
View File
@@ -33,9 +33,7 @@ this.Utils = { // jshint ignore:line
_buildAppMap: {
'{3c2e2abc-06d4-11e1-ac3b-374f68613e61}': 'b2g',
'{d1bfe7d9-c01e-4237-998b-7b5f960a4314}': 'graphene',
'{ec8030f7-c20a-464f-9b0e-13a3a9e97384}': 'browser',
'{aa3c5121-dab2-40e2-81ca-7ea25febc110}': 'mobile/android',
'{a23983c0-fd0e-11dc-95ff-0800200c9a66}': 'mobile/xul'
'{ec8030f7-c20a-464f-9b0e-13a3a9e97384}': 'browser'
},
init: function Utils_init(aWindow) {
@@ -67,7 +67,7 @@
* Change scrollbar styles from hidden to auto. That makes us to create an
* accessible for scroll area.
*/
function changeScrollbarStyles(aContainerID, aScrollAreaID)
function changeScrollStyles(aContainerID, aScrollAreaID)
{
this.container = getAccessible(aContainerID);
this.scrollAreaNode = getNode(aScrollAreaID);
@@ -77,7 +77,7 @@
new invokerChecker(EVENT_REORDER, this.container)
];
this.invoke = function changeScrollbarStyles_invoke()
this.invoke = function changeScrollStyles_invoke()
{
var accTree =
{ SECTION: [] };
@@ -86,7 +86,7 @@
this.scrollAreaNode.style.overflow = "auto";
}
this.finalCheck = function changeScrollbarStyles_finalCheck()
this.finalCheck = function changeScrollStyles_finalCheck()
{
var accTree =
{ SECTION: [ // container
@@ -95,7 +95,7 @@
testAccessibleTree(this.container, accTree);
}
this.getID = function changeScrollbarStyles_getID()
this.getID = function changeScrollStyles_getID()
{
return "change scrollbar styles " + prettyName(aScrollAreaID);
}
@@ -114,7 +114,7 @@
gQueue = new eventQueue();
gQueue.push(new changeScrollRange("container", "scrollarea"));
gQueue.push(new changeScrollbarStyles("container2", "scrollarea2"));
gQueue.push(new changeScrollStyles("container2", "scrollarea2"));
gQueue.invoke(); // Will call SimpleTest.finish();
}
-6
View File
@@ -210,12 +210,6 @@ fi
AC_DEFUN([MOZ_ANDROID_INSTALL_TRACKING],
[
if test -n "$MOZ_INSTALL_TRACKING"; then
AC_SUBST(MOZ_INSTALL_TRACKING)
MOZ_ANDROID_AAR(play-services-ads, $ANDROID_GOOGLE_PLAY_SERVICES_VERSION, google, com/google/android/gms)
MOZ_ANDROID_AAR(play-services-basement, $ANDROID_GOOGLE_PLAY_SERVICES_VERSION, google, com/google/android/gms)
fi
])
dnl Configure an Android SDK.
+5
View File
@@ -63,6 +63,11 @@ def GeckoBinary(linkage='dependent', msvcrt='dynamic', mozglue=None):
LDFLAGS += ['-rdynamic']
if CONFIG['MOZ_MEMORY']:
USE_LIBS += ['memory']
if CONFIG['OS_ARCH'] == 'FreeBSD':
# Make sure this function is linked in, so that it is
# executed at executable load (it has the 'constructor'
# flag).
LDFLAGS += ['-u', 'jemalloc_FreeBSD_init']
elif mozglue == 'library':
LIBRARY_DEFINES['MOZ_HAS_MOZGLUE'] = True
if not CONFIG['MOZ_GLUE_IN_PROGRAM']:
-4
View File
@@ -36,10 +36,6 @@ def keyfile(desc, help=None, callback=lambda x: x):
def simple_keyfile(desc):
value = keyfile(desc)
set_config('MOZ_%s_KEY' % desc.upper().replace(' ', '_'), value)
# Only really required for MOZ_ADJUST_SDK_KEY currently still used in
# old-configure.
add_old_configure_assignment('MOZ_%s_KEY' % desc.upper().replace(' ', '_'),
value)
@template
+1
View File
@@ -226,6 +226,7 @@ def old_configure_options(*options):
'--enable-safe-browsing',
'--enable-sandbox',
'--enable-security-sqlstore',
'--enable-shared-media',
'--enable-signmar',
'--enable-simulator',
'--enable-small-chunk-size',
+2
View File
@@ -79,6 +79,7 @@ included_inclnames_to_ignore = set([
'prtypes.h', # NSPR
'selfhosted.out.h', # generated in $OBJDIR
'shellmoduleloader.out.h', # generated in $OBJDIR
'unicode/plurrule.h', # ICU
'unicode/timezone.h', # ICU
'unicode/ucal.h', # ICU
'unicode/uclean.h', # ICU
@@ -90,6 +91,7 @@ included_inclnames_to_ignore = set([
'unicode/unorm.h', # ICU
'unicode/unum.h', # ICU
'unicode/unumsys.h', # ICU
'unicode/upluralrules.h', # ICU
'unicode/ustring.h', # ICU
'unicode/utypes.h', # ICU
'vtune/VTuneWrapper.h' # VTune
+7
View File
@@ -174,6 +174,13 @@ DEFAULT_GMAKE_FLAGS += NSS_SSL_ENABLE_ZLIB=
# Disable building of the test programs in security/nss/lib/zlib
DEFAULT_GMAKE_FLAGS += PROGRAMS=
# Disable AVX2 for poly1305
DEFAULT_GMAKE_FLAGS += NSS_DISABLE_AVX2=1
# Disable obsolete ciphers
DEFAULT_GMAKE_FLAGS += NSS_DISABLE_DEPRECATED_SEED=1
DEFAULT_GMAKE_FLAGS += NSS_DISABLE_DEPRECATED_RC2=1
# Disable creating .chk files. They will be generated from packager.mk
# When bug 681624 lands, we can replace CHECKLOC= with SKIP_SHLIBSIGN=1
DEFAULT_GMAKE_FLAGS += CHECKLOC=
+1 -1
View File
@@ -10,4 +10,4 @@
# hardcoded milestones in the tree from these two files.
#--------------------------------------------------------
4.7.0
4.8.0
+3
View File
@@ -28,6 +28,9 @@ if CONFIG['HOST_OS_ARCH'] != 'WINNT':
# while the program here is in C.
HostProgram('nsinstall_real', c_only=True)
if CONFIG['GKMEDIAS_SHARED_LIBRARY']:
DEFINES['GKMEDIAS_SHARED_LIBRARY'] = True
PYTHON_UNIT_TESTS += [
'tests/test_mozbuild_reading.py',
'tests/unit-expandlibs.py',
+16
View File
@@ -1287,6 +1287,22 @@ QtSparql/qsparqlresult.h
#if MOZ_TREE_PIXMAN!=1
pixman.h
#endif
#ifdef GKMEDIAS_SHARED_LIBRARY
vpx/vpx_codec.h
vpx/vpx_decoder.h
vpx/vpx_encoder.h
vpx/vp8cx.h
vpx/vp8dx.h
vpx_mem/vpx_mem.h
vorbis/codec.h
theora/theoradec.h
tremor/ivorbiscodec.h
speex/speex_resampler.h
ogg/ogg.h
ogg/os_types.h
nestegg/nestegg.h
cubeb/cubeb.h
#endif
gst/gst.h
gst/app/gstappsink.h
gst/app/gstappsrc.h
+1 -1
View File
@@ -94,7 +94,7 @@ exports.menuitems = [
},
key: {
id: "browserToolbox",
modifiers: isMac ? "accel,alt" : "accel,shift",
modifiers: "accel,alt,shift",
keytext: true
}
},
@@ -3038,6 +3038,7 @@ exports.CSS_PROPERTIES = {
"scroll-snap-points-y",
"scroll-snap-type-x",
"scroll-snap-type-y",
"scrollbar-width",
"shape-outside",
"shape-rendering",
"-moz-stack-sizing",
+3 -2
View File
@@ -10,6 +10,7 @@
#include "mozilla/dom/AnimationEffectTiming.h"
#include "mozilla/dom/KeyframeEffectBinding.h"
#include "mozilla/KeyframeUtils.h"
#include "mozilla/Preferences.h"
#include "nsContentUtils.h"
#include "nsDOMMutationObserver.h" // For nsAutoAnimationMutationBatch
#include "nsIScriptError.h"
@@ -135,9 +136,9 @@ void
KeyframeEffect::SetIterationComposite(
const IterationCompositeOperation& aIterationComposite)
{
// Ignore iterationComposite if the Web Animations API is not enabled,
// Ignore iterationComposite if the API is not enabled,
// then the default value 'Replace' will be used.
if (!AnimationUtils::IsCoreAPIEnabledForCaller()) {
if (!Preferences::GetBool("dom.animations-api.compositing.enabled")) {
return;
}
+1 -1
View File
@@ -1089,7 +1089,7 @@ KeyframeEffectReadOnly::CanThrottleTransformChanges(nsIFrame& aFrame) const
return true;
}
ScrollbarStyles ss = scrollable->GetScrollbarStyles();
ScrollStyles ss = scrollable->GetScrollStyles();
if (ss.mVertical == NS_STYLE_OVERFLOW_HIDDEN &&
ss.mHorizontal == NS_STYLE_OVERFLOW_HIDDEN &&
scrollable->GetLogicalScrollPosition() == nsPoint(0, 0)) {
+20 -10
View File
@@ -7,6 +7,7 @@
#include "mozilla/AnimationUtils.h"
#include "mozilla/ErrorResult.h"
#include "mozilla/Move.h"
#include "mozilla/Preferences.h"
#include "mozilla/RangedArray.h"
#include "mozilla/ServoBindings.h"
#include "mozilla/StyleAnimationValue.h"
@@ -21,6 +22,7 @@
#include "nsCSSPropertyIDSet.h"
#include "nsCSSProps.h"
#include "nsCSSPseudoElements.h" // For CSSPseudoElementType
#include "nsDocument.h"
#include "nsTArray.h"
#include <algorithm> // For std::stable_sort
@@ -400,7 +402,7 @@ GetKeyframeListFromPropertyIndexedKeyframe(JSContext* aCx,
ErrorResult& aRv);
static bool
RequiresAdditiveAnimation(const nsTArray<Keyframe>& aKeyframes,
HasImplicitKeyframeValues(const nsTArray<Keyframe>& aKeyframes,
nsIDocument* aDocument);
static void
@@ -467,11 +469,13 @@ KeyframeUtils::GetKeyframesFromObject(JSContext* aCx,
// says that if you don't have a keyframe at offset 0 or 1, then you should
// synthesize one using an additive zero value when you go to compose style.
// Until we implement additive animations we just throw if we encounter any
// set of keyframes that would put us in that situation.
// set of keyframes that would put us in that situation and keyframes aren't
// explicitly force-enabled.
if (RequiresAdditiveAnimation(keyframes, aDocument)) {
aRv.Throw(NS_ERROR_DOM_ANIM_MISSING_PROPS_ERR);
if (!nsDocument::AreWebAnimationsImplicitKeyframesEnabled(aCx, nullptr) &&
HasImplicitKeyframeValues(keyframes, aDocument)) {
keyframes.Clear();
aRv.Throw(NS_ERROR_DOM_ANIM_MISSING_PROPS_ERR);
}
return keyframes;
@@ -1330,10 +1334,16 @@ GetKeyframeListFromPropertyIndexedKeyframe(JSContext* aCx,
// No animation values for this property.
continue;
}
if (count == 1) {
// We don't support additive values and so can't support an
// animation that goes from the underlying value to this
// specified value. Throw an exception until we do support this.
if (!Preferences::GetBool("dom.animations-api.implicit-keyframes.enabled") &&
count == 1) {
// We don't support implicit keyframes by preference.
aRv.Throw(NS_ERROR_DOM_ANIM_MISSING_PROPS_ERR);
return;
} else if (count == 1) {
// Implicit keyframes isn't implemented yet and so we can't
// support an animation that goes from the underlying value
// to this specified value.
// Throw an exception until we do support this.
aRv.Throw(NS_ERROR_DOM_ANIM_MISSING_PROPS_ERR);
return;
}
@@ -1374,7 +1384,7 @@ GetKeyframeListFromPropertyIndexedKeyframe(JSContext* aCx,
* try to detect where we have an invalid value at 0%/100%.
*/
static bool
RequiresAdditiveAnimation(const nsTArray<Keyframe>& aKeyframes,
HasImplicitKeyframeValues(const nsTArray<Keyframe>& aKeyframes,
nsIDocument* aDocument)
{
// We are looking to see if that every property referenced in |aKeyframes|
@@ -1385,7 +1395,7 @@ RequiresAdditiveAnimation(const nsTArray<Keyframe>& aKeyframes,
// a document which we might not always have at the point where we want to
// perform this check.
//
// This is only a temporary measure until we implement additive animation.
// This is only a temporary measure until we implement implicit keyframes.
// So as long as this check catches most cases, and we don't do anything
// horrible in one of the cases we can't detect, it should be sufficient.
@@ -1,13 +1,13 @@
pref(dom.animations-api.core.enabled,true) load 1239889-1.html
pref(dom.animations-api.core.enabled,true) load 1244595-1.html
pref(dom.animations-api.core.enabled,true) load 1216842-1.html
pref(dom.animations-api.core.enabled,true) load 1216842-2.html
pref(dom.animations-api.core.enabled,true) load 1216842-3.html
pref(dom.animations-api.core.enabled,true) load 1216842-4.html
pref(dom.animations-api.core.enabled,true) load 1216842-5.html
pref(dom.animations-api.core.enabled,true) load 1216842-6.html
pref(dom.animations-api.core.enabled,true) pref(dom.animations-api.timelines.enabled,true) load 1216842-1.html
pref(dom.animations-api.core.enabled,true) pref(dom.animations-api.timelines.enabled,true) load 1216842-2.html
pref(dom.animations-api.core.enabled,true) pref(dom.animations-api.timelines.enabled,true) load 1216842-3.html
pref(dom.animations-api.core.enabled,true) pref(dom.animations-api.timelines.enabled,true) load 1216842-4.html
pref(dom.animations-api.core.enabled,true) pref(dom.animations-api.timelines.enabled,true) load 1216842-5.html
pref(dom.animations-api.core.enabled,true) pref(dom.animations-api.timelines.enabled,true) load 1216842-6.html
pref(dom.animations-api.core.enabled,true) load 1272475-1.html
pref(dom.animations-api.core.enabled,true) load 1272475-2.html
pref(dom.animations-api.core.enabled,true) load 1278485-1.html
pref(dom.animations-api.core.enabled,true) load 1277272-1.html
pref(dom.animations-api.core.enabled,true) pref(dom.animations-api.timelines.enabled,true) load 1277272-1.html
pref(dom.animations-api.core.enabled,true) load 1290535-1.html
+6
View File
@@ -1,4 +1,10 @@
[DEFAULT]
prefs =
dom.animations-api.compositing.enabled=true
dom.animations-api.core.enabled=true
dom.animations-api.getAnimations.enabled=true
dom.animations-api.implicit-keyframes.enabled=true
dom.animations-api.timelines.enabled=true
# Support files for chrome tests that we want to load over HTTP need
# to go in here, not chrome.ini.
support-files =
+10 -10
View File
@@ -745,7 +745,7 @@ Element::Scroll(const CSSIntPoint& aScroll, const ScrollOptions& aOptions)
if (aOptions.mBehavior == ScrollBehavior::Smooth) {
scrollMode = nsIScrollableFrame::SMOOTH_MSD;
} else if (aOptions.mBehavior == ScrollBehavior::Auto) {
ScrollbarStyles styles = sf->GetScrollbarStyles();
ScrollStyles styles = sf->GetScrollStyles();
if (styles.mScrollBehavior == NS_STYLE_SCROLL_BEHAVIOR_SMOOTH) {
scrollMode = nsIScrollableFrame::SMOOTH_MSD;
}
@@ -834,7 +834,7 @@ Element::SetScrollTop(int32_t aScrollTop)
nsIScrollableFrame* sf = GetScrollFrame();
if (sf) {
nsIScrollableFrame::ScrollMode scrollMode = nsIScrollableFrame::INSTANT;
if (sf->GetScrollbarStyles().mScrollBehavior == NS_STYLE_SCROLL_BEHAVIOR_SMOOTH) {
if (sf->GetScrollStyles().mScrollBehavior == NS_STYLE_SCROLL_BEHAVIOR_SMOOTH) {
scrollMode = nsIScrollableFrame::SMOOTH_MSD;
}
sf->ScrollToCSSPixels(CSSIntPoint(sf->GetScrollPositionCSSPixels().x,
@@ -856,7 +856,7 @@ Element::SetScrollLeft(int32_t aScrollLeft)
nsIScrollableFrame* sf = GetScrollFrame();
if (sf) {
nsIScrollableFrame::ScrollMode scrollMode = nsIScrollableFrame::INSTANT;
if (sf->GetScrollbarStyles().mScrollBehavior == NS_STYLE_SCROLL_BEHAVIOR_SMOOTH) {
if (sf->GetScrollStyles().mScrollBehavior == NS_STYLE_SCROLL_BEHAVIOR_SMOOTH) {
scrollMode = nsIScrollableFrame::SMOOTH_MSD;
}
@@ -1069,7 +1069,7 @@ ShadowRoot*
Element::GetShadowRootByMode() const
{
/**
* 1. Let shadow be context object’s shadow root.
* 1. Let shadow be context object???s shadow root.
* 2. If shadow is null or its mode is "closed", then return null.
*/
ShadowRoot* shadowRoot = GetShadowRoot();
@@ -1088,7 +1088,7 @@ already_AddRefed<ShadowRoot>
Element::AttachShadow(const ShadowRootInit& aInit, ErrorResult& aError)
{
/**
* 1. If context object’s namespace is not the HTML namespace,
* 1. If context object???s namespace is not the HTML namespace,
* then throw a "NotSupportedError" DOMException.
*/
if (!IsHTMLElement()) {
@@ -1097,7 +1097,7 @@ Element::AttachShadow(const ShadowRootInit& aInit, ErrorResult& aError)
}
/**
* 2. If context object’s local name is not
* 2. If context object???s local name is not
* a valid custom element name, "article", "aside", "blockquote",
* "body", "div", "footer", "h1", "h2", "h3", "h4", "h5", "h6",
* "header", "main" "nav", "p", "section", or "span",
@@ -1181,8 +1181,8 @@ Element::AttachShadowInternal(bool aClosed, ErrorResult& aError)
/**
* 4. Let shadow be a new shadow root whose node document is
* context object’s node document, host is context object,
* and mode is init’s mode.
* context object???s node document, host is context object,
* and mode is init???s mode.
*/
RefPtr<ShadowRoot> shadowRoot =
new ShadowRoot(this, aClosed, nodeInfo.forget(), protoBinding);
@@ -1190,7 +1190,7 @@ Element::AttachShadowInternal(bool aClosed, ErrorResult& aError)
shadowRoot->SetIsComposedDocParticipant(IsInComposedDoc());
/**
* 5. Set context object’s shadow root to shadow.
* 5. Set context object???s shadow root to shadow.
*/
SetShadowRoot(shadowRoot);
@@ -1890,7 +1890,7 @@ Element::UnbindFromTree(bool aDeep, bool aNullParent)
nsPresContext* presContext = presShell->GetPresContext();
if (presContext) {
MOZ_ASSERT(this !=
presContext->GetViewportScrollbarStylesOverrideNode(),
presContext->GetViewportScrollStylesOverrideNode(),
"Leaving behind a raw pointer to this node (as having "
"propagated scrollbar styles) - that's dangerous...");
}
-2
View File
@@ -16,8 +16,6 @@ namespace mozilla {
namespace dom {
class Promise;
// Make sure that any change to ScreenOrientationInternal values are
// also made in mobile/android/base/GeckoScreenOrientation.java
typedef uint32_t ScreenOrientationInternal;
static const ScreenOrientationInternal eScreenOrientation_None = 0;
-56
View File
@@ -9341,62 +9341,6 @@ nsContentUtils::SetScrollbarsVisibility(nsIDocShell* aDocShell, bool aVisible)
}
}
/* static */ void
nsContentUtils::GetPresentationURL(nsIDocShell* aDocShell, nsAString& aPresentationUrl)
{
MOZ_ASSERT(aDocShell);
// Simulate receiver context for web platform test
if (Preferences::GetBool("dom.presentation.testing.simulate-receiver")) {
nsCOMPtr<nsIDocument> doc;
nsCOMPtr<nsPIDOMWindowOuter> docShellWin =
do_QueryInterface(aDocShell->GetScriptGlobalObject());
if (docShellWin) {
doc = docShellWin->GetExtantDoc();
}
if (NS_WARN_IF(!doc)) {
return;
}
nsCOMPtr<nsIURI> uri = doc->GetDocumentURI();
if (NS_WARN_IF(!uri)) {
return;
}
nsAutoCString uriStr;
uri->GetSpec(uriStr);
aPresentationUrl = NS_ConvertUTF8toUTF16(uriStr);
return;
}
if (XRE_IsContentProcess()) {
nsCOMPtr<nsIDocShellTreeItem> sameTypeRoot;
aDocShell->GetSameTypeRootTreeItem(getter_AddRefs(sameTypeRoot));
nsCOMPtr<nsIDocShellTreeItem> root;
aDocShell->GetRootTreeItem(getter_AddRefs(root));
if (sameTypeRoot.get() == root.get()) {
// presentation URL is stored in TabChild for the top most
// <iframe mozbrowser> in content process.
TabChild* tabChild = TabChild::GetFrom(aDocShell);
if (tabChild) {
aPresentationUrl = tabChild->PresentationURL();
}
return;
}
}
nsCOMPtr<nsILoadContext> loadContext(do_QueryInterface(aDocShell));
nsCOMPtr<nsIDOMElement> topFrameElement;
loadContext->GetTopFrameElement(getter_AddRefs(topFrameElement));
if (!topFrameElement) {
return;
}
topFrameElement->GetAttribute(NS_LITERAL_STRING("mozpresentation"), aPresentationUrl);
}
/* static */ nsIDocShell*
nsContentUtils::GetDocShellForEventTarget(EventTarget* aTarget)
{
-6
View File
@@ -2679,12 +2679,6 @@ public:
static void SetScrollbarsVisibility(nsIDocShell* aDocShell, bool aVisible);
/*
* Return the associated presentation URL of the presented content.
* Will return empty string if the docshell is not in a presented content.
*/
static void GetPresentationURL(nsIDocShell* aDocShell, nsAString& aPresentationUrl);
/*
* Try to find the docshell corresponding to the given event target.
*/
+28 -1
View File
@@ -2923,6 +2923,33 @@ nsDocument::IsWebAnimationsEnabled(JSContext* /*unused*/, JSObject* /*unused*/)
Preferences::GetBool("dom.animations-api.core.enabled");
}
bool
nsDocument::AreWebAnimationsTimelinesEnabled(JSContext* /*unused*/, JSObject* /*unused*/)
{
MOZ_ASSERT(NS_IsMainThread());
return nsContentUtils::IsCallerChrome() ||
Preferences::GetBool("dom.animations-api.timelines.enabled");
}
bool
nsDocument::AreWebAnimationsImplicitKeyframesEnabled(JSContext* /*unused*/, JSObject* /*unused*/)
{
MOZ_ASSERT(NS_IsMainThread());
return nsContentUtils::IsCallerChrome() ||
Preferences::GetBool("dom.animations-api.implicit-keyframes.enabled");
}
bool
nsDocument::IsWebAnimationsGetAnimationsEnabled(JSContext* /*unused*/, JSObject* /*unused*/)
{
MOZ_ASSERT(NS_IsMainThread());
return nsContentUtils::IsCallerChrome() ||
Preferences::GetBool("dom.animations-api.getAnimations.enabled");
}
DocumentTimeline*
nsDocument::Timeline()
{
@@ -10568,7 +10595,7 @@ UpdateViewportScrollbarOverrideForFullscreen(nsIDocument* aDoc)
{
if (nsIPresShell* presShell = aDoc->GetShell()) {
if (nsPresContext* presContext = presShell->GetPresContext()) {
presContext->UpdateViewportScrollbarStylesOverride();
presContext->UpdateViewportScrollStylesOverride();
}
}
}
+4
View File
@@ -433,6 +433,10 @@ public:
static bool IsElementAnimateEnabled(JSContext* aCx, JSObject* aObject);
static bool IsWebAnimationsEnabled(JSContext* aCx, JSObject* aObject);
static bool AreWebAnimationsImplicitKeyframesEnabled(JSContext* aCx, JSObject* aObject);
static bool AreWebAnimationsTimelinesEnabled(JSContext* aCx, JSObject* aObject);
static bool IsWebAnimationsGetAnimationsEnabled(JSContext* aCx, JSObject* aObject);
virtual mozilla::dom::DocumentTimeline* Timeline() override;
virtual void GetAnimations(
nsTArray<RefPtr<mozilla::dom::Animation>>& aAnimations) override;
+1 -15
View File
@@ -3102,14 +3102,6 @@ nsFrameLoader::ApplySandboxFlags(uint32_t sandboxFlags)
// The child can only add restrictions, never remove them.
sandboxFlags |= parentSandboxFlags;
// If this frame is a receiving browsing context, we should add
// sandboxed auxiliary navigation flag to sandboxFlags. See
// https://w3c.github.io/presentation-api/#creating-a-receiving-browsing-context
nsAutoString presentationURL;
nsContentUtils::GetPresentationURL(mDocShell, presentationURL);
if (!presentationURL.IsEmpty()) {
sandboxFlags |= SANDBOXED_AUXILIARY_NAVIGATION;
}
mDocShell->SetSandboxFlags(sandboxFlags);
}
}
@@ -3427,11 +3419,6 @@ nsFrameLoader::GetNewTabContext(MutableTabContext* aTabContext,
rv = PopulateUserContextIdFromAttribute(attrs);
NS_ENSURE_SUCCESS(rv, rv);
nsAutoString presentationURLStr;
mOwnerContent->GetAttr(kNameSpaceID_None,
nsGkAtoms::mozpresentation,
presentationURLStr);
nsCOMPtr<nsIDocShell> docShell = mOwnerContent->OwnerDoc()->GetDocShell();
nsCOMPtr<nsILoadContext> parentContext = do_QueryInterface(docShell);
NS_ENSURE_STATE(parentContext);
@@ -3459,8 +3446,7 @@ nsFrameLoader::GetNewTabContext(MutableTabContext* aTabContext,
containingApp,
showAccelerators,
showFocusRings,
attrs,
presentationURLStr);
attrs);
NS_ENSURE_STATE(tabContextUpdated);
return NS_OK;
-1
View File
@@ -1038,7 +1038,6 @@ GK_ATOM(predicate, "predicate")
GK_ATOM(prefix, "prefix")
GK_ATOM(preload, "preload")
GK_ATOM(prerendered, "prerendered")
GK_ATOM(mozpresentation, "mozpresentation")
GK_ATOM(preserve, "preserve")
GK_ATOM(preserveSpace, "preserve-space")
GK_ATOM(preventdefault, "preventdefault")
+3 -3
View File
@@ -8264,7 +8264,7 @@ nsGlobalWindow::ScrollTo(const CSSIntPoint& aScroll,
scroll.y = maxpx;
}
bool smoothScroll = sf->GetScrollbarStyles().IsSmoothScroll(aOptions.mBehavior);
bool smoothScroll = sf->GetScrollStyles().IsSmoothScroll(aOptions.mBehavior);
sf->ScrollToCSSPixels(scroll, smoothScroll
? nsIScrollableFrame::SMOOTH_MSD
@@ -8320,7 +8320,7 @@ nsGlobalWindow::ScrollByLines(int32_t numLines,
// It seems like it would make more sense for ScrollByLines to use
// SMOOTH mode, but tests seem to depend on the synchronous behaviour.
// Perhaps Web content does too.
bool smoothScroll = sf->GetScrollbarStyles().IsSmoothScroll(aOptions.mBehavior);
bool smoothScroll = sf->GetScrollStyles().IsSmoothScroll(aOptions.mBehavior);
sf->ScrollBy(nsIntPoint(0, numLines), nsIScrollableFrame::LINES,
smoothScroll
@@ -8341,7 +8341,7 @@ nsGlobalWindow::ScrollByPages(int32_t numPages,
// It seems like it would make more sense for ScrollByPages to use
// SMOOTH mode, but tests seem to depend on the synchronous behaviour.
// Perhaps Web content does too.
bool smoothScroll = sf->GetScrollbarStyles().IsSmoothScroll(aOptions.mBehavior);
bool smoothScroll = sf->GetScrollStyles().IsSmoothScroll(aOptions.mBehavior);
sf->ScrollBy(nsIntPoint(0, numPages), nsIScrollableFrame::PAGES,
smoothScroll
+3 -2
View File
@@ -299,10 +299,11 @@ nsJSUtils::CompileModule(JSContext* aCx,
NS_ENSURE_TRUE(xpc::Scriptability::Get(aEvaluationGlobal).Allowed(), NS_OK);
if (!JS::CompileModule(aCx, aCompileOptions, aSrcBuf, aModule)) {
bool compileResult = JS::CompileModule(aCx, aCompileOptions, aSrcBuf, aModule);
if (!compileResult) {
return NS_ERROR_FAILURE;
}
return NS_OK;
}
+7 -3
View File
@@ -930,7 +930,7 @@ ImageBitmap::CreateInternal(nsIGlobalObject* aGlobal, ImageData& aImageData,
const Maybe<IntRect>& aCropRect, ErrorResult& aRv)
{
// Copy data into SourceSurface.
dom::Uint8ClampedArray array;
RootedTypedArray<Uint8ClampedArray> array(RootingCx());
DebugOnly<bool> inited = array.Init(aImageData.GetDataObject());
MOZ_ASSERT(inited);
@@ -952,13 +952,17 @@ ImageBitmap::CreateInternal(nsIGlobalObject* aGlobal, ImageData& aImageData,
// Create and Crop the raw data into a layers::Image
RefPtr<layers::Image> data;
// The data could move during a GC; copy it out into a local buffer.
uint8_t* fixedData = array.Data();
if (NS_IsMainThread()) {
data = CreateImageFromRawData(imageSize, imageStride, FORMAT,
array.Data(), dataLength,
fixedData, dataLength,
aCropRect);
} else {
RefPtr<CreateImageFromRawDataInMainThreadSyncTask> task
= new CreateImageFromRawDataInMainThreadSyncTask(array.Data(),
= new CreateImageFromRawDataInMainThreadSyncTask(fixedData,
dataLength,
imageStride,
FORMAT,
+2 -2
View File
@@ -2516,7 +2516,7 @@ EventStateManager::ComputeScrollTarget(nsIFrame* aTargetFrame,
return frameToScroll;
}
ScrollbarStyles ss = scrollableFrame->GetScrollbarStyles();
ScrollStyles ss = scrollableFrame->GetScrollStyles();
bool hiddenForV = (NS_STYLE_OVERFLOW_HIDDEN == ss.mVertical);
bool hiddenForH = (NS_STYLE_OVERFLOW_HIDDEN == ss.mHorizontal);
if ((hiddenForV && hiddenForH) ||
@@ -2609,7 +2609,7 @@ EventStateManager::DoScrollText(nsIScrollableFrame* aScrollableFrame,
ComputeScrollAmountForDefaultAction(aEvent, scrollAmountInDevPixels);
// Don't scroll around the axis whose overflow style is hidden.
ScrollbarStyles overflowStyle = aScrollableFrame->GetScrollbarStyles();
ScrollStyles overflowStyle = aScrollableFrame->GetScrollStyles();
if (overflowStyle.mHorizontal == NS_STYLE_OVERFLOW_HIDDEN) {
actualDevPixelScrollAmount.x = 0;
}
+3 -3
View File
@@ -137,9 +137,9 @@ HTMLMenuElement::ParseAttribute(int32_t aNamespaceID,
const nsAString& aValue,
nsAttrValue& aResult)
{
if (aNamespaceID == kNameSpaceID_None && aAttribute == nsGkAtoms::type) {
bool success = aResult.ParseEnumValue(aValue, kMenuTypeTable,
false);
if (aNamespaceID == kNameSpaceID_None && aAttribute == nsGkAtoms::type &&
Preferences::GetBool("dom.menuitem.enabled")) {
bool success = aResult.ParseEnumValue(aValue, kMenuTypeTable, false);
if (success) {
mType = aResult.GetEnumValue();
} else {
+12 -2
View File
@@ -7,12 +7,22 @@
#include "mozilla/BasicEvents.h"
#include "mozilla/EventDispatcher.h"
#include "mozilla/Preferences.h"
#include "mozilla/dom/HTMLMenuItemElementBinding.h"
#include "mozilla/dom/HTMLUnknownElement.h"
#include "nsAttrValueInlines.h"
#include "nsContentUtils.h"
NS_IMPL_NS_NEW_HTML_ELEMENT_CHECK_PARSER(MenuItem)
nsGenericHTMLElement*
NS_NewHTMLMenuItemElement(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo,
mozilla::dom::FromParser aFromParser) {
RefPtr<mozilla::dom::NodeInfo> nodeInfo(aNodeInfo);
if (mozilla::Preferences::GetBool("dom.menuitem.enabled")) {
return new mozilla::dom::HTMLMenuItemElement(nodeInfo.forget(), aFromParser);
} else {
return new mozilla::dom::HTMLUnknownElement(nodeInfo.forget());
}
}
namespace mozilla {
namespace dom {
@@ -4,6 +4,9 @@ const kPage = "http://example.org/browser/" +
"dom/html/test/file_content_contextmenu.html";
add_task(function* () {
yield SpecialPowers.pushPrefEnv({
set: [["dom.menuitem.enabled", true]],
});
yield BrowserTestUtils.withNewTab({
gBrowser,
url: kPage
+2
View File
@@ -1,4 +1,6 @@
[DEFAULT]
prefs =
dom.menuitem.enabled=true # only for test_bug617528.html
support-files =
347174transform.xsl
347174transformable.xml
-5
View File
@@ -48,11 +48,6 @@ struct FrameIPCTabContext
// Whether this TabContext should work in prerender mode.
bool isPrerendered;
// The requested presentation URL.
// This value would be empty if the TabContext isn't created for
// presented content.
nsString presentationURL;
// Keyboard indicator state inherited from the parent.
UIStateChangeType showAccelerators;
UIStateChangeType showFocusRings;
-5
View File
@@ -770,11 +770,6 @@ TabChild::NotifyTabContextUpdated(bool aIsPreallocated)
if (aIsPreallocated) {
nsDocShell::Cast(docShell)->SetOriginAttributes(OriginAttributesRef());
}
// Set SANDBOXED_AUXILIARY_NAVIGATION flag if this is a receiver page.
if (!PresentationURL().IsEmpty()) {
docShell->SetSandboxFlags(SANDBOXED_AUXILIARY_NAVIGATION);
}
}
void
+2 -14
View File
@@ -190,12 +190,6 @@ TabContext::OriginAttributesRef() const
return mOriginAttributes;
}
const nsAString&
TabContext::PresentationURL() const
{
return mPresentationURL;
}
UIStateChangeType
TabContext::ShowAccelerators() const
{
@@ -215,8 +209,7 @@ TabContext::SetTabContext(bool aIsMozBrowserElement,
mozIApplication* aAppFrameOwnerApp,
UIStateChangeType aShowAccelerators,
UIStateChangeType aShowFocusRings,
const DocShellOriginAttributes& aOriginAttributes,
const nsAString& aPresentationURL)
const DocShellOriginAttributes& aOriginAttributes)
{
NS_ENSURE_FALSE(mInitialized, false);
@@ -248,7 +241,6 @@ TabContext::SetTabContext(bool aIsMozBrowserElement,
mContainingAppId = containingAppId;
mOwnApp = aOwnApp;
mContainingApp = aAppFrameOwnerApp;
mPresentationURL = aPresentationURL;
mShowAccelerators = aShowAccelerators;
mShowFocusRings = aShowFocusRings;
return true;
@@ -261,7 +253,6 @@ TabContext::AsIPCTabContext() const
mContainingAppId,
mIsMozBrowserElement,
mIsPrerendered,
mPresentationURL,
mShowAccelerators,
mShowFocusRings));
}
@@ -285,7 +276,6 @@ MaybeInvalidTabContext::MaybeInvalidTabContext(const IPCTabContext& aParams)
bool isPrerendered = false;
uint32_t containingAppId = NO_APP_ID;
DocShellOriginAttributes originAttributes;
nsAutoString presentationURL;
UIStateChangeType showAccelerators = UIStateChangeType_NoChange;
UIStateChangeType showFocusRings = UIStateChangeType_NoChange;
@@ -348,7 +338,6 @@ MaybeInvalidTabContext::MaybeInvalidTabContext(const IPCTabContext& aParams)
isMozBrowserElement = ipcContext.isMozBrowserElement();
isPrerendered = ipcContext.isPrerendered();
containingAppId = ipcContext.frameOwnerAppId();
presentationURL = ipcContext.presentationURL();
showAccelerators = ipcContext.showAccelerators();
showFocusRings = ipcContext.showFocusRings();
originAttributes = ipcContext.originAttributes();
@@ -395,8 +384,7 @@ MaybeInvalidTabContext::MaybeInvalidTabContext(const IPCTabContext& aParams)
containingApp,
showAccelerators,
showFocusRings,
originAttributes,
presentationURL);
originAttributes);
if (!rv) {
mInvalidReason = "Couldn't initialize TabContext.";
}
+3 -17
View File
@@ -125,12 +125,6 @@ public:
*/
const DocShellOriginAttributes& OriginAttributesRef() const;
/**
* Returns the presentation URL associated with the tab if this tab is
* created for presented content
*/
const nsAString& PresentationURL() const;
UIStateChangeType ShowAccelerators() const;
UIStateChangeType ShowFocusRings() const;
@@ -169,8 +163,7 @@ protected:
mozIApplication* aAppFrameOwnerApp,
UIStateChangeType aShowAccelerators,
UIStateChangeType aShowFocusRings,
const DocShellOriginAttributes& aOriginAttributes,
const nsAString& aPresentationURL);
const DocShellOriginAttributes& aOriginAttributes);
/**
* Modify this TabContext to match the given TabContext. This is a special
@@ -225,11 +218,6 @@ private:
*/
DocShellOriginAttributes mOriginAttributes;
/**
* The requested presentation URL.
*/
nsString mPresentationURL;
/**
* Keyboard indicator state (focus rings, accelerators).
*/
@@ -257,8 +245,7 @@ public:
mozIApplication* aAppFrameOwnerApp,
UIStateChangeType aShowAccelerators,
UIStateChangeType aShowFocusRings,
const DocShellOriginAttributes& aOriginAttributes,
const nsAString& aPresentationURL = EmptyString())
const DocShellOriginAttributes& aOriginAttributes)
{
return TabContext::SetTabContext(aIsMozBrowserElement,
aIsPrerendered,
@@ -266,8 +253,7 @@ public:
aAppFrameOwnerApp,
aShowAccelerators,
aShowFocusRings,
aOriginAttributes,
aPresentationURL);
aOriginAttributes);
}
};
+3
View File
@@ -145,6 +145,9 @@ IPDL_SOURCES += [
'PGMPVideoEncoder.ipdl',
]
if CONFIG['GKMEDIAS_SHARED_LIBRARY']:
NO_VISIBILITY_FLAGS = True
# comment this out to use Unsafe Shmem for more performance
DEFINES['GMP_SAFE_SHMEM'] = True
@@ -1,227 +0,0 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "AndroidDecoderModule.h"
#include "AndroidBridge.h"
#include "MediaCodecDataDecoder.h"
#include "RemoteDataDecoder.h"
#include "MediaInfo.h"
#include "VPXDecoder.h"
#include "MediaPrefs.h"
#include "OpusDecoder.h"
#include "VorbisDecoder.h"
#include "nsPromiseFlatString.h"
#include "nsIGfxInfo.h"
#include "prlog.h"
#include <jni.h>
#undef LOG
#define LOG(arg, ...) MOZ_LOG(sAndroidDecoderModuleLog, \
mozilla::LogLevel::Debug, ("AndroidDecoderModule(%p)::%s: " arg, \
this, __func__, ##__VA_ARGS__))
using namespace mozilla;
using namespace mozilla::gl;
using namespace mozilla::java::sdk;
using media::TimeUnit;
namespace mozilla {
mozilla::LazyLogModule sAndroidDecoderModuleLog("AndroidDecoderModule");
static const char*
TranslateMimeType(const nsACString& aMimeType)
{
if (VPXDecoder::IsVPX(aMimeType, VPXDecoder::VP8)) {
return "video/x-vnd.on2.vp8";
} else if (VPXDecoder::IsVPX(aMimeType, VPXDecoder::VP9)) {
return "video/x-vnd.on2.vp9";
}
return PromiseFlatCString(aMimeType).get();
}
static bool
GetFeatureStatus(int32_t aFeature)
{
nsCOMPtr<nsIGfxInfo> gfxInfo = services::GetGfxInfo();
int32_t status = nsIGfxInfo::FEATURE_STATUS_UNKNOWN;
nsCString discardFailureId;
if (!gfxInfo || NS_FAILED(gfxInfo->GetFeatureStatus(aFeature, discardFailureId, &status))) {
return false;
}
return status == nsIGfxInfo::FEATURE_STATUS_OK;
};
CryptoInfo::LocalRef
GetCryptoInfoFromSample(const MediaRawData* aSample)
{
auto& cryptoObj = aSample->mCrypto;
if (!cryptoObj.mValid) {
return nullptr;
}
CryptoInfo::LocalRef cryptoInfo;
nsresult rv = CryptoInfo::New(&cryptoInfo);
NS_ENSURE_SUCCESS(rv, nullptr);
uint32_t numSubSamples =
std::min<uint32_t>(cryptoObj.mPlainSizes.Length(), cryptoObj.mEncryptedSizes.Length());
uint32_t totalSubSamplesSize = 0;
for (auto& size : cryptoObj.mEncryptedSizes) {
totalSubSamplesSize += size;
}
// mPlainSizes is uint16_t, need to transform to uint32_t first.
nsTArray<uint32_t> plainSizes;
for (auto& size : cryptoObj.mPlainSizes) {
totalSubSamplesSize += size;
plainSizes.AppendElement(size);
}
uint32_t codecSpecificDataSize = aSample->Size() - totalSubSamplesSize;
// Size of codec specific data("CSD") for Android MediaCodec usage should be
// included in the 1st plain size.
plainSizes[0] += codecSpecificDataSize;
static const int kExpectedIVLength = 16;
auto tempIV(cryptoObj.mIV);
auto tempIVLength = tempIV.Length();
MOZ_ASSERT(tempIVLength <= kExpectedIVLength);
for (size_t i = tempIVLength; i < kExpectedIVLength; i++) {
// Padding with 0
tempIV.AppendElement(0);
}
auto numBytesOfPlainData = mozilla::jni::IntArray::New(
reinterpret_cast<int32_t*>(&plainSizes[0]),
plainSizes.Length());
auto numBytesOfEncryptedData =
mozilla::jni::IntArray::New(reinterpret_cast<const int32_t*>(&cryptoObj.mEncryptedSizes[0]),
cryptoObj.mEncryptedSizes.Length());
auto iv = mozilla::jni::ByteArray::New(reinterpret_cast<int8_t*>(&tempIV[0]),
tempIV.Length());
auto keyId = mozilla::jni::ByteArray::New(reinterpret_cast<const int8_t*>(&cryptoObj.mKeyId[0]),
cryptoObj.mKeyId.Length());
cryptoInfo->Set(numSubSamples,
numBytesOfPlainData,
numBytesOfEncryptedData,
keyId,
iv,
MediaCodec::CRYPTO_MODE_AES_CTR);
return cryptoInfo;
}
bool
AndroidDecoderModule::SupportsMimeType(const nsACString& aMimeType,
DecoderDoctorDiagnostics* aDiagnostics) const
{
if (!AndroidBridge::Bridge() ||
AndroidBridge::Bridge()->GetAPIVersion() < 16) {
return false;
}
if (aMimeType.EqualsLiteral("video/mp4") ||
aMimeType.EqualsLiteral("video/avc")) {
return true;
}
// When checking "audio/x-wav", CreateDecoder can cause a JNI ERROR by
// Accessing a stale local reference leading to a SIGSEGV crash.
// To avoid this we check for wav types here.
if (aMimeType.EqualsLiteral("audio/x-wav") ||
aMimeType.EqualsLiteral("audio/wave; codecs=1") ||
aMimeType.EqualsLiteral("audio/wave; codecs=6") ||
aMimeType.EqualsLiteral("audio/wave; codecs=7") ||
aMimeType.EqualsLiteral("audio/wave; codecs=65534")) {
return false;
}
if ((VPXDecoder::IsVPX(aMimeType, VPXDecoder::VP8) &&
!GetFeatureStatus(nsIGfxInfo::FEATURE_VP8_HW_DECODE)) ||
(VPXDecoder::IsVPX(aMimeType, VPXDecoder::VP9) &&
!GetFeatureStatus(nsIGfxInfo::FEATURE_VP9_HW_DECODE))) {
return false;
}
// Prefer the gecko decoder for opus and vorbis; stagefright crashes
// on content demuxed from mp4.
if (OpusDataDecoder::IsOpus(aMimeType) ||
VorbisDataDecoder::IsVorbis(aMimeType)) {
LOG("Rejecting audio of type %s", aMimeType.Data());
return false;
}
return java::HardwareCodecCapabilityUtils::FindDecoderCodecInfoForMimeType(
nsCString(TranslateMimeType(aMimeType)));
}
already_AddRefed<MediaDataDecoder>
AndroidDecoderModule::CreateVideoDecoder(const CreateDecoderParams& aParams)
{
MediaFormat::LocalRef format;
const VideoInfo& config = aParams.VideoConfig();
NS_ENSURE_SUCCESS(MediaFormat::CreateVideoFormat(
TranslateMimeType(config.mMimeType),
config.mDisplay.width,
config.mDisplay.height,
&format), nullptr);
RefPtr<MediaDataDecoder> decoder = MediaPrefs::PDMAndroidRemoteCodecEnabled() ?
RemoteDataDecoder::CreateVideoDecoder(config,
format,
aParams.mCallback,
aParams.mImageContainer) :
MediaCodecDataDecoder::CreateVideoDecoder(config,
format,
aParams.mCallback,
aParams.mImageContainer);
return decoder.forget();
}
already_AddRefed<MediaDataDecoder>
AndroidDecoderModule::CreateAudioDecoder(const CreateDecoderParams& aParams)
{
const AudioInfo& config = aParams.AudioConfig();
MOZ_ASSERT(config.mBitDepth == 16, "We only handle 16-bit audio!");
MediaFormat::LocalRef format;
LOG("CreateAudioFormat with mimeType=%s, mRate=%d, channels=%d",
config.mMimeType.Data(), config.mRate, config.mChannels);
NS_ENSURE_SUCCESS(MediaFormat::CreateAudioFormat(
config.mMimeType,
config.mRate,
config.mChannels,
&format), nullptr);
RefPtr<MediaDataDecoder> decoder = MediaPrefs::PDMAndroidRemoteCodecEnabled() ?
RemoteDataDecoder::CreateAudioDecoder(config, format, aParams.mCallback) :
MediaCodecDataDecoder::CreateAudioDecoder(config, format, aParams.mCallback);
return decoder.forget();
}
PlatformDecoderModule::ConversionRequired
AndroidDecoderModule::DecoderNeedsConversion(const TrackInfo& aConfig) const
{
if (aConfig.IsVideo()) {
return ConversionRequired::kNeedAnnexB;
}
return ConversionRequired::kNeedNone;
}
} // mozilla
@@ -1,34 +0,0 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* 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/. */
#ifndef AndroidDecoderModule_h_
#define AndroidDecoderModule_h_
#include "PlatformDecoderModule.h"
namespace mozilla {
class AndroidDecoderModule : public PlatformDecoderModule {
public:
already_AddRefed<MediaDataDecoder>
CreateVideoDecoder(const CreateDecoderParams& aParams) override;
already_AddRefed<MediaDataDecoder>
CreateAudioDecoder(const CreateDecoderParams& aParams) override;
AndroidDecoderModule() {}
virtual ~AndroidDecoderModule() {}
bool SupportsMimeType(const nsACString& aMimeType,
DecoderDoctorDiagnostics* aDiagnostics) const override;
ConversionRequired
DecoderNeedsConversion(const TrackInfo& aConfig) const override;
};
extern LazyLogModule sAndroidDecoderModuleLog;
} // namespace mozilla
#endif
@@ -1,698 +0,0 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "MediaCodecDataDecoder.h"
#include "AndroidBridge.h"
#include "AndroidSurfaceTexture.h"
#include "GeneratedJNINatives.h"
#include "GLImages.h"
#include "MediaData.h"
#include "MediaInfo.h"
#include "VPXDecoder.h"
#include "nsThreadUtils.h"
#include "nsPromiseFlatString.h"
#include "nsIGfxInfo.h"
#include "prlog.h"
#include <jni.h>
#undef LOG
#define LOG(arg, ...) MOZ_LOG(sAndroidDecoderModuleLog, \
mozilla::LogLevel::Debug, ("MediaCodecDataDecoder(%p)::%s: " arg, \
this, __func__, ##__VA_ARGS__))
using namespace mozilla;
using namespace mozilla::gl;
using namespace mozilla::java;
using namespace mozilla::java::sdk;
using media::TimeUnit;
namespace mozilla {
#define INVOKE_CALLBACK(Func, ...) \
if (mCallback) { \
mCallback->Func(__VA_ARGS__); \
} else { \
NS_WARNING("Callback not set"); \
}
static MediaCodec::LocalRef
CreateDecoder(const nsACString& aMimeType)
{
MediaCodec::LocalRef codec;
NS_ENSURE_SUCCESS(MediaCodec::CreateDecoderByType(TranslateMimeType(aMimeType),
&codec), nullptr);
return codec;
}
class VideoDataDecoder : public MediaCodecDataDecoder
{
public:
VideoDataDecoder(const VideoInfo& aConfig,
MediaFormat::Param aFormat,
MediaDataDecoderCallback* aCallback,
layers::ImageContainer* aImageContainer)
: MediaCodecDataDecoder(MediaData::Type::VIDEO_DATA, aConfig.mMimeType,
aFormat, aCallback)
, mImageContainer(aImageContainer)
, mConfig(aConfig)
{
}
const char* GetDescriptionName() const override
{
return "Android MediaCodec video decoder";
}
RefPtr<InitPromise> Init() override
{
mSurfaceTexture = AndroidSurfaceTexture::Create();
if (!mSurfaceTexture) {
NS_WARNING("Failed to create SurfaceTexture for video decode\n");
return InitPromise::CreateAndReject(NS_ERROR_DOM_MEDIA_FATAL_ERR, __func__);
}
if (NS_FAILED(InitDecoder(mSurfaceTexture->JavaSurface()))) {
return InitPromise::CreateAndReject(NS_ERROR_DOM_MEDIA_FATAL_ERR, __func__);
}
return InitPromise::CreateAndResolve(TrackInfo::kVideoTrack, __func__);
}
void Cleanup() override
{
}
nsresult PostOutput(BufferInfo::Param aInfo, MediaFormat::Param aFormat,
const TimeUnit& aDuration) override
{
RefPtr<layers::Image> img =
new SurfaceTextureImage(mSurfaceTexture.get(), mConfig.mDisplay,
gl::OriginPos::BottomLeft);
nsresult rv;
int32_t flags;
NS_ENSURE_SUCCESS(rv = aInfo->Flags(&flags), rv);
bool isSync = !!(flags & MediaCodec::BUFFER_FLAG_SYNC_FRAME);
int32_t offset;
NS_ENSURE_SUCCESS(rv = aInfo->Offset(&offset), rv);
int64_t presentationTimeUs;
NS_ENSURE_SUCCESS(rv = aInfo->PresentationTimeUs(&presentationTimeUs), rv);
RefPtr<VideoData> v =
VideoData::CreateFromImage(mConfig,
offset,
presentationTimeUs,
aDuration.ToMicroseconds(),
img,
isSync,
presentationTimeUs,
gfx::IntRect(0, 0,
mConfig.mDisplay.width,
mConfig.mDisplay.height));
INVOKE_CALLBACK(Output, v);
return NS_OK;
}
protected:
layers::ImageContainer* mImageContainer;
const VideoInfo& mConfig;
RefPtr<AndroidSurfaceTexture> mSurfaceTexture;
};
class AudioDataDecoder : public MediaCodecDataDecoder
{
public:
AudioDataDecoder(const AudioInfo& aConfig, MediaFormat::Param aFormat,
MediaDataDecoderCallback* aCallback)
: MediaCodecDataDecoder(MediaData::Type::AUDIO_DATA, aConfig.mMimeType,
aFormat, aCallback)
{
JNIEnv* const env = jni::GetEnvForThread();
jni::ByteBuffer::LocalRef buffer(env);
NS_ENSURE_SUCCESS_VOID(aFormat->GetByteBuffer(NS_LITERAL_STRING("csd-0"),
&buffer));
if (!buffer && aConfig.mCodecSpecificConfig->Length() >= 2) {
buffer = jni::ByteBuffer::New(
aConfig.mCodecSpecificConfig->Elements(),
aConfig.mCodecSpecificConfig->Length());
NS_ENSURE_SUCCESS_VOID(aFormat->SetByteBuffer(NS_LITERAL_STRING("csd-0"),
buffer));
}
}
const char* GetDescriptionName() const override
{
return "android audio decoder";
}
nsresult Output(BufferInfo::Param aInfo, void* aBuffer,
MediaFormat::Param aFormat, const TimeUnit& aDuration)
{
// The output on Android is always 16-bit signed
nsresult rv;
int32_t numChannels;
NS_ENSURE_SUCCESS(rv =
aFormat->GetInteger(NS_LITERAL_STRING("channel-count"), &numChannels), rv);
AudioConfig::ChannelLayout layout(numChannels);
if (!layout.IsValid()) {
return NS_ERROR_FAILURE;
}
int32_t sampleRate;
NS_ENSURE_SUCCESS(rv =
aFormat->GetInteger(NS_LITERAL_STRING("sample-rate"), &sampleRate), rv);
int32_t size;
NS_ENSURE_SUCCESS(rv = aInfo->Size(&size), rv);
int32_t offset;
NS_ENSURE_SUCCESS(rv = aInfo->Offset(&offset), rv);
#ifdef MOZ_SAMPLE_TYPE_S16
const int32_t numSamples = size / 2;
#else
#error We only support 16-bit integer PCM
#endif
const int32_t numFrames = numSamples / numChannels;
AlignedAudioBuffer audio(numSamples);
if (!audio) {
return NS_ERROR_OUT_OF_MEMORY;
}
const uint8_t* bufferStart = static_cast<uint8_t*>(aBuffer) + offset;
PodCopy(audio.get(), reinterpret_cast<const AudioDataValue*>(bufferStart),
numSamples);
int64_t presentationTimeUs;
NS_ENSURE_SUCCESS(rv = aInfo->PresentationTimeUs(&presentationTimeUs), rv);
RefPtr<AudioData> data = new AudioData(0, presentationTimeUs,
aDuration.ToMicroseconds(),
numFrames,
Move(audio),
numChannels,
sampleRate);
INVOKE_CALLBACK(Output, data);
return NS_OK;
}
};
MediaDataDecoder*
MediaCodecDataDecoder::CreateAudioDecoder(const AudioInfo& aConfig,
MediaFormat::Param aFormat,
MediaDataDecoderCallback* aCallback)
{
return new AudioDataDecoder(aConfig, aFormat, aCallback);
}
MediaDataDecoder*
MediaCodecDataDecoder::CreateVideoDecoder(const VideoInfo& aConfig,
MediaFormat::Param aFormat,
MediaDataDecoderCallback* aCallback,
layers::ImageContainer* aImageContainer)
{
return new VideoDataDecoder(aConfig, aFormat, aCallback, aImageContainer);
}
MediaCodecDataDecoder::MediaCodecDataDecoder(MediaData::Type aType,
const nsACString& aMimeType,
MediaFormat::Param aFormat,
MediaDataDecoderCallback* aCallback)
: mType(aType)
, mMimeType(aMimeType)
, mFormat(aFormat)
, mCallback(aCallback)
, mInputBuffers(nullptr)
, mOutputBuffers(nullptr)
, mMonitor("MediaCodecDataDecoder::mMonitor")
, mState(ModuleState::kDecoding)
{
}
MediaCodecDataDecoder::~MediaCodecDataDecoder()
{
Shutdown();
}
RefPtr<MediaDataDecoder::InitPromise>
MediaCodecDataDecoder::Init()
{
nsresult rv = InitDecoder(nullptr);
TrackInfo::TrackType type =
(mType == MediaData::AUDIO_DATA ? TrackInfo::TrackType::kAudioTrack
: TrackInfo::TrackType::kVideoTrack);
return NS_SUCCEEDED(rv) ?
InitPromise::CreateAndResolve(type, __func__) :
InitPromise::CreateAndReject(
NS_ERROR_DOM_MEDIA_FATAL_ERR, __func__);
}
nsresult
MediaCodecDataDecoder::InitDecoder(Surface::Param aSurface)
{
mDecoder = CreateDecoder(mMimeType);
if (!mDecoder) {
INVOKE_CALLBACK(Error,
MediaResult(NS_ERROR_DOM_MEDIA_FATAL_ERR, __func__));
return NS_ERROR_FAILURE;
}
nsresult rv;
NS_ENSURE_SUCCESS(rv = mDecoder->Configure(mFormat, aSurface, nullptr, 0), rv);
NS_ENSURE_SUCCESS(rv = mDecoder->Start(), rv);
NS_ENSURE_SUCCESS(rv = ResetInputBuffers(), rv);
NS_ENSURE_SUCCESS(rv = ResetOutputBuffers(), rv);
nsCOMPtr<nsIRunnable> r = NewRunnableMethod(this, &MediaCodecDataDecoder::DecoderLoop);
rv = NS_NewNamedThread("MC Decoder", getter_AddRefs(mThread), r);
return rv;
}
// This is in usec, so that's 10ms.
static const int64_t kDecoderTimeout = 10000;
#define BREAK_ON_DECODER_ERROR() \
if (NS_FAILED(res)) { \
NS_WARNING("Exiting decoder loop due to exception"); \
if (mState == ModuleState::kDrainDecoder) { \
INVOKE_CALLBACK(DrainComplete); \
SetState(ModuleState::kDecoding); \
} \
INVOKE_CALLBACK(Error, MediaResult(NS_ERROR_DOM_MEDIA_FATAL_ERR, __func__)); \
break; \
}
nsresult
MediaCodecDataDecoder::GetInputBuffer(
JNIEnv* aEnv, int aIndex, jni::Object::LocalRef* aBuffer)
{
MOZ_ASSERT(aEnv);
MOZ_ASSERT(!*aBuffer);
int numTries = 2;
while (numTries--) {
*aBuffer = jni::Object::LocalRef::Adopt(
aEnv->GetObjectArrayElement(mInputBuffers.Get(), aIndex));
if (*aBuffer) {
return NS_OK;
}
nsresult res = ResetInputBuffers();
if (NS_FAILED(res)) {
return res;
}
}
return NS_ERROR_FAILURE;
}
bool
MediaCodecDataDecoder::WaitForInput()
{
MonitorAutoLock lock(mMonitor);
while (mState == ModuleState::kDecoding && mQueue.empty()) {
// Signal that we require more input.
INVOKE_CALLBACK(InputExhausted);
lock.Wait();
}
return mState != ModuleState::kStopping;
}
already_AddRefed<MediaRawData>
MediaCodecDataDecoder::PeekNextSample()
{
MonitorAutoLock lock(mMonitor);
if (mState == ModuleState::kFlushing) {
mDecoder->Flush();
ClearQueue();
SetState(ModuleState::kDecoding);
lock.Notify();
return nullptr;
}
if (mQueue.empty()) {
if (mState == ModuleState::kDrainQueue) {
SetState(ModuleState::kDrainDecoder);
}
return nullptr;
}
// We're not stopping or flushing, so try to get a sample.
return RefPtr<MediaRawData>(mQueue.front()).forget();
}
nsresult
MediaCodecDataDecoder::QueueSample(const MediaRawData* aSample)
{
MOZ_ASSERT(aSample);
AutoLocalJNIFrame frame(jni::GetEnvForThread(), 1);
// We have a sample, try to feed it to the decoder.
int32_t inputIndex = -1;
nsresult res = mDecoder->DequeueInputBuffer(kDecoderTimeout, &inputIndex);
if (NS_FAILED(res)) {
return res;
}
if (inputIndex < 0) {
// There is no valid input buffer available.
return NS_ERROR_FAILURE;
}
jni::Object::LocalRef buffer(frame.GetEnv());
res = GetInputBuffer(frame.GetEnv(), inputIndex, &buffer);
if (NS_FAILED(res)) {
return res;
}
void* directBuffer = frame.GetEnv()->GetDirectBufferAddress(buffer.Get());
MOZ_ASSERT(frame.GetEnv()->GetDirectBufferCapacity(buffer.Get()) >=
aSample->Size(),
"Decoder buffer is not large enough for sample");
PodCopy(static_cast<uint8_t*>(directBuffer), aSample->Data(), aSample->Size());
CryptoInfo::LocalRef cryptoInfo = GetCryptoInfoFromSample(aSample);
if (cryptoInfo) {
res = mDecoder->QueueSecureInputBuffer(inputIndex, 0, cryptoInfo,
aSample->mTime, 0);
} else {
res = mDecoder->QueueInputBuffer(inputIndex, 0, aSample->Size(),
aSample->mTime, 0);
}
if (NS_FAILED(res)) {
return res;
}
mDurations.push_back(TimeUnit::FromMicroseconds(aSample->mDuration));
return NS_OK;
}
nsresult
MediaCodecDataDecoder::QueueEOS()
{
mMonitor.AssertCurrentThreadOwns();
nsresult res = NS_OK;
int32_t inputIndex = -1;
res = mDecoder->DequeueInputBuffer(kDecoderTimeout, &inputIndex);
if (NS_FAILED(res) || inputIndex < 0) {
return res;
}
res = mDecoder->QueueInputBuffer(inputIndex, 0, 0, 0,
MediaCodec::BUFFER_FLAG_END_OF_STREAM);
if (NS_SUCCEEDED(res)) {
SetState(ModuleState::kDrainWaitEOS);
mMonitor.Notify();
}
return res;
}
void
MediaCodecDataDecoder::HandleEOS(int32_t aOutputStatus)
{
MonitorAutoLock lock(mMonitor);
if (mState == ModuleState::kDrainWaitEOS) {
SetState(ModuleState::kDecoding);
mMonitor.Notify();
INVOKE_CALLBACK(DrainComplete);
}
mDecoder->ReleaseOutputBuffer(aOutputStatus, false);
}
Maybe<TimeUnit>
MediaCodecDataDecoder::GetOutputDuration()
{
if (mDurations.empty()) {
return Nothing();
}
const Maybe<TimeUnit> duration = Some(mDurations.front());
mDurations.pop_front();
return duration;
}
nsresult
MediaCodecDataDecoder::ProcessOutput(
BufferInfo::Param aInfo, MediaFormat::Param aFormat, int32_t aStatus)
{
AutoLocalJNIFrame frame(jni::GetEnvForThread(), 1);
const Maybe<TimeUnit> duration = GetOutputDuration();
if (!duration) {
// Some devices report failure in QueueSample while actually succeeding at
// it, in which case we get an output buffer without having a cached duration
// (bug 1273523).
return NS_OK;
}
const auto buffer = jni::Object::LocalRef::Adopt(
frame.GetEnv()->GetObjectArrayElement(mOutputBuffers.Get(), aStatus));
if (buffer) {
// The buffer will be null on Android L if we are decoding to a Surface.
void* directBuffer = frame.GetEnv()->GetDirectBufferAddress(buffer.Get());
Output(aInfo, directBuffer, aFormat, duration.value());
}
// The Surface will be updated at this point (for video).
mDecoder->ReleaseOutputBuffer(aStatus, true);
PostOutput(aInfo, aFormat, duration.value());
return NS_OK;
}
void
MediaCodecDataDecoder::DecoderLoop()
{
bool isOutputDone = false;
AutoLocalJNIFrame frame(jni::GetEnvForThread(), 1);
MediaFormat::LocalRef outputFormat(frame.GetEnv());
nsresult res = NS_OK;
while (WaitForInput()) {
RefPtr<MediaRawData> sample = PeekNextSample();
{
MonitorAutoLock lock(mMonitor);
if (mState == ModuleState::kDrainDecoder) {
MOZ_ASSERT(!sample, "Shouldn't have a sample when pushing EOF frame");
res = QueueEOS();
BREAK_ON_DECODER_ERROR();
}
}
if (sample) {
res = QueueSample(sample);
if (NS_SUCCEEDED(res)) {
// We've fed this into the decoder, so remove it from the queue.
MonitorAutoLock lock(mMonitor);
MOZ_RELEASE_ASSERT(mQueue.size(), "Queue may not be empty");
mQueue.pop_front();
isOutputDone = false;
}
}
if (isOutputDone) {
continue;
}
BufferInfo::LocalRef bufferInfo;
nsresult res = BufferInfo::New(&bufferInfo);
BREAK_ON_DECODER_ERROR();
int32_t outputStatus = -1;
res = mDecoder->DequeueOutputBuffer(bufferInfo, kDecoderTimeout,
&outputStatus);
BREAK_ON_DECODER_ERROR();
if (outputStatus == MediaCodec::INFO_TRY_AGAIN_LATER) {
// We might want to call mCallback->InputExhausted() here, but there seems
// to be some possible bad interactions here with the threading.
} else if (outputStatus == MediaCodec::INFO_OUTPUT_BUFFERS_CHANGED) {
res = ResetOutputBuffers();
BREAK_ON_DECODER_ERROR();
} else if (outputStatus == MediaCodec::INFO_OUTPUT_FORMAT_CHANGED) {
res = mDecoder->GetOutputFormat(ReturnTo(&outputFormat));
BREAK_ON_DECODER_ERROR();
} else if (outputStatus < 0) {
NS_WARNING("Unknown error from decoder!");
INVOKE_CALLBACK(Error,
MediaResult(NS_ERROR_DOM_MEDIA_DECODE_ERR,
__func__));
// Don't break here just in case it's recoverable. If it's not, other
// stuff will fail later and we'll bail out.
} else {
// We have a valid buffer index >= 0 here.
int32_t flags;
nsresult res = bufferInfo->Flags(&flags);
BREAK_ON_DECODER_ERROR();
if (flags & MediaCodec::BUFFER_FLAG_END_OF_STREAM) {
HandleEOS(outputStatus);
isOutputDone = true;
// We only queue empty EOF frames, so we're done for now.
continue;
}
res = ProcessOutput(bufferInfo, outputFormat, outputStatus);
BREAK_ON_DECODER_ERROR();
}
}
Cleanup();
// We're done.
MonitorAutoLock lock(mMonitor);
SetState(ModuleState::kShutdown);
mMonitor.Notify();
}
const char*
MediaCodecDataDecoder::ModuleStateStr(ModuleState aState) {
switch (aState) {
case ModuleState::kDecoding: return "Decoding";
case ModuleState::kFlushing: return "Flushing";
case ModuleState::kDrainQueue: return "DrainQueue";
case ModuleState::kDrainDecoder: return "DrainDecoder";
case ModuleState::kDrainWaitEOS: return "DrainWaitEOS";
case ModuleState::kStopping: return "Stopping";
case ModuleState::kShutdown: return "Shutdown";
default: MOZ_ASSERT_UNREACHABLE("Invalid state.");
}
return "Unknown";
}
bool
MediaCodecDataDecoder::SetState(ModuleState aState)
{
bool ok = true;
if (mState == ModuleState::kShutdown) {
ok = false;
} else if (mState == ModuleState::kStopping) {
ok = aState == ModuleState::kShutdown;
} else if (aState == ModuleState::kDrainDecoder) {
ok = mState == ModuleState::kDrainQueue;
} else if (aState == ModuleState::kDrainWaitEOS) {
ok = mState == ModuleState::kDrainDecoder;
}
if (ok) {
LOG("%s -> %s", ModuleStateStr(mState), ModuleStateStr(aState));
mState = aState;
} else {
LOG("Fail to transit from %s to %s state", ModuleStateStr(mState), ModuleStateStr(aState));
}
return ok;
}
void
MediaCodecDataDecoder::ClearQueue()
{
mMonitor.AssertCurrentThreadOwns();
mQueue.clear();
mDurations.clear();
}
void
MediaCodecDataDecoder::Input(MediaRawData* aSample)
{
MonitorAutoLock lock(mMonitor);
mQueue.push_back(aSample);
lock.NotifyAll();
}
nsresult
MediaCodecDataDecoder::ResetInputBuffers()
{
return mDecoder->GetInputBuffers(ReturnTo(&mInputBuffers));
}
nsresult
MediaCodecDataDecoder::ResetOutputBuffers()
{
return mDecoder->GetOutputBuffers(ReturnTo(&mOutputBuffers));
}
void
MediaCodecDataDecoder::Flush()
{
MonitorAutoLock lock(mMonitor);
if (!SetState(ModuleState::kFlushing)) {
return;
}
lock.Notify();
while (mState == ModuleState::kFlushing) {
lock.Wait();
}
}
void
MediaCodecDataDecoder::Drain()
{
MonitorAutoLock lock(mMonitor);
if (mState == ModuleState::kDrainDecoder ||
mState == ModuleState::kDrainQueue) {
return;
}
SetState(ModuleState::kDrainQueue);
lock.Notify();
}
void
MediaCodecDataDecoder::Shutdown()
{
MonitorAutoLock lock(mMonitor);
SetState(ModuleState::kStopping);
lock.Notify();
while (mThread && mState != ModuleState::kShutdown) {
lock.Wait();
}
if (mThread) {
mThread->Shutdown();
mThread = nullptr;
}
if (mDecoder) {
mDecoder->Stop();
mDecoder->Release();
mDecoder = nullptr;
}
}
} // mozilla
@@ -1,126 +0,0 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* 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/. */
#ifndef MediaCodecDataDecoder_h_
#define MediaCodecDataDecoder_h_
#include "AndroidDecoderModule.h"
#include "MediaCodec.h"
#include "SurfaceTexture.h"
#include "TimeUnits.h"
#include "mozilla/Monitor.h"
#include "mozilla/Maybe.h"
#include <deque>
namespace mozilla {
typedef std::deque<RefPtr<MediaRawData>> SampleQueue;
class MediaCodecDataDecoder : public MediaDataDecoder {
public:
static MediaDataDecoder* CreateAudioDecoder(const AudioInfo& aConfig,
java::sdk::MediaFormat::Param aFormat,
MediaDataDecoderCallback* aCallback);
static MediaDataDecoder* CreateVideoDecoder(const VideoInfo& aConfig,
java::sdk::MediaFormat::Param aFormat,
MediaDataDecoderCallback* aCallback,
layers::ImageContainer* aImageContainer);
virtual ~MediaCodecDataDecoder();
RefPtr<MediaDataDecoder::InitPromise> Init() override;
void Flush() override;
void Drain() override;
void Shutdown() override;
void Input(MediaRawData* aSample) override;
const char* GetDescriptionName() const override
{
return "Android MediaCodec decoder";
}
protected:
enum class ModuleState : uint8_t {
kDecoding = 0,
kFlushing,
kDrainQueue,
kDrainDecoder,
kDrainWaitEOS,
kStopping,
kShutdown
};
friend class AndroidDecoderModule;
MediaCodecDataDecoder(MediaData::Type aType,
const nsACString& aMimeType,
java::sdk::MediaFormat::Param aFormat,
MediaDataDecoderCallback* aCallback);
static const char* ModuleStateStr(ModuleState aState);
virtual nsresult InitDecoder(java::sdk::Surface::Param aSurface);
virtual nsresult Output(java::sdk::BufferInfo::Param aInfo, void* aBuffer,
java::sdk::MediaFormat::Param aFormat, const media::TimeUnit& aDuration)
{
return NS_OK;
}
virtual nsresult PostOutput(java::sdk::BufferInfo::Param aInfo,
java::sdk::MediaFormat::Param aFormat, const media::TimeUnit& aDuration)
{
return NS_OK;
}
virtual void Cleanup() {};
nsresult ResetInputBuffers();
nsresult ResetOutputBuffers();
nsresult GetInputBuffer(JNIEnv* env, int index, jni::Object::LocalRef* buffer);
bool WaitForInput();
already_AddRefed<MediaRawData> PeekNextSample();
nsresult QueueSample(const MediaRawData* aSample);
nsresult QueueEOS();
void HandleEOS(int32_t aOutputStatus);
Maybe<media::TimeUnit> GetOutputDuration();
nsresult ProcessOutput(java::sdk::BufferInfo::Param aInfo,
java::sdk::MediaFormat::Param aFormat,
int32_t aStatus);
// Sets decoder state and returns whether the new state has become effective.
bool SetState(ModuleState aState);
void DecoderLoop();
virtual void ClearQueue();
MediaData::Type mType;
nsAutoCString mMimeType;
java::sdk::MediaFormat::GlobalRef mFormat;
MediaDataDecoderCallback* mCallback;
java::sdk::MediaCodec::GlobalRef mDecoder;
jni::ObjectArray::GlobalRef mInputBuffers;
jni::ObjectArray::GlobalRef mOutputBuffers;
nsCOMPtr<nsIThread> mThread;
// Only these members are protected by mMonitor.
Monitor mMonitor;
ModuleState mState;
SampleQueue mQueue;
// Durations are stored in microseconds.
std::deque<media::TimeUnit> mDurations;
};
} // namespace mozilla
#endif
@@ -1,489 +0,0 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "AndroidDecoderModule.h"
#include "AndroidBridge.h"
#include "AndroidSurfaceTexture.h"
#include "FennecJNINatives.h"
#include "GLImages.h"
#include "MediaData.h"
#include "MediaInfo.h"
#include "VideoUtils.h"
#include "VPXDecoder.h"
#include "nsThreadUtils.h"
#include "nsPromiseFlatString.h"
#include "nsIGfxInfo.h"
#include "prlog.h"
#include <jni.h>
#include <deque>
#undef LOG
#define LOG(arg, ...) MOZ_LOG(sAndroidDecoderModuleLog, \
mozilla::LogLevel::Debug, ("RemoteDataDecoder(%p)::%s: " arg, \
this, __func__, ##__VA_ARGS__))
using namespace mozilla;
using namespace mozilla::gl;
using namespace mozilla::java;
using namespace mozilla::java::sdk;
using media::TimeUnit;
namespace mozilla {
class JavaCallbacksSupport
: public CodecProxy::NativeCallbacks::Natives<JavaCallbacksSupport>
{
public:
typedef CodecProxy::NativeCallbacks::Natives<JavaCallbacksSupport> Base;
using Base::AttachNative;
JavaCallbacksSupport(MediaDataDecoderCallback* aDecoderCallback)
: mDecoderCallback(aDecoderCallback)
{
MOZ_ASSERT(aDecoderCallback);
}
virtual ~JavaCallbacksSupport() {}
void OnInputExhausted()
{
if (mDecoderCallback) {
mDecoderCallback->InputExhausted();
}
}
virtual void HandleOutput(Sample::Param aSample) = 0;
void OnOutput(jni::Object::Param aSample)
{
if (mDecoderCallback) {
HandleOutput(Sample::Ref::From(aSample));
}
}
virtual void HandleOutputFormatChanged(MediaFormat::Param aFormat) {};
void OnOutputFormatChanged(jni::Object::Param aFormat)
{
if (mDecoderCallback) {
HandleOutputFormatChanged(MediaFormat::Ref::From(aFormat));
}
}
void OnError(bool aIsFatal)
{
if (mDecoderCallback) {
mDecoderCallback->Error(aIsFatal ?
MediaResult(NS_ERROR_DOM_MEDIA_FATAL_ERR, __func__) :
MediaResult(NS_ERROR_DOM_MEDIA_DECODE_ERR, __func__));
}
}
void DisposeNative()
{
// TODO
}
void Cancel()
{
mDecoderCallback = nullptr;
}
protected:
MediaDataDecoderCallback* mDecoderCallback;
};
struct SampleTime final
{
SampleTime(int64_t aStart, int64_t aDuration)
: mStart(aStart)
, mDuration(aDuration)
{}
int64_t mStart;
int64_t mDuration;
};
class RemoteVideoDecoder final : public RemoteDataDecoder
{
public:
class CallbacksSupport final : public JavaCallbacksSupport
{
public:
CallbacksSupport(RemoteVideoDecoder* aDecoder, MediaDataDecoderCallback* aCallback)
: JavaCallbacksSupport(aCallback)
, mDecoder(aDecoder)
{}
virtual ~CallbacksSupport() {}
void HandleOutput(Sample::Param aSample) override
{
Maybe<int64_t> durationUs = mDecoder->mInputDurations.Get();
if (!durationUs) {
return;
}
BufferInfo::LocalRef info = aSample->Info();
int32_t flags;
bool ok = NS_SUCCEEDED(info->Flags(&flags));
MOZ_ASSERT(ok);
int32_t offset;
ok |= NS_SUCCEEDED(info->Offset(&offset));
MOZ_ASSERT(ok);
int64_t presentationTimeUs;
ok |= NS_SUCCEEDED(info->PresentationTimeUs(&presentationTimeUs));
MOZ_ASSERT(ok);
int32_t size;
ok |= NS_SUCCEEDED(info->Size(&size));
MOZ_ASSERT(ok);
NS_ENSURE_TRUE_VOID(ok);
if (size > 0) {
RefPtr<layers::Image> img =
new SurfaceTextureImage(mDecoder->mSurfaceTexture.get(), mDecoder->mConfig.mDisplay,
gl::OriginPos::BottomLeft);
RefPtr<VideoData> v =
VideoData::CreateFromImage(mDecoder->mConfig,
offset,
presentationTimeUs,
durationUs.value(),
img,
!!(flags & MediaCodec::BUFFER_FLAG_SYNC_FRAME),
presentationTimeUs,
gfx::IntRect(0, 0,
mDecoder->mConfig.mDisplay.width,
mDecoder->mConfig.mDisplay.height));
mDecoderCallback->Output(v);
}
if ((flags & MediaCodec::BUFFER_FLAG_END_OF_STREAM) != 0) {
mDecoderCallback->DrainComplete();
}
}
friend class RemoteDataDecoder;
private:
RemoteVideoDecoder* mDecoder;
};
RemoteVideoDecoder(const VideoInfo& aConfig,
MediaFormat::Param aFormat,
MediaDataDecoderCallback* aCallback,
layers::ImageContainer* aImageContainer)
: RemoteDataDecoder(MediaData::Type::VIDEO_DATA, aConfig.mMimeType,
aFormat, aCallback)
, mImageContainer(aImageContainer)
, mConfig(aConfig)
{
}
RefPtr<InitPromise> Init() override
{
mSurfaceTexture = AndroidSurfaceTexture::Create();
if (!mSurfaceTexture) {
NS_WARNING("Failed to create SurfaceTexture for video decode\n");
return InitPromise::CreateAndReject(NS_ERROR_DOM_MEDIA_FATAL_ERR, __func__);
}
if (!jni::IsFennec()) {
NS_WARNING("Remote decoding not supported in non-Fennec environment\n");
return InitPromise::CreateAndReject(NS_ERROR_DOM_MEDIA_FATAL_ERR, __func__);
}
// Register native methods.
JavaCallbacksSupport::Init();
mJavaCallbacks = CodecProxy::NativeCallbacks::New();
JavaCallbacksSupport::AttachNative(mJavaCallbacks,
mozilla::MakeUnique<CallbacksSupport>(this, mCallback));
mJavaDecoder = CodecProxy::Create(mFormat, mSurfaceTexture->JavaSurface(), mJavaCallbacks);
if (mJavaDecoder == nullptr) {
return InitPromise::CreateAndReject(NS_ERROR_DOM_MEDIA_FATAL_ERR, __func__);
}
mInputDurations.Clear();
return InitPromise::CreateAndResolve(TrackInfo::kVideoTrack, __func__);
}
void Flush() override
{
mInputDurations.Clear();
RemoteDataDecoder::Flush();
}
void Drain() override
{
RemoteDataDecoder::Drain();
mInputDurations.Put(0);
}
void Input(MediaRawData* aSample) override
{
RemoteDataDecoder::Input(aSample);
mInputDurations.Put(aSample->mDuration);
}
private:
class DurationQueue {
public:
void Clear()
{
mValues.clear();
}
void Put(int64_t aDurationUs)
{
mValues.emplace_back(aDurationUs);
}
Maybe<int64_t> Get()
{
if (mValues.empty()) {
return Nothing();
}
auto value = Some(mValues.front());
mValues.pop_front();
return value;
}
private:
std::deque<int64_t> mValues;
};
layers::ImageContainer* mImageContainer;
const VideoInfo& mConfig;
RefPtr<AndroidSurfaceTexture> mSurfaceTexture;
DurationQueue mInputDurations;
};
class RemoteAudioDecoder final : public RemoteDataDecoder
{
public:
RemoteAudioDecoder(const AudioInfo& aConfig,
MediaFormat::Param aFormat,
MediaDataDecoderCallback* aCallback)
: RemoteDataDecoder(MediaData::Type::AUDIO_DATA, aConfig.mMimeType,
aFormat, aCallback)
, mConfig(aConfig)
{
JNIEnv* const env = jni::GetEnvForThread();
bool formatHasCSD = false;
NS_ENSURE_SUCCESS_VOID(aFormat->ContainsKey(NS_LITERAL_STRING("csd-0"), &formatHasCSD));
if (!formatHasCSD && aConfig.mCodecSpecificConfig->Length() >= 2) {
jni::ByteBuffer::LocalRef buffer(env);
buffer = jni::ByteBuffer::New(
aConfig.mCodecSpecificConfig->Elements(),
aConfig.mCodecSpecificConfig->Length());
NS_ENSURE_SUCCESS_VOID(aFormat->SetByteBuffer(NS_LITERAL_STRING("csd-0"),
buffer));
}
}
RefPtr<InitPromise> Init() override
{
// Register native methods.
JavaCallbacksSupport::Init();
mJavaCallbacks = CodecProxy::NativeCallbacks::New();
JavaCallbacksSupport::AttachNative(mJavaCallbacks,
mozilla::MakeUnique<CallbacksSupport>(this, mCallback));
mJavaDecoder = CodecProxy::Create(mFormat, nullptr, mJavaCallbacks);
if (mJavaDecoder == nullptr) {
return InitPromise::CreateAndReject(NS_ERROR_DOM_MEDIA_FATAL_ERR, __func__);
}
return InitPromise::CreateAndResolve(TrackInfo::kAudioTrack, __func__);
}
private:
class CallbacksSupport final : public JavaCallbacksSupport
{
public:
CallbacksSupport(RemoteAudioDecoder* aDecoder, MediaDataDecoderCallback* aCallback)
: JavaCallbacksSupport(aCallback)
, mDecoder(aDecoder)
{}
virtual ~CallbacksSupport() {}
void HandleOutput(Sample::Param aSample) override
{
BufferInfo::LocalRef info = aSample->Info();
int32_t flags;
bool ok = NS_SUCCEEDED(info->Flags(&flags));
MOZ_ASSERT(ok);
int32_t offset;
ok |= NS_SUCCEEDED(info->Offset(&offset));
MOZ_ASSERT(ok);
int64_t presentationTimeUs;
ok |= NS_SUCCEEDED(info->PresentationTimeUs(&presentationTimeUs));
MOZ_ASSERT(ok);
int32_t size;
ok |= NS_SUCCEEDED(info->Size(&size));
MOZ_ASSERT(ok);
NS_ENSURE_TRUE_VOID(ok);
if (size > 0) {
#ifdef MOZ_SAMPLE_TYPE_S16
const int32_t numSamples = size / 2;
#else
#error We only support 16-bit integer PCM
#endif
const int32_t numFrames = numSamples / mOutputChannels;
AlignedAudioBuffer audio(numSamples);
if (!audio) {
return;
}
jni::ByteBuffer::LocalRef dest = jni::ByteBuffer::New(audio.get(), size);
aSample->WriteToByteBuffer(dest);
RefPtr<AudioData> data = new AudioData(0, presentationTimeUs,
FramesToUsecs(numFrames, mOutputSampleRate).value(),
numFrames,
Move(audio),
mOutputChannels,
mOutputSampleRate);
mDecoderCallback->Output(data);
}
if ((flags & MediaCodec::BUFFER_FLAG_END_OF_STREAM) != 0) {
mDecoderCallback->DrainComplete();
return;
}
}
void HandleOutputFormatChanged(MediaFormat::Param aFormat) override
{
aFormat->GetInteger(NS_LITERAL_STRING("channel-count"), &mOutputChannels);
AudioConfig::ChannelLayout layout(mOutputChannels);
if (!layout.IsValid()) {
mDecoderCallback->Error(MediaResult(
NS_ERROR_DOM_MEDIA_FATAL_ERR,
RESULT_DETAIL("Invalid channel layout:%d", mOutputChannels)));
return;
}
aFormat->GetInteger(NS_LITERAL_STRING("sample-rate"), &mOutputSampleRate);
LOG("Audio output format changed: channels:%d sample rate:%d", mOutputChannels, mOutputSampleRate);
}
private:
RemoteAudioDecoder* mDecoder;
int32_t mOutputChannels;
int32_t mOutputSampleRate;
};
const AudioInfo& mConfig;
};
MediaDataDecoder*
RemoteDataDecoder::CreateAudioDecoder(const AudioInfo& aConfig,
MediaFormat::Param aFormat,
MediaDataDecoderCallback* aCallback)
{
return new RemoteAudioDecoder(aConfig, aFormat, aCallback);
}
MediaDataDecoder*
RemoteDataDecoder::CreateVideoDecoder(const VideoInfo& aConfig,
MediaFormat::Param aFormat,
MediaDataDecoderCallback* aCallback,
layers::ImageContainer* aImageContainer)
{
return new RemoteVideoDecoder(aConfig, aFormat, aCallback, aImageContainer);
}
RemoteDataDecoder::RemoteDataDecoder(MediaData::Type aType,
const nsACString& aMimeType,
MediaFormat::Param aFormat,
MediaDataDecoderCallback* aCallback)
: mType(aType)
, mMimeType(aMimeType)
, mFormat(aFormat)
, mCallback(aCallback)
{
}
void
RemoteDataDecoder::Flush()
{
mJavaDecoder->Flush();
}
void
RemoteDataDecoder::Drain()
{
BufferInfo::LocalRef bufferInfo;
nsresult rv = BufferInfo::New(&bufferInfo);
NS_ENSURE_SUCCESS_VOID(rv);
bufferInfo->Set(0, 0, -1, MediaCodec::BUFFER_FLAG_END_OF_STREAM);
mJavaDecoder->Input(nullptr, bufferInfo, nullptr);
}
void
RemoteDataDecoder::Shutdown()
{
LOG("");
MOZ_ASSERT(mJavaDecoder && mJavaCallbacks);
mJavaDecoder->Release();
mJavaDecoder = nullptr;
JavaCallbacksSupport::GetNative(mJavaCallbacks)->Cancel();
mJavaCallbacks = nullptr;
mFormat = nullptr;
}
void
RemoteDataDecoder::Input(MediaRawData* aSample)
{
MOZ_ASSERT(aSample != nullptr);
jni::ByteBuffer::LocalRef bytes = jni::ByteBuffer::New(const_cast<uint8_t*>(aSample->Data()),
aSample->Size());
BufferInfo::LocalRef bufferInfo;
nsresult rv = BufferInfo::New(&bufferInfo);
if (NS_FAILED(rv)) {
mCallback->Error(MediaResult(NS_ERROR_OUT_OF_MEMORY, __func__));
return;
}
bufferInfo->Set(0, aSample->Size(), aSample->mTime, 0);
mJavaDecoder->Input(bytes, bufferInfo, GetCryptoInfoFromSample(aSample));
}
} // mozilla
@@ -1,62 +0,0 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* 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/. */
#ifndef RemoteDataDecoder_h_
#define RemoteDataDecoder_h_
#include "AndroidDecoderModule.h"
#include "FennecJNIWrappers.h"
#include "SurfaceTexture.h"
#include "TimeUnits.h"
#include "mozilla/Monitor.h"
#include "mozilla/Maybe.h"
#include <deque>
namespace mozilla {
class RemoteDataDecoder : public MediaDataDecoder {
public:
static MediaDataDecoder* CreateAudioDecoder(const AudioInfo& aConfig,
java::sdk::MediaFormat::Param aFormat,
MediaDataDecoderCallback* aCallback);
static MediaDataDecoder* CreateVideoDecoder(const VideoInfo& aConfig,
java::sdk::MediaFormat::Param aFormat,
MediaDataDecoderCallback* aCallback,
layers::ImageContainer* aImageContainer);
virtual ~RemoteDataDecoder() {}
void Flush() override;
void Drain() override;
void Shutdown() override;
void Input(MediaRawData* aSample) override;
const char* GetDescriptionName() const override
{
return "android remote decoder";
}
protected:
RemoteDataDecoder(MediaData::Type aType,
const nsACString& aMimeType,
java::sdk::MediaFormat::Param aFormat,
MediaDataDecoderCallback* aCallback);
MediaData::Type mType;
nsAutoCString mMimeType;
java::sdk::MediaFormat::GlobalRef mFormat;
MediaDataDecoderCallback* mCallback;
java::CodecProxy::GlobalRef mJavaDecoder;
java::CodecProxy::NativeCallbacks::GlobalRef mJavaCallbacks;
};
} // namespace mozilla
#endif
-10
View File
@@ -80,16 +80,6 @@ if CONFIG['MOZ_APPLEMEDIA']:
include('/ipc/chromium/chromium-config.mozbuild')
if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'android':
EXPORTS += [
'android/AndroidDecoderModule.h',
]
SOURCES += [
'android/AndroidDecoderModule.cpp',
'android/MediaCodecDataDecoder.cpp',
'android/RemoteDataDecoder.cpp',
]
FINAL_LIBRARY = 'xul'
if CONFIG['GNU_CXX']:
+11 -10
View File
@@ -42,19 +42,20 @@ ReverbInputBuffer::ReverbInputBuffer(size_t length)
void ReverbInputBuffer::write(const float* sourceP, size_t numberOfFrames)
{
size_t bufferLength = m_buffer.Length();
bool isCopySafe = m_writeIndex + numberOfFrames <= bufferLength;
MOZ_ASSERT(isCopySafe);
if (!isCopySafe)
return;
// m_writeIndex is atomic and checked by other threads, so only touch
// it at the start and end.
size_t index = m_writeIndex;
memcpy(m_buffer.Elements() + m_writeIndex, sourceP, sizeof(float) * numberOfFrames);
size_t bufferLength = m_buffer.Length();
size_t newIndex = index + numberOfFrames;
m_writeIndex += numberOfFrames;
MOZ_ASSERT(m_writeIndex <= bufferLength);
MOZ_RELEASE_ASSERT(newIndex <= bufferLength);
if (m_writeIndex >= bufferLength)
m_writeIndex = 0;
memcpy(m_buffer.Elements() + index, sourceP, sizeof(float) * numberOfFrames);
if (newIndex >= bufferLength) {
m_writeIndex = 0;
}
}
float* ReverbInputBuffer::directReadFrom(int* readIndex, size_t numberOfFrames)
+2 -1
View File
@@ -30,6 +30,7 @@
#define ReverbInputBuffer_h
#include "nsTArray.h"
#include "mozilla/Atomics.h"
#include "mozilla/MemoryReporting.h"
namespace WebCore {
@@ -63,7 +64,7 @@ public:
private:
nsTArray<float> m_buffer;
size_t m_writeIndex;
mozilla::Atomic<size_t, mozilla::ReleaseAcquire> m_writeIndex;
};
} // namespace WebCore
+5 -1
View File
@@ -5,6 +5,7 @@
#ifndef mozilla_dom_MessagePortParent_h
#define mozilla_dom_MessagePortParent_h
#include "mozilla/WeakPtr.h"
#include "mozilla/dom/PMessagePortParent.h"
namespace mozilla {
@@ -12,7 +13,8 @@ namespace dom {
class MessagePortService;
class MessagePortParent final : public PMessagePortParent
class MessagePortParent final : public PMessagePortParent,
public SupportsWeakPtr<MessagePortParent>
{
public:
explicit MessagePortParent(const nsID& aUUID);
@@ -40,6 +42,8 @@ public:
const nsID& aDestinationUUID,
const uint32_t& aSequenceID);
MOZ_DECLARE_WEAKREFERENCE_TYPENAME(MessagePortParent)
private:
virtual bool RecvPostMessages(nsTArray<MessagePortMessage>&& aMessages)
override;
+8 -3
View File
@@ -9,6 +9,7 @@
#include "mozilla/ipc/BackgroundParent.h"
#include "mozilla/StaticPtr.h"
#include "mozilla/Unused.h"
#include "mozilla/WeakPtr.h"
#include "nsTArray.h"
using mozilla::ipc::AssertIsOnBackgroundThread;
@@ -59,7 +60,7 @@ public:
{
uint32_t mSequenceID;
// MessagePortParent keeps the service alive, and we don't want a cycle.
MessagePortParent* mParent;
WeakPtr<MessagePortParent> mParent;
};
FallibleTArray<NextParent> mNextParents;
@@ -275,9 +276,13 @@ MessagePortService::CloseAll(const nsID& aUUID, bool aForced)
data->mParent->Close();
}
for (const MessagePortServiceData::NextParent& parent : data->mNextParents) {
parent.mParent->CloseAndDelete();
for (const MessagePortServiceData::NextParent& nextParent : data->mNextParents) {
MessagePortParent* const parent = nextParent.mParent;
if (parent) {
parent->CloseAndDelete();
}
}
data->mNextParents.Clear();
nsID destinationUUID = data->mDestinationUUID;
@@ -149,8 +149,16 @@ nsContentSecurityManager::CheckFTPSubresourceLoad(nsIChannel* aChannel)
nsIPrincipal* triggeringPrincipal = loadInfo->TriggeringPrincipal();
nsCOMPtr<nsIURI> tURI;
triggeringPrincipal->GetURI(getter_AddRefs(tURI));
if (!tURI) {
// We don't have a triggering principal URI, meaning this isn't actually
// a subresource, but rather a top-level document, i.e. something we can
// display in-browser and might be saving as-is. Allow the load.
return NS_OK;
}
bool isTrigFtpURI = (NS_SUCCEEDED(tURI->SchemeIs("ftp", &isTrigFtpURI)) && isTrigFtpURI);
if (isTrigFtpURI) {
// The document loading this resource is also on FTP, satisfying the SOP.
// Allow the load.
return NS_OK;
}
@@ -496,8 +496,6 @@ var interfaceNamesInGlobalScope =
"HTMLMediaElement",
// IMPORTANT: Do not change this list without review from a DOM peer!
"HTMLMenuElement",
// IMPORTANT: Do not change this list without review from a DOM peer!
"HTMLMenuItemElement",
// IMPORTANT: Do not change this list without review from a DOM peer!
"HTMLMetaElement",
// IMPORTANT: Do not change this list without review from a DOM peer!
@@ -71,7 +71,6 @@
['map', 'Map'],
['mark', ''],
['menu', 'Menu'],
['menuitem', 'MenuItem'],
['meta', 'Meta'],
['meter', 'Meter'],
['nav', ''],
+1 -1
View File
@@ -23,6 +23,6 @@ interface Animatable {
[Func="nsDocument::IsElementAnimateEnabled", Throws]
Animation animate(object? keyframes,
optional UnrestrictedDoubleOrKeyframeAnimationOptions options);
[Func="nsDocument::IsWebAnimationsEnabled"]
[Func="nsDocument::IsWebAnimationsGetAnimationsEnabled"]
sequence<Animation> getAnimations(optional AnimationFilter filter);
};
+1 -1
View File
@@ -19,7 +19,7 @@ interface Animation : EventTarget {
attribute DOMString id;
[Func="nsDocument::IsWebAnimationsEnabled", Pure]
attribute AnimationEffectReadOnly? effect;
[Func="nsDocument::IsWebAnimationsEnabled"]
[Func="nsDocument::AreWebAnimationsTimelinesEnabled"]
attribute AnimationTimeline? timeline;
[BinaryName="startTimeAsDouble"]
attribute double? startTime;
+1 -1
View File
@@ -10,7 +10,7 @@
* liability, trademark and document use rules apply.
*/
[Func="nsDocument::IsWebAnimationsEnabled"]
[Func="nsDocument::AreWebAnimationsTimelinesEnabled"]
interface AnimationTimeline {
[BinaryName="currentTimeAsDouble"]
readonly attribute double? currentTime;
+1 -1
View File
@@ -15,7 +15,7 @@
// this interface.
// What we implement here is a minimal subset of the two definitions which we
// ship behind a pref until the specification issues have been resolved.
[Func="nsDocument::IsWebAnimationsEnabled"]
[Func="nsDocument::IsWebAnimationsGetAnimationsEnabled"]
interface CSSPseudoElement {
readonly attribute DOMString type;
readonly attribute Element parentElement;
+2 -2
View File
@@ -312,9 +312,9 @@ partial interface Document {
// http://w3c.github.io/web-animations/#extensions-to-the-document-interface
partial interface Document {
[Func="nsDocument::IsWebAnimationsEnabled"]
[Func="nsDocument::AreWebAnimationsTimelinesEnabled"]
readonly attribute DocumentTimeline timeline;
[Func="nsDocument::IsWebAnimationsEnabled"]
[Func="nsDocument::IsWebAnimationsGetAnimationsEnabled"]
sequence<Animation> getAnimations();
};
+1 -1
View File
@@ -14,7 +14,7 @@ dictionary DocumentTimelineOptions {
DOMHighResTimeStamp originTime = 0;
};
[Func="nsDocument::IsWebAnimationsEnabled",
[Func="nsDocument::AreWebAnimationsTimelinesEnabled",
Constructor (optional DocumentTimelineOptions options)]
interface DocumentTimeline : AnimationTimeline {
};
+1
View File
@@ -82,6 +82,7 @@ interface GlobalEventHandlers {
attribute EventHandler onseeked;
attribute EventHandler onseeking;
attribute EventHandler onselect;
[Pref="dom.menuitem.enabled"]
attribute EventHandler onshow;
//(Not implemented)attribute EventHandler onsort;
attribute EventHandler onstalled;
+1 -3
View File
@@ -49,10 +49,8 @@ interface HTMLElement : Element {
attribute DOMString contentEditable;
[Pure]
readonly attribute boolean isContentEditable;
[Pure]
[Pure, Pref="dom.menuitem.enabled"]
readonly attribute HTMLMenuElement? contextMenu;
//[SetterThrows]
// attribute HTMLMenuElement? contextMenu;
[CEReactions, SetterThrows, Pure]
attribute boolean spellcheck;
+2 -2
View File
@@ -17,9 +17,9 @@ interface MenuBuilder;
// http://www.whatwg.org/specs/web-apps/current-work/#the-menu-element
[HTMLConstructor]
interface HTMLMenuElement : HTMLElement {
[CEReactions, SetterThrows]
[CEReactions, SetterThrows, Pref="dom.menuitem.enabled"]
attribute DOMString type;
[CEReactions, SetterThrows]
[CEReactions, SetterThrows, Pref="dom.menuitem.enabled"]
attribute DOMString label;
};
+1 -1
View File
@@ -12,7 +12,7 @@
*/
// http://www.whatwg.org/specs/web-apps/current-work/#the-menuitem-element
[HTMLConstructor]
[HTMLConstructor, Pref="dom.menuitem.enabled"]
interface HTMLMenuItemElement : HTMLElement {
[CEReactions, SetterThrows]
attribute DOMString type;
+1 -1
View File
@@ -6392,7 +6392,7 @@ WorkerPrivate::GarbageCollectInternal(JSContext* aCx, bool aShrinking,
if (aShrinking || aCollectChildren) {
JS::PrepareForFullGC(aCx);
if (aShrinking) {
if (aShrinking && mSyncLoopStack.IsEmpty()) {
JS::GCForReason(aCx, GC_SHRINK, JS::gcreason::DOM_WORKER);
if (!aCollectChildren) {
@@ -27,7 +27,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=1135764
}
addLoadEvent(function() {
SpecialPowers.pushPrefEnv(
{ "set": [[ "dom.animations-api.core.enabled", true]] },
{ "set": [[ "dom.animations-api.timelines.enabled", true]] },
function() {
var ifr = document.querySelector("iframe");
ifr.onload = function() {
-11
View File
@@ -16,9 +16,6 @@
#endif
#include "mozilla/Tuple.h"
#if defined(MOZ_WIDGET_ANDROID)
#include "nsDebug.h"
#endif
#include "Point.h"
#include "BaseRect.h"
#include "Matrix.h"
@@ -141,9 +138,6 @@ struct BasicLogger
// in the appropriate places in that method.
static bool ShouldOutputMessage(int aLevel) {
if (LoggingPrefs::sGfxLogLevel >= aLevel) {
#if defined(MOZ_WIDGET_ANDROID)
return true;
#else
#if defined(MOZ_LOGGING)
if (MOZ_LOG_TEST(GetGFX2DLog(), PRLogLevelForLevel(aLevel))) {
return true;
@@ -153,7 +147,6 @@ struct BasicLogger
(aLevel < LOG_DEBUG)) {
return true;
}
#endif
}
return false;
}
@@ -174,9 +167,6 @@ struct BasicLogger
// make the corresponding change in the ShouldOutputMessage method
// above.
if (LoggingPrefs::sGfxLogLevel >= aLevel) {
#if defined(MOZ_WIDGET_ANDROID)
printf_stderr("%s%s", aString.c_str(), aNoNewline ? "" : "\n");
#else
#if defined(MOZ_LOGGING)
if (MOZ_LOG_TEST(GetGFX2DLog(), PRLogLevelForLevel(aLevel))) {
PR_LogPrint("%s%s", aString.c_str(), aNoNewline ? "" : "\n");
@@ -186,7 +176,6 @@ struct BasicLogger
(aLevel < LOG_DEBUG)) {
printf("%s%s", aString.c_str(), aNoNewline ? "" : "\n");
}
#endif
}
}
};
+1 -1
View File
@@ -303,7 +303,7 @@ SkBitmap ImageOperations::ResizeSubpixel(const SkBitmap& source,
return result;
#else
return SkBitmap();
#endif // OS_POSIX && !OS_MACOSX && !defined(OS_ANDROID)
#endif // OS_POSIX && !OS_MACOSX
}
// static
+2 -2
View File
@@ -201,12 +201,12 @@ FINAL_LIBRARY = 'xul'
for var in ('USE_CAIRO', 'MOZ2D_HAS_MOZ_CAIRO'):
DEFINES[var] = True
if CONFIG['MOZ_WIDGET_TOOLKIT'] in ('android', 'gtk2', 'gtk3'):
if CONFIG['MOZ_WIDGET_TOOLKIT'] in ('gtk2', 'gtk3'):
DEFINES['MOZ_ENABLE_FREETYPE'] = True
CXXFLAGS += CONFIG['MOZ_CAIRO_CFLAGS']
if CONFIG['MOZ_WIDGET_TOOLKIT'] in ('android', 'gtk2', 'gtk3'):
if CONFIG['MOZ_WIDGET_TOOLKIT'] in ('gtk2', 'gtk3'):
CXXFLAGS += CONFIG['CAIRO_FT_CFLAGS']
LOCAL_INCLUDES += CONFIG['SKIA_INCLUDES']
+8
View File
@@ -172,6 +172,14 @@ EXPORTS.angle.KHR += [ 'include/KHR/khrplatform.h' ]
LOCAL_INCLUDES += [ 'include', 'src', 'src/common/third_party/numerics' ]
if CONFIG['GKMEDIAS_SHARED_LIBRARY']:
NO_VISIBILITY_FLAGS = True
# This tells ANGLE to build the translator with declspec(dllexport) on Windows
# which we need to get these symbols exported from gkmedias
DEFINES['COMPONENT_BUILD'] = True
DEFINES['ANGLE_TRANSLATOR_IMPLEMENTATION'] = True
# We allow warnings for third-party code that can be updated from upstream.
ALLOW_COMPILER_WARNINGS = True
-5
View File
@@ -242,11 +242,6 @@ if CONFIG['CLANG_CL']:
'-Wno-unused-variable',
]
# See bug 386897.
if CONFIG['GNU_CC'] and CONFIG['OS_TARGET'] == 'Android' and CONFIG['MOZ_OPTIMIZE']:
CFLAGS += ['-O2']
CXXFLAGS += ['-O2']
if CONFIG['MOZ_X11']:
CFLAGS += CONFIG['XCFLAGS']
-4
View File
@@ -156,7 +156,3 @@ if CONFIG['CLANG_CL']:
CFLAGS += [
'-Wno-unused-variable',
]
# See bug 386897.
if CONFIG['OS_TARGET'] == 'Android' and CONFIG['MOZ_OPTIMIZE']:
CFLAGS += ['-O2']
-10
View File
@@ -94,16 +94,6 @@ PIXMAN_BEGIN_DECLS
#if defined (_SVR4) || defined (SVR4) || defined (__OpenBSD__) || defined (_sgi) || defined (__sun) || defined (sun) || defined (__digital__) || defined (__HP_cc)
# include <inttypes.h>
/* VS 2010 (_MSC_VER 1600) has stdint.h */
#elif defined (_MSC_VER) && _MSC_VER < 1600
typedef __int8 int8_t;
typedef unsigned __int8 uint8_t;
typedef __int16 int16_t;
typedef unsigned __int16 uint16_t;
typedef __int32 int32_t;
typedef unsigned __int32 uint32_t;
typedef __int64 int64_t;
typedef unsigned __int64 uint64_t;
#else
# include <stdint.h>
#endif
-260
View File
@@ -1,260 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
// vim:set ts=2 sts=2 sw=2 et cin:
/* This Source Code Form is subject to the terms of the Mozilla Public
* 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/. */
#ifdef MOZ_WIDGET_ANDROID
#include <map>
#include <android/native_window_jni.h>
#include <android/log.h>
#include "AndroidSurfaceTexture.h"
#include "gfxImageSurface.h"
#include "gfxPrefs.h"
#include "AndroidBridge.h"
#include "nsThreadUtils.h"
#include "mozilla/gfx/Matrix.h"
#include "GeneratedJNINatives.h"
#include "GLContext.h"
using namespace mozilla;
namespace mozilla {
namespace gl {
class AndroidSurfaceTexture::Listener
: public java::SurfaceTextureListener::Natives<Listener>
{
using Base = java::SurfaceTextureListener::Natives<Listener>;
const nsCOMPtr<nsIRunnable> mCallback;
public:
using Base::AttachNative;
using Base::DisposeNative;
Listener(nsIRunnable* aCallback) : mCallback(aCallback) {}
void OnFrameAvailable()
{
if (NS_IsMainThread()) {
mCallback->Run();
return;
}
NS_DispatchToMainThread(mCallback);
}
};
already_AddRefed<AndroidSurfaceTexture>
AndroidSurfaceTexture::Create()
{
return Create(nullptr, 0);
}
already_AddRefed<AndroidSurfaceTexture>
AndroidSurfaceTexture::Create(GLContext* aContext, GLuint aTexture)
{
RefPtr<AndroidSurfaceTexture> st = new AndroidSurfaceTexture();
if (!st->Init(aContext, aTexture)) {
printf_stderr("Failed to initialize AndroidSurfaceTexture");
st = nullptr;
}
return st.forget();
}
nsresult
AndroidSurfaceTexture::Attach(GLContext* aContext, PRIntervalTime aTimeout)
{
MonitorAutoLock lock(mMonitor);
if (mAttachedContext == aContext) {
NS_WARNING("Tried to attach same GLContext to AndroidSurfaceTexture");
return NS_OK;
}
if (!CanDetach()) {
return NS_ERROR_NOT_AVAILABLE;
}
while (mAttachedContext) {
// Wait until it's detached (or we time out)
if (NS_FAILED(lock.Wait(aTimeout))) {
return NS_ERROR_NOT_AVAILABLE;
}
}
MOZ_ASSERT(aContext->IsOwningThreadCurrent(), "Trying to attach GLContext from different thread");
aContext->fGenTextures(1, &mTexture);
if (NS_FAILED(mSurfaceTexture->AttachToGLContext(mTexture))) {
return NS_ERROR_NOT_AVAILABLE;
}
mAttachedContext = aContext;
mAttachedContext->MakeCurrent();
return NS_OK;
}
nsresult
AndroidSurfaceTexture::Detach()
{
MonitorAutoLock lock(mMonitor);
if (!CanDetach() ||
!mAttachedContext ||
!mAttachedContext->IsOwningThreadCurrent())
{
return NS_ERROR_FAILURE;
}
mAttachedContext->MakeCurrent();
mSurfaceTexture->DetachFromGLContext();
mTexture = 0;
mAttachedContext = nullptr;
lock.NotifyAll();
return NS_OK;
}
bool
AndroidSurfaceTexture::CanDetach() const
{
// The API for attach/detach only exists on 16+, and PowerVR has some sort of
// fencing issue. Additionally, attach/detach seems to be busted on at least
// some Mali adapters (400MP2 for sure, bug 1131793)
return AndroidBridge::Bridge()->GetAPIVersion() >= 16 &&
(!mAttachedContext || mAttachedContext->Vendor() != GLVendor::Imagination) &&
(!mAttachedContext || mAttachedContext->Vendor() != GLVendor::ARM /* Mali */) &&
gfxPrefs::SurfaceTextureDetachEnabled();
}
bool
AndroidSurfaceTexture::Init(GLContext* aContext, GLuint aTexture)
{
if (!aTexture && !CanDetach()) {
// We have no texture and cannot initialize detached, bail out
return false;
}
if (NS_WARN_IF(NS_FAILED(
java::sdk::SurfaceTexture::New(aTexture, ReturnTo(&mSurfaceTexture))))) {
return false;
}
if (!aTexture) {
mSurfaceTexture->DetachFromGLContext();
}
mAttachedContext = aContext;
if (NS_WARN_IF(NS_FAILED(
java::sdk::Surface::New(mSurfaceTexture, ReturnTo(&mSurface))))) {
return false;
}
mNativeWindow = ANativeWindow_fromSurface(jni::GetEnvForThread(),
mSurface.Get());
MOZ_ASSERT(mNativeWindow, "Failed to create native window from surface");
return true;
}
AndroidSurfaceTexture::AndroidSurfaceTexture()
: mTexture(0)
, mSurfaceTexture()
, mSurface()
, mAttachedContext(nullptr)
, mMonitor("AndroidSurfaceTexture")
{
}
AndroidSurfaceTexture::~AndroidSurfaceTexture()
{
if (mSurfaceTexture) {
SetFrameAvailableCallback(nullptr);
mSurfaceTexture = nullptr;
}
if (mNativeWindow) {
ANativeWindow_release(mNativeWindow);
mNativeWindow = nullptr;
}
}
void
AndroidSurfaceTexture::UpdateTexImage()
{
mSurfaceTexture->UpdateTexImage();
}
void
AndroidSurfaceTexture::GetTransformMatrix(gfx::Matrix4x4& aMatrix) const
{
JNIEnv* const env = jni::GetEnvForThread();
auto jarray = jni::FloatArray::LocalRef::Adopt(env, env->NewFloatArray(16));
mSurfaceTexture->GetTransformMatrix(jarray);
jfloat* array = env->GetFloatArrayElements(jarray.Get(), nullptr);
aMatrix._11 = array[0];
aMatrix._12 = array[1];
aMatrix._13 = array[2];
aMatrix._14 = array[3];
aMatrix._21 = array[4];
aMatrix._22 = array[5];
aMatrix._23 = array[6];
aMatrix._24 = array[7];
aMatrix._31 = array[8];
aMatrix._32 = array[9];
aMatrix._33 = array[10];
aMatrix._34 = array[11];
aMatrix._41 = array[12];
aMatrix._42 = array[13];
aMatrix._43 = array[14];
aMatrix._44 = array[15];
env->ReleaseFloatArrayElements(jarray.Get(), array, 0);
}
void
AndroidSurfaceTexture::SetFrameAvailableCallback(nsIRunnable* aRunnable)
{
java::SurfaceTextureListener::LocalRef newListener;
if (aRunnable) {
newListener = java::SurfaceTextureListener::New();
Listener::AttachNative(newListener, MakeUnique<Listener>(aRunnable));
}
if (aRunnable || mListener) {
MOZ_ALWAYS_TRUE(NS_SUCCEEDED(
mSurfaceTexture->SetOnFrameAvailableListener(newListener)));
}
if (mListener) {
Listener::DisposeNative(java::SurfaceTextureListener::LocalRef(
newListener.Env(), mListener));
}
mListener = newListener;
}
void
AndroidSurfaceTexture::SetDefaultSize(mozilla::gfx::IntSize size)
{
mSurfaceTexture->SetDefaultBufferSize(size.width, size.height);
}
} // gl
} // mozilla
#endif // MOZ_WIDGET_ANDROID
-107
View File
@@ -1,107 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
// vim:set ts=2 sts=2 sw=2 et cin:
/* This Source Code Form is subject to the terms of the Mozilla Public
* 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/. */
#ifndef AndroidSurfaceTexture_h__
#define AndroidSurfaceTexture_h__
#ifdef MOZ_WIDGET_ANDROID
#include <jni.h>
#include <android/native_window.h>
#include "nsIRunnable.h"
#include "gfxPlatform.h"
#include "GLDefs.h"
#include "mozilla/gfx/2D.h"
#include "mozilla/gfx/MatrixFwd.h"
#include "mozilla/Monitor.h"
#include "GeneratedJNIWrappers.h"
#include "SurfaceTexture.h"
namespace mozilla {
namespace gl {
class GLContext;
/**
* This class is a wrapper around Android's SurfaceTexture class.
* Usage is pretty much exactly like the Java class, so see
* the Android documentation for details.
*/
class AndroidSurfaceTexture {
NS_INLINE_DECL_THREADSAFE_REFCOUNTING(AndroidSurfaceTexture)
public:
// The SurfaceTexture is created in an attached state. This method requires
// Android Ice Cream Sandwich.
static already_AddRefed<AndroidSurfaceTexture> Create(GLContext* aGLContext, GLuint aTexture);
// Here the SurfaceTexture will be created in a detached state. You must call
// Attach() with the GLContext you wish to composite with. It must be done
// on the thread where that GLContext is current. This method requires
// Android Jelly Bean.
static already_AddRefed<AndroidSurfaceTexture> Create();
// If we are on Jelly Bean, the SurfaceTexture can be detached and reattached
// to allow consumption from different GLContexts. It is recommended to only
// attach while you are consuming in order to allow this.
//
// Only one GLContext may be attached at any given time. If another is already
// attached, we try to wait for it to become detached.
nsresult Attach(GLContext* aContext, PRIntervalTime aTiemout = PR_INTERVAL_NO_TIMEOUT);
nsresult Detach();
// Ability to detach is based on API version (16+), and we also block PowerVR
// since it has some type of fencing problem. Bug 1100126.
bool CanDetach() const;
GLContext* AttachedContext() const { return mAttachedContext; }
ANativeWindow* NativeWindow() const {
return mNativeWindow;
}
// This attaches the updated data to the TEXTURE_EXTERNAL target
void UpdateTexImage();
void GetTransformMatrix(mozilla::gfx::Matrix4x4& aMatrix) const;
void SetDefaultSize(mozilla::gfx::IntSize size);
// The callback is guaranteed to be called on the main thread even
// if the upstream callback is received on a different thread
void SetFrameAvailableCallback(nsIRunnable* aRunnable);
GLuint Texture() const { return mTexture; }
const java::sdk::Surface::Ref& JavaSurface() const { return mSurface; }
private:
class Listener;
AndroidSurfaceTexture();
~AndroidSurfaceTexture();
bool Init(GLContext* aContext, GLuint aTexture);
GLuint mTexture;
java::sdk::SurfaceTexture::GlobalRef mSurfaceTexture;
java::sdk::Surface::GlobalRef mSurface;
java::SurfaceTextureListener::GlobalRef mListener;
GLContext* mAttachedContext;
ANativeWindow* mNativeWindow;
Monitor mMonitor;
};
}
}
#endif
#endif
+1 -119
View File
@@ -14,12 +14,6 @@
#include "mozilla/gfx/Matrix.h"
#include "mozilla/UniquePtr.h"
#ifdef MOZ_WIDGET_ANDROID
#include "AndroidSurfaceTexture.h"
#include "GLImages.h"
#include "GLLibraryEGL.h"
#endif
#ifdef XP_MACOSX
#include "MacIOSurfaceImage.h"
#include "GLContextCGL.h"
@@ -146,26 +140,6 @@ GLBlitHelper::InitTexQuadProgram(BlitType target)
vTexCoord * uTexCoordMult); \n\
} \n\
";
#ifdef ANDROID /* MOZ_WIDGET_ANDROID */
const char kTexExternalBlit_FragShaderSource[] = "\
#version 100 \n\
#extension GL_OES_EGL_image_external : require \n\
#ifdef GL_FRAGMENT_PRECISION_HIGH \n\
precision highp float; \n\
#else \n\
precision mediump float; \n\
#endif \n\
varying vec2 vTexCoord; \n\
uniform mat4 uTextureTransform; \n\
uniform samplerExternalOES uTexUnit; \n\
\n\
void main() \n\
{ \n\
gl_FragColor = texture2D(uTexUnit, \n\
(uTextureTransform * vec4(vTexCoord, 0.0, 1.0)).xy); \n\
} \n\
";
#endif
/* From Rec601:
[R] [1.1643835616438356, 0.0, 1.5960267857142858] [ Y - 16]
[G] = [1.1643835616438358, -0.3917622900949137, -0.8129676472377708] x [Cb - 128]
@@ -257,14 +231,6 @@ GLBlitHelper::InitTexQuadProgram(BlitType target)
fragShaderPtr = &mTex2DRectBlit_FragShader;
fragShaderSource = kTex2DRectBlit_FragShaderSource;
break;
#ifdef ANDROID
case ConvertSurfaceTexture:
case ConvertGralloc:
programPtr = &mTexExternalBlit_Program;
fragShaderPtr = &mTexExternalBlit_FragShader;
fragShaderSource = kTexExternalBlit_FragShaderSource;
break;
#endif
case ConvertPlanarYCbCr:
programPtr = &mTexYUVPlanarBlit_Program;
fragShaderPtr = &mTexYUVPlanarBlit_FragShader;
@@ -398,10 +364,6 @@ GLBlitHelper::InitTexQuadProgram(BlitType target)
// Cache and set attribute and uniform
mGL->fUseProgram(program);
switch (target) {
#ifdef ANDROID
case ConvertSurfaceTexture:
case ConvertGralloc:
#endif
case BlitTex2D:
case BlitTexRect:
case ConvertEGLImage: {
@@ -678,67 +640,6 @@ GLBlitHelper::BindAndUploadEGLImage(EGLImage image, GLuint target)
mGL->fEGLImageTargetTexture2D(target, image);
}
#ifdef MOZ_WIDGET_ANDROID
#define ATTACH_WAIT_MS 50
bool
GLBlitHelper::BlitSurfaceTextureImage(layers::SurfaceTextureImage* stImage)
{
AndroidSurfaceTexture* surfaceTexture = stImage->GetSurfaceTexture();
ScopedBindTextureUnit boundTU(mGL, LOCAL_GL_TEXTURE0);
if (NS_FAILED(surfaceTexture->Attach(mGL, PR_MillisecondsToInterval(ATTACH_WAIT_MS))))
return false;
// UpdateTexImage() changes the EXTERNAL binding, so save it here
// so we can restore it after.
int oldBinding = 0;
mGL->fGetIntegerv(LOCAL_GL_TEXTURE_BINDING_EXTERNAL, &oldBinding);
surfaceTexture->UpdateTexImage();
gfx::Matrix4x4 transform;
surfaceTexture->GetTransformMatrix(transform);
mGL->fUniformMatrix4fv(mTextureTransformLoc, 1, false, &transform._11);
mGL->fDrawArrays(LOCAL_GL_TRIANGLE_STRIP, 0, 4);
surfaceTexture->Detach();
mGL->fBindTexture(LOCAL_GL_TEXTURE_EXTERNAL, oldBinding);
return true;
}
bool
GLBlitHelper::BlitEGLImageImage(layers::EGLImageImage* image)
{
EGLImage eglImage = image->GetImage();
EGLSync eglSync = image->GetSync();
if (eglSync) {
EGLint status = sEGLLibrary.fClientWaitSync(EGL_DISPLAY(), eglSync, 0, LOCAL_EGL_FOREVER);
if (status != LOCAL_EGL_CONDITION_SATISFIED) {
return false;
}
}
ScopedBindTextureUnit boundTU(mGL, LOCAL_GL_TEXTURE0);
int oldBinding = 0;
mGL->fGetIntegerv(LOCAL_GL_TEXTURE_BINDING_2D, &oldBinding);
BindAndUploadEGLImage(eglImage, LOCAL_GL_TEXTURE_2D);
mGL->fDrawArrays(LOCAL_GL_TRIANGLE_STRIP, 0, 4);
mGL->fBindTexture(LOCAL_GL_TEXTURE_2D, oldBinding);
return true;
}
#endif
bool
GLBlitHelper::BlitPlanarYCbCrImage(layers::PlanarYCbCrImage* yuvImage)
{
@@ -835,16 +736,6 @@ GLBlitHelper::BlitImageToFramebuffer(layers::Image* srcImage,
srcOrigin = OriginPos::BottomLeft;
break;
#ifdef MOZ_WIDGET_ANDROID
case ImageFormat::SURFACE_TEXTURE:
type = ConvertSurfaceTexture;
srcOrigin = srcImage->AsSurfaceTextureImage()->GetOriginPos();
break;
case ImageFormat::EGLIMAGE:
type = ConvertEGLImage;
srcOrigin = srcImage->AsEGLImageImage()->GetOriginPos();
break;
#endif
#ifdef XP_MACOSX
case ImageFormat::MAC_IOSURFACE:
type = ConvertMacIOSurfaceImage;
@@ -877,14 +768,6 @@ GLBlitHelper::BlitImageToFramebuffer(layers::Image* srcImage,
return ret;
}
#ifdef MOZ_WIDGET_ANDROID
case ConvertSurfaceTexture:
return BlitSurfaceTextureImage(static_cast<layers::SurfaceTextureImage*>(srcImage));
case ConvertEGLImage:
return BlitEGLImageImage(static_cast<layers::EGLImageImage*>(srcImage));
#endif
#ifdef XP_MACOSX
case ConvertMacIOSurfaceImage:
return BlitMacIOSurfaceImage(srcImage->AsMacIOSurfaceImage());
@@ -983,8 +866,7 @@ GLBlitHelper::BlitFramebufferToTexture(GLuint srcFB, GLuint destTex,
GLenum destTarget,
bool internalFBs)
{
// On the Android 4.3 emulator, IsFramebuffer may return false incorrectly.
MOZ_ASSERT_IF(mGL->Renderer() != GLRenderer::AndroidEmulator, !srcFB || mGL->fIsFramebuffer(srcFB));
MOZ_ASSERT(!srcFB || mGL->fIsFramebuffer(srcFB));
MOZ_ASSERT(mGL->fIsTexture(destTex));
if (mGL->IsSupported(GLFeature::framebuffer_blit)) {
-5
View File
@@ -107,11 +107,6 @@ class GLBlitHelper final
void BindAndUploadEGLImage(EGLImage image, GLuint target);
bool BlitPlanarYCbCrImage(layers::PlanarYCbCrImage* yuvImage);
#ifdef MOZ_WIDGET_ANDROID
// Blit onto the current FB.
bool BlitSurfaceTextureImage(layers::SurfaceTextureImage* stImage);
bool BlitEGLImageImage(layers::EGLImageImage* eglImage);
#endif
#ifdef XP_MACOSX
bool BlitMacIOSurfaceImage(layers::MacIOSurfaceImage* ioImage);
#endif
+6 -91
View File
@@ -10,9 +10,6 @@
#include <string.h>
#include <ctype.h>
#include <vector>
#ifdef MOZ_WIDGET_ANDROID
#include <sys/mman.h>
#endif
#include "GLBlitHelper.h"
#include "GLReadTexImageHelper.h"
@@ -47,10 +44,6 @@
#include "nsCocoaFeatures.h"
#endif
#ifdef MOZ_WIDGET_ANDROID
#include "AndroidBridge.h"
#endif
namespace mozilla {
namespace gl {
@@ -234,7 +227,7 @@ ParseGLSLVersion(GLContext* gl, uint32_t* out_version)
}
if (!versionString) {
// This happens on the Android emulators. We'll just return 100
MOZ_ASSERT(false, "LOCAL_GL_SHADING_LANGUAGE_VERSION undefined, returning 100");
*out_version = 100;
return true;
}
@@ -1056,28 +1049,6 @@ GLContext::InitWithPrefixImpl(const char* prefix, bool trygl)
// prevents occasional driver crash.
mNeedsFlushBeforeDeleteFB = true;
}
#ifdef MOZ_WIDGET_ANDROID
if (mWorkAroundDriverBugs &&
(Renderer() == GLRenderer::AdrenoTM305 ||
Renderer() == GLRenderer::AdrenoTM320 ||
Renderer() == GLRenderer::AdrenoTM330) &&
AndroidBridge::Bridge()->GetAPIVersion() < 21) {
// Bug 1164027. Driver crashes when functions such as
// glTexImage2D fail due to virtual memory exhaustion.
mTextureAllocCrashesOnMapFailure = true;
}
#endif
#if MOZ_WIDGET_ANDROID
if (mWorkAroundDriverBugs &&
Renderer() == GLRenderer::SGX540 &&
AndroidBridge::Bridge()->GetAPIVersion() <= 15) {
// Bug 1288446. Driver sometimes crashes when uploading data to a
// texture if the render target has changed since the texture was
// rendered from. Calling glCheckFramebufferStatus after
// glFramebufferTexture2D prevents the crash.
mNeedsCheckAfterAttachTextureToFb = true;
}
#endif
mMaxTextureImageSize = mMaxTextureSize;
@@ -1810,17 +1781,6 @@ GLContext::InitExtensions()
MarkExtensionUnsupported(OES_EGL_sync);
}
#ifdef MOZ_WIDGET_ANDROID
if (Vendor() == GLVendor::Imagination &&
Renderer() == GLRenderer::SGX544MP &&
AndroidBridge::Bridge()->GetAPIVersion() < 21)
{
// Bug 1026404
MarkExtensionUnsupported(OES_EGL_image);
MarkExtensionUnsupported(OES_EGL_image_external);
}
#endif
if (Vendor() == GLVendor::ARM &&
(Renderer() == GLRenderer::Mali400MP ||
Renderer() == GLRenderer::Mali450MP))
@@ -1829,16 +1789,6 @@ GLContext::InitExtensions()
MarkExtensionUnsupported(OES_EGL_image_external);
}
if (Renderer() == GLRenderer::AndroidEmulator) {
// the Android emulator, which we use to run B2G reftests on,
// doesn't expose the OES_rgb8_rgba8 extension, but it seems to
// support it (tautologically, as it only runs on desktop GL).
MarkExtensionSupported(OES_rgb8_rgba8);
// there seems to be a similar issue for EXT_texture_format_BGRA8888
// on the Android 4.3 emulator
MarkExtensionSupported(EXT_texture_format_BGRA8888);
}
if (Vendor() == GLVendor::VMware &&
Renderer() == GLRenderer::GalliumLlvmpipe)
{
@@ -1857,8 +1807,8 @@ GLContext::InitExtensions()
// textures with glCompressedTexSubImage2D. Works on Intel HD 4000
// and Intel HD 5000/Iris that I tested.
// Bug 1124996: Appears to be the same on OSX Yosemite (10.10)
if (nsCocoaFeatures::OSXVersionMajor() == 10 &&
nsCocoaFeatures::OSXVersionMinor() >= 9 &&
if (nsCocoaFeatures::macOSVersionMajor() == 10 &&
nsCocoaFeatures::macOSVersionMinor() >= 9 &&
Renderer() == GLRenderer::IntelHD3000)
{
MarkExtensionUnsupported(EXT_texture_compression_s3tc);
@@ -2037,8 +1987,7 @@ GLContext::AttachBuffersToFB(GLuint colorTex, GLuint colorRB,
colorTex,
0);
} else if (colorRB) {
// On the Android 4.3 emulator, IsRenderbuffer may return false incorrectly.
MOZ_ASSERT_IF(Renderer() != GLRenderer::AndroidEmulator, fIsRenderbuffer(colorRB));
MOZ_ASSERT(fIsRenderbuffer(colorRB));
fFramebufferRenderbuffer(LOCAL_GL_FRAMEBUFFER,
LOCAL_GL_COLOR_ATTACHMENT0,
LOCAL_GL_RENDERBUFFER,
@@ -2046,7 +1995,7 @@ GLContext::AttachBuffersToFB(GLuint colorTex, GLuint colorRB,
}
if (depthRB) {
MOZ_ASSERT_IF(Renderer() != GLRenderer::AndroidEmulator, fIsRenderbuffer(depthRB));
MOZ_ASSERT(fIsRenderbuffer(depthRB));
fFramebufferRenderbuffer(LOCAL_GL_FRAMEBUFFER,
LOCAL_GL_DEPTH_ATTACHMENT,
LOCAL_GL_RENDERBUFFER,
@@ -2054,7 +2003,7 @@ GLContext::AttachBuffersToFB(GLuint colorTex, GLuint colorRB,
}
if (stencilRB) {
MOZ_ASSERT_IF(Renderer() != GLRenderer::AndroidEmulator, fIsRenderbuffer(stencilRB));
MOZ_ASSERT(fIsRenderbuffer(stencilRB));
fFramebufferRenderbuffer(LOCAL_GL_FRAMEBUFFER,
LOCAL_GL_STENCIL_ATTACHMENT,
LOCAL_GL_RENDERBUFFER,
@@ -2934,29 +2883,6 @@ GLContext::fDeleteFramebuffers(GLsizei n, const GLuint* names)
TRACKING_CONTEXT(DeletedFramebuffers(this, n, names));
}
#ifdef MOZ_WIDGET_ANDROID
/**
* Conservatively estimate whether there is enough available
* contiguous virtual address space to map a newly allocated texture.
*/
static bool
WillTextureMapSucceed(GLsizei width, GLsizei height, GLenum format, GLenum type)
{
bool willSucceed = false;
// Some drivers leave large gaps between textures, so require
// there to be double the actual size of the texture available.
size_t size = width * height * GetBytesPerTexel(format, type) * 2;
void *p = mmap(nullptr, size, PROT_NONE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
if (p != MAP_FAILED) {
willSucceed = true;
munmap(p, size);
}
return willSucceed;
}
#endif // MOZ_WIDGET_ANDROID
void
GLContext::fTexImage2D(GLenum target, GLint level, GLint internalformat,
GLsizei width, GLsizei height, GLint border,
@@ -2969,17 +2895,6 @@ GLContext::fTexImage2D(GLenum target, GLint level, GLint internalformat,
height = -1;
border = -1;
}
#if MOZ_WIDGET_ANDROID
if (mTextureAllocCrashesOnMapFailure) {
// We have no way of knowing whether this texture already has
// storage allocated for it, and therefore whether this check
// is necessary. We must therefore assume it does not and
// always perform the check.
if (!WillTextureMapSucceed(width, height, internalformat, type)) {
return;
}
}
#endif
raw_fTexImage2D(target, level, internalformat, width, height, border, format, type, pixels);
}
-13
View File
@@ -788,18 +788,10 @@ private:
static void AssertNotPassingStackBufferToTheGL(const void* ptr);
#ifdef MOZ_WIDGET_ANDROID
// Record the name of the GL call for better hang stacks on Android.
#define BEFORE_GL_CALL \
PROFILER_LABEL_FUNC( \
js::ProfileEntry::Category::GRAPHICS);\
BeforeGLCall(MOZ_FUNCTION_NAME)
#else
#define BEFORE_GL_CALL \
do { \
BeforeGLCall(MOZ_FUNCTION_NAME); \
} while (0)
#endif
#define AFTER_GL_CALL \
do { \
@@ -815,12 +807,7 @@ private:
#else // ifdef MOZ_GL_DEBUG
#ifdef MOZ_WIDGET_ANDROID
// Record the name of the GL call for better hang stacks on Android.
#define BEFORE_GL_CALL PROFILER_LABEL_FUNC(js::ProfileEntry::Category::GRAPHICS)
#else
#define BEFORE_GL_CALL do { } while (0)
#endif
#define AFTER_GL_CALL do { } while (0)
#define TRACKING_CONTEXT(a) do {} while (0)
#define ASSERT_NOT_PASSING_STACK_BUFFER_TO_GL(ptr) do {} while (0)
-83
View File
@@ -11,20 +11,7 @@
#define GET_NATIVE_WINDOW(aWidget) ((EGLNativeWindowType)aWidget->GetNativeData(NS_NATIVE_WINDOW))
#endif
#ifdef MOZ_WIDGET_ANDROID
#define GET_JAVA_SURFACE(aWidget) (aWidget->GetNativeData(NS_JAVA_SURFACE))
#endif
#if defined(XP_UNIX)
#ifdef MOZ_WIDGET_ANDROID
#include <android/native_window.h>
#include <android/native_window_jni.h>
#endif
#ifdef ANDROID
#include <android/log.h>
#define LOG(args...) __android_log_print(ANDROID_LOG_INFO, "Android" , ## args)
#endif
#define GLES2_LIB "libGLESv2.so"
#define GLES2_LIB2 "libGLESv2.so.2"
@@ -164,22 +151,8 @@ CreateSurfaceForWindow(nsIWidget* widget, const EGLConfig& config) {
EGLSurface newSurface = nullptr;
MOZ_ASSERT(widget);
#ifdef MOZ_WIDGET_ANDROID
void* javaSurface = GET_JAVA_SURFACE(widget);
if (!javaSurface) {
MOZ_CRASH("GFX: Failed to get Java surface.\n");
}
JNIEnv* const env = jni::GetEnvForThread();
ANativeWindow* const nativeWindow = ANativeWindow_fromSurface(
env, reinterpret_cast<jobject>(javaSurface));
newSurface = sEGLLibrary.fCreateWindowSurface(
sEGLLibrary.fGetDisplay(EGL_DEFAULT_DISPLAY),
config, nativeWindow, 0);
ANativeWindow_release(nativeWindow);
#else
newSurface = sEGLLibrary.fCreateWindowSurface(EGL_DISPLAY(), config,
GET_NATIVE_WINDOW(widget), 0);
#endif
return newSurface;
}
@@ -229,11 +202,6 @@ GLContextEGL::~GLContextEGL()
bool
GLContextEGL::Init()
{
#if defined(ANDROID)
// We can't use LoadApitraceLibrary here because the GLContext
// expects its own handle to the GL library
if (!OpenLibrary(APITRACE_LIB))
#endif
if (!OpenLibrary(GLES2_LIB)) {
#if defined(XP_UNIX)
if (!OpenLibrary(GLES2_LIB2)) {
@@ -432,10 +400,8 @@ GLContextEGL::GetWSIInfo(nsCString* const out) const
out->AppendLiteral("\nEGL_EXTENSIONS: ");
out->Append((const char*)sEGLLibrary.fQueryString(EGL_DISPLAY(), LOCAL_EGL_EXTENSIONS));
#ifndef ANDROID // This query will crash some old android.
out->AppendLiteral("\nEGL_EXTENSIONS(nullptr): ");
out->Append((const char*)sEGLLibrary.fQueryString(nullptr, LOCAL_EGL_EXTENSIONS));
#endif
}
// hold a reference to the given surface
@@ -685,18 +651,6 @@ CreateConfig(EGLConfig* aConfig, nsIWidget* aWidget)
{
int32_t depth = gfxPlatform::GetPlatform()->GetScreenDepth();
if (!CreateConfig(aConfig, depth, aWidget)) {
#ifdef MOZ_WIDGET_ANDROID
// Bug 736005
// Android doesn't always support 16 bit so also try 24 bit
if (depth == 16) {
return CreateConfig(aConfig, 24, aWidget);
}
// Bug 970096
// Some devices that have 24 bit screens only support 16 bit OpenGL?
if (depth == 24) {
return CreateConfig(aConfig, 16, aWidget);
}
#endif
return false;
} else {
return true;
@@ -771,43 +725,6 @@ GLContextProviderEGL::CreateForWindow(nsIWidget* aWidget, bool aForceAccelerated
return gl.forget();
}
#if defined(ANDROID)
EGLSurface
GLContextProviderEGL::CreateEGLSurface(void* aWindow)
{
nsCString discardFailureId;
if (!sEGLLibrary.EnsureInitialized(false, &discardFailureId)) {
MOZ_CRASH("GFX: Failed to load EGL library 4!\n");
}
EGLConfig config;
if (!CreateConfig(&config, static_cast<nsIWidget*>(aWindow))) {
MOZ_CRASH("GFX: Failed to create EGLConfig 2!\n");
}
MOZ_ASSERT(aWindow);
EGLSurface surface = sEGLLibrary.fCreateWindowSurface(EGL_DISPLAY(), config, aWindow,
0);
if (surface == EGL_NO_SURFACE) {
MOZ_CRASH("GFX: Failed to create EGLSurface 2!\n");
}
return surface;
}
void
GLContextProviderEGL::DestroyEGLSurface(EGLSurface surface)
{
nsCString discardFailureId;
if (!sEGLLibrary.EnsureInitialized(false, &discardFailureId)) {
MOZ_CRASH("GFX: Failed to load EGL library 5!\n");
}
sEGLLibrary.fDestroySurface(EGL_DISPLAY(), surface);
}
#endif // defined(ANDROID)
static void
FillContextAttribs(bool alpha, bool depth, bool stencil, bool bpp16,
bool es3, nsTArray<EGLint>* out)
-8
View File
@@ -10,9 +10,6 @@
#ifndef GL_CONTEXT_PROVIDER_NAME
#error GL_CONTEXT_PROVIDER_NAME not defined
#endif
#if defined(ANDROID)
typedef void* EGLSurface;
#endif // defined(ANDROID)
class GL_CONTEXT_PROVIDER_NAME
{
@@ -111,11 +108,6 @@ public:
static already_AddRefed<GLContext>
CreateWrappingExisting(void* aContext, void* aSurface);
#if defined(ANDROID)
static EGLSurface CreateEGLSurface(void* aWindow);
static void DestroyEGLSurface(EGLSurface surface);
#endif // defined(ANDROID)
/**
* Get a pointer to the global context, creating it if it doesn't exist.
*/
+2 -70
View File
@@ -54,46 +54,6 @@ static const char* sEGLExtensionNames[] = {
"EGL_ANGLE_platform_angle_d3d"
};
#if defined(ANDROID)
static PRLibrary* LoadApitraceLibrary()
{
// Initialization of gfx prefs here is only needed during the unit tests...
gfxPrefs::GetSingleton();
if (!gfxPrefs::UseApitrace()) {
return nullptr;
}
static PRLibrary* sApitraceLibrary = nullptr;
if (sApitraceLibrary)
return sApitraceLibrary;
nsCString logFile = Preferences::GetCString("gfx.apitrace.logfile");
if (logFile.IsEmpty()) {
logFile = "firefox.trace";
}
// The firefox process can't write to /data/local, but it can write
// to $GRE_HOME/
nsAutoCString logPath;
logPath.AppendPrintf("%s/%s", getenv("GRE_HOME"), logFile.get());
// apitrace uses the TRACE_FILE environment variable to determine where
// to log trace output to
printf_stderr("Logging GL tracing output to %s", logPath.get());
setenv("TRACE_FILE", logPath.get(), false);
printf_stderr("Attempting load of %s\n", APITRACE_LIB);
sApitraceLibrary = PR_LoadLibrary(APITRACE_LIB);
return sApitraceLibrary;
}
#endif // ANDROID
#ifdef XP_WIN
// see the comment in GLLibraryEGL::EnsureInitialized() for the rationale here.
static PRLibrary*
@@ -348,13 +308,8 @@ GLLibraryEGL::EnsureInitialized(bool forceAccel, nsACString* const out_failureId
#else // !Windows
// On non-Windows (Android) we use system copies of libEGL. We look for
// the APITrace lib, libEGL.so, and libEGL.so.1 in that order.
#if defined(ANDROID)
if (!mEGLLibrary)
mEGLLibrary = LoadApitraceLibrary();
#endif
// On non-Windows we use system copies of libEGL. We look for
// libEGL.so and libEGL.so.1 in that order.
if (!mEGLLibrary) {
printf_stderr("Attempting load of libEGL.so\n");
@@ -593,24 +548,6 @@ GLLibraryEGL::EnsureInitialized(bool forceAccel, nsACString* const out_failureId
MarkExtensionUnsupported(KHR_image_pixmap);
}
if (IsExtensionSupported(ANDROID_native_fence_sync)) {
GLLibraryLoader::SymLoadStruct nativeFenceSymbols[] = {
{ (PRFuncPtr*) &mSymbols.fDupNativeFenceFDANDROID, { "eglDupNativeFenceFDANDROID", nullptr } },
{ nullptr, { nullptr } }
};
bool success = GLLibraryLoader::LoadSymbols(mEGLLibrary,
&nativeFenceSymbols[0],
lookupFunction);
if (!success) {
NS_ERROR("EGL supports ANDROID_native_fence_sync without exposing its functions!");
MarkExtensionUnsupported(ANDROID_native_fence_sync);
mSymbols.fDupNativeFenceFDANDROID = nullptr;
}
}
mInitialized = true;
return true;
}
@@ -642,12 +579,7 @@ GLLibraryEGL::InitClientExtensions()
const char* rawExtString = nullptr;
#ifndef ANDROID
// Bug 1209612: Crashes on a number of android drivers.
// Ideally we would only blocklist this there, but for now we don't need the client
// extension list on ANDROID (we mostly need it on ANGLE), and we'd rather not crash.
rawExtString = (const char*)fQueryString(nullptr, LOCAL_EGL_EXTENSIONS);
#endif
if (!rawExtString) {
if (shouldDumpExts) {
+1 -25
View File
@@ -33,17 +33,6 @@
typedef void* EGLNativePixmapType;
typedef void* EGLNativeWindowType;
#ifdef ANDROID
// We only need to explicitly dlopen egltrace
// on android as we can use LD_PRELOAD or other tricks
// on other platforms. We look for it in /data/local
// as that's writeable by all users
//
// This should really go in GLLibraryEGL.cpp but we currently reference
// APITRACE_LIB in GLContextProviderEGL.cpp. Further refactoring
// will come in subsequent patches on Bug 732865
#define APITRACE_LIB "/data/local/tmp/egltrace.so"
#endif
#endif
#if defined(MOZ_X11)
@@ -79,28 +68,15 @@ namespace gl {
# endif
#endif
#ifdef MOZ_WIDGET_ANDROID
// Record the name of the GL call for better hang stacks on Android.
#define BEFORE_GL_CALL \
PROFILER_LABEL_FUNC( \
js::ProfileEntry::Category::GRAPHICS);\
BeforeGLCall(MOZ_FUNCTION_NAME)
#else
#define BEFORE_GL_CALL do { \
BeforeGLCall(MOZ_FUNCTION_NAME); \
} while (0)
#endif
#define AFTER_GL_CALL do { \
AfterGLCall(MOZ_FUNCTION_NAME); \
} while (0)
#else
#ifdef MOZ_WIDGET_ANDROID
// Record the name of the GL call for better hang stacks on Android.
#define BEFORE_GL_CALL PROFILER_LABEL_FUNC(js::ProfileEntry::Category::GRAPHICS)
#else
#else // !DEBUG
#define BEFORE_GL_CALL
#endif
#define AFTER_GL_CALL
#endif
-4
View File
@@ -16,14 +16,11 @@ elif 'gtk' in CONFIG['MOZ_WIDGET_TOOLKIT']:
gl_provider = 'EGL'
else:
gl_provider = 'GLX'
elif CONFIG['MOZ_WIDGET_TOOLKIT'] == 'android':
gl_provider = 'EGL'
if CONFIG['MOZ_GL_PROVIDER']:
gl_provider = CONFIG['MOZ_GL_PROVIDER']
EXPORTS += [
'AndroidSurfaceTexture.h',
'DecomposeIntoNoRepeatTriangles.h',
'EGLUtils.h',
'ForceDiscreteGPUHelperCGL.h',
@@ -118,7 +115,6 @@ elif gl_provider == 'GLX':
]
SOURCES += [
'AndroidSurfaceTexture.cpp',
'DecomposeIntoNoRepeatTriangles.cpp',
'EGLUtils.cpp',
'GfxTexturesReporter.cpp',
+7 -3
View File
@@ -57,9 +57,13 @@ SOURCES += [
'UtfCodec.cpp',
]
# tell graphite2 not to export symbols, we'll be linking it directly with
# thebes
DEFINES['GRAPHITE2_STATIC'] = True
if CONFIG['GKMEDIAS_SHARED_LIBRARY']:
NO_VISIBILITY_FLAGS = True
DEFINES['GRAPHITE2_EXPORTING'] = True
else:
# tell graphite2 not to export symbols, we'll be linking it directly with
# thebes
DEFINES['GRAPHITE2_STATIC'] = True
# We allow warnings for third-party code that can be updated from upstream.
ALLOW_COMPILER_WARNINGS = True
-10
View File
@@ -51,16 +51,6 @@
# include <inttypes.h>
#elif defined (_AIX)
# include <sys/inttypes.h>
/* VS 2010 (_MSC_VER 1600) has stdint.h */
#elif defined (_MSC_VER) && _MSC_VER < 1600
typedef __int8 int8_t;
typedef unsigned __int8 uint8_t;
typedef __int16 int16_t;
typedef unsigned __int16 uint16_t;
typedef __int32 int32_t;
typedef unsigned __int32 uint32_t;
typedef __int64 int64_t;
typedef unsigned __int64 uint64_t;
#else
# include <stdint.h>
#endif
+1 -3
View File
@@ -178,9 +178,7 @@ static int errno = 0; /* Use something better? */
# elif defined(WINAPI_FAMILY) && (WINAPI_FAMILY==WINAPI_FAMILY_PC_APP || WINAPI_FAMILY==WINAPI_FAMILY_PHONE_APP)
# define getenv(Name) NULL
# endif
# if defined(_MSC_VER) && _MSC_VER < 1900
# define snprintf _snprintf
# elif defined(_MSC_VER) && _MSC_VER >= 1900
# if defined(_MSC_VER)
# /* Covers VC++ Error for strdup being a deprecated POSIX name and to instead use _strdup instead */
# define strdup _strdup
# endif
-11
View File
@@ -28,15 +28,8 @@ Compositor::Compositor(widget::CompositorWidget* aWidget,
, mScreenRotation(ROTATION_0)
, mWidget(aWidget)
, mIsDestroyed(false)
#if defined(MOZ_WIDGET_ANDROID)
// If the default color isn't white for Fennec, there is a black
// flash before the first page of a tab is loaded.
, mClearColor(1.0, 1.0, 1.0, 1.0)
, mDefaultClearColor(1.0, 1.0, 1.0, 1.0)
#else
, mClearColor(0.0, 0.0, 0.0, 0.0)
, mDefaultClearColor(0.0, 0.0, 0.0, 0.0)
#endif
{
}
@@ -173,11 +166,7 @@ Compositor::DrawDiagnosticsInternal(DiagnosticFlags aFlags,
const gfx::Matrix4x4& aTransform,
uint32_t aFlashCounter)
{
#if defined(ANDROID)
int lWidth = 10;
#else
int lWidth = 2;
#endif
gfx::Color color;
if (aFlags & DiagnosticFlags::CONTENT) {
+4 -12
View File
@@ -1,3 +1,7 @@
/* -*- Mode: C++; indent-tabs-mode: nil; c-basic-offset: 2 -*-
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "GLImages.h"
#include "GLContext.h"
@@ -98,17 +102,5 @@ GLImage::GetAsSourceSurface()
return source.forget();
}
#ifdef MOZ_WIDGET_ANDROID
SurfaceTextureImage::SurfaceTextureImage(gl::AndroidSurfaceTexture* aSurfTex,
const gfx::IntSize& aSize,
gl::OriginPos aOriginPos)
: GLImage(ImageFormat::SURFACE_TEXTURE),
mSurfaceTexture(aSurfTex),
mSize(aSize),
mOriginPos(aOriginPos)
{
}
#endif
} // namespace layers
} // namespace mozilla
-29
View File
@@ -6,7 +6,6 @@
#ifndef GFX_GLIMAGES_H
#define GFX_GLIMAGES_H
#include "AndroidSurfaceTexture.h"
#include "GLContextTypes.h"
#include "GLTypes.h"
#include "ImageContainer.h" // for Image
@@ -60,34 +59,6 @@ private:
bool mOwns;
};
#ifdef MOZ_WIDGET_ANDROID
class SurfaceTextureImage : public GLImage {
public:
SurfaceTextureImage(gl::AndroidSurfaceTexture* aSurfTex,
const gfx::IntSize& aSize,
gl::OriginPos aOriginPos);
gfx::IntSize GetSize() override { return mSize; }
gl::AndroidSurfaceTexture* GetSurfaceTexture() const {
return mSurfaceTexture;
}
gl::OriginPos GetOriginPos() const {
return mOriginPos;
}
SurfaceTextureImage* AsSurfaceTextureImage() override {
return this;
}
private:
RefPtr<gl::AndroidSurfaceTexture> mSurfaceTexture;
gfx::IntSize mSize;
gl::OriginPos mOriginPos;
};
#endif // MOZ_WIDGET_ANDROID
} // namespace layers
} // namespace mozilla
+1 -6
View File
@@ -166,9 +166,7 @@ protected:
class GLImage;
class EGLImageImage;
class SharedRGBImage;
#ifdef MOZ_WIDGET_ANDROID
class SurfaceTextureImage;
#elif defined(XP_MACOSX)
#if defined(XP_MACOSX)
class MacIOSurfaceImage;
#endif
@@ -225,9 +223,6 @@ public:
/* Access to derived classes. */
virtual EGLImageImage* AsEGLImageImage() { return nullptr; }
virtual GLImage* AsGLImage() { return nullptr; }
#ifdef MOZ_WIDGET_ANDROID
virtual SurfaceTextureImage* AsSurfaceTextureImage() { return nullptr; }
#endif
#ifdef XP_MACOSX
virtual MacIOSurfaceImage* AsMacIOSurfaceImage() { return nullptr; }
#endif
-11
View File
@@ -396,18 +396,7 @@ AppendToString(std::stringstream& aStream, ImageFormat format,
void
print_stderr(std::stringstream& aStr)
{
#if defined(ANDROID)
// On Android logcat output is truncated to 1024 chars per line, and
// we usually use std::stringstream to build up giant multi-line gobs
// of output. So to avoid the truncation we find the newlines and
// print the lines individually.
std::string line;
while (std::getline(aStr, line)) {
printf_stderr("%s\n", line.c_str());
}
#else
printf_stderr("%s", aStr.str().c_str());
#endif
}
void
-273
View File
@@ -1,273 +0,0 @@
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "AndroidAPZ.h"
#include "AsyncPanZoomController.h"
#include "GeneratedJNIWrappers.h"
#include "gfxPrefs.h"
#include "OverscrollHandoffState.h"
#include "ViewConfiguration.h"
#define ANDROID_APZ_LOG(...)
// #define ANDROID_APZ_LOG(...) printf_stderr("ANDROID_APZ: " __VA_ARGS__)
static float sMaxFlingSpeed = 0.0f;
namespace mozilla {
namespace layers {
AndroidSpecificState::AndroidSpecificState() {
using namespace mozilla::java;
sdk::ViewConfiguration::LocalRef config;
if (sdk::ViewConfiguration::Get(GeckoAppShell::GetApplicationContext(), &config) == NS_OK) {
int32_t speed = 0;
if (config->GetScaledMaximumFlingVelocity(&speed) == NS_OK) {
sMaxFlingSpeed = (float)speed * 0.001f;
} else {
ANDROID_APZ_LOG("%p Failed to query ViewConfiguration for scaled maximum fling velocity\n", this);
}
} else {
ANDROID_APZ_LOG("%p Failed to get ViewConfiguration\n", this);
}
StackScroller::LocalRef scroller;
if (StackScroller::New(GeckoAppShell::GetApplicationContext(), &scroller) != NS_OK) {
ANDROID_APZ_LOG("%p Failed to create Android StackScroller\n", this);
return;
}
mOverScroller = scroller;
}
const float BOUNDS_EPSILON = 1.0f;
// This function is used to convert the scroll offset from a float to an integer
// suitable for using with the Android OverScroller Class.
// The Android OverScroller class (unfortunately) operates in integers instead of floats.
// When casting a float value such as 1.5 to an integer, the value is converted to 1.
// If this value represents the max scroll offset, the OverScroller class will never scroll
// to the end of the page as it will always be 0.5 pixels short. To work around this issue,
// the min and max scroll extents are floor/ceil to convert them to the nearest integer
// just outside of the actual scroll extents. This means, the starting
// scroll offset must be converted the same way so that if the frame has already been
// scrolled 1.5 pixels, it won't be snapped back when converted to an integer. This integer
// rounding error was one of several causes of Bug 1276463.
static int32_t
ClampStart(float aOrigin, float aMin, float aMax)
{
if (aOrigin <= aMin) {
return (int32_t)floor(aMin);
} else if (aOrigin >= aMax) {
return (int32_t)ceil(aMax);
}
return (int32_t)aOrigin;
}
AndroidFlingAnimation::AndroidFlingAnimation(AsyncPanZoomController& aApzc,
PlatformSpecificStateBase* aPlatformSpecificState,
const RefPtr<const OverscrollHandoffChain>& aOverscrollHandoffChain,
bool aFlingIsHandoff,
const RefPtr<const AsyncPanZoomController>& aScrolledApzc)
: mApzc(aApzc)
, mOverscrollHandoffChain(aOverscrollHandoffChain)
, mScrolledApzc(aScrolledApzc)
, mSentBounceX(false)
, mSentBounceY(false)
, mFlingDuration(0)
{
MOZ_ASSERT(mOverscrollHandoffChain);
AndroidSpecificState* state = aPlatformSpecificState->AsAndroidSpecificState();
MOZ_ASSERT(state);
mOverScroller = state->mOverScroller;
MOZ_ASSERT(mOverScroller);
// Drop any velocity on axes where we don't have room to scroll anyways
// (in this APZC, or an APZC further in the handoff chain).
// This ensures that we don't take the 'overscroll' path in Sample()
// on account of one axis which can't scroll having a velocity.
if (!mOverscrollHandoffChain->CanScrollInDirection(&mApzc, Layer::HORIZONTAL)) {
ReentrantMonitorAutoEnter lock(mApzc.mMonitor);
mApzc.mX.SetVelocity(0);
}
if (!mOverscrollHandoffChain->CanScrollInDirection(&mApzc, Layer::VERTICAL)) {
ReentrantMonitorAutoEnter lock(mApzc.mMonitor);
mApzc.mY.SetVelocity(0);
}
ParentLayerPoint velocity = mApzc.GetVelocityVector();
float scrollRangeStartX = mApzc.mX.GetPageStart().value;
float scrollRangeEndX = mApzc.mX.GetScrollRangeEnd().value;
float scrollRangeStartY = mApzc.mY.GetPageStart().value;
float scrollRangeEndY = mApzc.mY.GetScrollRangeEnd().value;
mStartOffset.x = mPreviousOffset.x = mApzc.mX.GetOrigin().value;
mStartOffset.y = mPreviousOffset.y = mApzc.mY.GetOrigin().value;
float length = velocity.Length();
if (length > 0.0f) {
mFlingDirection = velocity / length;
if ((sMaxFlingSpeed > 0.0f) && (length > sMaxFlingSpeed)) {
velocity = mFlingDirection * sMaxFlingSpeed;
}
}
mPreviousVelocity = velocity;
int32_t originX = ClampStart(mStartOffset.x, scrollRangeStartX, scrollRangeEndX);
int32_t originY = ClampStart(mStartOffset.y, scrollRangeStartY, scrollRangeEndY);
if (!state->mLastFling.IsNull()) {
// If it's been too long since the previous fling, or if the new fling's
// velocity is too low, don't allow flywheel to kick in. If we do allow
// flywheel to kick in, then we need to update the timestamp on the
// StackScroller because otherwise it might use a stale velocity.
TimeDuration flingDuration = TimeStamp::Now() - state->mLastFling;
if (flingDuration.ToMilliseconds() < gfxPrefs::APZFlingAccelInterval()
&& velocity.Length() >= gfxPrefs::APZFlingAccelMinVelocity()) {
bool unused = false;
mOverScroller->ComputeScrollOffset(flingDuration.ToMilliseconds(), &unused);
} else {
mOverScroller->ForceFinished(true);
}
}
mOverScroller->Fling(originX, originY,
// Android needs the velocity in pixels per second and it is in pixels per ms.
(int32_t)(velocity.x * 1000.0f), (int32_t)(velocity.y * 1000.0f),
(int32_t)floor(scrollRangeStartX), (int32_t)ceil(scrollRangeEndX),
(int32_t)floor(scrollRangeStartY), (int32_t)ceil(scrollRangeEndY),
0, 0, 0);
state->mLastFling = TimeStamp::Now();
}
/**
* Advances a fling by an interpolated amount based on the Android OverScroller.
* This should be called whenever sampling the content transform for this
* frame. Returns true if the fling animation should be advanced by one frame,
* or false if there is no fling or the fling has ended.
*/
bool
AndroidFlingAnimation::DoSample(FrameMetrics& aFrameMetrics,
const TimeDuration& aDelta)
{
bool shouldContinueFling = true;
mFlingDuration += aDelta.ToMilliseconds();
mOverScroller->ComputeScrollOffset(mFlingDuration, &shouldContinueFling);
int32_t currentX = 0;
int32_t currentY = 0;
mOverScroller->GetCurrX(&currentX);
mOverScroller->GetCurrY(&currentY);
ParentLayerPoint offset((float)currentX, (float)currentY);
ParentLayerPoint preCheckedOffset(offset);
bool hitBoundX = CheckBounds(mApzc.mX, offset.x, mFlingDirection.x, &(offset.x));
bool hitBoundY = CheckBounds(mApzc.mY, offset.y, mFlingDirection.y, &(offset.y));
ParentLayerPoint velocity = mPreviousVelocity;
// Sometimes the OverScroller fails to update the offset for a frame.
// If the frame can still scroll we just use the velocity from the previous
// frame. However, if the frame can no longer scroll in the direction
// of the fling, then end the animation.
if (offset != mPreviousOffset) {
if (aDelta.ToMilliseconds() > 0) {
mOverScroller->GetCurrSpeedX(&velocity.x);
mOverScroller->GetCurrSpeedY(&velocity.y);
velocity.x /= 1000;
velocity.y /= 1000;
mPreviousVelocity = velocity;
}
} else if ((fabsf(offset.x - preCheckedOffset.x) > BOUNDS_EPSILON) || (fabsf(offset.y - preCheckedOffset.y) > BOUNDS_EPSILON)) {
// The page is no longer scrolling but the fling animation is still animating beyond the page bounds. If it goes
// beyond the BOUNDS_EPSILON then it has overflowed and will never stop. In that case, stop the fling animation.
shouldContinueFling = false;
} else if (hitBoundX && hitBoundY) {
// We can't scroll any farther along either axis.
shouldContinueFling = false;
}
float speed = velocity.Length();
// gfxPrefs::APZFlingStoppedThreshold is only used in tests.
if (!shouldContinueFling || (speed < gfxPrefs::APZFlingStoppedThreshold())) {
if (shouldContinueFling) {
// The OverScroller thinks it should continue but the speed is below
// the stopping threshold so abort the animation.
mOverScroller->AbortAnimation();
}
// This animation is going to end. If DeferHandleFlingOverscroll
// has not been called and there is still some velocity left,
// call it so that fling hand off may occur if applicable.
if (!mSentBounceX && !mSentBounceY && (speed > 0.0f)) {
DeferHandleFlingOverscroll(velocity);
}
return false;
}
mPreviousOffset = offset;
mApzc.SetVelocityVector(velocity);
aFrameMetrics.SetScrollOffset(offset / aFrameMetrics.GetZoom());
// If we hit a bounds while flinging, send the velocity so that the bounce
// animation can play.
if (hitBoundX || hitBoundY) {
ParentLayerPoint bounceVelocity = velocity;
if (!mSentBounceX && hitBoundX && fabsf(offset.x - mStartOffset.x) > BOUNDS_EPSILON) {
mSentBounceX = true;
} else {
bounceVelocity.x = 0.0f;
}
if (!mSentBounceY && hitBoundY && fabsf(offset.y - mStartOffset.y) > BOUNDS_EPSILON) {
mSentBounceY = true;
} else {
bounceVelocity.y = 0.0f;
}
if (!IsZero(bounceVelocity)) {
DeferHandleFlingOverscroll(bounceVelocity);
}
}
return true;
}
void
AndroidFlingAnimation::DeferHandleFlingOverscroll(ParentLayerPoint& aVelocity)
{
mDeferredTasks.AppendElement(
NewRunnableMethod<ParentLayerPoint,
RefPtr<const OverscrollHandoffChain>,
RefPtr<const AsyncPanZoomController>>(&mApzc,
&AsyncPanZoomController::HandleFlingOverscroll,
aVelocity,
mOverscrollHandoffChain,
mScrolledApzc));
}
bool
AndroidFlingAnimation::CheckBounds(Axis& aAxis, float aValue, float aDirection, float* aClamped)
{
if ((aDirection < 0.0f) && (aValue <= aAxis.GetPageStart().value)) {
if (aClamped) {
*aClamped = aAxis.GetPageStart().value;
}
return true;
} else if ((aDirection > 0.0f) && (aValue >= aAxis.GetScrollRangeEnd().value)) {
if (aClamped) {
*aClamped = aAxis.GetScrollRangeEnd().value;
}
return true;
}
return false;
}
} // namespace layers
} // namespace mozilla
-60
View File
@@ -1,60 +0,0 @@
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* 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/. */
#ifndef mozilla_layers_AndroidAPZ_h_
#define mozilla_layers_AndroidAPZ_h_
#include "AsyncPanZoomAnimation.h"
#include "AsyncPanZoomController.h"
#include "GeneratedJNIWrappers.h"
namespace mozilla {
namespace layers {
class AndroidSpecificState : public PlatformSpecificStateBase {
public:
AndroidSpecificState();
virtual AndroidSpecificState* AsAndroidSpecificState() override {
return this;
}
java::StackScroller::GlobalRef mOverScroller;
TimeStamp mLastFling;
};
class AndroidFlingAnimation: public AsyncPanZoomAnimation {
public:
AndroidFlingAnimation(AsyncPanZoomController& aApzc,
PlatformSpecificStateBase* aPlatformSpecificState,
const RefPtr<const OverscrollHandoffChain>& aOverscrollHandoffChain,
bool aFlingIsHandoff /* ignored */,
const RefPtr<const AsyncPanZoomController>& aScrolledApzc);
virtual bool DoSample(FrameMetrics& aFrameMetrics,
const TimeDuration& aDelta) override;
private:
void DeferHandleFlingOverscroll(ParentLayerPoint& aVelocity);
// Returns true if value is on or outside of axis bounds.
bool CheckBounds(Axis& aAxis, float aValue, float aDirection, float* aClamped);
AsyncPanZoomController& mApzc;
java::StackScroller::GlobalRef mOverScroller;
RefPtr<const OverscrollHandoffChain> mOverscrollHandoffChain;
RefPtr<const AsyncPanZoomController> mScrolledApzc;
bool mSentBounceX;
bool mSentBounceY;
long mFlingDuration;
ParentLayerPoint mStartOffset;
ParentLayerPoint mPreviousOffset;
// Unit vector in the direction of the fling.
ParentLayerPoint mFlingDirection;
ParentLayerPoint mPreviousVelocity;
};
} // namespace layers
} // namespace mozilla
#endif // mozilla_layers_AndroidAPZ_h_
+1 -13
View File
@@ -75,9 +75,6 @@
#include "SharedMemoryBasic.h" // for SharedMemoryBasic
#include "ScrollSnap.h" // for ScrollSnapUtils
#include "WheelScrollAnimation.h"
#if defined(MOZ_WIDGET_ANDROID)
#include "AndroidAPZ.h"
#endif // defined(MOZ_WIDGET_ANDROID)
#define ENABLE_APZC_LOGGING 0
// #define ENABLE_APZC_LOGGING 1
@@ -110,16 +107,10 @@ using mozilla::gfx::PointTyped;
using mozilla::gfx::RectTyped;
using mozilla::gfx::ScaleFactors2D;
// Choose between platform-specific implementations.
#ifdef MOZ_WIDGET_ANDROID
typedef WidgetOverscrollEffect OverscrollEffect;
typedef AndroidSpecificState PlatformSpecificState;
typedef AndroidFlingAnimation FlingAnimation;
#else
// Platform-specific implementations.
typedef GenericOverscrollEffect OverscrollEffect;
typedef PlatformSpecificStateBase PlatformSpecificState; // no extra state, just use the base class
typedef GenericFlingAnimation FlingAnimation;
#endif
/**
* \page APZCPrefs APZ preferences
@@ -250,7 +241,6 @@ typedef GenericFlingAnimation FlingAnimation;
* for a new sample, v(t0) is the velocity at the previous sample, f is the
* value of this pref, and (t1 - t0) is the amount of time, in milliseconds,
* that has elapsed between the two samples.\n
* NOTE: Not currently used in Android fling calculations.
*
* \li\b apz.fling_min_velocity_threshold
* Minimum velocity for a fling to actually kick off. If the user pans and lifts
@@ -271,8 +261,6 @@ typedef GenericFlingAnimation FlingAnimation;
* animation completely. This is to prevent asymptotically approaching 0
* velocity and rerendering unnecessarily.\n
* Units: screen pixels per millisecond.\n
* NOTE: Should not be set to anything
* other than 0.0 for Android except for tests to disable flings.
*
* \li\b apz.max_velocity_inches_per_ms
* Maximum velocity. Velocity will be capped at this value if a faster fling
Loaded 100 of 1396 files, more files were not shown because too many files have changed in this diff. Show more