mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Merge m-c to fx-team.
This commit is contained in:
commit
e6a295e593
@ -12,7 +12,7 @@
|
||||
<copyfile dest="Makefile" src="core/root.mk"/>
|
||||
</project>
|
||||
<project name="fake-dalvik" path="dalvik" remote="b2g" revision="ca1f327d5acc198bb4be62fa51db2c039032c9ce"/>
|
||||
<project name="gaia.git" path="gaia" remote="mozillaorg" revision="258ae6472bd0e87ae074a6b9b464273dc9cfc8d6"/>
|
||||
<project name="gaia.git" path="gaia" remote="mozillaorg" revision="ac06cfbd2baf6494ffbb668cc599e3892cd5e17b"/>
|
||||
<project name="gonk-misc" path="gonk-misc" remote="b2g" revision="78b908b493bfe0b477e3d4f6edec8c46a2c0d096"/>
|
||||
<project name="rilproxy" path="rilproxy" remote="b2g" revision="827214fcf38d6569aeb5c6d6f31cb296d1f09272"/>
|
||||
<project name="platform_hardware_ril" path="hardware/ril" remote="b2g" revision="eda08beb3ba9a159843c70ffde0f9660ec351eb9"/>
|
||||
@ -91,7 +91,7 @@
|
||||
<project name="platform/system/vold" path="system/vold" revision="919829940468066a32f403980b43f6ebfee5d314"/>
|
||||
<!-- Emulator specific things -->
|
||||
<project name="android-development" path="development" remote="b2g" revision="4e236e65a5d652a66ac32590f69f2123d17cb4ad"/>
|
||||
<project name="device_generic_goldfish" path="device/generic/goldfish" remote="b2g" revision="5be0a9c4b3c6c004786917fdb5bee248960d045b"/>
|
||||
<project name="device_generic_goldfish" path="device/generic/goldfish" remote="b2g" revision="e7e8734fdd8bf41e48a56c1c85e0f7dac60aaa9f"/>
|
||||
<project name="platform/external/iproute2" path="external/iproute2" revision="c66c5716d5335e450f7a7b71ccc6a604fb2f41d2"/>
|
||||
<project name="platform/prebuilts/gcc/linux-x86/host/i686-linux-glibc2.7-4.6" path="prebuilts/gcc/linux-x86/host/i686-linux-glibc2.7-4.6" revision="d2685281e2e54ca14d1df304867aa82c37b27162"/>
|
||||
<project name="platform/prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.7-4.6" path="prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.7-4.6" revision="627f9b20fc518937b93747a7ff1ed4f5ed46e06f"/>
|
||||
|
@ -11,7 +11,7 @@
|
||||
</project>
|
||||
<project name="rilproxy" path="rilproxy" remote="b2g" revision="827214fcf38d6569aeb5c6d6f31cb296d1f09272"/>
|
||||
<project name="fake-libdvm" path="dalvik" remote="b2g" revision="d50ae982b19f42f0b66d08b9eb306be81687869f"/>
|
||||
<project name="gaia" path="gaia" remote="mozillaorg" revision="258ae6472bd0e87ae074a6b9b464273dc9cfc8d6"/>
|
||||
<project name="gaia" path="gaia" remote="mozillaorg" revision="ac06cfbd2baf6494ffbb668cc599e3892cd5e17b"/>
|
||||
<project name="gonk-misc" path="gonk-misc" remote="b2g" revision="78b908b493bfe0b477e3d4f6edec8c46a2c0d096"/>
|
||||
<project name="moztt" path="external/moztt" remote="b2g" revision="3d5c964015967ca8c86abe6dbbebee3cb82b1609"/>
|
||||
<project name="apitrace" path="external/apitrace" remote="apitrace" revision="a314508e397c8f1814228d36259ea8708034444e"/>
|
||||
|
@ -12,7 +12,7 @@
|
||||
<copyfile dest="Makefile" src="core/root.mk"/>
|
||||
</project>
|
||||
<project name="fake-dalvik" path="dalvik" remote="b2g" revision="ca1f327d5acc198bb4be62fa51db2c039032c9ce"/>
|
||||
<project name="gaia.git" path="gaia" remote="mozillaorg" revision="258ae6472bd0e87ae074a6b9b464273dc9cfc8d6"/>
|
||||
<project name="gaia.git" path="gaia" remote="mozillaorg" revision="ac06cfbd2baf6494ffbb668cc599e3892cd5e17b"/>
|
||||
<project name="gonk-misc" path="gonk-misc" remote="b2g" revision="78b908b493bfe0b477e3d4f6edec8c46a2c0d096"/>
|
||||
<project name="rilproxy" path="rilproxy" remote="b2g" revision="827214fcf38d6569aeb5c6d6f31cb296d1f09272"/>
|
||||
<project name="platform_hardware_ril" path="hardware/ril" remote="b2g" revision="eda08beb3ba9a159843c70ffde0f9660ec351eb9"/>
|
||||
@ -91,7 +91,7 @@
|
||||
<project name="platform/system/vold" path="system/vold" revision="919829940468066a32f403980b43f6ebfee5d314"/>
|
||||
<!-- Emulator specific things -->
|
||||
<project name="android-development" path="development" remote="b2g" revision="4e236e65a5d652a66ac32590f69f2123d17cb4ad"/>
|
||||
<project name="device_generic_goldfish" path="device/generic/goldfish" remote="b2g" revision="5be0a9c4b3c6c004786917fdb5bee248960d045b"/>
|
||||
<project name="device_generic_goldfish" path="device/generic/goldfish" remote="b2g" revision="e7e8734fdd8bf41e48a56c1c85e0f7dac60aaa9f"/>
|
||||
<project name="platform/external/iproute2" path="external/iproute2" revision="c66c5716d5335e450f7a7b71ccc6a604fb2f41d2"/>
|
||||
<project name="platform/prebuilts/gcc/linux-x86/host/i686-linux-glibc2.7-4.6" path="prebuilts/gcc/linux-x86/host/i686-linux-glibc2.7-4.6" revision="d2685281e2e54ca14d1df304867aa82c37b27162"/>
|
||||
<project name="platform/prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.7-4.6" path="prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.7-4.6" revision="627f9b20fc518937b93747a7ff1ed4f5ed46e06f"/>
|
||||
|
@ -1,4 +1,4 @@
|
||||
{
|
||||
"revision": "8d15cd3ac0d07cde9ff36ce611ae47e6ef30d9b0",
|
||||
"revision": "a8b221aeef715c5d8159faa5b31f3ee15e5c3c5a",
|
||||
"repo_path": "/integration/gaia-central"
|
||||
}
|
||||
|
@ -11,7 +11,7 @@
|
||||
<copyfile dest="Makefile" src="core/root.mk"/>
|
||||
</project>
|
||||
<project name="fake-dalvik" path="dalvik" remote="b2g" revision="ca1f327d5acc198bb4be62fa51db2c039032c9ce"/>
|
||||
<project name="gaia.git" path="gaia" remote="mozillaorg" revision="258ae6472bd0e87ae074a6b9b464273dc9cfc8d6"/>
|
||||
<project name="gaia.git" path="gaia" remote="mozillaorg" revision="ac06cfbd2baf6494ffbb668cc599e3892cd5e17b"/>
|
||||
<project name="gonk-misc" path="gonk-misc" remote="b2g" revision="78b908b493bfe0b477e3d4f6edec8c46a2c0d096"/>
|
||||
<project name="rilproxy" path="rilproxy" remote="b2g" revision="827214fcf38d6569aeb5c6d6f31cb296d1f09272"/>
|
||||
<project name="librecovery" path="librecovery" remote="b2g" revision="84f2f2fce22605e17d511ff1767e54770067b5b5"/>
|
||||
|
@ -10,7 +10,7 @@
|
||||
<copyfile dest="Makefile" src="core/root.mk"/>
|
||||
</project>
|
||||
<project name="fake-dalvik" path="dalvik" remote="b2g" revision="ca1f327d5acc198bb4be62fa51db2c039032c9ce"/>
|
||||
<project name="gaia.git" path="gaia" remote="mozillaorg" revision="258ae6472bd0e87ae074a6b9b464273dc9cfc8d6"/>
|
||||
<project name="gaia.git" path="gaia" remote="mozillaorg" revision="ac06cfbd2baf6494ffbb668cc599e3892cd5e17b"/>
|
||||
<project name="gonk-misc" path="gonk-misc" remote="b2g" revision="78b908b493bfe0b477e3d4f6edec8c46a2c0d096"/>
|
||||
<project name="rilproxy" path="rilproxy" remote="b2g" revision="827214fcf38d6569aeb5c6d6f31cb296d1f09272"/>
|
||||
<project name="librecovery" path="librecovery" remote="b2g" revision="84f2f2fce22605e17d511ff1767e54770067b5b5"/>
|
||||
|
@ -12,7 +12,7 @@
|
||||
<copyfile dest="Makefile" src="core/root.mk"/>
|
||||
</project>
|
||||
<project name="fake-dalvik" path="dalvik" remote="b2g" revision="ca1f327d5acc198bb4be62fa51db2c039032c9ce"/>
|
||||
<project name="gaia.git" path="gaia" remote="mozillaorg" revision="258ae6472bd0e87ae074a6b9b464273dc9cfc8d6"/>
|
||||
<project name="gaia.git" path="gaia" remote="mozillaorg" revision="ac06cfbd2baf6494ffbb668cc599e3892cd5e17b"/>
|
||||
<project name="gonk-misc" path="gonk-misc" remote="b2g" revision="78b908b493bfe0b477e3d4f6edec8c46a2c0d096"/>
|
||||
<project name="rilproxy" path="rilproxy" remote="b2g" revision="827214fcf38d6569aeb5c6d6f31cb296d1f09272"/>
|
||||
<project name="librecovery" path="librecovery" remote="b2g" revision="84f2f2fce22605e17d511ff1767e54770067b5b5"/>
|
||||
|
@ -11,7 +11,7 @@
|
||||
<copyfile dest="Makefile" src="core/root.mk"/>
|
||||
</project>
|
||||
<project name="fake-dalvik" path="dalvik" remote="b2g" revision="ca1f327d5acc198bb4be62fa51db2c039032c9ce"/>
|
||||
<project name="gaia.git" path="gaia" remote="mozillaorg" revision="258ae6472bd0e87ae074a6b9b464273dc9cfc8d6"/>
|
||||
<project name="gaia.git" path="gaia" remote="mozillaorg" revision="ac06cfbd2baf6494ffbb668cc599e3892cd5e17b"/>
|
||||
<project name="gonk-misc" path="gonk-misc" remote="b2g" revision="78b908b493bfe0b477e3d4f6edec8c46a2c0d096"/>
|
||||
<project name="rilproxy" path="rilproxy" remote="b2g" revision="827214fcf38d6569aeb5c6d6f31cb296d1f09272"/>
|
||||
<project name="librecovery" path="librecovery" remote="b2g" revision="84f2f2fce22605e17d511ff1767e54770067b5b5"/>
|
||||
|
@ -11,7 +11,7 @@
|
||||
</project>
|
||||
<project name="rilproxy" path="rilproxy" remote="b2g" revision="827214fcf38d6569aeb5c6d6f31cb296d1f09272"/>
|
||||
<project name="fake-libdvm" path="dalvik" remote="b2g" revision="d50ae982b19f42f0b66d08b9eb306be81687869f"/>
|
||||
<project name="gaia" path="gaia" remote="mozillaorg" revision="258ae6472bd0e87ae074a6b9b464273dc9cfc8d6"/>
|
||||
<project name="gaia" path="gaia" remote="mozillaorg" revision="ac06cfbd2baf6494ffbb668cc599e3892cd5e17b"/>
|
||||
<project name="gonk-misc" path="gonk-misc" remote="b2g" revision="78b908b493bfe0b477e3d4f6edec8c46a2c0d096"/>
|
||||
<project name="moztt" path="external/moztt" remote="b2g" revision="3d5c964015967ca8c86abe6dbbebee3cb82b1609"/>
|
||||
<project name="apitrace" path="external/apitrace" remote="apitrace" revision="a314508e397c8f1814228d36259ea8708034444e"/>
|
||||
|
@ -11,7 +11,7 @@
|
||||
<copyfile dest="Makefile" src="core/root.mk"/>
|
||||
</project>
|
||||
<project name="fake-dalvik" path="dalvik" remote="b2g" revision="ca1f327d5acc198bb4be62fa51db2c039032c9ce"/>
|
||||
<project name="gaia.git" path="gaia" remote="mozillaorg" revision="258ae6472bd0e87ae074a6b9b464273dc9cfc8d6"/>
|
||||
<project name="gaia.git" path="gaia" remote="mozillaorg" revision="ac06cfbd2baf6494ffbb668cc599e3892cd5e17b"/>
|
||||
<project name="gonk-misc" path="gonk-misc" remote="b2g" revision="78b908b493bfe0b477e3d4f6edec8c46a2c0d096"/>
|
||||
<project name="rilproxy" path="rilproxy" remote="b2g" revision="827214fcf38d6569aeb5c6d6f31cb296d1f09272"/>
|
||||
<project name="librecovery" path="librecovery" remote="b2g" revision="84f2f2fce22605e17d511ff1767e54770067b5b5"/>
|
||||
|
@ -247,7 +247,7 @@ var gPrivacyPane = {
|
||||
},
|
||||
|
||||
_lastMode: null,
|
||||
_lasCheckState: null,
|
||||
_lastCheckState: null,
|
||||
updateAutostart: function PPP_updateAutostart() {
|
||||
let mode = document.getElementById("historyMode");
|
||||
let autoStart = document.getElementById("privateBrowsingAutoStart");
|
||||
@ -299,6 +299,7 @@ var gPrivacyPane = {
|
||||
} else {
|
||||
autoStart.removeAttribute('checked');
|
||||
}
|
||||
pref.value = autoStart.hasAttribute('checked');
|
||||
mode.selectedIndex = this._lastMode;
|
||||
mode.doCommand();
|
||||
|
||||
|
@ -249,7 +249,7 @@ var gPrivacyPane = {
|
||||
},
|
||||
|
||||
_lastMode: null,
|
||||
_lasCheckState: null,
|
||||
_lastCheckState: null,
|
||||
updateAutostart: function PPP_updateAutostart() {
|
||||
let mode = document.getElementById("historyMode");
|
||||
let autoStart = document.getElementById("privateBrowsingAutoStart");
|
||||
@ -301,6 +301,7 @@ var gPrivacyPane = {
|
||||
} else {
|
||||
autoStart.removeAttribute('checked');
|
||||
}
|
||||
pref.value = autoStart.hasAttribute('checked');
|
||||
mode.selectedIndex = this._lastMode;
|
||||
mode.doCommand();
|
||||
|
||||
|
@ -1,4 +1,6 @@
|
||||
[DEFAULT]
|
||||
# Crashes/timeouts on all platforms (bug 973974)
|
||||
skip-if = true
|
||||
support-files =
|
||||
head.js
|
||||
mock_console_api.html
|
||||
|
@ -66,19 +66,20 @@ function getBrowserForWindow(aContentWindow) {
|
||||
|
||||
function handleRequest(aSubject, aTopic, aData) {
|
||||
let constraints = aSubject.getConstraints();
|
||||
let contentWindow = Services.wm.getOuterWindowWithId(aSubject.windowID);
|
||||
|
||||
Services.wm.getMostRecentWindow(null).navigator.mozGetUserMediaDevices(
|
||||
contentWindow.navigator.mozGetUserMediaDevices(
|
||||
constraints,
|
||||
function (devices) {
|
||||
prompt(aSubject.windowID, aSubject.callID, constraints.audio,
|
||||
prompt(contentWindow, aSubject.callID, constraints.audio,
|
||||
constraints.video || constraints.picture, devices);
|
||||
},
|
||||
function (error) {
|
||||
// bug 827146 -- In the future, the UI should catch NO_DEVICES_FOUND
|
||||
// and allow the user to plug in a device, instead of immediately failing.
|
||||
denyRequest(aSubject.callID, error);
|
||||
}
|
||||
);
|
||||
},
|
||||
aSubject.innerWindowID);
|
||||
}
|
||||
|
||||
function denyRequest(aCallID, aError) {
|
||||
@ -90,7 +91,7 @@ function denyRequest(aCallID, aError) {
|
||||
Services.obs.notifyObservers(msg, "getUserMedia:response:deny", aCallID);
|
||||
}
|
||||
|
||||
function prompt(aWindowID, aCallID, aAudioRequested, aVideoRequested, aDevices) {
|
||||
function prompt(aContentWindow, aCallID, aAudioRequested, aVideoRequested, aDevices) {
|
||||
let audioDevices = [];
|
||||
let videoDevices = [];
|
||||
for (let device of aDevices) {
|
||||
@ -119,9 +120,8 @@ function prompt(aWindowID, aCallID, aAudioRequested, aVideoRequested, aDevices)
|
||||
return;
|
||||
}
|
||||
|
||||
let contentWindow = Services.wm.getOuterWindowWithId(aWindowID);
|
||||
let host = contentWindow.document.documentURIObject.host;
|
||||
let browser = getBrowserForWindow(contentWindow);
|
||||
let host = aContentWindow.document.documentURIObject.host;
|
||||
let browser = getBrowserForWindow(aContentWindow);
|
||||
let chromeDoc = browser.ownerDocument;
|
||||
let chromeWin = chromeDoc.defaultView;
|
||||
let stringBundle = chromeWin.gNavigatorBundle;
|
||||
|
@ -149,6 +149,8 @@ if test -z "$BUILDING_JS" -o -n "$JS_STANDALONE"; then
|
||||
ICU_CPPFLAGS="$ICU_CPPFLAGS -DUCONFIG_NO_TRANSLITERATION"
|
||||
ICU_CPPFLAGS="$ICU_CPPFLAGS -DUCONFIG_NO_REGULAR_EXPRESSIONS"
|
||||
ICU_CPPFLAGS="$ICU_CPPFLAGS -DUCONFIG_NO_BREAK_ITERATION"
|
||||
# make sure to not accidentally pick up system-icu headers
|
||||
ICU_CPPFLAGS="$ICU_CPPFLAGS -I$icudir/common -I$icudir/i18n"
|
||||
|
||||
ICU_CROSS_BUILD_OPT=""
|
||||
ICU_SRCDIR=""
|
||||
|
@ -55,6 +55,7 @@ SEARCH_PATHS = [
|
||||
'testing/mozbase/mozsystemmonitor',
|
||||
'testing/mozbase/mozinfo',
|
||||
'testing/mozbase/moztest',
|
||||
'testing/mozbase/mozversion',
|
||||
'testing/mozbase/manifestdestiny',
|
||||
'xpcom/idl-parser',
|
||||
]
|
||||
|
@ -559,6 +559,12 @@ ConvertAndWrite(const nsAString& aString,
|
||||
startCharLength = charLength;
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
if (!charLength) {
|
||||
// Nothing to write. Besides, a length 0 string has an immutable buffer, so
|
||||
// attempts to null-terminate it will crash.
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsAutoCString charXferString;
|
||||
if (!charXferString.SetLength(charLength, fallible_t()))
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
@ -1,4 +1,5 @@
|
||||
// SJS file for CSP violation report test
|
||||
// https://bugzilla.mozilla.org/show_bug.cgi?id=548193
|
||||
function handleRequest(request, response)
|
||||
{
|
||||
var query = {};
|
@ -1,4 +1,7 @@
|
||||
<html>
|
||||
<!--
|
||||
https://bugzilla.mozilla.org/show_bug.cgi?id=717511
|
||||
-->
|
||||
<body>
|
||||
<!-- these should be stopped by CSP after fixing bug 717511. :) -->
|
||||
<img src="http://example.org/tests/content/base/test/file_CSP.sjs?testid=img_bad&type=img/png"> </img>
|
@ -1,4 +1,7 @@
|
||||
<html>
|
||||
<!--
|
||||
https://bugzilla.mozilla.org/show_bug.cgi?id=717511
|
||||
-->
|
||||
<body>
|
||||
<!-- these should be stopped by CSP after fixing bug 717511. :) -->
|
||||
<img src="http://example.org/tests/content/base/test/file_CSP.sjs?testid=img2_bad&type=img/png"> </img>
|
@ -1,2 +1,5 @@
|
||||
<!--
|
||||
https://bugzilla.mozilla.org/show_bug.cgi?id=558431
|
||||
-->
|
||||
<iframe id="inner"
|
||||
src="/tests/content/base/test/file_CSP.sjs?content=%3Cdiv%20id%3D%22test%22%3Etest%20558431%3C/div%3E"></iframe>
|
@ -1,6 +1,7 @@
|
||||
// SJS file for tests for bug650386, serves file_bug650386_content.html
|
||||
// https://bugzilla.mozilla.org/show_bug.cgi?id=650386
|
||||
// This SJS file serves file_redirect_content.html
|
||||
// with a CSP that will trigger a violation and that will report it
|
||||
// to file_bug650386_report.sjs
|
||||
// to file_redirect_report.sjs
|
||||
//
|
||||
// This handles 301, 302, 303 and 307 redirects. The HTTP status code
|
||||
// returned/type of redirect to do comes from the query string
|
||||
@ -22,7 +23,7 @@ function handleRequest(request, response) {
|
||||
return;
|
||||
}
|
||||
|
||||
var csp = "default-src \'self\';report-uri http://mochi.test:8888/tests/content/base/test/file_bug650386_report.sjs?" + redirect;
|
||||
var csp = "default-src \'self\';report-uri http://mochi.test:8888/tests/content/base/test/csp/file_redirect_report.sjs?" + redirect;
|
||||
|
||||
response.setHeader("X-Content-Security-Policy", csp, false);
|
||||
|
@ -1,4 +1,5 @@
|
||||
// SJS file for tests for bug650386, this serves as CSP violation report target
|
||||
// https://bugzilla.mozilla.org/show_bug.cgi?id=650386
|
||||
// This SJS file serves as CSP violation report target
|
||||
// and issues a redirect, to make sure the browser does not post to the target
|
||||
// of the redirect, per CSP spec.
|
||||
// This handles 301, 302, 303 and 307 redirects. The HTTP status code
|
13
content/base/test/csp/file_subframe_run_js_if_allowed.html
Normal file
13
content/base/test/csp/file_subframe_run_js_if_allowed.html
Normal file
@ -0,0 +1,13 @@
|
||||
<html>
|
||||
<!--
|
||||
https://bugzilla.mozilla.org/show_bug.cgi?id=702439
|
||||
|
||||
This document is a child frame of a CSP document and the
|
||||
test verifies that it is permitted to run javascript: URLs
|
||||
if the parent has a policy that allows them.
|
||||
-->
|
||||
<body onload="document.getElementById('a').click()">
|
||||
<a id="a" href="javascript:parent.javascript_link_ran = true;
|
||||
parent.checkResult();">click</a>
|
||||
</body>
|
||||
</html>
|
@ -113,6 +113,17 @@ support-files =
|
||||
file_csp_regexp_parsing.js
|
||||
file_report_uri_missing_in_report_only_header.html
|
||||
file_report_uri_missing_in_report_only_header.html^headers^
|
||||
file_csp_report.sjs
|
||||
file_policyuri_async_fetch.html
|
||||
file_policyuri_async_fetch.html^headers^
|
||||
file_redirect_content.sjs
|
||||
file_redirect_report.sjs
|
||||
file_subframe_run_js_if_allowed.html
|
||||
file_subframe_run_js_if_allowed.html^headers^
|
||||
file_multi_policy_injection_bypass.html
|
||||
file_multi_policy_injection_bypass.html^headers^
|
||||
file_multi_policy_injection_bypass_2.html
|
||||
file_multi_policy_injection_bypass_2.html^headers^
|
||||
|
||||
[test_CSP.html]
|
||||
skip-if = toolkit == 'android' #TIMED_OUT
|
||||
@ -145,3 +156,11 @@ skip-if = toolkit == 'android' #TIMED_OUT
|
||||
[test_bug949549.html]
|
||||
[test_csp_regexp_parsing.html]
|
||||
[test_report_uri_missing_in_report_only_header.html]
|
||||
[test_csp_report.html]
|
||||
[test_policyuri_async_fetch.html]
|
||||
[test_301_redirect.html]
|
||||
[test_302_redirect.html]
|
||||
[test_303_redirect.html]
|
||||
[test_307_redirect.html]
|
||||
[test_subframe_run_js_if_allowed.html]
|
||||
[test_multi_policy_injection_bypass.html]
|
||||
|
@ -71,7 +71,7 @@ window.done = function(result) {
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
|
||||
// save this for last so that our listeners are registered.
|
||||
document.getElementById('content_iframe').src = 'file_bug650386_content.sjs?301';
|
||||
document.getElementById('content_iframe').src = 'file_redirect_content.sjs?301';
|
||||
</script>
|
||||
</pre>
|
||||
</body>
|
@ -71,7 +71,7 @@ window.done = function(result) {
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
|
||||
// save this for last so that our listeners are registered.
|
||||
document.getElementById('content_iframe').src = 'file_bug650386_content.sjs?302';
|
||||
document.getElementById('content_iframe').src = 'file_redirect_content.sjs?302';
|
||||
</script>
|
||||
</pre>
|
||||
</body>
|
@ -71,7 +71,7 @@ window.done = function(result) {
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
|
||||
// save this for last so that our listeners are registered.
|
||||
document.getElementById('content_iframe').src = 'file_bug650386_content.sjs?303';
|
||||
document.getElementById('content_iframe').src = 'file_redirect_content.sjs?303';
|
||||
</script>
|
||||
</pre>
|
||||
</body>
|
@ -71,7 +71,7 @@ window.done = function(result) {
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
|
||||
// save this for last so that our listeners are registered.
|
||||
document.getElementById('content_iframe').src = 'file_bug650386_content.sjs?307';
|
||||
document.getElementById('content_iframe').src = 'file_redirect_content.sjs?307';
|
||||
</script>
|
||||
</pre>
|
||||
</body>
|
@ -1,7 +1,10 @@
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<!--
|
||||
https://bugzilla.mozilla.org/show_bug.cgi?id=548193
|
||||
-->
|
||||
<head>
|
||||
<title>Test for CSP JSON violation report</title>
|
||||
<title>Test for Bug 548193</title>
|
||||
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
|
||||
</head>
|
||||
@ -73,13 +76,13 @@ examiner.prototype = {
|
||||
}
|
||||
|
||||
// content file that triggers a violation report
|
||||
var testFile = "file_bug548193.sjs";
|
||||
var testFile = "file_csp_report.sjs";
|
||||
|
||||
window.checkResults = function(reportObj) {
|
||||
var cspReport = reportObj["csp-report"];
|
||||
// correct violating request
|
||||
is(cspReport["document-uri"],
|
||||
"http://mochi.test:8888/tests/content/base/test/" + testFile,
|
||||
"http://mochi.test:8888/tests/content/base/test/csp/" + testFile,
|
||||
"Incorrect violating request");
|
||||
// correct blocked-uri
|
||||
is(cspReport["blocked-uri"],
|
@ -115,8 +115,8 @@ SimpleTest.waitForExplicitFinish();
|
||||
// save this for last so that our listeners are registered.
|
||||
// ... this loads the testbed of good and bad requests.
|
||||
|
||||
document.getElementById('cspframe').src = 'file_bug717511.html';
|
||||
document.getElementById('cspframe2').src = 'file_bug717511_2.html';
|
||||
document.getElementById('cspframe').src = 'file_multi_policy_injection_bypass.html';
|
||||
document.getElementById('cspframe2').src = 'file_multi_policy_injection_bypass_2.html';
|
||||
|
||||
</script>
|
||||
</pre>
|
@ -1,7 +1,10 @@
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<!--
|
||||
https://bugzilla.mozilla.org/show_bug.cgi?id=558431
|
||||
-->
|
||||
<head>
|
||||
<title>Test for CSP async policy-uri</title>
|
||||
<title>Test for Bug 558431</title>
|
||||
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
|
||||
</head>
|
||||
@ -24,7 +27,7 @@ f.addEventListener('load', function() {
|
||||
SimpleTest.finish();
|
||||
}, false);
|
||||
// load the test frame
|
||||
f.src = "file_bug558431.html";
|
||||
f.src = "file_policyuri_async_fetch.html";
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
</script>
|
||||
</body>
|
@ -8,7 +8,7 @@ permitted to execute javascript: URLs assuming the policy
|
||||
allows this.
|
||||
-->
|
||||
<head>
|
||||
<title>Test for Bug 428847</title>
|
||||
<title>Test for Bug 702439</title>
|
||||
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
|
||||
</head>
|
||||
@ -27,6 +27,6 @@ function checkResult()
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
</script>
|
||||
<iframe id="i" src="file_bug702439.html"></iframe>
|
||||
<iframe id="i" src="file_subframe_run_js_if_allowed.html"></iframe>
|
||||
</body>
|
||||
</html>
|
@ -1,11 +0,0 @@
|
||||
<html>
|
||||
<!--
|
||||
This document is a child frame of a CSP document and the
|
||||
test verifies that it is permitted to run javascript: URLs
|
||||
if the parent has a policy that allows them.
|
||||
-->
|
||||
<body onload="document.getElementById('a').click()">
|
||||
<a id="a" href="javascript:parent.javascript_link_ran = true;
|
||||
parent.checkResult();">click</a>
|
||||
</body>
|
||||
</html>
|
@ -94,10 +94,7 @@ support-files =
|
||||
file_bug503481b_inner.html
|
||||
file_bug541937.html
|
||||
file_bug541937.xhtml
|
||||
file_bug548193.sjs
|
||||
file_bug557892.html
|
||||
file_bug558431.html
|
||||
file_bug558431.html^headers^
|
||||
file_bug562137.txt
|
||||
file_bug590812-ref.xhtml
|
||||
file_bug590812.xml
|
||||
@ -112,8 +109,6 @@ support-files =
|
||||
file_bug604660-6.xsl
|
||||
file_bug622088.sjs
|
||||
file_bug622088_inner.html
|
||||
file_bug650386_content.sjs
|
||||
file_bug650386_report.sjs
|
||||
file_bug675121.sjs
|
||||
file_bug687859-16.js
|
||||
file_bug687859-16.js^headers^
|
||||
@ -124,16 +119,11 @@ support-files =
|
||||
file_bug687859-http.js^headers^
|
||||
file_bug687859-inherit.js
|
||||
file_bug692434.xml
|
||||
file_bug702439.html
|
||||
file_bug707142_baseline.json
|
||||
file_bug707142_bom.json
|
||||
file_bug707142_utf-16.json
|
||||
file_bug708620-2.html
|
||||
file_bug708620.html
|
||||
file_bug717511.html
|
||||
file_bug717511.html^headers^
|
||||
file_bug717511_2.html
|
||||
file_bug717511_2.html^headers^
|
||||
file_bug782342.txt
|
||||
file_bug787778.sjs
|
||||
file_bug804395.jar
|
||||
@ -422,11 +412,9 @@ skip-if = toolkit == 'android' #TIMED_OUT
|
||||
[test_bug544642.html]
|
||||
[test_bug545644.html]
|
||||
[test_bug545644.xhtml]
|
||||
[test_bug548193.html]
|
||||
[test_bug548463.html]
|
||||
[test_bug553896.xhtml]
|
||||
[test_bug557892.html]
|
||||
[test_bug558431.html]
|
||||
[test_bug558726.html]
|
||||
[test_bug559526.html]
|
||||
[test_bug560780.html]
|
||||
@ -465,10 +453,6 @@ skip-if = toolkit == 'android' #bug 687032
|
||||
[test_bug631615.html]
|
||||
[test_bug638112.html]
|
||||
[test_bug647518.html]
|
||||
[test_bug650386_redirect_301.html]
|
||||
[test_bug650386_redirect_302.html]
|
||||
[test_bug650386_redirect_303.html]
|
||||
[test_bug650386_redirect_307.html]
|
||||
[test_bug656283.html]
|
||||
[test_bug664916.html]
|
||||
[test_bug666604.html]
|
||||
@ -490,14 +474,11 @@ skip-if = toolkit == 'android' #bug 687032
|
||||
[test_bug696301-2.html]
|
||||
[test_bug698381.html]
|
||||
[test_bug698384.html]
|
||||
[test_bug702439.html]
|
||||
[test_bug702439.html^headers^]
|
||||
[test_bug704063.html]
|
||||
[test_bug707142.html]
|
||||
[test_bug708620.html]
|
||||
[test_bug711047.html]
|
||||
[test_bug711180.html]
|
||||
[test_bug717511.html]
|
||||
[test_bug719533.html]
|
||||
[test_bug726364.html]
|
||||
[test_bug737087.html]
|
||||
|
@ -2793,15 +2793,16 @@ HTMLInputElement::SetValueInternal(const nsAString& aValue,
|
||||
if (aSetValueChanged) {
|
||||
SetValueChanged(true);
|
||||
}
|
||||
OnValueChanged(!mParserCreating);
|
||||
|
||||
if (mType == NS_FORM_INPUT_NUMBER) {
|
||||
// This has to happen before OnValueChanged is called because that
|
||||
// method needs the new value of our frame's anon text control.
|
||||
nsNumberControlFrame* numberControlFrame =
|
||||
do_QueryFrame(GetPrimaryFrame());
|
||||
if (numberControlFrame) {
|
||||
numberControlFrame->SetValueOfAnonTextControl(value);
|
||||
}
|
||||
}
|
||||
OnValueChanged(!mParserCreating);
|
||||
}
|
||||
|
||||
// Call parent's SetAttr for color input so its control frame is notified
|
||||
@ -3633,6 +3634,20 @@ HTMLInputElement::StopNumberControlSpinnerSpin()
|
||||
void
|
||||
HTMLInputElement::StepNumberControlForUserEvent(int32_t aDirection)
|
||||
{
|
||||
if (!IsValid()) {
|
||||
// If the user has typed a value into the control and inadvertently made a
|
||||
// mistake (e.g. put a thousand separator at the wrong point) we do not
|
||||
// want to wipe out what they typed if they try to increment/decrement the
|
||||
// value. Better is to highlight the value as being invalid so that they
|
||||
// can correct what they typed.
|
||||
// We pass 'true' for UpdateValidityUIBits' aIsFocused argument regardless
|
||||
// because we need the UI to update _now_ or the user will wonder why the
|
||||
// step behavior isn't functioning.
|
||||
UpdateValidityUIBits(true);
|
||||
UpdateState(true);
|
||||
return;
|
||||
}
|
||||
|
||||
Decimal newValue = Decimal::nan(); // unchanged if value will not change
|
||||
|
||||
nsresult rv = GetValueIfStepped(aDirection, CALLED_FOR_USER_EVENT, &newValue);
|
||||
|
@ -146,10 +146,10 @@ function test() {
|
||||
|
||||
for (key of ["VK_UP", "VK_DOWN"]) {
|
||||
// Start at middle:
|
||||
oldVal = elem.value = 0;
|
||||
oldVal = elem.value = -1;
|
||||
expectedVal = expectedValAfterKeyEvent(key, elem);
|
||||
synthesizeKey(key, {});
|
||||
is(elem.value, expectedVal, "Test " + key + " for number control with value set to the midpoint (" + oldVal + ")");
|
||||
is(elem.value, expectedVal, "Test " + key + " for number control with value set between min/max (" + oldVal + ")");
|
||||
|
||||
// Same again:
|
||||
expectedVal = expectedValAfterKeyEvent(key, elem);
|
||||
@ -196,6 +196,13 @@ function test() {
|
||||
synthesizeKey(key, {});
|
||||
is(elem.value, expectedVal, "Test " + key + " for number control with value set to the midpoint and step='any' (" + oldVal + ")");
|
||||
elem.step = oldStep; // restore
|
||||
|
||||
// Test that invalid input blocks UI initiated stepping:
|
||||
oldVal = elem.value = "";
|
||||
elem.select();
|
||||
sendString("abc");
|
||||
synthesizeKey(key, {});
|
||||
is(elem.value, "", "Test " + key + " does nothing when the input is invalid");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -42,7 +42,7 @@ ValidatePlane(const VideoData::YCbCrBuffer::Plane& aPlane)
|
||||
aPlane.mStride > 0;
|
||||
}
|
||||
|
||||
#if 0
|
||||
#ifdef MOZ_WIDGET_GONK
|
||||
static bool
|
||||
IsYV12Format(const VideoData::YCbCrBuffer::Plane& aYPlane,
|
||||
const VideoData::YCbCrBuffer::Plane& aCbPlane,
|
||||
@ -103,6 +103,45 @@ VideoData* VideoData::ShallowCopyUpdateDuration(VideoData* aOther,
|
||||
return v;
|
||||
}
|
||||
|
||||
/* static */
|
||||
void VideoData::SetVideoDataToImage(PlanarYCbCrImage* aVideoImage,
|
||||
VideoInfo& aInfo,
|
||||
const YCbCrBuffer &aBuffer,
|
||||
const IntRect& aPicture,
|
||||
bool aCopyData)
|
||||
{
|
||||
if (!aVideoImage) {
|
||||
return;
|
||||
}
|
||||
const YCbCrBuffer::Plane &Y = aBuffer.mPlanes[0];
|
||||
const YCbCrBuffer::Plane &Cb = aBuffer.mPlanes[1];
|
||||
const YCbCrBuffer::Plane &Cr = aBuffer.mPlanes[2];
|
||||
|
||||
PlanarYCbCrData data;
|
||||
data.mYChannel = Y.mData + Y.mOffset;
|
||||
data.mYSize = IntSize(Y.mWidth, Y.mHeight);
|
||||
data.mYStride = Y.mStride;
|
||||
data.mYSkip = Y.mSkip;
|
||||
data.mCbChannel = Cb.mData + Cb.mOffset;
|
||||
data.mCrChannel = Cr.mData + Cr.mOffset;
|
||||
data.mCbCrSize = IntSize(Cb.mWidth, Cb.mHeight);
|
||||
data.mCbCrStride = Cb.mStride;
|
||||
data.mCbSkip = Cb.mSkip;
|
||||
data.mCrSkip = Cr.mSkip;
|
||||
data.mPicX = aPicture.x;
|
||||
data.mPicY = aPicture.y;
|
||||
data.mPicSize = aPicture.Size();
|
||||
data.mStereoMode = aInfo.mStereoMode;
|
||||
|
||||
aVideoImage->SetDelayedConversion(true);
|
||||
if (aCopyData) {
|
||||
aVideoImage->SetData(data);
|
||||
} else {
|
||||
aVideoImage->SetDataNoCopy(data);
|
||||
}
|
||||
}
|
||||
|
||||
/* static */
|
||||
VideoData* VideoData::Create(VideoInfo& aInfo,
|
||||
ImageContainer* aContainer,
|
||||
Image* aImage,
|
||||
@ -164,14 +203,16 @@ VideoData* VideoData::Create(VideoInfo& aInfo,
|
||||
aKeyframe,
|
||||
aTimecode,
|
||||
aInfo.mDisplay.ToIntSize()));
|
||||
#ifdef MOZ_WIDGET_GONK
|
||||
const YCbCrBuffer::Plane &Y = aBuffer.mPlanes[0];
|
||||
const YCbCrBuffer::Plane &Cb = aBuffer.mPlanes[1];
|
||||
const YCbCrBuffer::Plane &Cr = aBuffer.mPlanes[2];
|
||||
#endif
|
||||
|
||||
if (!aImage) {
|
||||
// Currently our decoder only knows how to output to ImageFormat::PLANAR_YCBCR
|
||||
// format.
|
||||
#if 0
|
||||
#ifdef MOZ_WIDGET_GONK
|
||||
if (IsYV12Format(Y, Cb, Cr)) {
|
||||
v->mImage = aContainer->CreateImage(ImageFormat::GRALLOC_PLANAR_YCBCR);
|
||||
}
|
||||
@ -191,32 +232,30 @@ VideoData* VideoData::Create(VideoInfo& aInfo,
|
||||
"Wrong format?");
|
||||
PlanarYCbCrImage* videoImage = static_cast<PlanarYCbCrImage*>(v->mImage.get());
|
||||
|
||||
PlanarYCbCrData data;
|
||||
data.mYChannel = Y.mData + Y.mOffset;
|
||||
data.mYSize = IntSize(Y.mWidth, Y.mHeight);
|
||||
data.mYStride = Y.mStride;
|
||||
data.mYSkip = Y.mSkip;
|
||||
data.mCbChannel = Cb.mData + Cb.mOffset;
|
||||
data.mCrChannel = Cr.mData + Cr.mOffset;
|
||||
data.mCbCrSize = IntSize(Cb.mWidth, Cb.mHeight);
|
||||
data.mCbCrStride = Cb.mStride;
|
||||
data.mCbSkip = Cb.mSkip;
|
||||
data.mCrSkip = Cr.mSkip;
|
||||
data.mPicX = aPicture.x;
|
||||
data.mPicY = aPicture.y;
|
||||
data.mPicSize = aPicture.Size();
|
||||
data.mStereoMode = aInfo.mStereoMode;
|
||||
|
||||
videoImage->SetDelayedConversion(true);
|
||||
if (!aImage) {
|
||||
videoImage->SetData(data);
|
||||
VideoData::SetVideoDataToImage(videoImage, aInfo, aBuffer, aPicture,
|
||||
true /* aCopyData */);
|
||||
} else {
|
||||
videoImage->SetDataNoCopy(data);
|
||||
VideoData::SetVideoDataToImage(videoImage, aInfo, aBuffer, aPicture,
|
||||
false /* aCopyData */);
|
||||
}
|
||||
|
||||
#ifdef MOZ_WIDGET_GONK
|
||||
if (!videoImage->IsValid() && !aImage && IsYV12Format(Y, Cb, Cr)) {
|
||||
// Failed to allocate gralloc. Try fallback.
|
||||
v->mImage = aContainer->CreateImage(ImageFormat::PLANAR_YCBCR);
|
||||
if (!v->mImage) {
|
||||
return nullptr;
|
||||
}
|
||||
videoImage = static_cast<PlanarYCbCrImage*>(v->mImage.get());
|
||||
VideoData::SetVideoDataToImage(videoImage, aInfo, aBuffer, aPicture,
|
||||
true /* aCopyData */);
|
||||
}
|
||||
#endif
|
||||
return v.forget();
|
||||
}
|
||||
|
||||
/* static */
|
||||
VideoData* VideoData::Create(VideoInfo& aInfo,
|
||||
ImageContainer* aContainer,
|
||||
int64_t aOffset,
|
||||
@ -231,6 +270,7 @@ VideoData* VideoData::Create(VideoInfo& aInfo,
|
||||
aKeyframe, aTimecode, aPicture);
|
||||
}
|
||||
|
||||
/* static */
|
||||
VideoData* VideoData::Create(VideoInfo& aInfo,
|
||||
Image* aImage,
|
||||
int64_t aOffset,
|
||||
@ -245,6 +285,7 @@ VideoData* VideoData::Create(VideoInfo& aInfo,
|
||||
aKeyframe, aTimecode, aPicture);
|
||||
}
|
||||
|
||||
/* static */
|
||||
VideoData* VideoData::CreateFromImage(VideoInfo& aInfo,
|
||||
ImageContainer* aContainer,
|
||||
int64_t aOffset,
|
||||
@ -266,6 +307,7 @@ VideoData* VideoData::CreateFromImage(VideoInfo& aInfo,
|
||||
}
|
||||
|
||||
#ifdef MOZ_OMX_DECODER
|
||||
/* static */
|
||||
VideoData* VideoData::Create(VideoInfo& aInfo,
|
||||
ImageContainer* aContainer,
|
||||
int64_t aOffset,
|
||||
|
@ -102,6 +102,7 @@ public:
|
||||
|
||||
namespace layers {
|
||||
class GraphicBufferLocked;
|
||||
class PlanarYCbCrImage;
|
||||
}
|
||||
|
||||
class VideoInfo;
|
||||
@ -113,6 +114,7 @@ public:
|
||||
typedef gfx::IntSize IntSize;
|
||||
typedef layers::ImageContainer ImageContainer;
|
||||
typedef layers::Image Image;
|
||||
typedef layers::PlanarYCbCrImage PlanarYCbCrImage;
|
||||
|
||||
// YCbCr data obtained from decoding the video. The index's are:
|
||||
// 0 = Y
|
||||
@ -202,6 +204,14 @@ public:
|
||||
static VideoData* ShallowCopyUpdateDuration(VideoData* aOther,
|
||||
int64_t aDuration);
|
||||
|
||||
// Initialize PlanarYCbCrImage. Only When aCopyData is true,
|
||||
// video data is copied to PlanarYCbCrImage.
|
||||
static void SetVideoDataToImage(PlanarYCbCrImage* aVideoImage,
|
||||
VideoInfo& aInfo,
|
||||
const YCbCrBuffer &aBuffer,
|
||||
const IntRect& aPicture,
|
||||
bool aCopyData);
|
||||
|
||||
// Constructs a duplicate VideoData object. This intrinsically tells the
|
||||
// player that it does not need to update the displayed frame when this
|
||||
// frame is played; this frame is identical to the previous.
|
||||
|
@ -112,12 +112,16 @@ OmxVideoTrackEncoder::GetEncodedTrack(EncodedFrameContainer& aData)
|
||||
|
||||
// Send the EOS signal to OMXCodecWrapper.
|
||||
if (mEndOfStream && iter.IsEnded() && !mEosSetInEncoder) {
|
||||
mEosSetInEncoder = true;
|
||||
uint64_t totalDurationUs = mTotalFrameDuration * USECS_PER_S / mTrackRate;
|
||||
layers::Image* img = (!mLastFrame.GetImage() || mLastFrame.GetForceBlack())
|
||||
? nullptr : mLastFrame.GetImage();
|
||||
mEncoder->Encode(img, mFrameWidth, mFrameHeight, totalDurationUs,
|
||||
nsresult result = mEncoder->Encode(img, mFrameWidth, mFrameHeight,
|
||||
totalDurationUs,
|
||||
OMXCodecWrapper::BUFFER_EOS);
|
||||
// Keep sending EOS signal until OMXVideoEncoder gets it.
|
||||
if (result == NS_OK) {
|
||||
mEosSetInEncoder = true;
|
||||
}
|
||||
}
|
||||
|
||||
// Dequeue an encoded frame from the output buffers of OMXCodecWrapper.
|
||||
|
@ -226,15 +226,6 @@ void GStreamerReader::PlayBinSourceSetup(GstAppSrc* aSource)
|
||||
gst_app_src_set_callbacks(mSource, &mSrcCallbacks, (gpointer) this, nullptr);
|
||||
MediaResource* resource = mDecoder->GetResource();
|
||||
|
||||
/* do a short read to trigger a network request so that GetLength() below
|
||||
* returns something meaningful and not -1
|
||||
*/
|
||||
char buf[512];
|
||||
unsigned int size = 0;
|
||||
resource->Read(buf, sizeof(buf), &size);
|
||||
resource->Seek(SEEK_SET, 0);
|
||||
|
||||
/* now we should have a length */
|
||||
int64_t resourceLength = resource->GetLength();
|
||||
gst_app_src_set_size(mSource, resourceLength);
|
||||
if (resource->IsDataCachedToEndOfResource(0) ||
|
||||
|
@ -8,6 +8,7 @@
|
||||
#include "TrackEncoder.h"
|
||||
|
||||
#include <binder/ProcessState.h>
|
||||
#include <cutils/properties.h>
|
||||
#include <media/ICrypto.h>
|
||||
#include <media/IOMX.h>
|
||||
#include <OMX_Component.h>
|
||||
@ -110,6 +111,15 @@ OMXCodecWrapper::Stop()
|
||||
return result;
|
||||
}
|
||||
|
||||
// Check system property to see if we're running on emulator.
|
||||
static
|
||||
bool IsRunningOnEmulator()
|
||||
{
|
||||
char qemu[PROPERTY_VALUE_MAX];
|
||||
property_get("ro.kernel.qemu", qemu, "");
|
||||
return strncmp(qemu, "1", 1) == 0;
|
||||
}
|
||||
|
||||
nsresult
|
||||
OMXVideoEncoder::Configure(int aWidth, int aHeight, int aFrameRate)
|
||||
{
|
||||
@ -118,6 +128,19 @@ OMXVideoEncoder::Configure(int aWidth, int aHeight, int aFrameRate)
|
||||
NS_ENSURE_TRUE(aWidth > 0 && aHeight > 0 && aFrameRate > 0,
|
||||
NS_ERROR_INVALID_ARG);
|
||||
|
||||
OMX_VIDEO_AVCLEVELTYPE level = OMX_VIDEO_AVCLevel3;
|
||||
OMX_VIDEO_CONTROLRATETYPE bitrateMode = OMX_Video_ControlRateConstant;
|
||||
// Limitation of soft AVC/H.264 encoder running on emulator in stagefright.
|
||||
static bool emu = IsRunningOnEmulator();
|
||||
if (emu) {
|
||||
if (aWidth > 352 || aHeight > 288) {
|
||||
CODEC_ERROR("SoftAVCEncoder doesn't support resolution larger than CIF");
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
}
|
||||
level = OMX_VIDEO_AVCLevel2;
|
||||
bitrateMode = OMX_Video_ControlRateVariable;
|
||||
}
|
||||
|
||||
// Set up configuration parameters for AVC/H.264 encoder.
|
||||
sp<AMessage> format = new AMessage;
|
||||
// Fixed values
|
||||
@ -128,8 +151,8 @@ OMXVideoEncoder::Configure(int aWidth, int aHeight, int aFrameRate)
|
||||
// height is half that of Y
|
||||
format->setInt32("color-format", OMX_COLOR_FormatYUV420SemiPlanar);
|
||||
format->setInt32("profile", OMX_VIDEO_AVCProfileBaseline);
|
||||
format->setInt32("level", OMX_VIDEO_AVCLevel3);
|
||||
format->setInt32("bitrate-mode", OMX_Video_ControlRateConstant);
|
||||
format->setInt32("level", level);
|
||||
format->setInt32("bitrate-mode", bitrateMode);
|
||||
format->setInt32("store-metadata-in-buffers", 0);
|
||||
format->setInt32("prepend-sps-pps-to-idr-frames", 0);
|
||||
// Input values.
|
||||
|
@ -59,12 +59,13 @@ function runTests(text, charWidth)
|
||||
}
|
||||
}
|
||||
|
||||
expectThrow(-1, 2);
|
||||
expectThrow(-1, 0);
|
||||
expectThrow(1, 3);
|
||||
expectThrow(0, 4);
|
||||
expectThrow(100, 2);
|
||||
expectThrow(100, 0);
|
||||
expectThrow(3, 0);
|
||||
expectThrow(3, 1);
|
||||
|
||||
expectValue(1, 3, chars(2));
|
||||
expectValue(0, 4, chars(3));
|
||||
expectValue(0, 0, chars(0));
|
||||
expectValue(1, 0, chars(0));
|
||||
expectValue(2, 0, chars(0));
|
||||
@ -74,12 +75,8 @@ function runTests(text, charWidth)
|
||||
expectValue(0, 2, chars(2));
|
||||
expectValue(1, 2, chars(2));
|
||||
expectValue(0, 3, chars(3));
|
||||
|
||||
expectThrow(1, -1);
|
||||
expectThrow(2, -1);
|
||||
expectThrow(3, -1);
|
||||
expectThrow(3, -3);
|
||||
expectThrow(-1, -1);
|
||||
expectValue(1, 100, chars(2));
|
||||
expectValue(2, 100, chars(1));
|
||||
}
|
||||
|
||||
|
||||
|
@ -44,17 +44,34 @@ function runTests()
|
||||
}
|
||||
}
|
||||
|
||||
expectThrow(-1, 2);
|
||||
expectThrow(-1, 0);
|
||||
expectThrow(1, 3);
|
||||
expectThrow(0, 4);
|
||||
expectThrow(3, 0);
|
||||
function expectNoThrow(charnum, nchars, expected)
|
||||
{
|
||||
try
|
||||
{
|
||||
text.selectSubString(charnum, nchars);
|
||||
ok(true,
|
||||
"text.selectSubString(" + charnum + "," + nchars + ") " +
|
||||
"should not have thrown");
|
||||
}
|
||||
catch (e)
|
||||
{
|
||||
ok(false,
|
||||
"unexpected exception for " +
|
||||
"text.selectSubString(" + charnum + "," + nchars + ")");
|
||||
}
|
||||
}
|
||||
|
||||
expectThrow(1, -1);
|
||||
expectThrow(2, -1);
|
||||
expectThrow(3, -1);
|
||||
expectThrow(3, -3);
|
||||
expectThrow(-1, -1);
|
||||
expectThrow(100, 2);
|
||||
expectThrow(100, 0);
|
||||
expectThrow(3, 0);
|
||||
expectThrow(3, 100);
|
||||
expectThrow(3, 100);
|
||||
expectThrow(100, 100);
|
||||
|
||||
expectNoThrow(1, 100);
|
||||
expectNoThrow(2, 100);
|
||||
expectNoThrow(1, 3);
|
||||
expectNoThrow(0, 4);
|
||||
|
||||
SimpleTest.finish();
|
||||
}
|
||||
|
@ -45,6 +45,3 @@ MODULE_OPTIMIZE_FLAGS = -O2
|
||||
endif
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
||||
# next line allows use of MOZ_OBJDIR in .mozconfig with older gcc on BeOS, maybe others
|
||||
LOCAL_INCLUDES += -I$(srcdir)
|
||||
|
@ -448,7 +448,7 @@ AudioChannelService::SendAudioChannelChangedNotification(uint64_t aChildID)
|
||||
}
|
||||
|
||||
// Calculating the most important active channel.
|
||||
AudioChannelType higher = AUDIO_CHANNEL_LAST;
|
||||
AudioChannelType higher = AUDIO_CHANNEL_DEFAULT;
|
||||
|
||||
// Top-Down in the hierarchy for visible elements
|
||||
if (!mChannelCounters[AUDIO_CHANNEL_INT_PUBLICNOTIFICATION].IsEmpty()) {
|
||||
@ -482,30 +482,19 @@ AudioChannelService::SendAudioChannelChangedNotification(uint64_t aChildID)
|
||||
AudioChannelType visibleHigher = higher;
|
||||
|
||||
// Top-Down in the hierarchy for non-visible elements
|
||||
if (higher == AUDIO_CHANNEL_LAST) {
|
||||
if (!mChannelCounters[AUDIO_CHANNEL_INT_PUBLICNOTIFICATION_HIDDEN].IsEmpty()) {
|
||||
higher = AUDIO_CHANNEL_PUBLICNOTIFICATION;
|
||||
// And we can ignore normal channel because it can't play in the background.
|
||||
for (int i = AUDIO_CHANNEL_LAST - 1;
|
||||
i > higher && i > AUDIO_CHANNEL_NORMAL; i--) {
|
||||
if (i == AUDIO_CHANNEL_CONTENT &&
|
||||
mPlayableHiddenContentChildID != CONTENT_PROCESS_ID_UNKNOWN) {
|
||||
higher = static_cast<AudioChannelType>(i);
|
||||
}
|
||||
|
||||
else if (!mChannelCounters[AUDIO_CHANNEL_INT_RINGER_HIDDEN].IsEmpty()) {
|
||||
higher = AUDIO_CHANNEL_RINGER;
|
||||
}
|
||||
|
||||
else if (!mChannelCounters[AUDIO_CHANNEL_INT_TELEPHONY_HIDDEN].IsEmpty()) {
|
||||
higher = AUDIO_CHANNEL_TELEPHONY;
|
||||
}
|
||||
|
||||
else if (!mChannelCounters[AUDIO_CHANNEL_INT_ALARM_HIDDEN].IsEmpty()) {
|
||||
higher = AUDIO_CHANNEL_ALARM;
|
||||
}
|
||||
|
||||
else if (!mChannelCounters[AUDIO_CHANNEL_INT_NOTIFICATION_HIDDEN].IsEmpty()) {
|
||||
higher = AUDIO_CHANNEL_NOTIFICATION;
|
||||
}
|
||||
|
||||
// Check whether there is any playable hidden content channel or not.
|
||||
else if (mPlayableHiddenContentChildID != CONTENT_PROCESS_ID_UNKNOWN) {
|
||||
higher = AUDIO_CHANNEL_CONTENT;
|
||||
// Each channel type will be split to fg and bg for recording the state,
|
||||
// so here need to do a translation.
|
||||
if (!mChannelCounters[i * 2 + 1].IsEmpty()) {
|
||||
higher = static_cast<AudioChannelType>(i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@ -513,7 +502,7 @@ AudioChannelService::SendAudioChannelChangedNotification(uint64_t aChildID)
|
||||
mCurrentHigherChannel = higher;
|
||||
|
||||
nsString channelName;
|
||||
if (mCurrentHigherChannel != AUDIO_CHANNEL_LAST) {
|
||||
if (mCurrentHigherChannel != AUDIO_CHANNEL_DEFAULT) {
|
||||
channelName.AssignASCII(ChannelName(mCurrentHigherChannel));
|
||||
} else {
|
||||
channelName.AssignLiteral("none");
|
||||
@ -528,7 +517,7 @@ AudioChannelService::SendAudioChannelChangedNotification(uint64_t aChildID)
|
||||
mCurrentVisibleHigherChannel = visibleHigher;
|
||||
|
||||
nsString channelName;
|
||||
if (mCurrentVisibleHigherChannel != AUDIO_CHANNEL_LAST) {
|
||||
if (mCurrentVisibleHigherChannel != AUDIO_CHANNEL_DEFAULT) {
|
||||
channelName.AssignASCII(ChannelName(mCurrentVisibleHigherChannel));
|
||||
} else {
|
||||
channelName.AssignLiteral("none");
|
||||
|
@ -1022,6 +1022,7 @@ void
|
||||
Navigator::MozGetUserMediaDevices(const MediaStreamConstraintsInternal& aConstraints,
|
||||
MozGetUserMediaDevicesSuccessCallback& aOnSuccess,
|
||||
NavigatorUserMediaErrorCallback& aOnError,
|
||||
uint64_t aInnerWindowID,
|
||||
ErrorResult& aRv)
|
||||
{
|
||||
CallbackObjectHolder<MozGetUserMediaDevicesSuccessCallback,
|
||||
@ -1040,7 +1041,8 @@ Navigator::MozGetUserMediaDevices(const MediaStreamConstraintsInternal& aConstra
|
||||
}
|
||||
|
||||
MediaManager* manager = MediaManager::Get();
|
||||
aRv = manager->GetUserMediaDevices(mWindow, aConstraints, onsuccess, onerror);
|
||||
aRv = manager->GetUserMediaDevices(mWindow, aConstraints, onsuccess, onerror,
|
||||
aInnerWindowID);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -230,6 +230,7 @@ public:
|
||||
void MozGetUserMediaDevices(const MediaStreamConstraintsInternal& aConstraints,
|
||||
MozGetUserMediaDevicesSuccessCallback& aOnSuccess,
|
||||
NavigatorUserMediaErrorCallback& aOnError,
|
||||
uint64_t aInnerWindowID,
|
||||
ErrorResult& aRv);
|
||||
#endif // MOZ_MEDIA_NAVIGATOR
|
||||
bool DoNewResolve(JSContext* aCx, JS::Handle<JSObject*> aObject,
|
||||
|
@ -2196,10 +2196,15 @@ nsJSContext::EndCycleCollectionCallback(CycleCollectorResults &aResults)
|
||||
PokeGC(JS::gcreason::CC_WAITING);
|
||||
}
|
||||
|
||||
TimeStamp endCCTime = TimeStamp::Now();
|
||||
TimeStamp endCCTimeStamp = TimeStamp::Now();
|
||||
|
||||
PRTime endCCTime;
|
||||
if (sPostGCEventsToObserver) {
|
||||
endCCTime = PR_Now();
|
||||
}
|
||||
|
||||
// Log information about the CC via telemetry, JSON and the console.
|
||||
uint32_t ccNowDuration = TimeBetween(gCCStats.mBeginTime, endCCTime);
|
||||
uint32_t ccNowDuration = TimeBetween(gCCStats.mBeginTime, endCCTimeStamp);
|
||||
Telemetry::Accumulate(Telemetry::CYCLE_COLLECTOR_FINISH_IGC, gCCStats.mAnyLockedOut);
|
||||
Telemetry::Accumulate(Telemetry::CYCLE_COLLECTOR_SYNC_SKIPPABLE, gCCStats.mRanSyncForgetSkippable);
|
||||
Telemetry::Accumulate(Telemetry::CYCLE_COLLECTOR_FULL, ccNowDuration);
|
||||
@ -2209,7 +2214,7 @@ nsJSContext::EndCycleCollectionCallback(CycleCollectorResults &aResults)
|
||||
uint32_t timeBetween = TimeBetween(sLastCCEndTime, gCCStats.mBeginTime);
|
||||
Telemetry::Accumulate(Telemetry::CYCLE_COLLECTOR_TIME_BETWEEN, timeBetween);
|
||||
}
|
||||
sLastCCEndTime = endCCTime;
|
||||
sLastCCEndTime = endCCTimeStamp;
|
||||
|
||||
Telemetry::Accumulate(Telemetry::FORGET_SKIPPABLE_MAX,
|
||||
sMaxForgetSkippableTime / PR_USEC_PER_MSEC);
|
||||
|
@ -13,7 +13,7 @@ OS_CXXFLAGS += -Wno-uninitialized
|
||||
endif
|
||||
|
||||
# Bug 932082 tracks having bindings use namespaced includes.
|
||||
LOCAL_INCLUDES += -I$(DIST)/include/mozilla/dom -I..
|
||||
LOCAL_INCLUDES += -I$(DIST)/include/mozilla/dom
|
||||
|
||||
# Include rules.mk before any of our targets so our first target is coming from
|
||||
# rules.mk and running make with no target in this dir does the right thing.
|
||||
|
@ -36,6 +36,7 @@ WEBIDL_EXAMPLE_INTERFACES += [
|
||||
'TestExampleProxyInterface',
|
||||
]
|
||||
|
||||
GENERATED_INCLUDES += ['..']
|
||||
LOCAL_INCLUDES += [
|
||||
'/dom/bindings',
|
||||
'/js/xpconnect/src',
|
||||
|
@ -114,7 +114,7 @@ TextComposition::NotityUpdateComposition(WidgetGUIEvent* aEvent)
|
||||
}
|
||||
|
||||
void
|
||||
TextComposition::DispatchCompsotionEventRunnable(uint32_t aEventMessage,
|
||||
TextComposition::DispatchCompositionEventRunnable(uint32_t aEventMessage,
|
||||
const nsAString& aData)
|
||||
{
|
||||
nsContentUtils::AddScriptRunner(
|
||||
@ -128,10 +128,10 @@ TextComposition::SynthesizeCommit(bool aDiscard)
|
||||
nsRefPtr<TextComposition> kungFuDeathGrip(this);
|
||||
nsAutoString data(aDiscard ? EmptyString() : mLastData);
|
||||
if (mLastData != data) {
|
||||
DispatchCompsotionEventRunnable(NS_COMPOSITION_UPDATE, data);
|
||||
DispatchCompsotionEventRunnable(NS_TEXT_TEXT, data);
|
||||
DispatchCompositionEventRunnable(NS_COMPOSITION_UPDATE, data);
|
||||
DispatchCompositionEventRunnable(NS_TEXT_TEXT, data);
|
||||
}
|
||||
DispatchCompsotionEventRunnable(NS_COMPOSITION_END, data);
|
||||
DispatchCompositionEventRunnable(NS_COMPOSITION_END, data);
|
||||
}
|
||||
|
||||
nsresult
|
||||
|
@ -219,7 +219,7 @@ private:
|
||||
};
|
||||
|
||||
/**
|
||||
* DispatchCompsotionEventRunnable() dispatches a composition or text event
|
||||
* DispatchCompositionEventRunnable() dispatches a composition or text event
|
||||
* to the content. Be aware, if you use this method, nsPresShellEventCB
|
||||
* isn't used. That means that nsIFrame::HandleEvent() is never called.
|
||||
* WARNING: The instance which is managed by nsIMEStateManager may be
|
||||
@ -231,7 +231,7 @@ private:
|
||||
* Used for theText value if aEventMessage is
|
||||
* NS_TEXT_TEXT.
|
||||
*/
|
||||
void DispatchCompsotionEventRunnable(uint32_t aEventMessage,
|
||||
void DispatchCompositionEventRunnable(uint32_t aEventMessage,
|
||||
const nsAString& aData);
|
||||
};
|
||||
|
||||
|
@ -134,6 +134,7 @@
|
||||
#include "AudioChannelService.h"
|
||||
#include "JavaScriptChild.h"
|
||||
#include "mozilla/dom/telephony/PTelephonyChild.h"
|
||||
#include "mozilla/dom/time/DateCacheCleaner.h"
|
||||
#include "mozilla/net/NeckoMessageUtils.h"
|
||||
|
||||
using namespace base;
|
||||
@ -311,6 +312,15 @@ NS_IMPL_ISUPPORTS1(SystemMessageHandledObserver, nsIObserver)
|
||||
|
||||
ContentChild* ContentChild::sSingleton;
|
||||
|
||||
// Performs initialization that is not fork-safe, i.e. that must be done after
|
||||
// forking from the Nuwa process.
|
||||
static void
|
||||
InitOnContentProcessCreated()
|
||||
{
|
||||
// This will register cross-process observer.
|
||||
mozilla::dom::time::InitializeDateCacheCleaner();
|
||||
}
|
||||
|
||||
ContentChild::ContentChild()
|
||||
: mID(uint64_t(-1))
|
||||
#ifdef ANDROID
|
||||
@ -462,6 +472,10 @@ ContentChild::InitXPCOM()
|
||||
nsRefPtr<SystemMessageHandledObserver> sysMsgObserver =
|
||||
new SystemMessageHandledObserver();
|
||||
sysMsgObserver->Init();
|
||||
|
||||
#ifndef MOZ_NUWA_PROCESS
|
||||
InitOnContentProcessCreated();
|
||||
#endif
|
||||
}
|
||||
|
||||
PMemoryReportRequestChild*
|
||||
@ -1623,6 +1637,10 @@ public:
|
||||
|
||||
toplevel = toplevel->getNext();
|
||||
}
|
||||
|
||||
// Perform other after-fork initializations.
|
||||
InitOnContentProcessCreated();
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
};
|
||||
|
@ -66,7 +66,7 @@ CrashReporterParent::CrashReporterParent()
|
||||
#ifdef MOZ_CRASHREPORTER
|
||||
mNotes(4),
|
||||
#endif
|
||||
mStartTime(time(nullptr))
|
||||
mStartTime(::time(nullptr))
|
||||
, mInitialized(false)
|
||||
{
|
||||
MOZ_COUNT_CTOR(CrashReporterParent);
|
||||
|
@ -17,15 +17,15 @@ GetUserMediaRequest::GetUserMediaRequest(
|
||||
nsPIDOMWindow* aInnerWindow,
|
||||
const nsAString& aCallID,
|
||||
const MediaStreamConstraintsInternal& aConstraints)
|
||||
: mInnerWindow(aInnerWindow)
|
||||
, mWindowID(aInnerWindow->GetOuterWindow()->WindowID())
|
||||
: mInnerWindowID(aInnerWindow->WindowID())
|
||||
, mOuterWindowID(aInnerWindow->GetOuterWindow()->WindowID())
|
||||
, mCallID(aCallID)
|
||||
, mConstraints(aConstraints)
|
||||
{
|
||||
SetIsDOMBinding();
|
||||
}
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE_1(GetUserMediaRequest, mInnerWindow)
|
||||
NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE_0(GetUserMediaRequest)
|
||||
NS_IMPL_CYCLE_COLLECTING_ADDREF(GetUserMediaRequest)
|
||||
NS_IMPL_CYCLE_COLLECTING_RELEASE(GetUserMediaRequest)
|
||||
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(GetUserMediaRequest)
|
||||
@ -41,7 +41,7 @@ GetUserMediaRequest::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aScope)
|
||||
|
||||
nsISupports* GetUserMediaRequest::GetParentObject()
|
||||
{
|
||||
return mInnerWindow;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void GetUserMediaRequest::GetCallID(nsString& retval)
|
||||
@ -51,7 +51,12 @@ void GetUserMediaRequest::GetCallID(nsString& retval)
|
||||
|
||||
uint64_t GetUserMediaRequest::WindowID()
|
||||
{
|
||||
return mWindowID;
|
||||
return mOuterWindowID;
|
||||
}
|
||||
|
||||
uint64_t GetUserMediaRequest::InnerWindowID()
|
||||
{
|
||||
return mInnerWindowID;
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -20,7 +20,8 @@ class MediaStreamConstraintsInternal;
|
||||
class GetUserMediaRequest : public nsISupports, public nsWrapperCache
|
||||
{
|
||||
public:
|
||||
GetUserMediaRequest(nsPIDOMWindow* aInnerWindow, const nsAString& aCallID,
|
||||
GetUserMediaRequest(nsPIDOMWindow* aInnerWindow,
|
||||
const nsAString& aCallID,
|
||||
const MediaStreamConstraintsInternal& aConstraints);
|
||||
virtual ~GetUserMediaRequest() {};
|
||||
|
||||
@ -32,12 +33,12 @@ public:
|
||||
nsISupports* GetParentObject();
|
||||
|
||||
uint64_t WindowID();
|
||||
uint64_t InnerWindowID();
|
||||
void GetCallID(nsString& retval);
|
||||
void GetConstraints(MediaStreamConstraintsInternal &result);
|
||||
|
||||
private:
|
||||
nsCOMPtr<nsPIDOMWindow> mInnerWindow;
|
||||
uint64_t mWindowID;
|
||||
uint64_t mInnerWindowID, mOuterWindowID;
|
||||
const nsString mCallID;
|
||||
MediaStreamConstraintsInternal mConstraints;
|
||||
};
|
||||
|
@ -225,12 +225,15 @@ class DeviceSuccessCallbackRunnable: public nsRunnable
|
||||
{
|
||||
public:
|
||||
DeviceSuccessCallbackRunnable(
|
||||
uint64_t aWindowID,
|
||||
already_AddRefed<nsIGetUserMediaDevicesSuccessCallback> aSuccess,
|
||||
already_AddRefed<nsIDOMGetUserMediaErrorCallback> aError,
|
||||
nsTArray<nsCOMPtr<nsIMediaDevice> >* aDevices)
|
||||
: mSuccess(aSuccess)
|
||||
, mError(aError)
|
||||
, mDevices(aDevices) {}
|
||||
, mDevices(aDevices)
|
||||
, mWindowID(aWindowID)
|
||||
, mManager(MediaManager::GetInstance()) {}
|
||||
|
||||
NS_IMETHOD
|
||||
Run()
|
||||
@ -240,6 +243,11 @@ public:
|
||||
nsCOMPtr<nsIGetUserMediaDevicesSuccessCallback> success(mSuccess);
|
||||
nsCOMPtr<nsIDOMGetUserMediaErrorCallback> error(mError);
|
||||
|
||||
// Only run if window is still on our active list.
|
||||
if (!mManager->IsWindowStillActive(mWindowID)) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIWritableVariant> devices =
|
||||
do_CreateInstance("@mozilla.org/variant;1");
|
||||
|
||||
@ -273,6 +281,8 @@ private:
|
||||
already_AddRefed<nsIGetUserMediaDevicesSuccessCallback> mSuccess;
|
||||
already_AddRefed<nsIDOMGetUserMediaErrorCallback> mError;
|
||||
nsAutoPtr<nsTArray<nsCOMPtr<nsIMediaDevice> > > mDevices;
|
||||
uint64_t mWindowID;
|
||||
nsRefPtr<MediaManager> mManager;
|
||||
};
|
||||
|
||||
// Handle removing GetUserMediaCallbackMediaStreamListener from main thread
|
||||
@ -1076,7 +1086,8 @@ public:
|
||||
mLoopbackAudioDevice));
|
||||
final->MoveElementsFrom(*s);
|
||||
}
|
||||
NS_DispatchToMainThread(new DeviceSuccessCallbackRunnable(mSuccess, mError,
|
||||
NS_DispatchToMainThread(new DeviceSuccessCallbackRunnable(mWindowId,
|
||||
mSuccess, mError,
|
||||
final.forget()));
|
||||
return NS_OK;
|
||||
}
|
||||
@ -1087,6 +1098,7 @@ private:
|
||||
already_AddRefed<nsIDOMGetUserMediaErrorCallback> mError;
|
||||
nsRefPtr<MediaManager> mManager;
|
||||
uint64_t mWindowId;
|
||||
const nsString mCallId;
|
||||
// Audio & Video loopback devices to be used based on
|
||||
// the preference settings. This is currently used for
|
||||
// automated media tests only.
|
||||
@ -1449,7 +1461,8 @@ nsresult
|
||||
MediaManager::GetUserMediaDevices(nsPIDOMWindow* aWindow,
|
||||
const MediaStreamConstraintsInternal& aConstraints,
|
||||
nsIGetUserMediaDevicesSuccessCallback* aOnSuccess,
|
||||
nsIDOMGetUserMediaErrorCallback* aOnError)
|
||||
nsIDOMGetUserMediaErrorCallback* aOnError,
|
||||
uint64_t aInnerWindowID)
|
||||
{
|
||||
NS_ASSERTION(NS_IsMainThread(), "Only call on main thread");
|
||||
|
||||
@ -1474,9 +1487,9 @@ MediaManager::GetUserMediaDevices(nsPIDOMWindow* aWindow,
|
||||
#endif
|
||||
|
||||
nsCOMPtr<nsIRunnable> gUMDRunnable = new GetUserMediaDevicesRunnable(
|
||||
aConstraints, onSuccess.forget(), onError.forget(), aWindow->WindowID(),
|
||||
loopbackAudioDevice, loopbackVideoDevice
|
||||
);
|
||||
aConstraints, onSuccess.forget(), onError.forget(),
|
||||
(aInnerWindowID ? aInnerWindowID : aWindow->WindowID()),
|
||||
loopbackAudioDevice, loopbackVideoDevice);
|
||||
|
||||
nsCOMPtr<nsIThread> deviceThread;
|
||||
rv = NS_NewThread(getter_AddRefs(deviceThread));
|
||||
|
@ -494,7 +494,8 @@ public:
|
||||
nsresult GetUserMediaDevices(nsPIDOMWindow* aWindow,
|
||||
const dom::MediaStreamConstraintsInternal& aConstraints,
|
||||
nsIGetUserMediaDevicesSuccessCallback* onSuccess,
|
||||
nsIDOMGetUserMediaErrorCallback* onError);
|
||||
nsIDOMGetUserMediaErrorCallback* onError,
|
||||
uint64_t aInnerWindowID = 0);
|
||||
void OnNavigation(uint64_t aWindowID);
|
||||
|
||||
MediaEnginePrefs mPrefs;
|
||||
|
@ -173,7 +173,8 @@ MediaPermissionRequest::GetPrincipal(nsIPrincipal **aRequestingPrincipal)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aRequestingPrincipal);
|
||||
|
||||
nsCOMPtr<nsPIDOMWindow> window = do_QueryInterface(mRequest->GetParentObject());
|
||||
nsCOMPtr<nsPIDOMWindow> window = static_cast<nsPIDOMWindow*>
|
||||
(nsGlobalWindow::GetInnerWindowWithId(mRequest->InnerWindowID()));
|
||||
NS_ENSURE_TRUE(window, NS_ERROR_FAILURE);
|
||||
|
||||
nsCOMPtr<nsIDocument> doc = window->GetExtantDoc();
|
||||
@ -187,7 +188,8 @@ NS_IMETHODIMP
|
||||
MediaPermissionRequest::GetWindow(nsIDOMWindow** aRequestingWindow)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aRequestingWindow);
|
||||
nsCOMPtr<nsPIDOMWindow> window = do_QueryInterface(mRequest->GetParentObject());
|
||||
nsCOMPtr<nsPIDOMWindow> window = static_cast<nsPIDOMWindow*>
|
||||
(nsGlobalWindow::GetInnerWindowWithId(mRequest->InnerWindowID()));
|
||||
window.forget(aRequestingWindow);
|
||||
return NS_OK;
|
||||
}
|
||||
@ -221,7 +223,8 @@ MediaPermissionRequest::Allow()
|
||||
already_AddRefed<nsPIDOMWindow>
|
||||
MediaPermissionRequest::GetOwner()
|
||||
{
|
||||
nsCOMPtr<nsPIDOMWindow> window = do_QueryInterface(mRequest->GetParentObject());
|
||||
nsCOMPtr<nsPIDOMWindow> window = static_cast<nsPIDOMWindow*>
|
||||
(nsGlobalWindow::GetInnerWindowWithId(mRequest->InnerWindowID()));
|
||||
return window.forget();
|
||||
}
|
||||
|
||||
@ -434,7 +437,8 @@ MediaPermissionManager::HandleRequest(nsRefPtr<dom::GetUserMediaRequest> &req)
|
||||
nsString callID;
|
||||
req->GetCallID(callID);
|
||||
|
||||
nsCOMPtr<nsPIDOMWindow> innerWindow = do_QueryInterface(req->GetParentObject());
|
||||
nsCOMPtr<nsPIDOMWindow> innerWindow = static_cast<nsPIDOMWindow*>
|
||||
(nsGlobalWindow::GetInnerWindowWithId(req->InnerWindowID()));
|
||||
if (!innerWindow) {
|
||||
MOZ_ASSERT(false, "No inner window");
|
||||
return NS_ERROR_FAILURE;
|
||||
|
@ -1101,10 +1101,16 @@ function PeerConnectionWrapper(label, configuration) {
|
||||
* Event data which includes the stream to be added
|
||||
*/
|
||||
this._pc.onaddstream = function (event) {
|
||||
info(self + ": 'onaddstream' event fired for " + event.stream);
|
||||
info(self + ": 'onaddstream' event fired for " + JSON.stringify(event.stream));
|
||||
|
||||
// TODO: Bug 834835 - Assume type is video until we get get{Audio,Video}Tracks.
|
||||
self.attachMedia(event.stream, 'video', 'remote');
|
||||
var type = '';
|
||||
if (event.stream.getAudioTracks().length > 0) {
|
||||
type = 'audio';
|
||||
}
|
||||
if (event.stream.getVideoTracks().length > 0) {
|
||||
type += 'video';
|
||||
}
|
||||
self.attachMedia(event.stream, type, 'remote');
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -79,7 +79,15 @@ NetworkStatsDB.prototype = {
|
||||
// to modify the keyPath is mandatory to delete the object store
|
||||
// and create it again. Old data is going to be deleted because the
|
||||
// networkId for each sample can not be set.
|
||||
|
||||
// In version 1.2 objectStore name was 'net_stats_v2', to avoid errors when
|
||||
// upgrading from 1.2 to 1.3 objectStore name should be checked.
|
||||
let stores = db.objectStoreNames;
|
||||
if(stores.contains("net_stats_v2")) {
|
||||
db.deleteObjectStore("net_stats_v2");
|
||||
} else {
|
||||
db.deleteObjectStore(DEPRECATED_STORE_NAME);
|
||||
}
|
||||
|
||||
objectStore = db.createObjectStore(DEPRECATED_STORE_NAME, { keyPath: ["appId", "network", "timestamp"] });
|
||||
objectStore.createIndex("appId", "appId", { unique: false });
|
||||
|
@ -22,6 +22,7 @@ Cu.import("resource://gre/modules/Services.jsm");
|
||||
Cu.import("resource://gre/modules/Sntp.jsm");
|
||||
Cu.import("resource://gre/modules/systemlibs.js");
|
||||
Cu.import("resource://gre/modules/Promise.jsm");
|
||||
Cu.import("resource://gre/modules/FileUtils.jsm");
|
||||
|
||||
var RIL = {};
|
||||
Cu.import("resource://gre/modules/ril_consts.js", RIL);
|
||||
@ -3299,6 +3300,16 @@ RadioInterface.prototype = {
|
||||
// Or refresh the SNTP.
|
||||
this._sntp.request();
|
||||
}
|
||||
} else {
|
||||
// Set a sane minimum time.
|
||||
let buildTime = libcutils.property_get("ro.build.date.utc", "0") * 1000;
|
||||
let file = FileUtils.File("/system/b2g/b2g");
|
||||
if (file.lastModifiedTime > buildTime) {
|
||||
buildTime = file.lastModifiedTime;
|
||||
}
|
||||
if (buildTime > Date.now()) {
|
||||
gTimeService.set(buildTime);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case kSettingsTimezoneAutoUpdateEnabled:
|
||||
|
@ -9,6 +9,7 @@
|
||||
[NoInterfaceObject]
|
||||
interface GetUserMediaRequest {
|
||||
readonly attribute unsigned long long windowID;
|
||||
readonly attribute unsigned long long innerWindowID;
|
||||
readonly attribute DOMString callID;
|
||||
MediaStreamConstraintsInternal getConstraints();
|
||||
};
|
||||
|
@ -340,6 +340,10 @@ partial interface Navigator {
|
||||
[Throws, ChromeOnly]
|
||||
void mozGetUserMediaDevices(MediaStreamConstraintsInternal constraints,
|
||||
MozGetUserMediaDevicesSuccessCallback onsuccess,
|
||||
NavigatorUserMediaErrorCallback onerror);
|
||||
NavigatorUserMediaErrorCallback onerror,
|
||||
// The originating innerWindowID is needed to
|
||||
// avoid calling the callbacks if the window has
|
||||
// navigated away. It is optional only as legacy.
|
||||
optional unsigned long long innerWindowID = 0);
|
||||
};
|
||||
#endif // MOZ_MEDIA_NAVIGATOR
|
||||
|
@ -37,6 +37,7 @@ dictionary RTCInboundRTPStreamStats : RTCRTPStreamStats {
|
||||
unsigned long packetsReceived;
|
||||
unsigned long long bytesReceived;
|
||||
double jitter;
|
||||
unsigned long packetsLost;
|
||||
};
|
||||
|
||||
dictionary RTCOutboundRTPStreamStats : RTCRTPStreamStats {
|
||||
|
@ -82,13 +82,12 @@ readTextureImageFS_TEXTURE_RECTANGLE[] =
|
||||
"void main() { gl_FragColor = texture2DRect(uTexture, vTexCoord).bgra; }";
|
||||
|
||||
GLuint
|
||||
GLReadTexImageHelper::TextureImageProgramFor(GLenum aTextureTarget, int aShader) {
|
||||
GLReadTexImageHelper::TextureImageProgramFor(GLenum aTextureTarget, int aConfig) {
|
||||
int variant = 0;
|
||||
const GLchar* readTextureImageFS = nullptr;
|
||||
if (aTextureTarget == LOCAL_GL_TEXTURE_2D)
|
||||
{
|
||||
if (aShader == layers::BGRALayerProgramType ||
|
||||
aShader == layers::BGRXLayerProgramType)
|
||||
if (aConfig & mozilla::layers::ENABLE_TEXTURE_RB_SWAP)
|
||||
{ // Need to swizzle R/B.
|
||||
readTextureImageFS = readTextureImageFS_TEXTURE_2D_BGRA;
|
||||
variant = 1;
|
||||
@ -524,12 +523,9 @@ already_AddRefed<gfxImageSurface>
|
||||
GLReadTexImageHelper::ReadTexImage(GLuint aTextureId,
|
||||
GLenum aTextureTarget,
|
||||
const gfxIntSize& aSize,
|
||||
/* ShaderProgramType */ int aShaderProgram,
|
||||
/* ShaderConfigOGL.mFeature */ int aConfig,
|
||||
bool aYInvert)
|
||||
{
|
||||
// Check aShaderProgram is in bounds for a layers::ShaderProgramType
|
||||
MOZ_ASSERT(0 <= aShaderProgram && aShaderProgram < layers::NumProgramTypes);
|
||||
|
||||
MOZ_ASSERT(aTextureTarget == LOCAL_GL_TEXTURE_2D ||
|
||||
aTextureTarget == LOCAL_GL_TEXTURE_EXTERNAL ||
|
||||
aTextureTarget == LOCAL_GL_TEXTURE_RECTANGLE_ARB);
|
||||
@ -590,8 +586,7 @@ GLReadTexImageHelper::ReadTexImage(GLuint aTextureId,
|
||||
MOZ_ASSERT(mGL->fCheckFramebufferStatus(LOCAL_GL_FRAMEBUFFER) == LOCAL_GL_FRAMEBUFFER_COMPLETE);
|
||||
|
||||
/* Setup vertex and fragment shader */
|
||||
layers::ShaderProgramType shaderProgram = (layers::ShaderProgramType) aShaderProgram;
|
||||
GLuint program = TextureImageProgramFor(aTextureTarget, shaderProgram);
|
||||
GLuint program = TextureImageProgramFor(aTextureTarget, aConfig);
|
||||
MOZ_ASSERT(program);
|
||||
|
||||
mGL->fUseProgram(program);
|
||||
|
@ -80,7 +80,7 @@ SharedSurface_Gralloc::Create(GLContext* prodGL,
|
||||
gfxImageFormat format
|
||||
= gfxPlatform::GetPlatform()->OptimalFormatForContent(type);
|
||||
|
||||
GrallocTextureClientOGL* grallocTC =
|
||||
RefPtr<GrallocTextureClientOGL> grallocTC =
|
||||
new GrallocTextureClientOGL(
|
||||
allocator,
|
||||
gfx::ImageFormatToSurfaceFormat(format),
|
||||
@ -102,7 +102,6 @@ SharedSurface_Gralloc::Create(GLContext* prodGL,
|
||||
LOCAL_EGL_NATIVE_BUFFER_ANDROID,
|
||||
clientBuffer, attrs);
|
||||
if (!image) {
|
||||
grallocTC->DropTextureData()->DeallocateSharedData(allocator);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
@ -124,10 +124,7 @@ enum EffectTypes
|
||||
{
|
||||
EFFECT_MASK,
|
||||
EFFECT_MAX_SECONDARY, // sentinel for the count of secondary effect types
|
||||
EFFECT_BGRX,
|
||||
EFFECT_RGBX,
|
||||
EFFECT_BGRA,
|
||||
EFFECT_RGBA,
|
||||
EFFECT_RGB,
|
||||
EFFECT_YCBCR,
|
||||
EFFECT_COMPONENT_ALPHA,
|
||||
EFFECT_SOLID_COLOR,
|
||||
|
@ -105,49 +105,16 @@ struct EffectRenderTarget : public TexturedEffect
|
||||
RefPtr<CompositingRenderTarget> mRenderTarget;
|
||||
};
|
||||
|
||||
struct EffectBGRX : public TexturedEffect
|
||||
struct EffectRGB : public TexturedEffect
|
||||
{
|
||||
EffectBGRX(TextureSource *aBGRXTexture,
|
||||
EffectRGB(TextureSource *aTexture,
|
||||
bool aPremultiplied,
|
||||
gfx::Filter aFilter,
|
||||
bool aFlipped = false)
|
||||
: TexturedEffect(EFFECT_BGRX, aBGRXTexture, aPremultiplied, aFilter)
|
||||
: TexturedEffect(EFFECT_RGB, aTexture, aPremultiplied, aFilter)
|
||||
{}
|
||||
|
||||
virtual const char* Name() { return "EffectBGRX"; }
|
||||
};
|
||||
|
||||
struct EffectRGBX : public TexturedEffect
|
||||
{
|
||||
EffectRGBX(TextureSource *aRGBXTexture,
|
||||
bool aPremultiplied,
|
||||
gfx::Filter aFilter)
|
||||
: TexturedEffect(EFFECT_RGBX, aRGBXTexture, aPremultiplied, aFilter)
|
||||
{}
|
||||
|
||||
virtual const char* Name() { return "EffectRGBX"; }
|
||||
};
|
||||
|
||||
struct EffectBGRA : public TexturedEffect
|
||||
{
|
||||
EffectBGRA(TextureSource *aBGRATexture,
|
||||
bool aPremultiplied,
|
||||
gfx::Filter aFilter)
|
||||
: TexturedEffect(EFFECT_BGRA, aBGRATexture, aPremultiplied, aFilter)
|
||||
{}
|
||||
|
||||
virtual const char* Name() { return "EffectBGRA"; }
|
||||
};
|
||||
|
||||
struct EffectRGBA : public TexturedEffect
|
||||
{
|
||||
EffectRGBA(TextureSource *aRGBATexture,
|
||||
bool aPremultiplied,
|
||||
gfx::Filter aFilter)
|
||||
: TexturedEffect(EFFECT_RGBA, aRGBATexture, aPremultiplied, aFilter)
|
||||
{}
|
||||
|
||||
virtual const char* Name() { return "EffectRGBA"; }
|
||||
virtual const char* Name() { return "EffectRGB"; }
|
||||
};
|
||||
|
||||
struct EffectYCbCr : public TexturedEffect
|
||||
@ -215,19 +182,11 @@ CreateTexturedEffect(gfx::SurfaceFormat aFormat,
|
||||
RefPtr<TexturedEffect> result;
|
||||
switch (aFormat) {
|
||||
case gfx::SurfaceFormat::B8G8R8A8:
|
||||
result = new EffectBGRA(aSource, true, aFilter);
|
||||
break;
|
||||
case gfx::SurfaceFormat::B8G8R8X8:
|
||||
result = new EffectBGRX(aSource, true, aFilter);
|
||||
break;
|
||||
case gfx::SurfaceFormat::R8G8B8X8:
|
||||
result = new EffectRGBX(aSource, true, aFilter);
|
||||
break;
|
||||
case gfx::SurfaceFormat::R5G6B5:
|
||||
result = new EffectRGBX(aSource, true, aFilter);
|
||||
break;
|
||||
case gfx::SurfaceFormat::R8G8B8A8:
|
||||
result = new EffectRGBA(aSource, true, aFilter);
|
||||
result = new EffectRGB(aSource, true, aFilter);
|
||||
break;
|
||||
case gfx::SurfaceFormat::YUV:
|
||||
result = new EffectYCbCr(aSource, aFilter);
|
||||
|
@ -92,6 +92,9 @@ GrallocImage::SetData(const Data& aData)
|
||||
GraphicBuffer::USAGE_SW_WRITE_OFTEN |
|
||||
GraphicBuffer::USAGE_HW_TEXTURE,
|
||||
&desc);
|
||||
if (desc.type() == SurfaceDescriptor::T__None) {
|
||||
return;
|
||||
}
|
||||
mBufferAllocated = true;
|
||||
mGraphicBufferLocked = new GraphicBufferLocked(desc);
|
||||
}
|
||||
|
@ -48,13 +48,6 @@ namespace layers {
|
||||
|
||||
Atomic<int32_t> Image::sSerialCounter(0);
|
||||
|
||||
TemporaryRef<gfx::SourceSurface>
|
||||
Image::GetAsSourceSurface()
|
||||
{
|
||||
nsRefPtr<gfxASurface> surface = DeprecatedGetAsSurface();
|
||||
return gfxPlatform::GetPlatform()->GetSourceSurfaceForSurface(nullptr, surface);
|
||||
}
|
||||
|
||||
already_AddRefed<Image>
|
||||
ImageFactory::CreateImage(ImageFormat aFormat,
|
||||
const gfx::IntSize &,
|
||||
|
@ -213,7 +213,7 @@ public:
|
||||
void MarkSent() { mSent = true; }
|
||||
bool IsSentToCompositor() { return mSent; }
|
||||
|
||||
virtual TemporaryRef<gfx::SourceSurface> GetAsSourceSurface();
|
||||
virtual TemporaryRef<gfx::SourceSurface> GetAsSourceSurface() = 0;
|
||||
|
||||
protected:
|
||||
Image(void* aImplData, ImageFormat aFormat) :
|
||||
|
@ -701,9 +701,9 @@ SendTextureSource(GLContext* aGLContext,
|
||||
bool aFlipY)
|
||||
{
|
||||
GLenum textureTarget = aSource->GetTextureTarget();
|
||||
int shaderProgram =
|
||||
(int) ShaderProgramFromTargetAndFormat(textureTarget,
|
||||
ShaderConfigOGL config = ShaderConfigFromTargetAndFormat(textureTarget,
|
||||
aSource->GetFormat());
|
||||
int shaderConfig = config.mFeatures;
|
||||
|
||||
aSource->BindTexture(LOCAL_GL_TEXTURE0);
|
||||
|
||||
@ -725,7 +725,7 @@ SendTextureSource(GLContext* aGLContext,
|
||||
nsRefPtr<gfxImageSurface> img =
|
||||
aGLContext->ReadTexImageHelper()->ReadTexImage(0, textureTarget,
|
||||
gfxIntSize(size.width, size.height),
|
||||
shaderProgram, aFlipY);
|
||||
shaderConfig, aFlipY);
|
||||
|
||||
gLayerScopeWebSocketManager->AppendDebugData(
|
||||
new DebugGLTextureData(aGLContext, aLayerRef, textureTarget,
|
||||
@ -775,10 +775,7 @@ LayerScope::SendEffectChain(GLContext* aGLContext,
|
||||
|
||||
const Effect* primaryEffect = aEffectChain.mPrimaryEffect;
|
||||
switch (primaryEffect->mType) {
|
||||
case EFFECT_BGRX:
|
||||
case EFFECT_RGBX:
|
||||
case EFFECT_BGRA:
|
||||
case EFFECT_RGBA:
|
||||
case EFFECT_RGB:
|
||||
{
|
||||
const TexturedEffect* texturedEffect =
|
||||
static_cast<const TexturedEffect*>(primaryEffect);
|
||||
|
@ -482,10 +482,7 @@ BasicCompositor::DrawQuad(const gfx::Rect& aRect,
|
||||
DrawOptions(aOpacity));
|
||||
break;
|
||||
}
|
||||
case EFFECT_BGRA:
|
||||
case EFFECT_BGRX:
|
||||
case EFFECT_RGBA:
|
||||
case EFFECT_RGBX: {
|
||||
case EFFECT_RGB: {
|
||||
TexturedEffect* texturedEffect =
|
||||
static_cast<TexturedEffect*>(aEffectChain.mPrimaryEffect.get());
|
||||
TextureSourceBasic* source = texturedEffect->mTexture->AsSourceBasic();
|
||||
|
@ -132,7 +132,7 @@ CanvasClientSurfaceStream::Update(gfx::IntSize aSize, ClientCanvasLayer* aLayer)
|
||||
|
||||
SharedSurface_Gralloc* grallocSurf = SharedSurface_Gralloc::Cast(surf);
|
||||
|
||||
GrallocTextureClientOGL* grallocTextureClient =
|
||||
RefPtr<GrallocTextureClientOGL> grallocTextureClient =
|
||||
static_cast<GrallocTextureClientOGL*>(grallocSurf->GetTextureClient());
|
||||
|
||||
// If IPDLActor is null means this TextureClient didn't AddTextureClient yet
|
||||
|
@ -461,18 +461,19 @@ CompositorD3D11::SetRenderTarget(CompositingRenderTarget* aRenderTarget)
|
||||
}
|
||||
|
||||
void
|
||||
CompositorD3D11::SetPSForEffect(Effect* aEffect, MaskType aMaskType)
|
||||
CompositorD3D11::SetPSForEffect(Effect* aEffect, MaskType aMaskType, gfx::SurfaceFormat aFormat)
|
||||
{
|
||||
switch (aEffect->mType) {
|
||||
case EFFECT_SOLID_COLOR:
|
||||
mContext->PSSetShader(mAttachments->mSolidColorShader[aMaskType], nullptr, 0);
|
||||
return;
|
||||
case EFFECT_BGRA:
|
||||
case EFFECT_RENDER_TARGET:
|
||||
mContext->PSSetShader(mAttachments->mRGBAShader[aMaskType], nullptr, 0);
|
||||
return;
|
||||
case EFFECT_BGRX:
|
||||
mContext->PSSetShader(mAttachments->mRGBShader[aMaskType], nullptr, 0);
|
||||
case EFFECT_RGB:
|
||||
mContext->PSSetShader((aFormat == SurfaceFormat::B8G8R8A8 || aFormat == SurfaceFormat::R8G8B8A8)
|
||||
? mAttachments->mRGBAShader[aMaskType]
|
||||
: mAttachments->mRGBShader[aMaskType], nullptr, 0);
|
||||
return;
|
||||
case EFFECT_YCBCR:
|
||||
mContext->PSSetShader(mAttachments->mYCbCrShader[aMaskType], nullptr, 0);
|
||||
@ -510,7 +511,7 @@ CompositorD3D11::DrawQuad(const gfx::Rect& aRect,
|
||||
if (aTransform.Is2D()) {
|
||||
maskType = Mask2d;
|
||||
} else {
|
||||
MOZ_ASSERT(aEffectChain.mPrimaryEffect->mType == EFFECT_BGRA);
|
||||
MOZ_ASSERT(aEffectChain.mPrimaryEffect->mType == EFFECT_RGB);
|
||||
maskType = Mask3d;
|
||||
}
|
||||
|
||||
@ -546,7 +547,6 @@ CompositorD3D11::DrawQuad(const gfx::Rect& aRect,
|
||||
mContext->IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP);
|
||||
mContext->VSSetShader(mAttachments->mVSQuadShader[maskType], nullptr, 0);
|
||||
|
||||
SetPSForEffect(aEffectChain.mPrimaryEffect, maskType);
|
||||
|
||||
switch (aEffectChain.mPrimaryEffect->mType) {
|
||||
case EFFECT_SOLID_COLOR: {
|
||||
@ -558,13 +558,14 @@ CompositorD3D11::DrawQuad(const gfx::Rect& aRect,
|
||||
mPSConstants.layerColor[3] = color.a * aOpacity;
|
||||
}
|
||||
break;
|
||||
case EFFECT_BGRX:
|
||||
case EFFECT_BGRA:
|
||||
case EFFECT_RGB:
|
||||
case EFFECT_RENDER_TARGET:
|
||||
{
|
||||
TexturedEffect* texturedEffect =
|
||||
static_cast<TexturedEffect*>(aEffectChain.mPrimaryEffect.get());
|
||||
|
||||
SetPSForEffect(aEffectChain.mPrimaryEffect, maskType, texturedEffect->mTexture->GetFormat());
|
||||
|
||||
mVSConstants.textureCoords = texturedEffect->mTextureCoords;
|
||||
|
||||
TextureSourceD3D11* source = texturedEffect->mTexture->AsSourceD3D11();
|
||||
@ -592,6 +593,7 @@ CompositorD3D11::DrawQuad(const gfx::Rect& aRect,
|
||||
EffectYCbCr* ycbcrEffect =
|
||||
static_cast<EffectYCbCr*>(aEffectChain.mPrimaryEffect.get());
|
||||
|
||||
SetPSForEffect(aEffectChain.mPrimaryEffect, maskType, ycbcrEffect->mTexture->GetFormat());
|
||||
SetSamplerForFilter(Filter::LINEAR);
|
||||
|
||||
mVSConstants.textureCoords = ycbcrEffect->mTextureCoords;
|
||||
@ -632,6 +634,8 @@ CompositorD3D11::DrawQuad(const gfx::Rect& aRect,
|
||||
MOZ_ASSERT(mAttachments->mComponentBlendState);
|
||||
EffectComponentAlpha* effectComponentAlpha =
|
||||
static_cast<EffectComponentAlpha*>(aEffectChain.mPrimaryEffect.get());
|
||||
|
||||
SetPSForEffect(aEffectChain.mPrimaryEffect, maskType, effectComponentAlpha->mTexture->GetFormat());
|
||||
TextureSourceD3D11* sourceOnWhite = effectComponentAlpha->mOnWhite->AsSourceD3D11();
|
||||
TextureSourceD3D11* sourceOnBlack = effectComponentAlpha->mOnBlack->AsSourceD3D11();
|
||||
|
||||
|
@ -152,7 +152,7 @@ private:
|
||||
bool CreateShaders();
|
||||
void UpdateConstantBuffers();
|
||||
void SetSamplerForFilter(gfx::Filter aFilter);
|
||||
void SetPSForEffect(Effect *aEffect, MaskType aMaskType);
|
||||
void SetPSForEffect(Effect *aEffect, MaskType aMaskType, gfx::SurfaceFormat aFormat);
|
||||
void PaintToTarget();
|
||||
|
||||
RefPtr<ID3D11DeviceContext> mContext;
|
||||
|
@ -191,15 +191,16 @@ CompositorD3D9::SetRenderTarget(CompositingRenderTarget *aRenderTarget)
|
||||
}
|
||||
|
||||
static DeviceManagerD3D9::ShaderMode
|
||||
ShaderModeForEffectType(EffectTypes aEffectType)
|
||||
ShaderModeForEffectType(EffectTypes aEffectType, gfx::SurfaceFormat aFormat)
|
||||
{
|
||||
switch (aEffectType) {
|
||||
case EFFECT_SOLID_COLOR:
|
||||
return DeviceManagerD3D9::SOLIDCOLORLAYER;
|
||||
case EFFECT_BGRA:
|
||||
case EFFECT_RENDER_TARGET:
|
||||
return DeviceManagerD3D9::RGBALAYER;
|
||||
case EFFECT_BGRX:
|
||||
case EFFECT_RGB:
|
||||
if (aFormat == SurfaceFormat::B8G8R8A8 || aFormat == SurfaceFormat::R8G8B8A8)
|
||||
return DeviceManagerD3D9::RGBALAYER;
|
||||
return DeviceManagerD3D9::RGBLAYER;
|
||||
case EFFECT_YCBCR:
|
||||
return DeviceManagerD3D9::YCBCRLAYER;
|
||||
@ -287,8 +288,7 @@ CompositorD3D9::DrawQuad(const gfx::Rect &aRect,
|
||||
}
|
||||
break;
|
||||
case EFFECT_RENDER_TARGET:
|
||||
case EFFECT_BGRX:
|
||||
case EFFECT_BGRA:
|
||||
case EFFECT_RGB:
|
||||
{
|
||||
TexturedEffect* texturedEffect =
|
||||
static_cast<TexturedEffect*>(aEffectChain.mPrimaryEffect.get());
|
||||
@ -308,7 +308,8 @@ CompositorD3D9::DrawQuad(const gfx::Rect &aRect,
|
||||
d3d9Device->SetTexture(0, source->GetD3D9Texture());
|
||||
|
||||
maskTexture = mDeviceManager
|
||||
->SetShaderMode(ShaderModeForEffectType(aEffectChain.mPrimaryEffect->mType),
|
||||
->SetShaderMode(ShaderModeForEffectType(aEffectChain.mPrimaryEffect->mType,
|
||||
texturedEffect->mTexture->GetFormat()),
|
||||
maskType);
|
||||
|
||||
isPremultiplied = texturedEffect->mPremultiplied;
|
||||
|
@ -34,7 +34,6 @@ EXPORTS += [
|
||||
'LayerTreeInvalidation.h',
|
||||
'opengl/Composer2D.h',
|
||||
'opengl/OGLShaderProgram.h',
|
||||
'opengl/OGLShaders.h',
|
||||
'opengl/TexturePoolOGL.h',
|
||||
'ReadbackLayer.h',
|
||||
'SharedTextureImage.h',
|
||||
|
@ -52,6 +52,7 @@
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
using namespace std;
|
||||
using namespace gfx;
|
||||
|
||||
namespace layers {
|
||||
@ -177,19 +178,6 @@ CompositorOGL::CreateContext()
|
||||
return context.forget();
|
||||
}
|
||||
|
||||
void
|
||||
CompositorOGL::AddPrograms(ShaderProgramType aType)
|
||||
{
|
||||
for (uint32_t maskType = MaskNone; maskType < NumMaskTypes; ++maskType) {
|
||||
if (ProgramProfileOGL::ProgramExists(aType, static_cast<MaskType>(maskType))) {
|
||||
mPrograms[aType].mVariations[maskType] = new ShaderProgramOGL(this->gl(),
|
||||
ProgramProfileOGL::GetProfileFor(aType, static_cast<MaskType>(maskType)));
|
||||
} else {
|
||||
mPrograms[aType].mVariations[maskType] = nullptr;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
GLuint
|
||||
CompositorOGL::GetTemporaryTexture(GLenum aTextureUnit)
|
||||
{
|
||||
@ -239,7 +227,12 @@ CompositorOGL::CleanupResources()
|
||||
ctx = mGLContext;
|
||||
}
|
||||
|
||||
mPrograms.Clear();
|
||||
for (std::map<ShaderConfigOGL, ShaderProgramOGL *>::iterator iter = mPrograms.begin();
|
||||
iter != mPrograms.end();
|
||||
iter++) {
|
||||
delete iter->second;
|
||||
}
|
||||
mPrograms.clear();
|
||||
|
||||
if (!ctx->MakeCurrent()) {
|
||||
mQuadVBO = 0;
|
||||
@ -285,13 +278,10 @@ CompositorOGL::Initialize()
|
||||
LOCAL_GL_ONE, LOCAL_GL_ONE);
|
||||
mGLContext->fEnable(LOCAL_GL_BLEND);
|
||||
|
||||
mPrograms.AppendElements(NumProgramTypes);
|
||||
for (int type = 0; type < NumProgramTypes; ++type) {
|
||||
AddPrograms(static_cast<ShaderProgramType>(type));
|
||||
}
|
||||
|
||||
// initialise a common shader to check that we can actually compile a shader
|
||||
if (!mPrograms[RGBALayerProgramType].mVariations[MaskNone]->Initialize()) {
|
||||
RefPtr<EffectSolidColor> effect = new EffectSolidColor(Color(0, 0, 0, 0));
|
||||
ShaderConfigOGL config = GetShaderConfigFor(effect);
|
||||
if (!GetShaderProgramFor(config)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -543,21 +533,7 @@ CompositorOGL::PrepareViewport(const gfx::IntSize& aSize,
|
||||
Matrix4x4 matrix3d = Matrix4x4::From2D(viewMatrix);
|
||||
matrix3d._33 = 0.0f;
|
||||
|
||||
SetLayerProgramProjectionMatrix(matrix3d);
|
||||
}
|
||||
|
||||
void
|
||||
CompositorOGL::SetLayerProgramProjectionMatrix(const Matrix4x4& aMatrix)
|
||||
{
|
||||
// Update the projection matrix in all of the programs, without activating them.
|
||||
// The uniform will actually be set the next time the program is activated.
|
||||
for (unsigned int i = 0; i < mPrograms.Length(); ++i) {
|
||||
for (uint32_t mask = MaskNone; mask < NumMaskTypes; ++mask) {
|
||||
if (mPrograms[i].mVariations[mask]) {
|
||||
mPrograms[i].mVariations[mask]->DelayedSetProjectionMatrix(aMatrix);
|
||||
}
|
||||
}
|
||||
}
|
||||
mProjMatrix = matrix3d;
|
||||
}
|
||||
|
||||
TemporaryRef<CompositingRenderTarget>
|
||||
@ -835,31 +811,62 @@ CompositorOGL::CreateFBOWithTexture(const IntRect& aRect, bool aCopyFromSource,
|
||||
*aTexture = tex;
|
||||
}
|
||||
|
||||
ShaderProgramType
|
||||
CompositorOGL::GetProgramTypeForEffect(Effect *aEffect) const
|
||||
ShaderConfigOGL
|
||||
CompositorOGL::GetShaderConfigFor(Effect *aEffect, MaskType aMask) const
|
||||
{
|
||||
ShaderConfigOGL config;
|
||||
|
||||
switch(aEffect->mType) {
|
||||
case EFFECT_SOLID_COLOR:
|
||||
return ColorLayerProgramType;
|
||||
case EFFECT_RGBA:
|
||||
case EFFECT_RGBX:
|
||||
case EFFECT_BGRA:
|
||||
case EFFECT_BGRX:
|
||||
config.SetRenderColor(true);
|
||||
break;
|
||||
case EFFECT_YCBCR:
|
||||
config.SetYCbCr(true);
|
||||
break;
|
||||
case EFFECT_COMPONENT_ALPHA:
|
||||
config.SetComponentAlpha(true);
|
||||
break;
|
||||
case EFFECT_RENDER_TARGET:
|
||||
config.SetTextureTarget(mFBOTextureTarget);
|
||||
break;
|
||||
default:
|
||||
{
|
||||
MOZ_ASSERT(aEffect->mType == EFFECT_RGB);
|
||||
TexturedEffect* texturedEffect =
|
||||
static_cast<TexturedEffect*>(aEffect);
|
||||
TextureSourceOGL* source = texturedEffect->mTexture->AsSourceOGL();
|
||||
|
||||
return ShaderProgramFromTargetAndFormat(source->GetTextureTarget(),
|
||||
MOZ_ASSERT_IF(source->GetTextureTarget() == LOCAL_GL_TEXTURE_EXTERNAL,
|
||||
source->GetFormat() == gfx::SurfaceFormat::R8G8B8A8);
|
||||
MOZ_ASSERT_IF(source->GetTextureTarget() == LOCAL_GL_TEXTURE_RECTANGLE_ARB,
|
||||
source->GetFormat() == gfx::SurfaceFormat::R8G8B8A8 ||
|
||||
source->GetFormat() == gfx::SurfaceFormat::R8G8B8X8 ||
|
||||
source->GetFormat() == gfx::SurfaceFormat::R5G6B5);
|
||||
config = ShaderConfigFromTargetAndFormat(source->GetTextureTarget(),
|
||||
source->GetFormat());
|
||||
break;
|
||||
}
|
||||
case EFFECT_YCBCR:
|
||||
return YCbCrLayerProgramType;
|
||||
case EFFECT_RENDER_TARGET:
|
||||
return GetFBOLayerProgramType();
|
||||
default:
|
||||
return RGBALayerProgramType;
|
||||
}
|
||||
config.SetMask2D(aMask == Mask2d);
|
||||
config.SetMask3D(aMask == Mask3d);
|
||||
return config;
|
||||
}
|
||||
|
||||
ShaderProgramOGL*
|
||||
CompositorOGL::GetShaderProgramFor(const ShaderConfigOGL &aConfig)
|
||||
{
|
||||
std::map<ShaderConfigOGL, ShaderProgramOGL *>::iterator iter = mPrograms.find(aConfig);
|
||||
if (iter != mPrograms.end())
|
||||
return iter->second;
|
||||
|
||||
ProgramProfileOGL profile = ProgramProfileOGL::GetProfileFor(aConfig);
|
||||
ShaderProgramOGL *shader = new ShaderProgramOGL(gl(), profile);
|
||||
if (!shader->Initialize()) {
|
||||
delete shader;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
mPrograms[aConfig] = shader;
|
||||
return shader;
|
||||
}
|
||||
|
||||
struct MOZ_STACK_CLASS AutoBindTexture
|
||||
@ -1029,39 +1036,45 @@ CompositorOGL::DrawQuadInternal(const Rect& aRect,
|
||||
|
||||
mPixelsFilled += aRect.width * aRect.height;
|
||||
|
||||
ShaderProgramType programType = GetProgramTypeForEffect(aEffectChain.mPrimaryEffect);
|
||||
ShaderProgramOGL *program = GetProgram(programType, maskType);
|
||||
program->Activate();
|
||||
if (programType == RGBARectLayerProgramType ||
|
||||
programType == RGBXRectLayerProgramType) {
|
||||
TexturedEffect* texturedEffect =
|
||||
static_cast<TexturedEffect*>(aEffectChain.mPrimaryEffect.get());
|
||||
TextureSourceOGL* source = texturedEffect->mTexture->AsSourceOGL();
|
||||
// This is used by IOSurface that use 0,0...w,h coordinate rather then 0,0..1,1.
|
||||
program->SetTexCoordMultiplier(source->GetSize().width, source->GetSize().height);
|
||||
}
|
||||
program->SetLayerQuadRect(aRect);
|
||||
program->SetLayerTransform(aTransform);
|
||||
IntPoint offset = mCurrentRenderTarget->GetOrigin();
|
||||
program->SetRenderOffset(offset.x, offset.y);
|
||||
|
||||
switch (aEffectChain.mPrimaryEffect->mType) {
|
||||
case EFFECT_SOLID_COLOR: {
|
||||
// Determine the color if this is a color shader and fold the opacity into
|
||||
// the color since color shaders don't have an opacity uniform.
|
||||
Color color;
|
||||
if (aEffectChain.mPrimaryEffect->mType == EFFECT_SOLID_COLOR) {
|
||||
EffectSolidColor* effectSolidColor =
|
||||
static_cast<EffectSolidColor*>(aEffectChain.mPrimaryEffect.get());
|
||||
color = effectSolidColor->mColor;
|
||||
|
||||
Color color = effectSolidColor->mColor;
|
||||
/* Multiply color by the layer opacity, as the shader
|
||||
* ignores layer opacity and expects a final color to
|
||||
* write to the color buffer. This saves a needless
|
||||
* multiply in the fragment shader.
|
||||
*/
|
||||
Float opacity = aOpacity * color.a;
|
||||
color.r *= opacity;
|
||||
color.g *= opacity;
|
||||
color.b *= opacity;
|
||||
color.a = opacity;
|
||||
|
||||
// We can fold opacity into the color, so no need to consider it further.
|
||||
aOpacity = 1.f;
|
||||
}
|
||||
|
||||
ShaderConfigOGL config = GetShaderConfigFor(aEffectChain.mPrimaryEffect, maskType);
|
||||
config.SetOpacity(aOpacity != 1.f);
|
||||
ShaderProgramOGL *program = GetShaderProgramFor(config);
|
||||
program->Activate();
|
||||
program->SetProjectionMatrix(mProjMatrix);
|
||||
program->SetLayerQuadRect(aRect);
|
||||
program->SetLayerTransform(aTransform);
|
||||
IntPoint offset = mCurrentRenderTarget->GetOrigin();
|
||||
program->SetRenderOffset(offset.x, offset.y);
|
||||
if (aOpacity != 1.f)
|
||||
program->SetLayerOpacity(aOpacity);
|
||||
if (config.mFeatures & ENABLE_TEXTURE_RECT) {
|
||||
TexturedEffect* texturedEffect =
|
||||
static_cast<TexturedEffect*>(aEffectChain.mPrimaryEffect.get());
|
||||
TextureSourceOGL* source = texturedEffect->mTexture->AsSourceOGL();
|
||||
// This is used by IOSurface that use 0,0...w,h coordinate rather then 0,0..1,1.
|
||||
program->SetTexCoordMultiplier(source->GetSize().width, source->GetSize().height);
|
||||
}
|
||||
|
||||
switch (aEffectChain.mPrimaryEffect->mType) {
|
||||
case EFFECT_SOLID_COLOR: {
|
||||
program->SetRenderColor(color);
|
||||
|
||||
AutoSaveTexture bindMask(mGLContext, LOCAL_GL_TEXTURE0);
|
||||
@ -1073,13 +1086,9 @@ CompositorOGL::DrawQuadInternal(const Rect& aRect,
|
||||
}
|
||||
break;
|
||||
|
||||
case EFFECT_BGRA:
|
||||
case EFFECT_BGRX:
|
||||
case EFFECT_RGBA:
|
||||
case EFFECT_RGBX: {
|
||||
case EFFECT_RGB: {
|
||||
TexturedEffect* texturedEffect =
|
||||
static_cast<TexturedEffect*>(aEffectChain.mPrimaryEffect.get());
|
||||
Rect textureCoords;
|
||||
TextureSource *source = texturedEffect->mTexture;
|
||||
|
||||
if (!texturedEffect->mPremultiplied) {
|
||||
@ -1109,7 +1118,6 @@ CompositorOGL::DrawQuadInternal(const Rect& aRect,
|
||||
source->AsSourceOGL()->GetTextureTarget());
|
||||
|
||||
program->SetTextureUnit(0);
|
||||
program->SetLayerOpacity(aOpacity);
|
||||
|
||||
AutoSaveTexture bindMask(mGLContext, LOCAL_GL_TEXTURE1);
|
||||
if (maskType != MaskNone) {
|
||||
@ -1149,7 +1157,6 @@ CompositorOGL::DrawQuadInternal(const Rect& aRect,
|
||||
ApplyFilterToBoundTexture(mGLContext, filter);
|
||||
|
||||
program->SetYCbCrTextureUnits(Y, Cb, Cr);
|
||||
program->SetLayerOpacity(aOpacity);
|
||||
|
||||
AutoSaveTexture bindMask(mGLContext, LOCAL_GL_TEXTURE3);
|
||||
if (maskType != MaskNone) {
|
||||
@ -1167,14 +1174,10 @@ CompositorOGL::DrawQuadInternal(const Rect& aRect,
|
||||
RefPtr<CompositingRenderTargetOGL> surface
|
||||
= static_cast<CompositingRenderTargetOGL*>(effectRenderTarget->mRenderTarget.get());
|
||||
|
||||
ShaderProgramOGL *program = GetProgram(GetFBOLayerProgramType(), maskType);
|
||||
|
||||
surface->BindTexture(LOCAL_GL_TEXTURE0, mFBOTextureTarget);
|
||||
|
||||
program->Activate();
|
||||
program->SetTextureUnit(0);
|
||||
program->SetLayerOpacity(aOpacity);
|
||||
program->SetTextureTransform(Matrix4x4());
|
||||
program->SetTextureUnit(0);
|
||||
|
||||
AutoSaveTexture bindMask(mGLContext, LOCAL_GL_TEXTURE1);
|
||||
if (maskType != MaskNone) {
|
||||
@ -1183,7 +1186,7 @@ CompositorOGL::DrawQuadInternal(const Rect& aRect,
|
||||
program->SetMaskLayerTransform(maskQuadTransform);
|
||||
}
|
||||
|
||||
if (program->GetTexCoordMultiplierUniformLocation() != -1) {
|
||||
if (config.mFeatures & ENABLE_TEXTURE_RECT) {
|
||||
// 2DRect case, get the multiplier right for a sampler2DRect
|
||||
program->SetTexCoordMultiplier(aRect.width, aRect.height);
|
||||
}
|
||||
@ -1207,39 +1210,30 @@ CompositorOGL::DrawQuadInternal(const Rect& aRect,
|
||||
return;
|
||||
}
|
||||
|
||||
for (int32_t pass = 1; pass <=2; ++pass) {
|
||||
ShaderProgramOGL* program;
|
||||
if (pass == 1) {
|
||||
ShaderProgramType type = gl()->GetPreferredARGB32Format() == LOCAL_GL_BGRA ?
|
||||
ComponentAlphaPass1RGBProgramType :
|
||||
ComponentAlphaPass1ProgramType;
|
||||
program = GetProgram(type, maskType);
|
||||
gl()->fBlendFuncSeparate(LOCAL_GL_ZERO, LOCAL_GL_ONE_MINUS_SRC_COLOR,
|
||||
LOCAL_GL_ONE, LOCAL_GL_ONE);
|
||||
} else {
|
||||
ShaderProgramType type = gl()->GetPreferredARGB32Format() == LOCAL_GL_BGRA ?
|
||||
ComponentAlphaPass2RGBProgramType :
|
||||
ComponentAlphaPass2ProgramType;
|
||||
program = GetProgram(type, maskType);
|
||||
gl()->fBlendFuncSeparate(LOCAL_GL_ONE, LOCAL_GL_ONE,
|
||||
LOCAL_GL_ONE, LOCAL_GL_ONE);
|
||||
}
|
||||
|
||||
AutoBindTexture bindSourceOnBlack(mGLContext, sourceOnBlack, LOCAL_GL_TEXTURE0);
|
||||
AutoBindTexture bindSourceOnWhite(mGLContext, sourceOnWhite, LOCAL_GL_TEXTURE1);
|
||||
|
||||
program->Activate();
|
||||
program->SetBlackTextureUnit(0);
|
||||
program->SetWhiteTextureUnit(1);
|
||||
program->SetLayerOpacity(aOpacity);
|
||||
program->SetLayerTransform(aTransform);
|
||||
program->SetRenderOffset(offset.x, offset.y);
|
||||
program->SetLayerQuadRect(aRect);
|
||||
AutoSaveTexture bindMask(mGLContext, LOCAL_GL_TEXTURE2);
|
||||
program->SetTextureTransform(gfx::Matrix4x4());
|
||||
|
||||
AutoBindTexture bindMask(mGLContext);
|
||||
if (maskType != MaskNone) {
|
||||
BindMaskForProgram(program, sourceMask, LOCAL_GL_TEXTURE2, maskQuadTransform);
|
||||
}
|
||||
// Pass 1.
|
||||
gl()->fBlendFuncSeparate(LOCAL_GL_ZERO, LOCAL_GL_ONE_MINUS_SRC_COLOR,
|
||||
LOCAL_GL_ONE, LOCAL_GL_ONE);
|
||||
program->SetTexturePass2(false);
|
||||
BindAndDrawQuadWithTextureRect(program,
|
||||
gfx3DMatrix(),
|
||||
effectComponentAlpha->mTextureCoords,
|
||||
effectComponentAlpha->mOnBlack);
|
||||
|
||||
// Pass 2.
|
||||
gl()->fBlendFuncSeparate(LOCAL_GL_ONE, LOCAL_GL_ONE,
|
||||
LOCAL_GL_ONE, LOCAL_GL_ONE);
|
||||
program->SetTexturePass2(true);
|
||||
BindAndDrawQuadWithTextureRect(program,
|
||||
gfx3DMatrix(),
|
||||
effectComponentAlpha->mTextureCoords,
|
||||
@ -1248,7 +1242,6 @@ CompositorOGL::DrawQuadInternal(const Rect& aRect,
|
||||
mGLContext->fBlendFuncSeparate(LOCAL_GL_ONE, LOCAL_GL_ONE_MINUS_SRC_ALPHA,
|
||||
LOCAL_GL_ONE, LOCAL_GL_ONE);
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
MOZ_ASSERT(false, "Unhandled effect type");
|
||||
|
@ -55,10 +55,10 @@ struct EffectChain;
|
||||
class CompositorOGL : public Compositor
|
||||
{
|
||||
typedef mozilla::gl::GLContext GLContext;
|
||||
typedef ShaderProgramType ProgramType;
|
||||
|
||||
friend class GLManagerCompositor;
|
||||
|
||||
std::map<ShaderConfigOGL, ShaderProgramOGL*> mPrograms;
|
||||
public:
|
||||
CompositorOGL(nsIWidget *aWidget, int aSurfaceWidth = -1, int aSurfaceHeight = -1,
|
||||
bool aUseExternalSurfaceSize = false);
|
||||
@ -160,10 +160,6 @@ public:
|
||||
virtual nsIWidget* GetWidget() const MOZ_OVERRIDE { return mWidget; }
|
||||
|
||||
GLContext* gl() const { return mGLContext; }
|
||||
ShaderProgramType GetFBOLayerProgramType() const {
|
||||
return mFBOTextureTarget == LOCAL_GL_TEXTURE_RECTANGLE_ARB ?
|
||||
RGBARectLayerProgramType : RGBALayerProgramType;
|
||||
}
|
||||
gfx::SurfaceFormat GetFBOFormat() const {
|
||||
return gfx::SurfaceFormat::R8G8B8A8;
|
||||
}
|
||||
@ -175,6 +171,10 @@ public:
|
||||
* (see https://wiki.mozilla.org/Platform/GFX/Gralloc)
|
||||
*/
|
||||
GLuint GetTemporaryTexture(GLenum aUnit);
|
||||
|
||||
const gfx::Matrix4x4& GetProjMatrix() const {
|
||||
return mProjMatrix;
|
||||
}
|
||||
private:
|
||||
virtual void DrawQuadInternal(const gfx::Rect& aRect,
|
||||
const gfx::Rect& aClipRect,
|
||||
@ -192,6 +192,7 @@ private:
|
||||
nsIWidget *mWidget;
|
||||
nsIntSize mWidgetSize;
|
||||
nsRefPtr<GLContext> mGLContext;
|
||||
gfx::Matrix4x4 mProjMatrix;
|
||||
|
||||
/** The size of the surface we are rendering to */
|
||||
nsIntSize mSurfaceSize;
|
||||
@ -200,19 +201,6 @@ private:
|
||||
|
||||
already_AddRefed<mozilla::gl::GLContext> CreateContext();
|
||||
|
||||
/** Shader Programs */
|
||||
struct ShaderProgramVariations {
|
||||
nsAutoTArray<nsAutoPtr<ShaderProgramOGL>, NumMaskTypes> mVariations;
|
||||
ShaderProgramVariations() {
|
||||
MOZ_COUNT_CTOR(ShaderProgramVariations);
|
||||
mVariations.SetLength(NumMaskTypes);
|
||||
}
|
||||
~ShaderProgramVariations() {
|
||||
MOZ_COUNT_DTOR(ShaderProgramVariations);
|
||||
}
|
||||
};
|
||||
nsTArray<ShaderProgramVariations> mPrograms;
|
||||
|
||||
/** Texture target to use for FBOs */
|
||||
GLenum mFBOTextureTarget;
|
||||
|
||||
@ -261,25 +249,8 @@ private:
|
||||
gfx::Rect *aClipRectOut = nullptr,
|
||||
gfx::Rect *aRenderBoundsOut = nullptr) MOZ_OVERRIDE;
|
||||
|
||||
ShaderProgramType GetProgramTypeForEffect(Effect* aEffect) const;
|
||||
|
||||
/**
|
||||
* Updates all layer programs with a new projection matrix.
|
||||
*/
|
||||
void SetLayerProgramProjectionMatrix(const gfx::Matrix4x4& aMatrix);
|
||||
|
||||
/**
|
||||
* Helper method for Initialize, creates all valid variations of a program
|
||||
* and adds them to mPrograms
|
||||
*/
|
||||
void AddPrograms(ShaderProgramType aType);
|
||||
|
||||
ShaderProgramOGL* GetProgram(ShaderProgramType aType,
|
||||
MaskType aMask = MaskNone) {
|
||||
MOZ_ASSERT(ProgramProfileOGL::ProgramExists(aType, aMask),
|
||||
"Invalid program type.");
|
||||
return mPrograms[aType].mVariations[aMask];
|
||||
}
|
||||
ShaderConfigOGL GetShaderConfigFor(Effect *aEffect, MaskType aMask = MaskNone) const;
|
||||
ShaderProgramOGL* GetShaderProgramFor(const ShaderConfigOGL &aConfig);
|
||||
|
||||
/**
|
||||
* Create a FBO backed by a texture.
|
||||
|
@ -32,9 +32,15 @@ public:
|
||||
return mImpl->gl();
|
||||
}
|
||||
|
||||
virtual ShaderProgramOGL* GetProgram(ShaderProgramType aType) MOZ_OVERRIDE
|
||||
virtual ShaderProgramOGL* GetProgram(GLenum aTarget, gfx::SurfaceFormat aFormat) MOZ_OVERRIDE
|
||||
{
|
||||
return mImpl->GetProgram(aType);
|
||||
ShaderConfigOGL config = ShaderConfigFromTargetAndFormat(aTarget, aFormat);
|
||||
return mImpl->GetShaderProgramFor(config);
|
||||
}
|
||||
|
||||
virtual const gfx::Matrix4x4& GetProjMatrix() const MOZ_OVERRIDE
|
||||
{
|
||||
return mImpl->GetProjMatrix();
|
||||
}
|
||||
|
||||
virtual void BindAndDrawQuad(ShaderProgramOGL *aProg) MOZ_OVERRIDE
|
||||
|
@ -31,12 +31,9 @@ public:
|
||||
virtual ~GLManager() {}
|
||||
|
||||
virtual gl::GLContext* gl() const = 0;
|
||||
virtual ShaderProgramOGL* GetProgram(ShaderProgramType aType) = 0;
|
||||
virtual ShaderProgramOGL* GetProgram(GLenum aTarget, gfx::SurfaceFormat aFormat) = 0;
|
||||
virtual const gfx::Matrix4x4& GetProjMatrix() const = 0;
|
||||
virtual void BindAndDrawQuad(ShaderProgramOGL *aProg) = 0;
|
||||
|
||||
ShaderProgramOGL* GetProgram(gfx::SurfaceFormat aFormat) {
|
||||
return GetProgram(ShaderProgramFromSurfaceFormat(aFormat));
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -4,13 +4,13 @@
|
||||
|
||||
#include "OGLShaderProgram.h"
|
||||
#include <stdint.h> // for uint32_t
|
||||
#include <sstream> // for ostringstream
|
||||
#include "gfxRect.h" // for gfxRect
|
||||
#include "mozilla/DebugOnly.h" // for DebugOnly
|
||||
#include "nsAString.h"
|
||||
#include "nsAutoPtr.h" // for nsRefPtr
|
||||
#include "nsString.h" // for nsAutoCString
|
||||
#include "prenv.h" // for PR_GetEnv
|
||||
#include "OGLShaders.h"
|
||||
#include "Layers.h"
|
||||
#include "GLContext.h"
|
||||
|
||||
@ -19,8 +19,13 @@ struct gfxRGBA;
|
||||
namespace mozilla {
|
||||
namespace layers {
|
||||
|
||||
using namespace std;
|
||||
|
||||
typedef ProgramProfileOGL::Argument Argument;
|
||||
|
||||
#define GAUSSIAN_KERNEL_HALF_WIDTH 11
|
||||
#define GAUSSIAN_KERNEL_STEP 0.2
|
||||
|
||||
void
|
||||
AddUniforms(ProgramProfileOGL& aProfile)
|
||||
{
|
||||
@ -41,6 +46,7 @@ AddUniforms(ProgramProfileOGL& aProfile)
|
||||
"uMaskTexture",
|
||||
"uRenderColor",
|
||||
"uTexCoordMultiplier",
|
||||
"uTexturePass2",
|
||||
nullptr
|
||||
};
|
||||
|
||||
@ -51,222 +57,302 @@ AddUniforms(ProgramProfileOGL& aProfile)
|
||||
}
|
||||
|
||||
void
|
||||
AddCommonArgs(ProgramProfileOGL& aProfile)
|
||||
ShaderConfigOGL::SetRenderColor(bool aEnabled)
|
||||
{
|
||||
aProfile.mAttributes.AppendElement(Argument("aVertexCoord"));
|
||||
SetFeature(ENABLE_RENDER_COLOR, aEnabled);
|
||||
}
|
||||
|
||||
void
|
||||
AddCommonTextureArgs(ProgramProfileOGL& aProfile)
|
||||
ShaderConfigOGL::SetTextureTarget(GLenum aTarget)
|
||||
{
|
||||
aProfile.mAttributes.AppendElement(Argument("aTexCoord"));
|
||||
SetFeature(ENABLE_TEXTURE_EXTERNAL | ENABLE_TEXTURE_RECT, false);
|
||||
switch (aTarget) {
|
||||
case LOCAL_GL_TEXTURE_EXTERNAL:
|
||||
SetFeature(ENABLE_TEXTURE_EXTERNAL, true);
|
||||
break;
|
||||
case LOCAL_GL_TEXTURE_RECTANGLE_ARB:
|
||||
SetFeature(ENABLE_TEXTURE_RECT, true);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
ShaderConfigOGL::SetRBSwap(bool aEnabled)
|
||||
{
|
||||
SetFeature(ENABLE_TEXTURE_RB_SWAP, aEnabled);
|
||||
}
|
||||
|
||||
void
|
||||
ShaderConfigOGL::SetNoAlpha(bool aEnabled)
|
||||
{
|
||||
SetFeature(ENABLE_TEXTURE_NO_ALPHA, aEnabled);
|
||||
}
|
||||
|
||||
void
|
||||
ShaderConfigOGL::SetOpacity(bool aEnabled)
|
||||
{
|
||||
SetFeature(ENABLE_OPACITY, aEnabled);
|
||||
}
|
||||
|
||||
void
|
||||
ShaderConfigOGL::SetYCbCr(bool aEnabled)
|
||||
{
|
||||
SetFeature(ENABLE_TEXTURE_YCBCR, aEnabled);
|
||||
}
|
||||
|
||||
void
|
||||
ShaderConfigOGL::SetComponentAlpha(bool aEnabled)
|
||||
{
|
||||
SetFeature(ENABLE_TEXTURE_COMPONENT_ALPHA, aEnabled);
|
||||
}
|
||||
|
||||
void
|
||||
ShaderConfigOGL::SetColorMatrix(bool aEnabled)
|
||||
{
|
||||
SetFeature(ENABLE_COLOR_MATRIX, aEnabled);
|
||||
}
|
||||
|
||||
void
|
||||
ShaderConfigOGL::SetBlur(bool aEnabled)
|
||||
{
|
||||
SetFeature(ENABLE_BLUR, aEnabled);
|
||||
}
|
||||
|
||||
void
|
||||
ShaderConfigOGL::SetMask2D(bool aEnabled)
|
||||
{
|
||||
SetFeature(ENABLE_MASK_2D, aEnabled);
|
||||
}
|
||||
|
||||
void
|
||||
ShaderConfigOGL::SetMask3D(bool aEnabled)
|
||||
{
|
||||
SetFeature(ENABLE_MASK_3D, aEnabled);
|
||||
}
|
||||
|
||||
/* static */ ProgramProfileOGL
|
||||
ProgramProfileOGL::GetProfileFor(ShaderProgramType aType,
|
||||
MaskType aMask)
|
||||
ProgramProfileOGL::GetProfileFor(ShaderConfigOGL aConfig)
|
||||
{
|
||||
NS_ASSERTION(ProgramExists(aType, aMask), "Invalid program type.");
|
||||
ProgramProfileOGL result;
|
||||
ostringstream fs, vs;
|
||||
|
||||
AddUniforms(result);
|
||||
|
||||
switch (aType) {
|
||||
case RGBALayerProgramType:
|
||||
if (aMask == Mask3d) {
|
||||
result.mVertexShaderString = sLayerMask3DVS;
|
||||
result.mFragmentShaderString = sRGBATextureLayerMask3DFS;
|
||||
} else if (aMask == Mask2d) {
|
||||
result.mVertexShaderString = sLayerMaskVS;
|
||||
result.mFragmentShaderString = sRGBATextureLayerMaskFS;
|
||||
} else {
|
||||
result.mVertexShaderString = sLayerVS;
|
||||
result.mFragmentShaderString = sRGBATextureLayerFS;
|
||||
}
|
||||
AddCommonArgs(result);
|
||||
AddCommonTextureArgs(result);
|
||||
result.mTextureCount = 1;
|
||||
break;
|
||||
case BGRALayerProgramType:
|
||||
if (aMask == Mask2d) {
|
||||
result.mVertexShaderString = sLayerMaskVS;
|
||||
result.mFragmentShaderString = sBGRATextureLayerMaskFS;
|
||||
} else {
|
||||
result.mVertexShaderString = sLayerVS;
|
||||
result.mFragmentShaderString = sBGRATextureLayerFS;
|
||||
}
|
||||
AddCommonArgs(result);
|
||||
AddCommonTextureArgs(result);
|
||||
result.mTextureCount = 1;
|
||||
break;
|
||||
case RGBXLayerProgramType:
|
||||
if (aMask == Mask2d) {
|
||||
result.mVertexShaderString = sLayerMaskVS;
|
||||
result.mFragmentShaderString = sRGBXTextureLayerMaskFS;
|
||||
} else {
|
||||
result.mVertexShaderString = sLayerVS;
|
||||
result.mFragmentShaderString = sRGBXTextureLayerFS;
|
||||
}
|
||||
AddCommonArgs(result);
|
||||
AddCommonTextureArgs(result);
|
||||
result.mTextureCount = 1;
|
||||
break;
|
||||
case BGRXLayerProgramType:
|
||||
if (aMask == Mask2d) {
|
||||
result.mVertexShaderString = sLayerMaskVS;
|
||||
result.mFragmentShaderString = sBGRXTextureLayerMaskFS;
|
||||
} else {
|
||||
result.mVertexShaderString = sLayerVS;
|
||||
result.mFragmentShaderString = sBGRXTextureLayerFS;
|
||||
}
|
||||
AddCommonArgs(result);
|
||||
AddCommonTextureArgs(result);
|
||||
result.mTextureCount = 1;
|
||||
break;
|
||||
case RGBARectLayerProgramType:
|
||||
if (aMask == Mask3d) {
|
||||
result.mVertexShaderString = sLayerMask3DVS;
|
||||
result.mFragmentShaderString = sRGBARectTextureLayerMask3DFS;
|
||||
} else if (aMask == Mask2d) {
|
||||
result.mVertexShaderString = sLayerMaskVS;
|
||||
result.mFragmentShaderString = sRGBARectTextureLayerMaskFS;
|
||||
} else {
|
||||
result.mVertexShaderString = sLayerVS;
|
||||
result.mFragmentShaderString = sRGBARectTextureLayerFS;
|
||||
}
|
||||
AddCommonArgs(result);
|
||||
AddCommonTextureArgs(result);
|
||||
result.mTextureCount = 1;
|
||||
break;
|
||||
case RGBXRectLayerProgramType:
|
||||
if (aMask == Mask3d) {
|
||||
result.mVertexShaderString = sLayerMask3DVS;
|
||||
result.mFragmentShaderString = sRGBXRectTextureLayerMask3DFS;
|
||||
} else if (aMask == Mask2d) {
|
||||
result.mVertexShaderString = sLayerMaskVS;
|
||||
result.mFragmentShaderString = sRGBXRectTextureLayerMaskFS;
|
||||
} else {
|
||||
result.mVertexShaderString = sLayerVS;
|
||||
result.mFragmentShaderString = sRGBXRectTextureLayerFS;
|
||||
}
|
||||
AddCommonArgs(result);
|
||||
AddCommonTextureArgs(result);
|
||||
result.mTextureCount = 1;
|
||||
break;
|
||||
case BGRARectLayerProgramType:
|
||||
MOZ_ASSERT(aMask == MaskNone, "BGRARectLayerProgramType can't handle masks.");
|
||||
result.mVertexShaderString = sLayerVS;
|
||||
result.mFragmentShaderString = sBGRARectTextureLayerFS;
|
||||
AddCommonArgs(result);
|
||||
AddCommonTextureArgs(result);
|
||||
result.mTextureCount = 1;
|
||||
break;
|
||||
case RGBAExternalLayerProgramType:
|
||||
if (aMask == Mask3d) {
|
||||
result.mVertexShaderString = sLayerMask3DVS;
|
||||
result.mFragmentShaderString = sRGBAExternalTextureLayerMask3DFS;
|
||||
} else if (aMask == Mask2d) {
|
||||
result.mVertexShaderString = sLayerMaskVS;
|
||||
result.mFragmentShaderString = sRGBAExternalTextureLayerMaskFS;
|
||||
} else {
|
||||
result.mVertexShaderString = sLayerVS;
|
||||
result.mFragmentShaderString = sRGBAExternalTextureLayerFS;
|
||||
}
|
||||
AddCommonArgs(result);
|
||||
AddCommonTextureArgs(result);
|
||||
result.mTextureCount = 1;
|
||||
break;
|
||||
case ColorLayerProgramType:
|
||||
if (aMask == Mask2d) {
|
||||
result.mVertexShaderString = sLayerMaskVS;
|
||||
result.mFragmentShaderString = sSolidColorLayerMaskFS;
|
||||
} else {
|
||||
result.mVertexShaderString = sLayerVS;
|
||||
result.mFragmentShaderString = sSolidColorLayerFS;
|
||||
}
|
||||
AddCommonArgs(result);
|
||||
break;
|
||||
case YCbCrLayerProgramType:
|
||||
if (aMask == Mask2d) {
|
||||
result.mVertexShaderString = sLayerMaskVS;
|
||||
result.mFragmentShaderString = sYCbCrTextureLayerMaskFS;
|
||||
} else {
|
||||
result.mVertexShaderString = sLayerVS;
|
||||
result.mFragmentShaderString = sYCbCrTextureLayerFS;
|
||||
}
|
||||
AddCommonArgs(result);
|
||||
result.mAttributes.AppendElement(Argument("aTexCoord"));
|
||||
result.mTextureCount = 3;
|
||||
break;
|
||||
case ComponentAlphaPass1ProgramType:
|
||||
if (aMask == Mask2d) {
|
||||
result.mVertexShaderString = sLayerMaskVS;
|
||||
result.mFragmentShaderString = sComponentPassMask1FS;
|
||||
} else {
|
||||
result.mVertexShaderString = sLayerVS;
|
||||
result.mFragmentShaderString = sComponentPass1FS;
|
||||
}
|
||||
AddCommonArgs(result);
|
||||
result.mAttributes.AppendElement(Argument("aTexCoord"));
|
||||
result.mTextureCount = 2;
|
||||
break;
|
||||
case ComponentAlphaPass1RGBProgramType:
|
||||
if (aMask == Mask2d) {
|
||||
result.mVertexShaderString = sLayerMaskVS;
|
||||
result.mFragmentShaderString = sComponentPassMask1RGBFS;
|
||||
} else {
|
||||
result.mVertexShaderString = sLayerVS;
|
||||
result.mFragmentShaderString = sComponentPass1RGBFS;
|
||||
}
|
||||
AddCommonArgs(result);
|
||||
result.mAttributes.AppendElement(Argument("aTexCoord"));
|
||||
result.mTextureCount = 2;
|
||||
break;
|
||||
case ComponentAlphaPass2ProgramType:
|
||||
if (aMask == Mask2d) {
|
||||
result.mVertexShaderString = sLayerMaskVS;
|
||||
result.mFragmentShaderString = sComponentPassMask2FS;
|
||||
} else {
|
||||
result.mVertexShaderString = sLayerVS;
|
||||
result.mFragmentShaderString = sComponentPass2FS;
|
||||
}
|
||||
AddCommonArgs(result);
|
||||
result.mAttributes.AppendElement(Argument("aTexCoord"));
|
||||
result.mTextureCount = 2;
|
||||
break;
|
||||
case ComponentAlphaPass2RGBProgramType:
|
||||
if (aMask == Mask2d) {
|
||||
result.mVertexShaderString = sLayerMaskVS;
|
||||
result.mFragmentShaderString = sComponentPassMask2RGBFS;
|
||||
} else {
|
||||
result.mVertexShaderString = sLayerVS;
|
||||
result.mFragmentShaderString = sComponentPass2RGBFS;
|
||||
}
|
||||
AddCommonArgs(result);
|
||||
result.mAttributes.AppendElement(Argument("aTexCoord"));
|
||||
result.mTextureCount = 2;
|
||||
break;
|
||||
case Copy2DProgramType:
|
||||
NS_ASSERTION(!aMask, "Program does not have masked variant.");
|
||||
result.mVertexShaderString = sCopyVS;
|
||||
result.mFragmentShaderString = sCopy2DFS;
|
||||
result.mAttributes.AppendElement(Argument("aVertexCoord"));
|
||||
result.mAttributes.AppendElement(Argument("aTexCoord"));
|
||||
result.mTextureCount = 1;
|
||||
break;
|
||||
case Copy2DRectProgramType:
|
||||
NS_ASSERTION(!aMask, "Program does not have masked variant.");
|
||||
result.mVertexShaderString = sCopyVS;
|
||||
result.mFragmentShaderString = sCopy2DRectFS;
|
||||
result.mAttributes.AppendElement(Argument("aVertexCoord"));
|
||||
result.mAttributes.AppendElement(Argument("aTexCoord"));
|
||||
result.mTextureCount = 1;
|
||||
break;
|
||||
default:
|
||||
NS_NOTREACHED("Unknown shader program type.");
|
||||
vs << "uniform mat4 uMatrixProj;" << endl;
|
||||
vs << "uniform mat4 uLayerQuadTransform;" << endl;
|
||||
vs << "uniform mat4 uLayerTransform;" << endl;
|
||||
vs << "uniform vec4 uRenderTargetOffset;" << endl;
|
||||
|
||||
vs << "attribute vec4 aVertexCoord;" << endl;
|
||||
|
||||
if (!(aConfig.mFeatures & ENABLE_RENDER_COLOR)) {
|
||||
vs << "uniform mat4 uTextureTransform;" << endl;
|
||||
vs << "attribute vec2 aTexCoord;" << endl;
|
||||
vs << "varying vec2 vTexCoord;" << endl;
|
||||
}
|
||||
|
||||
if (aMask > MaskNone) {
|
||||
result.mTextureCount += 1;
|
||||
if (aConfig.mFeatures & ENABLE_MASK_2D ||
|
||||
aConfig.mFeatures & ENABLE_MASK_3D) {
|
||||
vs << "uniform mat4 uMaskQuadTransform;" << endl;
|
||||
vs << "varying vec3 vMaskCoord;" << endl;
|
||||
}
|
||||
|
||||
vs << "void main() {" << endl;
|
||||
vs << " vec4 finalPosition = aVertexCoord;" << endl;
|
||||
vs << " finalPosition = uLayerQuadTransform * finalPosition;" << endl;
|
||||
vs << " finalPosition = uLayerTransform * finalPosition;" << endl;
|
||||
vs << " finalPosition.xyz /= finalPosition.w;" << endl;
|
||||
|
||||
if (aConfig.mFeatures & ENABLE_MASK_3D) {
|
||||
vs << " vMaskCoord.xy = (uMaskQuadTransform * vec4(finalPosition.xyz, 1.0)).xy;" << endl;
|
||||
// correct for perspective correct interpolation, see comment in D3D10 shader
|
||||
vs << " vMaskCoord.z = 1.0;" << endl;
|
||||
vs << " vMaskCoord *= finalPosition.w;" << endl;
|
||||
} else if (aConfig.mFeatures & ENABLE_MASK_2D) {
|
||||
vs << " vMaskCoord.xy = (uMaskQuadTransform * finalPosition).xy;" << endl;
|
||||
}
|
||||
|
||||
vs << " finalPosition = finalPosition - uRenderTargetOffset;" << endl;
|
||||
vs << " finalPosition.xyz *= finalPosition.w;" << endl;
|
||||
vs << " finalPosition = uMatrixProj * finalPosition;" << endl;
|
||||
|
||||
if (!(aConfig.mFeatures & ENABLE_RENDER_COLOR)) {
|
||||
vs << " vTexCoord = (uTextureTransform * vec4(aTexCoord.x, aTexCoord.y, 0.0, 1.0)).xy;" << endl;
|
||||
}
|
||||
|
||||
vs << " gl_Position = finalPosition;" << endl;
|
||||
vs << "}" << endl;
|
||||
|
||||
fs << "#ifdef GL_ES" << endl;
|
||||
fs << "precision mediump float;" << endl;
|
||||
fs << "#define COLOR_PRECISION lowp" << endl;
|
||||
fs << "#else" << endl;
|
||||
fs << "#define COLOR_PRECISION" << endl;
|
||||
fs << "#endif" << endl;
|
||||
if (aConfig.mFeatures & ENABLE_RENDER_COLOR) {
|
||||
fs << "uniform COLOR_PRECISION vec4 uRenderColor;" << endl;
|
||||
} else {
|
||||
// for tiling, texcoord can be greater than the lowfp range
|
||||
fs << "varying vec2 vTexCoord;" << endl;
|
||||
if (aConfig.mFeatures & ENABLE_BLUR) {
|
||||
fs << "uniform bool uBlurAlpha;" << endl;
|
||||
fs << "uniform vec2 uBlurRadius;" << endl;
|
||||
fs << "uniform vec2 uBlurOffset;" << endl;
|
||||
fs << "uniform float uBlurGaussianKernel[" << GAUSSIAN_KERNEL_HALF_WIDTH << "];" << endl;
|
||||
}
|
||||
if (aConfig.mFeatures & ENABLE_COLOR_MATRIX) {
|
||||
fs << "uniform mat4 uColorMatrix;" << endl;
|
||||
fs << "uniform vec4 uColorMatrixVector;" << endl;
|
||||
}
|
||||
if (aConfig.mFeatures & ENABLE_OPACITY) {
|
||||
fs << "uniform COLOR_PRECISION float uLayerOpacity;" << endl;
|
||||
}
|
||||
}
|
||||
|
||||
const char *sampler2D = "sampler2D";
|
||||
const char *texture2D = "texture2D";
|
||||
|
||||
if (aConfig.mFeatures & ENABLE_TEXTURE_RECT) {
|
||||
fs << "#extension GL_ARB_texture_rectangle : require" << endl;
|
||||
fs << "uniform vec2 uTexCoordMultiplier;" << endl;
|
||||
sampler2D = "sampler2DRect";
|
||||
texture2D = "texture2DRect";
|
||||
}
|
||||
|
||||
if (aConfig.mFeatures & ENABLE_TEXTURE_EXTERNAL) {
|
||||
fs << "#extension GL_OES_EGL_image_external : require" << endl;
|
||||
sampler2D = "samplerExternalOES";
|
||||
}
|
||||
|
||||
if (aConfig.mFeatures & ENABLE_TEXTURE_YCBCR) {
|
||||
fs << "uniform sampler2D uYTexture;" << endl;
|
||||
fs << "uniform sampler2D uCbTexture;" << endl;
|
||||
fs << "uniform sampler2D uCrTexture;" << endl;
|
||||
} else if (aConfig.mFeatures & ENABLE_TEXTURE_COMPONENT_ALPHA) {
|
||||
fs << "uniform sampler2D uBlackTexture;" << endl;
|
||||
fs << "uniform sampler2D uWhiteTexture;" << endl;
|
||||
fs << "uniform bool uTexturePass2;" << endl;
|
||||
} else {
|
||||
fs << "uniform " << sampler2D << " uTexture;" << endl;
|
||||
}
|
||||
|
||||
if (aConfig.mFeatures & ENABLE_MASK_2D ||
|
||||
aConfig.mFeatures & ENABLE_MASK_3D) {
|
||||
fs << "varying vec3 vMaskCoord;" << endl;
|
||||
fs << "uniform sampler2D uMaskTexture;" << endl;
|
||||
}
|
||||
|
||||
if (!(aConfig.mFeatures & ENABLE_RENDER_COLOR)) {
|
||||
fs << "vec4 sample(vec2 coord) {" << endl;
|
||||
fs << " vec4 color;" << endl;
|
||||
if (aConfig.mFeatures & ENABLE_TEXTURE_YCBCR) {
|
||||
fs << " COLOR_PRECISION float y = texture2D(uYTexture, coord).r;" << endl;
|
||||
fs << " COLOR_PRECISION float cb = texture2D(uCbTexture, coord).r;" << endl;
|
||||
fs << " COLOR_PRECISION float cr = texture2D(uCrTexture, coord).r;" << endl;
|
||||
fs << " y = (y - 0.0625) * 1.164;" << endl;
|
||||
fs << " cb = cb - 0.5;" << endl;
|
||||
fs << " cr = cr - 0.5;" << endl;
|
||||
fs << " color.r = y + cr * 1.596;" << endl;
|
||||
fs << " color.g = y - 0.813 * cr - 0.391 * cb;" << endl;
|
||||
fs << " color.b = y + cb * 2.018;" << endl;
|
||||
fs << " color.a = 1.0;" << endl;
|
||||
} else if (aConfig.mFeatures & ENABLE_TEXTURE_COMPONENT_ALPHA) {
|
||||
fs << " COLOR_PRECISION vec3 onBlack = texture2D(uBlackTexture, coord).rgb;" << endl;
|
||||
fs << " COLOR_PRECISION vec3 onWhite = texture2D(uWhiteTexture, coord).rgb;" << endl;
|
||||
fs << " COLOR_PRECISION vec4 alphas = (1.0 - onWhite + onBlack).rgbg;" << endl;
|
||||
fs << " if (uTexturePass2)" << endl;
|
||||
fs << " color = vec4(onBlack, alphas.a);" << endl;
|
||||
fs << " else" << endl;
|
||||
fs << " color = alphas;" << endl;
|
||||
} else {
|
||||
fs << " color = " << texture2D << "(uTexture, coord);" << endl;
|
||||
}
|
||||
if (aConfig.mFeatures & ENABLE_TEXTURE_RB_SWAP) {
|
||||
fs << " color = color.bgra;" << endl;
|
||||
}
|
||||
if (aConfig.mFeatures & ENABLE_TEXTURE_NO_ALPHA) {
|
||||
fs << " color = vec4(color.rgb, 1.0);" << endl;
|
||||
}
|
||||
fs << " return color;" << endl;
|
||||
fs << "}" << endl;
|
||||
if (aConfig.mFeatures & ENABLE_BLUR) {
|
||||
fs << "vec4 sampleAtRadius(vec2 coord, float radius) {" << endl;
|
||||
fs << " coord += uBlurOffset;" << endl;
|
||||
fs << " coord += radius * uBlurRadius;" << endl;
|
||||
fs << " if (coord.x < 0. || coord.y < 0. || coord.x > 1. || coord.y > 1.)" << endl;
|
||||
fs << " return vec4(0, 0, 0, 0);" << endl;
|
||||
fs << " return sample(coord);" << endl;
|
||||
fs << "}" << endl;
|
||||
fs << "vec4 blur(vec4 color, vec2 coord) {" << endl;
|
||||
fs << " vec4 total = color * uBlurGaussianKernel[0];" << endl;
|
||||
fs << " for (int i = 1; i < " << GAUSSIAN_KERNEL_HALF_WIDTH << "; ++i) {" << endl;
|
||||
fs << " float r = float(i) * " << GAUSSIAN_KERNEL_STEP << " << endl;" << endl;
|
||||
fs << " float k = uBlurGaussianKernel[i];" << endl;
|
||||
fs << " total += sampleAtRadius(coord, r) * k;" << endl;
|
||||
fs << " total += sampleAtRadius(coord, -r) * k;" << endl;
|
||||
fs << " }" << endl;
|
||||
fs << " if (uBlurAlpha) {" << endl;
|
||||
fs << " color *= total.a;" << endl;
|
||||
fs << " } else {" << endl;
|
||||
fs << " color = total;" << endl;
|
||||
fs << " }" << endl;
|
||||
fs << " return color;" << endl;
|
||||
fs << "}" << endl;
|
||||
}
|
||||
}
|
||||
fs << "void main() {" << endl;
|
||||
if (aConfig.mFeatures & ENABLE_RENDER_COLOR) {
|
||||
fs << " vec4 color = uRenderColor;" << endl;
|
||||
} else {
|
||||
if (aConfig.mFeatures & ENABLE_TEXTURE_RECT) {
|
||||
fs << " vec4 color = sample(vTexCoord * uTexCoordMultiplier);" << endl;
|
||||
} else {
|
||||
fs << " vec4 color = sample(vTexCoord);" << endl;
|
||||
}
|
||||
if (aConfig.mFeatures & ENABLE_BLUR) {
|
||||
fs << " color = blur(color, vTexCoord);" << endl;
|
||||
}
|
||||
if (aConfig.mFeatures & ENABLE_COLOR_MATRIX) {
|
||||
fs << " color = uColorMatrix * vec4(color.rgb / color.a, color.a) + uColorMatrixVector;" << endl;
|
||||
fs << " color.rgb *= color.a;" << endl;
|
||||
}
|
||||
if (aConfig.mFeatures & ENABLE_OPACITY) {
|
||||
fs << " color *= uLayerOpacity;" << endl;
|
||||
}
|
||||
}
|
||||
if (aConfig.mFeatures & ENABLE_MASK_3D) {
|
||||
fs << " vec2 maskCoords = vMaskCoord.xy / vMaskCoord.z;" << endl;
|
||||
fs << " COLOR_PRECISION float mask = texture2D(uMaskTexture, maskCoords).r;" << endl;
|
||||
fs << " color *= mask;" << endl;
|
||||
} else if (aConfig.mFeatures & ENABLE_MASK_2D) {
|
||||
fs << " COLOR_PRECISION float mask = texture2D(uMaskTexture, vMaskCoord.xy).r;" << endl;
|
||||
fs << " color *= mask;" << endl;
|
||||
} else {
|
||||
fs << " COLOR_PRECISION float mask = 1.0;" << endl;
|
||||
fs << " color *= mask;" << endl;
|
||||
}
|
||||
fs << " gl_FragColor = color;" << endl;
|
||||
fs << "}" << endl;
|
||||
|
||||
result.mVertexShaderString = vs.str();
|
||||
result.mFragmentShaderString = fs.str();
|
||||
|
||||
result.mAttributes.AppendElement(Argument("aVertexCoord"));
|
||||
if (aConfig.mFeatures & ENABLE_RENDER_COLOR) {
|
||||
result.mTextureCount = 0;
|
||||
} else {
|
||||
result.mAttributes.AppendElement(Argument("aTexCoord"));
|
||||
if (aConfig.mFeatures & ENABLE_TEXTURE_YCBCR) {
|
||||
result.mTextureCount = 3;
|
||||
} else if (aConfig.mFeatures & ENABLE_TEXTURE_COMPONENT_ALPHA) {
|
||||
result.mTextureCount = 2;
|
||||
} else {
|
||||
result.mTextureCount = 1;
|
||||
}
|
||||
}
|
||||
if (aConfig.mFeatures & ENABLE_MASK_2D ||
|
||||
aConfig.mFeatures & ENABLE_MASK_3D) {
|
||||
result.mTextureCount = 1;
|
||||
}
|
||||
|
||||
return result;
|
||||
@ -276,8 +362,7 @@ const char* const ShaderProgramOGL::VertexCoordAttrib = "aVertexCoord";
|
||||
const char* const ShaderProgramOGL::TexCoordAttrib = "aTexCoord";
|
||||
|
||||
ShaderProgramOGL::ShaderProgramOGL(GLContext* aGL, const ProgramProfileOGL& aProfile)
|
||||
: mIsProjectionMatrixStale(false)
|
||||
, mGL(aGL)
|
||||
: mGL(aGL)
|
||||
, mProgram(0)
|
||||
, mProfile(aProfile)
|
||||
, mProgramState(STATE_NEW)
|
||||
@ -303,8 +388,15 @@ ShaderProgramOGL::Initialize()
|
||||
{
|
||||
NS_ASSERTION(mProgramState == STATE_NEW, "Shader program has already been initialised");
|
||||
|
||||
if (!CreateProgram(mProfile.mVertexShaderString,
|
||||
mProfile.mFragmentShaderString)) {
|
||||
ostringstream vs, fs;
|
||||
for (uint32_t i = 0; i < mProfile.mDefines.Length(); ++i) {
|
||||
vs << mProfile.mDefines[i] << endl;
|
||||
fs << mProfile.mDefines[i] << endl;
|
||||
}
|
||||
vs << mProfile.mVertexShaderString << endl;
|
||||
fs << mProfile.mFragmentShaderString << endl;
|
||||
|
||||
if (!CreateProgram(vs.str().c_str(), fs.str().c_str())) {
|
||||
mProgramState = STATE_ERROR;
|
||||
return false;
|
||||
}
|
||||
@ -322,7 +414,7 @@ ShaderProgramOGL::Initialize()
|
||||
NS_ASSERTION(mProfile.mAttributes[i].mLocation >= 0, "Bad attribute location.");
|
||||
}
|
||||
|
||||
mProfile.mHasMatrixProj = mProfile.mUniforms[KnownUniform::MatrixProj].mLocation != -1;
|
||||
//mProfile.mHasMatrixProj = mProfile.mUniforms[KnownUniform::MatrixProj].mLocation != -1;
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -439,11 +531,6 @@ ShaderProgramOGL::Activate()
|
||||
}
|
||||
NS_ASSERTION(HasInitialized(), "Attempting to activate a program that's not in use!");
|
||||
mGL->fUseProgram(mProgram);
|
||||
|
||||
// check if we need to set the projection matrix
|
||||
if (mIsProjectionMatrixStale) {
|
||||
SetProjectionMatrix(mProjectionMatrix);
|
||||
}
|
||||
}
|
||||
|
||||
} /* layers */
|
||||
|
@ -19,6 +19,8 @@
|
||||
#include "nsTArray.h" // for nsTArray
|
||||
#include "mozilla/layers/CompositorTypes.h"
|
||||
|
||||
#include <string>
|
||||
|
||||
struct gfxRGBA;
|
||||
struct nsIntRect;
|
||||
|
||||
@ -27,24 +29,19 @@ namespace layers {
|
||||
|
||||
class Layer;
|
||||
|
||||
enum ShaderProgramType {
|
||||
RGBALayerProgramType,
|
||||
BGRALayerProgramType,
|
||||
RGBXLayerProgramType,
|
||||
BGRXLayerProgramType,
|
||||
RGBARectLayerProgramType,
|
||||
RGBXRectLayerProgramType,
|
||||
BGRARectLayerProgramType,
|
||||
RGBAExternalLayerProgramType,
|
||||
ColorLayerProgramType,
|
||||
YCbCrLayerProgramType,
|
||||
ComponentAlphaPass1ProgramType,
|
||||
ComponentAlphaPass1RGBProgramType,
|
||||
ComponentAlphaPass2ProgramType,
|
||||
ComponentAlphaPass2RGBProgramType,
|
||||
Copy2DProgramType,
|
||||
Copy2DRectProgramType,
|
||||
NumProgramTypes
|
||||
enum ShaderFeatures {
|
||||
ENABLE_RENDER_COLOR=0x01,
|
||||
ENABLE_TEXTURE_RECT=0x02,
|
||||
ENABLE_TEXTURE_EXTERNAL=0x04,
|
||||
ENABLE_TEXTURE_YCBCR=0x08,
|
||||
ENABLE_TEXTURE_COMPONENT_ALPHA=0x10,
|
||||
ENABLE_TEXTURE_NO_ALPHA=0x20,
|
||||
ENABLE_TEXTURE_RB_SWAP=0x40,
|
||||
ENABLE_OPACITY=0x80,
|
||||
ENABLE_BLUR=0x100,
|
||||
ENABLE_COLOR_MATRIX=0x200,
|
||||
ENABLE_MASK_2D=0x400,
|
||||
ENABLE_MASK_3D=0x800
|
||||
};
|
||||
|
||||
class KnownUniform {
|
||||
@ -68,6 +65,7 @@ public:
|
||||
MaskTexture,
|
||||
RenderColor,
|
||||
TexCoordMultiplier,
|
||||
TexturePass2,
|
||||
|
||||
KnownUniformCount
|
||||
};
|
||||
@ -156,54 +154,51 @@ public:
|
||||
} mValue;
|
||||
};
|
||||
|
||||
static inline ShaderProgramType
|
||||
ShaderProgramFromSurfaceFormat(gfx::SurfaceFormat aFormat)
|
||||
class ShaderConfigOGL
|
||||
{
|
||||
switch (aFormat) {
|
||||
case gfx::SurfaceFormat::B8G8R8A8:
|
||||
return BGRALayerProgramType;
|
||||
case gfx::SurfaceFormat::B8G8R8X8:
|
||||
return BGRXLayerProgramType;
|
||||
case gfx::SurfaceFormat::R8G8B8A8:
|
||||
return RGBALayerProgramType;
|
||||
case gfx::SurfaceFormat::R8G8B8X8:
|
||||
case gfx::SurfaceFormat::R5G6B5:
|
||||
return RGBXLayerProgramType;
|
||||
case gfx::SurfaceFormat::A8:
|
||||
// We don't have a specific luminance shader
|
||||
break;
|
||||
default:
|
||||
NS_ASSERTION(false, "Unhandled surface format!");
|
||||
}
|
||||
return ShaderProgramType(0);
|
||||
public:
|
||||
ShaderConfigOGL() :
|
||||
mFeatures(0) {}
|
||||
|
||||
void SetRenderColor(bool aEnabled);
|
||||
void SetTextureTarget(GLenum aTarget);
|
||||
void SetRBSwap(bool aEnabled);
|
||||
void SetNoAlpha(bool aEnabled);
|
||||
void SetOpacity(bool aEnabled);
|
||||
void SetYCbCr(bool aEnabled);
|
||||
void SetComponentAlpha(bool aEnabled);
|
||||
void SetColorMatrix(bool aEnabled);
|
||||
void SetBlur(bool aEnabled);
|
||||
void SetMask2D(bool aEnabled);
|
||||
void SetMask3D(bool aEnabled);
|
||||
|
||||
bool operator< (const ShaderConfigOGL& other) const {
|
||||
return mFeatures < other.mFeatures;
|
||||
}
|
||||
|
||||
static inline ShaderProgramType
|
||||
ShaderProgramFromTargetAndFormat(GLenum aTarget,
|
||||
public:
|
||||
void SetFeature(int aBitmask, bool aState) {
|
||||
if (aState)
|
||||
mFeatures |= aBitmask;
|
||||
else
|
||||
mFeatures &= (~aBitmask);
|
||||
}
|
||||
|
||||
int mFeatures;
|
||||
};
|
||||
|
||||
static inline ShaderConfigOGL
|
||||
ShaderConfigFromTargetAndFormat(GLenum aTarget,
|
||||
gfx::SurfaceFormat aFormat)
|
||||
{
|
||||
switch(aTarget) {
|
||||
case LOCAL_GL_TEXTURE_EXTERNAL:
|
||||
MOZ_ASSERT(aFormat == gfx::SurfaceFormat::R8G8B8A8);
|
||||
return RGBAExternalLayerProgramType;
|
||||
case LOCAL_GL_TEXTURE_RECTANGLE_ARB:
|
||||
MOZ_ASSERT(aFormat == gfx::SurfaceFormat::R8G8B8A8 ||
|
||||
aFormat == gfx::SurfaceFormat::R8G8B8X8);
|
||||
if (aFormat == gfx::SurfaceFormat::R8G8B8A8)
|
||||
return RGBARectLayerProgramType;
|
||||
else
|
||||
return RGBXRectLayerProgramType;
|
||||
default:
|
||||
return ShaderProgramFromSurfaceFormat(aFormat);
|
||||
}
|
||||
}
|
||||
|
||||
static inline ShaderProgramType
|
||||
ShaderProgramFromContentType(gfxContentType aContentType)
|
||||
{
|
||||
if (aContentType == gfxContentType::COLOR_ALPHA)
|
||||
return RGBALayerProgramType;
|
||||
return RGBXLayerProgramType;
|
||||
ShaderConfigOGL config;
|
||||
config.SetTextureTarget(aTarget);
|
||||
config.SetRBSwap(aFormat == gfx::SurfaceFormat::B8G8R8A8 ||
|
||||
aFormat == gfx::SurfaceFormat::B8G8R8X8);
|
||||
config.SetNoAlpha(aFormat == gfx::SurfaceFormat::B8G8R8X8 ||
|
||||
aFormat == gfx::SurfaceFormat::R8G8B8X8 ||
|
||||
aFormat == gfx::SurfaceFormat::R5G6B5);
|
||||
return config;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -216,39 +211,9 @@ struct ProgramProfileOGL
|
||||
{
|
||||
/**
|
||||
* Factory method; creates an instance of this class for the given
|
||||
* ShaderProgramType
|
||||
* ShaderConfigOGL
|
||||
*/
|
||||
static ProgramProfileOGL GetProfileFor(ShaderProgramType aType,
|
||||
MaskType aMask);
|
||||
|
||||
/**
|
||||
* returns true if such a shader program exists
|
||||
*/
|
||||
static bool ProgramExists(ShaderProgramType aType, MaskType aMask)
|
||||
{
|
||||
if (aType < 0 ||
|
||||
aType >= NumProgramTypes)
|
||||
return false;
|
||||
|
||||
if (aMask < MaskNone ||
|
||||
aMask >= NumMaskTypes)
|
||||
return false;
|
||||
|
||||
if (aMask == Mask2d &&
|
||||
(aType == Copy2DProgramType ||
|
||||
aType == Copy2DRectProgramType))
|
||||
return false;
|
||||
|
||||
if (aMask != MaskNone &&
|
||||
aType == BGRARectLayerProgramType)
|
||||
return false;
|
||||
|
||||
return aMask != Mask3d ||
|
||||
aType == RGBARectLayerProgramType ||
|
||||
aType == RGBXRectLayerProgramType ||
|
||||
aType == RGBALayerProgramType;
|
||||
}
|
||||
|
||||
static ProgramProfileOGL GetProfileFor(ShaderConfigOGL aConfig);
|
||||
|
||||
/**
|
||||
* These two methods lookup the location of a uniform and attribute,
|
||||
@ -276,17 +241,17 @@ struct ProgramProfileOGL
|
||||
};
|
||||
|
||||
// the source code for the program's shaders
|
||||
const char *mVertexShaderString;
|
||||
const char *mFragmentShaderString;
|
||||
std::string mVertexShaderString;
|
||||
std::string mFragmentShaderString;
|
||||
|
||||
KnownUniform mUniforms[KnownUniform::KnownUniformCount];
|
||||
nsTArray<Argument> mAttributes;
|
||||
nsTArray<const char *> mDefines;
|
||||
uint32_t mTextureCount;
|
||||
bool mHasMatrixProj;
|
||||
private:
|
||||
|
||||
ProgramProfileOGL() :
|
||||
mTextureCount(0),
|
||||
mHasMatrixProj(false) {}
|
||||
mTextureCount(0)
|
||||
{}
|
||||
};
|
||||
|
||||
|
||||
@ -341,10 +306,6 @@ public:
|
||||
return mProfile.LookupAttributeLocation(aName);
|
||||
}
|
||||
|
||||
GLint GetTexCoordMultiplierUniformLocation() {
|
||||
return mProfile.mUniforms[KnownUniform::TexCoordMultiplier].mLocation;
|
||||
}
|
||||
|
||||
/**
|
||||
* The following set of methods set a uniform argument to the shader program.
|
||||
* Not all uniforms may be set for all programs, and such uses will throw
|
||||
@ -376,17 +337,8 @@ public:
|
||||
SetMatrixUniform(KnownUniform::LayerQuadTransform, m);
|
||||
}
|
||||
|
||||
// Set a projection matrix on the program to be set the next time
|
||||
// the program is activated.
|
||||
void DelayedSetProjectionMatrix(const gfx::Matrix4x4& aMatrix)
|
||||
{
|
||||
mIsProjectionMatrixStale = true;
|
||||
mProjectionMatrix = aMatrix;
|
||||
}
|
||||
|
||||
void SetProjectionMatrix(const gfx::Matrix4x4& aMatrix) {
|
||||
SetMatrixUniform(KnownUniform::MatrixProj, aMatrix);
|
||||
mIsProjectionMatrixStale = false;
|
||||
}
|
||||
|
||||
// sets this program's texture transform, if it uses one
|
||||
@ -454,15 +406,18 @@ public:
|
||||
SetUniform(KnownUniform::TexCoordMultiplier, 2, f);
|
||||
}
|
||||
|
||||
// Set whether we want the component alpha shader to return the color
|
||||
// vector (pass 1, false) or the alpha vector (pass2, true). With support
|
||||
// for multiple render targets we wouldn't need two passes here.
|
||||
void SetTexturePass2(bool aFlag) {
|
||||
SetUniform(KnownUniform::TexturePass2, aFlag ? 1 : 0);
|
||||
}
|
||||
|
||||
// the names of attributes
|
||||
static const char* const VertexCoordAttrib;
|
||||
static const char* const TexCoordAttrib;
|
||||
|
||||
protected:
|
||||
gfx::Matrix4x4 mProjectionMatrix;
|
||||
// true if the projection matrix needs setting
|
||||
bool mIsProjectionMatrixStale;
|
||||
|
||||
RefPtr<GLContext> mGL;
|
||||
// the OpenGL id of the program
|
||||
GLuint mProgram;
|
||||
@ -473,6 +428,10 @@ protected:
|
||||
STATE_ERROR
|
||||
} mProgramState;
|
||||
|
||||
#ifdef CHECK_CURRENT_PROGRAM
|
||||
static int sCurrentProgramKey;
|
||||
#endif
|
||||
|
||||
void SetUniform(KnownUniform::KnownUniformName aKnownUniform, float aFloatValue)
|
||||
{
|
||||
ASSERT_THIS_PROGRAM;
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1,495 +0,0 @@
|
||||
// -*- Mode: glsl; c-basic-offset: 2; indent-tabs-mode: nil; tab-width: 40; -*-
|
||||
|
||||
// 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/.
|
||||
|
||||
// This file is compiled by genshaders.py, use genshaders.sh, no arguments necessary.
|
||||
// The compiled shaders will be in LayerManagerOGLShaders.h.
|
||||
// This file must be compiled after editing, it is not compiled as part of the
|
||||
// build process.
|
||||
//
|
||||
// Syntax:
|
||||
//
|
||||
// // comments (only at the start of a line)
|
||||
//
|
||||
// (@ is used because # is valid inside GLSL)
|
||||
//
|
||||
// multi-line:
|
||||
// @define FOO
|
||||
// ...
|
||||
// @end
|
||||
//
|
||||
// single:
|
||||
// @define FOO 123
|
||||
//
|
||||
// $FOO$ to paste
|
||||
//
|
||||
// To generate a constant string named ShaderName (shader name should not
|
||||
// use '<', '>', ',', ':', except for parameters, see below):
|
||||
// @shader ShaderName
|
||||
// ...
|
||||
// @end
|
||||
//
|
||||
// @shader may have a single parameter with multiple values using
|
||||
// <param:val1,val2> an empty value is allowed. The shader is expanded for
|
||||
// each value, <param> in the body of the shader will be expanded to
|
||||
// the current value, as will the declaration of the parameter. The name of
|
||||
// defines may include <...> and this should work as expected.
|
||||
//
|
||||
// For example:
|
||||
//
|
||||
// @Shader<name:Name1,Name2>
|
||||
// string name = "<name>";
|
||||
// @end
|
||||
//
|
||||
// will be expanded to
|
||||
//
|
||||
// @ShaderName1
|
||||
// string name = "Name1";
|
||||
// @end
|
||||
// @ShaderName2
|
||||
// string name = "Name2";
|
||||
// @end
|
||||
//
|
||||
// This will be straightaway compiled to two constant strings named
|
||||
// ShaderName1 and ShaderName2.
|
||||
//
|
||||
|
||||
@define VERTEX_SHADER_HEADER<>
|
||||
/* Vertex Shader */
|
||||
|
||||
uniform mat4 uMatrixProj;
|
||||
uniform mat4 uLayerQuadTransform;
|
||||
uniform mat4 uLayerTransform;
|
||||
uniform mat4 uTextureTransform;
|
||||
uniform vec4 uRenderTargetOffset;
|
||||
|
||||
attribute vec4 aVertexCoord;
|
||||
attribute vec2 aTexCoord;
|
||||
|
||||
varying vec2 vTexCoord;
|
||||
@end
|
||||
|
||||
@define VERTEX_SHADER_HEADER<Mask>
|
||||
$VERTEX_SHADER_HEADER<>$
|
||||
|
||||
uniform mat4 uMaskQuadTransform;
|
||||
varying vec2 vMaskCoord;
|
||||
@end
|
||||
|
||||
@define VERTEX_SHADER_HEADER<Mask3D>
|
||||
$VERTEX_SHADER_HEADER<>$
|
||||
|
||||
uniform mat4 uMaskQuadTransform;
|
||||
varying vec3 vMaskCoord;
|
||||
@end
|
||||
|
||||
@define VERTEX_MASK_STUFF<>
|
||||
@end
|
||||
|
||||
@define VERTEX_MASK_STUFF<Mask>
|
||||
vMaskCoord = (uMaskQuadTransform * finalPosition).xy;
|
||||
@end
|
||||
|
||||
@define VERTEX_MASK_STUFF<Mask3D>
|
||||
vMaskCoord.xy = (uMaskQuadTransform * vec4(finalPosition.xyz, 1.0)).xy;
|
||||
// correct for perspective correct interpolation, see comment in D3D10 shader
|
||||
vMaskCoord.z = 1.0;
|
||||
vMaskCoord *= finalPosition.w;
|
||||
@end
|
||||
|
||||
|
||||
// This is a basic Layer vertex shader. It's used for all
|
||||
// Layer programs.
|
||||
|
||||
@shader sLayer<mask:,Mask,Mask3D>VS
|
||||
$VERTEX_SHADER_HEADER<mask>$
|
||||
|
||||
|
||||
void main()
|
||||
{
|
||||
vec4 finalPosition = aVertexCoord;
|
||||
finalPosition = uLayerQuadTransform * finalPosition;
|
||||
finalPosition = uLayerTransform * finalPosition;
|
||||
finalPosition.xyz /= finalPosition.w;
|
||||
|
||||
$VERTEX_MASK_STUFF<mask>$
|
||||
|
||||
finalPosition = finalPosition - uRenderTargetOffset;
|
||||
finalPosition.xyz *= finalPosition.w;
|
||||
finalPosition = uMatrixProj * finalPosition;
|
||||
|
||||
vTexCoord = (uTextureTransform * vec4(aTexCoord.x, aTexCoord.y, 0.0, 1.0)).xy;
|
||||
|
||||
gl_Position = finalPosition;
|
||||
}
|
||||
@end
|
||||
|
||||
|
||||
/*
|
||||
* Fragment shaders
|
||||
*/
|
||||
|
||||
@define FRAGMENT_SHADER_HEADER
|
||||
/* Fragment Shader */
|
||||
#ifdef GL_ES
|
||||
precision mediump float;
|
||||
#define COLOR_PRECISION lowp
|
||||
#else
|
||||
#define COLOR_PRECISION
|
||||
#endif
|
||||
@end
|
||||
|
||||
// fragment shader header for layers
|
||||
@define LAYER_FRAGMENT<>
|
||||
$FRAGMENT_SHADER_HEADER$
|
||||
|
||||
#ifndef NO_LAYER_OPACITY
|
||||
uniform COLOR_PRECISION float uLayerOpacity;
|
||||
#endif
|
||||
|
||||
varying vec2 vTexCoord;
|
||||
@end
|
||||
|
||||
// fragment shader header for layers with masks
|
||||
@define LAYER_FRAGMENT<Mask>
|
||||
$LAYER_FRAGMENT<>$
|
||||
|
||||
varying vec2 vMaskCoord;
|
||||
uniform sampler2D uMaskTexture;
|
||||
@end
|
||||
|
||||
// fragment shader header for layers with masks and 3D transforms
|
||||
@define LAYER_FRAGMENT<Mask3D>
|
||||
$LAYER_FRAGMENT<>$
|
||||
|
||||
varying vec3 vMaskCoord;
|
||||
uniform sampler2D uMaskTexture;
|
||||
@end
|
||||
|
||||
@define FRAGMENT_CALC_MASK<>
|
||||
COLOR_PRECISION float mask = 1.0;
|
||||
@end
|
||||
|
||||
@define FRAGMENT_CALC_MASK<Mask>
|
||||
COLOR_PRECISION float mask = texture2D(uMaskTexture, vMaskCoord).r;
|
||||
@end
|
||||
|
||||
@define FRAGMENT_CALC_MASK<Mask3D>
|
||||
vec2 maskCoords = vMaskCoord.xy / vMaskCoord.z;
|
||||
COLOR_PRECISION float mask = texture2D(uMaskTexture, maskCoords).r;
|
||||
@end
|
||||
|
||||
// Solid color rendering.
|
||||
// texcoords are ignored (no texture to sample).
|
||||
// The layer opacity is baked in to the color.
|
||||
@shader sSolidColorLayer<mask:,Mask>FS
|
||||
#define NO_LAYER_OPACITY 1
|
||||
$LAYER_FRAGMENT<mask>$
|
||||
uniform COLOR_PRECISION vec4 uRenderColor;
|
||||
|
||||
void main()
|
||||
{
|
||||
$FRAGMENT_CALC_MASK<mask>$
|
||||
gl_FragColor = mask * uRenderColor;
|
||||
}
|
||||
@end
|
||||
|
||||
// Single texture in RGBA format
|
||||
@shader sRGBATextureLayer<mask:,Mask,Mask3D>FS
|
||||
$LAYER_FRAGMENT<mask>$
|
||||
uniform sampler2D uTexture;
|
||||
|
||||
void main()
|
||||
{
|
||||
$FRAGMENT_CALC_MASK<mask>$
|
||||
gl_FragColor = texture2D(uTexture, vTexCoord) * uLayerOpacity * mask;
|
||||
}
|
||||
@end
|
||||
|
||||
// Single texture in RGBA format, but with a Rect texture.
|
||||
// Container layer needs this to render a FBO group.
|
||||
@shader sRGBARectTextureLayer<mask:,Mask,Mask3D>FS
|
||||
#extension GL_ARB_texture_rectangle : enable
|
||||
|
||||
$LAYER_FRAGMENT<mask>$
|
||||
|
||||
/* This should not be used on GL ES */
|
||||
#ifndef GL_ES
|
||||
uniform sampler2DRect uTexture;
|
||||
uniform vec2 uTexCoordMultiplier;
|
||||
void main()
|
||||
{
|
||||
$FRAGMENT_CALC_MASK<mask>$
|
||||
gl_FragColor = texture2DRect(uTexture, vec2(vTexCoord * uTexCoordMultiplier)) * uLayerOpacity * mask;
|
||||
}
|
||||
#else
|
||||
void main()
|
||||
{
|
||||
gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0);
|
||||
}
|
||||
#endif
|
||||
@end
|
||||
|
||||
@shader sRGBXRectTextureLayer<mask:,Mask,Mask3D>FS
|
||||
#extension GL_ARB_texture_rectangle : enable
|
||||
|
||||
$LAYER_FRAGMENT<mask>$
|
||||
|
||||
/* This should not be used on GL ES */
|
||||
#ifndef GL_ES
|
||||
uniform sampler2DRect uTexture;
|
||||
uniform vec2 uTexCoordMultiplier;
|
||||
void main()
|
||||
{
|
||||
$FRAGMENT_CALC_MASK<mask>$
|
||||
gl_FragColor = vec4(texture2DRect(uTexture, vec2(vTexCoord * uTexCoordMultiplier)).rgb, 1.0) * uLayerOpacity * mask;
|
||||
}
|
||||
#else
|
||||
void main()
|
||||
{
|
||||
gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0);
|
||||
}
|
||||
#endif
|
||||
@end
|
||||
|
||||
// Single texture in BGRA format, but with a Rect texture.
|
||||
// nsChildView needs this for old Mac hardware.
|
||||
@shader sBGRARectTextureLayerFS
|
||||
#extension GL_ARB_texture_rectangle : enable
|
||||
|
||||
$LAYER_FRAGMENT<>$
|
||||
|
||||
uniform sampler2DRect uTexture;
|
||||
uniform vec2 uTexCoordMultiplier;
|
||||
void main()
|
||||
{
|
||||
gl_FragColor = texture2DRect(uTexture, vec2(vTexCoord * uTexCoordMultiplier)).bgra * uLayerOpacity;
|
||||
}
|
||||
@end
|
||||
|
||||
|
||||
// Single texture in RGBA format, but uses external image. External
|
||||
// image is an EGLImage which have internal formats not otherwise
|
||||
// supported by OpenGL ES. It is up to the implementation exactly what
|
||||
// formats are accepted. It is specified in the OES_EGL_image_external
|
||||
// extension.
|
||||
@shader sRGBAExternalTextureLayer<mask:,Mask,Mask3D>FS
|
||||
#extension GL_OES_EGL_image_external : require
|
||||
|
||||
$LAYER_FRAGMENT<mask>$
|
||||
uniform samplerExternalOES uTexture;
|
||||
|
||||
void main()
|
||||
{
|
||||
$FRAGMENT_CALC_MASK<mask>$
|
||||
gl_FragColor = texture2D(uTexture, vTexCoord) * uLayerOpacity * mask;
|
||||
}
|
||||
@end
|
||||
|
||||
|
||||
// Single texture in BGRA format (via swizzle)
|
||||
@shader sBGRATextureLayer<mask:,Mask>FS
|
||||
$LAYER_FRAGMENT<mask>$
|
||||
uniform sampler2D uTexture;
|
||||
|
||||
void main()
|
||||
{
|
||||
$FRAGMENT_CALC_MASK<mask>$
|
||||
gl_FragColor = texture2D(uTexture, vTexCoord).bgra * uLayerOpacity * mask;
|
||||
}
|
||||
@end
|
||||
|
||||
// Single texture in RGBX format
|
||||
@shader sRGBXTextureLayer<mask:,Mask>FS
|
||||
$LAYER_FRAGMENT<mask>$
|
||||
uniform sampler2D uTexture;
|
||||
|
||||
void main()
|
||||
{
|
||||
$FRAGMENT_CALC_MASK<mask>$
|
||||
gl_FragColor = vec4(texture2D(uTexture, vTexCoord).rgb, 1.0) * uLayerOpacity * mask;
|
||||
}
|
||||
@end
|
||||
|
||||
// Single texture in BGRX format (via swizzle)
|
||||
@shader sBGRXTextureLayer<mask:,Mask>FS
|
||||
$LAYER_FRAGMENT<mask>$
|
||||
uniform sampler2D uTexture;
|
||||
|
||||
void main()
|
||||
{
|
||||
$FRAGMENT_CALC_MASK<mask>$
|
||||
gl_FragColor = vec4(texture2D(uTexture, vTexCoord).bgr, 1.0) * uLayerOpacity * mask;
|
||||
}
|
||||
@end
|
||||
|
||||
// Three textures, representing YCbCr planes of a video image.
|
||||
//
|
||||
// Some older versions of the Tegra 2 android driver have a bug
|
||||
// where arithmetic ops on a texture read are just ignored. So,
|
||||
// if the below was |cb = texture2D(...).r - 0.5|, the "- 0.5" was
|
||||
// just being ignored/skipped. This, of course, lead to crappy
|
||||
// rendering -- see bug 765150. Doing them separately like below
|
||||
// makes it all OK. We don't know if this is special to constants,
|
||||
// special to 0.5, special to addition/subtraction, etc.
|
||||
@shader sYCbCrTextureLayer<mask:,Mask>FS
|
||||
$LAYER_FRAGMENT<mask>$
|
||||
#ifdef GL_ES
|
||||
precision mediump float;
|
||||
#endif
|
||||
uniform sampler2D uYTexture;
|
||||
uniform sampler2D uCbTexture;
|
||||
uniform sampler2D uCrTexture;
|
||||
|
||||
void main()
|
||||
{
|
||||
COLOR_PRECISION vec4 color;
|
||||
|
||||
COLOR_PRECISION float y = texture2D(uYTexture, vTexCoord).r;
|
||||
COLOR_PRECISION float cb = texture2D(uCbTexture, vTexCoord).r;
|
||||
COLOR_PRECISION float cr = texture2D(uCrTexture, vTexCoord).r;
|
||||
|
||||
y = (y - 0.0625) * 1.164;
|
||||
cb = cb - 0.5;
|
||||
cr = cr - 0.5;
|
||||
|
||||
color.r = y + cr * 1.596;
|
||||
color.g = y - 0.813 * cr - 0.391 * cb;
|
||||
color.b = y + cb * 2.018;
|
||||
color.a = 1.0;
|
||||
$FRAGMENT_CALC_MASK<mask>$
|
||||
gl_FragColor = color * uLayerOpacity * mask;
|
||||
}
|
||||
@end
|
||||
|
||||
// Two textures and two passes for component alpha rendering
|
||||
@shader sComponentPass<mask:,Mask>1FS
|
||||
|
||||
$LAYER_FRAGMENT<mask>$
|
||||
uniform sampler2D uBlackTexture;
|
||||
uniform sampler2D uWhiteTexture;
|
||||
|
||||
void main()
|
||||
{
|
||||
COLOR_PRECISION vec3 onBlack = texture2D(uBlackTexture, vTexCoord).bgr;
|
||||
COLOR_PRECISION vec3 onWhite = texture2D(uWhiteTexture, vTexCoord).bgr;
|
||||
COLOR_PRECISION vec4 alphas = (1.0 - onWhite + onBlack).rgbg;
|
||||
$FRAGMENT_CALC_MASK<mask>$
|
||||
gl_FragColor = alphas * uLayerOpacity * mask;
|
||||
}
|
||||
@end
|
||||
|
||||
@shader sComponentPass<mask:,Mask>1RGBFS
|
||||
|
||||
$LAYER_FRAGMENT<mask>$
|
||||
uniform sampler2D uBlackTexture;
|
||||
uniform sampler2D uWhiteTexture;
|
||||
|
||||
void main()
|
||||
{
|
||||
COLOR_PRECISION vec3 onBlack = texture2D(uBlackTexture, vTexCoord).rgb;
|
||||
COLOR_PRECISION vec3 onWhite = texture2D(uWhiteTexture, vTexCoord).rgb;
|
||||
COLOR_PRECISION vec4 alphas = (1.0 - onWhite + onBlack).rgbg;
|
||||
$FRAGMENT_CALC_MASK<mask>$
|
||||
gl_FragColor = alphas * uLayerOpacity * mask;
|
||||
}
|
||||
@end
|
||||
|
||||
@shader sComponentPass<mask:,Mask>2FS
|
||||
|
||||
$LAYER_FRAGMENT<mask>$
|
||||
uniform sampler2D uBlackTexture;
|
||||
uniform sampler2D uWhiteTexture;
|
||||
|
||||
void main()
|
||||
{
|
||||
COLOR_PRECISION vec3 onBlack = texture2D(uBlackTexture, vTexCoord).bgr;
|
||||
COLOR_PRECISION vec3 onWhite = texture2D(uWhiteTexture, vTexCoord).bgr;
|
||||
COLOR_PRECISION vec4 alphas = (1.0 - onWhite + onBlack).rgbg;
|
||||
$FRAGMENT_CALC_MASK<mask>$
|
||||
gl_FragColor = vec4(onBlack, alphas.a) * uLayerOpacity * mask;
|
||||
}
|
||||
@end
|
||||
|
||||
@shader sComponentPass<mask:,Mask>2RGBFS
|
||||
|
||||
$LAYER_FRAGMENT<mask>$
|
||||
uniform sampler2D uBlackTexture;
|
||||
uniform sampler2D uWhiteTexture;
|
||||
|
||||
void main()
|
||||
{
|
||||
COLOR_PRECISION vec3 onBlack = texture2D(uBlackTexture, vTexCoord).rgb;
|
||||
COLOR_PRECISION vec3 onWhite = texture2D(uWhiteTexture, vTexCoord).rgb;
|
||||
COLOR_PRECISION vec4 alphas = (1.0 - onWhite + onBlack).rgbg;
|
||||
$FRAGMENT_CALC_MASK<mask>$
|
||||
gl_FragColor = vec4(onBlack, alphas.a) * uLayerOpacity * mask;
|
||||
}
|
||||
@end
|
||||
|
||||
|
||||
//
|
||||
// The "Copy" program is used for blitting a texture to a destination
|
||||
// with no transforms or any other manipulation. They're used for
|
||||
// blitting the contents of a FBO-rendered texture to a destination.
|
||||
//
|
||||
// There are two variants of the fragment shader: one that uses 2D
|
||||
// textures and one that uses 2DRect textures (for when
|
||||
// EXT_TEXTURE_RECTANGLE is used for FBOs).
|
||||
//
|
||||
// On GL ES, EXT_TEXTURE_RECTANGLE isn't available, so we still
|
||||
// compile the shader but have it render pure red. It should never
|
||||
// be used.
|
||||
//
|
||||
|
||||
@shader sCopyVS
|
||||
/* Vertex Shader */
|
||||
|
||||
attribute vec4 aVertexCoord;
|
||||
attribute vec2 aTexCoord;
|
||||
|
||||
varying vec2 vTexCoord;
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_Position = aVertexCoord;
|
||||
vTexCoord = aTexCoord;
|
||||
}
|
||||
@end
|
||||
|
||||
@shader sCopy2DFS
|
||||
$FRAGMENT_SHADER_HEADER$
|
||||
|
||||
varying vec2 vTexCoord;
|
||||
|
||||
uniform sampler2D uTexture;
|
||||
void main()
|
||||
{
|
||||
gl_FragColor = texture2D(uTexture, vTexCoord);
|
||||
}
|
||||
@end
|
||||
|
||||
@shader sCopy2DRectFS
|
||||
#extension GL_ARB_texture_rectangle : enable
|
||||
|
||||
$FRAGMENT_SHADER_HEADER$
|
||||
|
||||
varying vec2 vTexCoord;
|
||||
uniform vec2 uTexCoordMultiplier;
|
||||
|
||||
#ifndef GL_ES
|
||||
uniform sampler2DRect uTexture;
|
||||
void main()
|
||||
{
|
||||
gl_FragColor = texture2DRect(uTexture, vTexCoord * uTexCoordMultiplier);
|
||||
}
|
||||
#else
|
||||
void main()
|
||||
{
|
||||
gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0);
|
||||
}
|
||||
#endif
|
||||
@end
|
||||
|
@ -93,29 +93,6 @@ protected:
|
||||
* sequence as simple as possible.
|
||||
*/
|
||||
|
||||
inline ShaderProgramType
|
||||
GetProgramTypeForSurfaceFormat(gfx::SurfaceFormat aFormat)
|
||||
{
|
||||
switch (aFormat) {
|
||||
case gfx::SurfaceFormat::B8G8R8A8:
|
||||
return BGRALayerProgramType;;
|
||||
case gfx::SurfaceFormat::B8G8R8X8:
|
||||
return BGRXLayerProgramType;;
|
||||
case gfx::SurfaceFormat::R8G8B8X8:
|
||||
return RGBXLayerProgramType;;
|
||||
case gfx::SurfaceFormat::R8G8B8A8:
|
||||
return RGBALayerProgramType;;
|
||||
default:
|
||||
MOZ_CRASH("unhandled program type");
|
||||
}
|
||||
}
|
||||
|
||||
inline ShaderProgramType
|
||||
GetProgramTypeForTexture(const DeprecatedTextureHost *aDeprecatedTextureHost)
|
||||
{
|
||||
return GetProgramTypeForSurfaceFormat(aDeprecatedTextureHost->GetFormat());
|
||||
}
|
||||
|
||||
/**
|
||||
* TextureSourceOGL provides the necessary API for CompositorOGL to composite
|
||||
* a TextureSource.
|
||||
|
@ -1,158 +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/.
|
||||
|
||||
|
||||
import sys
|
||||
import re
|
||||
import string
|
||||
|
||||
defines = dict()
|
||||
|
||||
def parseShaderName(shadername):
|
||||
name = ""
|
||||
params = {}
|
||||
inparams = None
|
||||
inparam = None
|
||||
curparams = []
|
||||
for c in shadername:
|
||||
if c == '<':
|
||||
inparams = ''
|
||||
elif c == ':':
|
||||
if inparams is None:
|
||||
raise Exception(": in shader name")
|
||||
inparam = ''
|
||||
elif c == ',':
|
||||
if inparams is None:
|
||||
raise Exception(", in shader name")
|
||||
if inparam is None:
|
||||
raise Exception("no values for parameter " + inparams)
|
||||
curparams.append(inparam)
|
||||
inparam = ''
|
||||
elif c == '>':
|
||||
if inparams is None:
|
||||
raise Exception("> in shader name")
|
||||
if inparam is None:
|
||||
raise Exception("no values for parameter " + inparams)
|
||||
curparams.append(inparam)
|
||||
params[inparams] = curparams
|
||||
name += '$' + inparams + '$'
|
||||
inparams = None
|
||||
inparam = None
|
||||
else:
|
||||
if inparam is not None:
|
||||
inparam += c
|
||||
elif inparams is not None:
|
||||
inparams += c
|
||||
else:
|
||||
name += c
|
||||
return (name, params)
|
||||
|
||||
def emitShader(fp, shadername, shaderlines):
|
||||
(parsedname, params) = parseShaderName(shadername)
|
||||
eolContinue = "\\n\\\n";
|
||||
pvals = ['']
|
||||
pname = ''
|
||||
pnames = params.keys()
|
||||
if len(pnames) > 1:
|
||||
raise Exception("Currently only supports zero or one parameters to a @shader")
|
||||
if pnames:
|
||||
pname = pnames[0]
|
||||
pvals = params[pname]
|
||||
for pval in pvals:
|
||||
name = parsedname.replace('$' + pname + '$', pval, 1);
|
||||
fp.write("static const char %s[] = \"/* %s */%s" % (name,name,eolContinue))
|
||||
for line in shaderlines:
|
||||
line = line.replace("\\", "\\\\")
|
||||
while line.find('$') != -1:
|
||||
expansions = re.findall('\$\S+\$', line)
|
||||
for m in expansions:
|
||||
mkey = m[1:-1]
|
||||
mkey = mkey.replace('<' + pname + '>', '<' + pval + '>')
|
||||
if not defines.has_key(mkey):
|
||||
print "Error: Undefined expansion used: '%s'" % (m,)
|
||||
sys.exit(1)
|
||||
mval = defines[mkey]
|
||||
if type(mval) == str:
|
||||
line = line.replace(m, mval)
|
||||
elif type(mval) == list:
|
||||
line = line.replace(m, eolContinue.join(mval) + eolContinue);
|
||||
else:
|
||||
print "Internal Error: Unknown type in defines array: '%s'" % (str(type(mval)),)
|
||||
|
||||
fp.write("%s%s" % (line,eolContinue))
|
||||
fp.write("\";\n\n");
|
||||
|
||||
def genShaders(infile, outfile):
|
||||
source = open(infile, "r").readlines()
|
||||
desthdr = open(outfile, "w+")
|
||||
|
||||
desthdr.write("/* AUTOMATICALLY GENERATED from " + infile + " */\n");
|
||||
desthdr.write("/* DO NOT EDIT! */\n\n");
|
||||
|
||||
global defines
|
||||
|
||||
indefine = None
|
||||
inshader = None
|
||||
|
||||
inblock = False
|
||||
linebuffer = []
|
||||
|
||||
for line in source:
|
||||
# strip comments, if not inblock
|
||||
if not inblock and line.startswith("//"):
|
||||
continue
|
||||
line = string.strip(line)
|
||||
|
||||
if len(line) == 0:
|
||||
continue
|
||||
|
||||
if line[0] == '@':
|
||||
cmd = line
|
||||
rest = ''
|
||||
|
||||
if line.find(' ') != -1:
|
||||
cmd = line[0:line.find(' ')]
|
||||
rest = string.strip(line[len(cmd) + 1:])
|
||||
|
||||
if cmd == "@define":
|
||||
if inblock:
|
||||
raise Exception("@define inside a block!")
|
||||
space = rest.find(' ')
|
||||
if space != -1:
|
||||
defines[rest[0:space]] = rest[space+1:]
|
||||
else:
|
||||
indefine = rest
|
||||
inblock = True
|
||||
elif cmd == "@shader":
|
||||
if inblock:
|
||||
raise Exception("@shader inside a block!")
|
||||
if len(rest) == 0:
|
||||
raise Exception("@shader without a name!")
|
||||
inshader = rest
|
||||
inblock = True
|
||||
elif cmd == "@end":
|
||||
if indefine is not None:
|
||||
if type(linebuffer) == list:
|
||||
for i in range(len(linebuffer)):
|
||||
linebuffer[i] = linebuffer[i].replace("\\", "\\\\")
|
||||
defines[indefine] = linebuffer
|
||||
elif inshader is not None:
|
||||
emitShader(desthdr, inshader, linebuffer)
|
||||
else:
|
||||
raise Exception("@end outside of a block!")
|
||||
indefine = None
|
||||
inshader = None
|
||||
inblock = None
|
||||
linebuffer = []
|
||||
else:
|
||||
raise Exception("Unknown command: %s" % (cmd,))
|
||||
else:
|
||||
if inblock:
|
||||
linebuffer.append(line)
|
||||
|
||||
if (len(sys.argv) != 3):
|
||||
print "Usage: %s infile.txt outfile.h" % (sys.argv[0],)
|
||||
sys.exit(1)
|
||||
|
||||
genShaders(sys.argv[1], sys.argv[2])
|
@ -8003,8 +8003,8 @@ CodeGenerator::visitAsmJSCall(LAsmJSCall *ins)
|
||||
{
|
||||
MAsmJSCall *mir = ins->mir();
|
||||
|
||||
#if defined(JS_CODEGEN_ARM) && !defined(JS_CODEGEN_ARM_HARDFP)
|
||||
if (mir->callee().which() == MAsmJSCall::Callee::Builtin) {
|
||||
#if defined(JS_CODEGEN_ARM)
|
||||
if (!useHardFpABI() && mir->callee().which() == MAsmJSCall::Callee::Builtin) {
|
||||
for (unsigned i = 0, e = ins->numOperands(); i < e; i++) {
|
||||
LAllocation *a = ins->getOperand(i);
|
||||
if (a->isFloatReg()) {
|
||||
|
@ -2879,7 +2879,9 @@ AutoDebugModeInvalidation::~AutoDebugModeInvalidation()
|
||||
if (comp_) {
|
||||
FinishDiscardJitCode(fop, comp_);
|
||||
} else {
|
||||
for (CompartmentsInZoneIter comp(zone_); !comp.done(); comp.next())
|
||||
for (CompartmentsInZoneIter comp(zone_); !comp.done(); comp.next()) {
|
||||
if (comp->principals)
|
||||
FinishDiscardJitCode(fop, comp);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -15,6 +15,8 @@
|
||||
|
||||
#include "jit/arm/Assembler-arm.h"
|
||||
|
||||
#define HWCAP_USE_HARDFP_ABI (1 << 28)
|
||||
|
||||
#if !(defined(ANDROID) || defined(MOZ_B2G)) && !defined(JS_ARM_SIMULATOR)
|
||||
#define HWCAP_ARMv7 (1 << 29)
|
||||
#include <asm/hwcap.h>
|
||||
@ -39,6 +41,10 @@ uint32_t GetARMFlags()
|
||||
if (isSet)
|
||||
return flags;
|
||||
|
||||
#ifdef JS_CODEGEN_ARM_HARDFP
|
||||
flags |= HWCAP_USE_HARDFP_ABI;
|
||||
#endif
|
||||
|
||||
static const char *env = getenv("ARMHWCAP");
|
||||
|
||||
if (env && env[0]) {
|
||||
@ -56,6 +62,9 @@ uint32_t GetARMFlags()
|
||||
" vfpv4 \n"
|
||||
" idiva \n"
|
||||
" idivt \n"
|
||||
#if defined(JS_ARM_SIMULATOR)
|
||||
" hardfp \n"
|
||||
#endif
|
||||
"\n"
|
||||
);
|
||||
exit(0);
|
||||
@ -98,6 +107,10 @@ uint32_t GetARMFlags()
|
||||
flags |= HWCAP_NEON;
|
||||
else if (count == 5 && strncmp(start, "armv7", 5) == 0)
|
||||
flags |= HWCAP_ARMv7;
|
||||
#if defined(JS_ARM_SIMULATOR)
|
||||
else if (count == 6 && strncmp(start, "hardfp", 6) == 0)
|
||||
flags |= HWCAP_USE_HARDFP_ABI;
|
||||
#endif
|
||||
else
|
||||
fprintf(stderr, "Warning: unexpected ARMHWCAP flag at: %s\n", start);
|
||||
start = end;
|
||||
@ -236,6 +249,14 @@ bool hasIDIV()
|
||||
#endif
|
||||
}
|
||||
|
||||
// This is defined in the header and inlined when not using the simulator.
|
||||
#if defined(JS_ARM_SIMULATOR)
|
||||
bool useHardFpABI()
|
||||
{
|
||||
return GetARMFlags() & HWCAP_USE_HARDFP_ABI;
|
||||
}
|
||||
#endif
|
||||
|
||||
Registers::Code
|
||||
Registers::FromName(const char *name)
|
||||
{
|
||||
|
@ -13,9 +13,10 @@
|
||||
#include "js/Utility.h"
|
||||
|
||||
// gcc appears to use __ARM_PCS_VFP to denote that the target is a hard-float target.
|
||||
#ifdef __ARM_PCS_VFP
|
||||
#if defined(__ARM_PCS_VFP)
|
||||
#define JS_CODEGEN_ARM_HARDFP
|
||||
#endif
|
||||
|
||||
namespace js {
|
||||
namespace jit {
|
||||
|
||||
@ -232,6 +233,21 @@ bool hasVFP();
|
||||
bool has16DP();
|
||||
bool hasIDIV();
|
||||
|
||||
// If the simulator is used then the ABI choice is dynamic. Otherwise the ABI is static
|
||||
// and useHardFpABI is inlined so that unused branches can be optimized away.
|
||||
#if defined(JS_ARM_SIMULATOR)
|
||||
bool useHardFpABI();
|
||||
#else
|
||||
static inline bool useHardFpABI()
|
||||
{
|
||||
#if defined(JS_CODEGEN_ARM_HARDFP)
|
||||
return true;
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
} // namespace jit
|
||||
} // namespace js
|
||||
|
||||
|
@ -2093,7 +2093,6 @@ class InstructionIterator {
|
||||
static const uint32_t NumIntArgRegs = 4;
|
||||
static const uint32_t NumFloatArgRegs = 8;
|
||||
|
||||
#ifdef JS_CODEGEN_ARM_HARDFP
|
||||
static inline bool
|
||||
GetIntArgReg(uint32_t usedIntArgs, uint32_t usedFloatArgs, Register *out)
|
||||
{
|
||||
@ -2123,9 +2122,26 @@ GetTempRegForIntArg(uint32_t usedIntArgs, uint32_t usedFloatArgs, Register *out)
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
#if !defined(JS_CODEGEN_ARM_HARDFP) || defined(JS_ARM_SIMULATOR)
|
||||
|
||||
static inline uint32_t
|
||||
GetArgStackDisp(uint32_t arg)
|
||||
{
|
||||
JS_ASSERT(!useHardFpABI());
|
||||
JS_ASSERT(arg >= NumIntArgRegs);
|
||||
return (arg - NumIntArgRegs) * sizeof(intptr_t);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
#if defined(JS_CODEGEN_ARM_HARDFP) || defined(JS_ARM_SIMULATOR)
|
||||
|
||||
static inline bool
|
||||
GetFloatArgReg(uint32_t usedIntArgs, uint32_t usedFloatArgs, FloatRegister *out)
|
||||
{
|
||||
JS_ASSERT(useHardFpABI());
|
||||
if (usedFloatArgs >= NumFloatArgRegs)
|
||||
return false;
|
||||
*out = FloatRegister::FromCode(usedFloatArgs);
|
||||
@ -2135,6 +2151,7 @@ GetFloatArgReg(uint32_t usedIntArgs, uint32_t usedFloatArgs, FloatRegister *out)
|
||||
static inline uint32_t
|
||||
GetIntArgStackDisp(uint32_t usedIntArgs, uint32_t usedFloatArgs, uint32_t *padding)
|
||||
{
|
||||
JS_ASSERT(useHardFpABI());
|
||||
JS_ASSERT(usedIntArgs >= NumIntArgRegs);
|
||||
uint32_t doubleSlots = Max(0, (int32_t)usedFloatArgs - (int32_t)NumFloatArgRegs);
|
||||
doubleSlots *= 2;
|
||||
@ -2145,6 +2162,7 @@ GetIntArgStackDisp(uint32_t usedIntArgs, uint32_t usedFloatArgs, uint32_t *paddi
|
||||
static inline uint32_t
|
||||
GetFloat32ArgStackDisp(uint32_t usedIntArgs, uint32_t usedFloatArgs, uint32_t *padding)
|
||||
{
|
||||
JS_ASSERT(useHardFpABI());
|
||||
JS_ASSERT(usedFloatArgs >= NumFloatArgRegs);
|
||||
uint32_t intSlots = 0;
|
||||
if (usedIntArgs > NumIntArgRegs)
|
||||
@ -2156,6 +2174,7 @@ GetFloat32ArgStackDisp(uint32_t usedIntArgs, uint32_t usedFloatArgs, uint32_t *p
|
||||
static inline uint32_t
|
||||
GetDoubleArgStackDisp(uint32_t usedIntArgs, uint32_t usedFloatArgs, uint32_t *padding)
|
||||
{
|
||||
JS_ASSERT(useHardFpABI());
|
||||
JS_ASSERT(usedFloatArgs >= NumFloatArgRegs);
|
||||
uint32_t intSlots = 0;
|
||||
if (usedIntArgs > NumIntArgRegs) {
|
||||
@ -2167,46 +2186,11 @@ GetDoubleArgStackDisp(uint32_t usedIntArgs, uint32_t usedFloatArgs, uint32_t *pa
|
||||
doubleSlots *= 2;
|
||||
return (intSlots + doubleSlots + *padding) * sizeof(intptr_t);
|
||||
}
|
||||
#else
|
||||
static inline bool
|
||||
GetIntArgReg(uint32_t arg, uint32_t floatArg, Register *out)
|
||||
{
|
||||
if (arg < NumIntArgRegs) {
|
||||
*out = Register::FromCode(arg);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// Get a register in which we plan to put a quantity that will be used as an
|
||||
// integer argument. This differs from GetIntArgReg in that if we have no more
|
||||
// actual argument registers to use we will fall back on using whatever
|
||||
// CallTempReg* don't overlap the argument registers, and only fail once those
|
||||
// run out too.
|
||||
static inline bool
|
||||
GetTempRegForIntArg(uint32_t usedIntArgs, uint32_t usedFloatArgs, Register *out)
|
||||
{
|
||||
if (GetIntArgReg(usedIntArgs, usedFloatArgs, out))
|
||||
return true;
|
||||
// Unfortunately, we have to assume things about the point at which
|
||||
// GetIntArgReg returns false, because we need to know how many registers it
|
||||
// can allocate.
|
||||
usedIntArgs -= NumIntArgRegs;
|
||||
if (usedIntArgs >= NumCallTempNonArgRegs)
|
||||
return false;
|
||||
*out = CallTempNonArgRegs[usedIntArgs];
|
||||
return true;
|
||||
}
|
||||
|
||||
static inline uint32_t
|
||||
GetArgStackDisp(uint32_t arg)
|
||||
{
|
||||
JS_ASSERT(arg >= NumIntArgRegs);
|
||||
return (arg - NumIntArgRegs) * sizeof(intptr_t);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
class DoubleEncoder {
|
||||
uint32_t rep(bool b, uint32_t count) {
|
||||
uint32_t ret = 0;
|
||||
|
@ -176,8 +176,7 @@ class CodeGeneratorARM : public CodeGeneratorShared
|
||||
bool generateInvalidateEpilogue();
|
||||
protected:
|
||||
void postAsmJSCall(LAsmJSCall *lir) {
|
||||
#ifndef JS_CODEGEN_ARM_HARDFP
|
||||
if (lir->mir()->callee().which() == MAsmJSCall::Callee::Builtin) {
|
||||
if (!useHardFpABI() && lir->mir()->callee().which() == MAsmJSCall::Callee::Builtin) {
|
||||
switch (lir->mir()->type()) {
|
||||
case MIRType_Double:
|
||||
masm.ma_vxfer(r0, r1, d0);
|
||||
@ -190,7 +189,6 @@ class CodeGeneratorARM : public CodeGeneratorShared
|
||||
break;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
bool visitEffectiveAddress(LEffectiveAddress *ins);
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user