Merge mozilla-central to fx-team

This commit is contained in:
Carsten "Tomcat" Book 2016-06-22 13:46:27 +02:00
commit 96801fb02b
323 changed files with 5043 additions and 2610 deletions

View File

@ -714,6 +714,37 @@ logging::Tree(const char* aTitle, const char* aMsgText,
logging::MsgEnd();
}
void
logging::DOMTree(const char* aTitle, const char* aMsgText,
DocAccessible* aDocument)
{
logging::MsgBegin(aTitle, aMsgText);
nsAutoString level;
nsINode* root = aDocument->DocumentNode();
do {
printf("%s", NS_ConvertUTF16toUTF8(level).get());
logging::Node("", root);
if (root->GetFirstChild()) {
level.Append(NS_LITERAL_STRING(" "));
root = root->GetFirstChild();
continue;
}
if (root->GetNextSibling()) {
root = root->GetNextSibling();
continue;
}
while ((root = root->GetParentNode())) {
level.Cut(0, 2);
if (root->GetNextSibling()) {
root = root->GetNextSibling();
break;
}
}
}
while (root);
logging::MsgEnd();
}
void
logging::MsgBegin(const char* aTitle, const char* aMsgText, ...)
{

View File

@ -140,11 +140,12 @@ void TreeInfo(const char* aMsg, uint32_t aExtraFlags,
void TreeInfo(const char* aMsg, uint32_t aExtraFlags, Accessible* aParent);
/**
* Log the accessible tree.
* Log the accessible/DOM tree.
*/
typedef const char* (*GetTreePrefix)(void* aData, Accessible*);
void Tree(const char* aTitle, const char* aMsgText, DocAccessible* aDoc,
GetTreePrefix aPrefixFunc = nullptr, void* aGetTreePrefixData = nullptr);
void DOMTree(const char* aTitle, const char* aMsgText, DocAccessible* aDoc);
/**
* Log the message ('title: text' format) on new line. Print the start and end

View File

@ -57,14 +57,29 @@ TreeWalker::~TreeWalker()
MOZ_COUNT_DTOR(TreeWalker);
}
Accessible*
TreeWalker::Scope(nsIContent* aAnchorNode)
{
Reset();
mAnchorNode = aAnchorNode;
bool skipSubtree = false;
Accessible* acc = AccessibleFor(aAnchorNode, 0, &skipSubtree);
if (acc) {
mPhase = eAtEnd;
return acc;
}
return skipSubtree ? nullptr : Next();
}
bool
TreeWalker::Seek(nsIContent* aChildNode)
{
MOZ_ASSERT(aChildNode, "Child cannot be null");
mPhase = eAtStart;
mStateStack.Clear();
mARIAOwnsIdx = 0;
Reset();
nsIContent* childNode = nullptr;
nsINode* parentNode = aChildNode;
@ -110,7 +125,7 @@ TreeWalker::Seek(nsIContent* aChildNode)
}
Accessible*
TreeWalker::Next(nsIContent* aStopNode)
TreeWalker::Next()
{
if (mStateStack.IsEmpty()) {
if (mPhase == eAtEnd) {
@ -139,10 +154,6 @@ TreeWalker::Next(nsIContent* aStopNode)
dom::AllChildrenIterator* top = &mStateStack[mStateStack.Length() - 1];
while (top) {
if (aStopNode && top->Get() == aStopNode) {
return nullptr;
}
while (nsIContent* childNode = top->GetNextChild()) {
bool skipSubtree = false;
Accessible* child = AccessibleFor(childNode, mFlags, &skipSubtree);
@ -150,14 +161,10 @@ TreeWalker::Next(nsIContent* aStopNode)
return child;
}
// Walk down the subtree if allowed, otherwise check if we have reached
// a stop node.
// Walk down the subtree if allowed.
if (!skipSubtree && childNode->IsElement()) {
top = PushState(childNode, true);
}
else if (childNode == aStopNode) {
return nullptr;
}
}
top = PopState();
}
@ -171,7 +178,7 @@ TreeWalker::Next(nsIContent* aStopNode)
mPhase = eAtEnd;
return nullptr;
}
return Next(aStopNode);
return Next();
}
nsINode* contextNode = mContext->GetNode();
@ -184,7 +191,7 @@ TreeWalker::Next(nsIContent* aStopNode)
top = PushState(parent, true);
if (top->Seek(mAnchorNode)) {
mAnchorNode = parent;
return Next(aStopNode);
return Next();
}
// XXX We really should never get here, it means we're trying to find an
@ -194,7 +201,7 @@ TreeWalker::Next(nsIContent* aStopNode)
mAnchorNode = parent;
}
return Next(aStopNode);
return Next();
}
Accessible*

View File

@ -50,8 +50,23 @@ public:
~TreeWalker();
/**
* Clears the tree walker state and resets it to the given child within
* the anchor.
* Resets the walker state, and sets the given node as an anchor. Returns a
* first accessible element within the node including the node itself.
*/
Accessible* Scope(nsIContent* aAnchorNode);
/**
* Resets the walker state.
*/
void Reset()
{
mPhase = eAtStart;
mStateStack.Clear();
mARIAOwnsIdx = 0;
}
/**
* Sets the walker state to the given child node if it's within the anchor.
*/
bool Seek(nsIContent* aChildNode);
@ -62,7 +77,7 @@ public:
* rejected during tree creation then the caller should be unbind it
* from the document.
*/
Accessible* Next(nsIContent* aStopNode = nullptr);
Accessible* Next();
Accessible* Prev();
Accessible* Context() const { return mContext; }

View File

@ -1663,7 +1663,7 @@ public:
InsertIterator(Accessible* aContext,
const nsTArray<nsCOMPtr<nsIContent> >* aNodes) :
mChild(nullptr), mChildBefore(nullptr), mWalker(aContext),
mStopNode(nullptr), mNodes(aNodes), mNodesIdx(0)
mNodes(aNodes), mNodesIdx(0)
{
MOZ_ASSERT(aContext, "No context");
MOZ_ASSERT(aNodes, "No nodes to search for accessible elements");
@ -1685,7 +1685,6 @@ private:
Accessible* mChild;
Accessible* mChildBefore;
TreeWalker mWalker;
nsIContent* mStopNode;
const nsTArray<nsCOMPtr<nsIContent> >* mNodes;
uint32_t mNodesIdx;
@ -1695,7 +1694,7 @@ bool
InsertIterator::Next()
{
if (mNodesIdx > 0) {
Accessible* nextChild = mWalker.Next(mStopNode);
Accessible* nextChild = mWalker.Next();
if (nextChild) {
mChildBefore = mChild;
mChild = nextChild;
@ -1737,20 +1736,21 @@ InsertIterator::Next()
// If inserted nodes are siblings then just move the walker next.
if (prevNode && prevNode->GetNextSibling() == node) {
mStopNode = node;
Accessible* nextChild = mWalker.Next(mStopNode);
Accessible* nextChild = mWalker.Scope(node);
if (nextChild) {
mChildBefore = mChild;
mChild = nextChild;
return true;
}
}
else if (mWalker.Seek(node)) {
mStopNode = node;
mChildBefore = mWalker.Prev();
mChild = mWalker.Next(mStopNode);
if (mChild) {
return true;
else {
TreeWalker finder(container);
if (finder.Seek(node)) {
mChild = mWalker.Scope(node);
if (mChild) {
mChildBefore = finder.Prev();
return true;
}
}
}
}

View File

@ -1366,7 +1366,6 @@ pref("browser.tabs.crashReporting.email", "");
#ifndef MOZ_MULET
pref("layers.async-pan-zoom.enabled", true);
#endif
pref("apz.velocity_bias", "0.0");
// Enable e10s add-on interposition by default.
pref("extensions.interposition.enabled", true);

View File

@ -195,6 +195,12 @@ XPCOMUtils.defineLazyGetter(gEMEHandler, "_brandShortName", function() {
return document.getElementById("bundle_brand").getString("brandShortName");
});
const TELEMETRY_DDSTAT_SHOWN = 0;
const TELEMETRY_DDSTAT_SHOWN_FIRST = 1;
const TELEMETRY_DDSTAT_CLICKED = 2;
const TELEMETRY_DDSTAT_CLICKED_FIRST = 3;
const TELEMETRY_DDSTAT_SOLVED = 4;
let gDecoderDoctorHandler = {
shouldShowLearnMoreButton() {
return AppConstants.platform == "win";
@ -241,32 +247,93 @@ let gDecoderDoctorHandler = {
Cu.reportError("Malformed Decoder Doctor message with data: " + data);
return;
}
let {type} = parsedData;
// parsedData (the result of parsing the incoming 'data' json string)
// contains analysis information from Decoder Doctor:
// - 'type' is the type of issue, it determines which text to show in the
// infobar.
// - 'decoderDoctorReportId' is the Decoder Doctor issue identifier, to be
// used here as key for the telemetry (counting infobar displays,
// "Learn how" buttons clicks, and resolutions) and for the prefs used
// to store at-issue formats.
// - 'formats' contains a comma-separated list of formats (or key systems)
// that suffer the issue. These are kept in a pref, which the backend
// uses to later find when an issue is resolved.
// - 'isSolved' is true when the notification actually indicates the
// resolution of that issue, to be reported as telemetry.
let {type, isSolved, decoderDoctorReportId, formats} = parsedData;
type = type.toLowerCase();
let title = gDecoderDoctorHandler.getLabelForNotificationBox(type);
if (!title) {
return;
}
let buttons = [];
if (gDecoderDoctorHandler.shouldShowLearnMoreButton()) {
buttons.push({
label: gNavigatorBundle.getString("decoder.noCodecs.button"),
accessKey: gNavigatorBundle.getString("decoder.noCodecs.accesskey"),
callback() {
let baseURL = Services.urlFormatter.formatURLPref("app.support.baseURL");
openUILinkIn(baseURL + "fix-video-audio-problems-firefox-windows", "tab");
}
});
}
// We keep the list of formats in prefs for the sake of the decoder itself,
// which reads it to determine when issues get solved for these formats.
// (Writing prefs from e10s content is now allowed.)
let formatsPref = "media.decoder-doctor." + decoderDoctorReportId + ".formats";
let buttonClickedPref = "media.decoder-doctor." + decoderDoctorReportId + ".button-clicked";
let histogram =
Services.telemetry.getKeyedHistogramById("DECODER_DOCTOR_INFOBAR_STATS");
box.appendNotification(
title,
notificationId,
"", // This uses the info icon as specified below.
box.PRIORITY_INFO_LOW,
buttons
);
let formatsInPref = Services.prefs.getPrefType(formatsPref) &&
Services.prefs.getCharPref(formatsPref);
if (!isSolved) {
if (!formats) {
Cu.reportError("Malformed Decoder Doctor unsolved message with no formats");
return;
}
if (!formatsInPref) {
Services.prefs.setCharPref(formatsPref, formats);
histogram.add(decoderDoctorReportId, TELEMETRY_DDSTAT_SHOWN_FIRST);
} else {
// Split existing formats into an array of strings.
let existing = formatsInPref.split(",").map(String.trim);
// Keep given formats that were not already recorded.
let newbies = formats.split(",").map(String.trim)
.filter(x => existing.includes(x));
// And rewrite pref with the added new formats (if any).
if (newbies.length) {
Services.prefs.setCharPref(formatsPref,
existing.concat(newbies).join(", "));
}
}
histogram.add(decoderDoctorReportId, TELEMETRY_DDSTAT_SHOWN);
let buttons = [];
if (gDecoderDoctorHandler.shouldShowLearnMoreButton()) {
buttons.push({
label: gNavigatorBundle.getString("decoder.noCodecs.button"),
accessKey: gNavigatorBundle.getString("decoder.noCodecs.accesskey"),
callback() {
let clickedInPref = Services.prefs.getPrefType(buttonClickedPref) &&
Services.prefs.getBoolPref(buttonClickedPref);
if (!clickedInPref) {
Services.prefs.setBoolPref(buttonClickedPref, true);
histogram.add(decoderDoctorReportId, TELEMETRY_DDSTAT_CLICKED_FIRST);
}
histogram.add(decoderDoctorReportId, TELEMETRY_DDSTAT_CLICKED);
let baseURL = Services.urlFormatter.formatURLPref("app.support.baseURL");
openUILinkIn(baseURL + "fix-video-audio-problems-firefox-windows", "tab");
}
});
}
box.appendNotification(
title,
notificationId,
"", // This uses the info icon as specified below.
box.PRIORITY_INFO_LOW,
buttons
);
} else if (formatsInPref) {
// Issue is solved, and prefs haven't been cleared yet, meaning it's the
// first time we get this resolution -> Clear prefs and report telemetry.
Services.prefs.clearUserPref(formatsPref);
Services.prefs.clearUserPref(buttonClickedPref);
histogram.add(decoderDoctorReportId, TELEMETRY_DDSTAT_SOLVED);
}
},
}

View File

@ -1,5 +1,4 @@
[DEFAULT]
skip-if = (os == "win" && debug && e10s) # Bug 1253956
support-files =
POSTSearchEngine.xml
accounts_testRemoteCommands.html
@ -392,7 +391,7 @@ skip-if = buildapp == 'mulet'
[browser_sanitizeDialog.js]
skip-if = buildapp == 'mulet'
[browser_save_link-perwindowpb.js]
skip-if = buildapp == 'mulet'
skip-if = buildapp == 'mulet' || (e10s && debug && os == "win") # Bug 1280505
[browser_save_private_link_perwindowpb.js]
skip-if = buildapp == 'mulet'
[browser_save_link_when_window_navigates.js]

View File

@ -86,16 +86,11 @@ function* checkBookmark(uri, expected_title) {
// custom page load listener.
function promisePageLoaded(browser)
{
return new Promise(resolve => {
browser.addEventListener("DOMContentLoaded", function pageLoaded(event) {
browser.removeEventListener("DOMContentLoaded", pageLoaded, true);
if (event.originalTarget != browser.contentDocument ||
event.target.location.href == "about:blank") {
info("skipping spurious load event");
return;
}
resolve();
}, true);
return ContentTask.spawn(browser, null, function* () {
yield ContentTaskUtils.waitForEvent(this, "DOMContentLoaded", true,
(event) => {
return event.originalTarget === content.document &&
event.target.location.href !== "about:blank"
});
});
}

View File

@ -8,7 +8,10 @@ function* test_decoder_doctor_notification(type, notificationMessage, options) {
yield ContentTask.spawn(browser, type, function*(type) {
Services.obs.notifyObservers(content.window,
"decoder-doctor-notification",
JSON.stringify({type: type}));
JSON.stringify({type: type,
isSolved: false,
decoderDoctorReportId: "test",
formats: "test"}));
});
let notification;

View File

@ -118,7 +118,7 @@ add_task(function* () {
let notification = PopupNotifications.getNotification("click-to-play-plugins", gTestBrowser);
ok(!notification, "Test 11b, Should not have a click-to-play notification");
gTestBrowser.contentWindow.history.back();
gTestBrowser.webNavigation.goBack();
yield promisePopupNotification("click-to-play-plugins");
});

View File

@ -4,6 +4,8 @@ XPCOMUtils.defineLazyModuleGetter(this, "Task",
"resource://gre/modules/Task.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "PlacesUtils",
"resource://gre/modules/PlacesUtils.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "PromiseUtils",
"resource://gre/modules/PromiseUtils.jsm");
// The blocklist shim running in the content process does not initialize at
// start up, so it's not active until we load content that needs to do a
@ -71,40 +73,44 @@ function waitForEvent(subject, eventName, checkFn, useCapture, useUntrusted) {
* The tab to load into.
* @param [optional] url
* The url to load, or the current url.
* @param [optional] event
* The load event type to wait for. Defaults to "load".
* @return {Promise} resolved when the event is handled.
* @resolves to the received event
* @rejects if a valid load event is not received within a meaningful interval
*/
function promiseTabLoadEvent(tab, url, eventType="load") {
return new Promise((resolve, reject) => {
info("Wait tab event: " + eventType);
function promiseTabLoadEvent(tab, url) {
let deferred = PromiseUtils.defer();
info("Wait tab event: load");
function handle(event) {
if (event.originalTarget != tab.linkedBrowser.contentDocument ||
event.target.location.href == "about:blank" ||
(url && event.target.location.href != url)) {
info("Skipping spurious '" + eventType + "'' event" +
" for " + event.target.location.href);
return;
}
clearTimeout(timeout);
tab.linkedBrowser.removeEventListener(eventType, handle, true);
info("Tab event received: " + eventType);
resolve(event);
function handle(loadedUrl) {
if (loadedUrl === "about:blank" || (url && loadedUrl !== url)) {
info(`Skipping spurious load event for ${loadedUrl}`);
return false;
}
let timeout = setTimeout(() => {
tab.linkedBrowser.removeEventListener(eventType, handle, true);
reject(new Error("Timed out while waiting for a '" + eventType + "'' event"));
}, 30000);
info("Tab event received: load");
return true;
}
tab.linkedBrowser.addEventListener(eventType, handle, true, true);
if (url) {
tab.linkedBrowser.loadURI(url);
}
// Create two promises: one resolved from the content process when the page
// loads and one that is rejected if we take too long to load the url.
let loaded = BrowserTestUtils.browserLoaded(tab.linkedBrowser, false, handle);
let timeout = setTimeout(() => {
deferred.reject(new Error("Timed out while waiting for a 'load' event"));
}, 30000);
loaded.then(() => {
clearTimeout(timeout);
deferred.resolve()
});
if (url)
BrowserTestUtils.loadURI(tab.linkedBrowser, url);
// Promise.all rejects if either promise rejects (i.e. if we time out) and
// if our loaded promise resolves before the timeout, then we resolve the
// timeout promise as well, causing the all promise to resolve.
return Promise.all([deferred.promise, loaded]);
}
function waitForCondition(condition, nextTest, errorMsg, aTries, aWait) {

View File

@ -22,32 +22,46 @@ XPCOMUtils.defineLazyModuleGetter(this, "Task",
function promiseTabLoadEvent(tab, url, eventType="load")
{
let deferred = Promise.defer();
info("Wait tab event: " + eventType);
info(`Wait tab event: ${eventType}`);
function handle(event) {
if (event.originalTarget != tab.linkedBrowser.contentDocument ||
event.target.location.href == "about:blank" ||
(url && event.target.location.href != url)) {
info("Skipping spurious '" + eventType + "'' event" +
" for " + event.target.location.href);
return;
function handle(loadedUrl) {
if (loadedUrl === "about:blank" || (url && loadedUrl !== url)) {
info(`Skipping spurious load event for ${loadedUrl}`);
return false;
}
clearTimeout(timeout);
tab.linkedBrowser.removeEventListener(eventType, handle, true);
info("Tab event received: " + eventType);
deferred.resolve(event);
info("Tab event received: load");
return true;
}
// Create two promises: one resolved from the content process when the page
// loads and one that is rejected if we take too long to load the url.
let loaded;
if (eventType === "load") {
loaded = BrowserTestUtils.browserLoaded(tab.linkedBrowser, false, handle);
} else {
// No need to use handle.
loaded =
BrowserTestUtils.waitForContentEvent(tab.linkedBrowser, eventType,
true, undefined, true);
}
let timeout = setTimeout(() => {
tab.linkedBrowser.removeEventListener(eventType, handle, true);
deferred.reject(new Error("Timed out while waiting for a '" + eventType + "'' event"));
deferred.reject(new Error(`Timed out while waiting for a ${eventType} event`));
}, 30000);
tab.linkedBrowser.addEventListener(eventType, handle, true, true);
if (url) {
tab.linkedBrowser.loadURI(url);
}
return deferred.promise;
loaded.then(() => {
clearTimeout(timeout);
deferred.resolve()
});
if (url)
BrowserTestUtils.loadURI(tab.linkedBrowser, url);
// Promise.all rejects if either promise rejects (i.e. if we time out) and
// if our loaded promise resolves before the timeout, then we resolve the
// timeout promise as well, causing the all promise to resolve.
return Promise.all([deferred.promise, loaded]);
}
Services.prefs.setCharPref("urlclassifier.forbiddenTable", "test-forbid-simple");

View File

@ -20,7 +20,6 @@
#include "nsIContentPolicy.h"
#include "nsIContentSecurityPolicy.h"
#include "nsContentPolicyUtils.h"
#include "nsCORSListenerProxy.h"
#include "nsISupportsPriority.h"
#include "nsICachingChannel.h"
#include "nsIWebContentHandlerRegistrar.h"

View File

@ -1869,7 +1869,7 @@ InitEvent(WidgetGUIEvent& aEvent, LayoutDeviceIntPoint* aPt = nullptr)
NS_IMETHODIMP
nsDOMWindowUtils::SendQueryContentEvent(uint32_t aType,
uint32_t aOffset, uint32_t aLength,
int64_t aOffset, uint32_t aLength,
int32_t aX, int32_t aY,
uint32_t aAdditionalFlags,
nsIQueryContentEventResult **aResult)
@ -1971,13 +1971,29 @@ nsDOMWindowUtils::SendQueryContentEvent(uint32_t aType,
nsCOMPtr<nsIWidget> targetWidget = widget;
LayoutDeviceIntPoint pt(aX, aY);
bool useNativeLineBreak =
WidgetQueryContentEvent::Options options;
options.mUseNativeLineBreak =
!(aAdditionalFlags & QUERY_CONTENT_FLAG_USE_XP_LINE_BREAK);
options.mRelativeToInsertionPoint =
(aAdditionalFlags &
QUERY_CONTENT_FLAG_OFFSET_RELATIVE_TO_INSERTION_POINT) != 0;
if (options.mRelativeToInsertionPoint) {
switch (message) {
case eQueryTextContent:
case eQueryCaretRect:
case eQueryTextRect:
break;
default:
return NS_ERROR_INVALID_ARG;
}
} else if (aOffset < 0) {
return NS_ERROR_INVALID_ARG;
}
if (message == eQueryCharacterAtPoint) {
// Looking for the widget at the point.
WidgetQueryContentEvent dummyEvent(true, eQueryContentState, widget);
dummyEvent.mUseNativeLineBreak = useNativeLineBreak;
dummyEvent.Init(options);
InitEvent(dummyEvent, &pt);
nsIFrame* popupFrame =
nsLayoutUtils::GetPopupFrameForEventCoordinates(presContext->GetRootPresContext(), &dummyEvent);
@ -2004,19 +2020,19 @@ nsDOMWindowUtils::SendQueryContentEvent(uint32_t aType,
switch (message) {
case eQueryTextContent:
queryEvent.InitForQueryTextContent(aOffset, aLength, useNativeLineBreak);
queryEvent.InitForQueryTextContent(aOffset, aLength, options);
break;
case eQueryCaretRect:
queryEvent.InitForQueryCaretRect(aOffset, useNativeLineBreak);
queryEvent.InitForQueryCaretRect(aOffset, options);
break;
case eQueryTextRect:
queryEvent.InitForQueryTextRect(aOffset, aLength, useNativeLineBreak);
queryEvent.InitForQueryTextRect(aOffset, aLength, options);
break;
case eQuerySelectedText:
queryEvent.InitForQuerySelectedText(selectionType, useNativeLineBreak);
queryEvent.InitForQuerySelectedText(selectionType, options);
break;
default:
queryEvent.mUseNativeLineBreak = useNativeLineBreak;
queryEvent.Init(options);
break;
}

View File

@ -11,6 +11,37 @@
using namespace mozilla;
/******************************************************************************
* Is*PropertyAvailable() methods which check if the property is available
* (valid) with the event message.
******************************************************************************/
static bool IsNotFoundPropertyAvailable(EventMessage aEventMessage)
{
return aEventMessage == eQuerySelectedText ||
aEventMessage == eQueryCharacterAtPoint;
}
static bool IsOffsetPropertyAvailable(EventMessage aEventMessage)
{
return aEventMessage == eQueryTextContent ||
aEventMessage == eQueryTextRect ||
aEventMessage == eQueryCaretRect ||
IsNotFoundPropertyAvailable(aEventMessage);
}
static bool IsRectRelatedPropertyAvailable(EventMessage aEventMessage)
{
return aEventMessage == eQueryCaretRect ||
aEventMessage == eQueryTextRect ||
aEventMessage == eQueryEditorRect ||
aEventMessage == eQueryCharacterAtPoint;
}
/******************************************************************************
* nsQueryContentEventResult
******************************************************************************/
NS_INTERFACE_MAP_BEGIN(nsQueryContentEventResult)
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIQueryContentEventResult)
NS_INTERFACE_MAP_ENTRY(nsIQueryContentEventResult)
@ -30,12 +61,33 @@ nsQueryContentEventResult::~nsQueryContentEventResult()
}
NS_IMETHODIMP
nsQueryContentEventResult::GetOffset(uint32_t *aOffset)
nsQueryContentEventResult::GetOffset(uint32_t* aOffset)
{
bool notFound;
nsresult rv = GetNotFound(&notFound);
NS_ENSURE_SUCCESS(rv, rv);
NS_ENSURE_TRUE(!notFound, NS_ERROR_NOT_AVAILABLE);
if (NS_WARN_IF(!mSucceeded)) {
return NS_ERROR_NOT_AVAILABLE;
}
if (NS_WARN_IF(!IsOffsetPropertyAvailable(mEventMessage))) {
return NS_ERROR_NOT_AVAILABLE;
}
// With some event message, both offset and notFound properties are available.
// In that case, offset value may mean "not found". If so, this method
// shouldn't return mOffset as the result because it's a special value for
// "not found".
if (IsNotFoundPropertyAvailable(mEventMessage)) {
bool notFound;
nsresult rv = GetNotFound(&notFound);
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv; // Just an unexpected case...
}
// As said above, if mOffset means "not found", offset property shouldn't
// return its value without any errors.
if (NS_WARN_IF(notFound)) {
return NS_ERROR_NOT_AVAILABLE;
}
}
*aOffset = mOffset;
return NS_OK;
}
@ -55,14 +107,6 @@ nsQueryContentEventResult::GetTentativeCaretOffset(uint32_t* aOffset)
return NS_OK;
}
static bool IsRectEnabled(EventMessage aEventMessage)
{
return aEventMessage == eQueryCaretRect ||
aEventMessage == eQueryTextRect ||
aEventMessage == eQueryEditorRect ||
aEventMessage == eQueryCharacterAtPoint;
}
NS_IMETHODIMP
nsQueryContentEventResult::GetReversed(bool *aReversed)
{
@ -76,7 +120,7 @@ NS_IMETHODIMP
nsQueryContentEventResult::GetLeft(int32_t *aLeft)
{
NS_ENSURE_TRUE(mSucceeded, NS_ERROR_NOT_AVAILABLE);
NS_ENSURE_TRUE(IsRectEnabled(mEventMessage),
NS_ENSURE_TRUE(IsRectRelatedPropertyAvailable(mEventMessage),
NS_ERROR_NOT_AVAILABLE);
*aLeft = mRect.x;
return NS_OK;
@ -86,7 +130,7 @@ NS_IMETHODIMP
nsQueryContentEventResult::GetWidth(int32_t *aWidth)
{
NS_ENSURE_TRUE(mSucceeded, NS_ERROR_NOT_AVAILABLE);
NS_ENSURE_TRUE(IsRectEnabled(mEventMessage),
NS_ENSURE_TRUE(IsRectRelatedPropertyAvailable(mEventMessage),
NS_ERROR_NOT_AVAILABLE);
*aWidth = mRect.width;
return NS_OK;
@ -96,7 +140,7 @@ NS_IMETHODIMP
nsQueryContentEventResult::GetTop(int32_t *aTop)
{
NS_ENSURE_TRUE(mSucceeded, NS_ERROR_NOT_AVAILABLE);
NS_ENSURE_TRUE(IsRectEnabled(mEventMessage),
NS_ENSURE_TRUE(IsRectRelatedPropertyAvailable(mEventMessage),
NS_ERROR_NOT_AVAILABLE);
*aTop = mRect.y;
return NS_OK;
@ -106,7 +150,7 @@ NS_IMETHODIMP
nsQueryContentEventResult::GetHeight(int32_t *aHeight)
{
NS_ENSURE_TRUE(mSucceeded, NS_ERROR_NOT_AVAILABLE);
NS_ENSURE_TRUE(IsRectEnabled(mEventMessage),
NS_ENSURE_TRUE(IsRectRelatedPropertyAvailable(mEventMessage),
NS_ERROR_NOT_AVAILABLE);
*aHeight = mRect.height;
return NS_OK;
@ -132,12 +176,12 @@ nsQueryContentEventResult::GetSucceeded(bool *aSucceeded)
}
NS_IMETHODIMP
nsQueryContentEventResult::GetNotFound(bool *aNotFound)
nsQueryContentEventResult::GetNotFound(bool* aNotFound)
{
NS_ENSURE_TRUE(mSucceeded, NS_ERROR_NOT_AVAILABLE);
NS_ENSURE_TRUE(mEventMessage == eQuerySelectedText ||
mEventMessage == eQueryCharacterAtPoint,
NS_ERROR_NOT_AVAILABLE);
if (NS_WARN_IF(!mSucceeded) ||
NS_WARN_IF(!IsNotFoundPropertyAvailable(mEventMessage))) {
return NS_ERROR_NOT_AVAILABLE;
}
*aNotFound = (mOffset == WidgetQueryContentEvent::NOT_FOUND);
return NS_OK;
}
@ -167,7 +211,8 @@ nsQueryContentEventResult::SetEventResult(nsIWidget* aWidget,
mTentativeCaretOffset = aEvent.mReply.mTentativeCaretOffset;
mString = aEvent.mReply.mString;
if (!IsRectEnabled(mEventMessage) || !aWidget || !mSucceeded) {
if (!IsRectRelatedPropertyAvailable(mEventMessage) ||
!aWidget || !mSucceeded) {
return;
}

View File

@ -45,7 +45,6 @@
#include "mozilla/Logging.h"
#include "nsCRT.h"
#include "nsContentCreatorFunctions.h"
#include "nsCORSListenerProxy.h"
#include "nsProxyRelease.h"
#include "nsSandboxFlags.h"
#include "nsContentTypeParser.h"

View File

@ -299,10 +299,9 @@ WebGLContext::DestroyResourcesAndContext()
// We just got rid of everything, so the context had better
// have been going away.
#ifdef DEBUG
if (gl->DebugMode())
if (GLContext::ShouldSpew()) {
printf_stderr("--- WebGL context destroyed: %p\n", gl.get());
#endif
}
gl = nullptr;
}
@ -587,7 +586,7 @@ CreateGLWithEGL(const gl::SurfaceCaps& caps, gl::CreateContextFlags flags,
{
const gfx::IntSize dummySize(16, 16);
RefPtr<GLContext> gl = gl::GLContextProviderEGL::CreateOffscreen(dummySize, caps,
flags, *out_failureId);
flags, out_failureId);
if (gl && gl->IsANGLE()) {
gl = nullptr;
}
@ -613,7 +612,7 @@ CreateGLWithANGLE(const gl::SurfaceCaps& caps, gl::CreateContextFlags flags,
{
const gfx::IntSize dummySize(16, 16);
RefPtr<GLContext> gl = gl::GLContextProviderEGL::CreateOffscreen(dummySize, caps,
flags, *out_failureId);
flags, out_failureId);
if (gl && !gl->IsANGLE()) {
gl = nullptr;
}
@ -652,7 +651,7 @@ CreateGLWithDefault(const gl::SurfaceCaps& caps, gl::CreateContextFlags flags,
const gfx::IntSize dummySize(16, 16);
RefPtr<GLContext> gl = gl::GLContextProvider::CreateOffscreen(dummySize, caps,
flags, *out_failureId);
flags, out_failureId);
if (gl && gl->IsANGLE()) {
gl = nullptr;
@ -719,7 +718,8 @@ WebGLContext::CreateAndInitGL(bool forceEnabled, nsACString* const out_failReaso
useANGLE = !disableANGLE;
#endif
gl::CreateContextFlags flags = gl::CreateContextFlags::NONE;
gl::CreateContextFlags flags = gl::CreateContextFlags::NO_VALIDATION;
if (forceEnabled) flags |= gl::CreateContextFlags::FORCE_ENABLE_HARDWARE;
if (!IsWebGL2()) flags |= gl::CreateContextFlags::REQUIRE_COMPAT_PROFILE;
if (IsWebGL2()) flags |= gl::CreateContextFlags::PREFER_ES3;
@ -961,10 +961,9 @@ WebGLContext::SetDimensions(int32_t signedWidth, int32_t signedHeight)
return NS_ERROR_FAILURE;
}
#ifdef DEBUG
if (gl->DebugMode())
if (GLContext::ShouldSpew()) {
printf_stderr("--- WebGL context created: %p\n", gl.get());
#endif
}
mResetLayer = true;
mOptionsFrozen = true;

View File

@ -2797,7 +2797,8 @@ skip-if = (os == 'android') || (os == 'linux')
[generated/test_conformance__misc__is-object.html]
[generated/test_conformance__misc__null-object-behaviour.html]
[generated/test_conformance__misc__object-deletion-behaviour.html]
fail-if = (os == 'android' && (android_version == '10' || android_version == '18')) || (os == 'b2g')
skip-if = (os == 'android' && debug)
fail-if = (os == 'android')
[generated/test_conformance__misc__shader-precision-format.html]
skip-if = (os == 'android' && android_version == '10')
[generated/test_conformance__misc__type-conversion-test.html]
@ -2816,6 +2817,7 @@ skip-if = (os == 'android')
[generated/test_conformance__more__conformance__quickCheckAPI-B4.html]
[generated/test_conformance__more__conformance__quickCheckAPI-C.html]
[generated/test_conformance__more__conformance__quickCheckAPI-D_G.html]
skip-if = (os == 'android' && debug)
[generated/test_conformance__more__conformance__quickCheckAPI-G_I.html]
[generated/test_conformance__more__conformance__quickCheckAPI-L_S.html]
[generated/test_conformance__more__conformance__quickCheckAPI-S_V.html]
@ -3060,7 +3062,7 @@ skip-if = (os == 'android')
[generated/test_conformance__rendering__gl-viewport-test.html]
[generated/test_conformance__rendering__line-loop-tri-fan.html]
[generated/test_conformance__rendering__many-draw-calls.html]
skip-if = (os == 'android')
skip-if = (os == 'android') || debug
[generated/test_conformance__rendering__more-than-65536-indices.html]
[generated/test_conformance__rendering__multisample-corruption.html]
skip-if = (os == 'mac') || (os == 'android')
@ -3141,19 +3143,24 @@ fail-if = 1
[generated/test_conformance__textures__texture-formats-test.html]
[generated/test_conformance__textures__texture-hd-dpi.html]
[generated/test_conformance__textures__texture-mips.html]
skip-if = (os == 'android' && debug)
fail-if = (os == 'android')
[generated/test_conformance__textures__texture-npot-video.html]
skip-if = 1
[generated/test_conformance__textures__texture-npot.html]
fail-if = (os == 'android' && (android_version == '10' || android_version == '18')) || (os == 'b2g')
skip-if = (os == 'android' && debug)
fail-if = (os == 'android')
[generated/test_conformance__textures__texture-size-cube-maps.html]
skip-if = (os == 'android' && debug)
fail-if = (os == 'android')
[generated/test_conformance__textures__texture-size-limit.html]
skip-if = (os == 'android') || (os == 'linux' && asan && e10s)
fail-if = (os == 'linux')
[generated/test_conformance__textures__texture-size.html]
skip-if = (os == 'android' && debug)
fail-if = (os == 'android') || (os == 'mac' && os_version == '10.8') || (os == 'b2g')
[generated/test_conformance__textures__texture-sub-image-cube-maps.html]
skip-if = (os == 'android' && debug)
fail-if = (os == 'android')
[generated/test_conformance__textures__texture-transparent-pixels-initialized.html]
skip-if = 1

View File

@ -118,13 +118,19 @@ fail-if = (os == 'linux')
skip-if = (os == 'android') || (os == 'b2g') || (os == 'linux')
[generated/test_conformance__misc__object-deletion-behaviour.html]
fail-if = (os == 'android' && (android_version == '10' || android_version == '18')) || (os == 'b2g')
fail-if = (os == 'android')
# void mozilla::gl::GLContext::fDetachShader(GLuint, GLuint): Generated unexpected GL_INVALID_VALUE error. (0x0501)
skip-if = (os == 'android' && debug)
[generated/test_conformance__textures__texture-npot.html]
fail-if = (os == 'android' && (android_version == '10' || android_version == '18')) || (os == 'b2g')
fail-if = (os == 'android')
# void mozilla::gl::GLContext::fGenerateMipmap(GLenum): Generated unexpected GL_INVALID_ENUM error. (0x0500)
skip-if = (os == 'android' && debug)
[generated/test_conformance__textures__texture-size.html]
fail-if = (os == 'android') || (os == 'mac' && os_version == '10.8') || (os == 'b2g')
# void mozilla::gl::GLContext::fGenerateMipmap(GLenum): Generated unexpected GL_INVALID_ENUM error. (0x0500)
skip-if = (os == 'android' && debug)
########################################################################
# "tst-linux{32,64}-spot-NNN" Slaves:
@ -186,8 +192,12 @@ fail-if = (os == 'android')
fail-if = (os == 'android')
[generated/test_conformance__textures__texture-mips.html]
fail-if = (os == 'android')
# void mozilla::gl::GLContext::fGenerateMipmap(GLenum): Generated unexpected GL_INVALID_ENUM error. (0x0500)
skip-if = (os == 'android' && debug)
[generated/test_conformance__textures__texture-size-cube-maps.html]
fail-if = (os == 'android')
# void mozilla::gl::GLContext::fGenerateMipmap(GLenum): Generated unexpected GL_INVALID_ENUM error. (0x0500)
skip-if = (os == 'android' && debug)
[generated/test_conformance__textures__tex-image-and-sub-image-2d-with-video-rgb565.html]
fail-if = (os == 'android')
[generated/test_conformance__textures__tex-image-and-sub-image-2d-with-video-rgba4444.html]
@ -199,6 +209,8 @@ fail-if = (os == 'android')
[generated/test_conformance__textures__texture-sub-image-cube-maps.html]
fail-if = (os == 'android')
# void mozilla::gl::GLContext::fGenerateMipmap(GLenum): Generated unexpected GL_INVALID_ENUM error. (0x0500)
skip-if = (os == 'android' && debug)
[generated/test_conformance__canvas__buffer-offscreen-test.html]
# Causes frequent *blues*: "DMError: Remote Device Error: unable to
@ -243,8 +255,9 @@ skip-if = (os == 'android')
# Crashes
skip-if = (os == 'android')
[generated/test_conformance__rendering__many-draw-calls.html]
# Crashes
skip-if = (os == 'android')
# Crashes on Android
# Times-out on DEBUG builds
skip-if = (os == 'android') || debug
[generated/test_conformance__textures__tex-image-webgl.html]
# Crashes
skip-if = (os == 'android')
@ -269,6 +282,9 @@ skip-if = (os == 'android')
[generated/test_conformance__glsl__bugs__array-of-struct-with-int-first-position.html]
# Crashes
skip-if = (os == 'android')
[generated/test_conformance__more__conformance__quickCheckAPI-D_G.html]
# void mozilla::gl::GLContext::fGenerateMipmap(GLenum): Generated unexpected GL_INVALID_ENUM error. (0x0500)
skip-if = (os == 'android' && debug)
####################
# 2.3 failures

View File

@ -6,6 +6,7 @@
#include "ContentEventHandler.h"
#include "mozilla/IMEStateManager.h"
#include "mozilla/TextComposition.h"
#include "mozilla/TextEvents.h"
#include "mozilla/dom/Element.h"
#include "mozilla/dom/HTMLUnknownElement.h"
@ -274,6 +275,11 @@ ContentEventHandler::Init(WidgetQueryContentEvent* aEvent)
MOZ_ASSERT(aEvent->mMessage == eQuerySelectedText ||
aEvent->mInput.mSelectionType == SelectionType::eNormal);
if (NS_WARN_IF(!aEvent->mInput.IsValidOffset()) ||
NS_WARN_IF(!aEvent->mInput.IsValidEventMessage(aEvent->mMessage))) {
return NS_ERROR_FAILURE;
}
// Note that we should ignore WidgetQueryContentEvent::Input::mSelectionType
// if the event isn't eQuerySelectedText.
SelectionType selectionType =
@ -286,6 +292,33 @@ ContentEventHandler::Init(WidgetQueryContentEvent* aEvent)
nsresult rv = InitCommon(selectionType);
NS_ENSURE_SUCCESS(rv, rv);
// Be aware, WidgetQueryContentEvent::mInput::mOffset should be made absolute
// offset before sending it to ContentEventHandler because querying selection
// every time may be expensive. So, if the caller caches selection, it
// should initialize the event with the cached value.
if (aEvent->mInput.mRelativeToInsertionPoint) {
MOZ_ASSERT(selectionType == SelectionType::eNormal);
RefPtr<TextComposition> composition =
IMEStateManager::GetTextCompositionFor(aEvent->mWidget);
if (composition) {
uint32_t compositionStart = composition->NativeOffsetOfStartComposition();
if (NS_WARN_IF(!aEvent->mInput.MakeOffsetAbsolute(compositionStart))) {
return NS_ERROR_FAILURE;
}
} else {
LineBreakType lineBreakType = GetLineBreakType(aEvent);
uint32_t selectionStart = 0;
rv = GetFlatTextLengthBefore(mFirstSelectedRange,
&selectionStart, lineBreakType);
if (NS_WARN_IF(NS_FAILED(rv))) {
return NS_ERROR_FAILURE;
}
if (NS_WARN_IF(!aEvent->mInput.MakeOffsetAbsolute(selectionStart))) {
return NS_ERROR_FAILURE;
}
}
}
aEvent->mSucceeded = false;
aEvent->mReply.mContentsRoot = mRootContent.get();
@ -1702,7 +1735,8 @@ ContentEventHandler::OnQueryCharacterAtPoint(WidgetQueryContentEvent* aEvent)
}
WidgetQueryContentEvent textRect(true, eQueryTextRect, aEvent->mWidget);
textRect.InitForQueryTextRect(offset, 1, aEvent->mUseNativeLineBreak);
WidgetQueryContentEvent::Options options(*aEvent);
textRect.InitForQueryTextRect(offset, 1, options);
rv = OnQueryTextRect(&textRect);
NS_ENSURE_SUCCESS(rv, rv);
NS_ENSURE_TRUE(textRect.mSucceeded, NS_ERROR_FAILURE);

View File

@ -100,7 +100,7 @@ inline EventListenerFlags TrustedEventsAtCapture()
return flags;
}
inline EventListenerFlags AllEventsAtBubbe()
inline EventListenerFlags AllEventsAtBubble()
{
EventListenerFlags flags;
flags.mAllowUntrustedEvents = true;

View File

@ -708,9 +708,12 @@ IMEContentObserver::HandleQueryContentEvent(WidgetQueryContentEvent* aEvent)
// value. Note that don't update selection cache here since if you update
// selection cache here, IMENotificationSender won't notify IME of selection
// change because it looks like that the selection isn't actually changed.
if (aEvent->mMessage == eQuerySelectedText && aEvent->mUseNativeLineBreak &&
aEvent->mInput.mSelectionType == SelectionType::eNormal &&
mSelectionData.IsValid() && !mNeedsToNotifyIMEOfSelectionChange) {
bool isSelectionCacheAvailable =
aEvent->mUseNativeLineBreak && mSelectionData.IsValid() &&
!mNeedsToNotifyIMEOfSelectionChange;
if (isSelectionCacheAvailable &&
aEvent->mMessage == eQuerySelectedText &&
aEvent->mInput.mSelectionType == SelectionType::eNormal) {
aEvent->mReply.mContentsRoot = mRootContent;
aEvent->mReply.mHasSelection = !mSelectionData.IsCollapsed();
aEvent->mReply.mOffset = mSelectionData.mOffset;
@ -728,6 +731,32 @@ IMEContentObserver::HandleQueryContentEvent(WidgetQueryContentEvent* aEvent)
("IMECO: 0x%p IMEContentObserver::HandleQueryContentEvent(aEvent={ "
"mMessage=%s })", this, ToChar(aEvent->mMessage)));
// If we can make the event's input offset absolute with TextComposition or
// mSelection, we should set it here for reducing the cost of computing
// selection start offset. If ContentEventHandler receives a
// WidgetQueryContentEvent whose input offset is relative to insertion point,
// it computes current selection start offset (this may be expensive) and
// make the offset absolute value itself.
// Note that calling MakeOffsetAbsolute() makes the event a query event with
// absolute offset. So, ContentEventHandler doesn't pay any additional cost
// after calling MakeOffsetAbsolute() here.
if (aEvent->mInput.mRelativeToInsertionPoint &&
aEvent->mInput.IsValidEventMessage(aEvent->mMessage)) {
RefPtr<TextComposition> composition =
IMEStateManager::GetTextCompositionFor(aEvent->mWidget);
if (composition) {
uint32_t compositionStart = composition->NativeOffsetOfStartComposition();
if (NS_WARN_IF(!aEvent->mInput.MakeOffsetAbsolute(compositionStart))) {
return NS_ERROR_FAILURE;
}
} else if (isSelectionCacheAvailable) {
uint32_t selectionStart = mSelectionData.mOffset;
if (NS_WARN_IF(!aEvent->mInput.MakeOffsetAbsolute(selectionStart))) {
return NS_ERROR_FAILURE;
}
}
}
AutoRestore<bool> handling(mIsHandlingQueryContentEvent);
mIsHandlingQueryContentEvent = true;
ContentEventHandler handler(GetPresContext());

View File

@ -21,7 +21,6 @@
#include "nsIPipe.h"
#include "nsContentPolicyUtils.h"
#include "nsCORSListenerProxy.h"
#include "nsDataHandler.h"
#include "nsHostObjectProtocolHandler.h"
#include "nsNetUtil.h"

View File

@ -112,12 +112,15 @@
#include <limits>
#include "nsIColorPicker.h"
#include "nsIDatePicker.h"
#include "nsIStringEnumerator.h"
#include "HTMLSplitOnSpacesTokenizer.h"
#include "nsIController.h"
#include "nsIMIMEInfo.h"
#include "nsFrameSelection.h"
#include "nsIConsoleService.h"
// input type=date
#include "js/Date.h"
@ -938,6 +941,13 @@ GetDOMFileOrDirectoryPath(const OwningFileOrDirectory& aData,
} // namespace
/* static */
bool
HTMLInputElement::ValueAsDateEnabled(JSContext* cx, JSObject* obj)
{
return Preferences::GetBool("dom.experimental_forms", false) ||
Preferences::GetBool("dom.forms.datepicker", false);
}
NS_IMETHODIMP
HTMLInputElement::nsFilePickerShownCallback::Done(int16_t aResult)
@ -1141,6 +1151,59 @@ nsColorPickerShownCallback::Done(const nsAString& aColor)
NS_IMPL_ISUPPORTS(nsColorPickerShownCallback, nsIColorPickerShownCallback)
class DatePickerShownCallback final : public nsIDatePickerShownCallback
{
~DatePickerShownCallback() {}
public:
DatePickerShownCallback(HTMLInputElement* aInput,
nsIDatePicker* aDatePicker)
: mInput(aInput)
, mDatePicker(aDatePicker)
{}
NS_DECL_ISUPPORTS
NS_IMETHOD Done(const nsAString& aDate) override;
NS_IMETHOD Cancel() override;
private:
RefPtr<HTMLInputElement> mInput;
nsCOMPtr<nsIDatePicker> mDatePicker;
};
NS_IMETHODIMP
DatePickerShownCallback::Cancel()
{
mInput->PickerClosed();
return NS_OK;
}
NS_IMETHODIMP
DatePickerShownCallback::Done(const nsAString& aDate)
{
nsAutoString oldValue;
mInput->PickerClosed();
mInput->GetValue(oldValue);
if(!oldValue.Equals(aDate)){
mInput->SetValue(aDate);
nsContentUtils::DispatchTrustedEvent(mInput->OwnerDoc(),
static_cast<nsIDOMHTMLInputElement*>(mInput.get()),
NS_LITERAL_STRING("input"), true,
false);
return nsContentUtils::DispatchTrustedEvent(mInput->OwnerDoc(),
static_cast<nsIDOMHTMLInputElement*>(mInput.get()),
NS_LITERAL_STRING("change"), true,
false);
}
return NS_OK;
}
NS_IMPL_ISUPPORTS(DatePickerShownCallback, nsIDatePickerShownCallback)
bool
HTMLInputElement::IsPopupBlocked() const
{
@ -1165,6 +1228,56 @@ HTMLInputElement::IsPopupBlocked() const
return permission == nsIPopupWindowManager::DENY_POPUP;
}
nsresult
HTMLInputElement::InitDatePicker()
{
if (!Preferences::GetBool("dom.forms.datepicker", false)) {
return NS_OK;
}
if (mPickerRunning) {
NS_WARNING("Just one nsIDatePicker is allowed");
return NS_ERROR_FAILURE;
}
nsCOMPtr<nsIDocument> doc = OwnerDoc();
nsCOMPtr<nsPIDOMWindowOuter> win = doc->GetWindow();
if (!win) {
return NS_ERROR_FAILURE;
}
if (IsPopupBlocked()) {
win->FirePopupBlockedEvent(doc, nullptr, EmptyString(), EmptyString());
return NS_OK;
}
// Get Loc title
nsXPIDLString title;
nsContentUtils::GetLocalizedString(nsContentUtils::eFORMS_PROPERTIES,
"DatePicker", title);
nsresult rv;
nsCOMPtr<nsIDatePicker> datePicker = do_CreateInstance("@mozilla.org/datepicker;1", &rv);
if (!datePicker) {
return rv;
}
nsAutoString initialValue;
GetValueInternal(initialValue);
rv = datePicker->Init(win, title, initialValue);
nsCOMPtr<nsIDatePickerShownCallback> callback =
new DatePickerShownCallback(this, datePicker);
rv = datePicker->Open(callback);
if (NS_SUCCEEDED(rv)) {
mPickerRunning = true;
}
return rv;
}
nsresult
HTMLInputElement::InitColorPicker()
{
@ -2020,7 +2133,8 @@ HTMLInputElement::GetValue(nsAString& aValue)
}
// Don't return non-sanitized value for types that are experimental on mobile.
if (IsExperimentalMobileType(mType)) {
// or date types
if (IsExperimentalMobileType(mType) || mType == NS_FORM_INPUT_DATE) {
SanitizeValue(aValue);
}
@ -2654,6 +2768,15 @@ HTMLInputElement::ApplyStep(int32_t aStep)
return rv;
}
/* static */
bool
HTMLInputElement::IsExperimentalMobileType(uint8_t aType)
{
return aType == NS_FORM_INPUT_TIME ||
(aType == NS_FORM_INPUT_DATE &&
!Preferences::GetBool("dom.forms.datepicker", false));
}
NS_IMETHODIMP
HTMLInputElement::StepDown(int32_t n, uint8_t optional_argc)
{
@ -2843,7 +2966,7 @@ bool
HTMLInputElement::MozIsTextField(bool aExcludePassword)
{
// TODO: temporary until bug 773205 is fixed.
if (IsExperimentalMobileType(mType)) {
if (IsExperimentalMobileType(mType) || mType == NS_FORM_INPUT_DATE) {
return false;
}
@ -3875,7 +3998,7 @@ HTMLInputElement::PreHandleEvent(EventChainPreVisitor& aVisitor)
// Experimental mobile types rely on the system UI to prevent users to not
// set invalid values but we have to be extra-careful. Especially if the
// option has been enabled on desktop.
if (IsExperimentalMobileType(mType)) {
if (IsExperimentalMobileType(mType) || mType == NS_FORM_INPUT_DATE) {
nsAutoString aValue;
GetValueInternal(aValue);
nsresult rv =
@ -4291,6 +4414,10 @@ HTMLInputElement::MaybeInitPickers(EventChainPostVisitor& aVisitor)
if (mType == NS_FORM_INPUT_COLOR) {
return InitColorPicker();
}
if (mType == NS_FORM_INPUT_DATE) {
return InitDatePicker();
}
return NS_OK;
}
@ -4572,7 +4699,8 @@ HTMLInputElement::PostHandleEvent(EventChainPostVisitor& aVisitor)
keyEvent->mKeyCode == NS_VK_RETURN &&
(IsSingleLineTextControl(false, mType) ||
mType == NS_FORM_INPUT_NUMBER ||
IsExperimentalMobileType(mType))) {
IsExperimentalMobileType(mType) ||
mType == NS_FORM_INPUT_DATE)) {
FireChangeEventIfNeeded();
rv = MaybeSubmitForm(aVisitor.mPresContext);
NS_ENSURE_SUCCESS(rv, rv);

View File

@ -270,6 +270,9 @@ public:
static void InitUploadLastDir();
static void DestroyUploadLastDir();
//If the valueAsDate attribute should be enabled in webIDL
static bool ValueAsDateEnabled(JSContext* cx, JSObject* obj);
void MaybeLoadImage();
void SetSelectionProperties(const nsTextEditorState::SelectionProperties& aProps)
@ -1246,10 +1249,7 @@ protected:
/**
* Returns if the current type is an experimental mobile type.
*/
static bool IsExperimentalMobileType(uint8_t aType)
{
return aType == NS_FORM_INPUT_DATE || aType == NS_FORM_INPUT_TIME;
}
static bool IsExperimentalMobileType(uint8_t aType);
/**
* Flushes the layout frame tree to make sure we have up-to-date frames.
@ -1276,6 +1276,7 @@ protected:
};
nsresult InitFilePicker(FilePickerType aType);
nsresult InitColorPicker();
nsresult InitDatePicker();
/**
* Use this function before trying to open a picker.

View File

@ -20,23 +20,31 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=764481
var input = document.createElement("input");
SimpleTest.waitForExplicitFinish();
SpecialPowers.pushPrefEnv({'set': [["dom.experimental_forms", false]]}, function() {
SpecialPowers.pushPrefEnv({'set': [["dom.experimental_forms", false], ["dom.forms.datepicker",false]]}, function() {
input.type = "date";
is(input.type, "text", "input type shouldn't be date when the experimental forms are disabled");
is(input.getAttribute('type'), "date", "input 'type' attribute should not change");
SpecialPowers.pushPrefEnv({'set': [["dom.experimental_forms",true]]}, function() {
// Change the type of input to text and then back to date,
SpecialPowers.pushPrefEnv({'set': [["dom.experimental_forms",true], ["dom.forms.datepicker",false]]}, function() {
// Change the type of input to text and then back to date,
// so that HTMLInputElement::ParseAttribute gets called with the pref enabled.
input.type = "text";
input.type = "date";
is(input.type, "date", "input type should be date when the experimental forms are enabled");
is(input.getAttribute('type'), "date", "input 'type' attribute should not change");
SimpleTest.finish();
SpecialPowers.pushPrefEnv({'set': [["dom.experimental_forms",false], ["dom.forms.datepicker",true]]}, function() {
// Change the type of input to text and then back to date,
// so that HTMLInputElement::ParseAttribute gets called with the pref enabled.
input.type = "text";
input.type = "date";
is(input.type, "date", "input type should be date when the datepicker is enabled");
is(input.getAttribute('type'), "date", "input 'type' attribute should not change");
SimpleTest.finish();
});
});
});
</script>
</pre>
</body>

View File

@ -11,8 +11,14 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=874640
<script type="application/javascript">
/** Test for Bug 874640 **/
var states = [ 'true', 'false', 'end' ];
var pref = SpecialPowers.getBoolPref("dom.experimental_forms");
var states = [
//dom.experimental_forms, dom.forms.datepicker, expectedValueAsDate
[ 'true', 'true', 'true' ],
[ 'true', 'false', 'true' ],
[ 'false', 'true', 'true' ],
[ 'false', 'false', 'false' ],
'end'
];
SimpleTest.waitForExplicitFinish();
@ -24,11 +30,13 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=874640
return;
}
SpecialPowers.pushPrefEnv({"set":[["dom.experimental_forms", state === 'true']]},
SpecialPowers.pushPrefEnv({"set":[
["dom.experimental_forms", state[0] === 'true'],
["dom.forms.datepicker", state[1] === 'true']]},
function() {
iframe.src = 'data:text/html,<script>' +
'parent.is("valueAsDate" in document.createElement("input"), ' +
state + ', "valueAsDate presence state should be ' + state + '");' +
state[2] + ', "valueAsDate presence state should be ' + state[2] + '");' +
'<\/script>'
});
}

View File

@ -1102,6 +1102,15 @@ interface nsIDOMWindowUtils : nsISupports {
const unsigned long QUERY_CONTENT_FLAG_SELECTION_URLSECONDARY = 0x0100;
const unsigned long QUERY_CONTENT_FLAG_SELECTION_URLSTRIKEOUT = 0x0200;
/**
* One of sendQueryContentEvent()'s aAdditionalFlags. If this is specified,
* aOffset is relative to start of selection or composition.
* Note that this is supported only when QUERY_CONTENT_FLAG_USE_XP_LINE_BREAK
* is not specified for now.
*/
const unsigned long QUERY_CONTENT_FLAG_OFFSET_RELATIVE_TO_INSERTION_POINT =
0x0400;
/**
* Synthesize a query content event. Note that the result value returned here
* is in LayoutDevice pixels rather than CSS pixels.
@ -1112,7 +1121,7 @@ interface nsIDOMWindowUtils : nsISupports {
*/
nsIQueryContentEventResult sendQueryContentEvent(
in unsigned long aType,
in unsigned long aOffset,
in long long aOffset,
in unsigned long aLength,
in long aX,
in long aY,

View File

@ -0,0 +1,87 @@
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "DatePickerParent.h"
#include "nsComponentManagerUtils.h"
#include "nsIDocument.h"
#include "nsIDOMWindow.h"
#include "mozilla/unused.h"
#include "mozilla/dom/Element.h"
#include "mozilla/dom/TabParent.h"
using mozilla::Unused;
using namespace mozilla::dom;
NS_IMPL_ISUPPORTS(DatePickerParent::DatePickerShownCallback,
nsIDatePickerShownCallback);
NS_IMETHODIMP
DatePickerParent::DatePickerShownCallback::Cancel()
{
if (mDatePickerParent) {
Unused << mDatePickerParent->SendCancel();
}
return NS_OK;
}
NS_IMETHODIMP
DatePickerParent::DatePickerShownCallback::Done(const nsAString& aDate)
{
if (mDatePickerParent) {
Unused << mDatePickerParent->Send__delete__(mDatePickerParent,
nsString(aDate));
}
return NS_OK;
}
void
DatePickerParent::DatePickerShownCallback::Destroy()
{
mDatePickerParent = nullptr;
}
bool
DatePickerParent::CreateDatePicker()
{
mPicker = do_CreateInstance("@mozilla.org/datepicker;1");
if (!mPicker) {
return false;
}
Element* ownerElement = TabParent::GetFrom(Manager())->GetOwnerElement();
if (!ownerElement) {
return false;
}
nsCOMPtr<mozIDOMWindowProxy> window = do_QueryInterface(ownerElement->OwnerDoc()->GetWindow());
if (!window) {
return false;
}
return NS_SUCCEEDED(mPicker->Init(window, mTitle, mInitialDate));
}
bool
DatePickerParent::RecvOpen()
{
if (!CreateDatePicker()) {
Unused << Send__delete__(this, mInitialDate);
return true;
}
mCallback = new DatePickerShownCallback(this);
mPicker->Open(mCallback);
return true;
};
void
DatePickerParent::ActorDestroy(ActorDestroyReason aWhy)
{
if (mCallback) {
mCallback->Destroy();
}
}

View File

@ -0,0 +1,61 @@
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef mozilla_dom_DatePickerParent_h
#define mozilla_dom_DatePickerParent_h
#include "mozilla/dom/PDatePickerParent.h"
#include "nsIDatePicker.h"
namespace mozilla {
namespace dom {
class DatePickerParent : public PDatePickerParent
{
public:
DatePickerParent(const nsString& aTitle,
const nsString& aInitialDate)
: mTitle(aTitle)
, mInitialDate(aInitialDate)
{}
virtual bool RecvOpen() override;
virtual void ActorDestroy(ActorDestroyReason aWhy) override;
class DatePickerShownCallback final
: public nsIDatePickerShownCallback
{
public:
explicit DatePickerShownCallback(DatePickerParent* aDatePickerParnet)
: mDatePickerParent(aDatePickerParnet)
{}
NS_DECL_ISUPPORTS
NS_DECL_NSIDATEPICKERSHOWNCALLBACK
void Destroy();
private:
~DatePickerShownCallback() {}
DatePickerParent* mDatePickerParent;
};
private:
virtual ~DatePickerParent() {}
bool CreateDatePicker();
RefPtr<DatePickerShownCallback> mCallback;
nsCOMPtr<nsIDatePicker> mPicker;
nsString mTitle;
nsString mInitialDate;
};
} // namespace dom
} // namespace mozilla
#endif // mozilla_dom_DatePickerParent_h

View File

@ -9,6 +9,7 @@ include protocol PBlob;
include protocol PColorPicker;
include protocol PContent;
include protocol PContentBridge;
include protocol PDatePicker;
include protocol PDocAccessible;
include protocol PDocumentRenderer;
include protocol PFilePicker;
@ -111,6 +112,7 @@ prio(normal upto urgent) sync protocol PBrowser
manager PContent or PContentBridge;
manages PColorPicker;
manages PDatePicker;
manages PDocAccessible;
manages PDocumentRenderer;
manages PFilePicker;
@ -420,6 +422,12 @@ parent:
*/
async PColorPicker(nsString title, nsString initialColor);
/**
* Create an asynchronous date picker on the parent side,
* but don't open it yet.
*/
async PDatePicker(nsString title, nsString initialDate);
async PFilePicker(nsString aTitle, int16_t aMode);
/**

27
dom/ipc/PDatePicker.ipdl Normal file
View File

@ -0,0 +1,27 @@
/* -*- Mode: C++; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 8 -*- */
/* vim: set sw=4 ts=8 et tw=80 ft=cpp : */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
include protocol PBrowser;
namespace mozilla {
namespace dom {
protocol PDatePicker
{
manager PBrowser;
parent:
async Open();
child:
async Cancel();
async __delete__(nsString color);
};
} // namespace dom
} // namespace mozilla

View File

@ -102,6 +102,7 @@
#include "nsIOService.h"
#include "nsDOMClassInfoID.h"
#include "nsColorPickerProxy.h"
#include "nsDatePickerProxy.h"
#include "nsContentPermissionHelper.h"
#include "nsPresShell.h"
#include "nsIAppsService.h"
@ -2284,6 +2285,21 @@ TabChild::DeallocPColorPickerChild(PColorPickerChild* aColorPicker)
return true;
}
PDatePickerChild*
TabChild::AllocPDatePickerChild(const nsString&, const nsString&)
{
NS_RUNTIMEABORT("unused");
return nullptr;
}
bool
TabChild::DeallocPDatePickerChild(PDatePickerChild* aDatePicker)
{
nsDatePickerProxy* picker = static_cast<nsDatePickerProxy*>(aDatePicker);
NS_RELEASE(picker);
return true;
}
PFilePickerChild*
TabChild::AllocPFilePickerChild(const nsString&, const int16_t&)
{

View File

@ -453,6 +453,10 @@ public:
virtual bool DeallocPColorPickerChild(PColorPickerChild* aActor) override;
virtual PDatePickerChild*
AllocPDatePickerChild(const nsString& title, const nsString& initialDate) override;
virtual bool DeallocPDatePickerChild(PDatePickerChild* actor) override;
virtual PFilePickerChild*
AllocPFilePickerChild(const nsString& aTitle, const int16_t& aMode) override;

View File

@ -80,6 +80,7 @@
#include "PermissionMessageUtils.h"
#include "StructuredCloneData.h"
#include "ColorPickerParent.h"
#include "DatePickerParent.h"
#include "FilePickerParent.h"
#include "TabChild.h"
#include "LoadContext.h"
@ -2587,6 +2588,20 @@ TabParent::DeallocPColorPickerParent(PColorPickerParent* actor)
return true;
}
PDatePickerParent*
TabParent::AllocPDatePickerParent(const nsString& aTitle,
const nsString& aInitialDate)
{
return new DatePickerParent(aTitle, aInitialDate);
}
bool
TabParent::DeallocPDatePickerParent(PDatePickerParent* actor)
{
delete actor;
return true;
}
PRenderFrameParent*
TabParent::AllocPRenderFrameParent()
{

View File

@ -379,6 +379,10 @@ public:
virtual bool
DeallocPColorPickerParent(PColorPickerParent* aColorPicker) override;
virtual PDatePickerParent*
AllocPDatePickerParent(const nsString& aTitle, const nsString& aInitialDate) override;
virtual bool DeallocPDatePickerParent(PDatePickerParent* aDatePicker) override;
virtual PDocAccessibleParent*
AllocPDocAccessibleParent(PDocAccessibleParent*, const uint64_t&) override;

View File

@ -61,6 +61,7 @@ UNIFIED_SOURCES += [
'ContentProcess.cpp',
'ContentProcessManager.cpp',
'CrashReporterParent.cpp',
'DatePickerParent.cpp',
'FilePickerParent.cpp',
'nsIContentChild.cpp',
'nsIContentParent.cpp',
@ -102,6 +103,7 @@ IPDL_SOURCES += [
'PContentPermissionRequest.ipdl',
'PCrashReporter.ipdl',
'PCycleCollectWithLogs.ipdl',
'PDatePicker.ipdl',
'PDocumentRenderer.ipdl',
'PFilePicker.ipdl',
'PMemoryReportRequest.ipdl',

View File

@ -22,6 +22,8 @@ LowMemoryTitle=Warning: Low memory
LowMemoryMessage=A script on this page has been stopped due to a low memory condition.
SpeculationFailed=An unbalanced tree was written using document.write() causing data from the network to be reparsed. For more information https://developer.mozilla.org/en/Optimizing_Your_Pages_for_Speculative_Parsing
DocumentWriteIgnored=A call to document.write() from an asynchronously-loaded external script was ignored.
# LOCALIZATION NOTE (EditorFileDropFailed): Do not translate contenteditable, %S is the error message explaining why the drop failed.
EditorFileDropFailed=Dropping a file into a contenteditable element failed: %S.
FormValidationTextTooLong=Please shorten this text to %S characters or less (you are currently using %S characters).
FormValidationValueMissing=Please fill out this field.
FormValidationCheckboxMissing=Please check this box if you want to proceed.

View File

@ -30,6 +30,7 @@ NoFilesSelected=No files selected.
# %S will be a number greater or equal to 2.
XFilesSelected=%S files selected.
ColorPicker=Choose a color
DatePicker=Choose a date
# LOCALIZATION NOTE (AndNMoreFiles): Semi-colon list of plural forms.
# See: http://developer.mozilla.org/en/docs/Localization_and_Plurals
# This string is shown at the end of the tooltip text for <input type='file'

View File

@ -17,6 +17,7 @@
#include "nsITimer.h"
#include "nsIWeakReference.h"
#include "nsPluginHost.h"
#include "VideoUtils.h"
static mozilla::LazyLogModule sDecoderDoctorLog("DecoderDoctor");
#define DD_LOG(level, arg, ...) MOZ_LOG(sDecoderDoctorLog, level, (arg, ##__VA_ARGS__))
@ -24,8 +25,13 @@ static mozilla::LazyLogModule sDecoderDoctorLog("DecoderDoctor");
#define DD_INFO(arg, ...) DD_LOG(mozilla::LogLevel::Info, arg, ##__VA_ARGS__)
#define DD_WARN(arg, ...) DD_LOG(mozilla::LogLevel::Warning, arg, ##__VA_ARGS__)
namespace mozilla
namespace mozilla {
struct NotificationAndReportStringId
{
dom::DecoderDoctorNotificationType mNotificationType;
const char* mReportStringId;
};
// Class that collects a sequence of diagnostics from the same document over a
// small period of time, in order to provide a synthesized analysis.
@ -68,8 +74,8 @@ private:
static const uint32_t sAnalysisPeriod_ms = 1000;
void EnsureTimerIsStarted();
void ReportAnalysis(dom::DecoderDoctorNotificationType aNotificationType,
const char* aReportStringId,
void ReportAnalysis(const NotificationAndReportStringId& aNotification,
bool aIsSolved,
const nsAString& aFormats);
void SynthesizeAnalysis();
@ -237,16 +243,46 @@ DecoderDoctorDocumentWatcher::EnsureTimerIsStarted()
}
}
static const NotificationAndReportStringId sMediaWidevineNoWMFNoSilverlight =
{ dom::DecoderDoctorNotificationType::Platform_decoder_not_found,
"MediaWidevineNoWMFNoSilverlight" };
static const NotificationAndReportStringId sMediaWMFNeeded =
{ dom::DecoderDoctorNotificationType::Platform_decoder_not_found,
"MediaWMFNeeded" };
static const NotificationAndReportStringId sMediaPlatformDecoderNotFound =
{ dom::DecoderDoctorNotificationType::Platform_decoder_not_found,
"MediaPlatformDecoderNotFound" };
static const NotificationAndReportStringId sMediaCannotPlayNoDecoders =
{ dom::DecoderDoctorNotificationType::Cannot_play,
"MediaCannotPlayNoDecoders" };
static const NotificationAndReportStringId sMediaNoDecoders =
{ dom::DecoderDoctorNotificationType::Can_play_but_some_missing_decoders,
"MediaNoDecoders" };
static const NotificationAndReportStringId*
sAllNotificationsAndReportStringIds[] =
{
&sMediaWidevineNoWMFNoSilverlight,
&sMediaWMFNeeded,
&sMediaPlatformDecoderNotFound,
&sMediaCannotPlayNoDecoders,
&sMediaNoDecoders
};
static void
DispatchNotification(nsISupports* aSubject,
dom::DecoderDoctorNotificationType aNotificationType,
const NotificationAndReportStringId& aNotification,
bool aIsSolved,
const nsAString& aFormats)
{
if (!aSubject) {
return;
}
dom::DecoderDoctorNotification data;
data.mType = aNotificationType;
data.mType = aNotification.mNotificationType;
data.mIsSolved = aIsSolved;
data.mDecoderDoctorReportId.Assign(
NS_ConvertUTF8toUTF16(aNotification.mReportStringId));
if (!aFormats.IsEmpty()) {
data.mFormats.Construct(aFormats);
}
@ -267,8 +303,8 @@ DispatchNotification(nsISupports* aSubject,
void
DecoderDoctorDocumentWatcher::ReportAnalysis(
dom::DecoderDoctorNotificationType aNotificationType,
const char* aReportStringId,
const NotificationAndReportStringId& aNotification,
bool aIsSolved,
const nsAString& aParams)
{
MOZ_ASSERT(NS_IsMainThread());
@ -277,18 +313,21 @@ DecoderDoctorDocumentWatcher::ReportAnalysis(
return;
}
// 'params' will only be forwarded for non-empty strings.
const char16_t* params[1] = { aParams.Data() };
DD_DEBUG("DecoderDoctorDocumentWatcher[%p, doc=%p]::ReportAnalysis() ReportToConsole - aMsg='%s' params[0]='%s'",
this, mDocument, aReportStringId,
aParams.IsEmpty() ? "<no params>" : NS_ConvertUTF16toUTF8(params[0]).get());
nsContentUtils::ReportToConsole(nsIScriptError::warningFlag,
NS_LITERAL_CSTRING("Media"),
mDocument,
nsContentUtils::eDOM_PROPERTIES,
aReportStringId,
aParams.IsEmpty() ? nullptr : params,
aParams.IsEmpty() ? 0 : 1);
// Report non-solved issues to console.
if (!aIsSolved) {
// 'params' will only be forwarded for non-empty strings.
const char16_t* params[1] = { aParams.Data() };
DD_DEBUG("DecoderDoctorDocumentWatcher[%p, doc=%p]::ReportAnalysis() ReportToConsole - aMsg='%s' params[0]='%s'",
this, mDocument, aNotification.mReportStringId,
aParams.IsEmpty() ? "<no params>" : NS_ConvertUTF16toUTF8(params[0]).get());
nsContentUtils::ReportToConsole(nsIScriptError::warningFlag,
NS_LITERAL_CSTRING("Media"),
mDocument,
nsContentUtils::eDOM_PROPERTIES,
aNotification.mReportStringId,
aParams.IsEmpty() ? nullptr : params,
aParams.IsEmpty() ? 0 : 1);
}
// "media.decoder-doctor.notifications-allowed" controls which notifications
// may be dispatched to the front-end. It either contains:
@ -299,24 +338,10 @@ DecoderDoctorDocumentWatcher::ReportAnalysis(
nsAdoptingCString filter =
Preferences::GetCString("media.decoder-doctor.notifications-allowed");
filter.StripWhitespace();
bool allowed = false;
if (!filter || filter.IsEmpty()) {
// Allow nothing.
} else if (filter.EqualsLiteral("*")) {
allowed = true;
} else for (uint32_t start = 0; start < filter.Length(); ) {
int32_t comma = filter.FindChar(',', start);
uint32_t end = (comma >= 0) ? uint32_t(comma) : filter.Length();
if (strncmp(aReportStringId, filter.Data() + start, end - start) == 0) {
allowed = true;
break;
}
// Skip comma. End of line will be caught in for 'while' clause.
start = end + 1;
}
if (allowed) {
if (filter.EqualsLiteral("*")
|| StringListContains(filter, aNotification.mReportStringId)) {
DispatchNotification(
mDocument->GetInnerWindow(), aNotificationType, aParams);
mDocument->GetInnerWindow(), aNotification, aIsSolved, aParams);
}
}
@ -347,12 +372,31 @@ CheckSilverlight()
return eNoSilverlight;
}
static void AppendToStringList(nsAString& list, const nsAString& item)
static nsString
CleanItemForFormatsList(const nsAString& aItem)
{
if (!list.IsEmpty()) {
list += NS_LITERAL_STRING(", ");
nsString item(aItem);
// Remove commas from item, as commas are used to separate items. It's fine
// to have a one-way mapping, it's only used for comparisons and in
// console display (where formats shouldn't contain commas in the first place)
item.ReplaceChar(',', ' ');
item.CompressWhitespace();
return item;
}
static void
AppendToFormatsList(nsAString& aList, const nsAString& aItem)
{
if (!aList.IsEmpty()) {
aList += NS_LITERAL_STRING(", ");
}
list += item;
aList += CleanItemForFormatsList(aItem);
}
static bool
FormatsListContains(const nsAString& aList, const nsAString& aItem)
{
return StringListContains(aList, CleanItemForFormatsList(aItem));
}
void
@ -360,115 +404,169 @@ DecoderDoctorDocumentWatcher::SynthesizeAnalysis()
{
MOZ_ASSERT(NS_IsMainThread());
bool canPlay = false;
#if defined(XP_WIN)
bool WMFNeeded = false;
#endif
#if defined(MOZ_FFMPEG)
bool FFMpegNeeded = false;
#endif
nsAutoString playableFormats;
nsAutoString unplayableFormats;
// Subsets of unplayableFormats that require a specific platform decoder:
#if defined(XP_WIN)
nsAutoString formatsRequiringWMF;
#endif
#if defined(MOZ_FFMPEG)
nsAutoString formatsRequiringFFMpeg;
#endif
nsAutoString supportedKeySystems;
nsAutoString unsupportedKeySystems;
DecoderDoctorDiagnostics::KeySystemIssue lastKeySystemIssue =
DecoderDoctorDiagnostics::eUnset;
for (auto& diag : mDiagnosticsSequence) {
for (const auto& diag : mDiagnosticsSequence) {
switch (diag.mDecoderDoctorDiagnostics.Type()) {
case DecoderDoctorDiagnostics::eFormatSupportCheck:
if (diag.mDecoderDoctorDiagnostics.CanPlay()) {
canPlay = true;
AppendToStringList(playableFormats,
diag.mDecoderDoctorDiagnostics.Format());
} else {
case DecoderDoctorDiagnostics::eFormatSupportCheck:
if (diag.mDecoderDoctorDiagnostics.CanPlay()) {
AppendToFormatsList(playableFormats,
diag.mDecoderDoctorDiagnostics.Format());
} else {
AppendToFormatsList(unplayableFormats,
diag.mDecoderDoctorDiagnostics.Format());
#if defined(XP_WIN)
if (diag.mDecoderDoctorDiagnostics.DidWMFFailToLoad()) {
WMFNeeded = true;
}
if (diag.mDecoderDoctorDiagnostics.DidWMFFailToLoad()) {
AppendToFormatsList(formatsRequiringWMF,
diag.mDecoderDoctorDiagnostics.Format());
}
#endif
#if defined(MOZ_FFMPEG)
if (diag.mDecoderDoctorDiagnostics.DidFFmpegFailToLoad()) {
FFMpegNeeded = true;
}
if (diag.mDecoderDoctorDiagnostics.DidFFmpegFailToLoad()) {
AppendToFormatsList(formatsRequiringFFMpeg,
diag.mDecoderDoctorDiagnostics.Format());
}
#endif
AppendToStringList(unplayableFormats,
diag.mDecoderDoctorDiagnostics.Format());
}
break;
case DecoderDoctorDiagnostics::eMediaKeySystemAccessRequest:
if (diag.mDecoderDoctorDiagnostics.IsKeySystemSupported()) {
AppendToStringList(supportedKeySystems,
diag.mDecoderDoctorDiagnostics.KeySystem());
} else {
AppendToStringList(unsupportedKeySystems,
diag.mDecoderDoctorDiagnostics.KeySystem());
DecoderDoctorDiagnostics::KeySystemIssue issue =
diag.mDecoderDoctorDiagnostics.GetKeySystemIssue();
if (issue != DecoderDoctorDiagnostics::eUnset) {
lastKeySystemIssue = issue;
}
}
break;
default:
MOZ_ASSERT(diag.mDecoderDoctorDiagnostics.Type()
== DecoderDoctorDiagnostics::eFormatSupportCheck
|| diag.mDecoderDoctorDiagnostics.Type()
== DecoderDoctorDiagnostics::eMediaKeySystemAccessRequest);
break;
break;
case DecoderDoctorDiagnostics::eMediaKeySystemAccessRequest:
if (diag.mDecoderDoctorDiagnostics.IsKeySystemSupported()) {
AppendToFormatsList(supportedKeySystems,
diag.mDecoderDoctorDiagnostics.KeySystem());
} else {
AppendToFormatsList(unsupportedKeySystems,
diag.mDecoderDoctorDiagnostics.KeySystem());
DecoderDoctorDiagnostics::KeySystemIssue issue =
diag.mDecoderDoctorDiagnostics.GetKeySystemIssue();
if (issue != DecoderDoctorDiagnostics::eUnset) {
lastKeySystemIssue = issue;
}
}
break;
default:
MOZ_ASSERT(diag.mDecoderDoctorDiagnostics.Type()
== DecoderDoctorDiagnostics::eFormatSupportCheck
|| diag.mDecoderDoctorDiagnostics.Type()
== DecoderDoctorDiagnostics::eMediaKeySystemAccessRequest);
break;
}
}
// Look at Key System issues first, as they may influence format checks.
// Check if issues have been solved, by finding if some now-playable
// key systems or formats were previously recorded as having issues.
if (!supportedKeySystems.IsEmpty() || !playableFormats.IsEmpty()) {
DD_DEBUG("DecoderDoctorDocumentWatcher[%p, doc=%p]::SynthesizeAnalysis() - supported key systems '%s', playable formats '%s'; See if they show issues have been solved...",
this, mDocument,
NS_ConvertUTF16toUTF8(supportedKeySystems).Data(),
NS_ConvertUTF16toUTF8(playableFormats).get());
const nsAString* workingFormatsArray[] =
{ &supportedKeySystems, &playableFormats };
// For each type of notification, retrieve the pref that contains formats/
// key systems with issues.
for (const NotificationAndReportStringId* id :
sAllNotificationsAndReportStringIds) {
nsAutoCString formatsPref("media.decoder-doctor.");
formatsPref += id->mReportStringId;
formatsPref += ".formats";
nsAdoptingString formatsWithIssues =
Preferences::GetString(formatsPref.Data());
if (formatsWithIssues.IsEmpty()) {
continue;
}
// See if that list of formats-with-issues contains any formats that are
// now playable/supported.
bool solved = false;
for (const nsAString* workingFormats : workingFormatsArray) {
for (const auto& workingFormat : MakeStringListRange(*workingFormats)) {
if (FormatsListContains(formatsWithIssues, workingFormat)) {
// This now-working format used not to work -> Report solved issue.
DD_INFO("DecoderDoctorDocumentWatcher[%p, doc=%p]::SynthesizeAnalysis() - %s solved ('%s' now works, it was in pref(%s)='%s')",
this, mDocument, id->mReportStringId,
NS_ConvertUTF16toUTF8(workingFormat).get(),
formatsPref.Data(),
NS_ConvertUTF16toUTF8(formatsWithIssues).get());
ReportAnalysis(*id, true, workingFormat);
// This particular Notification&ReportId has been solved, no need
// to keep looking at other keysys/formats that might solve it too.
solved = true;
break;
}
}
if (solved) {
break;
}
}
if (!solved) {
DD_DEBUG("DecoderDoctorDocumentWatcher[%p, doc=%p]::SynthesizeAnalysis() - %s not solved (pref(%s)='%s')",
this, mDocument, id->mReportStringId, formatsPref.Data(),
NS_ConvertUTF16toUTF8(formatsWithIssues).get());
}
}
}
// Look at Key System issues first, as they take precedence over format checks.
if (!unsupportedKeySystems.IsEmpty() && supportedKeySystems.IsEmpty()) {
// No supported key systems!
switch (lastKeySystemIssue) {
case DecoderDoctorDiagnostics::eWidevineWithNoWMF:
if (CheckSilverlight() != eSilverlightEnabled) {
DD_DEBUG("DecoderDoctorDocumentWatcher[%p, doc=%p]::SynthesizeAnalysis() - unsupported key systems: %s, widevine without WMF nor Silverlight",
this, mDocument, NS_ConvertUTF16toUTF8(unplayableFormats).get());
ReportAnalysis(dom::DecoderDoctorNotificationType::Platform_decoder_not_found,
"MediaWidevineNoWMFNoSilverlight", NS_LITERAL_STRING(""));
return;
}
break;
default:
break;
case DecoderDoctorDiagnostics::eWidevineWithNoWMF:
if (CheckSilverlight() != eSilverlightEnabled) {
DD_INFO("DecoderDoctorDocumentWatcher[%p, doc=%p]::SynthesizeAnalysis() - unsupported key systems: %s, widevine without WMF nor Silverlight",
this, mDocument, NS_ConvertUTF16toUTF8(unsupportedKeySystems).get());
ReportAnalysis(
sMediaWidevineNoWMFNoSilverlight, false, unsupportedKeySystems);
return;
}
break;
default:
break;
}
}
if (!canPlay && !unplayableFormats.IsEmpty()) {
// Next, check playability of requested formats.
if (!unplayableFormats.IsEmpty()) {
// Some requested formats cannot be played.
if (playableFormats.IsEmpty()) {
// No requested formats can be played. See if we can help the user, by
// going through expected decoders from most to least desirable.
#if defined(XP_WIN)
if (WMFNeeded) {
DD_DEBUG("DecoderDoctorDocumentWatcher[%p, doc=%p]::SynthesizeAnalysis() - formats: %s -> Cannot play media because WMF was not found",
this, mDocument, NS_ConvertUTF16toUTF8(unplayableFormats).get());
ReportAnalysis(dom::DecoderDoctorNotificationType::Platform_decoder_not_found,
"MediaWMFNeeded", unplayableFormats);
return;
}
if (!formatsRequiringWMF.IsEmpty()) {
DD_INFO("DecoderDoctorDocumentWatcher[%p, doc=%p]::SynthesizeAnalysis() - unplayable formats: %s -> Cannot play media because WMF was not found",
this, mDocument, NS_ConvertUTF16toUTF8(formatsRequiringWMF).get());
ReportAnalysis(sMediaWMFNeeded, false, formatsRequiringWMF);
return;
}
#endif
#if defined(MOZ_FFMPEG)
if (FFMpegNeeded) {
DD_DEBUG("DecoderDoctorDocumentWatcher[%p, doc=%p]::SynthesizeAnalysis() - unplayable formats: %s -> Cannot play media because platform decoder was not found",
this, mDocument, NS_ConvertUTF16toUTF8(unplayableFormats).get());
ReportAnalysis(dom::DecoderDoctorNotificationType::Platform_decoder_not_found,
"MediaPlatformDecoderNotFound", unplayableFormats);
if (!formatsRequiringFFMpeg.IsEmpty()) {
DD_INFO("DecoderDoctorDocumentWatcher[%p, doc=%p]::SynthesizeAnalysis() - unplayable formats: %s -> Cannot play media because platform decoder was not found",
this, mDocument, NS_ConvertUTF16toUTF8(formatsRequiringFFMpeg).get());
ReportAnalysis(sMediaPlatformDecoderNotFound,
false, formatsRequiringFFMpeg);
return;
}
#endif
DD_INFO("DecoderDoctorDocumentWatcher[%p, doc=%p]::SynthesizeAnalysis() - Cannot play media, unplayable formats: %s",
this, mDocument, NS_ConvertUTF16toUTF8(unplayableFormats).get());
ReportAnalysis(sMediaCannotPlayNoDecoders, false, unplayableFormats);
return;
}
#endif
DD_WARN("DecoderDoctorDocumentWatcher[%p, doc=%p]::SynthesizeAnalysis() - Cannot play media, unplayable formats: %s",
this, mDocument, NS_ConvertUTF16toUTF8(unplayableFormats).get());
ReportAnalysis(dom::DecoderDoctorNotificationType::Cannot_play,
"MediaCannotPlayNoDecoders", unplayableFormats);
return;
}
if (!unplayableFormats.IsEmpty()) {
DD_INFO("DecoderDoctorDocumentWatcher[%p, doc=%p]::SynthesizeAnalysis() - Can play media, but no decoders for some requested formats: %s",
this, mDocument, NS_ConvertUTF16toUTF8(unplayableFormats).get());
if (Preferences::GetBool("media.decoder-doctor.verbose", false)) {
ReportAnalysis(
dom::DecoderDoctorNotificationType::Can_play_but_some_missing_decoders,
"MediaNoDecoders", unplayableFormats);
ReportAnalysis(sMediaNoDecoders, false, unplayableFormats);
}
return;
}
@ -619,39 +717,39 @@ DecoderDoctorDiagnostics::GetDescription() const
|| mDiagnosticsType == eMediaKeySystemAccessRequest);
nsCString s;
switch (mDiagnosticsType) {
case eUnsaved:
s = "Unsaved diagnostics, cannot get accurate description";
break;
case eFormatSupportCheck:
s = "format='";
s += NS_ConvertUTF16toUTF8(mFormat).get();
s += mCanPlay ? "', can play" : "', cannot play";
if (mWMFFailedToLoad) {
s += ", Windows platform decoder failed to load";
}
if (mFFmpegFailedToLoad) {
s += ", Linux platform decoder failed to load";
}
if (mGMPPDMFailedToStartup) {
s += ", GMP PDM failed to startup";
} else if (!mGMP.IsEmpty()) {
s += ", Using GMP '";
s += mGMP;
s += "'";
}
break;
case eMediaKeySystemAccessRequest:
s = "key system='";
s += NS_ConvertUTF16toUTF8(mKeySystem).get();
s += mIsKeySystemSupported ? "', supported" : "', not supported";
switch (mKeySystemIssue) {
case eUnset:
case eUnsaved:
s = "Unsaved diagnostics, cannot get accurate description";
break;
case eWidevineWithNoWMF:
s += ", Widevine with no WMF";
case eFormatSupportCheck:
s = "format='";
s += NS_ConvertUTF16toUTF8(mFormat).get();
s += mCanPlay ? "', can play" : "', cannot play";
if (mWMFFailedToLoad) {
s += ", Windows platform decoder failed to load";
}
if (mFFmpegFailedToLoad) {
s += ", Linux platform decoder failed to load";
}
if (mGMPPDMFailedToStartup) {
s += ", GMP PDM failed to startup";
} else if (!mGMP.IsEmpty()) {
s += ", Using GMP '";
s += mGMP;
s += "'";
}
break;
case eMediaKeySystemAccessRequest:
s = "key system='";
s += NS_ConvertUTF16toUTF8(mKeySystem).get();
s += mIsKeySystemSupported ? "', supported" : "', not supported";
switch (mKeySystemIssue) {
case eUnset:
break;
case eWidevineWithNoWMF:
s += ", Widevine with no WMF";
break;
}
break;
}
break;
default:
s = "?";
break;

View File

@ -93,6 +93,7 @@ private:
#endif
#ifdef XP_WIN
DECL_MEDIA_PREF("media.wmf.enabled", PDMWMFEnabled, bool, true);
DECL_MEDIA_PREF("media.decoder-doctor.wmf-disabled-is-failure", DecoderDoctorWMFDisabledIsFailure, bool, false);
DECL_MEDIA_PREF("media.webm.intel_decoder.enabled", PDMWMFIntelDecoderEnabled, bool, false);
DECL_MEDIA_PREF("media.wmf.low-latency.enabled", PDMWMFLowLatencyEnabled, bool, false);
DECL_MEDIA_PREF("media.wmf.decoder.thread-count", PDMWMFThreadCount, int32_t, -1);

View File

@ -23,7 +23,6 @@
#include "nsIRequestObserver.h"
#include "nsIStreamListener.h"
#include "nsIScriptSecurityManager.h"
#include "nsCORSListenerProxy.h"
#include "mozilla/dom/HTMLMediaElement.h"
#include "nsError.h"
#include "nsICachingChannel.h"

View File

@ -334,6 +334,119 @@ IsAACContentType(const nsAString& aContentType);
bool
IsAACCodecString(const nsAString& aCodec);
template <typename String>
class StringListRange
{
typedef typename String::char_type CharType;
typedef const CharType* Pointer;
public:
// Iterator into range, trims items and skips empty items.
class Iterator
{
public:
bool operator!=(const Iterator& a) const
{
return mStart != a.mStart || mEnd != a.mEnd;
}
Iterator& operator++()
{
SearchItemAt(mComma + 1);
return *this;
}
typedef decltype(Substring(Pointer(), Pointer())) DereferencedType;
DereferencedType operator*()
{
return Substring(mStart, mEnd);
}
private:
friend class StringListRange;
Iterator(const CharType* aRangeStart, uint32_t aLength)
: mRangeEnd(aRangeStart + aLength)
{
SearchItemAt(aRangeStart);
}
void SearchItemAt(Pointer start)
{
// First, skip leading whitespace.
for (Pointer p = start; ; ++p) {
if (p >= mRangeEnd) {
mStart = mEnd = mComma = mRangeEnd;
return;
}
auto c = *p;
if (c == CharType(',')) {
// Comma -> Empty item -> Skip.
} else if (c != CharType(' ')) {
mStart = p;
break;
}
}
// Find comma, recording start of trailing space.
Pointer trailingWhitespace = nullptr;
for (Pointer p = mStart + 1; ; ++p) {
if (p >= mRangeEnd) {
mEnd = trailingWhitespace ? trailingWhitespace : p;
mComma = p;
return;
}
auto c = *p;
if (c == CharType(',')) {
mEnd = trailingWhitespace ? trailingWhitespace : p;
mComma = p;
return;
}
if (c == CharType(' ')) {
// Found a whitespace -> Record as trailing if not first one.
if (!trailingWhitespace) {
trailingWhitespace = p;
}
} else {
// Found a non-whitespace -> Reset trailing whitespace if needed.
if (trailingWhitespace) {
trailingWhitespace = nullptr;
}
}
}
}
const Pointer mRangeEnd;
Pointer mStart;
Pointer mEnd;
Pointer mComma;
};
explicit StringListRange(const String& aList) : mList(aList) {}
Iterator begin()
{
return Iterator(mList.Data(), mList.Length());
}
Iterator end()
{
return Iterator(mList.Data() + mList.Length(), 0);
}
private:
const String& mList;
};
template <typename String>
StringListRange<String>
MakeStringListRange(const String& aList)
{
return StringListRange<String>(aList);
}
template <typename ListString, typename ItemString>
static bool
StringListContains(const ListString& aList, const ItemString& aItem)
{
for (const auto& listItem : MakeStringListRange(aList)) {
if (listItem.Equals(aItem)) {
return true;
}
}
return false;
}
} // end namespace mozilla
#endif

View File

@ -0,0 +1,80 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "gtest/gtest.h"
#include "nsString.h"
#include "VideoUtils.h"
using namespace mozilla;
TEST(StringListRange, MakeStringListRange)
{
static const struct
{
const char* mList;
const char* mExpected;
} tests[] =
{
{ "", "" },
{ " ", "" },
{ ",", "" },
{ " , ", "" },
{ "a", "a|" },
{ " a ", "a|" },
{ "aa,bb", "aa|bb|" },
{ " a a , b b ", "a a|b b|" },
{ " , ,a 1,, ,b 2,", "a 1|b 2|" }
};
for (const auto& test : tests) {
nsCString list(test.mList);
nsCString out;
for (const auto& item : MakeStringListRange(list)) {
out += item;
out += "|";
}
EXPECT_STREQ(test.mExpected, out.Data());
}
}
TEST(StringListRange, StringListContains)
{
static const struct
{
const char* mList;
const char* mItemToSearch;
bool mExpected;
} tests[] =
{
{ "", "", false },
{ "", "a", false },
{ " ", "a", false },
{ ",", "a", false },
{ " , ", "", false },
{ " , ", "a", false },
{ "a", "a", true },
{ "a", "b", false },
{ " a ", "a", true },
{ "aa,bb", "aa", true },
{ "aa,bb", "bb", true },
{ "aa,bb", "cc", false },
{ "aa,bb", " aa ", false },
{ " a a , b b ", "a a", true },
{ " , ,a 1,, ,b 2,", "a 1", true },
{ " , ,a 1,, ,b 2,", "b 2", true },
{ " , ,a 1,, ,b 2,", "", false },
{ " , ,a 1,, ,b 2,", " ", false },
{ " , ,a 1,, ,b 2,", "A 1", false },
{ " , ,A 1,, ,b 2,", "a 1", false }
};
for (const auto& test : tests) {
nsCString list(test.mList);
nsCString itemToSearch(test.mItemToSearch);
EXPECT_EQ(test.mExpected, StringListContains(list, itemToSearch))
<< "trying to find \"" << itemToSearch.Data()
<< "\" in \"" << list.Data() << "\"";
}
}

View File

@ -20,6 +20,7 @@ UNIFIED_SOURCES += [
# 'TestMP4Reader.cpp', disabled so we can turn check tests back on (bug 1175752)
'TestTrackEncoder.cpp',
'TestVideoSegment.cpp',
'TestVideoUtils.cpp',
'TestVPXDecoding.cpp',
'TestWebMBuffered.cpp',
]

View File

@ -257,7 +257,7 @@ PDMFactory::CreatePDMs()
m = new WMFDecoderModule();
mWMFFailedToLoad = !StartupPDM(m);
} else {
mWMFFailedToLoad = false;
mWMFFailedToLoad = MediaPrefs::DecoderDoctorWMFDisabledIsFailure();
}
#endif
#ifdef MOZ_FFVPX

View File

@ -52,7 +52,7 @@ public:
, mGrallocFormat(aGrallocFormat)
{}
already_AddRefed<TextureClient> Allocate(CompositableForwarder* aAllocator) override
already_AddRefed<TextureClient> Allocate(TextureForwarder* aAllocator) override
{
uint32_t usage = android::GraphicBuffer::USAGE_SW_READ_OFTEN |
android::GraphicBuffer::USAGE_SW_WRITE_OFTEN |

View File

@ -17,4 +17,4 @@ mozversion==1.4
wptserve==1.3.0
marionette-client==2.2.0
marionette-driver==1.3.0
firefox-puppeteer >= 49.0.0, <50.0.0
firefox-puppeteer >= 50.0.0, <51.0.0

View File

@ -92,8 +92,9 @@ static RefPtr<GLContext> sPluginContext = nullptr;
static bool EnsureGLContext()
{
if (!sPluginContext) {
nsCString failureId;
sPluginContext = GLContextProvider::CreateHeadless(CreateContextFlags::REQUIRE_COMPAT_PROFILE, failureId);
const auto flags = CreateContextFlags::REQUIRE_COMPAT_PROFILE;
nsCString discardedFailureId;
sPluginContext = GLContextProvider::CreateHeadless(flags, &discardedFailureId);
}
return sPluginContext != nullptr;

View File

@ -141,7 +141,9 @@ function testScript(script) {
return workerTest();
})
.then(function() {
return nestedWorkerTest();
// XXX Bug 1281212 - This makes other, unrelated test suites fail, primarily on WinXP.
let isWin = navigator.platform.indexOf("Win") == 0;
return isWin ? undefined : nestedWorkerTest();
})
.then(function() {
return serviceWorkerTest();

View File

@ -12,5 +12,10 @@ enum DecoderDoctorNotificationType {
dictionary DecoderDoctorNotification {
required DecoderDoctorNotificationType type;
// True when the issue has been solved.
required boolean isSolved;
// Key from dom.properties, used for telemetry and prefs.
required DOMString decoderDoctorReportId;
// If provided, formats (or key systems) at issue.
DOMString formats;
};

View File

@ -88,7 +88,7 @@ interface HTMLInputElement : HTMLElement {
attribute DOMString defaultValue;
[Pure, TreatNullAs=EmptyString, Throws]
attribute DOMString value;
[Throws, Pref="dom.experimental_forms"]
[Throws, Func="HTMLInputElement::ValueAsDateEnabled"]
attribute Date? valueAsDate;
[Pure, SetterThrows]
attribute unrestricted double valueAsNumber;

View File

@ -34,7 +34,6 @@
#include "nsAttrName.h"
#include "nsIScriptError.h"
#include "nsIURL.h"
#include "nsCORSListenerProxy.h"
#include "nsError.h"
#include "mozilla/Attributes.h"
#include "mozilla/dom/Element.h"

View File

@ -0,0 +1,34 @@
/* 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/. */
var { classes: Cc, interfaces: Ci, utils: Cu } = Components;
"use strict";
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
Cu.import("resource://gre/modules/Services.jsm");
const EDITORUTILS_CID = Components.ID('{12e63991-86ac-4dff-bb1a-703495d67d17}');
function EditorUtils() {
}
EditorUtils.prototype = {
classID: EDITORUTILS_CID,
QueryInterface: XPCOMUtils.generateQI([ Ci.nsIEditorUtils ]),
slurpBlob(aBlob, aScope, aListener) {
let reader = new aScope.FileReader();
reader.addEventListener("load", (event) => {
aListener.onResult(event.target.result);
});
reader.addEventListener("error", (event) => {
aListener.onError(event.target.error.message);
});
reader.readAsBinaryString(aBlob);
},
};
this.NSGetFactory = XPCOMUtils.generateNSGetFactory([EditorUtils]);

View File

@ -0,0 +1,2 @@
component {12e63991-86ac-4dff-bb1a-703495d67d17} EditorUtils.js
contract @mozilla.org/editor-utils;1 {12e63991-86ac-4dff-bb1a-703495d67d17}

View File

@ -70,6 +70,11 @@ LOCAL_INCLUDES += [
'/layout/xul',
]
EXTRA_COMPONENTS += [
'EditorUtils.js',
'EditorUtils.manifest',
]
include('/ipc/chromium/chromium-config.mozbuild')
FINAL_LIBRARY = 'xul'

View File

@ -18,6 +18,7 @@
#include "nsCRT.h"
#include "nsCRTGlue.h"
#include "nsComponentManagerUtils.h"
#include "nsIScriptError.h"
#include "nsContentUtils.h"
#include "nsDebug.h"
#include "nsDependentSubstring.h"
@ -1009,6 +1010,77 @@ nsHTMLEditor::ParseCFHTML(nsCString & aCfhtml, char16_t **aStuffToPaste, char16_
return NS_OK;
}
static nsresult
ImgFromData(const nsACString& aType, const nsACString& aData, nsString& aOutput)
{
nsAutoCString data64;
nsresult rv = Base64Encode(aData, data64);
NS_ENSURE_SUCCESS(rv, rv);
aOutput.AssignLiteral("<IMG src=\"data:");
AppendUTF8toUTF16(aType, aOutput);
aOutput.AppendLiteral(";base64,");
AppendUTF8toUTF16(data64, aOutput);
aOutput.AppendLiteral("\" alt=\"\" >");
return NS_OK;
}
NS_IMPL_ISUPPORTS(nsHTMLEditor::BlobReader, nsIEditorBlobListener)
nsHTMLEditor::BlobReader::BlobReader(BlobImpl* aBlob, nsHTMLEditor* aEditor,
bool aIsSafe, nsIDOMDocument* aSourceDoc,
nsIDOMNode* aDestinationNode,
int32_t aDestOffset,
bool aDoDeleteSelection)
: mBlob(aBlob)
, mEditor(aEditor)
, mIsSafe(aIsSafe)
, mSourceDoc(aSourceDoc)
, mDestinationNode(aDestinationNode)
, mDestOffset(aDestOffset)
, mDoDeleteSelection(aDoDeleteSelection)
{
MOZ_ASSERT(mBlob);
MOZ_ASSERT(mEditor);
MOZ_ASSERT(mDestinationNode);
}
NS_IMETHODIMP
nsHTMLEditor::BlobReader::OnResult(const nsACString& aResult)
{
nsString blobType;
mBlob->GetType(blobType);
NS_ConvertUTF16toUTF8 type(blobType);
nsAutoString stuffToPaste;
nsresult rv = ImgFromData(type, aResult, stuffToPaste);
NS_ENSURE_SUCCESS(rv, rv);
nsAutoEditBatch beginBatching(mEditor);
rv = mEditor->DoInsertHTMLWithContext(stuffToPaste, EmptyString(), EmptyString(),
NS_LITERAL_STRING(kFileMime),
mSourceDoc,
mDestinationNode, mDestOffset,
mDoDeleteSelection,
mIsSafe, false);
return rv;
}
NS_IMETHODIMP
nsHTMLEditor::BlobReader::OnError(const nsAString& aError)
{
nsCOMPtr<nsINode> destNode = do_QueryInterface(mDestinationNode);
const nsPromiseFlatString& flat = PromiseFlatString(aError);
const char16_t* error = flat.get();
nsContentUtils::ReportToConsole(nsIScriptError::warningFlag,
NS_LITERAL_CSTRING("Editor"),
destNode->OwnerDoc(),
nsContentUtils::eDOM_PROPERTIES,
"EditorFileDropFailed",
&error, 1);
return NS_OK;
}
nsresult nsHTMLEditor::InsertObject(const char* aType, nsISupports* aObject, bool aIsSafe,
nsIDOMDocument *aSourceDoc,
nsIDOMNode *aDestinationNode,
@ -1017,6 +1089,23 @@ nsresult nsHTMLEditor::InsertObject(const char* aType, nsISupports* aObject, boo
{
nsresult rv;
if (nsCOMPtr<BlobImpl> blob = do_QueryInterface(aObject)) {
RefPtr<BlobReader> br = new BlobReader(blob, this, aIsSafe, aSourceDoc,
aDestinationNode, aDestOffset,
aDoDeleteSelection);
nsCOMPtr<nsIEditorUtils> utils =
do_GetService("@mozilla.org/editor-utils;1");
NS_ENSURE_TRUE(utils, NS_ERROR_FAILURE);
nsCOMPtr<nsINode> node = do_QueryInterface(aDestinationNode);
MOZ_ASSERT(node);
nsCOMPtr<nsIDOMBlob> domBlob = Blob::Create(node->GetOwnerGlobal(), blob);
NS_ENSURE_TRUE(domBlob, NS_ERROR_FAILURE);
return utils->SlurpBlob(domBlob, node->OwnerDoc()->GetWindow(), br);
}
nsAutoCString type(aType);
// Check to see if we can insert an image file
@ -1064,16 +1153,10 @@ nsresult nsHTMLEditor::InsertObject(const char* aType, nsISupports* aObject, boo
NS_ENSURE_SUCCESS(rv, rv);
}
nsAutoCString data64;
rv = Base64Encode(imageData, data64);
nsAutoString stuffToPaste;
rv = ImgFromData(type, imageData, stuffToPaste);
NS_ENSURE_SUCCESS(rv, rv);
nsAutoString stuffToPaste;
stuffToPaste.AssignLiteral("<IMG src=\"data:");
AppendUTF8toUTF16(type, stuffToPaste);
stuffToPaste.AppendLiteral(";base64,");
AppendUTF8toUTF16(data64, stuffToPaste);
stuffToPaste.AppendLiteral("\" alt=\"\" >");
nsAutoEditBatch beginBatching(this);
rv = DoInsertHTMLWithContext(stuffToPaste, EmptyString(), EmptyString(),
NS_LITERAL_STRING(kFileMime),

View File

@ -13,6 +13,7 @@
#include "nsITableEditor.h"
#include "nsIEditorMailSupport.h"
#include "nsIEditorStyleSheets.h"
#include "nsIEditorUtils.h"
#include "nsEditor.h"
#include "nsIDOMElement.h"
@ -56,6 +57,7 @@ struct PropItem;
namespace mozilla {
template<class T> class OwningNonNull;
namespace dom {
class BlobImpl;
class DocumentFragment;
} // namespace dom
namespace widget {
@ -405,6 +407,30 @@ public:
}
protected:
class BlobReader final : public nsIEditorBlobListener
{
public:
BlobReader(mozilla::dom::BlobImpl* aBlob, nsHTMLEditor* aEditor,
bool aIsSafe, nsIDOMDocument* aSourceDoc,
nsIDOMNode* aDestinationNode, int32_t aDestOffset,
bool aDoDeleteSelection);
NS_DECL_ISUPPORTS
NS_DECL_NSIEDITORBLOBLISTENER
private:
~BlobReader()
{
}
RefPtr<mozilla::dom::BlobImpl> mBlob;
RefPtr<nsHTMLEditor> mEditor;
bool mIsSafe;
nsCOMPtr<nsIDOMDocument> mSourceDoc;
nsCOMPtr<nsIDOMNode> mDestinationNode;
int32_t mDestOffset;
bool mDoDeleteSelection;
};
NS_IMETHOD InitRules() override;

View File

@ -21,6 +21,7 @@ XPIDL_SOURCES += [
'nsIEditorObserver.idl',
'nsIEditorSpellCheck.idl',
'nsIEditorStyleSheets.idl',
'nsIEditorUtils.idl',
'nsIHTMLAbsPosEditor.idl',
'nsIHTMLEditor.idl',
'nsIHTMLInlineTableEditor.idl',

32
editor/nsIEditorUtils.idl Normal file
View File

@ -0,0 +1,32 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "nsISupports.idl"
#include "domstubs.idl"
interface nsIDOMBlob;
interface mozIDOMWindowProxy;
[scriptable, uuid(eb8b8ad9-5d8f-43bd-8ce5-5b943c180d56)]
interface nsIEditorBlobListener : nsISupports
{
void onResult(in ACString aResult);
void onError(in AString aErrorName);
};
/**
* A collection of utility functions that editors can use that are more easily
* done in JavaScript.
*/
[scriptable, uuid(4bf94928-575e-4bd1-8321-a2c4b3d0119e)]
interface nsIEditorUtils : nsISupports
{
/**
* Given a blob, returns the data from that blob, asynchronously.
*/
void slurpBlob(in nsIDOMBlob aBlob, in mozIDOMWindowProxy aScope,
in nsIEditorBlobListener aListener);
};

View File

@ -1378,10 +1378,8 @@ DrawTargetSkia::CopySurface(SourceSurface *aSurface,
SkBitmap bitmap = GetBitmapForSurface(aSurface);
mCanvas->save();
mCanvas->resetMatrix();
SkRect dest = IntRectToSkRect(IntRect(aDestination.x, aDestination.y, aSourceRect.width, aSourceRect.height));
SkIRect source = IntRectToSkIRect(aSourceRect);
mCanvas->clipRect(dest, SkRegion::kReplace_Op);
mCanvas->setMatrix(SkMatrix::MakeTrans(SkIntToScalar(aDestination.x), SkIntToScalar(aDestination.y)));
mCanvas->clipRect(SkRect::MakeIWH(aSourceRect.width, aSourceRect.height), SkRegion::kReplace_Op);
SkPaint paint;
if (!bitmap.isOpaque()) {
@ -1389,12 +1387,12 @@ DrawTargetSkia::CopySurface(SourceSurface *aSurface,
// http://code.google.com/p/skia/issues/detail?id=628
paint.setXfermodeMode(SkXfermode::kSrc_Mode);
}
// drawBitmapRect with A8 bitmaps ends up doing a mask operation
// drawBitmap with A8 bitmaps ends up doing a mask operation
// so we need to clear before
if (bitmap.colorType() == kAlpha_8_SkColorType) {
mCanvas->clear(SK_ColorTRANSPARENT);
}
mCanvas->drawBitmapRect(bitmap, source, dest, &paint);
mCanvas->drawBitmap(bitmap, -SkIntToScalar(aSourceRect.x), -SkIntToScalar(aSourceRect.y), &paint);
mCanvas->restore();
}

View File

@ -131,10 +131,10 @@ private:
typedef int32_t (*pfnANativeWindow_setBuffersGeometry)(void* window, int32_t width, int32_t height, int32_t format);
pfnANativeWindow_setBuffersGeometry fANativeWindow_setBuffersGeometry;
typedef int32_t (*pfnANativeWindow_lock)(void *window, void *out_buffer, void *in_out_dirtyBounds);
typedef int32_t (*pfnANativeWindow_lock)(void* window, void* out_buffer, void* in_out_dirtyBounds);
pfnANativeWindow_lock fANativeWindow_lock;
typedef int32_t (*pfnANativeWindow_unlockAndPost)(void *window);
typedef int32_t (*pfnANativeWindow_unlockAndPost)(void* window);
pfnANativeWindow_unlockAndPost fANativeWindow_unlockAndPost;
typedef AndroidWindowFormat (*pfnANativeWindow_getFormat)(void* window);
@ -247,7 +247,7 @@ AndroidNativeWindow::Lock(void** out_bits,int32_t* out_width, int32_t* out_heigh
// Do not touch.
uint32_t reserved[6];
} ANativeWindow_Buffer;
} ANativeWindow_Buffer;
ANativeWindow_Buffer buffer;

View File

@ -236,8 +236,8 @@ GLBlitHelper::InitTexQuadProgram(BlitType target)
bool success = false;
GLuint *programPtr;
GLuint *fragShaderPtr;
GLuint* programPtr;
GLuint* fragShaderPtr;
const char* fragShaderSource;
switch (target) {
case ConvertEGLImage:
@ -329,7 +329,7 @@ GLBlitHelper::InitTexQuadProgram(BlitType target)
mGL->fBindAttribLocation(program, 0, "aPosition");
mGL->fLinkProgram(program);
if (mGL->DebugMode()) {
if (GLContext::ShouldSpew()) {
GLint status = 0;
mGL->fGetShaderiv(mTexBlit_VertShader, LOCAL_GL_COMPILE_STATUS, &status);
if (status != LOCAL_GL_TRUE) {
@ -372,7 +372,7 @@ GLBlitHelper::InitTexQuadProgram(BlitType target)
GLint status = 0;
mGL->fGetProgramiv(program, LOCAL_GL_LINK_STATUS, &status);
if (status != LOCAL_GL_TRUE) {
if (mGL->DebugMode()) {
if (GLContext::ShouldSpew()) {
NS_ERROR("Linking blit program failed.");
GLint length = 0;
mGL->fGetProgramiv(program, LOCAL_GL_INFO_LOG_LENGTH, &length);

View File

@ -55,8 +55,6 @@ using namespace mozilla::layers;
unsigned GLContext::sCurrentGLContextTLS = -1;
#endif
uint32_t GLContext::sDebugMode = 0;
// If adding defines, don't forget to undefine symbols. See #undef block below.
#define CORE_SYMBOL(x) { (PRFuncPtr*) &mSymbols.f##x, { #x, nullptr } }
#define CORE_EXT_SYMBOL2(x,y,z) { (PRFuncPtr*) &mSymbols.f##x, { #x, #x #y, #x #z, nullptr } }
@ -400,9 +398,49 @@ ParseGLVersion(GLContext* gl, uint32_t* out_version)
return true;
}
GLContext::GLContext(const SurfaceCaps& caps,
GLContext* sharedContext,
bool isOffscreen)
static uint8_t
ChooseDebugFlags(CreateContextFlags createFlags)
{
uint8_t debugFlags = 0;
#ifdef MOZ_GL_DEBUG
if (gfxEnv::GlDebug()) {
debugFlags |= GLContext::DebugFlagEnabled;
}
// Enables extra verbose output, informing of the start and finish of every GL call.
// Useful e.g. to record information to investigate graphics system crashes/lockups
if (gfxEnv::GlDebugVerbose()) {
debugFlags |= GLContext::DebugFlagTrace;
}
// Aborts on GL error. Can be useful to debug quicker code that is known not to
// generate any GL error in principle.
bool abortOnError = false;
if (createFlags & CreateContextFlags::NO_VALIDATION) {
abortOnError = true;
const auto fnStringsMatch = [](const char* a, const char* b) {
return strcmp(a, b) == 0;
};
const char* envAbortOnError = PR_GetEnv("MOZ_GL_DEBUG_ABORT_ON_ERROR");
if (envAbortOnError && fnStringsMatch(envAbortOnError, "0")) {
abortOnError = false;
}
}
if (abortOnError) {
debugFlags |= GLContext::DebugFlagAbortOnError;
}
#endif
return debugFlags;
}
GLContext::GLContext(CreateContextFlags flags, const SurfaceCaps& caps,
GLContext* sharedContext, bool isOffscreen)
: mIsOffscreen(isOffscreen),
mContextLost(false),
mVersion(0),
@ -411,6 +449,7 @@ GLContext::GLContext(const SurfaceCaps& caps,
mVendor(GLVendor::Other),
mRenderer(GLRenderer::Other),
mTopError(LOCAL_GL_NO_ERROR),
mDebugFlags(ChooseDebugFlags(flags)),
mSharedContext(sharedContext),
mCaps(caps),
mScreen(nullptr),
@ -434,7 +473,7 @@ GLContext::~GLContext() {
NS_ASSERTION(IsDestroyed(), "GLContext implementation must call MarkDestroyed in destructor!");
#ifdef MOZ_GL_DEBUG
if (mSharedContext) {
GLContext *tip = mSharedContext;
GLContext* tip = mSharedContext;
while (tip->mSharedContext)
tip = tip->mSharedContext;
tip->SharedContextDestroyed(this);
@ -531,20 +570,6 @@ GLContext::InitWithPrefixImpl(const char* prefix, bool trygl)
{
mWorkAroundDriverBugs = gfxPrefs::WorkAroundDriverBugs();
#ifdef MOZ_GL_DEBUG
if (gfxEnv::GlDebug())
sDebugMode |= DebugEnabled;
// enables extra verbose output, informing of the start and finish of every GL call.
// useful e.g. to record information to investigate graphics system crashes/lockups
if (gfxEnv::GlDebugVerbose())
sDebugMode |= DebugTrace;
// aborts on GL error. Can be useful to debug quicker code that is known not to generate any GL error in principle.
if (gfxEnv::GlDebugAbortOnError())
sDebugMode |= DebugAbortOnError;
#endif
const SymLoadStruct coreSymbols[] = {
{ (PRFuncPtr*) &mSymbols.fActiveTexture, { "ActiveTexture", "ActiveTextureARB", nullptr } },
{ (PRFuncPtr*) &mSymbols.fAttachShader, { "AttachShader", "AttachShaderARB", nullptr } },
@ -1051,7 +1076,7 @@ GLContext::InitWithPrefixImpl(const char* prefix, bool trygl)
MOZ_ASSERT(IsCurrent());
if (DebugMode() && IsExtensionSupported(KHR_debug)) {
if (ShouldSpew() && IsExtensionSupported(KHR_debug)) {
fEnable(LOCAL_GL_DEBUG_OUTPUT);
fDisable(LOCAL_GL_DEBUG_OUTPUT_SYNCHRONOUS);
fDebugMessageCallback(&StaticDebugCallback, (void*)this);
@ -1523,8 +1548,8 @@ GLContext::LoadMoreSymbols(const char* prefix, bool trygl)
if (IsSupported(GLFeature::invalidate_framebuffer)) {
const SymLoadStruct symbols[] = {
{ (PRFuncPtr *) &mSymbols.fInvalidateFramebuffer, { "InvalidateFramebuffer", nullptr } },
{ (PRFuncPtr *) &mSymbols.fInvalidateSubFramebuffer, { "InvalidateSubFramebuffer", nullptr } },
{ (PRFuncPtr*) &mSymbols.fInvalidateFramebuffer, { "InvalidateFramebuffer", nullptr } },
{ (PRFuncPtr*) &mSymbols.fInvalidateSubFramebuffer, { "InvalidateSubFramebuffer", nullptr } },
END_SYMBOLS
};
fnLoadForFeature(symbols, GLFeature::invalidate_framebuffer);
@ -1592,7 +1617,7 @@ GLContext::LoadMoreSymbols(const char* prefix, bool trygl)
{ (PRFuncPtr*) &mSymbols.fGetTexLevelParameteriv, { "GetTexLevelParameteriv", nullptr } },
END_SYMBOLS
};
const bool warnOnFailures = DebugMode();
const bool warnOnFailures = ShouldSpew();
LoadSymbols(devSymbols, trygl, prefix, warnOnFailures);
}
@ -1801,17 +1826,18 @@ GLContext::PlatformStartup()
// Common code for checking for both GL extensions and GLX extensions.
bool
GLContext::ListHasExtension(const GLubyte *extensions, const char *extension)
GLContext::ListHasExtension(const GLubyte* extensions, const char* extension)
{
// fix bug 612572 - we were crashing as we were calling this function with extensions==null
if (extensions == nullptr || extension == nullptr)
return false;
const GLubyte *start;
GLubyte *where, *terminator;
const GLubyte* start;
GLubyte* where;
GLubyte* terminator;
/* Extension names should not have spaces. */
where = (GLubyte *) strchr(extension, ' ');
where = (GLubyte*) strchr(extension, ' ');
if (where || *extension == '\0')
return false;
@ -1822,7 +1848,7 @@ GLContext::ListHasExtension(const GLubyte *extensions, const char *extension)
*/
start = extensions;
for (;;) {
where = (GLubyte *) strstr((const char *) start, extension);
where = (GLubyte*) strstr((const char*) start, extension);
if (!where) {
break;
}
@ -2044,7 +2070,7 @@ GLContext::AssembleOffscreenFBs(const GLuint colorMSRB,
if (!IsFramebufferComplete(drawFB, &status)) {
NS_WARNING("DrawFBO: Incomplete");
#ifdef MOZ_GL_DEBUG
if (DebugMode()) {
if (ShouldSpew()) {
printf_stderr("Framebuffer status: %X\n", status);
}
#endif
@ -2054,7 +2080,7 @@ GLContext::AssembleOffscreenFBs(const GLuint colorMSRB,
if (!IsFramebufferComplete(readFB, &status)) {
NS_WARNING("ReadFBO: Incomplete");
#ifdef MOZ_GL_DEBUG
if (DebugMode()) {
if (ShouldSpew()) {
printf_stderr("Framebuffer status: %X\n", status);
}
#endif
@ -2210,19 +2236,19 @@ GLContext::AssertNotPassingStackBufferToTheGL(const void* ptr)
}
void
GLContext::CreatedProgram(GLContext *aOrigin, GLuint aName)
GLContext::CreatedProgram(GLContext* aOrigin, GLuint aName)
{
mTrackedPrograms.AppendElement(NamedResource(aOrigin, aName));
}
void
GLContext::CreatedShader(GLContext *aOrigin, GLuint aName)
GLContext::CreatedShader(GLContext* aOrigin, GLuint aName)
{
mTrackedShaders.AppendElement(NamedResource(aOrigin, aName));
}
void
GLContext::CreatedBuffers(GLContext *aOrigin, GLsizei aCount, GLuint *aNames)
GLContext::CreatedBuffers(GLContext* aOrigin, GLsizei aCount, GLuint* aNames)
{
for (GLsizei i = 0; i < aCount; ++i) {
mTrackedBuffers.AppendElement(NamedResource(aOrigin, aNames[i]));
@ -2230,7 +2256,7 @@ GLContext::CreatedBuffers(GLContext *aOrigin, GLsizei aCount, GLuint *aNames)
}
void
GLContext::CreatedQueries(GLContext *aOrigin, GLsizei aCount, GLuint *aNames)
GLContext::CreatedQueries(GLContext* aOrigin, GLsizei aCount, GLuint* aNames)
{
for (GLsizei i = 0; i < aCount; ++i) {
mTrackedQueries.AppendElement(NamedResource(aOrigin, aNames[i]));
@ -2238,7 +2264,7 @@ GLContext::CreatedQueries(GLContext *aOrigin, GLsizei aCount, GLuint *aNames)
}
void
GLContext::CreatedTextures(GLContext *aOrigin, GLsizei aCount, GLuint *aNames)
GLContext::CreatedTextures(GLContext* aOrigin, GLsizei aCount, GLuint* aNames)
{
for (GLsizei i = 0; i < aCount; ++i) {
mTrackedTextures.AppendElement(NamedResource(aOrigin, aNames[i]));
@ -2246,7 +2272,7 @@ GLContext::CreatedTextures(GLContext *aOrigin, GLsizei aCount, GLuint *aNames)
}
void
GLContext::CreatedFramebuffers(GLContext *aOrigin, GLsizei aCount, GLuint *aNames)
GLContext::CreatedFramebuffers(GLContext* aOrigin, GLsizei aCount, GLuint* aNames)
{
for (GLsizei i = 0; i < aCount; ++i) {
mTrackedFramebuffers.AppendElement(NamedResource(aOrigin, aNames[i]));
@ -2254,7 +2280,7 @@ GLContext::CreatedFramebuffers(GLContext *aOrigin, GLsizei aCount, GLuint *aName
}
void
GLContext::CreatedRenderbuffers(GLContext *aOrigin, GLsizei aCount, GLuint *aNames)
GLContext::CreatedRenderbuffers(GLContext* aOrigin, GLsizei aCount, GLuint* aNames)
{
for (GLsizei i = 0; i < aCount; ++i) {
mTrackedRenderbuffers.AppendElement(NamedResource(aOrigin, aNames[i]));
@ -2262,7 +2288,7 @@ GLContext::CreatedRenderbuffers(GLContext *aOrigin, GLsizei aCount, GLuint *aNam
}
static void
RemoveNamesFromArray(GLContext *aOrigin, GLsizei aCount, const GLuint *aNames, nsTArray<GLContext::NamedResource>& aArray)
RemoveNamesFromArray(GLContext* aOrigin, GLsizei aCount, const GLuint* aNames, nsTArray<GLContext::NamedResource>& aArray)
{
for (GLsizei j = 0; j < aCount; ++j) {
GLuint name = aNames[j];
@ -2280,49 +2306,49 @@ RemoveNamesFromArray(GLContext *aOrigin, GLsizei aCount, const GLuint *aNames, n
}
void
GLContext::DeletedProgram(GLContext *aOrigin, GLuint aName)
GLContext::DeletedProgram(GLContext* aOrigin, GLuint aName)
{
RemoveNamesFromArray(aOrigin, 1, &aName, mTrackedPrograms);
}
void
GLContext::DeletedShader(GLContext *aOrigin, GLuint aName)
GLContext::DeletedShader(GLContext* aOrigin, GLuint aName)
{
RemoveNamesFromArray(aOrigin, 1, &aName, mTrackedShaders);
}
void
GLContext::DeletedBuffers(GLContext *aOrigin, GLsizei aCount, const GLuint *aNames)
GLContext::DeletedBuffers(GLContext* aOrigin, GLsizei aCount, const GLuint* aNames)
{
RemoveNamesFromArray(aOrigin, aCount, aNames, mTrackedBuffers);
}
void
GLContext::DeletedQueries(GLContext *aOrigin, GLsizei aCount, const GLuint *aNames)
GLContext::DeletedQueries(GLContext* aOrigin, GLsizei aCount, const GLuint* aNames)
{
RemoveNamesFromArray(aOrigin, aCount, aNames, mTrackedQueries);
}
void
GLContext::DeletedTextures(GLContext *aOrigin, GLsizei aCount, const GLuint *aNames)
GLContext::DeletedTextures(GLContext* aOrigin, GLsizei aCount, const GLuint* aNames)
{
RemoveNamesFromArray(aOrigin, aCount, aNames, mTrackedTextures);
}
void
GLContext::DeletedFramebuffers(GLContext *aOrigin, GLsizei aCount, const GLuint *aNames)
GLContext::DeletedFramebuffers(GLContext* aOrigin, GLsizei aCount, const GLuint* aNames)
{
RemoveNamesFromArray(aOrigin, aCount, aNames, mTrackedFramebuffers);
}
void
GLContext::DeletedRenderbuffers(GLContext *aOrigin, GLsizei aCount, const GLuint *aNames)
GLContext::DeletedRenderbuffers(GLContext* aOrigin, GLsizei aCount, const GLuint* aNames)
{
RemoveNamesFromArray(aOrigin, aCount, aNames, mTrackedRenderbuffers);
}
static void
MarkContextDestroyedInArray(GLContext *aContext, nsTArray<GLContext::NamedResource>& aArray)
MarkContextDestroyedInArray(GLContext* aContext, nsTArray<GLContext::NamedResource>& aArray)
{
for (uint32_t i = 0; i < aArray.Length(); ++i) {
if (aArray[i].origin == aContext)
@ -2331,7 +2357,7 @@ MarkContextDestroyedInArray(GLContext *aContext, nsTArray<GLContext::NamedResour
}
void
GLContext::SharedContextDestroyed(GLContext *aChild)
GLContext::SharedContextDestroyed(GLContext* aChild)
{
MarkContextDestroyedInArray(aChild, mTrackedPrograms);
MarkContextDestroyedInArray(aChild, mTrackedShaders);
@ -2343,7 +2369,7 @@ GLContext::SharedContextDestroyed(GLContext *aChild)
}
static void
ReportArrayContents(const char *title, const nsTArray<GLContext::NamedResource>& aArray)
ReportArrayContents(const char* title, const nsTArray<GLContext::NamedResource>& aArray)
{
if (aArray.Length() == 0)
return;
@ -2353,7 +2379,7 @@ ReportArrayContents(const char *title, const nsTArray<GLContext::NamedResource>&
nsTArray<GLContext::NamedResource> copy(aArray);
copy.Sort();
GLContext *lastContext = nullptr;
GLContext* lastContext = nullptr;
for (uint32_t i = 0; i < copy.Length(); ++i) {
if (lastContext != copy[i].origin) {
if (lastContext)
@ -2507,12 +2533,12 @@ GLContext::ShouldDumpExts()
}
bool
DoesStringMatch(const char* aString, const char *aWantedString)
DoesStringMatch(const char* aString, const char* aWantedString)
{
if (!aString || !aWantedString)
return false;
const char *occurrence = strstr(aString, aWantedString);
const char* occurrence = strstr(aString, aWantedString);
// aWanted not found
if (!occurrence)
@ -2523,7 +2549,7 @@ DoesStringMatch(const char* aString, const char *aWantedString)
return false;
// aWantedVendor followed by alpha character
const char *afterOccurrence = occurrence + strlen(aWantedString);
const char* afterOccurrence = occurrence + strlen(aWantedString);
if (isalpha(*afterOccurrence))
return false;

View File

@ -720,11 +720,12 @@ private:
void BeforeGLCall(const char* funcName) {
MOZ_ASSERT(IsCurrent());
if (DebugMode()) {
if (mDebugFlags) {
FlushErrors();
if (DebugMode() & DebugTrace)
if (mDebugFlags & DebugFlagTrace) {
printf_stderr("[gl:%p] > %s\n", this, funcName);
}
GLContext* tlsContext = (GLContext*)PR_GetThreadPrivate(sCurrentGLContextTLS);
if (this != tlsContext) {
@ -737,14 +738,14 @@ private:
}
void AfterGLCall(const char* funcName) {
if (DebugMode()) {
if (mDebugFlags) {
// calling fFinish() immediately after every GL call makes sure that if this GL command crashes,
// the stack trace will actually point to it. Otherwise, OpenGL being an asynchronous API, stack traces
// tend to be meaningless
mSymbols.fFinish();
GLenum err = FlushErrors();
if (DebugMode() & DebugTrace) {
if (mDebugFlags & DebugFlagTrace) {
printf_stderr("[gl:%p] < %s [%s (0x%04x)]\n", this, funcName,
GLErrorToString(err), err);
}
@ -756,15 +757,17 @@ private:
" (0x%04x)\n", this, funcName,
GLErrorToString(err), err);
if (DebugMode() & DebugAbortOnError)
MOZ_CRASH("MOZ_GL_DEBUG_ABORT_ON_ERROR");
if (mDebugFlags & DebugFlagAbortOnError) {
MOZ_CRASH("Unexpected error with MOZ_GL_DEBUG_ABORT_ON_ERROR. (Run"
" with MOZ_GL_DEBUG_ABORT_ON_ERROR=0 to disable)");
}
}
}
}
GLContext *TrackingContext()
GLContext* TrackingContext()
{
GLContext *tip = this;
GLContext* tip = this;
while (tip->mSharedContext)
tip = tip->mSharedContext;
return tip;
@ -1018,7 +1021,7 @@ public:
AFTER_GL_CALL;
}
void fCompressedTexImage2D(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid *pixels) {
void fCompressedTexImage2D(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid* pixels) {
ASSERT_NOT_PASSING_STACK_BUFFER_TO_GL(pixels);
BEFORE_GL_CALL;
mSymbols.fCompressedTexImage2D(target, level, internalformat, width, height, border, imageSize, pixels);
@ -1026,7 +1029,7 @@ public:
mHeavyGLCallsSinceLastFlush = true;
}
void fCompressedTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid *pixels) {
void fCompressedTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid* pixels) {
ASSERT_NOT_PASSING_STACK_BUFFER_TO_GL(pixels);
BEFORE_GL_CALL;
mSymbols.fCompressedTexSubImage2D(target, level, xoffset, yoffset, width, height, format, imageSize, pixels);
@ -1120,7 +1123,7 @@ private:
AFTER_GL_CALL;
}
void raw_fDrawElements(GLenum mode, GLsizei count, GLenum type, const GLvoid *indices) {
void raw_fDrawElements(GLenum mode, GLsizei count, GLenum type, const GLvoid* indices) {
BEFORE_GL_CALL;
mSymbols.fDrawElements(mode, count, type, indices);
AFTER_GL_CALL;
@ -1133,7 +1136,7 @@ public:
AfterGLDrawCall();
}
void fDrawElements(GLenum mode, GLsizei count, GLenum type, const GLvoid *indices) {
void fDrawElements(GLenum mode, GLsizei count, GLenum type, const GLvoid* indices) {
BeforeGLDrawCall();
raw_fDrawElements(mode, count, type, indices);
AfterGLDrawCall();
@ -1220,7 +1223,7 @@ public:
void fGetIntegerv(GLenum pname, GLint* params);
void GetUIntegerv(GLenum pname, GLuint *params) {
void GetUIntegerv(GLenum pname, GLuint* params) {
fGetIntegerv(pname, reinterpret_cast<GLint*>(params));
}
@ -1309,19 +1312,19 @@ public:
const GLubyte* fGetString(GLenum name) {
BEFORE_GL_CALL;
const GLubyte *result = mSymbols.fGetString(name);
const GLubyte* result = mSymbols.fGetString(name);
AFTER_GL_CALL;
return result;
}
void fGetTexImage(GLenum target, GLint level, GLenum format, GLenum type, GLvoid *img) {
void fGetTexImage(GLenum target, GLint level, GLenum format, GLenum type, GLvoid* img) {
BEFORE_GL_CALL;
ASSERT_SYMBOL_PRESENT(fGetTexImage);
mSymbols.fGetTexImage(target, level, format, type, img);
AFTER_GL_CALL;
}
void fGetTexLevelParameteriv(GLenum target, GLint level, GLenum pname, GLint *params)
void fGetTexLevelParameteriv(GLenum target, GLint level, GLenum pname, GLint* params)
{
BEFORE_GL_CALL;
ASSERT_SYMBOL_PRESENT(fGetTexLevelParameteriv);
@ -1458,7 +1461,7 @@ public:
AFTER_GL_CALL;
}
void fLoadMatrixf(const GLfloat *matrix) {
void fLoadMatrixf(const GLfloat* matrix) {
BEFORE_GL_CALL;
mSymbols.fLoadMatrixf(matrix);
AFTER_GL_CALL;
@ -1476,7 +1479,7 @@ public:
AFTER_GL_CALL;
}
void fTextureRangeAPPLE(GLenum target, GLsizei length, GLvoid *pointer) {
void fTextureRangeAPPLE(GLenum target, GLsizei length, GLvoid* pointer) {
ASSERT_NOT_PASSING_STACK_BUFFER_TO_GL(pointer);
BEFORE_GL_CALL;
mSymbols.fTextureRangeAPPLE(target, length, pointer);
@ -1515,7 +1518,7 @@ public:
AFTER_GL_CALL;
}
void raw_fReadPixels(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLvoid *pixels) {
void raw_fReadPixels(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLvoid* pixels) {
ASSERT_NOT_PASSING_STACK_BUFFER_TO_GL(pixels);
BEFORE_GL_CALL;
mSymbols.fReadPixels(x, y, width, height, format, type, pixels);
@ -1598,14 +1601,14 @@ public:
AFTER_GL_CALL;
}
void fTexGenfv(GLenum coord, GLenum pname, const GLfloat *params) {
void fTexGenfv(GLenum coord, GLenum pname, const GLfloat* params) {
BEFORE_GL_CALL;
mSymbols.fTexGenfv(coord, pname, params);
AFTER_GL_CALL;
}
private:
void raw_fTexImage2D(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid *pixels) {
void raw_fTexImage2D(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid* pixels) {
ASSERT_NOT_PASSING_STACK_BUFFER_TO_GL(pixels);
BEFORE_GL_CALL;
mSymbols.fTexImage2D(target, level, internalformat, width, height, border, format, type, pixels);
@ -1614,7 +1617,7 @@ private:
}
public:
void fTexImage2D(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid *pixels) {
void fTexImage2D(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid* pixels) {
if (!IsTextureSizeSafeToPassToDriver(target, width, height)) {
// pass wrong values to cause the GL to generate GL_INVALID_VALUE.
// See bug 737182 and the comment in IsTextureSizeSafeToPassToDriver.
@ -2063,7 +2066,7 @@ public:
void* fMapBuffer(GLenum target, GLenum access) {
BEFORE_GL_CALL;
ASSERT_SYMBOL_PRESENT(fMapBuffer);
void *ret = mSymbols.fMapBuffer(target, access);
void* ret = mSymbols.fMapBuffer(target, access);
AFTER_GL_CALL;
return ret;
}
@ -2265,14 +2268,14 @@ public:
AFTER_GL_CALL;
}
void fGetInteger64v(GLenum pname, GLint64 *params) {
void fGetInteger64v(GLenum pname, GLint64* params) {
BEFORE_GL_CALL;
ASSERT_SYMBOL_PRESENT(fGetInteger64v);
mSymbols.fGetInteger64v(pname, params);
AFTER_GL_CALL;
}
void fGetSynciv(GLsync sync, GLenum pname, GLsizei bufSize, GLsizei *length, GLint *values) {
void fGetSynciv(GLsync sync, GLenum pname, GLsizei bufSize, GLsizei* length, GLint* values) {
BEFORE_GL_CALL;
ASSERT_SYMBOL_PRESENT(fGetSynciv);
mSymbols.fGetSynciv(sync, pname, bufSize, length, values);
@ -2796,7 +2799,7 @@ public:
AFTER_GL_CALL;
}
void fDeleteVertexArrays(GLsizei n, const GLuint *arrays)
void fDeleteVertexArrays(GLsizei n, const GLuint* arrays)
{
BEFORE_GL_CALL;
ASSERT_SYMBOL_PRESENT(fDeleteVertexArrays);
@ -2804,7 +2807,7 @@ public:
AFTER_GL_CALL;
}
void fGenVertexArrays(GLsizei n, GLuint *arrays)
void fGenVertexArrays(GLsizei n, GLuint* arrays)
{
BEFORE_GL_CALL;
ASSERT_SYMBOL_PRESENT(fGenVertexArrays);
@ -2930,7 +2933,7 @@ public:
// -----------------------------------------------------------------------------
// Core GL & Extension ARB_sampler_objects
public:
void fGenSamplers(GLsizei count, GLuint *samplers)
void fGenSamplers(GLsizei count, GLuint* samplers)
{
BEFORE_GL_CALL;
ASSERT_SYMBOL_PRESENT(fGenSamplers);
@ -2938,7 +2941,7 @@ public:
AFTER_GL_CALL;
}
void fDeleteSamplers(GLsizei count, const GLuint *samplers)
void fDeleteSamplers(GLsizei count, const GLuint* samplers)
{
BEFORE_GL_CALL;
ASSERT_SYMBOL_PRESENT(fDeleteSamplers);
@ -2971,7 +2974,7 @@ public:
AFTER_GL_CALL;
}
void fSamplerParameteriv(GLuint sampler, GLenum pname, const GLint *param)
void fSamplerParameteriv(GLuint sampler, GLenum pname, const GLint* param)
{
BEFORE_GL_CALL;
ASSERT_SYMBOL_PRESENT(fSamplerParameteriv);
@ -2987,7 +2990,7 @@ public:
AFTER_GL_CALL;
}
void fSamplerParameterfv(GLuint sampler, GLenum pname, const GLfloat *param)
void fSamplerParameterfv(GLuint sampler, GLenum pname, const GLfloat* param)
{
BEFORE_GL_CALL;
ASSERT_SYMBOL_PRESENT(fSamplerParameterfv);
@ -2995,7 +2998,7 @@ public:
AFTER_GL_CALL;
}
void fGetSamplerParameteriv(GLuint sampler, GLenum pname, GLint *params)
void fGetSamplerParameteriv(GLuint sampler, GLenum pname, GLint* params)
{
BEFORE_GL_CALL;
ASSERT_SYMBOL_PRESENT(fGetSamplerParameteriv);
@ -3003,7 +3006,7 @@ public:
AFTER_GL_CALL;
}
void fGetSamplerParameterfv(GLuint sampler, GLenum pname, GLfloat *params)
void fGetSamplerParameterfv(GLuint sampler, GLenum pname, GLfloat* params)
{
BEFORE_GL_CALL;
ASSERT_SYMBOL_PRESENT(fGetSamplerParameterfv);
@ -3174,7 +3177,7 @@ public:
// -----------------------------------------------------------------------------
// Constructor
protected:
explicit GLContext(const SurfaceCaps& caps,
explicit GLContext(CreateContextFlags flags, const SurfaceCaps& caps,
GLContext* sharedContext = nullptr,
bool isOffscreen = false);
@ -3234,7 +3237,7 @@ public:
return mSymbols.fUseProgram == nullptr;
}
GLContext *GetSharedContext() { return mSharedContext; }
GLContext* GetSharedContext() { return mSharedContext; }
/**
* Returns true if the thread on which this context was created is the currently
@ -3342,8 +3345,8 @@ public:
virtual bool RenewSurface(nsIWidget* aWidget) { return false; }
// Shared code for GL extensions and GLX extensions.
static bool ListHasExtension(const GLubyte *extensions,
const char *extension);
static bool ListHasExtension(const GLubyte* extensions,
const char* extension);
GLint GetMaxTextureImageSize() { return mMaxTextureImageSize; }
@ -3351,20 +3354,12 @@ public:
std::map<GLuint, SharedSurface*> mFBOMapping;
enum {
DebugEnabled = 1 << 0,
DebugTrace = 1 << 1,
DebugAbortOnError = 1 << 2
DebugFlagEnabled = 1 << 0,
DebugFlagTrace = 1 << 1,
DebugFlagAbortOnError = 1 << 2
};
static uint32_t sDebugMode;
static uint32_t DebugMode() {
#ifdef MOZ_GL_DEBUG
return sDebugMode;
#else
return 0;
#endif
}
const uint8_t mDebugFlags;
protected:
RefPtr<GLContext> mSharedContext;
@ -3375,11 +3370,11 @@ protected:
GLContextSymbols mSymbols;
#ifdef MOZ_GL_DEBUG
// GLDebugMode will check that we don't send call
// Non-zero debug flags will check that we don't send call
// to a GLContext that isn't current on the current
// thread.
// Store the current context when binding to thread local
// storage to support DebugMode on an arbitrary thread.
// storage to support debug flags on an arbitrary thread.
static unsigned sCurrentGLContextTLS;
#endif
@ -3573,22 +3568,22 @@ public:
#undef ASSERT_SYMBOL_PRESENT
#ifdef MOZ_GL_DEBUG
void CreatedProgram(GLContext *aOrigin, GLuint aName);
void CreatedShader(GLContext *aOrigin, GLuint aName);
void CreatedBuffers(GLContext *aOrigin, GLsizei aCount, GLuint *aNames);
void CreatedQueries(GLContext *aOrigin, GLsizei aCount, GLuint *aNames);
void CreatedTextures(GLContext *aOrigin, GLsizei aCount, GLuint *aNames);
void CreatedFramebuffers(GLContext *aOrigin, GLsizei aCount, GLuint *aNames);
void CreatedRenderbuffers(GLContext *aOrigin, GLsizei aCount, GLuint *aNames);
void DeletedProgram(GLContext *aOrigin, GLuint aName);
void DeletedShader(GLContext *aOrigin, GLuint aName);
void DeletedBuffers(GLContext *aOrigin, GLsizei aCount, const GLuint *aNames);
void DeletedQueries(GLContext *aOrigin, GLsizei aCount, const GLuint *aNames);
void DeletedTextures(GLContext *aOrigin, GLsizei aCount, const GLuint *aNames);
void DeletedFramebuffers(GLContext *aOrigin, GLsizei aCount, const GLuint *aNames);
void DeletedRenderbuffers(GLContext *aOrigin, GLsizei aCount, const GLuint *aNames);
void CreatedProgram(GLContext* aOrigin, GLuint aName);
void CreatedShader(GLContext* aOrigin, GLuint aName);
void CreatedBuffers(GLContext* aOrigin, GLsizei aCount, GLuint* aNames);
void CreatedQueries(GLContext* aOrigin, GLsizei aCount, GLuint* aNames);
void CreatedTextures(GLContext* aOrigin, GLsizei aCount, GLuint* aNames);
void CreatedFramebuffers(GLContext* aOrigin, GLsizei aCount, GLuint* aNames);
void CreatedRenderbuffers(GLContext* aOrigin, GLsizei aCount, GLuint* aNames);
void DeletedProgram(GLContext* aOrigin, GLuint aName);
void DeletedShader(GLContext* aOrigin, GLuint aName);
void DeletedBuffers(GLContext* aOrigin, GLsizei aCount, const GLuint* aNames);
void DeletedQueries(GLContext* aOrigin, GLsizei aCount, const GLuint* aNames);
void DeletedTextures(GLContext* aOrigin, GLsizei aCount, const GLuint* aNames);
void DeletedFramebuffers(GLContext* aOrigin, GLsizei aCount, const GLuint* aNames);
void DeletedRenderbuffers(GLContext* aOrigin, GLsizei aCount, const GLuint* aNames);
void SharedContextDestroyed(GLContext *aChild);
void SharedContextDestroyed(GLContext* aChild);
void ReportOutstandingNames();
struct NamedResource {
@ -3596,11 +3591,11 @@ public:
: origin(nullptr), name(0), originDeleted(false)
{ }
NamedResource(GLContext *aOrigin, GLuint aName)
NamedResource(GLContext* aOrigin, GLuint aName)
: origin(aOrigin), name(aName), originDeleted(false)
{ }
GLContext *origin;
GLContext* origin;
GLuint name;
bool originDeleted;
@ -3639,7 +3634,7 @@ public:
void Readback(SharedSurface* src, gfx::DataSourceSurface* dest);
};
bool DoesStringMatch(const char* aString, const char *aWantedString);
bool DoesStringMatch(const char* aString, const char* aWantedString);
void SplitByChar(const nsACString& str, const char delim,
std::vector<nsCString>* const out);

View File

@ -24,12 +24,12 @@ class GLContextCGL : public GLContext
{
friend class GLContextProviderCGL;
NSOpenGLContext *mContext;
NSOpenGLContext* mContext;
public:
MOZ_DECLARE_REFCOUNTED_VIRTUAL_TYPENAME(GLContextCGL, override)
GLContextCGL(const SurfaceCaps& caps, NSOpenGLContext* context,
bool isOffscreen, ContextProfile profile);
GLContextCGL(CreateContextFlags flags, const SurfaceCaps& caps,
NSOpenGLContext* context, bool isOffscreen, ContextProfile profile);
~GLContextCGL();

View File

@ -23,9 +23,8 @@ class GLContextEAGL : public GLContext
public:
MOZ_DECLARE_REFCOUNTED_VIRTUAL_TYPENAME(GLContextEAGL, override)
GLContextEAGL(const SurfaceCaps& caps, EAGLContext* context,
GLContext* sharedContext,
bool isOffscreen, ContextProfile profile);
GLContextEAGL(CreateContextFlags flags, const SurfaceCaps& caps, EAGLContext* context,
GLContext* sharedContext, bool isOffscreen, ContextProfile profile);
~GLContextEAGL();

View File

@ -20,15 +20,16 @@ class GLContextEGL : public GLContext
static already_AddRefed<GLContextEGL>
CreateGLContext(CreateContextFlags flags,
const SurfaceCaps& caps,
GLContextEGL *shareContext,
GLContextEGL* shareContext,
bool isOffscreen,
EGLConfig config,
EGLSurface surface,
nsACString& aFailureId);
nsACString* const out_failureId);
public:
MOZ_DECLARE_REFCOUNTED_VIRTUAL_TYPENAME(GLContextEGL, override)
GLContextEGL(const SurfaceCaps& caps,
GLContextEGL(CreateContextFlags flags,
const SurfaceCaps& caps,
GLContext* shareContext,
bool isOffscreen,
EGLConfig config,
@ -90,7 +91,7 @@ public:
// hold a reference to the given surface
// for the lifetime of this context.
void HoldSurface(gfxASurface *aSurf);
void HoldSurface(gfxASurface* aSurf);
EGLSurface GetEGLSurface() const {
return mSurface;
@ -100,15 +101,15 @@ public:
return sEGLLibrary.Display();
}
bool BindTex2DOffscreen(GLContext *aOffscreen);
void UnbindTex2DOffscreen(GLContext *aOffscreen);
bool BindTex2DOffscreen(GLContext* aOffscreen);
void UnbindTex2DOffscreen(GLContext* aOffscreen);
void BindOffscreenFramebuffer();
static already_AddRefed<GLContextEGL>
CreateEGLPBufferOffscreenContext(CreateContextFlags flags,
const gfx::IntSize& size,
const SurfaceCaps& minCaps,
nsACString& aFailureId);
nsACString* const out_FailureId);
protected:
friend class GLContextProviderEGL;

View File

@ -19,7 +19,8 @@ class GLContextGLX : public GLContext
public:
MOZ_DECLARE_REFCOUNTED_VIRTUAL_TYPENAME(GLContextGLX, override)
static already_AddRefed<GLContextGLX>
CreateGLContext(const SurfaceCaps& caps,
CreateGLContext(CreateContextFlags flags,
const SurfaceCaps& caps,
GLContextGLX* shareContext,
bool isOffscreen,
Display* display,
@ -70,19 +71,20 @@ public:
private:
friend class GLContextProviderGLX;
GLContextGLX(const SurfaceCaps& caps,
GLContextGLX(CreateContextFlags flags,
const SurfaceCaps& caps,
GLContext* shareContext,
bool isOffscreen,
Display *aDisplay,
Display* aDisplay,
GLXDrawable aDrawable,
GLXContext aContext,
bool aDeleteDrawable,
bool aDoubleBuffered,
gfxXlibSurface *aPixmap,
gfxXlibSurface* aPixmap,
ContextProfile profile);
GLXContext mContext;
Display *mDisplay;
Display* mDisplay;
GLXDrawable mDrawable;
bool mDeleteDrawable;
bool mDoubleBuffered;

View File

@ -65,14 +65,15 @@ public:
private:
bool mInitialized;
bool mUseDoubleBufferedWindows;
PRLibrary *mOGLLibrary;
PRLibrary* mOGLLibrary;
};
CGLLibrary sCGLLibrary;
GLContextCGL::GLContextCGL(const SurfaceCaps& caps, NSOpenGLContext* context,
bool isOffscreen, ContextProfile profile)
: GLContext(caps, nullptr, isOffscreen)
GLContextCGL::GLContextCGL(CreateContextFlags flags, const SurfaceCaps& caps,
NSOpenGLContext* context, bool isOffscreen,
ContextProfile profile)
: GLContext(flags, caps, nullptr, isOffscreen)
, mContext(context)
{
SetProfileVersion(profile, 210);
@ -234,7 +235,7 @@ CreateWithFormat(const NSOpenGLPixelFormatAttribute* attribs)
}
already_AddRefed<GLContext>
GLContextProviderCGL::CreateForWindow(nsIWidget *aWidget, bool aForceAccelerated)
GLContextProviderCGL::CreateForWindow(nsIWidget* aWidget, bool aForceAccelerated)
{
if (!sCGLLibrary.EnsureInitialized()) {
return nullptr;
@ -263,8 +264,8 @@ GLContextProviderCGL::CreateForWindow(nsIWidget *aWidget, bool aForceAccelerated
SurfaceCaps caps = SurfaceCaps::ForRGBA();
ContextProfile profile = ContextProfile::OpenGLCompatibility;
RefPtr<GLContextCGL> glContext = new GLContextCGL(caps, context, false,
profile);
RefPtr<GLContextCGL> glContext = new GLContextCGL(CreateContextFlags::NONE, caps,
context, false, profile);
if (!glContext->Init()) {
glContext = nullptr;
@ -311,8 +312,8 @@ CreateOffscreenFBOContext(CreateContextFlags flags)
}
SurfaceCaps dummyCaps = SurfaceCaps::Any();
RefPtr<GLContextCGL> glContext = new GLContextCGL(dummyCaps, context,
true, profile);
RefPtr<GLContextCGL> glContext = new GLContextCGL(flags, dummyCaps, context, true,
profile);
if (gfxPrefs::GLMultithreaded()) {
CGLEnable(glContext->GetCGLContext(), kCGLCEMPEngine);
@ -321,17 +322,18 @@ CreateOffscreenFBOContext(CreateContextFlags flags)
}
already_AddRefed<GLContext>
GLContextProviderCGL::CreateHeadless(CreateContextFlags flags, nsACString& aFailureId)
GLContextProviderCGL::CreateHeadless(CreateContextFlags flags,
nsACString* const out_failureId)
{
RefPtr<GLContextCGL> gl;
gl = CreateOffscreenFBOContext(flags);
if (!gl) {
aFailureId = NS_LITERAL_CSTRING("FEATURE_FAILURE_CGL_FBO");
*out_failureId = NS_LITERAL_CSTRING("FEATURE_FAILURE_CGL_FBO");
return nullptr;
}
if (!gl->Init()) {
aFailureId = NS_LITERAL_CSTRING("FEATURE_FAILURE_CGL_INIT");
*out_failureId = NS_LITERAL_CSTRING("FEATURE_FAILURE_CGL_INIT");
NS_WARNING("Failed during Init.");
return nullptr;
}
@ -343,15 +345,15 @@ already_AddRefed<GLContext>
GLContextProviderCGL::CreateOffscreen(const IntSize& size,
const SurfaceCaps& minCaps,
CreateContextFlags flags,
nsACString& aFailureId)
nsACString* const out_failureId)
{
RefPtr<GLContext> gl = CreateHeadless(flags, aFailureId);
RefPtr<GLContext> gl = CreateHeadless(flags, out_failureId);
if (!gl) {
return nullptr;
}
if (!gl->InitOffscreen(size, minCaps)) {
aFailureId = NS_LITERAL_CSTRING("FEATURE_FAILURE_CGL_INIT");
*out_failureId = NS_LITERAL_CSTRING("FEATURE_FAILURE_CGL_INIT");
return nullptr;
}
@ -370,7 +372,7 @@ GLContextProviderCGL::GetGlobalContext()
MOZ_RELEASE_ASSERT(!gGlobalContext);
nsCString discardFailureId;
RefPtr<GLContext> temp = CreateHeadless(CreateContextFlags::NONE,
discardFailureId);
&discardFailureId);
gGlobalContext = temp;
if (!gGlobalContext) {

View File

@ -18,10 +18,10 @@
namespace mozilla {
namespace gl {
GLContextEAGL::GLContextEAGL(const SurfaceCaps& caps, EAGLContext* context,
GLContext* sharedContext,
GLContextEAGL::GLContextEAGL(CreateContextFlags flags, const SurfaceCaps& caps,
EAGLContext* context, GLContext* sharedContext,
bool isOffscreen, ContextProfile profile)
: GLContext(caps, sharedContext, isOffscreen)
: GLContext(flags, caps, sharedContext, isOffscreen)
, mContext(context)
, mBackbufferRB(0)
, mBackbufferFB(0)
@ -166,7 +166,7 @@ GetGlobalContextEAGL()
}
static already_AddRefed<GLContext>
CreateEAGLContext(bool aOffscreen, GLContextEAGL* sharedContext)
CreateEAGLContext(CreateContextFlags flags, bool aOffscreen, GLContextEAGL* sharedContext)
{
EAGLRenderingAPI apis[] = { kEAGLRenderingAPIOpenGLES3, kEAGLRenderingAPIOpenGLES2 };
@ -191,7 +191,7 @@ CreateEAGLContext(bool aOffscreen, GLContextEAGL* sharedContext)
SurfaceCaps caps = SurfaceCaps::ForRGBA();
ContextProfile profile = ContextProfile::OpenGLES;
RefPtr<GLContextEAGL> glContext = new GLContextEAGL(caps, context,
RefPtr<GLContextEAGL> glContext = new GLContextEAGL(flags, caps, context,
sharedContext,
aOffscreen,
profile);
@ -207,7 +207,8 @@ CreateEAGLContext(bool aOffscreen, GLContextEAGL* sharedContext)
already_AddRefed<GLContext>
GLContextProviderEAGL::CreateForWindow(nsIWidget* aWidget, bool aForceAccelerated)
{
RefPtr<GLContext> glContext = CreateEAGLContext(false, GetGlobalContextEAGL());
RefPtr<GLContext> glContext = CreateEAGLContext(CreateContextFlags::NONE, false,
GetGlobalContextEAGL());
if (!glContext) {
return nullptr;
}
@ -220,17 +221,19 @@ GLContextProviderEAGL::CreateForWindow(nsIWidget* aWidget, bool aForceAccelerate
}
already_AddRefed<GLContext>
GLContextProviderEAGL::CreateHeadless(CreateContextFlags flags)
GLContextProviderEAGL::CreateHeadless(CreateContextFlags flags,
nsACString* const out_failureId)
{
return CreateEAGLContext(true, GetGlobalContextEAGL());
return CreateEAGLContext(flags, true, GetGlobalContextEAGL());
}
already_AddRefed<GLContext>
GLContextProviderEAGL::CreateOffscreen(const mozilla::gfx::IntSize& size,
const SurfaceCaps& caps,
CreateContextFlags flags)
CreateContextFlags flags,
nsACString* const out_failureId)
{
RefPtr<GLContext> glContext = CreateHeadless(flags);
RefPtr<GLContext> glContext = CreateHeadless(flags, out_failureId);
if (!glContext->InitOffscreen(size, caps)) {
return nullptr;
}

View File

@ -193,14 +193,10 @@ CreateSurfaceForWindow(nsIWidget* widget, const EGLConfig& config) {
return newSurface;
}
GLContextEGL::GLContextEGL(
const SurfaceCaps& caps,
GLContext* shareContext,
bool isOffscreen,
EGLConfig config,
EGLSurface surface,
EGLContext context)
: GLContext(caps, shareContext, isOffscreen)
GLContextEGL::GLContextEGL(CreateContextFlags flags, const SurfaceCaps& caps,
GLContext* shareContext, bool isOffscreen, EGLConfig config,
EGLSurface surface, EGLContext context)
: GLContext(flags, caps, shareContext, isOffscreen)
, mConfig(config)
, mSurface(surface)
, mContext(context)
@ -452,7 +448,7 @@ GLContextEGL::SwapBuffers()
// hold a reference to the given surface
// for the lifetime of this context.
void
GLContextEGL::HoldSurface(gfxASurface *aSurf) {
GLContextEGL::HoldSurface(gfxASurface* aSurf) {
mThebesSurface = aSurf;
}
@ -460,7 +456,7 @@ GLContextEGL::HoldSurface(gfxASurface *aSurf) {
GLContextEGL::CreateSurfaceForWindow(nsIWidget* aWidget)
{
nsCString discardFailureId;
if (!sEGLLibrary.EnsureInitialized(false, discardFailureId)) {
if (!sEGLLibrary.EnsureInitialized(false, &discardFailureId)) {
MOZ_CRASH("GFX: Failed to load EGL library!\n");
return nullptr;
}
@ -490,14 +486,14 @@ GLContextEGL::DestroySurface(EGLSurface aSurface)
already_AddRefed<GLContextEGL>
GLContextEGL::CreateGLContext(CreateContextFlags flags,
const SurfaceCaps& caps,
GLContextEGL *shareContext,
GLContextEGL* shareContext,
bool isOffscreen,
EGLConfig config,
EGLSurface surface,
nsACString& aFailureId)
nsACString* const out_failureId)
{
if (sEGLLibrary.fBindAPI(LOCAL_EGL_OPENGL_ES_API) == LOCAL_EGL_FALSE) {
aFailureId = NS_LITERAL_CSTRING("FEATURE_FAILURE_EGL_ES");
*out_failureId = NS_LITERAL_CSTRING("FEATURE_FAILURE_EGL_ES");
NS_WARNING("Failed to bind API to GLES!");
return nullptr;
}
@ -528,26 +524,21 @@ GLContextEGL::CreateGLContext(CreateContextFlags flags,
contextAttribs.Elements());
if (!context && shareContext) {
shareContext = nullptr;
context = sEGLLibrary.fCreateContext(EGL_DISPLAY(),
config,
EGL_NO_CONTEXT,
contextAttribs.Elements());
context = sEGLLibrary.fCreateContext(EGL_DISPLAY(), config, EGL_NO_CONTEXT,
contextAttribs.Elements());
}
if (!context) {
aFailureId = NS_LITERAL_CSTRING("FEATURE_FAILURE_EGL_CREATE");
*out_failureId = NS_LITERAL_CSTRING("FEATURE_FAILURE_EGL_CREATE");
NS_WARNING("Failed to create EGLContext!");
return nullptr;
}
RefPtr<GLContextEGL> glContext = new GLContextEGL(caps,
shareContext,
isOffscreen,
config,
surface,
context);
RefPtr<GLContextEGL> glContext = new GLContextEGL(flags, caps, shareContext,
isOffscreen, config, surface,
context);
if (!glContext->Init()) {
aFailureId = NS_LITERAL_CSTRING("FEATURE_FAILURE_EGL_INIT");
*out_failureId = NS_LITERAL_CSTRING("FEATURE_FAILURE_EGL_INIT");
return nullptr;
}
@ -749,33 +740,30 @@ already_AddRefed<GLContext>
GLContextProviderEGL::CreateWrappingExisting(void* aContext, void* aSurface)
{
nsCString discardFailureId;
if (!sEGLLibrary.EnsureInitialized(false, discardFailureId)) {
if (!sEGLLibrary.EnsureInitialized(false, &discardFailureId)) {
MOZ_CRASH("GFX: Failed to load EGL library 2!\n");
return nullptr;
}
if (aContext && aSurface) {
SurfaceCaps caps = SurfaceCaps::Any();
EGLConfig config = EGL_NO_CONFIG;
RefPtr<GLContextEGL> glContext =
new GLContextEGL(caps,
nullptr, false,
config, (EGLSurface)aSurface, (EGLContext)aContext);
if (!aContext || !aSurface)
return nullptr;
glContext->SetIsDoubleBuffered(true);
glContext->mOwnsContext = false;
SurfaceCaps caps = SurfaceCaps::Any();
EGLConfig config = EGL_NO_CONFIG;
RefPtr<GLContextEGL> gl = new GLContextEGL(CreateContextFlags::NONE, caps, nullptr,
false, config, (EGLSurface)aSurface,
(EGLContext)aContext);
gl->SetIsDoubleBuffered(true);
gl->mOwnsContext = false;
return glContext.forget();
}
return nullptr;
return gl.forget();
}
already_AddRefed<GLContext>
GLContextProviderEGL::CreateForWindow(nsIWidget *aWidget, bool aForceAccelerated)
GLContextProviderEGL::CreateForWindow(nsIWidget* aWidget, bool aForceAccelerated)
{
nsCString discardFailureId;
if (!sEGLLibrary.EnsureInitialized(false, discardFailureId)) {
if (!sEGLLibrary.EnsureInitialized(false, &discardFailureId)) {
MOZ_CRASH("GFX: Failed to load EGL library 3!\n");
return nullptr;
}
@ -795,21 +783,19 @@ GLContextProviderEGL::CreateForWindow(nsIWidget *aWidget, bool aForceAccelerated
}
SurfaceCaps caps = SurfaceCaps::Any();
RefPtr<GLContextEGL> glContext =
GLContextEGL::CreateGLContext(CreateContextFlags::NONE, caps,
nullptr, false,
config, surface, discardFailureId);
if (!glContext) {
RefPtr<GLContextEGL> gl = GLContextEGL::CreateGLContext(CreateContextFlags::NONE,
caps, nullptr, false, config,
surface, &discardFailureId);
if (!gl) {
MOZ_CRASH("GFX: Failed to create EGLContext!\n");
mozilla::gl::DestroySurface(surface);
return nullptr;
}
glContext->MakeCurrent();
glContext->SetIsDoubleBuffered(doubleBuffered);
gl->MakeCurrent();
gl->SetIsDoubleBuffered(doubleBuffered);
return glContext.forget();
return gl.forget();
}
#if defined(ANDROID)
@ -817,7 +803,7 @@ EGLSurface
GLContextProviderEGL::CreateEGLSurface(void* aWindow)
{
nsCString discardFailureId;
if (!sEGLLibrary.EnsureInitialized(false, discardFailureId)) {
if (!sEGLLibrary.EnsureInitialized(false, &discardFailureId)) {
MOZ_CRASH("GFX: Failed to load EGL library 4!\n");
}
@ -828,8 +814,8 @@ GLContextProviderEGL::CreateEGLSurface(void* aWindow)
MOZ_ASSERT(aWindow);
EGLSurface surface = sEGLLibrary.fCreateWindowSurface(EGL_DISPLAY(), config, aWindow, 0);
EGLSurface surface = sEGLLibrary.fCreateWindowSurface(EGL_DISPLAY(), config, aWindow,
0);
if (surface == EGL_NO_SURFACE) {
MOZ_CRASH("GFX: Failed to create EGLSurface 2!\n");
}
@ -841,7 +827,7 @@ void
GLContextProviderEGL::DestroyEGLSurface(EGLSurface surface)
{
nsCString discardFailureId;
if (!sEGLLibrary.EnsureInitialized(false, discardFailureId)) {
if (!sEGLLibrary.EnsureInitialized(false, &discardFailureId)) {
MOZ_CRASH("GFX: Failed to load EGL library 5!\n");
}
@ -953,17 +939,17 @@ ChooseConfig(GLLibraryEGL* egl, CreateContextFlags flags, const SurfaceCaps& min
GLContextEGL::CreateEGLPBufferOffscreenContext(CreateContextFlags flags,
const mozilla::gfx::IntSize& size,
const SurfaceCaps& minCaps,
nsACString& aFailureId)
nsACString* const out_failureId)
{
bool forceEnableHardware = bool(flags & CreateContextFlags::FORCE_ENABLE_HARDWARE);
if (!sEGLLibrary.EnsureInitialized(forceEnableHardware, aFailureId)) {
if (!sEGLLibrary.EnsureInitialized(forceEnableHardware, out_failureId)) {
return nullptr;
}
SurfaceCaps configCaps;
EGLConfig config = ChooseConfig(&sEGLLibrary, flags, minCaps, &configCaps);
if (config == EGL_NO_CONFIG) {
aFailureId = NS_LITERAL_CSTRING("FEATURE_FAILURE_EGL_NO_CONFIG");
*out_failureId = NS_LITERAL_CSTRING("FEATURE_FAILURE_EGL_NO_CONFIG");
NS_WARNING("Failed to find a compatible config.");
return nullptr;
}
@ -977,13 +963,14 @@ GLContextEGL::CreateEGLPBufferOffscreenContext(CreateContextFlags flags,
LOCAL_EGL_NONE,
pbSize);
if (!surface) {
aFailureId = NS_LITERAL_CSTRING("FEATURE_FAILURE_EGL_POT");
*out_failureId = NS_LITERAL_CSTRING("FEATURE_FAILURE_EGL_POT");
NS_WARNING("Failed to create PBuffer for context!");
return nullptr;
}
RefPtr<GLContextEGL> gl = GLContextEGL::CreateGLContext(flags, configCaps, nullptr, true,
config, surface, aFailureId);
RefPtr<GLContextEGL> gl = GLContextEGL::CreateGLContext(flags, configCaps, nullptr,
true, config, surface,
out_failureId);
if (!gl) {
NS_WARNING("Failed to create GLContext from PBuffer");
sEGLLibrary.fDestroySurface(sEGLLibrary.Display(), surface);
@ -994,12 +981,13 @@ GLContextEGL::CreateEGLPBufferOffscreenContext(CreateContextFlags flags,
}
/*static*/ already_AddRefed<GLContext>
GLContextProviderEGL::CreateHeadless(CreateContextFlags flags, nsACString& aFailureId)
GLContextProviderEGL::CreateHeadless(CreateContextFlags flags,
nsACString* const out_failureId)
{
mozilla::gfx::IntSize dummySize = mozilla::gfx::IntSize(16, 16);
SurfaceCaps dummyCaps = SurfaceCaps::Any();
return GLContextEGL::CreateEGLPBufferOffscreenContext(flags, dummySize, dummyCaps,
aFailureId);
out_failureId);
}
// Under EGL, on Android, pbuffers are supported fine, though
@ -1008,11 +996,11 @@ GLContextProviderEGL::CreateHeadless(CreateContextFlags flags, nsACString& aFail
GLContextProviderEGL::CreateOffscreen(const mozilla::gfx::IntSize& size,
const SurfaceCaps& minCaps,
CreateContextFlags flags,
nsACString& aFailureId)
nsACString* const out_failureId)
{
bool forceEnableHardware = bool(flags & CreateContextFlags::FORCE_ENABLE_HARDWARE);
if (!sEGLLibrary.EnsureInitialized(forceEnableHardware, aFailureId)) { // Needed for IsANGLE().
aFailureId = NS_LITERAL_CSTRING("FEATURE_FAILURE_EGL_LIB_INIT");
if (!sEGLLibrary.EnsureInitialized(forceEnableHardware, out_failureId)) { // Needed for IsANGLE().
*out_failureId = NS_LITERAL_CSTRING("FEATURE_FAILURE_EGL_LIB_INIT");
return nullptr;
}
@ -1026,7 +1014,7 @@ GLContextProviderEGL::CreateOffscreen(const mozilla::gfx::IntSize& size,
SurfaceCaps minOffscreenCaps = minCaps;
if (canOffscreenUseHeadless) {
gl = CreateHeadless(flags, aFailureId);
gl = CreateHeadless(flags, out_failureId);
if (!gl) {
return nullptr;
}
@ -1038,11 +1026,11 @@ GLContextProviderEGL::CreateOffscreen(const mozilla::gfx::IntSize& size,
minBackbufferCaps.stencil = false;
}
gl = GLContextEGL::CreateEGLPBufferOffscreenContext(flags, size, minBackbufferCaps,
aFailureId);
if (!gl) {
gl = GLContextEGL::CreateEGLPBufferOffscreenContext(flags, size,
minBackbufferCaps,
out_failureId);
if (!gl)
return nullptr;
}
// Pull the actual resulting caps to ensure that our offscreen matches our
// backbuffer.
@ -1057,7 +1045,7 @@ GLContextProviderEGL::CreateOffscreen(const mozilla::gfx::IntSize& size,
// Init the offscreen with the updated offscreen caps.
if (!gl->InitOffscreen(size, minOffscreenCaps)) {
aFailureId = NS_LITERAL_CSTRING("FEATURE_FAILURE_EGL_OFFSCREEN");
*out_failureId = NS_LITERAL_CSTRING("FEATURE_FAILURE_EGL_OFFSCREEN");
return nullptr;
}

View File

@ -6,7 +6,7 @@
#ifdef MOZ_WIDGET_GTK
#include <gdk/gdk.h>
#include <gdk/gdkx.h>
#define GET_NATIVE_WINDOW(aWidget) GDK_WINDOW_XID((GdkWindow *) aWidget->GetNativeData(NS_NATIVE_WINDOW))
#define GET_NATIVE_WINDOW(aWidget) GDK_WINDOW_XID((GdkWindow*) aWidget->GetNativeData(NS_NATIVE_WINDOW))
#elif defined(MOZ_WIDGET_QT)
#define GET_NATIVE_WINDOW(aWidget) (Window)(aWidget->GetNativeData(NS_NATIVE_SHAREABLE_WINDOW))
#endif
@ -180,7 +180,7 @@ GLXLibrary::EnsureInitialized()
return false;
}
Display *display = DefaultXDisplay();
Display* display = DefaultXDisplay();
int screen = DefaultScreen(display);
if (!xQueryVersion(display, &mGLXMajorVersion, &mGLXMinorVersion)) {
@ -193,11 +193,11 @@ GLXLibrary::EnsureInitialized()
// Not possible to query for extensions.
return false;
const char *clientVendor = xGetClientString(display, LOCAL_GLX_VENDOR);
const char *serverVendor = xQueryServerString(display, screen, LOCAL_GLX_VENDOR);
const char *extensionsStr = xQueryExtensionsString(display, screen);
const char* clientVendor = xGetClientString(display, LOCAL_GLX_VENDOR);
const char* serverVendor = xQueryServerString(display, screen, LOCAL_GLX_VENDOR);
const char* extensionsStr = xQueryExtensionsString(display, screen);
GLLibraryLoader::SymLoadStruct *sym13;
GLLibraryLoader::SymLoadStruct* sym13;
if (!GLXVersionCheck(1, 3)) {
// Even if we don't have 1.3, we might have equivalent extensions
// (as on the Intel X server).
@ -213,7 +213,7 @@ GLXLibrary::EnsureInitialized()
return false;
}
GLLibraryLoader::SymLoadStruct *sym14;
GLLibraryLoader::SymLoadStruct* sym14;
if (!GLXVersionCheck(1, 4)) {
// Even if we don't have 1.4, we might have equivalent extensions
// (as on the Intel X server).
@ -299,8 +299,8 @@ GLXLibrary::CreatePixmap(gfxASurface* aSurface)
return None;
}
gfxXlibSurface *xs = static_cast<gfxXlibSurface*>(aSurface);
const XRenderPictFormat *format = xs->XRenderFormat();
gfxXlibSurface* xs = static_cast<gfxXlibSurface*>(aSurface);
const XRenderPictFormat* format = xs->XRenderFormat();
if (!format || format->type != PictTypeDirect) {
return None;
}
@ -318,7 +318,7 @@ GLXLibrary::CreatePixmap(gfxASurface* aSurface)
None };
int numConfigs = 0;
Display *display = xs->XDisplay();
Display* display = xs->XDisplay();
int xscreen = DefaultScreen(display);
ScopedXFree<GLXFBConfig> cfgs(xChooseFBConfig(display,
@ -341,7 +341,7 @@ GLXLibrary::CreatePixmap(gfxASurface* aSurface)
for (int i = 0; i < numConfigs; i++) {
int id = None;
sGLXLibrary.xGetFBConfigAttrib(display, cfgs[i], LOCAL_GLX_VISUAL_ID, &id);
Visual *visual;
Visual* visual;
int depth;
FindVisualAndDepth(display, id, &visual, &depth);
if (!visual ||
@ -484,9 +484,9 @@ GLXLibrary::UpdateTexImage(Display* aDisplay, GLXPixmap aPixmap)
#ifdef DEBUG
static int (*sOldErrorHandler)(Display *, XErrorEvent *);
static int (*sOldErrorHandler)(Display*, XErrorEvent*);
ScopedXErrorHandler::ErrorEvent sErrorEvent;
static int GLXErrorHandler(Display *display, XErrorEvent *ev)
static int GLXErrorHandler(Display* display, XErrorEvent* ev)
{
if (!sErrorEvent.mError.error_code) {
sErrorEvent.mError = *ev;
@ -566,7 +566,7 @@ GLXLibrary::xGetCurrentContext()
}
/* static */ void*
GLXLibrary::xGetProcAddress(const char *procName)
GLXLibrary::xGetProcAddress(const char* procName)
{
BEFORE_GLX_CALL;
void* result = sGLXLibrary.xGetProcAddressInternal(procName);
@ -577,8 +577,8 @@ GLXLibrary::xGetProcAddress(const char *procName)
GLXFBConfig*
GLXLibrary::xChooseFBConfig(Display* display,
int screen,
const int *attrib_list,
int *nelements)
const int* attrib_list,
int* nelements)
{
BEFORE_GLX_CALL;
GLXFBConfig* result = xChooseFBConfigInternal(display, screen, attrib_list, nelements);
@ -589,7 +589,7 @@ GLXLibrary::xChooseFBConfig(Display* display,
GLXFBConfig*
GLXLibrary::xGetFBConfigs(Display* display,
int screen,
int *nelements)
int* nelements)
{
BEFORE_GLX_CALL;
GLXFBConfig* result = xGetFBConfigsInternal(display, screen, nelements);
@ -613,10 +613,10 @@ GLXLibrary::xCreateNewContext(Display* display,
}
int
GLXLibrary::xGetFBConfigAttrib(Display *display,
GLXLibrary::xGetFBConfigAttrib(Display* display,
GLXFBConfig config,
int attribute,
int *value)
int* value)
{
BEFORE_GLX_CALL;
int result = xGetFBConfigAttribInternal(display, config,
@ -626,48 +626,48 @@ GLXLibrary::xGetFBConfigAttrib(Display *display,
}
void
GLXLibrary::xSwapBuffers(Display *display, GLXDrawable drawable)
GLXLibrary::xSwapBuffers(Display* display, GLXDrawable drawable)
{
BEFORE_GLX_CALL;
xSwapBuffersInternal(display, drawable);
AFTER_GLX_CALL;
}
const char *
GLXLibrary::xQueryExtensionsString(Display *display,
const char*
GLXLibrary::xQueryExtensionsString(Display* display,
int screen)
{
BEFORE_GLX_CALL;
const char *result = xQueryExtensionsStringInternal(display, screen);
const char* result = xQueryExtensionsStringInternal(display, screen);
AFTER_GLX_CALL;
return result;
}
const char *
GLXLibrary::xGetClientString(Display *display,
const char*
GLXLibrary::xGetClientString(Display* display,
int screen)
{
BEFORE_GLX_CALL;
const char *result = xGetClientStringInternal(display, screen);
const char* result = xGetClientStringInternal(display, screen);
AFTER_GLX_CALL;
return result;
}
const char *
GLXLibrary::xQueryServerString(Display *display,
const char*
GLXLibrary::xQueryServerString(Display* display,
int screen, int name)
{
BEFORE_GLX_CALL;
const char *result = xQueryServerStringInternal(display, screen, name);
const char* result = xQueryServerStringInternal(display, screen, name);
AFTER_GLX_CALL;
return result;
}
GLXPixmap
GLXLibrary::xCreatePixmap(Display *display,
GLXLibrary::xCreatePixmap(Display* display,
GLXFBConfig config,
Pixmap pixmap,
const int *attrib_list)
const int* attrib_list)
{
BEFORE_GLX_CALL;
GLXPixmap result = xCreatePixmapInternal(display, config,
@ -677,7 +677,7 @@ GLXLibrary::xCreatePixmap(Display *display,
}
GLXPixmap
GLXLibrary::xCreateGLXPixmapWithConfig(Display *display,
GLXLibrary::xCreateGLXPixmapWithConfig(Display* display,
GLXFBConfig config,
Pixmap pixmap)
{
@ -688,7 +688,7 @@ GLXLibrary::xCreateGLXPixmapWithConfig(Display *display,
}
void
GLXLibrary::xDestroyPixmap(Display *display, GLXPixmap pixmap)
GLXLibrary::xDestroyPixmap(Display* display, GLXPixmap pixmap)
{
BEFORE_GLX_CALL;
xDestroyPixmapInternal(display, pixmap);
@ -696,9 +696,9 @@ GLXLibrary::xDestroyPixmap(Display *display, GLXPixmap pixmap)
}
Bool
GLXLibrary::xQueryVersion(Display *display,
int *major,
int *minor)
GLXLibrary::xQueryVersion(Display* display,
int* major,
int* minor)
{
BEFORE_GLX_CALL;
Bool result = xQueryVersionInternal(display, major, minor);
@ -707,10 +707,10 @@ GLXLibrary::xQueryVersion(Display *display,
}
void
GLXLibrary::xBindTexImage(Display *display,
GLXLibrary::xBindTexImage(Display* display,
GLXDrawable drawable,
int buffer,
const int *attrib_list)
const int* attrib_list)
{
BEFORE_GLX_CALL;
xBindTexImageInternal(display, drawable, buffer, attrib_list);
@ -718,7 +718,7 @@ GLXLibrary::xBindTexImage(Display *display,
}
void
GLXLibrary::xReleaseTexImage(Display *display,
GLXLibrary::xReleaseTexImage(Display* display,
GLXDrawable drawable,
int buffer)
{
@ -779,16 +779,11 @@ GLXLibrary::xWaitVideoSync(int divisor, int remainder, unsigned int* count)
}
already_AddRefed<GLContextGLX>
GLContextGLX::CreateGLContext(
const SurfaceCaps& caps,
GLContextGLX* shareContext,
bool isOffscreen,
Display* display,
GLXDrawable drawable,
GLXFBConfig cfg,
bool deleteDrawable,
gfxXlibSurface* pixmap,
ContextProfile profile)
GLContextGLX::CreateGLContext(CreateContextFlags flags, const SurfaceCaps& caps,
GLContextGLX* shareContext, bool isOffscreen,
Display* display, GLXDrawable drawable, GLXFBConfig cfg,
bool deleteDrawable, gfxXlibSurface* pixmap,
ContextProfile profile)
{
GLXLibrary& glx = sGLXLibrary;
@ -796,11 +791,9 @@ GLContextGLX::CreateGLContext(
int err = glx.xGetFBConfigAttrib(display, cfg,
LOCAL_GLX_DOUBLEBUFFER, &db);
if (LOCAL_GLX_BAD_ATTRIBUTE != err) {
#ifdef DEBUG
if (DebugMode()) {
if (ShouldSpew()) {
printf("[GLX] FBConfig is %sdouble-buffered\n", db ? "" : "not ");
}
#endif
}
GLXContext context;
@ -849,16 +842,9 @@ TRY_AGAIN_NO_SHARING:
}
if (context) {
glContext = new GLContextGLX(caps,
shareContext,
isOffscreen,
display,
drawable,
context,
deleteDrawable,
db,
pixmap,
profile);
glContext = new GLContextGLX(flags, caps, shareContext, isOffscreen, display,
drawable, context, deleteDrawable, db, pixmap,
profile);
if (!glContext->Init())
error = true;
} else {
@ -1006,17 +992,18 @@ GLContextGLX::RestoreDrawable()
}
GLContextGLX::GLContextGLX(
CreateContextFlags flags,
const SurfaceCaps& caps,
GLContext* shareContext,
bool isOffscreen,
Display *aDisplay,
Display* aDisplay,
GLXDrawable aDrawable,
GLXContext aContext,
bool aDeleteDrawable,
bool aDoubleBuffered,
gfxXlibSurface *aPixmap,
gfxXlibSurface* aPixmap,
ContextProfile profile)
: GLContext(caps, shareContext, isOffscreen),//aDeleteDrawable ? true : false, aShareContext, ),
: GLContext(flags, caps, shareContext, isOffscreen),
mContext(aContext),
mDisplay(aDisplay),
mDrawable(aDrawable),
@ -1032,14 +1019,14 @@ GLContextGLX::GLContextGLX(
}
static GLContextGLX *
static GLContextGLX*
GetGlobalContextGLX()
{
return static_cast<GLContextGLX*>(GLContextProviderGLX::GetGlobalContext());
}
static bool
AreCompatibleVisuals(Visual *one, Visual *two)
AreCompatibleVisuals(Visual* one, Visual* two)
{
if (one->c_class != two->c_class) {
return false;
@ -1070,7 +1057,7 @@ GLContextProviderGLX::CreateWrappingExisting(void* aContext, void* aSurface)
if (aContext && aSurface) {
SurfaceCaps caps = SurfaceCaps::Any();
RefPtr<GLContextGLX> glContext =
new GLContextGLX(caps,
new GLContextGLX(CreateContextFlags::NONE, caps,
nullptr, // SharedContext
false, // Offscreen
(Display*)DefaultXDisplay(), // Display
@ -1090,7 +1077,7 @@ GLContextProviderGLX::CreateWrappingExisting(void* aContext, void* aSurface)
}
already_AddRefed<GLContext>
GLContextProviderGLX::CreateForWindow(nsIWidget *aWidget, bool aForceAccelerated)
GLContextProviderGLX::CreateForWindow(nsIWidget* aWidget, bool aForceAccelerated)
{
if (!sGLXLibrary.EnsureInitialized()) {
return nullptr;
@ -1103,7 +1090,7 @@ GLContextProviderGLX::CreateForWindow(nsIWidget *aWidget, bool aForceAccelerated
// performance might be suboptimal. But using the existing visual
// is a relatively safe intermediate step.
Display *display = (Display*)aWidget->GetNativeData(NS_NATIVE_DISPLAY);
Display* display = (Display*)aWidget->GetNativeData(NS_NATIVE_DISPLAY);
if (!display) {
NS_ERROR("X Display required for GLX Context provider");
return nullptr;
@ -1121,18 +1108,13 @@ GLContextProviderGLX::CreateForWindow(nsIWidget *aWidget, bool aForceAccelerated
return nullptr;
}
GLContextGLX *shareContext = GetGlobalContextGLX();
SurfaceCaps caps = SurfaceCaps::Any();
RefPtr<GLContextGLX> glContext = GLContextGLX::CreateGLContext(caps,
shareContext,
false,
display,
window,
config,
false);
return glContext.forget();
GLContextGLX* shareContext = GetGlobalContextGLX();
RefPtr<GLContextGLX> gl = GLContextGLX::CreateGLContext(CreateContextFlags::NONE,
caps, shareContext, false,
display, window, config,
false);
return gl.forget();
}
static bool
@ -1242,7 +1224,7 @@ GLContextGLX::FindFBConfigForWindow(Display* display, int screen, Window window,
}
if (sGLXLibrary.IsATI()) {
int depth;
Visual *visual;
Visual* visual;
FindVisualAndDepth(display, visid, &visual, &depth);
if (depth == windowAttrs.depth &&
AreCompatibleVisuals(windowAttrs.visual, visual)) {
@ -1264,7 +1246,8 @@ GLContextGLX::FindFBConfigForWindow(Display* display, int screen, Window window,
}
static already_AddRefed<GLContextGLX>
CreateOffscreenPixmapContext(const IntSize& size, const SurfaceCaps& minCaps, nsACString& aFailureId,
CreateOffscreenPixmapContext(CreateContextFlags flags, const IntSize& size,
const SurfaceCaps& minCaps, nsACString* const out_failureId,
ContextProfile profile = ContextProfile::OpenGLCompatibility)
{
GLXLibrary* glx = &sGLXLibrary;
@ -1322,23 +1305,24 @@ DONE_CREATING_PIXMAP:
return nullptr;
GLContextGLX* shareContext = GetGlobalContextGLX();
return GLContextGLX::CreateGLContext(minCaps, shareContext, true, display, pixmap,
config, true, surface, profile);
return GLContextGLX::CreateGLContext(flags, minCaps, shareContext, true, display,
pixmap, config, true, surface, profile);
}
/*static*/ already_AddRefed<GLContext>
GLContextProviderGLX::CreateHeadless(CreateContextFlags, nsACString& aFailureId)
GLContextProviderGLX::CreateHeadless(CreateContextFlags flags,
nsACString* const out_failureId)
{
IntSize dummySize = IntSize(16, 16);
SurfaceCaps dummyCaps = SurfaceCaps::Any();
return CreateOffscreenPixmapContext(dummySize, dummyCaps, aFailureId);
return CreateOffscreenPixmapContext(flags, dummySize, dummyCaps, out_failureId);
}
/*static*/ already_AddRefed<GLContext>
GLContextProviderGLX::CreateOffscreen(const IntSize& size,
const SurfaceCaps& minCaps,
CreateContextFlags flags,
nsACString& aFailureId)
nsACString* const out_failureId)
{
SurfaceCaps minBackbufferCaps = minCaps;
if (minCaps.antialias) {
@ -1353,12 +1337,13 @@ GLContextProviderGLX::CreateOffscreen(const IntSize& size,
}
RefPtr<GLContext> gl;
gl = CreateOffscreenPixmapContext(size, minBackbufferCaps, aFailureId, profile);
gl = CreateOffscreenPixmapContext(flags, size, minBackbufferCaps, out_failureId,
profile);
if (!gl)
return nullptr;
if (!gl->InitOffscreen(size, minCaps)) {
aFailureId = NS_LITERAL_CSTRING("FEATURE_FAILURE_GLX_INIT");
*out_failureId = NS_LITERAL_CSTRING("FEATURE_FAILURE_GLX_INIT");
return nullptr;
}
@ -1378,7 +1363,7 @@ GLContextProviderGLX::GetGlobalContext()
MOZ_RELEASE_ASSERT(!gGlobalContext, "GFX: Global GL context already initialized.");
nsCString discardFailureId;
RefPtr<GLContext> temp = CreateHeadless(CreateContextFlags::NONE, discardFailureId);
RefPtr<GLContext> temp = CreateHeadless(CreateContextFlags::NONE, &discardFailureId);
gGlobalContext = temp;
}

View File

@ -68,11 +68,11 @@ public:
CreateOffscreen(const mozilla::gfx::IntSize& size,
const SurfaceCaps& minCaps,
CreateContextFlags flags,
nsACString& failureId);
nsACString* const out_failureId);
// Just create a context. We'll add offscreen stuff ourselves.
static already_AddRefed<GLContext>
CreateHeadless(CreateContextFlags flags, nsACString& aFailureId);
CreateHeadless(CreateContextFlags flags, nsACString* const out_failureId);
/**
* Create wrapping Gecko GLContext for external gl context.

View File

@ -24,15 +24,16 @@ already_AddRefed<GLContext>
GLContextProviderNull::CreateOffscreen(const gfx::IntSize&,
const SurfaceCaps&,
CreateContextFlags,
nsACString& aFailureId)
nsACString* const out_failureId)
{
aFailureId = NS_LITERAL_CSTRING("FEATURE_FAILURE_NULL");
*out_failureId = NS_LITERAL_CSTRING("FEATURE_FAILURE_NULL");
return nullptr;
}
already_AddRefed<GLContext>
GLContextProviderNull::CreateHeadless(CreateContextFlags)
GLContextProviderNull::CreateHeadless(CreateContextFlags, nsACString* const out_failureId)
{
*out_failureId = NS_LITERAL_CSTRING("FEATURE_FAILURE_NULL");
return nullptr;
}

View File

@ -26,7 +26,7 @@ using namespace mozilla::gfx;
WGLLibrary sWGLLib;
HWND
WGLLibrary::CreateDummyWindow(HDC *aWindowDC)
WGLLibrary::CreateDummyWindow(HDC* aWindowDC)
{
WNDCLASSW wc;
if (!GetClassInfoW(GetModuleHandle(nullptr), L"GLContextWGLClass", &wc)) {
@ -177,24 +177,24 @@ WGLLibrary::EnsureInitialized()
}
GLLibraryLoader::SymLoadStruct extensionsSymbols[] = {
{ (PRFuncPtr *) &fGetExtensionsString, { "wglGetExtensionsStringARB", nullptr} },
{ (PRFuncPtr*) &fGetExtensionsString, { "wglGetExtensionsStringARB", nullptr} },
{ nullptr, { nullptr } }
};
GLLibraryLoader::SymLoadStruct robustnessSymbols[] = {
{ (PRFuncPtr *) &fCreateContextAttribs, { "wglCreateContextAttribsARB", nullptr} },
{ (PRFuncPtr*) &fCreateContextAttribs, { "wglCreateContextAttribsARB", nullptr} },
{ nullptr, { nullptr } }
};
GLLibraryLoader::SymLoadStruct dxInteropSymbols[] = {
{ (PRFuncPtr *)&fDXSetResourceShareHandle,{ "wglDXSetResourceShareHandleNV", nullptr } },
{ (PRFuncPtr *)&fDXOpenDevice, { "wglDXOpenDeviceNV", nullptr } },
{ (PRFuncPtr *)&fDXCloseDevice, { "wglDXCloseDeviceNV", nullptr } },
{ (PRFuncPtr *)&fDXRegisterObject, { "wglDXRegisterObjectNV", nullptr } },
{ (PRFuncPtr *)&fDXUnregisterObject, { "wglDXUnregisterObjectNV", nullptr } },
{ (PRFuncPtr *)&fDXObjectAccess, { "wglDXObjectAccessNV", nullptr } },
{ (PRFuncPtr *)&fDXLockObjects, { "wglDXLockObjectsNV", nullptr } },
{ (PRFuncPtr *)&fDXUnlockObjects, { "wglDXUnlockObjectsNV", nullptr } },
{ (PRFuncPtr*)&fDXSetResourceShareHandle,{ "wglDXSetResourceShareHandleNV", nullptr } },
{ (PRFuncPtr*)&fDXOpenDevice, { "wglDXOpenDeviceNV", nullptr } },
{ (PRFuncPtr*)&fDXCloseDevice, { "wglDXCloseDeviceNV", nullptr } },
{ (PRFuncPtr*)&fDXRegisterObject, { "wglDXRegisterObjectNV", nullptr } },
{ (PRFuncPtr*)&fDXUnregisterObject, { "wglDXUnregisterObjectNV", nullptr } },
{ (PRFuncPtr*)&fDXObjectAccess, { "wglDXObjectAccessNV", nullptr } },
{ (PRFuncPtr*)&fDXLockObjects, { "wglDXLockObjectsNV", nullptr } },
{ (PRFuncPtr*)&fDXUnlockObjects, { "wglDXUnlockObjectsNV", nullptr } },
{ nullptr, { nullptr } }
};
@ -266,14 +266,10 @@ WGLLibrary::EnsureInitialized()
return true;
}
GLContextWGL::GLContextWGL(
const SurfaceCaps& caps,
GLContext* sharedContext,
bool isOffscreen,
HDC aDC,
HGLRC aContext,
HWND aWindow)
: GLContext(caps, sharedContext, isOffscreen),
GLContextWGL::GLContextWGL(CreateContextFlags flags, const SurfaceCaps& caps,
GLContext* sharedContext, bool isOffscreen, HDC aDC,
HGLRC aContext, HWND aWindow)
: GLContext(flags, caps, sharedContext, isOffscreen),
mDC(aDC),
mContext(aContext),
mWnd(aWindow),
@ -285,15 +281,10 @@ GLContextWGL::GLContextWGL(
SetProfileVersion(ContextProfile::OpenGLCompatibility, 200);
}
GLContextWGL::GLContextWGL(
const SurfaceCaps& caps,
GLContext* sharedContext,
bool isOffscreen,
HANDLE aPbuffer,
HDC aDC,
HGLRC aContext,
int aPixelFormat)
: GLContext(caps, sharedContext, isOffscreen),
GLContextWGL::GLContextWGL(CreateContextFlags flags, const SurfaceCaps& caps,
GLContext* sharedContext, bool isOffscreen, HANDLE aPbuffer,
HDC aDC, HGLRC aContext, int aPixelFormat)
: GLContext(flags, caps, sharedContext, isOffscreen),
mDC(aDC),
mContext(aContext),
mWnd(nullptr),
@ -401,7 +392,7 @@ GetMaxSize(HDC hDC, int format, IntSize& size)
int query[] = {LOCAL_WGL_MAX_PBUFFER_WIDTH_ARB, LOCAL_WGL_MAX_PBUFFER_HEIGHT_ARB};
int result[2];
// (HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, int* piAttributes, int *piValues)
// (HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, int* piAttributes, int* piValues)
if (!sWGLLib.fGetPixelFormatAttribiv(hDC, format, 0, 2, query, result))
return false;
@ -439,7 +430,7 @@ GLContextProviderWGL::CreateWrappingExisting(void*, void*)
}
already_AddRefed<GLContext>
GLContextProviderWGL::CreateForWindow(nsIWidget *aWidget, bool aForceAccelerated)
GLContextProviderWGL::CreateForWindow(nsIWidget* aWidget, bool aForceAccelerated)
{
if (!sWGLLib.EnsureInitialized()) {
return nullptr;
@ -456,7 +447,7 @@ GLContextProviderWGL::CreateForWindow(nsIWidget *aWidget, bool aForceAccelerated
SetPixelFormat(dc, sWGLLib.GetWindowPixelFormat(), nullptr);
HGLRC context;
GLContextWGL *shareContext = GetGlobalContextWGL();
GLContextWGL* shareContext = GetGlobalContextWGL();
if (sWGLLib.HasRobustness()) {
int attribs[] = {
@ -485,7 +476,8 @@ GLContextProviderWGL::CreateForWindow(nsIWidget *aWidget, bool aForceAccelerated
}
SurfaceCaps caps = SurfaceCaps::ForRGBA();
RefPtr<GLContextWGL> glContext = new GLContextWGL(caps,
RefPtr<GLContextWGL> glContext = new GLContextWGL(CreateContextFlags::NONE,
caps,
shareContext,
false,
dc,
@ -500,8 +492,8 @@ GLContextProviderWGL::CreateForWindow(nsIWidget *aWidget, bool aForceAccelerated
}
static already_AddRefed<GLContextWGL>
CreatePBufferOffscreenContext(const IntSize& aSize,
GLContextWGL *aShareContext)
CreatePBufferOffscreenContext(CreateContextFlags flags, const IntSize& aSize,
GLContextWGL* aShareContext)
{
WGLLibrary& wgl = sWGLLib;
@ -580,7 +572,7 @@ CreatePBufferOffscreenContext(const IntSize& aSize,
}
SurfaceCaps dummyCaps = SurfaceCaps::Any();
RefPtr<GLContextWGL> glContext = new GLContextWGL(dummyCaps,
RefPtr<GLContextWGL> glContext = new GLContextWGL(flags, dummyCaps,
aShareContext,
true,
pbuffer,
@ -595,7 +587,7 @@ static already_AddRefed<GLContextWGL>
CreateWindowOffscreenContext()
{
// CreateWindowOffscreenContext must return a global-shared context
GLContextWGL *shareContext = GetGlobalContextWGL();
GLContextWGL* shareContext = GetGlobalContextWGL();
if (!shareContext) {
return nullptr;
}
@ -633,15 +625,16 @@ CreateWindowOffscreenContext()
}
SurfaceCaps caps = SurfaceCaps::ForRGBA();
RefPtr<GLContextWGL> glContext = new GLContextWGL(caps,
shareContext, true,
dc, context, win);
RefPtr<GLContextWGL> glContext = new GLContextWGL(CreateContextFlags::NONE, caps,
shareContext, true, dc, context,
win);
return glContext.forget();
}
/*static*/ already_AddRefed<GLContext>
GLContextProviderWGL::CreateHeadless(CreateContextFlags, nsACString& aFailureId)
GLContextProviderWGL::CreateHeadless(CreateContextFlags flags,
nsACString* const out_failureId)
{
if (!sWGLLib.EnsureInitialized()) {
return nullptr;
@ -655,7 +648,8 @@ GLContextProviderWGL::CreateHeadless(CreateContextFlags, nsACString& aFailureId)
sWGLLib.fChoosePixelFormat)
{
IntSize dummySize = IntSize(16, 16);
glContext = CreatePBufferOffscreenContext(dummySize, GetGlobalContextWGL());
glContext = CreatePBufferOffscreenContext(flags, dummySize,
GetGlobalContextWGL());
}
// If it failed, then create a window context and use a FBO.
@ -677,14 +671,14 @@ GLContextProviderWGL::CreateHeadless(CreateContextFlags, nsACString& aFailureId)
GLContextProviderWGL::CreateOffscreen(const IntSize& size,
const SurfaceCaps& minCaps,
CreateContextFlags flags,
nsACString& aFailureId)
nsACString* const out_failureId)
{
RefPtr<GLContext> gl = CreateHeadless(flags, aFailureId);
RefPtr<GLContext> gl = CreateHeadless(flags, out_failureId);
if (!gl)
return nullptr;
if (!gl->InitOffscreen(size, minCaps)) {
aFailureId = NS_LITERAL_CSTRING("FEATURE_FAILURE_WGL_INIT");
*out_failureId = NS_LITERAL_CSTRING("FEATURE_FAILURE_WGL_INIT");
return nullptr;
}
@ -702,7 +696,8 @@ GLContextProviderWGL::GetGlobalContext()
MOZ_RELEASE_ASSERT(!gGlobalContext, "GFX: Global GL context already initialized.");
nsCString discardFailureId;
RefPtr<GLContext> temp = CreateHeadless(CreateContextFlags::NONE, discardFailureId);
RefPtr<GLContext> temp = CreateHeadless(CreateContextFlags::NONE,
&discardFailureId);
gGlobalContext = temp;
}

View File

@ -79,9 +79,9 @@ struct GLContextSymbols
PFNGLCLEARSTENCILPROC fClearStencil;
typedef void (GLAPIENTRY * PFNGLCOLORMASKPROC) (realGLboolean red, realGLboolean green, realGLboolean blue, realGLboolean alpha);
PFNGLCOLORMASKPROC fColorMask;
typedef void (GLAPIENTRY * PFNGLCOMPRESSEDTEXIMAGE2D) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid *pixels);
typedef void (GLAPIENTRY * PFNGLCOMPRESSEDTEXIMAGE2D) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid* pixels);
PFNGLCOMPRESSEDTEXIMAGE2D fCompressedTexImage2D;
typedef void (GLAPIENTRY * PFNGLCOMPRESSEDTEXSUBIMAGE2D) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid *pixels);
typedef void (GLAPIENTRY * PFNGLCOMPRESSEDTEXSUBIMAGE2D) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid* pixels);
PFNGLCOMPRESSEDTEXSUBIMAGE2D fCompressedTexSubImage2D;
typedef void (GLAPIENTRY * PFNGLCULLFACEPROC) (GLenum mode);
PFNGLCULLFACEPROC fCullFace;
@ -101,7 +101,7 @@ struct GLContextSymbols
PFNGLDRAWBUFFERPROC fDrawBuffer;
typedef void (GLAPIENTRY * PFNGLDRAWBUFFERSPROC) (GLsizei n, const GLenum* bufs);
PFNGLDRAWBUFFERSPROC fDrawBuffers;
typedef void (GLAPIENTRY * PFNGLDRAWELEMENTSPROC) (GLenum mode, GLsizei count, GLenum type, const GLvoid *indices);
typedef void (GLAPIENTRY * PFNGLDRAWELEMENTSPROC) (GLenum mode, GLsizei count, GLenum type, const GLvoid* indices);
PFNGLDRAWELEMENTSPROC fDrawElements;
typedef void (GLAPIENTRY * PFNGLENABLEPROC) (GLenum);
PFNGLENABLEPROC fEnable;
@ -123,11 +123,11 @@ struct GLContextSymbols
PFNGLGETATTACHEDSHADERSPROC fGetAttachedShaders;
typedef GLint (GLAPIENTRY * PFNGLGETATTRIBLOCATIONPROC) (GLuint program, const GLchar* name);
PFNGLGETATTRIBLOCATIONPROC fGetAttribLocation;
typedef void (GLAPIENTRY * PFNGLGETINTEGERVPROC) (GLenum pname, GLint *params);
typedef void (GLAPIENTRY * PFNGLGETINTEGERVPROC) (GLenum pname, GLint* params);
PFNGLGETINTEGERVPROC fGetIntegerv;
typedef void (GLAPIENTRY * PFNGLGETFLOATVPROC) (GLenum pname, GLfloat *params);
typedef void (GLAPIENTRY * PFNGLGETFLOATVPROC) (GLenum pname, GLfloat* params);
PFNGLGETFLOATVPROC fGetFloatv;
typedef void (GLAPIENTRY * PFNGLGETBOOLEANBPROC) (GLenum pname, realGLboolean *params);
typedef void (GLAPIENTRY * PFNGLGETBOOLEANBPROC) (GLenum pname, realGLboolean* params);
PFNGLGETBOOLEANBPROC fGetBooleanv;
typedef void (GLAPIENTRY * PFNGLGETBUFFERPARAMETERIVPROC) (GLenum target, GLenum pname, GLint* params);
PFNGLGETBUFFERPARAMETERIVPROC fGetBufferParameteriv;
@ -161,11 +161,11 @@ struct GLContextSymbols
PFNGLGETSTRINGPROC fGetString;
typedef void (GLAPIENTRY * PFNGLGETTEXIMAGEPROC) (GLenum target, GLint level, GLenum format, GLenum type, GLvoid* image);
PFNGLGETTEXIMAGEPROC fGetTexImage;
typedef void (GLAPIENTRY * PFNGLGETTEXLEVELPARAMETERIVPROC) (GLenum target, GLint level, GLenum pname, GLint *params);
typedef void (GLAPIENTRY * PFNGLGETTEXLEVELPARAMETERIVPROC) (GLenum target, GLint level, GLenum pname, GLint* params);
PFNGLGETTEXLEVELPARAMETERIVPROC fGetTexLevelParameteriv;
typedef void (GLAPIENTRY * PFNGLGETTEXPARAMETERFVPROC) (GLenum target, GLenum pname, GLfloat *params);
typedef void (GLAPIENTRY * PFNGLGETTEXPARAMETERFVPROC) (GLenum target, GLenum pname, GLfloat* params);
PFNGLGETTEXPARAMETERFVPROC fGetTexParameterfv;
typedef void (GLAPIENTRY * PFNGLGETTEXPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params);
typedef void (GLAPIENTRY * PFNGLGETTEXPARAMETERIVPROC) (GLenum target, GLenum pname, GLint* params);
PFNGLGETTEXPARAMETERIVPROC fGetTexParameteriv;
typedef void (GLAPIENTRY * PFNGLGETUNIFORMFVPROC) (GLuint program, GLint location, GLfloat* params);
PFNGLGETUNIFORMFVPROC fGetUniformfv;
@ -207,7 +207,7 @@ struct GLContextSymbols
PFNGLPOLYGONOFFSETPROC fPolygonOffset;
typedef void (GLAPIENTRY * PFNGLREADBUFFERPROC) (GLenum);
PFNGLREADBUFFERPROC fReadBuffer;
typedef void (GLAPIENTRY * PFNGLREADPIXELSPROC) (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLvoid *pixels);
typedef void (GLAPIENTRY * PFNGLREADPIXELSPROC) (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLvoid* pixels);
PFNGLREADPIXELSPROC fReadPixels;
typedef void (GLAPIENTRY * PFNGLSAMPLECOVERAGEPROC) (GLclampf value, realGLboolean invert);
PFNGLSAMPLECOVERAGEPROC fSampleCoverage;
@ -223,11 +223,11 @@ struct GLContextSymbols
PFNGLSTENCILOPPROC fStencilOp;
typedef void (GLAPIENTRY * PFNGLSTENCILOPSEPARATEPROC) (GLenum face, GLenum sfail, GLenum dpfail, GLenum dppass);
PFNGLSTENCILOPSEPARATEPROC fStencilOpSeparate;
typedef void (GLAPIENTRY * PFNGLTEXIMAGE2DPROC) (GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid *pixels);
typedef void (GLAPIENTRY * PFNGLTEXIMAGE2DPROC) (GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid* pixels);
PFNGLTEXIMAGE2DPROC fTexImage2D;
typedef void (GLAPIENTRY * PFNGLTEXSUBIMAGE2DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const void* pixels);
PFNGLTEXSUBIMAGE2DPROC fTexSubImage2D;
typedef void (GLAPIENTRY * PFNGLTEXTURERANGEAPPLEPROC) (GLenum target, GLsizei length, GLvoid *pointer);
typedef void (GLAPIENTRY * PFNGLTEXTURERANGEAPPLEPROC) (GLenum target, GLsizei length, GLvoid* pointer);
PFNGLTEXTURERANGEAPPLEPROC fTextureRangeAPPLE;
typedef void (GLAPIENTRY * PFNGLUNIFORM1FPROC) (GLint location, GLfloat v0);
PFNGLUNIFORM1FPROC fUniform1f;
@ -417,7 +417,7 @@ struct GLContextSymbols
PFNGLGENBUFFERSPROC fGenBuffers;
typedef void (GLAPIENTRY * PFNGLGENQUERIESPROC) (GLsizei n, GLuint* queries);
PFNGLGENQUERIESPROC fGenQueries;
typedef void (GLAPIENTRY * PFNGLGENTEXTURESPROC) (GLsizei n, GLuint *textures);
typedef void (GLAPIENTRY * PFNGLGENTEXTURESPROC) (GLsizei n, GLuint* textures);
PFNGLGENTEXTURESPROC fGenTextures;
typedef void (GLAPIENTRY * PFNGLGENFRAMEBUFFERS) (GLsizei n, GLuint* ids);
PFNGLGENFRAMEBUFFERS fGenFramebuffers;
@ -468,9 +468,9 @@ struct GLContextSymbols
PFNGLCLIENTWAITSYNC fClientWaitSync;
typedef void (GLAPIENTRY * PFNGLWAITSYNC) (GLsync sync, GLbitfield flags, GLuint64 timeout);
PFNGLWAITSYNC fWaitSync;
typedef void (GLAPIENTRY * PFNGLGETINTEGER64V) (GLenum pname, GLint64 *params);
typedef void (GLAPIENTRY * PFNGLGETINTEGER64V) (GLenum pname, GLint64* params);
PFNGLGETINTEGER64V fGetInteger64v;
typedef void (GLAPIENTRY * PFNGLGETSYNCIV) (GLsync sync, GLenum pname, GLsizei bufSize, GLsizei *length, GLint *values);
typedef void (GLAPIENTRY * PFNGLGETSYNCIV) (GLsync sync, GLenum pname, GLsizei bufSize, GLsizei* length, GLint* values);
PFNGLGETSYNCIV fGetSynciv;
// OES_egl_image
@ -580,9 +580,9 @@ struct GLContextSymbols
PFNGLFLUSHMAPPEDBUFFERRANGEPROC fFlushMappedBufferRange;
// sampler_object
typedef void (GLAPIENTRY * PFNGLGENSAMPLERSPROC) (GLsizei count, GLuint *samplers);
typedef void (GLAPIENTRY * PFNGLGENSAMPLERSPROC) (GLsizei count, GLuint* samplers);
PFNGLGENSAMPLERSPROC fGenSamplers;
typedef void (GLAPIENTRY * PFNGLDELETESAMPLERSPROC) (GLsizei count, const GLuint *samplers);
typedef void (GLAPIENTRY * PFNGLDELETESAMPLERSPROC) (GLsizei count, const GLuint* samplers);
PFNGLDELETESAMPLERSPROC fDeleteSamplers;
typedef realGLboolean (GLAPIENTRY * PFNGLISSAMPLERPROC) (GLuint sampler);
PFNGLISSAMPLERPROC fIsSampler;
@ -590,15 +590,15 @@ struct GLContextSymbols
PFNGLBINDSAMPLERPROC fBindSampler;
typedef void (GLAPIENTRY * PFNGLSAMPLERPARAMETERIPROC) (GLuint sampler, GLenum pname, GLint param);
PFNGLSAMPLERPARAMETERIPROC fSamplerParameteri;
typedef void (GLAPIENTRY * PFNGLSAMPLERPARAMETERIVPROC) (GLuint sampler, GLenum pname, const GLint *param);
typedef void (GLAPIENTRY * PFNGLSAMPLERPARAMETERIVPROC) (GLuint sampler, GLenum pname, const GLint* param);
PFNGLSAMPLERPARAMETERIVPROC fSamplerParameteriv;
typedef void (GLAPIENTRY * PFNGLSAMPLERPARAMETERFPROC) (GLuint sampler, GLenum pname, GLfloat param);
PFNGLSAMPLERPARAMETERFPROC fSamplerParameterf;
typedef void (GLAPIENTRY * PFNGLSAMPLERPARAMETERFVPROC) (GLuint sampler, GLenum pname, const GLfloat *param);
typedef void (GLAPIENTRY * PFNGLSAMPLERPARAMETERFVPROC) (GLuint sampler, GLenum pname, const GLfloat* param);
PFNGLSAMPLERPARAMETERFVPROC fSamplerParameterfv;
typedef void (GLAPIENTRY * PFNGLGETSAMPLERPARAMETERIVPROC) (GLuint sampler, GLenum pname, GLint *params);
typedef void (GLAPIENTRY * PFNGLGETSAMPLERPARAMETERIVPROC) (GLuint sampler, GLenum pname, GLint* params);
PFNGLGETSAMPLERPARAMETERIVPROC fGetSamplerParameteriv;
typedef void (GLAPIENTRY * PFNGLGETSAMPLERPARAMETERFVPROC) (GLuint sampler, GLenum pname, GLfloat *params);
typedef void (GLAPIENTRY * PFNGLGETSAMPLERPARAMETERFVPROC) (GLuint sampler, GLenum pname, GLfloat* params);
PFNGLGETSAMPLERPARAMETERFVPROC fGetSamplerParameterfv;
// texture_storage

View File

@ -54,6 +54,8 @@ enum class CreateContextFlags : int8_t {
ALLOW_OFFLINE_RENDERER = 1 << 2,
// Ask for ES3 if possible
PREFER_ES3 = 1 << 3,
NO_VALIDATION = 1 << 4,
};
MOZ_MAKE_ENUM_CLASS_BITWISE_OPERATORS(CreateContextFlags)

View File

@ -18,7 +18,8 @@ class GLContextWGL : public GLContext
public:
MOZ_DECLARE_REFCOUNTED_VIRTUAL_TYPENAME(GLContextWGL, override)
// From Window: (possibly for offscreen!)
GLContextWGL(const SurfaceCaps& caps,
GLContextWGL(CreateContextFlags flags,
const SurfaceCaps& caps,
GLContext* sharedContext,
bool isOffscreen,
HDC aDC,
@ -26,7 +27,8 @@ public:
HWND aWindow = nullptr);
// From PBuffer
GLContextWGL(const SurfaceCaps& caps,
GLContextWGL(CreateContextFlags flags,
const SurfaceCaps& caps,
GLContext* sharedContext,
bool isOffscreen,
HANDLE aPbuffer,

View File

@ -35,7 +35,7 @@ MOZ_THREAD_LOCAL(EGLContext) GLLibraryEGL::sCurrentContext;
#endif
// should match the order of EGLExtensions, and be null-terminated.
static const char *sEGLExtensionNames[] = {
static const char* sEGLExtensionNames[] = {
"EGL_KHR_image_base",
"EGL_KHR_image_pixmap",
"EGL_KHR_gl_texture_2D_image",
@ -129,7 +129,7 @@ GetAndInitWARPDisplay(GLLibraryEGL& egl, void* displayType)
if (display == EGL_NO_DISPLAY) {
const EGLint err = egl.fGetError();
if (err != LOCAL_EGL_SUCCESS) {
gfxCriticalError() << "Unexpected GL error: " << gfx::hexa(err);
gfxCriticalError() << "Unexpected GL error: " << gfx::hexa(err);
MOZ_CRASH("GFX: Unexpected GL error.");
}
return EGL_NO_DISPLAY;
@ -142,7 +142,8 @@ GetAndInitWARPDisplay(GLLibraryEGL& egl, void* displayType)
}
static bool
IsAccelAngleSupported(const nsCOMPtr<nsIGfxInfo>& gfxInfo, nsACString& aFailureId)
IsAccelAngleSupported(const nsCOMPtr<nsIGfxInfo>& gfxInfo,
nsACString* const out_failureId)
{
int32_t angleSupport;
nsCString failureId;
@ -153,7 +154,7 @@ IsAccelAngleSupported(const nsCOMPtr<nsIGfxInfo>& gfxInfo, nsACString& aFailureI
Telemetry::Accumulate(Telemetry::CANVAS_WEBGL_ACCL_FAILURE_ID,
failureId);
if (failureId.IsEmpty()) {
aFailureId = failureId;
*out_failureId = failureId;
}
return (angleSupport == nsIGfxInfo::FEATURE_STATUS_OK);
}
@ -206,7 +207,7 @@ GLLibraryEGL::ReadbackEGLImage(EGLImage image, gfx::DataSourceSurface* out_surfa
if (!mReadbackGL) {
nsCString discardFailureId;
mReadbackGL = gl::GLContextProvider::CreateHeadless(gl::CreateContextFlags::NONE,
discardFailureId);
&discardFailureId);
}
ScopedTexture destTex(mReadbackGL);
@ -228,7 +229,7 @@ GLLibraryEGL::ReadbackEGLImage(EGLImage image, gfx::DataSourceSurface* out_surfa
}
bool
GLLibraryEGL::EnsureInitialized(bool forceAccel, nsACString& aFailureId)
GLLibraryEGL::EnsureInitialized(bool forceAccel, nsACString* const out_failureId)
{
if (mInitialized) {
return true;
@ -394,7 +395,7 @@ GLLibraryEGL::EnsureInitialized(bool forceAccel, nsACString& aFailureId)
EGLDisplay chosenDisplay = nullptr;
if (IsExtensionSupported(ANGLE_platform_angle_d3d)) {
bool accelAngleSupport = IsAccelAngleSupported(gfxInfo, aFailureId);
bool accelAngleSupport = IsAccelAngleSupported(gfxInfo, out_failureId);
bool shouldTryAccel = forceAccel || accelAngleSupport;
bool shouldTryWARP = !shouldTryAccel;
@ -415,8 +416,8 @@ GLLibraryEGL::EnsureInitialized(bool forceAccel, nsACString& aFailureId)
// If falling back to WARP did not work and we don't want to try
// using HW accelerated ANGLE, then fail.
if (!shouldTryAccel) {
if (aFailureId.IsEmpty()) {
aFailureId = NS_LITERAL_CSTRING("FEATURE_FAILURE_WARP_FALLBACK");
if (out_failureId->IsEmpty()) {
*out_failureId = NS_LITERAL_CSTRING("FEATURE_FAILURE_WARP_FALLBACK");
}
NS_ERROR("Fallback WARP ANGLE context failed to initialize.");
return false;
@ -430,8 +431,8 @@ GLLibraryEGL::EnsureInitialized(bool forceAccel, nsACString& aFailureId)
}
if (!chosenDisplay) {
if (aFailureId.IsEmpty()) {
aFailureId = NS_LITERAL_CSTRING("FEATURE_FAILURE_NO_DISPLAY");
if (out_failureId->IsEmpty()) {
*out_failureId = NS_LITERAL_CSTRING("FEATURE_FAILURE_NO_DISPLAY");
}
NS_WARNING("Failed to initialize a display.");
return false;
@ -672,11 +673,11 @@ GLLibraryEGL::DumpEGLConfigs()
{
int nc = 0;
fGetConfigs(mEGLDisplay, nullptr, 0, &nc);
EGLConfig *ec = new EGLConfig[nc];
EGLConfig* ec = new EGLConfig[nc];
fGetConfigs(mEGLDisplay, ec, nc, &nc);
for (int i = 0; i < nc; ++i) {
printf_stderr ("========= EGL Config %d ========\n", i);
printf_stderr("========= EGL Config %d ========\n", i);
DumpEGLConfig(ec[i]);
}
@ -684,19 +685,25 @@ GLLibraryEGL::DumpEGLConfigs()
}
#ifdef DEBUG
static bool
ShouldTrace()
{
static bool ret = gfxEnv::GlDebugVerbose();
return ret;
}
/*static*/ void
GLLibraryEGL::BeforeGLCall(const char* glFunction)
{
if (GLContext::DebugMode()) {
if (GLContext::DebugMode() & GLContext::DebugTrace)
printf_stderr("[egl] > %s\n", glFunction);
if (ShouldTrace()) {
printf_stderr("[egl] > %s\n", glFunction);
}
}
/*static*/ void
GLLibraryEGL::AfterGLCall(const char* glFunction)
{
if (GLContext::DebugMode() & GLContext::DebugTrace) {
if (ShouldTrace()) {
printf_stderr("[egl] < %s\n", glFunction);
}
}

View File

@ -251,7 +251,7 @@ public:
return b;
}
EGLContext fCreateContext(EGLDisplay dpy, EGLConfig config, EGLContext share_context, const EGLint *attrib_list)
EGLContext fCreateContext(EGLDisplay dpy, EGLConfig config, EGLContext share_context, const EGLint* attrib_list)
{
BEFORE_GL_CALL;
EGLContext ctx = mSymbols.fCreateContext(dpy, config, share_context, attrib_list);
@ -267,7 +267,7 @@ public:
return b;
}
EGLSurface fCreateWindowSurface(EGLDisplay dpy, EGLConfig config, EGLNativeWindowType win, const EGLint *attrib_list)
EGLSurface fCreateWindowSurface(EGLDisplay dpy, EGLConfig config, EGLNativeWindowType win, const EGLint* attrib_list)
{
BEFORE_GL_CALL;
EGLSurface surf = mSymbols.fCreateWindowSurface(dpy, config, win, attrib_list);
@ -275,7 +275,7 @@ public:
return surf;
}
EGLSurface fCreatePbufferSurface(EGLDisplay dpy, EGLConfig config, const EGLint *attrib_list)
EGLSurface fCreatePbufferSurface(EGLDisplay dpy, EGLConfig config, const EGLint* attrib_list)
{
BEFORE_GL_CALL;
EGLSurface surf = mSymbols.fCreatePbufferSurface(dpy, config, attrib_list);
@ -283,7 +283,7 @@ public:
return surf;
}
EGLSurface fCreatePixmapSurface(EGLDisplay dpy, EGLConfig config, EGLNativePixmapType pixmap, const EGLint *attrib_list)
EGLSurface fCreatePixmapSurface(EGLDisplay dpy, EGLConfig config, EGLNativePixmapType pixmap, const EGLint* attrib_list)
{
BEFORE_GL_CALL;
EGLSurface surf = mSymbols.fCreatePixmapSurface(dpy, config, pixmap, attrib_list);
@ -307,7 +307,7 @@ public:
return b;
}
EGLBoolean fChooseConfig(EGLDisplay dpy, const EGLint *attrib_list, EGLConfig *configs, EGLint config_size, EGLint *num_config)
EGLBoolean fChooseConfig(EGLDisplay dpy, const EGLint* attrib_list, EGLConfig* configs, EGLint config_size, EGLint* num_config)
{
BEFORE_GL_CALL;
EGLBoolean b = mSymbols.fChooseConfig(dpy, attrib_list, configs, config_size, num_config);
@ -323,7 +323,7 @@ public:
return i;
}
EGLBoolean fGetConfigAttrib(EGLDisplay dpy, EGLConfig config, EGLint attribute, EGLint *value)
EGLBoolean fGetConfigAttrib(EGLDisplay dpy, EGLConfig config, EGLint attribute, EGLint* value)
{
BEFORE_GL_CALL;
EGLBoolean b = mSymbols.fGetConfigAttrib(dpy, config, attribute, value);
@ -331,7 +331,7 @@ public:
return b;
}
EGLBoolean fGetConfigs(EGLDisplay dpy, EGLConfig *configs, EGLint config_size, EGLint *num_config)
EGLBoolean fGetConfigs(EGLDisplay dpy, EGLConfig* configs, EGLint config_size, EGLint* num_config)
{
BEFORE_GL_CALL;
EGLBoolean b = mSymbols.fGetConfigs(dpy, configs, config_size, num_config);
@ -347,7 +347,7 @@ public:
return b;
}
EGLCastToRelevantPtr fGetProcAddress(const char *procname)
EGLCastToRelevantPtr fGetProcAddress(const char* procname)
{
BEFORE_GL_CALL;
EGLCastToRelevantPtr p = mSymbols.fGetProcAddress(procname);
@ -384,7 +384,7 @@ public:
return b;
}
EGLBoolean fQueryContext(EGLDisplay dpy, EGLContext ctx, EGLint attribute, EGLint *value)
EGLBoolean fQueryContext(EGLDisplay dpy, EGLContext ctx, EGLint attribute, EGLint* value)
{
BEFORE_GL_CALL;
EGLBoolean b = mSymbols.fQueryContext(dpy, ctx, attribute, value);
@ -408,7 +408,7 @@ public:
return b;
}
EGLImage fCreateImage(EGLDisplay dpy, EGLContext ctx, EGLenum target, EGLClientBuffer buffer, const EGLint *attrib_list)
EGLImage fCreateImage(EGLDisplay dpy, EGLContext ctx, EGLenum target, EGLClientBuffer buffer, const EGLint* attrib_list)
{
BEFORE_GL_CALL;
EGLImage i = mSymbols.fCreateImage(dpy, ctx, target, buffer, attrib_list);
@ -425,7 +425,7 @@ public:
}
// New extension which allow us to lock texture and get raw image pointer
EGLBoolean fLockSurface(EGLDisplay dpy, EGLSurface surface, const EGLint *attrib_list)
EGLBoolean fLockSurface(EGLDisplay dpy, EGLSurface surface, const EGLint* attrib_list)
{
BEFORE_GL_CALL;
EGLBoolean b = mSymbols.fLockSurface(dpy, surface, attrib_list);
@ -441,7 +441,7 @@ public:
return b;
}
EGLBoolean fQuerySurface(EGLDisplay dpy, EGLSurface surface, EGLint attribute, EGLint *value)
EGLBoolean fQuerySurface(EGLDisplay dpy, EGLSurface surface, EGLint attribute, EGLint* value)
{
BEFORE_GL_CALL;
EGLBoolean b = mSymbols.fQuerySurface(dpy, surface, attribute, value);
@ -449,7 +449,7 @@ public:
return b;
}
EGLBoolean fQuerySurfacePointerANGLE(EGLDisplay dpy, EGLSurface surface, EGLint attribute, void **value)
EGLBoolean fQuerySurfacePointerANGLE(EGLDisplay dpy, EGLSurface surface, EGLint attribute, void** value)
{
BEFORE_GL_CALL;
EGLBoolean b = mSymbols.fQuerySurfacePointerANGLE(dpy, surface, attribute, value);
@ -457,7 +457,7 @@ public:
return b;
}
EGLSync fCreateSync(EGLDisplay dpy, EGLenum type, const EGLint *attrib_list)
EGLSync fCreateSync(EGLDisplay dpy, EGLenum type, const EGLint* attrib_list)
{
BEFORE_GL_CALL;
EGLSync ret = mSymbols.fCreateSync(dpy, type, attrib_list);
@ -481,7 +481,7 @@ public:
return ret;
}
EGLBoolean fGetSyncAttrib(EGLDisplay dpy, EGLSync sync, EGLint attribute, EGLint *value)
EGLBoolean fGetSyncAttrib(EGLDisplay dpy, EGLSync sync, EGLint attribute, EGLint* value)
{
BEFORE_GL_CALL;
EGLBoolean b = mSymbols.fGetSyncAttrib(dpy, sync, attribute, value);
@ -535,15 +535,15 @@ public:
bool ReadbackEGLImage(EGLImage image, gfx::DataSourceSurface* out_surface);
bool EnsureInitialized(bool forceAccel, nsACString& aFailureId);
bool EnsureInitialized(bool forceAccel, nsACString* const out_failureId);
void DumpEGLConfig(EGLConfig cfg);
void DumpEGLConfigs();
struct {
typedef EGLDisplay (GLAPIENTRY * pfnGetDisplay)(void *display_id);
typedef EGLDisplay (GLAPIENTRY * pfnGetDisplay)(void* display_id);
pfnGetDisplay fGetDisplay;
typedef EGLDisplay(GLAPIENTRY * pfnGetPlatformDisplayEXT)(EGLenum platform, void *native_display, const EGLint *attrib_list);
typedef EGLDisplay(GLAPIENTRY * pfnGetPlatformDisplayEXT)(EGLenum platform, void* native_display, const EGLint* attrib_list);
pfnGetPlatformDisplayEXT fGetPlatformDisplayEXT;
typedef EGLBoolean (GLAPIENTRY * pfnTerminate)(EGLDisplay dpy);
pfnTerminate fTerminate;
@ -555,31 +555,31 @@ public:
pfnMakeCurrent fMakeCurrent;
typedef EGLBoolean (GLAPIENTRY * pfnDestroyContext)(EGLDisplay dpy, EGLContext ctx);
pfnDestroyContext fDestroyContext;
typedef EGLContext (GLAPIENTRY * pfnCreateContext)(EGLDisplay dpy, EGLConfig config, EGLContext share_context, const EGLint *attrib_list);
typedef EGLContext (GLAPIENTRY * pfnCreateContext)(EGLDisplay dpy, EGLConfig config, EGLContext share_context, const EGLint* attrib_list);
pfnCreateContext fCreateContext;
typedef EGLBoolean (GLAPIENTRY * pfnDestroySurface)(EGLDisplay dpy, EGLSurface surface);
pfnDestroySurface fDestroySurface;
typedef EGLSurface (GLAPIENTRY * pfnCreateWindowSurface)(EGLDisplay dpy, EGLConfig config, EGLNativeWindowType win, const EGLint *attrib_list);
typedef EGLSurface (GLAPIENTRY * pfnCreateWindowSurface)(EGLDisplay dpy, EGLConfig config, EGLNativeWindowType win, const EGLint* attrib_list);
pfnCreateWindowSurface fCreateWindowSurface;
typedef EGLSurface (GLAPIENTRY * pfnCreatePbufferSurface)(EGLDisplay dpy, EGLConfig config, const EGLint *attrib_list);
typedef EGLSurface (GLAPIENTRY * pfnCreatePbufferSurface)(EGLDisplay dpy, EGLConfig config, const EGLint* attrib_list);
pfnCreatePbufferSurface fCreatePbufferSurface;
typedef EGLSurface (GLAPIENTRY * pfnCreatePixmapSurface)(EGLDisplay dpy, EGLConfig config, EGLNativePixmapType pixmap, const EGLint *attrib_list);
typedef EGLSurface (GLAPIENTRY * pfnCreatePixmapSurface)(EGLDisplay dpy, EGLConfig config, EGLNativePixmapType pixmap, const EGLint* attrib_list);
pfnCreatePixmapSurface fCreatePixmapSurface;
typedef EGLBoolean (GLAPIENTRY * pfnBindAPI)(EGLenum api);
pfnBindAPI fBindAPI;
typedef EGLBoolean (GLAPIENTRY * pfnInitialize)(EGLDisplay dpy, EGLint *major, EGLint *minor);
typedef EGLBoolean (GLAPIENTRY * pfnInitialize)(EGLDisplay dpy, EGLint* major, EGLint* minor);
pfnInitialize fInitialize;
typedef EGLBoolean (GLAPIENTRY * pfnChooseConfig)(EGLDisplay dpy, const EGLint *attrib_list, EGLConfig *configs, EGLint config_size, EGLint *num_config);
typedef EGLBoolean (GLAPIENTRY * pfnChooseConfig)(EGLDisplay dpy, const EGLint* attrib_list, EGLConfig* configs, EGLint config_size, EGLint* num_config);
pfnChooseConfig fChooseConfig;
typedef EGLint (GLAPIENTRY * pfnGetError)(void);
pfnGetError fGetError;
typedef EGLBoolean (GLAPIENTRY * pfnGetConfigAttrib)(EGLDisplay dpy, EGLConfig config, EGLint attribute, EGLint *value);
typedef EGLBoolean (GLAPIENTRY * pfnGetConfigAttrib)(EGLDisplay dpy, EGLConfig config, EGLint attribute, EGLint* value);
pfnGetConfigAttrib fGetConfigAttrib;
typedef EGLBoolean (GLAPIENTRY * pfnGetConfigs)(EGLDisplay dpy, EGLConfig *configs, EGLint config_size, EGLint *num_config);
typedef EGLBoolean (GLAPIENTRY * pfnGetConfigs)(EGLDisplay dpy, EGLConfig* configs, EGLint config_size, EGLint* num_config);
pfnGetConfigs fGetConfigs;
typedef EGLBoolean (GLAPIENTRY * pfnWaitNative)(EGLint engine);
pfnWaitNative fWaitNative;
typedef EGLCastToRelevantPtr (GLAPIENTRY * pfnGetProcAddress)(const char *procname);
typedef EGLCastToRelevantPtr (GLAPIENTRY * pfnGetProcAddress)(const char* procname);
pfnGetProcAddress fGetProcAddress;
typedef EGLBoolean (GLAPIENTRY * pfnSwapBuffers)(EGLDisplay dpy, EGLSurface surface);
pfnSwapBuffers fSwapBuffers;
@ -590,35 +590,35 @@ public:
pfnQueryString fQueryString;
pfnQueryString fQueryStringImplementationANDROID;
typedef EGLBoolean (GLAPIENTRY * pfnQueryContext)(EGLDisplay dpy, EGLContext ctx,
EGLint attribute, EGLint *value);
EGLint attribute, EGLint* value);
pfnQueryContext fQueryContext;
typedef EGLBoolean (GLAPIENTRY * pfnBindTexImage)(EGLDisplay, EGLSurface surface, EGLint buffer);
pfnBindTexImage fBindTexImage;
typedef EGLBoolean (GLAPIENTRY * pfnReleaseTexImage)(EGLDisplay, EGLSurface surface, EGLint buffer);
pfnReleaseTexImage fReleaseTexImage;
typedef EGLImage (GLAPIENTRY * pfnCreateImage)(EGLDisplay dpy, EGLContext ctx, EGLenum target, EGLClientBuffer buffer, const EGLint *attrib_list);
typedef EGLImage (GLAPIENTRY * pfnCreateImage)(EGLDisplay dpy, EGLContext ctx, EGLenum target, EGLClientBuffer buffer, const EGLint* attrib_list);
pfnCreateImage fCreateImage;
typedef EGLBoolean (GLAPIENTRY * pfnDestroyImage)(EGLDisplay dpy, EGLImage image);
pfnDestroyImage fDestroyImage;
// New extension which allow us to lock texture and get raw image pointer
typedef EGLBoolean (GLAPIENTRY * pfnLockSurface)(EGLDisplay dpy, EGLSurface surface, const EGLint *attrib_list);
typedef EGLBoolean (GLAPIENTRY * pfnLockSurface)(EGLDisplay dpy, EGLSurface surface, const EGLint* attrib_list);
pfnLockSurface fLockSurface;
typedef EGLBoolean (GLAPIENTRY * pfnUnlockSurface)(EGLDisplay dpy, EGLSurface surface);
pfnUnlockSurface fUnlockSurface;
typedef EGLBoolean (GLAPIENTRY * pfnQuerySurface)(EGLDisplay dpy, EGLSurface surface, EGLint attribute, EGLint *value);
typedef EGLBoolean (GLAPIENTRY * pfnQuerySurface)(EGLDisplay dpy, EGLSurface surface, EGLint attribute, EGLint* value);
pfnQuerySurface fQuerySurface;
typedef EGLBoolean (GLAPIENTRY * pfnQuerySurfacePointerANGLE)(EGLDisplay dpy, EGLSurface surface, EGLint attribute, void **value);
typedef EGLBoolean (GLAPIENTRY * pfnQuerySurfacePointerANGLE)(EGLDisplay dpy, EGLSurface surface, EGLint attribute, void** value);
pfnQuerySurfacePointerANGLE fQuerySurfacePointerANGLE;
typedef EGLSync (GLAPIENTRY * pfnCreateSync)(EGLDisplay dpy, EGLenum type, const EGLint *attrib_list);
typedef EGLSync (GLAPIENTRY * pfnCreateSync)(EGLDisplay dpy, EGLenum type, const EGLint* attrib_list);
pfnCreateSync fCreateSync;
typedef EGLBoolean (GLAPIENTRY * pfnDestroySync)(EGLDisplay dpy, EGLSync sync);
pfnDestroySync fDestroySync;
typedef EGLint (GLAPIENTRY * pfnClientWaitSync)(EGLDisplay dpy, EGLSync sync, EGLint flags, EGLTime timeout);
pfnClientWaitSync fClientWaitSync;
typedef EGLBoolean (GLAPIENTRY * pfnGetSyncAttrib)(EGLDisplay dpy, EGLSync sync, EGLint attribute, EGLint *value);
typedef EGLBoolean (GLAPIENTRY * pfnGetSyncAttrib)(EGLDisplay dpy, EGLSync sync, EGLint attribute, EGLint* value);
pfnGetSyncAttrib fGetSyncAttrib;
typedef EGLint (GLAPIENTRY * pfnDupNativeFenceFDANDROID)(EGLDisplay dpy, EGLSync sync);
pfnDupNativeFenceFDANDROID fDupNativeFenceFDANDROID;

View File

@ -10,7 +10,7 @@ namespace mozilla {
namespace gl {
bool
GLLibraryLoader::OpenLibrary(const char *library)
GLLibraryLoader::OpenLibrary(const char* library)
{
PRLibSpec lspec;
lspec.type = PR_LibSpec_Pathname;
@ -24,9 +24,9 @@ GLLibraryLoader::OpenLibrary(const char *library)
}
bool
GLLibraryLoader::LoadSymbols(const SymLoadStruct *firstStruct,
GLLibraryLoader::LoadSymbols(const SymLoadStruct* firstStruct,
bool tryplatform,
const char *prefix,
const char* prefix,
bool warnOnFailure)
{
return LoadSymbols(mLibrary,
@ -37,8 +37,8 @@ GLLibraryLoader::LoadSymbols(const SymLoadStruct *firstStruct,
}
PRFuncPtr
GLLibraryLoader::LookupSymbol(PRLibrary *lib,
const char *sym,
GLLibraryLoader::LookupSymbol(PRLibrary* lib,
const char* sym,
PlatformLookupFunction lookupFunction)
{
PRFuncPtr res = 0;
@ -55,7 +55,7 @@ GLLibraryLoader::LookupSymbol(PRLibrary *lib,
// finally just try finding it in the process
if (!res) {
PRLibrary *leakedLibRef;
PRLibrary* leakedLibRef;
res = PR_FindFunctionSymbolAndLibrary(sym, &leakedLibRef);
}
@ -63,16 +63,16 @@ GLLibraryLoader::LookupSymbol(PRLibrary *lib,
}
bool
GLLibraryLoader::LoadSymbols(PRLibrary *lib,
const SymLoadStruct *firstStruct,
GLLibraryLoader::LoadSymbols(PRLibrary* lib,
const SymLoadStruct* firstStruct,
PlatformLookupFunction lookupFunction,
const char *prefix,
const char* prefix,
bool warnOnFailure)
{
char sbuf[MAX_SYMBOL_LENGTH * 2];
int failCount = 0;
const SymLoadStruct *ss = firstStruct;
const SymLoadStruct* ss = firstStruct;
while (ss->symPointer) {
*ss->symPointer = 0;
@ -80,7 +80,7 @@ GLLibraryLoader::LoadSymbols(PRLibrary *lib,
if (ss->symNames[i] == nullptr)
break;
const char *s = ss->symNames[i];
const char* s = ss->symNames[i];
if (prefix && *prefix != 0) {
strcpy(sbuf, prefix);
strcat(sbuf, ss->symNames[i]);

View File

@ -21,9 +21,9 @@ namespace gl {
class GLLibraryLoader
{
public:
bool OpenLibrary(const char *library);
bool OpenLibrary(const char* library);
typedef PRFuncPtr (GLAPIENTRY * PlatformLookupFunction) (const char *);
typedef PRFuncPtr (GLAPIENTRY * PlatformLookupFunction) (const char*);
enum {
MAX_SYMBOL_NAMES = 6,
@ -31,25 +31,25 @@ public:
};
typedef struct {
PRFuncPtr *symPointer;
const char *symNames[MAX_SYMBOL_NAMES];
PRFuncPtr* symPointer;
const char* symNames[MAX_SYMBOL_NAMES];
} SymLoadStruct;
bool LoadSymbols(const SymLoadStruct *firstStruct,
bool LoadSymbols(const SymLoadStruct* firstStruct,
bool tryplatform = false,
const char *prefix = nullptr,
const char* prefix = nullptr,
bool warnOnFailure = true);
/*
* Static version of the functions in this class
*/
static PRFuncPtr LookupSymbol(PRLibrary *lib,
const char *symname,
static PRFuncPtr LookupSymbol(PRLibrary* lib,
const char* symname,
PlatformLookupFunction lookupFunction = nullptr);
static bool LoadSymbols(PRLibrary *lib,
const SymLoadStruct *firstStruct,
static bool LoadSymbols(PRLibrary* lib,
const SymLoadStruct* firstStruct,
PlatformLookupFunction lookupFunction = nullptr,
const char *prefix = nullptr,
const char* prefix = nullptr,
bool warnOnFailure = true);
protected:
GLLibraryLoader() {
@ -57,7 +57,7 @@ protected:
mLookupFunc = nullptr;
}
PRLibrary *mLibrary;
PRLibrary* mLibrary;
PlatformLookupFunction mLookupFunc;
};

View File

@ -332,7 +332,7 @@ ReadPixelsIntoDataSurface(GLContext* gl, DataSourceSurface* dest)
needsTempSurf = true;
}
if (needsTempSurf) {
if (gl->DebugMode()) {
if (GLContext::ShouldSpew()) {
NS_WARNING("Needing intermediary surface for ReadPixels. This will be slow!");
}
SurfaceFormat readFormatGFX;

View File

@ -246,7 +246,7 @@ public:
* otherwise.
*/
bool ReadPixels(GLint x, GLint y, GLsizei width, GLsizei height,
GLenum format, GLenum type, GLvoid *pixels);
GLenum format, GLenum type, GLvoid* pixels);
// Morph changes the factory used to create surfaces.
void Morph(UniquePtr<SurfaceFactory> newFactory);

View File

@ -84,7 +84,7 @@ TextureImage::Create(GLContext* gl,
}
bool
TextureImage::UpdateFromDataSource(gfx::DataSourceSurface *aSurface,
TextureImage::UpdateFromDataSource(gfx::DataSourceSurface* aSurface,
const nsIntRegion* aDestRegion,
const gfx::IntPoint* aSrcPoint)
{
@ -117,7 +117,7 @@ TextureImage::UpdateUploadSize(size_t amount)
BasicTextureImage::~BasicTextureImage()
{
GLContext *ctx = mGLContext;
GLContext* ctx = mGLContext;
if (ctx->IsDestroyed() || !ctx->IsOwningThreadCurrent()) {
ctx = ctx->GetSharedContext();
}

View File

@ -168,7 +168,7 @@ public:
* aFrom - offset in the source to update from
*/
virtual bool DirectUpdate(gfx::DataSourceSurface* aSurf, const nsIntRegion& aRegion, const gfx::IntPoint& aFrom = gfx::IntPoint(0,0)) = 0;
bool UpdateFromDataSource(gfx::DataSourceSurface *aSurf,
bool UpdateFromDataSource(gfx::DataSourceSurface* aSurf,
const nsIntRegion* aDstRegion = nullptr,
const gfx::IntPoint* aSrcOffset = nullptr);

View File

@ -74,14 +74,14 @@ typedef void* EGLImage;
typedef int EGLint;
typedef unsigned int EGLBoolean;
typedef unsigned int EGLenum;
typedef void *EGLConfig;
typedef void *EGLContext;
typedef void *EGLDisplay;
typedef void *EGLSurface;
typedef void *EGLClientBuffer;
typedef void *EGLCastToRelevantPtr;
typedef void *EGLImage;
typedef void *EGLSync;
typedef void* EGLConfig;
typedef void* EGLContext;
typedef void* EGLDisplay;
typedef void* EGLSurface;
typedef void* EGLClientBuffer;
typedef void* EGLCastToRelevantPtr;
typedef void* EGLImage;
typedef void* EGLSync;
typedef uint64_t EGLTime;
#define EGL_NO_CONTEXT ((EGLContext)0)

View File

@ -52,7 +52,7 @@ NextPowerOfTwo(int aNumber)
}
static unsigned int
DataOffset(const IntPoint &aPoint, int32_t aStride, SurfaceFormat aFormat)
DataOffset(const IntPoint& aPoint, int32_t aStride, SurfaceFormat aFormat)
{
unsigned int data = aPoint.y * aStride;
data += aPoint.x * BytesPerPixel(aFormat);
@ -81,8 +81,8 @@ CopyAndPadTextureData(const GLvoid* srcBuffer,
GLsizei dstWidth, GLsizei dstHeight,
GLsizei stride, GLint pixelsize)
{
unsigned char *rowDest = static_cast<unsigned char*>(dstBuffer);
const unsigned char *source = static_cast<const unsigned char*>(srcBuffer);
unsigned char* rowDest = static_cast<unsigned char*>(dstBuffer);
const unsigned char* source = static_cast<const unsigned char*>(srcBuffer);
for (GLsizei h = 0; h < srcHeight; ++h) {
memcpy(rowDest, source, srcWidth * pixelsize);
@ -176,7 +176,7 @@ TexSubImage2DWithUnpackSubimageGLES(GLContext* gl,
1,
format,
type,
(const unsigned char *)pixels+(height-1)*stride);
(const unsigned char*)pixels+(height-1)*stride);
gl->fPixelStorei(LOCAL_GL_UNPACK_ALIGNMENT, 4);
}
@ -193,9 +193,9 @@ TexSubImage2DWithoutUnpackSubimage(GLContext* gl,
// isn't supported. We make a copy of the texture data we're using,
// such that we're using the whole row of data in the copy. This turns
// out to be more efficient than uploading row-by-row; see bug 698197.
unsigned char *newPixels = new unsigned char[width*height*pixelsize];
unsigned char *rowDest = newPixels;
const unsigned char *rowSource = (const unsigned char *)pixels;
unsigned char* newPixels = new unsigned char[width*height*pixelsize];
unsigned char* rowDest = newPixels;
const unsigned char* rowSource = (const unsigned char*)pixels;
for (int h = 0; h < height; h++) {
memcpy(rowDest, rowSource, width*pixelsize);
rowDest += width*pixelsize;
@ -220,7 +220,7 @@ TexSubImage2DWithoutUnpackSubimage(GLContext* gl,
}
static void
TexSubImage2DHelper(GLContext *gl,
TexSubImage2DHelper(GLContext* gl,
GLenum target, GLint level,
GLint xoffset, GLint yoffset,
GLsizei width, GLsizei height, GLsizei stride,
@ -274,11 +274,11 @@ TexSubImage2DHelper(GLContext *gl,
}
static void
TexImage2DHelper(GLContext *gl,
TexImage2DHelper(GLContext* gl,
GLenum target, GLint level, GLint internalformat,
GLsizei width, GLsizei height, GLsizei stride,
GLint pixelsize, GLint border, GLenum format,
GLenum type, const GLvoid *pixels)
GLenum type, const GLvoid* pixels)
{
if (gl->IsGLES()) {
@ -562,7 +562,7 @@ UploadImageDataToTexture(GLContext* gl,
// The inital data pointer is at the top left point of the region's
// bounding rectangle. We need to find the offset of this rect
// within the region and adjust the data pointer accordingly.
unsigned char *rectData =
unsigned char* rectData =
aData + DataOffset(rect.TopLeft() - topLeft, aStride, aFormat);
NS_ASSERTION(textureInited || (rect.x == 0 && rect.y == 0),

View File

@ -71,7 +71,7 @@ UploadImageDataToTexture(GLContext* gl,
*/
gfx::SurfaceFormat
UploadSurfaceToTexture(GLContext* gl,
gfx::DataSourceSurface *aSurface,
gfx::DataSourceSurface* aSurface,
const nsIntRegion& aDstRegion,
GLuint& aTexture,
size_t* aOutUploadSize = nullptr,

View File

@ -11,11 +11,11 @@ typedef realGLboolean GLboolean;
// stuff from glx.h
#include "X11/Xlib.h"
typedef struct __GLXcontextRec *GLXContext;
typedef struct __GLXcontextRec* GLXContext;
typedef XID GLXPixmap;
typedef XID GLXDrawable;
/* GLX 1.3 and later */
typedef struct __GLXFBConfigRec *GLXFBConfig;
typedef struct __GLXFBConfigRec* GLXFBConfig;
typedef XID GLXFBConfigID;
typedef XID GLXContextID;
typedef XID GLXWindow;
@ -67,59 +67,59 @@ public:
{}
void xDestroyContext(Display* display, GLXContext context);
Bool xMakeCurrent(Display* display,
GLXDrawable drawable,
Bool xMakeCurrent(Display* display,
GLXDrawable drawable,
GLXContext context);
GLXContext xGetCurrentContext();
static void* xGetProcAddress(const char *procName);
GLXFBConfig* xChooseFBConfig(Display* display,
int screen,
const int *attrib_list,
int *nelements);
GLXFBConfig* xGetFBConfigs(Display* display,
int screen,
int *nelements);
GLXContext xCreateNewContext(Display* display,
GLXFBConfig config,
int render_type,
GLXContext share_list,
static void* xGetProcAddress(const char* procName);
GLXFBConfig* xChooseFBConfig(Display* display,
int screen,
const int* attrib_list,
int* nelements);
GLXFBConfig* xGetFBConfigs(Display* display,
int screen,
int* nelements);
GLXContext xCreateNewContext(Display* display,
GLXFBConfig config,
int render_type,
GLXContext share_list,
Bool direct);
int xGetFBConfigAttrib(Display *display,
int xGetFBConfigAttrib(Display* display,
GLXFBConfig config,
int attribute,
int *value);
void xSwapBuffers(Display *display, GLXDrawable drawable);
const char * xQueryExtensionsString(Display *display,
int screen);
const char * xGetClientString(Display *display,
int screen);
const char * xQueryServerString(Display *display,
int screen, int name);
GLXPixmap xCreatePixmap(Display *display,
int* value);
void xSwapBuffers(Display* display, GLXDrawable drawable);
const char* xQueryExtensionsString(Display* display,
int screen);
const char* xGetClientString(Display* display,
int screen);
const char* xQueryServerString(Display* display,
int screen, int name);
GLXPixmap xCreatePixmap(Display* display,
GLXFBConfig config,
Pixmap pixmap,
const int *attrib_list);
GLXPixmap xCreateGLXPixmapWithConfig(Display *display,
const int* attrib_list);
GLXPixmap xCreateGLXPixmapWithConfig(Display* display,
GLXFBConfig config,
Pixmap pixmap);
void xDestroyPixmap(Display *display, GLXPixmap pixmap);
Bool xQueryVersion(Display *display,
int *major,
int *minor);
void xBindTexImage(Display *display,
void xDestroyPixmap(Display* display, GLXPixmap pixmap);
Bool xQueryVersion(Display* display,
int* major,
int* minor);
void xBindTexImage(Display* display,
GLXDrawable drawable,
int buffer,
const int *attrib_list);
void xReleaseTexImage(Display *display,
const int* attrib_list);
void xReleaseTexImage(Display* display,
GLXDrawable drawable,
int buffer);
void xWaitGL();
void xWaitX();
GLXContext xCreateContextAttribs(Display* display,
GLXFBConfig config,
GLXContext share_list,
GLXContext xCreateContextAttribs(Display* display,
GLXFBConfig config,
GLXContext share_list,
Bool direct,
const int* attrib_list);
@ -143,7 +143,7 @@ public:
bool GLXVersionCheck(int aMajor, int aMinor);
private:
typedef void (GLAPIENTRY * PFNGLXDESTROYCONTEXTPROC) (Display*,
GLXContext);
PFNGLXDESTROYCONTEXTPROC xDestroyContextInternal;
@ -153,89 +153,89 @@ private:
PFNGLXMAKECURRENTPROC xMakeCurrentInternal;
typedef GLXContext (GLAPIENTRY * PFNGLXGETCURRENTCONTEXT) ();
PFNGLXGETCURRENTCONTEXT xGetCurrentContextInternal;
typedef void* (GLAPIENTRY * PFNGLXGETPROCADDRESSPROC) (const char *);
typedef void* (GLAPIENTRY * PFNGLXGETPROCADDRESSPROC) (const char*);
PFNGLXGETPROCADDRESSPROC xGetProcAddressInternal;
typedef GLXFBConfig* (GLAPIENTRY * PFNGLXCHOOSEFBCONFIG) (Display *,
typedef GLXFBConfig* (GLAPIENTRY * PFNGLXCHOOSEFBCONFIG) (Display*,
int,
const int *,
int *);
const int*,
int*);
PFNGLXCHOOSEFBCONFIG xChooseFBConfigInternal;
typedef GLXFBConfig* (GLAPIENTRY * PFNGLXGETFBCONFIGS) (Display *,
typedef GLXFBConfig* (GLAPIENTRY * PFNGLXGETFBCONFIGS) (Display*,
int,
int *);
int*);
PFNGLXGETFBCONFIGS xGetFBConfigsInternal;
typedef GLXContext (GLAPIENTRY * PFNGLXCREATENEWCONTEXT) (Display *,
typedef GLXContext (GLAPIENTRY * PFNGLXCREATENEWCONTEXT) (Display*,
GLXFBConfig,
int,
GLXContext,
Bool);
PFNGLXCREATENEWCONTEXT xCreateNewContextInternal;
typedef int (GLAPIENTRY * PFNGLXGETFBCONFIGATTRIB) (Display *,
typedef int (GLAPIENTRY * PFNGLXGETFBCONFIGATTRIB) (Display*,
GLXFBConfig,
int,
int *);
int*);
PFNGLXGETFBCONFIGATTRIB xGetFBConfigAttribInternal;
typedef void (GLAPIENTRY * PFNGLXSWAPBUFFERS) (Display *,
typedef void (GLAPIENTRY * PFNGLXSWAPBUFFERS) (Display*,
GLXDrawable);
PFNGLXSWAPBUFFERS xSwapBuffersInternal;
typedef const char * (GLAPIENTRY * PFNGLXQUERYEXTENSIONSSTRING) (Display *,
int);
typedef const char* (GLAPIENTRY * PFNGLXQUERYEXTENSIONSSTRING) (Display*,
int);
PFNGLXQUERYEXTENSIONSSTRING xQueryExtensionsStringInternal;
typedef const char * (GLAPIENTRY * PFNGLXGETCLIENTSTRING) (Display *,
int);
typedef const char* (GLAPIENTRY * PFNGLXGETCLIENTSTRING) (Display*,
int);
PFNGLXGETCLIENTSTRING xGetClientStringInternal;
typedef const char * (GLAPIENTRY * PFNGLXQUERYSERVERSTRING) (Display *,
int,
int);
typedef const char* (GLAPIENTRY * PFNGLXQUERYSERVERSTRING) (Display*,
int,
int);
PFNGLXQUERYSERVERSTRING xQueryServerStringInternal;
typedef GLXPixmap (GLAPIENTRY * PFNGLXCREATEPIXMAP) (Display *,
typedef GLXPixmap (GLAPIENTRY * PFNGLXCREATEPIXMAP) (Display*,
GLXFBConfig,
Pixmap,
const int *);
const int*);
PFNGLXCREATEPIXMAP xCreatePixmapInternal;
typedef GLXPixmap (GLAPIENTRY * PFNGLXCREATEGLXPIXMAPWITHCONFIG)
(Display *,
(Display*,
GLXFBConfig,
Pixmap);
PFNGLXCREATEGLXPIXMAPWITHCONFIG xCreateGLXPixmapWithConfigInternal;
typedef void (GLAPIENTRY * PFNGLXDESTROYPIXMAP) (Display *,
typedef void (GLAPIENTRY * PFNGLXDESTROYPIXMAP) (Display*,
GLXPixmap);
PFNGLXDESTROYPIXMAP xDestroyPixmapInternal;
typedef Bool (GLAPIENTRY * PFNGLXQUERYVERSION) (Display *,
int *,
int *);
typedef Bool (GLAPIENTRY * PFNGLXQUERYVERSION) (Display*,
int*,
int*);
PFNGLXQUERYVERSION xQueryVersionInternal;
typedef void (GLAPIENTRY * PFNGLXBINDTEXIMAGE) (Display *,
typedef void (GLAPIENTRY * PFNGLXBINDTEXIMAGE) (Display*,
GLXDrawable,
int,
const int *);
const int*);
PFNGLXBINDTEXIMAGE xBindTexImageInternal;
typedef void (GLAPIENTRY * PFNGLXRELEASETEXIMAGE) (Display *,
typedef void (GLAPIENTRY * PFNGLXRELEASETEXIMAGE) (Display*,
GLXDrawable,
int);
PFNGLXRELEASETEXIMAGE xReleaseTexImageInternal;
typedef void (GLAPIENTRY * PFNGLXWAITGL) ();
PFNGLXWAITGL xWaitGLInternal;
typedef void (GLAPIENTRY * PFNGLXWAITX) ();
PFNGLXWAITGL xWaitXInternal;
typedef GLXContext (GLAPIENTRY * PFNGLXCREATECONTEXTATTRIBS) (Display *,
typedef GLXContext (GLAPIENTRY * PFNGLXCREATECONTEXTATTRIBS) (Display*,
GLXFBConfig,
GLXContext,
Bool,
const int *);
const int*);
PFNGLXCREATECONTEXTATTRIBS xCreateContextAttribsInternal;
typedef int (GLAPIENTRY *PFNGLXGETVIDEOSYNCSGI) (unsigned int *count);
typedef int (GLAPIENTRY * PFNGLXGETVIDEOSYNCSGI) (unsigned int* count);
PFNGLXGETVIDEOSYNCSGI xGetVideoSyncInternal;
typedef int (GLAPIENTRY *PFNGLXWAITVIDEOSYNCSGI) (int divisor, int remainder, unsigned int *count);
typedef int (GLAPIENTRY * PFNGLXWAITVIDEOSYNCSGI) (int divisor, int remainder, unsigned int* count);
PFNGLXWAITVIDEOSYNCSGI xWaitVideoSyncInternal;
#ifdef DEBUG
@ -255,7 +255,7 @@ private:
bool mClientIsMesa;
int mGLXMajorVersion;
int mGLXMinorVersion;
PRLibrary *mOGLLibrary;
PRLibrary* mOGLLibrary;
};
// a global GLXLibrary instance

View File

@ -43,7 +43,7 @@ public:
GLint x, GLint y, GLsizei width, GLsizei height,
GLint border) override;
virtual bool ReadPixels(GLint x, GLint y, GLsizei width, GLsizei height,
GLenum format, GLenum type, GLvoid *pixels) override;
GLenum format, GLenum type, GLvoid* pixels) override;
virtual GLuint ProdTexture() override {
return mProdTex;
@ -53,7 +53,7 @@ public:
return LOCAL_GL_TEXTURE_RECTANGLE_ARB;
}
static SharedSurface_IOSurface* Cast(SharedSurface *surf) {
static SharedSurface_IOSurface* Cast(SharedSurface* surf) {
MOZ_ASSERT(surf->mType == SharedSurfaceType::IOSurface);
return static_cast<SharedSurface_IOSurface*>(surf);
}

View File

@ -38,7 +38,7 @@ private:
};
already_AddRefed<TextureImage>
CreateTextureImageCGL(GLContext *gl,
CreateTextureImageCGL(GLContext* gl,
const gfx::IntSize& aSize,
TextureImage::ContentType aContentType,
GLenum aWrapMode,
@ -46,7 +46,7 @@ CreateTextureImageCGL(GLContext *gl,
TextureImage::ImageFormat aImageFormat);
already_AddRefed<TextureImage>
TileGenFuncCGL(GLContext *gl,
TileGenFuncCGL(GLContext* gl,
const gfx::IntSize& aSize,
TextureImage::ContentType aContentType,
TextureImage::Flags aFlags);

View File

@ -79,7 +79,7 @@ CreateTextureImageCGL(GLContext* gl,
}
already_AddRefed<TextureImage>
TileGenFuncCGL(GLContext *gl,
TileGenFuncCGL(GLContext* gl,
const IntSize& aSize,
TextureImage::ContentType aContentType,
TextureImage::Flags aFlags)

View File

@ -310,7 +310,7 @@ TextureImageEGL::DestroyEGLSurface(void)
}
already_AddRefed<TextureImage>
CreateTextureImageEGL(GLContext *gl,
CreateTextureImageEGL(GLContext* gl,
const gfx::IntSize& aSize,
TextureImage::ContentType aContentType,
GLenum aWrapMode,
@ -322,7 +322,7 @@ CreateTextureImageEGL(GLContext *gl,
}
already_AddRefed<TextureImage>
TileGenFuncEGL(GLContext *gl,
TileGenFuncEGL(GLContext* gl,
const gfx::IntSize& aSize,
TextureImage::ContentType aContentType,
TextureImage::Flags aFlags,

View File

@ -78,7 +78,7 @@ protected:
};
already_AddRefed<TextureImage>
CreateTextureImageEGL(GLContext *gl,
CreateTextureImageEGL(GLContext* gl,
const gfx::IntSize& aSize,
TextureImage::ContentType aContentType,
GLenum aWrapMode,
@ -86,7 +86,7 @@ CreateTextureImageEGL(GLContext *gl,
TextureImage::ImageFormat aImageFormat);
already_AddRefed<TextureImage>
TileGenFuncEGL(GLContext *gl,
TileGenFuncEGL(GLContext* gl,
const gfx::IntSize& aSize,
TextureImage::ContentType aContentType,
TextureImage::Flags aFlags,

View File

@ -53,23 +53,23 @@ public:
typedef BOOL (WINAPI * PFNWGLRELEASETEXIMAGEPROC) (HANDLE hPbuffer, int iBuffer);
PFNWGLRELEASETEXIMAGEPROC fReleaseTexImage;
typedef BOOL (WINAPI * PFNWGLCHOOSEPIXELFORMATPROC) (HDC hdc, const int* piAttribIList, const FLOAT *pfAttribFList, UINT nMaxFormats, int *piFormats, UINT *nNumFormats);
typedef BOOL (WINAPI * PFNWGLCHOOSEPIXELFORMATPROC) (HDC hdc, const int* piAttribIList, const FLOAT* pfAttribFList, UINT nMaxFormats, int* piFormats, UINT* nNumFormats);
PFNWGLCHOOSEPIXELFORMATPROC fChoosePixelFormat;
typedef BOOL (WINAPI * PFNWGLGETPIXELFORMATATTRIBIVPROC) (HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, int* piAttributes, int *piValues);
typedef BOOL (WINAPI * PFNWGLGETPIXELFORMATATTRIBIVPROC) (HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, int* piAttributes, int* piValues);
PFNWGLGETPIXELFORMATATTRIBIVPROC fGetPixelFormatAttribiv;
typedef const char * (WINAPI * PFNWGLGETEXTENSIONSSTRINGPROC) (HDC hdc);
typedef const char* (WINAPI * PFNWGLGETEXTENSIONSSTRINGPROC) (HDC hdc);
PFNWGLGETEXTENSIONSSTRINGPROC fGetExtensionsString;
typedef HGLRC (WINAPI * PFNWGLCREATECONTEXTATTRIBSPROC) (HDC hdc, HGLRC hShareContext, const int *attribList);
typedef HGLRC (WINAPI * PFNWGLCREATECONTEXTATTRIBSPROC) (HDC hdc, HGLRC hShareContext, const int* attribList);
PFNWGLCREATECONTEXTATTRIBSPROC fCreateContextAttribs;
// WGL_NV_DX_interop:
// BOOL wglDXSetResourceShareHandleNV(void *dxObject, HANDLE shareHandle);
// BOOL wglDXSetResourceShareHandleNV(void* dxObject, HANDLE shareHandle);
typedef BOOL (WINAPI * PFNWGLDXSETRESOURCESHAREHANDLEPROC) (void* dxObject, HANDLE shareHandle);
PFNWGLDXSETRESOURCESHAREHANDLEPROC fDXSetResourceShareHandle;
// HANDLE wglDXOpenDeviceNV(void *dxDevice);
// HANDLE wglDXOpenDeviceNV(void* dxDevice);
typedef HANDLE (WINAPI * PFNWGLDXOPENDEVICEPROC) (void* dxDevice);
PFNWGLDXOPENDEVICEPROC fDXOpenDevice;
@ -77,7 +77,7 @@ public:
typedef BOOL (WINAPI * PFNWGLDXCLOSEDEVICEPROC) (HANDLE hDevice);
PFNWGLDXCLOSEDEVICEPROC fDXCloseDevice;
// HANDLE wglDXRegisterObjectNV(HANDLE hDevice, void *dxObject, GLuint name, GLenum type, GLenum access);
// HANDLE wglDXRegisterObjectNV(HANDLE hDevice, void* dxObject, GLuint name, GLenum type, GLenum access);
typedef HANDLE (WINAPI * PFNWGLDXREGISTEROBJECTPROC) (HANDLE hDevice, void* dxObject, GLuint name, GLenum type, GLenum access);
PFNWGLDXREGISTEROBJECTPROC fDXRegisterObject;
@ -89,16 +89,16 @@ public:
typedef BOOL (WINAPI * PFNWGLDXOBJECTACCESSPROC) (HANDLE hObject, GLenum access);
PFNWGLDXOBJECTACCESSPROC fDXObjectAccess;
// BOOL wglDXLockObjectsNV(HANDLE hDevice, GLint count, HANDLE *hObjects);
// BOOL wglDXLockObjectsNV(HANDLE hDevice, GLint count, HANDLE* hObjects);
typedef BOOL (WINAPI * PFNWGLDXLOCKOBJECTSPROC) (HANDLE hDevice, GLint count, HANDLE* hObjects);
PFNWGLDXLOCKOBJECTSPROC fDXLockObjects;
// BOOL wglDXUnlockObjectsNV(HANDLE hDevice, GLint count, HANDLE *hObjects);
// BOOL wglDXUnlockObjectsNV(HANDLE hDevice, GLint count, HANDLE* hObjects);
typedef BOOL (WINAPI * PFNWGLDXUNLOCKOBJECTSPROC) (HANDLE hDevice, GLint count, HANDLE* hObjects);
PFNWGLDXUNLOCKOBJECTSPROC fDXUnlockObjects;
bool EnsureInitialized();
HWND CreateDummyWindow(HDC *aWindowDC = nullptr);
HWND CreateDummyWindow(HDC* aWindowDC = nullptr);
bool HasRobustness() const { return mHasRobustness; }
bool HasDXInterop() const { return mHasDXInterop; }
@ -108,11 +108,11 @@ public:
HDC GetWindowDC() const {return mWindowDC; }
HGLRC GetWindowGLContext() const {return mWindowGLContext; }
int GetWindowPixelFormat() const { return mWindowPixelFormat; }
PRLibrary *GetOGLLibrary() { return mOGLLibrary; }
PRLibrary* GetOGLLibrary() { return mOGLLibrary; }
private:
bool mInitialized;
PRLibrary *mOGLLibrary;
PRLibrary* mOGLLibrary;
bool mHasRobustness;
bool mHasDXInterop;
bool mHasDXInterop2;

View File

@ -53,7 +53,7 @@ GLImage::GetAsSourceSurface()
if (!sSnapshotContext) {
nsCString discardFailureId;
sSnapshotContext = GLContextProvider::CreateHeadless(CreateContextFlags::NONE,
discardFailureId);
&discardFailureId);
if (!sSnapshotContext) {
NS_WARNING("Failed to create snapshot GLContext");
return nullptr;

View File

@ -721,6 +721,7 @@ LayerManagerComposite::PushGroupForLayerEffects()
mTwoPassTmpTarget->GetOrigin() != previousTarget->GetOrigin()) {
mTwoPassTmpTarget = mCompositor->CreateRenderTarget(rect, INIT_MODE_NONE);
}
MOZ_ASSERT(mTwoPassTmpTarget);
mCompositor->SetRenderTarget(mTwoPassTmpTarget);
return previousTarget;
}
@ -807,7 +808,7 @@ LayerManagerComposite::Render(const nsIntRegion& aInvalidRegion, const nsIntRegi
PROFILER_LABEL("LayerManagerComposite", "Render",
js::ProfileEntry::Category::GRAPHICS);
if (mDestroyed) {
if (mDestroyed || !mCompositor || mCompositor->IsDestroyed()) {
NS_WARNING("Call on destroyed layer manager");
return;
}

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