diff --git a/b2g/config/dolphin/sources.xml b/b2g/config/dolphin/sources.xml index c0ed703aecdb..1494c0f896d5 100644 --- a/b2g/config/dolphin/sources.xml +++ b/b2g/config/dolphin/sources.xml @@ -15,7 +15,7 @@ - + @@ -129,7 +129,7 @@ - + diff --git a/b2g/config/emulator-ics/sources.xml b/b2g/config/emulator-ics/sources.xml index f8f7be1f26f8..a93a66f90e72 100644 --- a/b2g/config/emulator-ics/sources.xml +++ b/b2g/config/emulator-ics/sources.xml @@ -19,7 +19,7 @@ - + diff --git a/b2g/config/emulator-jb/sources.xml b/b2g/config/emulator-jb/sources.xml index 6099255c1bff..789a1b03597b 100644 --- a/b2g/config/emulator-jb/sources.xml +++ b/b2g/config/emulator-jb/sources.xml @@ -17,7 +17,7 @@ - + diff --git a/b2g/config/emulator-kk/sources.xml b/b2g/config/emulator-kk/sources.xml index 66afda1ae193..29f9799ad1dc 100644 --- a/b2g/config/emulator-kk/sources.xml +++ b/b2g/config/emulator-kk/sources.xml @@ -15,7 +15,7 @@ - + diff --git a/b2g/config/emulator/sources.xml b/b2g/config/emulator/sources.xml index f8f7be1f26f8..a93a66f90e72 100644 --- a/b2g/config/emulator/sources.xml +++ b/b2g/config/emulator/sources.xml @@ -19,7 +19,7 @@ - + diff --git a/b2g/config/flame-kk/sources.xml b/b2g/config/flame-kk/sources.xml index 7c75e21039ea..69507232b95e 100644 --- a/b2g/config/flame-kk/sources.xml +++ b/b2g/config/flame-kk/sources.xml @@ -15,7 +15,7 @@ - + diff --git a/b2g/config/flame/sources.xml b/b2g/config/flame/sources.xml index 6c71a7e5099f..7c152639b161 100644 --- a/b2g/config/flame/sources.xml +++ b/b2g/config/flame/sources.xml @@ -17,7 +17,7 @@ - + diff --git a/b2g/config/gaia.json b/b2g/config/gaia.json index 0267096a3fe4..8bb041a0e481 100644 --- a/b2g/config/gaia.json +++ b/b2g/config/gaia.json @@ -4,6 +4,6 @@ "remote": "", "branch": "" }, - "revision": "95521d1e0cf64f0d95be0cf643931e20119a7387", + "revision": "1cd63caaf46eefcdaa427914e363220096a1c09a", "repo_path": "/integration/gaia-central" } diff --git a/b2g/config/hamachi/sources.xml b/b2g/config/hamachi/sources.xml index 3245d6cb0f8e..31b9ae18750d 100644 --- a/b2g/config/hamachi/sources.xml +++ b/b2g/config/hamachi/sources.xml @@ -17,7 +17,7 @@ - + diff --git a/b2g/config/helix/sources.xml b/b2g/config/helix/sources.xml index c3260222328f..fe33d03f6b8a 100644 --- a/b2g/config/helix/sources.xml +++ b/b2g/config/helix/sources.xml @@ -15,7 +15,7 @@ - + diff --git a/b2g/config/nexus-4/sources.xml b/b2g/config/nexus-4/sources.xml index fe8145359342..7381e1e8338a 100644 --- a/b2g/config/nexus-4/sources.xml +++ b/b2g/config/nexus-4/sources.xml @@ -17,7 +17,7 @@ - + diff --git a/b2g/config/wasabi/sources.xml b/b2g/config/wasabi/sources.xml index 8315d5abf112..7500a3b63fa2 100644 --- a/b2g/config/wasabi/sources.xml +++ b/b2g/config/wasabi/sources.xml @@ -17,7 +17,7 @@ - + diff --git a/content/html/content/src/HTMLMediaElement.cpp b/content/html/content/src/HTMLMediaElement.cpp index 91f47a39d5eb..ed72a4045e0b 100755 --- a/content/html/content/src/HTMLMediaElement.cpp +++ b/content/html/content/src/HTMLMediaElement.cpp @@ -3942,7 +3942,9 @@ void HTMLMediaElement::UpdateAudioChannelPlayingState() (!mPaused && (HasAttr(kNameSpaceID_None, nsGkAtoms::loop) || (mReadyState >= nsIDOMHTMLMediaElement::HAVE_CURRENT_DATA && - !IsPlaybackEnded()) || + !IsPlaybackEnded() && + !(mSrcStream && !(mSrcStream->GetTrackTypesAvailable() & + DOMMediaStream::HINT_CONTENTS_AUDIO))) || mPlayingThroughTheAudioChannelBeforeSeek)); if (playingThroughTheAudioChannel != mPlayingThroughTheAudioChannel) { mPlayingThroughTheAudioChannel = playingThroughTheAudioChannel; diff --git a/content/media/DOMMediaStream.h b/content/media/DOMMediaStream.h index c5a82d4b12be..e59c31b40164 100644 --- a/content/media/DOMMediaStream.h +++ b/content/media/DOMMediaStream.h @@ -171,6 +171,8 @@ public: TrackTypeHints GetHintContents() const { return mHintContents; } void SetHintContents(TrackTypeHints aHintContents) { mHintContents = aHintContents; } + TrackTypeHints GetTrackTypesAvailable() const { return mTrackTypesAvailable; } + /** * Create an nsDOMMediaStream whose underlying stream is a SourceMediaStream. */ diff --git a/dom/apps/Webapps.jsm b/dom/apps/Webapps.jsm index 02f4a4b42759..2e6a0047f6e4 100755 --- a/dom/apps/Webapps.jsm +++ b/dom/apps/Webapps.jsm @@ -3739,7 +3739,7 @@ this.DOMApplicationRegistry = { this.broadcastMessage("Webapps:UpdateState", { app: aOldApp, error: aError, - id: aNewApp.id + id: aId }); this.broadcastMessage("Webapps:FireEvent", { eventType: "downloaderror", diff --git a/dom/apps/tests/signed_app.sjs b/dom/apps/tests/signed_app.sjs index ff85a80e4afc..5b11e366b086 100644 --- a/dom/apps/tests/signed_app.sjs +++ b/dom/apps/tests/signed_app.sjs @@ -20,6 +20,14 @@ var gDevUrl = "http://dev.url"; function handleRequest(request, response) { var query = getQuery(request); + if ("nextApp" in query) { + setState("nextApp", query.nextApp); + response.write("OK"); + return; + } + + var nextApp = getState("nextApp"); + response.setHeader("Access-Control-Allow-Origin", "*", false); var version = ("version" in query) ? query.version : "1"; @@ -29,7 +37,7 @@ function handleRequest(request, response) { if (version != prevVersion) { setState("version", version); } - var packageName = app + "_app_" + version + ".zip"; + var packageName = (nextApp.length ? nextApp : app) + "_app_" + version + ".zip"; setState("packageName", packageName); var packagePath = "/" + gBasePath + "signed/" + packageName; setState("packagePath", packagePath); @@ -37,13 +45,15 @@ function handleRequest(request, response) { var etag = getEtag(request, version); - if (etagMatches(request, etag)) { + if (!nextApp.length && etagMatches(request, etag)) { dump("Etags Match. Sending 304\n"); response.setStatusLine(request.httpVersion, "304", "Not modified"); return; } response.setHeader("Etag", etag, false); + setState("nextApp", ""); + // Serve the mini-manifest corresponding to the requested app version. var template = gBasePath + gMiniManifestTemplate; diff --git a/dom/apps/tests/test_signed_pkg_install.html b/dom/apps/tests/test_signed_pkg_install.html index 3b3c91663dc5..bf1b5b9c024a 100644 --- a/dom/apps/tests/test_signed_pkg_install.html +++ b/dom/apps/tests/test_signed_pkg_install.html @@ -142,12 +142,53 @@ var steps = [ var request = navigator.mozApps.installPackage(miniManifestURL); request.onerror = function(evt) { ok(false, "Application should have been correctly installed (error: " + - JSON.stringify(evt)); + request.error.name); }; request.onsuccess = function() { info("Application installed"); }; }, + function() { + // Set up the server side to send a different package on the next call. + info("== TEST == Set state to invalid app"); + var url = gSJS + "?" + "nextApp=unsigned"; + var xhr = new XMLHttpRequest(); + xhr.addEventListener("load", function() { + is(xhr.responseText, "OK", "nextApp=unsigned OK"); + PackagedTestHelper.next(); + }); + xhr.addEventListener("error", event => { + ok(false, "XHR error loading " + url + ": " + xhr.status + " - " + + xhr.statusText); + }); + xhr.addEventListener("abort", event => { + ok(false, "XHR abort loading " + url); + }); + xhr.open('GET', url, true); + xhr.send(); + }, + function() { + info("== TEST == Update app from an invalid source"); + info("Updating app: " + gApp.manifest.name); + gApp.ondownloaderror = function() { + is(gApp.downloadError.name, "INVALID_SIGNATURE"); + PackagedTestHelper.next(); + }; + gApp.ondownloadsuccess = function() { + info("App downloaded"); + ok(false, "App should not download success"); + PackagedTestHelper.finish(); + }; + info("App manifest: " + gApp.manifestURL); + + // This update check will return a different mini manifest pointing to + // an invalid package. + var req = gApp.checkForUpdate(); + req.onsuccess = function() { + gApp.download(); + } + req.onerror = PackagedTestHelper.mozAppsError; + }, function() { info("== TEST == Uninstall a signed app"); // Uninstall App diff --git a/dom/interfaces/base/nsIDOMWindowUtils.idl b/dom/interfaces/base/nsIDOMWindowUtils.idl index f7acd3f8dacd..fd2b9c16fa1e 100644 --- a/dom/interfaces/base/nsIDOMWindowUtils.idl +++ b/dom/interfaces/base/nsIDOMWindowUtils.idl @@ -1463,7 +1463,7 @@ interface nsIDOMWindowUtils : nsISupports { readonly attribute boolean mayHaveTouchEventListeners; /** - * Check if any ThebesLayer painting has been done for this element, + * Check if any PaintedLayer painting has been done for this element, * clears the painted flags if they have. */ boolean checkAndClearPaintedState(in nsIDOMElement aElement); diff --git a/dom/system/gonk/RadioInterfaceLayer.js b/dom/system/gonk/RadioInterfaceLayer.js index 94ff6665f6c3..3e066a7fc5fb 100644 --- a/dom/system/gonk/RadioInterfaceLayer.js +++ b/dom/system/gonk/RadioInterfaceLayer.js @@ -4169,7 +4169,15 @@ DataCall.prototype = { return; } if (this.state == RIL.GECKO_NETWORK_STATE_CONNECTED) { - networkInterface.notifyRILNetworkInterface(); + // This needs to run asynchronously, to behave the same way as the case of + // non-shared apn, see bug 1059110. + Services.tm.currentThread.dispatch(function(state) { + // Do not notify if state changed while this event was being dispatched, + // the state probably was notified already or need not to be notified. + if (networkInterface.state == state) { + networkInterface.notifyRILNetworkInterface(); + } + }.bind(null, RIL.GECKO_NETWORK_STATE_CONNECTED), Ci.nsIEventTarget.DISPATCH_NORMAL); return; } @@ -4281,7 +4289,13 @@ DataCall.prototype = { // Notify the DISCONNECTED event immediately after network interface is // removed from requestedNetworkIfaces, to make the DataCall, shared or // not, to have the same behavior. - networkInterface.notifyRILNetworkInterface(); + Services.tm.currentThread.dispatch(function(state) { + // Do not notify if state changed while this event was being dispatched, + // the state probably was notified already or need not to be notified. + if (networkInterface.state == state) { + networkInterface.notifyRILNetworkInterface(); + } + }.bind(null, RIL.GECKO_NETWORK_STATE_DISCONNECTED), Ci.nsIEventTarget.DISPATCH_NORMAL); } // Only deactivate data call if no more network interface needs this diff --git a/dom/system/gonk/ril_consts.js b/dom/system/gonk/ril_consts.js index 1c8ab37a471b..ce04406939e3 100644 --- a/dom/system/gonk/ril_consts.js +++ b/dom/system/gonk/ril_consts.js @@ -1254,11 +1254,12 @@ this.STK_SUPPORTED_TERMINAL_PROFILE = [ ]; /** - * (U)SIM Services. + * ICC Services Table. * * @see 3GPP TS 51.011 10.3.7 (SIM) and 3GPP TS 31.102 4.2.8 (USIM). */ this.GECKO_ICC_SERVICES = { + // @see 3GPP TS 51.011 10.3.7 (SIM). sim: { ADN: 2, FDN: 3, @@ -1279,6 +1280,7 @@ this.GECKO_ICC_SERVICES = { MWIS: 54, SPDI: 56 }, + // @see 3GPP TS 31.102 4.2.8 (USIM). usim: { FDN: 2, SDN: 4, @@ -1297,9 +1299,11 @@ this.GECKO_ICC_SERVICES = { MWIS: 48, SPDI: 51 }, + // @see 3GPP2 C.S0023-D 3.4.18 (RUIM). ruim: { ENHANCED_PHONEBOOK: 6, - SPN: 17 + SPN: 17, + SDN: 18 } }; diff --git a/dom/system/gonk/ril_worker.js b/dom/system/gonk/ril_worker.js index c4ee8180b745..32249a1f2c5a 100644 --- a/dom/system/gonk/ril_worker.js +++ b/dom/system/gonk/ril_worker.js @@ -5629,26 +5629,38 @@ RilObject.prototype[REQUEST_SETUP_DATA_CALL] = function REQUEST_SETUP_DATA_CALL( this[REQUEST_DATA_CALL_LIST](length, options); }; RilObject.prototype[REQUEST_SIM_IO] = function REQUEST_SIM_IO(length, options) { - let ICCIOHelper = this.context.ICCIOHelper; - if (!length) { - ICCIOHelper.processICCIOError(options); + if (options.rilRequestError) { + if (options.onerror) { + options.onerror(RIL_ERROR_TO_GECKO_ERROR[options.rilRequestError] || + GECKO_ERROR_GENERIC_FAILURE); + } return; } - // Don't need to read rilRequestError since we can know error status from - // sw1 and sw2. let Buf = this.context.Buf; options.sw1 = Buf.readInt32(); options.sw2 = Buf.readInt32(); - // See 3GPP TS 11.11, clause 9.4.1 for opetation success results. + + // See 3GPP TS 11.11, clause 9.4.1 for operation success results. if (options.sw1 !== ICC_STATUS_NORMAL_ENDING && options.sw1 !== ICC_STATUS_NORMAL_ENDING_WITH_EXTRA && options.sw1 !== ICC_STATUS_WITH_SIM_DATA && options.sw1 !== ICC_STATUS_WITH_RESPONSE_DATA) { - ICCIOHelper.processICCIOError(options); + if (DEBUG) { + this.context.debug("ICC I/O Error EF id = 0x" + options.fileId.toString(16) + + ", command = 0x" + options.command.toString(16) + + ", sw1 = 0x" + options.sw1.toString(16) + + ", sw2 = 0x" + options.sw2.toString(16)); + } + if (options.onerror) { + // We can get fail cause from sw1/sw2 (See TS 11.11 clause 9.4.1 and + // ISO 7816-4 clause 6). But currently no one needs this information, + // so simply reports "GenericFailure" for now. + options.onerror(GECKO_ERROR_GENERIC_FAILURE); + } return; } - ICCIOHelper.processICCIO(options); + this.context.ICCIOHelper.processICCIO(options); }; RilObject.prototype[REQUEST_SEND_USSD] = function REQUEST_SEND_USSD(length, options) { if (DEBUG) { @@ -12491,28 +12503,6 @@ ICCIOHelperObject.prototype = { options.callback(options); } }, - - /** - * Process ICC IO error. - */ - processICCIOError: function(options) { - let requestError = RIL_ERROR_TO_GECKO_ERROR[options.rilRequestError]; - if (DEBUG) { - // See GSM11.11, TS 51.011 clause 9.4, and ISO 7816-4 for the error - // description. - let errorMsg = "ICC I/O Error code " + requestError + - " EF id = " + options.fileId.toString(16) + - " command = " + options.command.toString(16); - if (options.sw1 && options.sw2) { - errorMsg += "(" + options.sw1.toString(16) + - "/" + options.sw2.toString(16) + ")"; - } - this.context.debug(errorMsg); - } - if (options.onerror) { - options.onerror(requestError); - } - }, }; ICCIOHelperObject.prototype[ICC_COMMAND_SEEK] = null; ICCIOHelperObject.prototype[ICC_COMMAND_READ_BINARY] = function ICC_COMMAND_READ_BINARY(options) { @@ -14820,6 +14810,12 @@ ICCContactHelperObject.prototype = { ICCRecordHelper.readADNLike(ICC_EF_FDN, onsuccess, onerror); break; case "sdn": + let ICCUtilsHelper = this.context.ICCUtilsHelper; + if (!ICCUtilsHelper.isICCServiceAvailable("SDN")) { + onerror(CONTACT_ERR_CONTACT_TYPE_NOT_SUPPORTED); + break; + } + ICCRecordHelper.readADNLike(ICC_EF_SDN, onsuccess, onerror); break; default: diff --git a/dom/system/gonk/tests/test_ril_worker_icc_ICCContactHelper.js b/dom/system/gonk/tests/test_ril_worker_icc_ICCContactHelper.js index 77c11f562e71..d74ee860fdae 100644 --- a/dom/system/gonk/tests/test_ril_worker_icc_ICCContactHelper.js +++ b/dom/system/gonk/tests/test_ril_worker_icc_ICCContactHelper.js @@ -27,7 +27,7 @@ add_test(function test_error_message_read_icc_contact () { // Error 2, specifying a non-supported contactType. ril.appType = CARD_APPTYPE_USIM; - do_test({contactType: "sdn"}, CONTACT_ERR_CONTACT_TYPE_NOT_SUPPORTED); + do_test({contactType: "foo"}, CONTACT_ERR_CONTACT_TYPE_NOT_SUPPORTED); // Error 3, suppose we update the supported PBR fields in USIM_PBR_FIELDS, // but forget to add implemenetations for it. diff --git a/dom/system/gonk/tests/test_ril_worker_icc_ICCIOHelper.js b/dom/system/gonk/tests/test_ril_worker_icc_ICCIOHelper.js index b6daf85ee12e..5bbb163ff409 100644 --- a/dom/system/gonk/tests/test_ril_worker_icc_ICCIOHelper.js +++ b/dom/system/gonk/tests/test_ril_worker_icc_ICCIOHelper.js @@ -54,31 +54,41 @@ add_test(function test_load_linear_fixed_ef() { }); /** - * Verify ICCIOHelper.processICCIOError. + * Verify ICC IO Error. */ add_test(function test_process_icc_io_error() { let worker = newUint8Worker(); let context = worker.ContextPool._contexts[0]; - let ioHelper = context.ICCIOHelper; + let buf = context.Buf; - function do_test(errorCode, expectedErrorMsg) { + function do_test(sw1, sw2, expectedErrorMsg) { let called = false; function errorCb(errorMsg) { called = true; do_check_eq(errorMsg, expectedErrorMsg); } - ioHelper.processICCIOError({rilRequestError: errorCode, - fileId: 0xffff, - command: 0xff, - sw1: 0xff, - sw2: 0xff, - onerror: errorCb}); + // Write sw1 and sw2 to buffer. + buf.writeInt32(sw1); + buf.writeInt32(sw2); + + context.RIL[REQUEST_SIM_IO](0, {rilRequestError: ERROR_SUCCESS, + fileId: 0xffff, + command: 0xff, + onerror: errorCb}); + + // onerror callback should be triggered. do_check_true(called); } - for (let i = 0; i < ERROR_REJECTED_BY_REMOTE + 1; i++) { - do_test(i, RIL_ERROR_TO_GECKO_ERROR[i]); + let TEST_DATA = [ + // [sw1, sw2, expectError] + [ICC_STATUS_ERROR_COMMAND_NOT_ALLOWED, 0xff, GECKO_ERROR_GENERIC_FAILURE], + [ICC_STATUS_ERROR_WRONG_PARAMETERS, 0xff, GECKO_ERROR_GENERIC_FAILURE], + ]; + + for (let i = 0; i < TEST_DATA.length; i++) { + do_test.apply(null, TEST_DATA[i]); } run_next_test(); diff --git a/editor/composer/nsEditingSession.cpp b/editor/composer/nsEditingSession.cpp index 97092bc1f6af..a927661b7af3 100644 --- a/editor/composer/nsEditingSession.cpp +++ b/editor/composer/nsEditingSession.cpp @@ -25,7 +25,6 @@ #include "nsIDOMDocument.h" // for nsIDOMDocument #include "nsIDOMHTMLDocument.h" // for nsIDOMHTMLDocument #include "nsIDOMWindow.h" // for nsIDOMWindow -#include "nsIDOMWindowUtils.h" // for nsIDOMWindowUtils #include "nsIDocShell.h" // for nsIDocShell #include "nsIDocument.h" // for nsIDocument #include "nsIDocumentStateListener.h" @@ -33,6 +32,7 @@ #include "nsIHTMLDocument.h" // for nsIHTMLDocument, etc #include "nsIInterfaceRequestorUtils.h" // for do_GetInterface #include "nsIPlaintextEditor.h" // for nsIPlaintextEditor, etc +#include "nsIPresShell.h" // for nsIPresShell #include "nsIRefreshURI.h" // for nsIRefreshURI #include "nsIRequest.h" // for nsIRequest #include "nsISelection.h" // for nsISelection @@ -45,6 +45,7 @@ #include "nsLiteralString.h" // for NS_LITERAL_STRING #include "nsPICommandUpdater.h" // for nsPICommandUpdater #include "nsPIDOMWindow.h" // for nsPIDOMWindow +#include "nsPresContext.h" // for nsPresContext #include "nsReadableUtils.h" // for AppendUTF16toUTF8 #include "nsStringFwd.h" // for nsAFlatString @@ -396,12 +397,13 @@ nsEditingSession::SetupEditorOnWindow(nsIDOMWindow *aWindow) if (!mInteractive) { // Disable animation of images in this document: - nsCOMPtr utils(do_GetInterface(aWindow)); - NS_ENSURE_TRUE(utils, NS_ERROR_FAILURE); + nsCOMPtr presShell = docShell->GetPresShell(); + NS_ENSURE_TRUE(presShell, NS_ERROR_FAILURE); + nsPresContext* presContext = presShell->GetPresContext(); + NS_ENSURE_TRUE(presContext, NS_ERROR_FAILURE); - rv = utils->GetImageAnimationMode(&mImageAnimationMode); - NS_ENSURE_SUCCESS(rv, rv); - utils->SetImageAnimationMode(imgIContainer::kDontAnimMode); + mImageAnimationMode = presContext->ImageAnimationMode(); + presContext->SetImageAnimationMode(imgIContainer::kDontAnimMode); } // create and set editor @@ -1303,9 +1305,14 @@ nsEditingSession::RestoreAnimationMode(nsIDOMWindow *aWindow) { if (!mInteractive) { - nsCOMPtr utils(do_GetInterface(aWindow)); - if (utils) - utils->SetImageAnimationMode(mImageAnimationMode); + nsCOMPtr docShell = GetDocShellFromWindow(aWindow); + NS_ENSURE_TRUE(docShell, ); + nsCOMPtr presShell = docShell->GetPresShell(); + NS_ENSURE_TRUE(presShell, ); + nsPresContext* presContext = presShell->GetPresContext(); + NS_ENSURE_TRUE(presContext, ); + + presContext->SetImageAnimationMode(mImageAnimationMode); } } @@ -1390,12 +1397,13 @@ nsEditingSession::ReattachToWindow(nsIDOMWindow* aWindow) if (!mInteractive) { // Disable animation of images in this document: - nsCOMPtr utils(do_GetInterface(aWindow)); - NS_ENSURE_TRUE(utils, NS_ERROR_FAILURE); + nsCOMPtr presShell = docShell->GetPresShell(); + NS_ENSURE_TRUE(presShell, NS_ERROR_FAILURE); + nsPresContext* presContext = presShell->GetPresContext(); + NS_ENSURE_TRUE(presContext, NS_ERROR_FAILURE); - rv = utils->GetImageAnimationMode(&mImageAnimationMode); - NS_ENSURE_SUCCESS(rv, rv); - utils->SetImageAnimationMode(imgIContainer::kDontAnimMode); + mImageAnimationMode = presContext->ImageAnimationMode(); + presContext->SetImageAnimationMode(imgIContainer::kDontAnimMode); } // The third controller takes an nsIEditor as the context diff --git a/embedding/browser/nsWebBrowser.cpp b/embedding/browser/nsWebBrowser.cpp index 4911a8eef4c0..af416e9655bf 100644 --- a/embedding/browser/nsWebBrowser.cpp +++ b/embedding/browser/nsWebBrowser.cpp @@ -1637,7 +1637,7 @@ NS_IMETHODIMP nsWebBrowser::EnsureDocShellTreeOwner() return NS_OK; } -static void DrawThebesLayer(ThebesLayer* aLayer, +static void DrawPaintedLayer(PaintedLayer* aLayer, gfxContext* aContext, const nsIntRegion& aRegionToDraw, DrawRegionClip aClip, @@ -1682,14 +1682,14 @@ bool nsWebBrowser::PaintWindow(nsIWidget* aWidget, nsIntRegion aRegion) NS_ASSERTION(layerManager, "Must be in paint event"); layerManager->BeginTransaction(); - nsRefPtr root = layerManager->CreateThebesLayer(); + nsRefPtr root = layerManager->CreatePaintedLayer(); if (root) { nsIntRect dirtyRect = aRegion.GetBounds(); root->SetVisibleRegion(dirtyRect); layerManager->SetRoot(root); } - layerManager->EndTransaction(DrawThebesLayer, &mBackgroundColor); + layerManager->EndTransaction(DrawPaintedLayer, &mBackgroundColor); return true; } diff --git a/gfx/layers/CompositorTypes.h b/gfx/layers/CompositorTypes.h index a37bd58fd99c..a01fffc24059 100644 --- a/gfx/layers/CompositorTypes.h +++ b/gfx/layers/CompositorTypes.h @@ -162,16 +162,16 @@ MOZ_BEGIN_ENUM_CLASS(CompositableType, uint8_t) BUFFER_IMAGE_SINGLE, // image/canvas with a single texture, single buffered BUFFER_IMAGE_BUFFERED, // canvas, double buffered BUFFER_BRIDGE, // image bridge protocol - BUFFER_CONTENT_INC, // thebes layer interface, only sends incremental + BUFFER_CONTENT_INC, // painted layer interface, only sends incremental // updates to a texture on the compositor side. // somewhere in the middle - BUFFER_TILED, // tiled thebes layer + BUFFER_TILED, // tiled painted layer BUFFER_SIMPLE_TILED, // the new compositable types IMAGE, // image with single buffering IMAGE_OVERLAY, // image without buffer - CONTENT_SINGLE, // thebes layer interface, single buffering - CONTENT_DOUBLE, // thebes layer interface, double buffering + CONTENT_SINGLE, // painted layer interface, single buffering + CONTENT_DOUBLE, // painted layer interface, double buffering BUFFER_COUNT MOZ_END_ENUM_CLASS(CompositableType) diff --git a/gfx/layers/ImageLayers.cpp b/gfx/layers/ImageLayers.cpp index 4bc27b44c807..daabe084543d 100644 --- a/gfx/layers/ImageLayers.cpp +++ b/gfx/layers/ImageLayers.cpp @@ -44,8 +44,8 @@ void ImageLayer::ComputeEffectiveTransforms(const gfx::Matrix4x4& aTransformToSu } // Snap our local transform first, and snap the inherited transform as well. // This makes our snapping equivalent to what would happen if our content - // was drawn into a ThebesLayer (gfxContext would snap using the local - // transform, then we'd snap again when compositing the ThebesLayer). + // was drawn into a PaintedLayer (gfxContext would snap using the local + // transform, then we'd snap again when compositing the PaintedLayer). mEffectiveTransform = SnapTransform(local, sourceRect, nullptr) * SnapTransformTranslation(aTransformToSurface, nullptr); diff --git a/gfx/layers/ImageTypes.h b/gfx/layers/ImageTypes.h index 5685a3224d0b..e6ebe3929251 100644 --- a/gfx/layers/ImageTypes.h +++ b/gfx/layers/ImageTypes.h @@ -36,7 +36,7 @@ MOZ_BEGIN_ENUM_CLASS(ImageFormat) * The CAIRO_SURFACE format creates a CairoImage. All backends should * support this format, because video rendering sometimes requires it. * - * This format is useful even though a ThebesLayer could be used. + * This format is useful even though a PaintedLayer could be used. * It makes it easy to render a cairo surface when another Image format * could be used. It can also avoid copying the surface data in some * cases. diff --git a/gfx/layers/LayerMetricsWrapper.h b/gfx/layers/LayerMetricsWrapper.h index 384c28437849..f62d99e45f78 100644 --- a/gfx/layers/LayerMetricsWrapper.h +++ b/gfx/layers/LayerMetricsWrapper.h @@ -77,7 +77,7 @@ namespace layers { * layers C1...Cn, where C1 has FrameMetrics FM1 and Cn has FrameMetrics Fn. * Although in this example C (in the first layer tree) and C0 (in the second * layer tree) are both ContainerLayers (because they have children), they - * do not have to be. They may just be ThebesLayers or ColorLayers, for example, + * do not have to be. They may just be PaintedLayers or ColorLayers, for example, * which do not have any children. However, the type of C will always be the * same as the type of C0. * diff --git a/gfx/layers/LayerScope.cpp b/gfx/layers/LayerScope.cpp index 649dbbdf702e..b1a7fd326759 100644 --- a/gfx/layers/LayerScope.cpp +++ b/gfx/layers/LayerScope.cpp @@ -715,7 +715,7 @@ SenderHelper::SendLayer(LayerComposite* aLayer, } case Layer::TYPE_IMAGE: case Layer::TYPE_CANVAS: - case Layer::TYPE_THEBES: { + case Layer::TYPE_PAINTED: { // Get CompositableHost and Compositor CompositableHost* compHost = aLayer->GetCompositableHost(); Compositor* comp = compHost->GetCompositor(); diff --git a/gfx/layers/Layers.cpp b/gfx/layers/Layers.cpp index 76357c047418..0535afc64a49 100644 --- a/gfx/layers/Layers.cpp +++ b/gfx/layers/Layers.cpp @@ -1151,11 +1151,11 @@ ContainerLayer::HasOpaqueAncestorLayer(Layer* aLayer) void ContainerLayer::DidRemoveChild(Layer* aLayer) { - ThebesLayer* tl = aLayer->AsThebesLayer(); + PaintedLayer* tl = aLayer->AsPaintedLayer(); if (tl && tl->UsedForReadback()) { for (Layer* l = mFirstChild; l; l = l->GetNextSibling()) { if (l->GetType() == TYPE_READBACK) { - static_cast(l)->NotifyThebesLayerRemoved(tl); + static_cast(l)->NotifyPaintedLayerRemoved(tl); } } } @@ -1343,7 +1343,7 @@ Layer::Dump(std::stringstream& aStream, const char* aPrefix, bool aDumpHtml) if (aDumpHtml) { aStream << nsPrintfCString("
  • mutable_layer(aPacket->layer_size()-1); - layer->set_type(LayersPacket::Layer::ThebesLayer); + layer->set_type(LayersPacket::Layer::PaintedLayer); if (!mValidRegion.IsEmpty()) { DumpRegion(layer->mutable_valid(), mValidRegion); } diff --git a/gfx/layers/Layers.h b/gfx/layers/Layers.h index 272ed32dd3f3..b0fd86f83cec 100644 --- a/gfx/layers/Layers.h +++ b/gfx/layers/Layers.h @@ -79,7 +79,7 @@ class ClientLayerManager; class CommonLayerAttributes; class Layer; class LayerMetricsWrapper; -class ThebesLayer; +class PaintedLayer; class ContainerLayer; class ImageLayer; class ColorLayer; @@ -159,8 +159,8 @@ static void LayerManagerUserDataDestroy(void *data) * BeginTransaction and BeginTransactionWithTarget start a transaction in * the Construction phase. When the client has finished constructing the layer * tree, it should call EndConstruction() to enter the drawing phase. - * 2) Drawing: ThebesLayers are rendered into in this phase, in tree - * order. When the client has finished drawing into the ThebesLayers, it should + * 2) Drawing: PaintedLayers are rendered into in this phase, in tree + * order. When the client has finished drawing into the PaintedLayers, it should * call EndTransaction to complete the transaction. * * All layer API calls happen on the main thread. @@ -235,7 +235,7 @@ public: enum EndTransactionFlags { END_DEFAULT = 0, END_NO_IMMEDIATE_REDRAW = 1 << 0, // Do not perform the drawing phase - END_NO_COMPOSITE = 1 << 1, // Do not composite after drawing thebes layer contents. + END_NO_COMPOSITE = 1 << 1, // Do not composite after drawing painted layer contents. END_NO_REMOTE_COMPOSITE = 1 << 2 // Do not schedule a composition with a remote Compositor, if one exists. }; @@ -246,7 +246,7 @@ public: /** * Attempts to end an "empty transaction". There must have been no * changes to the layer tree since the BeginTransaction(). - * It's possible for this to fail; ThebesLayers may need to be updated + * It's possible for this to fail; PaintedLayers may need to be updated * due to VRAM data being lost, for example. In such cases this method * returns false, and the caller must proceed with a normal layer tree * update and EndTransaction. @@ -254,20 +254,20 @@ public: virtual bool EndEmptyTransaction(EndTransactionFlags aFlags = END_DEFAULT) = 0; /** - * Function called to draw the contents of each ThebesLayer. + * Function called to draw the contents of each PaintedLayer. * aRegionToDraw contains the region that needs to be drawn. * This would normally be a subregion of the visible region. * The callee must draw all of aRegionToDraw. Drawing outside * aRegionToDraw will be clipped out or ignored. * The callee must draw all of aRegionToDraw. - * This region is relative to 0,0 in the ThebesLayer. + * This region is relative to 0,0 in the PaintedLayer. * * aRegionToInvalidate contains a region whose contents have been * changed by the layer manager and which must therefore be invalidated. * For example, this could be non-empty if a retained layer internally * switches from RGBA to RGB or back ... we might want to repaint it to * consistently use subpixel-AA or not. - * This region is relative to 0,0 in the ThebesLayer. + * This region is relative to 0,0 in the PaintedLayer. * aRegionToInvalidate may contain areas that are outside * aRegionToDraw; the callee must ensure that these areas are repainted * in the current layer manager transaction or in a later layer @@ -277,9 +277,9 @@ public: * We guarantee that buffered contents in the visible * region are valid once drawing is complete. * - * The origin of aContext is 0,0 in the ThebesLayer. + * The origin of aContext is 0,0 in the PaintedLayer. */ - typedef void (* DrawThebesLayerCallback)(ThebesLayer* aLayer, + typedef void (* DrawPaintedLayerCallback)(PaintedLayer* aLayer, gfxContext* aContext, const nsIntRegion& aRegionToDraw, DrawRegionClip aClip, @@ -289,11 +289,11 @@ public: /** * Finish the construction phase of the transaction, perform the * drawing phase, and end the transaction. - * During the drawing phase, all ThebesLayers in the tree are + * During the drawing phase, all PaintedLayers in the tree are * drawn in tree order, exactly once each, except for those layers * where it is known that the visible region is empty. */ - virtual void EndTransaction(DrawThebesLayerCallback aCallback, + virtual void EndTransaction(DrawPaintedLayerCallback aCallback, void* aCallbackData, EndTransactionFlags aFlags = END_DEFAULT) = 0; @@ -373,35 +373,35 @@ public: #endif /** - * Hints that can be used during Thebes layer creation to influence the type + * Hints that can be used during PaintedLayer creation to influence the type * or properties of the layer created. * * NONE: No hint. * SCROLLABLE: This layer may represent scrollable content. */ - enum ThebesLayerCreationHint { + enum PaintedLayerCreationHint { NONE, SCROLLABLE }; /** - * Returns true if aLayer is optimized for the given ThebesLayerCreationHint. + * Returns true if aLayer is optimized for the given PaintedLayerCreationHint. */ - virtual bool IsOptimizedFor(ThebesLayer* aLayer, - ThebesLayerCreationHint aCreationHint) + virtual bool IsOptimizedFor(PaintedLayer* aLayer, + PaintedLayerCreationHint aCreationHint) { return true; } /** * CONSTRUCTION PHASE ONLY - * Create a ThebesLayer for this manager's layer tree. + * Create a PaintedLayer for this manager's layer tree. */ - virtual already_AddRefed CreateThebesLayer() = 0; + virtual already_AddRefed CreatePaintedLayer() = 0; /** * CONSTRUCTION PHASE ONLY - * Create a ThebesLayer for this manager's layer tree, with a creation hint + * Create a PaintedLayer for this manager's layer tree, with a creation hint * parameter to help optimise the type of layer created. */ - virtual already_AddRefed CreateThebesLayerWithHint(ThebesLayerCreationHint) { - return CreateThebesLayer(); + virtual already_AddRefed CreatePaintedLayerWithHint(PaintedLayerCreationHint) { + return CreatePaintedLayer(); } /** * CONSTRUCTION PHASE ONLY @@ -738,7 +738,7 @@ public: TYPE_READBACK, TYPE_REF, TYPE_SHADOW, - TYPE_THEBES + TYPE_PAINTED }; /** @@ -791,7 +791,7 @@ public: /** * CONSTRUCTION PHASE ONLY * This lets layout make some promises about what will be drawn into the - * visible region of the ThebesLayer. This enables internal quality + * visible region of the PaintedLayer. This enables internal quality * and performance optimizations. */ void SetContentFlags(uint32_t aFlags) @@ -1323,10 +1323,10 @@ public: virtual void Disconnect() {} /** - * Dynamic downcast to a Thebes layer. Returns null if this is not - * a ThebesLayer. + * Dynamic downcast to a PaintedLayer. Returns null if this is not + * a PaintedLayer. */ - virtual ThebesLayer* AsThebesLayer() { return nullptr; } + virtual PaintedLayer* AsPaintedLayer() { return nullptr; } /** * Dynamic cast to a ContainerLayer. Returns null if this is not @@ -1655,17 +1655,17 @@ protected: }; /** - * A Layer which we can draw into using Thebes. It is a conceptually - * infinite surface, but each ThebesLayer has an associated "valid region" - * of contents that it is currently storing, which is finite. ThebesLayer + * A Layer which we can paint into. It is a conceptually + * infinite surface, but each PaintedLayer has an associated "valid region" + * of contents that it is currently storing, which is finite. PaintedLayer * implementations can store content between paints. * - * ThebesLayers are rendered into during the drawing phase of a transaction. + * PaintedLayers are rendered into during the drawing phase of a transaction. * - * Currently the contents of a ThebesLayer are in the device output color + * Currently the contents of a PaintedLayer are in the device output color * space. */ -class ThebesLayer : public Layer { +class PaintedLayer : public Layer { public: /** * CONSTRUCTION PHASE ONLY @@ -1678,7 +1678,7 @@ public: * CONSTRUCTION PHASE ONLY * Set whether ComputeEffectiveTransforms should compute the * "residual translation" --- the translation that should be applied *before* - * mEffectiveTransform to get the ideal transform for this ThebesLayer. + * mEffectiveTransform to get the ideal transform for this PaintedLayer. * When this is true, ComputeEffectiveTransforms will compute the residual * and ensure that the layer is invalidated whenever the residual changes. * When it's false, a change in the residual will not trigger invalidation @@ -1693,9 +1693,9 @@ public: */ const nsIntRegion& GetValidRegion() const { return mValidRegion; } - virtual ThebesLayer* AsThebesLayer() { return this; } + virtual PaintedLayer* AsPaintedLayer() { return this; } - MOZ_LAYER_DECL_NAME("ThebesLayer", TYPE_THEBES) + MOZ_LAYER_DECL_NAME("PaintedLayer", TYPE_PAINTED) virtual void ComputeEffectiveTransforms(const gfx::Matrix4x4& aTransformToSurface) { @@ -1717,13 +1717,13 @@ public: ComputeEffectiveTransformForMaskLayer(aTransformToSurface); } - LayerManager::ThebesLayerCreationHint GetCreationHint() const { return mCreationHint; } + LayerManager::PaintedLayerCreationHint GetCreationHint() const { return mCreationHint; } bool UsedForReadback() { return mUsedForReadback; } void SetUsedForReadback(bool aUsed) { mUsedForReadback = aUsed; } /** * Returns the residual translation. Apply this translation when drawing - * into the ThebesLayer so that when mEffectiveTransform is applied afterwards + * into the PaintedLayer so that when mEffectiveTransform is applied afterwards * by layer compositing, the results exactly match the "ideal transform" * (the product of the transform of this layer and its ancestors). * Returns 0,0 unless SetAllowResidualTranslation(true) has been called. @@ -1732,8 +1732,8 @@ public: gfxPoint GetResidualTranslation() const { return mResidualTranslation; } protected: - ThebesLayer(LayerManager* aManager, void* aImplData, - LayerManager::ThebesLayerCreationHint aCreationHint = LayerManager::NONE) + PaintedLayer(LayerManager* aManager, void* aImplData, + LayerManager::PaintedLayerCreationHint aCreationHint = LayerManager::NONE) : Layer(aManager, aImplData) , mValidRegion() , mCreationHint(aCreationHint) @@ -1757,9 +1757,9 @@ protected: /** * The creation hint that was used when constructing this layer. */ - const LayerManager::ThebesLayerCreationHint mCreationHint; + const LayerManager::PaintedLayerCreationHint mCreationHint; /** - * Set when this ThebesLayer is participating in readback, i.e. some + * Set when this PaintedLayer is participating in readback, i.e. some * ReadbackLayer (may) be getting its background from this layer. */ bool mUsedForReadback; @@ -2127,8 +2127,8 @@ public: { // Snap our local transform first, and snap the inherited transform as well. // This makes our snapping equivalent to what would happen if our content - // was drawn into a ThebesLayer (gfxContext would snap using the local - // transform, then we'd snap again when compositing the ThebesLayer). + // was drawn into a PaintedLayer (gfxContext would snap using the local + // transform, then we'd snap again when compositing the PaintedLayer). mEffectiveTransform = SnapTransform(GetLocalTransform(), gfxRect(0, 0, mBounds.width, mBounds.height), nullptr)* diff --git a/gfx/layers/ReadbackLayer.h b/gfx/layers/ReadbackLayer.h index b1aaad2b0dc6..7786d0603e94 100644 --- a/gfx/layers/ReadbackLayer.h +++ b/gfx/layers/ReadbackLayer.h @@ -91,8 +91,8 @@ public: { // Snap our local transform first, and snap the inherited transform as well. // This makes our snapping equivalent to what would happen if our content - // was drawn into a ThebesLayer (gfxContext would snap using the local - // transform, then we'd snap again when compositing the ThebesLayer). + // was drawn into a PaintedLayer (gfxContext would snap using the local + // transform, then we'd snap again when compositing the PaintedLayer). mEffectiveTransform = SnapTransform(GetLocalTransform(), gfxRect(0, 0, mSize.width, mSize.height), nullptr)* @@ -140,7 +140,7 @@ public: mSink = nullptr; } - void NotifyThebesLayerRemoved(ThebesLayer* aLayer) + void NotifyPaintedLayerRemoved(PaintedLayer* aLayer) { if (mBackgroundLayer == aLayer) { mBackgroundLayer = nullptr; @@ -182,14 +182,14 @@ protected: nsAutoPtr mSink; nsIntSize mSize; - // This can refer to any (earlier) sibling ThebesLayer. That ThebesLayer - // must have mUsedForReadback set on it. If the ThebesLayer is removed - // for the container, this will be set to null by NotifyThebesLayerRemoved. - // This ThebesLayer contains the contents which have previously been reported - // to mSink. The ThebesLayer had only an integer translation transform, + // This can refer to any (earlier) sibling PaintedLayer. That PaintedLayer + // must have mUsedForReadback set on it. If the PaintedLayer is removed + // for the container, this will be set to null by NotifyPaintedLayerRemoved. + // This PaintedLayer contains the contents which have previously been reported + // to mSink. The PaintedLayer had only an integer translation transform, // and it covered the entire readback area. This layer also had only an // integer translation transform. - ThebesLayer* mBackgroundLayer; + PaintedLayer* mBackgroundLayer; // When mBackgroundLayer is non-null, this is the offset to add to // convert from the coordinates of mBackgroundLayer to the coordinates // of this layer. diff --git a/gfx/layers/ReadbackProcessor.cpp b/gfx/layers/ReadbackProcessor.cpp index b534a07ccb1d..f0669431abab 100644 --- a/gfx/layers/ReadbackProcessor.cpp +++ b/gfx/layers/ReadbackProcessor.cpp @@ -5,7 +5,7 @@ #include "ReadbackProcessor.h" #include // for int32_t -#include "Layers.h" // for Layer, ThebesLayer, etc +#include "Layers.h" // for Layer, PaintedLayer, etc #include "ReadbackLayer.h" // for ReadbackLayer, ReadbackSink #include "gfxColor.h" // for gfxRGBA #include "gfxContext.h" // for gfxContext @@ -77,7 +77,7 @@ FindBackgroundLayer(ReadbackLayer* aLayer, nsIntPoint* aOffset) return nullptr; Layer::LayerType type = l->GetType(); - if (type != Layer::TYPE_COLOR && type != Layer::TYPE_THEBES) + if (type != Layer::TYPE_COLOR && type != Layer::TYPE_PAINTED) return nullptr; *aOffset = backgroundOffset - transformOffset; @@ -119,19 +119,19 @@ ReadbackProcessor::BuildUpdatesForLayer(ReadbackLayer* aLayer) } } } else { - NS_ASSERTION(newBackground->AsThebesLayer(), "Must be ThebesLayer"); - ThebesLayer* thebesLayer = static_cast(newBackground); - // updateRect is relative to the ThebesLayer + NS_ASSERTION(newBackground->AsPaintedLayer(), "Must be PaintedLayer"); + PaintedLayer* paintedLayer = static_cast(newBackground); + // updateRect is relative to the PaintedLayer nsIntRect updateRect = aLayer->GetRect() - offset; - if (thebesLayer != aLayer->mBackgroundLayer || + if (paintedLayer != aLayer->mBackgroundLayer || offset != aLayer->mBackgroundLayerOffset) { - aLayer->mBackgroundLayer = thebesLayer; + aLayer->mBackgroundLayer = paintedLayer; aLayer->mBackgroundLayerOffset = offset; aLayer->mBackgroundColor = gfxRGBA(0,0,0,0); - thebesLayer->SetUsedForReadback(true); + paintedLayer->SetUsedForReadback(true); } else { nsIntRegion invalid; - invalid.Sub(updateRect, thebesLayer->GetValidRegion()); + invalid.Sub(updateRect, paintedLayer->GetValidRegion()); updateRect = invalid.GetBounds(); } @@ -141,11 +141,11 @@ ReadbackProcessor::BuildUpdatesForLayer(ReadbackLayer* aLayer) } void -ReadbackProcessor::GetThebesLayerUpdates(ThebesLayer* aLayer, +ReadbackProcessor::GetPaintedLayerUpdates(PaintedLayer* aLayer, nsTArray* aUpdates, nsIntRegion* aUpdateRegion) { - // All ThebesLayers used for readback are in mAllUpdates (some possibly + // All PaintedLayers used for readback are in mAllUpdates (some possibly // with an empty update rect). aLayer->SetUsedForReadback(false); if (aUpdateRegion) { diff --git a/gfx/layers/ReadbackProcessor.h b/gfx/layers/ReadbackProcessor.h index 96c365ee5c21..dbd404db6d46 100644 --- a/gfx/layers/ReadbackProcessor.h +++ b/gfx/layers/ReadbackProcessor.h @@ -17,32 +17,32 @@ namespace layers { class ContainerLayer; class ReadbackLayer; -class ThebesLayer; +class PaintedLayer; class ReadbackProcessor { public: /** * Called by the container before processing any child layers. Call this * if any child layer might have changed in any way (other than content-only - * changes to layers other than ColorLayers and ThebesLayers). + * changes to layers other than ColorLayers and PaintedLayers). * * This method recomputes the relationship between ReadbackLayers and * sibling layers, and dispatches changes to ReadbackLayers. Except that - * if a ThebesLayer needs its contents sent to some ReadbackLayer, we'll - * just record that internally and later the ThebesLayer should call - * GetThebesLayerUpdates when it paints, to find out which rectangle needs + * if a PaintedLayer needs its contents sent to some ReadbackLayer, we'll + * just record that internally and later the PaintedLayer should call + * GetPaintedLayerUpdates when it paints, to find out which rectangle needs * to be sent, and the ReadbackLayer it needs to be sent to. */ void BuildUpdates(ContainerLayer* aContainer); struct Update { /** - * The layer a ThebesLayer should send its contents to. + * The layer a PaintedLayer should send its contents to. */ ReadbackLayer* mLayer; /** - * The rectangle of content that it should send, in the ThebesLayer's - * coordinate system. This rectangle is guaranteed to be in the ThebesLayer's + * The rectangle of content that it should send, in the PaintedLayer's + * coordinate system. This rectangle is guaranteed to be in the PaintedLayer's * visible region. Translate it to mLayer's coordinate system * by adding mLayer->GetBackgroundLayerOffset(). */ @@ -54,16 +54,16 @@ public: }; /** * Appends any ReadbackLayers that need to be updated, and the rects that - * need to be updated, to aUpdates. Only need to call this for ThebesLayers + * need to be updated, to aUpdates. Only need to call this for PaintedLayers * that have been marked UsedForReadback(). * Each Update's mLayer's mBackgroundLayer will have been set to aLayer. - * If a ThebesLayer doesn't call GetThebesLayerUpdates, then all the - * ReadbackLayers that needed data from that ThebesLayer will be marked + * If a PaintedLayer doesn't call GetPaintedLayerUpdates, then all the + * ReadbackLayers that needed data from that PaintedLayer will be marked * as having unknown backgrounds. * @param aUpdateRegion if non-null, this region is set to the union * of the mUpdateRects. */ - void GetThebesLayerUpdates(ThebesLayer* aLayer, + void GetPaintedLayerUpdates(PaintedLayer* aLayer, nsTArray* aUpdates, nsIntRegion* aUpdateRegion = nullptr); diff --git a/gfx/layers/RotatedBuffer.cpp b/gfx/layers/RotatedBuffer.cpp index d098f93519f0..fbf23bf1a384 100644 --- a/gfx/layers/RotatedBuffer.cpp +++ b/gfx/layers/RotatedBuffer.cpp @@ -10,7 +10,7 @@ #include "BasicLayersImpl.h" // for ToData #include "BufferUnrotate.h" // for BufferUnrotate #include "GeckoProfiler.h" // for PROFILER_LABEL -#include "Layers.h" // for ThebesLayer, Layer, etc +#include "Layers.h" // for PaintedLayer, Layer, etc #include "gfxPlatform.h" // for gfxPlatform #include "gfxPrefs.h" // for gfxPrefs #include "gfxUtils.h" // for gfxUtils @@ -203,7 +203,7 @@ RotatedContentBuffer::IsClippingCheap(DrawTarget* aTarget, const nsIntRegion& aR } void -RotatedContentBuffer::DrawTo(ThebesLayer* aLayer, +RotatedContentBuffer::DrawTo(PaintedLayer* aLayer, DrawTarget* aTarget, float aOpacity, CompositionOp aOp, @@ -428,7 +428,7 @@ RotatedContentBuffer::FlushBuffers() } RotatedContentBuffer::PaintState -RotatedContentBuffer::BeginPaint(ThebesLayer* aLayer, +RotatedContentBuffer::BeginPaint(PaintedLayer* aLayer, uint32_t aFlags) { PaintState result; diff --git a/gfx/layers/RotatedBuffer.h b/gfx/layers/RotatedBuffer.h index c2e098ee6bd2..51c70f918af3 100644 --- a/gfx/layers/RotatedBuffer.h +++ b/gfx/layers/RotatedBuffer.h @@ -31,7 +31,7 @@ class Matrix; namespace layers { class TextureClient; -class ThebesLayer; +class PaintedLayer; /** * This is a cairo/Thebes surface, but with a literal twist. Scrolling @@ -115,7 +115,7 @@ protected: gfx::SourceSurface* aMask, const gfx::Matrix* aMaskTransform) const; - /** The area of the ThebesLayer that is covered by the buffer as a whole */ + /** The area of the PaintedLayer that is covered by the buffer as a whole */ nsIntRect mBufferRect; /** * The x and y rotation of the buffer. Conceptually the buffer @@ -169,7 +169,7 @@ protected: }; /** - * This class encapsulates the buffer used to retain ThebesLayer contents, + * This class encapsulates the buffer used to retain PaintedLayer contents, * i.e., the contents of the layer's GetVisibleRegion(). */ class RotatedContentBuffer : public RotatedBuffer @@ -181,7 +181,7 @@ public: /** * Controls the size of the backing buffer of this. * - SizedToVisibleBounds: the backing buffer is exactly the same - * size as the bounds of ThebesLayer's visible region + * size as the bounds of PaintedLayer's visible region * - ContainsVisibleBounds: the backing buffer is large enough to * fit visible bounds. May be larger. */ @@ -267,7 +267,7 @@ public: * will need to call BorrowDrawTargetForPainting multiple times to achieve * this. */ - PaintState BeginPaint(ThebesLayer* aLayer, + PaintState BeginPaint(PaintedLayer* aLayer, uint32_t aFlags); struct DrawIterator { @@ -333,7 +333,7 @@ public: * drawn before this is called. The contents of the buffer are drawn * to aTarget. */ - void DrawTo(ThebesLayer* aLayer, + void DrawTo(PaintedLayer* aLayer, gfx::DrawTarget* aTarget, float aOpacity, gfx::CompositionOp aOp, diff --git a/gfx/layers/basic/BasicContainerLayer.cpp b/gfx/layers/basic/BasicContainerLayer.cpp index 1c72bd215849..409bd6cb36b8 100644 --- a/gfx/layers/basic/BasicContainerLayer.cpp +++ b/gfx/layers/basic/BasicContainerLayer.cpp @@ -115,7 +115,7 @@ BasicContainerLayer::ChildrenPartitionVisibleRegion(const nsIntRect& aInRect) } void -BasicContainerLayer::Validate(LayerManager::DrawThebesLayerCallback aCallback, +BasicContainerLayer::Validate(LayerManager::DrawPaintedLayerCallback aCallback, void* aCallbackData, ReadbackProcessor* aReadback) { diff --git a/gfx/layers/basic/BasicContainerLayer.h b/gfx/layers/basic/BasicContainerLayer.h index 7cc2f6dbcab8..da1abd95b9a9 100644 --- a/gfx/layers/basic/BasicContainerLayer.h +++ b/gfx/layers/basic/BasicContainerLayer.h @@ -84,7 +84,7 @@ public: void SetSupportsComponentAlphaChildren(bool aSupports) { mSupportsComponentAlphaChildren = aSupports; } - virtual void Validate(LayerManager::DrawThebesLayerCallback aCallback, + virtual void Validate(LayerManager::DrawPaintedLayerCallback aCallback, void* aCallbackData, ReadbackProcessor* aReadback) MOZ_OVERRIDE; diff --git a/gfx/layers/basic/BasicImplData.h b/gfx/layers/basic/BasicImplData.h index a57fcb91c8b9..6e73da76dc6d 100644 --- a/gfx/layers/basic/BasicImplData.h +++ b/gfx/layers/basic/BasicImplData.h @@ -21,7 +21,7 @@ class SurfaceDescriptor; * This is the ImplData for all Basic layers. It also exposes methods * private to the Basic implementation that are common to all Basic layer types. * In particular, there is an internal Paint() method that we can use - * to paint the contents of non-Thebes layers. + * to paint the contents of non-PaintedLayers. * * The class hierarchy for Basic layers is like this: * BasicImplData @@ -31,9 +31,9 @@ class SurfaceDescriptor; * | | | | | * | +-> BasicContainerLayer <--+ | | * | | | - * +-> ThebesLayer | | + * +-> PaintedLayer | | * | | | | - * | +-> BasicThebesLayer <---------+ | + * | +-> BasicPaintedLayer <---------+ | * | | * +-> ImageLayer | * | | @@ -64,17 +64,17 @@ public: Layer* aMaskLayer) {} /** - * Like Paint() but called for ThebesLayers with the additional parameters + * Like Paint() but called for PaintedLayers with the additional parameters * they need. * If mClipToVisibleRegion is set, then the layer must clip to its * effective visible region (snapped or unsnapped, it doesn't matter). */ virtual void PaintThebes(gfxContext* aContext, Layer* aMasklayer, - LayerManager::DrawThebesLayerCallback aCallback, + LayerManager::DrawPaintedLayerCallback aCallback, void* aCallbackData) {} - virtual void Validate(LayerManager::DrawThebesLayerCallback aCallback, + virtual void Validate(LayerManager::DrawPaintedLayerCallback aCallback, void* aCallbackData, ReadbackProcessor* aReadback) {} diff --git a/gfx/layers/basic/BasicLayerManager.cpp b/gfx/layers/basic/BasicLayerManager.cpp index 0a2266700290..36093415b482 100644 --- a/gfx/layers/basic/BasicLayerManager.cpp +++ b/gfx/layers/basic/BasicLayerManager.cpp @@ -126,7 +126,7 @@ ToInsideIntRect(const gfxRect& aRect) class PaintLayerContext { public: PaintLayerContext(gfxContext* aTarget, Layer* aLayer, - LayerManager::DrawThebesLayerCallback aCallback, + LayerManager::DrawPaintedLayerCallback aCallback, void* aCallbackData) : mTarget(aTarget) , mTargetMatrixSR(aTarget) @@ -196,7 +196,7 @@ public: gfxContext* mTarget; gfxContextMatrixAutoSaveRestore mTargetMatrixSR; Layer* mLayer; - LayerManager::DrawThebesLayerCallback mCallback; + LayerManager::DrawPaintedLayerCallback mCallback; void* mCallbackData; Matrix mTransform; bool mPushedOpaqueRect; @@ -445,7 +445,7 @@ ApplyDoubleBuffering(Layer* aLayer, const nsIntRect& aVisibleRect) } void -BasicLayerManager::EndTransaction(DrawThebesLayerCallback aCallback, +BasicLayerManager::EndTransaction(DrawPaintedLayerCallback aCallback, void* aCallbackData, EndTransactionFlags aFlags) { @@ -464,7 +464,7 @@ BasicLayerManager::AbortTransaction() } bool -BasicLayerManager::EndTransactionInternal(DrawThebesLayerCallback aCallback, +BasicLayerManager::EndTransactionInternal(DrawPaintedLayerCallback aCallback, void* aCallbackData, EndTransactionFlags aFlags) { @@ -727,7 +727,7 @@ BasicLayerManager::PaintSelfOrChildren(PaintLayerContext& aPaintContext, /* Only paint ourself, or our children - This optimization relies on this! */ Layer* child = aPaintContext.mLayer->GetFirstChild(); if (!child) { - if (aPaintContext.mLayer->AsThebesLayer()) { + if (aPaintContext.mLayer->AsPaintedLayer()) { data->PaintThebes(aGroupTarget, aPaintContext.mLayer->GetMaskLayer(), aPaintContext.mCallback, aPaintContext.mCallbackData); } else { @@ -778,7 +778,7 @@ BasicLayerManager::FlushGroup(PaintLayerContext& aPaintContext, bool aNeedsClipT void BasicLayerManager::PaintLayer(gfxContext* aTarget, Layer* aLayer, - DrawThebesLayerCallback aCallback, + DrawPaintedLayerCallback aCallback, void* aCallbackData) { PROFILER_LABEL("BasicLayerManager", "PaintLayer", @@ -802,7 +802,7 @@ BasicLayerManager::PaintLayer(gfxContext* aTarget, container->UseIntermediateSurface(); BasicImplData* data = ToData(aLayer); bool needsClipToVisibleRegion = - data->GetClipToVisibleRegion() && !aLayer->AsThebesLayer(); + data->GetClipToVisibleRegion() && !aLayer->AsPaintedLayer(); NS_ASSERTION(needsGroup || !aLayer->GetFirstChild() || container->GetOperator() == CompositionOp::OP_OVER, "non-OVER operator should have forced UseIntermediateSurface"); diff --git a/gfx/layers/basic/BasicLayers.h b/gfx/layers/basic/BasicLayers.h index 352e4157718b..8c13629a5020 100644 --- a/gfx/layers/basic/BasicLayers.h +++ b/gfx/layers/basic/BasicLayers.h @@ -37,7 +37,7 @@ class ReadbackProcessor; * This is a cairo/Thebes-only, main-thread-only implementation of layers. * * In each transaction, the client sets up the layer tree and then during - * the drawing phase, each ThebesLayer is painted directly into the target + * the drawing phase, each PaintedLayer is painted directly into the target * context (with appropriate clipping and Push/PopGroups performed * between layers). */ @@ -53,16 +53,16 @@ public: /** * Construct a BasicLayerManager which will have no default * target context. SetDefaultTarget or BeginTransactionWithTarget - * must be called for any rendering to happen. ThebesLayers will not + * must be called for any rendering to happen. PaintedLayers will not * be retained. */ explicit BasicLayerManager(BasicLayerManagerType aType); /** * Construct a BasicLayerManager which will have no default * target context. SetDefaultTarget or BeginTransactionWithTarget - * must be called for any rendering to happen. ThebesLayers will be + * must be called for any rendering to happen. PaintedLayers will be * retained; that is, we will try to retain the visible contents of - * ThebesLayers as cairo surfaces. We create ThebesLayer buffers by + * PaintedLayers as cairo surfaces. We create PaintedLayer buffers by * creating similar surfaces to the default target context, or to * aWidget's GetThebesSurface if there is no default target context, or * to the passed-in context if there is no widget and no default @@ -102,7 +102,7 @@ public: virtual void BeginTransaction(); virtual void BeginTransactionWithTarget(gfxContext* aTarget); virtual bool EndEmptyTransaction(EndTransactionFlags aFlags = END_DEFAULT); - virtual void EndTransaction(DrawThebesLayerCallback aCallback, + virtual void EndTransaction(DrawPaintedLayerCallback aCallback, void* aCallbackData, EndTransactionFlags aFlags = END_DEFAULT); virtual bool ShouldAvoidComponentAlphaLayers() { return IsWidgetLayerManager(); } @@ -111,7 +111,7 @@ public: virtual void SetRoot(Layer* aLayer); - virtual already_AddRefed CreateThebesLayer(); + virtual already_AddRefed CreatePaintedLayer(); virtual already_AddRefed CreateContainerLayer(); virtual already_AddRefed CreateImageLayer(); virtual already_AddRefed CreateCanvasLayer(); @@ -169,19 +169,19 @@ protected: // Paints aLayer to mTarget. void PaintLayer(gfxContext* aTarget, Layer* aLayer, - DrawThebesLayerCallback aCallback, + DrawPaintedLayerCallback aCallback, void* aCallbackData); // Clear the contents of a layer void ClearLayer(Layer* aLayer); - bool EndTransactionInternal(DrawThebesLayerCallback aCallback, + bool EndTransactionInternal(DrawPaintedLayerCallback aCallback, void* aCallbackData, EndTransactionFlags aFlags = END_DEFAULT); void FlashWidgetUpdateArea(gfxContext* aContext); - // Widget whose surface should be used as the basis for ThebesLayer + // Widget whose surface should be used as the basis for PaintedLayer // buffers. nsIWidget* mWidget; // The default context for BeginTransaction. diff --git a/gfx/layers/basic/BasicThebesLayer.cpp b/gfx/layers/basic/BasicPaintedLayer.cpp similarity index 94% rename from gfx/layers/basic/BasicThebesLayer.cpp rename to gfx/layers/basic/BasicPaintedLayer.cpp index 6db2bd7006d1..1180f45a3126 100644 --- a/gfx/layers/basic/BasicThebesLayer.cpp +++ b/gfx/layers/basic/BasicPaintedLayer.cpp @@ -3,7 +3,7 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -#include "BasicThebesLayer.h" +#include "BasicPaintedLayer.h" #include // for uint32_t #include "GeckoProfiler.h" // for PROFILER_LABEL #include "ReadbackLayer.h" // for ReadbackLayer, ReadbackSink @@ -45,12 +45,12 @@ IntersectWithClip(const nsIntRegion& aRegion, gfxContext* aContext) } void -BasicThebesLayer::PaintThebes(gfxContext* aContext, +BasicPaintedLayer::PaintThebes(gfxContext* aContext, Layer* aMaskLayer, - LayerManager::DrawThebesLayerCallback aCallback, + LayerManager::DrawPaintedLayerCallback aCallback, void* aCallbackData) { - PROFILER_LABEL("BasicThebesLayer", "PaintThebes", + PROFILER_LABEL("BasicPaintedLayer", "PaintThebes", js::ProfileEntry::Category::GRAPHICS); NS_ASSERTION(BasicManager()->InDrawing(), @@ -132,7 +132,7 @@ BasicThebesLayer::PaintThebes(gfxContext* aContext, } void -BasicThebesLayer::Validate(LayerManager::DrawThebesLayerCallback aCallback, +BasicPaintedLayer::Validate(LayerManager::DrawPaintedLayerCallback aCallback, void* aCallbackData, ReadbackProcessor* aReadback) { @@ -148,7 +148,7 @@ BasicThebesLayer::Validate(LayerManager::DrawThebesLayerCallback aCallback, nsTArray readbackUpdates; if (aReadback && UsedForReadback()) { - aReadback->GetThebesLayerUpdates(this, &readbackUpdates); + aReadback->GetPaintedLayerUpdates(this, &readbackUpdates); } uint32_t flags = 0; @@ -218,11 +218,11 @@ BasicThebesLayer::Validate(LayerManager::DrawThebesLayerCallback aCallback, } } -already_AddRefed -BasicLayerManager::CreateThebesLayer() +already_AddRefed +BasicLayerManager::CreatePaintedLayer() { NS_ASSERTION(InConstruction(), "Only allowed in construction phase"); - nsRefPtr layer = new BasicThebesLayer(this); + nsRefPtr layer = new BasicPaintedLayer(this); return layer.forget(); } diff --git a/gfx/layers/basic/BasicThebesLayer.h b/gfx/layers/basic/BasicPaintedLayer.h similarity index 83% rename from gfx/layers/basic/BasicThebesLayer.h rename to gfx/layers/basic/BasicPaintedLayer.h index ffbbe8259b27..db4935df53b2 100644 --- a/gfx/layers/basic/BasicThebesLayer.h +++ b/gfx/layers/basic/BasicPaintedLayer.h @@ -3,10 +3,10 @@ * 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 GFX_BASICTHEBESLAYER_H -#define GFX_BASICTHEBESLAYER_H +#ifndef GFX_BASICPAINTEDLAYER_H +#define GFX_BASICPAINTEDLAYER_H -#include "Layers.h" // for ThebesLayer, LayerManager, etc +#include "Layers.h" // for PaintedLayer, LayerManager, etc #include "RotatedBuffer.h" // for RotatedContentBuffer, etc #include "BasicImplData.h" // for BasicImplData #include "BasicLayers.h" // for BasicLayerManager @@ -25,23 +25,23 @@ namespace layers { class ReadbackProcessor; -class BasicThebesLayer : public ThebesLayer, public BasicImplData { +class BasicPaintedLayer : public PaintedLayer, public BasicImplData { public: typedef RotatedContentBuffer::PaintState PaintState; typedef RotatedContentBuffer::ContentType ContentType; - explicit BasicThebesLayer(BasicLayerManager* aLayerManager) : - ThebesLayer(aLayerManager, + explicit BasicPaintedLayer(BasicLayerManager* aLayerManager) : + PaintedLayer(aLayerManager, static_cast(MOZ_THIS_IN_INITIALIZER_LIST())), mContentClient(nullptr) { - MOZ_COUNT_CTOR(BasicThebesLayer); + MOZ_COUNT_CTOR(BasicPaintedLayer); } protected: - virtual ~BasicThebesLayer() + virtual ~BasicPaintedLayer() { - MOZ_COUNT_DTOR(BasicThebesLayer); + MOZ_COUNT_DTOR(BasicPaintedLayer); } public: @@ -49,7 +49,7 @@ public: { NS_ASSERTION(BasicManager()->InConstruction(), "Can only set properties in construction phase"); - ThebesLayer::SetVisibleRegion(aRegion); + PaintedLayer::SetVisibleRegion(aRegion); } virtual void InvalidateRegion(const nsIntRegion& aRegion) { @@ -62,10 +62,10 @@ public: virtual void PaintThebes(gfxContext* aContext, Layer* aMaskLayer, - LayerManager::DrawThebesLayerCallback aCallback, + LayerManager::DrawPaintedLayerCallback aCallback, void* aCallbackData); - virtual void Validate(LayerManager::DrawThebesLayerCallback aCallback, + virtual void Validate(LayerManager::DrawPaintedLayerCallback aCallback, void* aCallbackData, ReadbackProcessor* aReadback) MOZ_OVERRIDE; @@ -90,7 +90,7 @@ public: ComputeEffectiveTransformForMaskLayer(aTransformToSurface); return; } - ThebesLayer::ComputeEffectiveTransforms(aTransformToSurface); + PaintedLayer::ComputeEffectiveTransforms(aTransformToSurface); } BasicLayerManager* BasicManager() @@ -106,7 +106,7 @@ protected: const nsIntRegion& aRegionToInvalidate, bool aDidSelfCopy, DrawRegionClip aClip, - LayerManager::DrawThebesLayerCallback aCallback, + LayerManager::DrawPaintedLayerCallback aCallback, void* aCallbackData) { if (!aCallback) { diff --git a/gfx/layers/client/ClientContainerLayer.h b/gfx/layers/client/ClientContainerLayer.h index f82e65f166b6..74241d2163fa 100644 --- a/gfx/layers/client/ClientContainerLayer.h +++ b/gfx/layers/client/ClientContainerLayer.h @@ -16,7 +16,7 @@ #include "nsRegion.h" // for nsIntRegion #include "nsTArray.h" // for nsAutoTArray #include "ReadbackProcessor.h" -#include "ClientThebesLayer.h" +#include "ClientPaintedLayer.h" namespace mozilla { namespace layers { diff --git a/gfx/layers/client/ClientLayerManager.cpp b/gfx/layers/client/ClientLayerManager.cpp index 3dfe94ca207b..ffb298ab2b42 100644 --- a/gfx/layers/client/ClientLayerManager.cpp +++ b/gfx/layers/client/ClientLayerManager.cpp @@ -203,7 +203,7 @@ ClientLayerManager::BeginTransactionWithTarget(gfxContext* aTarget) mForwarder->BeginTransaction(targetBounds, mTargetRotation, orientation); // If we're drawing on behalf of a context with async pan/zoom - // enabled, then the entire buffer of thebes layers might be + // enabled, then the entire buffer of painted layers might be // composited (including resampling) asynchronously before we get // a chance to repaint, so we have to ensure that it's all valid // and not rotated. @@ -233,7 +233,7 @@ ClientLayerManager::BeginTransaction() } bool -ClientLayerManager::EndTransactionInternal(DrawThebesLayerCallback aCallback, +ClientLayerManager::EndTransactionInternal(DrawPaintedLayerCallback aCallback, void* aCallbackData, EndTransactionFlags) { @@ -257,8 +257,8 @@ ClientLayerManager::EndTransactionInternal(DrawThebesLayerCallback aCallback, // properties. GetRoot()->ApplyPendingUpdatesToSubtree(); - mThebesLayerCallback = aCallback; - mThebesLayerCallbackData = aCallbackData; + mPaintedLayerCallback = aCallback; + mPaintedLayerCallbackData = aCallbackData; GetRoot()->ComputeEffectiveTransforms(Matrix4x4()); @@ -267,8 +267,8 @@ ClientLayerManager::EndTransactionInternal(DrawThebesLayerCallback aCallback, GetRoot()->Mutated(); } - mThebesLayerCallback = nullptr; - mThebesLayerCallbackData = nullptr; + mPaintedLayerCallback = nullptr; + mPaintedLayerCallbackData = nullptr; // Go back to the construction phase if the transaction isn't complete. // Layout will update the layer tree and call EndTransaction(). @@ -285,7 +285,7 @@ ClientLayerManager::EndTransactionInternal(DrawThebesLayerCallback aCallback, } void -ClientLayerManager::EndTransaction(DrawThebesLayerCallback aCallback, +ClientLayerManager::EndTransaction(DrawPaintedLayerCallback aCallback, void* aCallbackData, EndTransactionFlags aFlags) { diff --git a/gfx/layers/client/ClientLayerManager.h b/gfx/layers/client/ClientLayerManager.h index 8412d3e469e3..7be1d70abc4d 100644 --- a/gfx/layers/client/ClientLayerManager.h +++ b/gfx/layers/client/ClientLayerManager.h @@ -32,7 +32,7 @@ class nsIWidget; namespace mozilla { namespace layers { -class ClientThebesLayer; +class ClientPaintedLayer; class CompositorChild; class ImageLayer; class PLayerChild; @@ -71,7 +71,7 @@ public: virtual void BeginTransactionWithTarget(gfxContext* aTarget); virtual void BeginTransaction(); virtual bool EndEmptyTransaction(EndTransactionFlags aFlags = END_DEFAULT); - virtual void EndTransaction(DrawThebesLayerCallback aCallback, + virtual void EndTransaction(DrawPaintedLayerCallback aCallback, void* aCallbackData, EndTransactionFlags aFlags = END_DEFAULT); @@ -87,10 +87,10 @@ public: virtual void Mutated(Layer* aLayer); - virtual bool IsOptimizedFor(ThebesLayer* aLayer, ThebesLayerCreationHint aHint); + virtual bool IsOptimizedFor(PaintedLayer* aLayer, PaintedLayerCreationHint aHint); - virtual already_AddRefed CreateThebesLayer(); - virtual already_AddRefed CreateThebesLayerWithHint(ThebesLayerCreationHint aHint); + virtual already_AddRefed CreatePaintedLayer(); + virtual already_AddRefed CreatePaintedLayerWithHint(PaintedLayerCreationHint aHint); virtual already_AddRefed CreateContainerLayer(); virtual already_AddRefed CreateImageLayer(); virtual already_AddRefed CreateCanvasLayer(); @@ -148,11 +148,11 @@ public: bool CompositorMightResample() { return mCompositorMightResample; } - DrawThebesLayerCallback GetThebesLayerCallback() const - { return mThebesLayerCallback; } + DrawPaintedLayerCallback GetPaintedLayerCallback() const + { return mPaintedLayerCallback; } - void* GetThebesLayerCallbackData() const - { return mThebesLayerCallbackData; } + void* GetPaintedLayerCallbackData() const + { return mPaintedLayerCallbackData; } CompositorChild* GetRemoteRenderer(); @@ -284,7 +284,7 @@ private: void ClearLayer(Layer* aLayer); - bool EndTransactionInternal(DrawThebesLayerCallback aCallback, + bool EndTransactionInternal(DrawPaintedLayerCallback aCallback, void* aCallbackData, EndTransactionFlags); @@ -292,10 +292,10 @@ private: nsIWidget* mWidget; - /* Thebes layer callbacks; valid at the end of a transaciton, + /* PaintedLayer callbacks; valid at the end of a transaciton, * while rendering */ - DrawThebesLayerCallback mThebesLayerCallback; - void *mThebesLayerCallbackData; + DrawPaintedLayerCallback mPaintedLayerCallback; + void *mPaintedLayerCallbackData; // When we're doing a transaction in order to draw to a non-default // target, the layers transaction is only performed in order to send @@ -369,7 +369,7 @@ public: virtual void RenderLayer() = 0; virtual void RenderLayerWithReadback(ReadbackProcessor *aReadback) { RenderLayer(); } - virtual ClientThebesLayer* AsThebes() { return nullptr; } + virtual ClientPaintedLayer* AsThebes() { return nullptr; } static inline ClientLayer * ToClientLayer(Layer* aLayer) diff --git a/gfx/layers/client/ClientThebesLayer.cpp b/gfx/layers/client/ClientPaintedLayer.cpp similarity index 84% rename from gfx/layers/client/ClientThebesLayer.cpp rename to gfx/layers/client/ClientPaintedLayer.cpp index 3879ab2a69ee..cdb3ebe0c93c 100644 --- a/gfx/layers/client/ClientThebesLayer.cpp +++ b/gfx/layers/client/ClientPaintedLayer.cpp @@ -3,8 +3,8 @@ * 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 "ClientThebesLayer.h" -#include "ClientTiledThebesLayer.h" // for ClientTiledThebesLayer +#include "ClientPaintedLayer.h" +#include "ClientTiledPaintedLayer.h" // for ClientTiledPaintedLayer #include // for uint32_t #include "GeckoProfiler.h" // for PROFILER_LABEL #include "client/ClientLayerManager.h" // for ClientLayerManager, etc @@ -31,9 +31,9 @@ namespace layers { using namespace mozilla::gfx; void -ClientThebesLayer::PaintThebes() +ClientPaintedLayer::PaintThebes() { - PROFILER_LABEL("ClientThebesLayer", "PaintThebes", + PROFILER_LABEL("ClientPaintedLayer", "PaintThebes", js::ProfileEntry::Category::GRAPHICS); NS_ASSERTION(ClientManager()->InDrawing(), @@ -54,7 +54,7 @@ ClientThebesLayer::PaintThebes() mContentClient->BeginPaintBuffer(this, flags); mValidRegion.Sub(mValidRegion, state.mRegionToInvalidate); - if (!state.mRegionToDraw.IsEmpty() && !ClientManager()->GetThebesLayerCallback()) { + if (!state.mRegionToDraw.IsEmpty() && !ClientManager()->GetPaintedLayerCallback()) { ClientManager()->SetTransactionIncomplete(); return; } @@ -73,12 +73,12 @@ ClientThebesLayer::PaintThebes() nsRefPtr ctx = gfxContext::ContextForDrawTarget(target); - ClientManager()->GetThebesLayerCallback()(this, + ClientManager()->GetPaintedLayerCallback()(this, ctx, iter.mDrawRegion, state.mClip, state.mRegionToInvalidate, - ClientManager()->GetThebesLayerCallbackData()); + ClientManager()->GetPaintedLayerCallbackData()); ctx = nullptr; mContentClient->ReturnDrawTargetToBuffer(target); @@ -104,7 +104,7 @@ ClientThebesLayer::PaintThebes() } void -ClientThebesLayer::RenderLayerWithReadback(ReadbackProcessor *aReadback) +ClientPaintedLayer::RenderLayerWithReadback(ReadbackProcessor *aReadback) { if (GetMaskLayer()) { ToClientLayer(GetMaskLayer())->RenderLayer(); @@ -123,7 +123,7 @@ ClientThebesLayer::RenderLayerWithReadback(ReadbackProcessor *aReadback) nsTArray readbackUpdates; nsIntRegion readbackRegion; if (aReadback && UsedForReadback()) { - aReadback->GetThebesLayerUpdates(this, &readbackUpdates); + aReadback->GetPaintedLayerUpdates(this, &readbackUpdates); } IntPoint origin(mVisibleRegion.GetBounds().x, mVisibleRegion.GetBounds().y); @@ -133,7 +133,7 @@ ClientThebesLayer::RenderLayerWithReadback(ReadbackProcessor *aReadback) } bool -ClientLayerManager::IsOptimizedFor(ThebesLayer* aLayer, ThebesLayerCreationHint aHint) +ClientLayerManager::IsOptimizedFor(PaintedLayer* aLayer, PaintedLayerCreationHint aHint) { #ifdef MOZ_B2G // The only creation hint is whether the layer is scrollable or not, and this @@ -148,14 +148,14 @@ ClientLayerManager::IsOptimizedFor(ThebesLayer* aLayer, ThebesLayerCreationHint #endif } -already_AddRefed -ClientLayerManager::CreateThebesLayer() +already_AddRefed +ClientLayerManager::CreatePaintedLayer() { - return CreateThebesLayerWithHint(NONE); + return CreatePaintedLayerWithHint(NONE); } -already_AddRefed -ClientLayerManager::CreateThebesLayerWithHint(ThebesLayerCreationHint aHint) +already_AddRefed +ClientLayerManager::CreatePaintedLayerWithHint(PaintedLayerCreationHint aHint) { NS_ASSERTION(InConstruction(), "Only allowed in construction phase"); if ( @@ -166,12 +166,12 @@ ClientLayerManager::CreateThebesLayerWithHint(ThebesLayerCreationHint aHint) (AsShadowForwarder()->GetCompositorBackendType() == LayersBackend::LAYERS_OPENGL || AsShadowForwarder()->GetCompositorBackendType() == LayersBackend::LAYERS_D3D9 || AsShadowForwarder()->GetCompositorBackendType() == LayersBackend::LAYERS_D3D11)) { - nsRefPtr layer = new ClientTiledThebesLayer(this, aHint); - CREATE_SHADOW(Thebes); + nsRefPtr layer = new ClientTiledPaintedLayer(this, aHint); + CREATE_SHADOW(Painted); return layer.forget(); } else { - nsRefPtr layer = new ClientThebesLayer(this, aHint); - CREATE_SHADOW(Thebes); + nsRefPtr layer = new ClientPaintedLayer(this, aHint); + CREATE_SHADOW(Painted); return layer.forget(); } } diff --git a/gfx/layers/client/ClientThebesLayer.h b/gfx/layers/client/ClientPaintedLayer.h similarity index 81% rename from gfx/layers/client/ClientThebesLayer.h rename to gfx/layers/client/ClientPaintedLayer.h index 01b7513973d7..449ee3dfbcc1 100644 --- a/gfx/layers/client/ClientThebesLayer.h +++ b/gfx/layers/client/ClientPaintedLayer.h @@ -3,11 +3,11 @@ * 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 GFX_CLIENTTHEBESLAYER_H -#define GFX_CLIENTTHEBESLAYER_H +#ifndef GFX_CLIENTPAINTEDLAYER_H +#define GFX_CLIENTPAINTEDLAYER_H #include "ClientLayerManager.h" // for ClientLayerManager, etc -#include "Layers.h" // for ThebesLayer, etc +#include "Layers.h" // for PaintedLayer, etc #include "RotatedBuffer.h" // for RotatedContentBuffer, etc #include "mozilla/Attributes.h" // for MOZ_OVERRIDE #include "mozilla/RefPtr.h" // for RefPtr @@ -16,7 +16,7 @@ #include "nsDebug.h" // for NS_ASSERTION #include "nsISupportsImpl.h" // for MOZ_COUNT_CTOR, etc #include "nsRegion.h" // for nsIntRegion -#include "mozilla/layers/PLayerTransaction.h" // for ThebesLayerAttributes +#include "mozilla/layers/PLayerTransaction.h" // for PaintedLayerAttributes class gfxContext; @@ -27,30 +27,30 @@ class CompositableClient; class ShadowableLayer; class SpecificLayerAttributes; -class ClientThebesLayer : public ThebesLayer, +class ClientPaintedLayer : public PaintedLayer, public ClientLayer { public: typedef RotatedContentBuffer::PaintState PaintState; typedef RotatedContentBuffer::ContentType ContentType; - explicit ClientThebesLayer(ClientLayerManager* aLayerManager, - LayerManager::ThebesLayerCreationHint aCreationHint = LayerManager::NONE) : - ThebesLayer(aLayerManager, + explicit ClientPaintedLayer(ClientLayerManager* aLayerManager, + LayerManager::PaintedLayerCreationHint aCreationHint = LayerManager::NONE) : + PaintedLayer(aLayerManager, static_cast(MOZ_THIS_IN_INITIALIZER_LIST()), aCreationHint), mContentClient(nullptr) { - MOZ_COUNT_CTOR(ClientThebesLayer); + MOZ_COUNT_CTOR(ClientPaintedLayer); } protected: - virtual ~ClientThebesLayer() + virtual ~ClientPaintedLayer() { if (mContentClient) { mContentClient->OnDetach(); mContentClient = nullptr; } - MOZ_COUNT_DTOR(ClientThebesLayer); + MOZ_COUNT_DTOR(ClientPaintedLayer); } public: @@ -58,7 +58,7 @@ public: { NS_ASSERTION(ClientManager()->InConstruction(), "Can only set properties in construction phase"); - ThebesLayer::SetVisibleRegion(aRegion); + PaintedLayer::SetVisibleRegion(aRegion); } virtual void InvalidateRegion(const nsIntRegion& aRegion) { @@ -84,7 +84,7 @@ public: virtual void FillSpecificAttributes(SpecificLayerAttributes& aAttrs) { - aAttrs = ThebesLayerAttributes(GetValidRegion()); + aAttrs = PaintedLayerAttributes(GetValidRegion()); } ClientLayerManager* ClientManager() diff --git a/gfx/layers/client/ClientTiledThebesLayer.cpp b/gfx/layers/client/ClientTiledPaintedLayer.cpp similarity index 93% rename from gfx/layers/client/ClientTiledThebesLayer.cpp rename to gfx/layers/client/ClientTiledPaintedLayer.cpp index 7091ee174090..97206af255ca 100644 --- a/gfx/layers/client/ClientTiledThebesLayer.cpp +++ b/gfx/layers/client/ClientTiledPaintedLayer.cpp @@ -2,7 +2,7 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this file, * You can obtain one at http://mozilla.org/MPL/2.0/. */ -#include "ClientTiledThebesLayer.h" +#include "ClientTiledPaintedLayer.h" #include "FrameMetrics.h" // for FrameMetrics #include "Units.h" // for ScreenIntRect, CSSPoint, etc #include "UnitTransforms.h" // for TransformTo @@ -24,25 +24,25 @@ namespace mozilla { namespace layers { -ClientTiledThebesLayer::ClientTiledThebesLayer(ClientLayerManager* const aManager, - ClientLayerManager::ThebesLayerCreationHint aCreationHint) - : ThebesLayer(aManager, +ClientTiledPaintedLayer::ClientTiledPaintedLayer(ClientLayerManager* const aManager, + ClientLayerManager::PaintedLayerCreationHint aCreationHint) + : PaintedLayer(aManager, static_cast(MOZ_THIS_IN_INITIALIZER_LIST()), aCreationHint) , mContentClient() { - MOZ_COUNT_CTOR(ClientTiledThebesLayer); + MOZ_COUNT_CTOR(ClientTiledPaintedLayer); mPaintData.mLastScrollOffset = ParentLayerPoint(0, 0); mPaintData.mFirstPaint = true; } -ClientTiledThebesLayer::~ClientTiledThebesLayer() +ClientTiledPaintedLayer::~ClientTiledPaintedLayer() { - MOZ_COUNT_DTOR(ClientTiledThebesLayer); + MOZ_COUNT_DTOR(ClientTiledPaintedLayer); } void -ClientTiledThebesLayer::ClearCachedResources() +ClientTiledPaintedLayer::ClearCachedResources() { if (mContentClient) { mContentClient->ClearCachedResources(); @@ -52,9 +52,9 @@ ClientTiledThebesLayer::ClearCachedResources() } void -ClientTiledThebesLayer::FillSpecificAttributes(SpecificLayerAttributes& aAttrs) +ClientTiledPaintedLayer::FillSpecificAttributes(SpecificLayerAttributes& aAttrs) { - aAttrs = ThebesLayerAttributes(GetValidRegion()); + aAttrs = PaintedLayerAttributes(GetValidRegion()); } static LayerRect @@ -81,7 +81,7 @@ GetTransformToAncestorsParentLayer(Layer* aStart, const LayerMetricsWrapper& aAn } void -ClientTiledThebesLayer::GetAncestorLayers(LayerMetricsWrapper* aOutScrollAncestor, +ClientTiledPaintedLayer::GetAncestorLayers(LayerMetricsWrapper* aOutScrollAncestor, LayerMetricsWrapper* aOutDisplayPortAncestor) { LayerMetricsWrapper scrollAncestor; @@ -107,7 +107,7 @@ ClientTiledThebesLayer::GetAncestorLayers(LayerMetricsWrapper* aOutScrollAncesto } void -ClientTiledThebesLayer::BeginPaint() +ClientTiledPaintedLayer::BeginPaint() { mPaintData.mLowPrecisionPaintCount = 0; mPaintData.mPaintFinished = false; @@ -132,7 +132,7 @@ ClientTiledThebesLayer::BeginPaint() #if defined(MOZ_WIDGET_ANDROID) || defined(MOZ_B2G) // Both Android and b2g are guaranteed to have a displayport set, so this // should never happen. - NS_WARNING("Tiled Thebes layer with no scrollable container ancestor"); + NS_WARNING("Tiled PaintedLayer with no scrollable container ancestor"); #endif return; } @@ -184,7 +184,7 @@ ClientTiledThebesLayer::BeginPaint() } bool -ClientTiledThebesLayer::UseFastPath() +ClientTiledPaintedLayer::UseFastPath() { LayerMetricsWrapper scrollAncestor; GetAncestorLayers(&scrollAncestor, nullptr); @@ -201,9 +201,9 @@ ClientTiledThebesLayer::UseFastPath() } bool -ClientTiledThebesLayer::RenderHighPrecision(nsIntRegion& aInvalidRegion, +ClientTiledPaintedLayer::RenderHighPrecision(nsIntRegion& aInvalidRegion, const nsIntRegion& aVisibleRegion, - LayerManager::DrawThebesLayerCallback aCallback, + LayerManager::DrawPaintedLayerCallback aCallback, void* aCallbackData) { // If we have no high-precision stuff to draw, or we have started drawing low-precision @@ -248,9 +248,9 @@ ClientTiledThebesLayer::RenderHighPrecision(nsIntRegion& aInvalidRegion, } bool -ClientTiledThebesLayer::RenderLowPrecision(nsIntRegion& aInvalidRegion, +ClientTiledPaintedLayer::RenderLowPrecision(nsIntRegion& aInvalidRegion, const nsIntRegion& aVisibleRegion, - LayerManager::DrawThebesLayerCallback aCallback, + LayerManager::DrawPaintedLayerCallback aCallback, void* aCallbackData) { // Render the low precision buffer, if the visible region is larger than the @@ -310,7 +310,7 @@ ClientTiledThebesLayer::RenderLowPrecision(nsIntRegion& aInvalidRegion, } void -ClientTiledThebesLayer::EndPaint() +ClientTiledPaintedLayer::EndPaint() { mPaintData.mLastScrollOffset = mPaintData.mScrollOffset; mPaintData.mPaintFinished = true; @@ -319,11 +319,11 @@ ClientTiledThebesLayer::EndPaint() } void -ClientTiledThebesLayer::RenderLayer() +ClientTiledPaintedLayer::RenderLayer() { - LayerManager::DrawThebesLayerCallback callback = - ClientManager()->GetThebesLayerCallback(); - void *data = ClientManager()->GetThebesLayerCallbackData(); + LayerManager::DrawPaintedLayerCallback callback = + ClientManager()->GetPaintedLayerCallback(); + void *data = ClientManager()->GetPaintedLayerCallbackData(); if (!callback) { ClientManager()->SetTransactionIncomplete(); return; diff --git a/gfx/layers/client/ClientTiledThebesLayer.h b/gfx/layers/client/ClientTiledPaintedLayer.h similarity index 79% rename from gfx/layers/client/ClientTiledThebesLayer.h rename to gfx/layers/client/ClientTiledPaintedLayer.h index 1cd6369b2008..aeb456cc2f5b 100644 --- a/gfx/layers/client/ClientTiledThebesLayer.h +++ b/gfx/layers/client/ClientTiledPaintedLayer.h @@ -2,11 +2,11 @@ * 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 GFX_CLIENTTILEDTHEBESLAYER_H -#define GFX_CLIENTTILEDTHEBESLAYER_H +#ifndef GFX_CLIENTTILEDPAINTEDLAYER_H +#define GFX_CLIENTTILEDPAINTEDLAYER_H #include "ClientLayerManager.h" // for ClientLayer, etc -#include "Layers.h" // for ThebesLayer, etc +#include "Layers.h" // for PaintedLayer, etc #include "mozilla/RefPtr.h" // for RefPtr #include "mozilla/layers/TiledContentClient.h" #include "nsDebug.h" // for NS_RUNTIMEABORT @@ -21,12 +21,12 @@ class ShadowableLayer; class SpecificLayerAttributes; /** - * An implementation of ThebesLayer that ONLY supports remote - * composition that is backed by tiles. This thebes layer implementation + * An implementation of PaintedLayer that ONLY supports remote + * composition that is backed by tiles. This painted layer implementation * is better suited to mobile hardware to work around slow implementation * of glTexImage2D (for OGL compositors), and restrait memory bandwidth. * - * Tiled Thebes layers use a different protocol compared with other + * Tiled PaintedLayers use a different protocol compared with other * layers. A copy of the tiled buffer is made and sent to the compositing * thread via the layers protocol. Tiles are uploaded by the buffers * asynchonously without using IPC, that means they are not safe for cross- @@ -35,23 +35,23 @@ class SpecificLayerAttributes; * * There is no ContentClient for tiled layers. There is a ContentHost, however. */ -class ClientTiledThebesLayer : public ThebesLayer, +class ClientTiledPaintedLayer : public PaintedLayer, public ClientLayer { - typedef ThebesLayer Base; + typedef PaintedLayer Base; public: - explicit ClientTiledThebesLayer(ClientLayerManager* const aManager, - ClientLayerManager::ThebesLayerCreationHint aCreationHint = LayerManager::NONE); + explicit ClientTiledPaintedLayer(ClientLayerManager* const aManager, + ClientLayerManager::PaintedLayerCreationHint aCreationHint = LayerManager::NONE); protected: - ~ClientTiledThebesLayer(); + ~ClientTiledPaintedLayer(); public: - // Override name to distinguish it from ClientThebesLayer in layer dumps - virtual const char* Name() const { return "TiledThebesLayer"; } + // Override name to distinguish it from ClientPaintedLayer in layer dumps + virtual const char* Name() const { return "TiledPaintedLayer"; } - // Thebes Layer + // PaintedLayer virtual Layer* AsLayer() { return this; } virtual void InvalidateRegion(const nsIntRegion& aRegion) { mInvalidRegion.Or(mInvalidRegion, aRegion); @@ -104,7 +104,7 @@ private: */ bool RenderHighPrecision(nsIntRegion& aInvalidRegion, const nsIntRegion& aVisibleRegion, - LayerManager::DrawThebesLayerCallback aCallback, + LayerManager::DrawPaintedLayerCallback aCallback, void* aCallbackData); /** @@ -113,7 +113,7 @@ private: */ bool RenderLowPrecision(nsIntRegion& aInvalidRegion, const nsIntRegion& aVisibleRegion, - LayerManager::DrawThebesLayerCallback aCallback, + LayerManager::DrawPaintedLayerCallback aCallback, void* aCallbackData); /** diff --git a/gfx/layers/client/CompositableClient.h b/gfx/layers/client/CompositableClient.h index 9efa601865ef..ac2677032474 100644 --- a/gfx/layers/client/CompositableClient.h +++ b/gfx/layers/client/CompositableClient.h @@ -110,7 +110,7 @@ private: * by this layer forwarder (the matching uses a global map on the compositor side, * see CompositableMap in ImageBridgeParent.cpp) * - * Subclasses: Thebes layers use ContentClients, ImageLayers use ImageClients, + * Subclasses: Painted layers use ContentClients, ImageLayers use ImageClients, * Canvas layers use CanvasClients (but ImageHosts). We have a different subclass * where we have a different way of interfacing with the textures - in terms of * drawing into the compositable and/or passing its contents to the compostior. diff --git a/gfx/layers/client/ContentClient.cpp b/gfx/layers/client/ContentClient.cpp index d5faf022aad9..ae835e3436a0 100644 --- a/gfx/layers/client/ContentClient.cpp +++ b/gfx/layers/client/ContentClient.cpp @@ -676,7 +676,7 @@ ContentClientIncremental::NotifyBufferCreated(ContentType aType, TextureFlags aF } RotatedContentBuffer::PaintState -ContentClientIncremental::BeginPaintBuffer(ThebesLayer* aLayer, +ContentClientIncremental::BeginPaintBuffer(PaintedLayer* aLayer, uint32_t aFlags) { mTextureInfo.mDeprecatedTextureHostFlags = DeprecatedTextureHostFlags::DEFAULT; diff --git a/gfx/layers/client/ContentClient.h b/gfx/layers/client/ContentClient.h index 5884811f4d7d..bdafeb598a0a 100644 --- a/gfx/layers/client/ContentClient.h +++ b/gfx/layers/client/ContentClient.h @@ -38,20 +38,20 @@ class DrawTarget; namespace layers { class BasicLayerManager; -class ThebesLayer; +class PaintedLayer; /** - * A compositable client for Thebes layers. These are different to Image/Canvas + * A compositable client for PaintedLayers. These are different to Image/Canvas * clients due to sending a valid region across IPC and because we do a lot more * optimisation work, encapsualted in RotatedContentBuffers. * * We use content clients for OMTC and non-OMTC, basic rendering so that - * BasicThebesLayer has only one interface to deal with. We support single and + * BasicPaintedLayer has only one interface to deal with. We support single and * double buffered flavours. For tiled layers, we do not use a ContentClient * although we do have a ContentHost, and we do use texture clients and texture * hosts. * - * The interface presented by ContentClient is used by the BasicThebesLayer + * The interface presented by ContentClient is used by the BasicPaintedLayer * methods - PaintThebes, which is the same for MT and OMTC, and PaintBuffer * which is different (the OMTC one does a little more). The 'buffer' in the * names of a lot of these method is actually the TextureClient. But, 'buffer' @@ -91,7 +91,7 @@ public: virtual void Clear() = 0; - virtual RotatedContentBuffer::PaintState BeginPaintBuffer(ThebesLayer* aLayer, + virtual RotatedContentBuffer::PaintState BeginPaintBuffer(PaintedLayer* aLayer, uint32_t aFlags) = 0; virtual gfx::DrawTarget* BorrowDrawTargetForPainting(RotatedContentBuffer::PaintState& aPaintState, RotatedContentBuffer::DrawIterator* aIter = nullptr) = 0; @@ -133,7 +133,7 @@ public: typedef RotatedContentBuffer::ContentType ContentType; virtual void Clear() { RotatedContentBuffer::Clear(); } - virtual PaintState BeginPaintBuffer(ThebesLayer* aLayer, + virtual PaintState BeginPaintBuffer(PaintedLayer* aLayer, uint32_t aFlags) MOZ_OVERRIDE { return RotatedContentBuffer::BeginPaint(aLayer, aFlags); @@ -148,7 +148,7 @@ public: BorrowDrawTarget::ReturnDrawTarget(aReturned); } - void DrawTo(ThebesLayer* aLayer, + void DrawTo(PaintedLayer* aLayer, gfx::DrawTarget* aTarget, float aOpacity, gfx::CompositionOp aOp, @@ -208,7 +208,7 @@ public: mTextureClientOnWhite = nullptr; } - virtual PaintState BeginPaintBuffer(ThebesLayer* aLayer, + virtual PaintState BeginPaintBuffer(PaintedLayer* aLayer, uint32_t aFlags) MOZ_OVERRIDE { return RotatedContentBuffer::BeginPaint(aLayer, aFlags); @@ -418,7 +418,7 @@ public: mHasBufferOnWhite = false; } - virtual PaintState BeginPaintBuffer(ThebesLayer* aLayer, + virtual PaintState BeginPaintBuffer(PaintedLayer* aLayer, uint32_t aFlags) MOZ_OVERRIDE; virtual gfx::DrawTarget* BorrowDrawTargetForPainting(PaintState& aPaintState, RotatedContentBuffer::DrawIterator* aIter = nullptr) MOZ_OVERRIDE; diff --git a/gfx/layers/client/TiledContentClient.cpp b/gfx/layers/client/TiledContentClient.cpp index 82d93d421c04..329551ea3629 100644 --- a/gfx/layers/client/TiledContentClient.cpp +++ b/gfx/layers/client/TiledContentClient.cpp @@ -6,7 +6,7 @@ #include "mozilla/layers/TiledContentClient.h" #include // for ceil, ceilf, floor #include -#include "ClientTiledThebesLayer.h" // for ClientTiledThebesLayer +#include "ClientTiledPaintedLayer.h" // for ClientTiledPaintedLayer #include "GeckoProfiler.h" // for PROFILER_LABEL #include "ClientLayerManager.h" // for ClientLayerManager #include "CompositorChild.h" // for CompositorChild @@ -89,15 +89,15 @@ using namespace gfx; namespace layers { -TiledContentClient::TiledContentClient(ClientTiledThebesLayer* aThebesLayer, +TiledContentClient::TiledContentClient(ClientTiledPaintedLayer* aPaintedLayer, ClientLayerManager* aManager) : CompositableClient(aManager->AsShadowForwarder()) { MOZ_COUNT_CTOR(TiledContentClient); - mTiledBuffer = ClientTiledLayerBuffer(aThebesLayer, this, aManager, + mTiledBuffer = ClientTiledLayerBuffer(aPaintedLayer, this, aManager, &mSharedFrameMetricsHelper); - mLowPrecisionTiledBuffer = ClientTiledLayerBuffer(aThebesLayer, this, aManager, + mLowPrecisionTiledBuffer = ClientTiledLayerBuffer(aPaintedLayer, this, aManager, &mSharedFrameMetricsHelper); mLowPrecisionTiledBuffer.SetResolution(gfxPrefs::LowPrecisionResolution()); @@ -286,11 +286,11 @@ SharedFrameMetricsHelper::AboutToCheckerboard(const FrameMetrics& aContentMetric return false; } -ClientTiledLayerBuffer::ClientTiledLayerBuffer(ClientTiledThebesLayer* aThebesLayer, +ClientTiledLayerBuffer::ClientTiledLayerBuffer(ClientTiledPaintedLayer* aPaintedLayer, CompositableClient* aCompositableClient, ClientLayerManager* aManager, SharedFrameMetricsHelper* aHelper) - : mThebesLayer(aThebesLayer) + : mPaintedLayer(aPaintedLayer) , mCompositableClient(aCompositableClient) , mManager(aManager) , mLastPaintContentType(gfxContentType::COLOR) @@ -313,24 +313,24 @@ gfxContentType ClientTiledLayerBuffer::GetContentType(SurfaceMode* aMode) const { gfxContentType content = - mThebesLayer->CanUseOpaqueSurface() ? gfxContentType::COLOR : + mPaintedLayer->CanUseOpaqueSurface() ? gfxContentType::COLOR : gfxContentType::COLOR_ALPHA; - SurfaceMode mode = mThebesLayer->GetSurfaceMode(); + SurfaceMode mode = mPaintedLayer->GetSurfaceMode(); if (mode == SurfaceMode::SURFACE_COMPONENT_ALPHA) { #if defined(MOZ_GFX_OPTIMIZE_MOBILE) || defined(MOZ_WIDGET_GONK) mode = SurfaceMode::SURFACE_SINGLE_CHANNEL_ALPHA; } #else - if (!mThebesLayer->GetParent() || - !mThebesLayer->GetParent()->SupportsComponentAlphaChildren() || + if (!mPaintedLayer->GetParent() || + !mPaintedLayer->GetParent()->SupportsComponentAlphaChildren() || !gfxPrefs::TiledDrawTargetEnabled()) { mode = SurfaceMode::SURFACE_SINGLE_CHANNEL_ALPHA; } else { content = gfxContentType::COLOR; } } else if (mode == SurfaceMode::SURFACE_OPAQUE) { - if (mThebesLayer->MayResample()) { + if (mPaintedLayer->MayResample()) { mode = SurfaceMode::SURFACE_SINGLE_CHANNEL_ALPHA; content = gfxContentType::COLOR_ALPHA; } @@ -887,11 +887,11 @@ ClientTiledLayerBuffer::GetSurfaceDescriptorTiles() void ClientTiledLayerBuffer::PaintThebes(const nsIntRegion& aNewValidRegion, const nsIntRegion& aPaintRegion, - LayerManager::DrawThebesLayerCallback aCallback, + LayerManager::DrawPaintedLayerCallback aCallback, void* aCallbackData) { - TILING_LOG("TILING %p: PaintThebes painting region %s\n", mThebesLayer, Stringify(aPaintRegion).c_str()); - TILING_LOG("TILING %p: PaintThebes new valid region %s\n", mThebesLayer, Stringify(aNewValidRegion).c_str()); + TILING_LOG("TILING %p: PaintThebes painting region %s\n", mPaintedLayer, Stringify(aPaintRegion).c_str()); + TILING_LOG("TILING %p: PaintThebes new valid region %s\n", mPaintedLayer, Stringify(aNewValidRegion).c_str()); mCallback = aCallback; mCallbackData = aCallbackData; @@ -955,7 +955,7 @@ ClientTiledLayerBuffer::PaintThebes(const nsIntRegion& aNewValidRegion, PROFILER_LABEL("ClientTiledLayerBuffer", "PaintThebesSingleBufferDraw", js::ProfileEntry::Category::GRAPHICS); - mCallback(mThebesLayer, ctxt, aPaintRegion, DrawRegionClip::CLIP_NONE, nsIntRegion(), mCallbackData); + mCallback(mPaintedLayer, ctxt, aPaintRegion, DrawRegionClip::CLIP_NONE, nsIntRegion(), mCallbackData); } #ifdef GFX_TILEDLAYER_PREF_WARNINGS @@ -1068,7 +1068,7 @@ ClientTiledLayerBuffer::PostValidate(const nsIntRegion& aPaintRegion) ctx->SetMatrix( ctx->CurrentMatrix().Scale(mResolution, mResolution)); - mCallback(mThebesLayer, ctx, aPaintRegion, DrawRegionClip::DRAW, nsIntRegion(), mCallbackData); + mCallback(mPaintedLayer, ctx, aPaintRegion, DrawRegionClip::DRAW, nsIntRegion(), mCallbackData); mMoz2DTiles.clear(); } } @@ -1323,7 +1323,7 @@ ClientTiledLayerBuffer::ValidateTile(TileClient aTile, ctxt->CurrentMatrix().Translate(-unscaledTileOrigin.x, -unscaledTileOrigin.y). Scale(mResolution, mResolution)); - mCallback(mThebesLayer, ctxt, + mCallback(mPaintedLayer, ctxt, tileRegion.GetBounds(), DrawRegionClip::CLIP_NONE, nsIntRegion(), mCallbackData); @@ -1379,7 +1379,7 @@ ClientTiledLayerBuffer::ValidateTile(TileClient aTile, * basically replaces the nontransient async transform that was injected * in GetTransformToAncestorsParentLayer with the complete async transform. * This function then returns the scroll ancestor's composition bounds, - * transformed into the thebes layer's LayerPixel coordinates, accounting + * transformed into the painted layer's LayerPixel coordinates, accounting * for the compositor state. */ static LayerRect @@ -1432,10 +1432,10 @@ ClientTiledLayerBuffer::ComputeProgressiveUpdateRegion(const nsIntRegion& aInval nsIntRegion staleRegion; staleRegion.And(aInvalidRegion, aOldValidRegion); - TILING_LOG("TILING %p: Progressive update stale region %s\n", mThebesLayer, Stringify(staleRegion).c_str()); + TILING_LOG("TILING %p: Progressive update stale region %s\n", mPaintedLayer, Stringify(staleRegion).c_str()); LayerMetricsWrapper scrollAncestor; - mThebesLayer->GetAncestorLayers(&scrollAncestor, nullptr); + mPaintedLayer->GetAncestorLayers(&scrollAncestor, nullptr); // Find out the current view transform to determine which tiles to draw // first, and see if we should just abort this paint. Aborting is usually @@ -1467,7 +1467,7 @@ ClientTiledLayerBuffer::ComputeProgressiveUpdateRegion(const nsIntRegion& aInval #endif TILING_LOG("TILING %p: Progressive update view transform %s zoom %f abort %d\n", - mThebesLayer, ToString(viewTransform.mTranslation).c_str(), viewTransform.mScale.scale, abortPaint); + mPaintedLayer, ToString(viewTransform.mTranslation).c_str(), viewTransform.mScale.scale, abortPaint); if (abortPaint) { // We ignore if front-end wants to abort if this is the first, @@ -1487,7 +1487,7 @@ ClientTiledLayerBuffer::ComputeProgressiveUpdateRegion(const nsIntRegion& aInval aPaintData->mTransformToCompBounds, viewTransform); - TILING_LOG("TILING %p: Progressive update transformed compositor bounds %s\n", mThebesLayer, Stringify(transformedCompositionBounds).c_str()); + TILING_LOG("TILING %p: Progressive update transformed compositor bounds %s\n", mPaintedLayer, Stringify(transformedCompositionBounds).c_str()); // Compute a "coherent update rect" that we should paint all at once in a // single transaction. This is to avoid rendering glitches on animated @@ -1506,7 +1506,7 @@ ClientTiledLayerBuffer::ComputeProgressiveUpdateRegion(const nsIntRegion& aInval #endif ))); - TILING_LOG("TILING %p: Progressive update final coherency rect %s\n", mThebesLayer, Stringify(coherentUpdateRect).c_str()); + TILING_LOG("TILING %p: Progressive update final coherency rect %s\n", mPaintedLayer, Stringify(coherentUpdateRect).c_str()); aRegionToPaint.And(aInvalidRegion, coherentUpdateRect); aRegionToPaint.Or(aRegionToPaint, staleRegion); @@ -1522,14 +1522,14 @@ ClientTiledLayerBuffer::ComputeProgressiveUpdateRegion(const nsIntRegion& aInval paintingVisible = true; } - TILING_LOG("TILING %p: Progressive update final paint region %s\n", mThebesLayer, Stringify(aRegionToPaint).c_str()); + TILING_LOG("TILING %p: Progressive update final paint region %s\n", mPaintedLayer, Stringify(aRegionToPaint).c_str()); // Paint area that's visible and overlaps previously valid content to avoid // visible glitches in animated elements, such as gifs. bool paintInSingleTransaction = paintingVisible && (drawingStale || aPaintData->mFirstPaint); TILING_LOG("TILING %p: paintingVisible %d drawingStale %d firstPaint %d singleTransaction %d\n", - mThebesLayer, paintingVisible, drawingStale, aPaintData->mFirstPaint, paintInSingleTransaction); + mPaintedLayer, paintingVisible, drawingStale, aPaintData->mFirstPaint, paintInSingleTransaction); // The following code decides what order to draw tiles in, based on the // current scroll direction of the primary scrollable layer. @@ -1599,12 +1599,12 @@ ClientTiledLayerBuffer::ProgressiveUpdate(nsIntRegion& aValidRegion, nsIntRegion& aInvalidRegion, const nsIntRegion& aOldValidRegion, BasicTiledLayerPaintData* aPaintData, - LayerManager::DrawThebesLayerCallback aCallback, + LayerManager::DrawPaintedLayerCallback aCallback, void* aCallbackData) { - TILING_LOG("TILING %p: Progressive update valid region %s\n", mThebesLayer, Stringify(aValidRegion).c_str()); - TILING_LOG("TILING %p: Progressive update invalid region %s\n", mThebesLayer, Stringify(aInvalidRegion).c_str()); - TILING_LOG("TILING %p: Progressive update old valid region %s\n", mThebesLayer, Stringify(aOldValidRegion).c_str()); + TILING_LOG("TILING %p: Progressive update valid region %s\n", mPaintedLayer, Stringify(aValidRegion).c_str()); + TILING_LOG("TILING %p: Progressive update invalid region %s\n", mPaintedLayer, Stringify(aInvalidRegion).c_str()); + TILING_LOG("TILING %p: Progressive update old valid region %s\n", mPaintedLayer, Stringify(aOldValidRegion).c_str()); bool repeat = false; bool isBufferChanged = false; @@ -1618,7 +1618,7 @@ ClientTiledLayerBuffer::ProgressiveUpdate(nsIntRegion& aValidRegion, aPaintData, repeat); - TILING_LOG("TILING %p: Progressive update computed paint region %s repeat %d\n", mThebesLayer, Stringify(regionToPaint).c_str(), repeat); + TILING_LOG("TILING %p: Progressive update computed paint region %s repeat %d\n", mPaintedLayer, Stringify(regionToPaint).c_str(), repeat); // There's no further work to be done. if (regionToPaint.IsEmpty()) { @@ -1641,8 +1641,8 @@ ClientTiledLayerBuffer::ProgressiveUpdate(nsIntRegion& aValidRegion, aInvalidRegion.Sub(aInvalidRegion, regionToPaint); } while (repeat); - TILING_LOG("TILING %p: Progressive update final valid region %s buffer changed %d\n", mThebesLayer, Stringify(aValidRegion).c_str(), isBufferChanged); - TILING_LOG("TILING %p: Progressive update final invalid region %s\n", mThebesLayer, Stringify(aInvalidRegion).c_str()); + TILING_LOG("TILING %p: Progressive update final valid region %s buffer changed %d\n", mPaintedLayer, Stringify(aValidRegion).c_str(), isBufferChanged); + TILING_LOG("TILING %p: Progressive update final invalid region %s\n", mPaintedLayer, Stringify(aInvalidRegion).c_str()); // Return false if nothing has been drawn, or give what has been drawn // to the shadow layer to upload. diff --git a/gfx/layers/client/TiledContentClient.h b/gfx/layers/client/TiledContentClient.h index 98aea99afc93..a6528e04973a 100644 --- a/gfx/layers/client/TiledContentClient.h +++ b/gfx/layers/client/TiledContentClient.h @@ -41,7 +41,7 @@ namespace mozilla { namespace layers { class BasicTileDescriptor; -class ClientTiledThebesLayer; +class ClientTiledPaintedLayer; class ClientLayerManager; @@ -388,12 +388,12 @@ class ClientTiledLayerBuffer friend class TiledLayerBuffer; public: - ClientTiledLayerBuffer(ClientTiledThebesLayer* aThebesLayer, + ClientTiledLayerBuffer(ClientTiledPaintedLayer* aPaintedLayer, CompositableClient* aCompositableClient, ClientLayerManager* aManager, SharedFrameMetricsHelper* aHelper); ClientTiledLayerBuffer() - : mThebesLayer(nullptr) + : mPaintedLayer(nullptr) , mCompositableClient(nullptr) , mManager(nullptr) , mLastPaintContentType(gfxContentType::COLOR) @@ -403,7 +403,7 @@ public: void PaintThebes(const nsIntRegion& aNewValidRegion, const nsIntRegion& aPaintRegion, - LayerManager::DrawThebesLayerCallback aCallback, + LayerManager::DrawPaintedLayerCallback aCallback, void* aCallbackData); void ReadUnlock(); @@ -428,7 +428,7 @@ public: nsIntRegion& aInvalidRegion, const nsIntRegion& aOldValidRegion, BasicTiledLayerPaintData* aPaintData, - LayerManager::DrawThebesLayerCallback aCallback, + LayerManager::DrawPaintedLayerCallback aCallback, void* aCallbackData); SurfaceDescriptorTiles GetSurfaceDescriptorTiles(); @@ -456,10 +456,10 @@ protected: private: gfxContentType GetContentType(SurfaceMode* aMode = nullptr) const; - ClientTiledThebesLayer* mThebesLayer; + ClientTiledPaintedLayer* mPaintedLayer; CompositableClient* mCompositableClient; ClientLayerManager* mManager; - LayerManager::DrawThebesLayerCallback mCallback; + LayerManager::DrawPaintedLayerCallback mCallback; void* mCallbackData; CSSToParentLayerScale mFrameResolution; gfxContentType mLastPaintContentType; @@ -504,11 +504,11 @@ class TiledContentClient : public CompositableClient // XXX: for now the layer which owns us interacts directly with our buffers. // We should have a content client for each tiled buffer which manages its // own valid region, resolution, etc. Then we could have a much cleaner - // interface and tidy up BasicTiledThebesLayer::PaintThebes (bug 862547). - friend class ClientTiledThebesLayer; + // interface and tidy up BasicTiledPaintedLayer::PaintThebes (bug 862547). + friend class ClientTiledPaintedLayer; public: - TiledContentClient(ClientTiledThebesLayer* aThebesLayer, + TiledContentClient(ClientTiledPaintedLayer* aPaintedLayer, ClientLayerManager* aManager); protected: diff --git a/gfx/layers/composite/CompositableHost.cpp b/gfx/layers/composite/CompositableHost.cpp index 803d89ef9a06..2bbbd78d82ad 100644 --- a/gfx/layers/composite/CompositableHost.cpp +++ b/gfx/layers/composite/CompositableHost.cpp @@ -24,6 +24,14 @@ namespace layers { class Compositor; +CompositableBackendSpecificData::CompositableBackendSpecificData() + : mAllowSharingTextureHost(false) +{ + static uint64_t sNextID = 1; + ++sNextID; + mId = sNextID; +} + /** * IPDL actor used by CompositableHost to match with its corresponding * CompositableClient on the content side. @@ -131,7 +139,7 @@ void CompositableHost::RemoveTextureHost(TextureHost* aTexture) { // Clear strong refrence to CompositableBackendSpecificData - aTexture->SetCompositableBackendSpecificData(nullptr); + aTexture->UnsetCompositableBackendSpecificData(GetCompositableBackendSpecificData()); } void diff --git a/gfx/layers/composite/CompositableHost.h b/gfx/layers/composite/CompositableHost.h index 4d5953b34a8a..854e17058020 100644 --- a/gfx/layers/composite/CompositableHost.h +++ b/gfx/layers/composite/CompositableHost.h @@ -54,18 +54,34 @@ struct EffectChain; class CompositableBackendSpecificData { protected: - virtual ~CompositableBackendSpecificData() { } + virtual ~CompositableBackendSpecificData() {} public: NS_INLINE_DECL_REFCOUNTING(CompositableBackendSpecificData) - CompositableBackendSpecificData() + CompositableBackendSpecificData(); + + virtual void ClearData() {} + virtual void SetCompositor(Compositor* aCompositor) {} + + bool IsAllowingSharingTextureHost() { + return mAllowSharingTextureHost; } - virtual void SetCompositor(Compositor* aCompositor) {} - virtual void ClearData() {} + void SetAllowSharingTextureHost(bool aAllow) + { + mAllowSharingTextureHost = aAllow; + } + uint64_t GetId() + { + return mId; + } + +public: + bool mAllowSharingTextureHost; + uint64_t mId; }; /** diff --git a/gfx/layers/composite/ContainerLayerComposite.cpp b/gfx/layers/composite/ContainerLayerComposite.cpp index 1f9bb15e35b7..dc66eeeb5fba 100644 --- a/gfx/layers/composite/ContainerLayerComposite.cpp +++ b/gfx/layers/composite/ContainerLayerComposite.cpp @@ -297,7 +297,7 @@ RenderLayers(ContainerT* aContainer, if (LayerHasCheckerboardingAPZC(layer, &color)) { // Ideally we would want to intersect the checkerboard region from the APZ with the layer bounds // and only fill in that area. However the layer bounds takes into account the base translation - // for the thebes layer whereas the checkerboard region does not. One does not simply + // for the painted layer whereas the checkerboard region does not. One does not simply // intersect areas in different coordinate spaces. So we do this a little more permissively // and only fill in the background when we know there is checkerboard, which in theory // should only occur transiently. diff --git a/gfx/layers/composite/ContentHost.h b/gfx/layers/composite/ContentHost.h index 0c6a2912fdf1..5a98e7a93d67 100644 --- a/gfx/layers/composite/ContentHost.h +++ b/gfx/layers/composite/ContentHost.h @@ -47,7 +47,7 @@ class TextureImageTextureSourceOGL; struct TexturedEffect; /** - * ContentHosts are used for compositing Thebes layers, always matched by a + * ContentHosts are used for compositing Painted layers, always matched by a * ContentClient of the same type. * * ContentHosts support only UpdateThebes(), not Update(). diff --git a/gfx/layers/composite/ImageHost.cpp b/gfx/layers/composite/ImageHost.cpp index 61300d52a600..bb523513e99c 100644 --- a/gfx/layers/composite/ImageHost.cpp +++ b/gfx/layers/composite/ImageHost.cpp @@ -34,12 +34,30 @@ ImageHost::ImageHost(const TextureInfo& aTextureInfo) , mLocked(false) {} -ImageHost::~ImageHost() {} +ImageHost::~ImageHost() +{ + if (mFrontBuffer) { + mFrontBuffer->UnsetCompositableBackendSpecificData(GetCompositableBackendSpecificData()); + } +} + +void +ImageHost::SetCompositableBackendSpecificData(CompositableBackendSpecificData* aBackendData) +{ + CompositableHost::SetCompositableBackendSpecificData(aBackendData); + // ImageHost allows TextureHost sharing among ImageHosts. + if (aBackendData) { + aBackendData->SetAllowSharingTextureHost(true); + } +} void ImageHost::UseTextureHost(TextureHost* aTexture) { CompositableHost::UseTextureHost(aTexture); + if (mFrontBuffer) { + mFrontBuffer->UnsetCompositableBackendSpecificData(GetCompositableBackendSpecificData()); + } mFrontBuffer = aTexture; } diff --git a/gfx/layers/composite/ImageHost.h b/gfx/layers/composite/ImageHost.h index 544e22c7ec00..d8586444efee 100644 --- a/gfx/layers/composite/ImageHost.h +++ b/gfx/layers/composite/ImageHost.h @@ -45,6 +45,8 @@ public: virtual CompositableType GetType() { return mTextureInfo.mCompositableType; } + virtual void SetCompositableBackendSpecificData(CompositableBackendSpecificData* aBackendData) MOZ_OVERRIDE; + virtual void Composite(EffectChain& aEffectChain, float aOpacity, const gfx::Matrix4x4& aTransform, diff --git a/gfx/layers/composite/ImageLayerComposite.cpp b/gfx/layers/composite/ImageLayerComposite.cpp index d421fad67c47..99d7b491b961 100644 --- a/gfx/layers/composite/ImageLayerComposite.cpp +++ b/gfx/layers/composite/ImageLayerComposite.cpp @@ -135,8 +135,8 @@ ImageLayerComposite::ComputeEffectiveTransforms(const gfx::Matrix4x4& aTransform } // Snap our local transform first, and snap the inherited transform as well. // This makes our snapping equivalent to what would happen if our content - // was drawn into a ThebesLayer (gfxContext would snap using the local - // transform, then we'd snap again when compositing the ThebesLayer). + // was drawn into a PaintedLayer (gfxContext would snap using the local + // transform, then we'd snap again when compositing the PaintedLayer). mEffectiveTransform = SnapTransform(local, sourceRect, nullptr) * SnapTransformTranslation(aTransformToSurface, nullptr); diff --git a/gfx/layers/composite/LayerManagerComposite.cpp b/gfx/layers/composite/LayerManagerComposite.cpp index 8d3141e8c2f8..541e82051363 100644 --- a/gfx/layers/composite/LayerManagerComposite.cpp +++ b/gfx/layers/composite/LayerManagerComposite.cpp @@ -18,7 +18,7 @@ #include "Layers.h" // for Layer, ContainerLayer, etc #include "LayerScope.h" // for LayerScope Tool #include "protobuf/LayerScopePacket.pb.h" // for protobuf (LayerScope) -#include "ThebesLayerComposite.h" // for ThebesLayerComposite +#include "PaintedLayerComposite.h" // for PaintedLayerComposite #include "TiledLayerBuffer.h" // for TiledLayerComposer #include "Units.h" // for ScreenIntRect #include "gfx2DGlue.h" // for ToMatrix4x4 @@ -212,7 +212,7 @@ LayerManagerComposite::EndEmptyTransaction(EndTransactionFlags aFlags) } void -LayerManagerComposite::EndTransaction(DrawThebesLayerCallback aCallback, +LayerManagerComposite::EndTransaction(DrawPaintedLayerCallback aCallback, void* aCallbackData, EndTransactionFlags aFlags) { @@ -280,8 +280,8 @@ LayerManagerComposite::CreateOptimalMaskDrawTarget(const IntSize &aSize) return nullptr; } -already_AddRefed -LayerManagerComposite::CreateThebesLayer() +already_AddRefed +LayerManagerComposite::CreatePaintedLayer() { NS_RUNTIMEABORT("Should only be called on the drawing side"); return nullptr; @@ -757,15 +757,15 @@ LayerManagerComposite::ComputeRenderIntegrityInternal(Layer* aLayer, return; } - // Only thebes layers can be incomplete - ThebesLayer* thebesLayer = aLayer->AsThebesLayer(); - if (!thebesLayer) { + // Only painted layers can be incomplete + PaintedLayer* paintedLayer = aLayer->AsPaintedLayer(); + if (!paintedLayer) { return; } // See if there's any incomplete rendering nsIntRegion incompleteRegion = aLayer->GetEffectiveVisibleRegion(); - incompleteRegion.Sub(incompleteRegion, thebesLayer->GetValidRegion()); + incompleteRegion.Sub(incompleteRegion, paintedLayer->GetValidRegion()); if (!incompleteRegion.IsEmpty()) { // Calculate the transform to get between screen and layer space @@ -922,14 +922,14 @@ LayerManagerComposite::ComputeRenderIntegrity() return 1.f; } -already_AddRefed -LayerManagerComposite::CreateThebesLayerComposite() +already_AddRefed +LayerManagerComposite::CreatePaintedLayerComposite() { if (mDestroyed) { NS_WARNING("Call on destroyed layer manager"); return nullptr; } - return nsRefPtr(new ThebesLayerComposite(this)).forget(); + return nsRefPtr(new PaintedLayerComposite(this)).forget(); } already_AddRefed diff --git a/gfx/layers/composite/LayerManagerComposite.h b/gfx/layers/composite/LayerManagerComposite.h index a67fa450fca4..051c9b660ce6 100644 --- a/gfx/layers/composite/LayerManagerComposite.h +++ b/gfx/layers/composite/LayerManagerComposite.h @@ -61,7 +61,7 @@ class ImageLayerComposite; class LayerComposite; class RefLayerComposite; class SurfaceDescriptor; -class ThebesLayerComposite; +class PaintedLayerComposite; class TiledLayerComposer; class TextRenderer; class CompositingRenderTarget; @@ -120,7 +120,7 @@ public: void BeginTransactionWithDrawTarget(gfx::DrawTarget* aTarget, const nsIntRect& aRect); virtual bool EndEmptyTransaction(EndTransactionFlags aFlags = END_DEFAULT) MOZ_OVERRIDE; - virtual void EndTransaction(DrawThebesLayerCallback aCallback, + virtual void EndTransaction(DrawPaintedLayerCallback aCallback, void* aCallbackData, EndTransactionFlags aFlags = END_DEFAULT) MOZ_OVERRIDE; @@ -137,12 +137,12 @@ public: virtual void ClearCachedResources(Layer* aSubtree = nullptr) MOZ_OVERRIDE; - virtual already_AddRefed CreateThebesLayer() MOZ_OVERRIDE; + virtual already_AddRefed CreatePaintedLayer() MOZ_OVERRIDE; virtual already_AddRefed CreateContainerLayer() MOZ_OVERRIDE; virtual already_AddRefed CreateImageLayer() MOZ_OVERRIDE; virtual already_AddRefed CreateColorLayer() MOZ_OVERRIDE; virtual already_AddRefed CreateCanvasLayer() MOZ_OVERRIDE; - already_AddRefed CreateThebesLayerComposite(); + already_AddRefed CreatePaintedLayerComposite(); already_AddRefed CreateContainerLayerComposite(); already_AddRefed CreateImageLayerComposite(); already_AddRefed CreateColorLayerComposite(); diff --git a/gfx/layers/composite/ThebesLayerComposite.cpp b/gfx/layers/composite/PaintedLayerComposite.cpp similarity index 82% rename from gfx/layers/composite/ThebesLayerComposite.cpp rename to gfx/layers/composite/PaintedLayerComposite.cpp index 8b1b7bc28038..2f34ab9b9e5c 100644 --- a/gfx/layers/composite/ThebesLayerComposite.cpp +++ b/gfx/layers/composite/PaintedLayerComposite.cpp @@ -3,7 +3,7 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -#include "ThebesLayerComposite.h" +#include "PaintedLayerComposite.h" #include "CompositableHost.h" // for TiledLayerProperties, etc #include "FrameMetrics.h" // for FrameMetrics #include "Units.h" // for CSSRect, LayerPixel, etc @@ -34,23 +34,23 @@ namespace layers { class TiledLayerComposer; -ThebesLayerComposite::ThebesLayerComposite(LayerManagerComposite *aManager) - : ThebesLayer(aManager, nullptr) +PaintedLayerComposite::PaintedLayerComposite(LayerManagerComposite *aManager) + : PaintedLayer(aManager, nullptr) , LayerComposite(aManager) , mBuffer(nullptr) { - MOZ_COUNT_CTOR(ThebesLayerComposite); + MOZ_COUNT_CTOR(PaintedLayerComposite); mImplData = static_cast(this); } -ThebesLayerComposite::~ThebesLayerComposite() +PaintedLayerComposite::~PaintedLayerComposite() { - MOZ_COUNT_DTOR(ThebesLayerComposite); + MOZ_COUNT_DTOR(PaintedLayerComposite); CleanupResources(); } bool -ThebesLayerComposite::SetCompositableHost(CompositableHost* aHost) +PaintedLayerComposite::SetCompositableHost(CompositableHost* aHost) { switch (aHost->GetType()) { case CompositableType::BUFFER_CONTENT_INC: @@ -65,13 +65,13 @@ ThebesLayerComposite::SetCompositableHost(CompositableHost* aHost) } void -ThebesLayerComposite::Disconnect() +PaintedLayerComposite::Disconnect() { Destroy(); } void -ThebesLayerComposite::Destroy() +PaintedLayerComposite::Destroy() { if (!mDestroyed) { CleanupResources(); @@ -80,13 +80,13 @@ ThebesLayerComposite::Destroy() } Layer* -ThebesLayerComposite::GetLayer() +PaintedLayerComposite::GetLayer() { return this; } TiledLayerComposer* -ThebesLayerComposite::GetTiledLayerComposer() +PaintedLayerComposite::GetTiledLayerComposer() { if (!mBuffer) { return nullptr; @@ -96,7 +96,7 @@ ThebesLayerComposite::GetTiledLayerComposer() } LayerRenderState -ThebesLayerComposite::GetRenderState() +PaintedLayerComposite::GetRenderState() { if (!mBuffer || !mBuffer->IsAttached() || mDestroyed) { return LayerRenderState(); @@ -105,12 +105,12 @@ ThebesLayerComposite::GetRenderState() } void -ThebesLayerComposite::RenderLayer(const nsIntRect& aClipRect) +PaintedLayerComposite::RenderLayer(const nsIntRect& aClipRect) { if (!mBuffer || !mBuffer->IsAttached()) { return; } - PROFILER_LABEL("ThebesLayerComposite", "RenderLayer", + PROFILER_LABEL("PaintedLayerComposite", "RenderLayer", js::ProfileEntry::Category::GRAPHICS); MOZ_ASSERT(mBuffer->GetCompositor() == mCompositeManager->GetCompositor() && @@ -147,7 +147,7 @@ ThebesLayerComposite::RenderLayer(const nsIntRect& aClipRect) } CompositableHost* -ThebesLayerComposite::GetCompositableHost() +PaintedLayerComposite::GetCompositableHost() { if (mBuffer && mBuffer->IsAttached()) { return mBuffer.get(); @@ -157,7 +157,7 @@ ThebesLayerComposite::GetCompositableHost() } void -ThebesLayerComposite::CleanupResources() +PaintedLayerComposite::CleanupResources() { if (mBuffer) { mBuffer->Detach(this); @@ -166,16 +166,16 @@ ThebesLayerComposite::CleanupResources() } void -ThebesLayerComposite::GenEffectChain(EffectChain& aEffect) +PaintedLayerComposite::GenEffectChain(EffectChain& aEffect) { aEffect.mLayerRef = this; aEffect.mPrimaryEffect = mBuffer->GenEffect(GetEffectFilter()); } void -ThebesLayerComposite::PrintInfo(std::stringstream& aStream, const char* aPrefix) +PaintedLayerComposite::PrintInfo(std::stringstream& aStream, const char* aPrefix) { - ThebesLayer::PrintInfo(aStream, aPrefix); + PaintedLayer::PrintInfo(aStream, aPrefix); if (mBuffer && mBuffer->IsAttached()) { aStream << "\n"; nsAutoCString pfx(aPrefix); diff --git a/gfx/layers/composite/ThebesLayerComposite.h b/gfx/layers/composite/PaintedLayerComposite.h similarity index 78% rename from gfx/layers/composite/ThebesLayerComposite.h rename to gfx/layers/composite/PaintedLayerComposite.h index 71defa3a5738..7da8b663a897 100644 --- a/gfx/layers/composite/ThebesLayerComposite.h +++ b/gfx/layers/composite/PaintedLayerComposite.h @@ -3,8 +3,8 @@ * 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 GFX_ThebesLayerComposite_H -#define GFX_ThebesLayerComposite_H +#ifndef GFX_PaintedLayerComposite_H +#define GFX_PaintedLayerComposite_H #include "Layers.h" // for Layer (ptr only), etc #include "gfxRect.h" // for gfxRect @@ -24,23 +24,23 @@ namespace mozilla { namespace layers { /** - * Thebes layers use ContentHosts for their compsositable host. - * By using different ContentHosts, ThebesLayerComposite support tiled and - * non-tiled Thebes layers and single or double buffering. + * PaintedLayers use ContentHosts for their compsositable host. + * By using different ContentHosts, PaintedLayerComposite support tiled and + * non-tiled PaintedLayers and single or double buffering. */ class CompositableHost; class ContentHost; class TiledLayerComposer; -class ThebesLayerComposite : public ThebesLayer, +class PaintedLayerComposite : public PaintedLayer, public LayerComposite { public: - explicit ThebesLayerComposite(LayerManagerComposite *aManager); + explicit PaintedLayerComposite(LayerManagerComposite *aManager); protected: - virtual ~ThebesLayerComposite(); + virtual ~PaintedLayerComposite(); public: virtual void Disconnect() MOZ_OVERRIDE; @@ -67,7 +67,7 @@ public: virtual void InvalidateRegion(const nsIntRegion& aRegion) { - NS_RUNTIMEABORT("ThebesLayerComposites can't fill invalidated regions"); + NS_RUNTIMEABORT("PaintedLayerComposites can't fill invalidated regions"); } void SetValidRegion(const nsIntRegion& aRegion) @@ -77,7 +77,7 @@ public: Mutated(); } - MOZ_LAYER_DECL_NAME("ThebesLayerComposite", TYPE_THEBES) + MOZ_LAYER_DECL_NAME("PaintedLayerComposite", TYPE_PAINTED) protected: @@ -92,4 +92,4 @@ private: } /* layers */ } /* mozilla */ -#endif /* GFX_ThebesLayerComposite_H */ +#endif /* GFX_PaintedLayerComposite_H */ diff --git a/gfx/layers/composite/TextureHost.cpp b/gfx/layers/composite/TextureHost.cpp index b60219dd822f..8463e57bcbfa 100644 --- a/gfx/layers/composite/TextureHost.cpp +++ b/gfx/layers/composite/TextureHost.cpp @@ -291,9 +291,14 @@ TextureHost::CompositorRecycle() void TextureHost::SetCompositableBackendSpecificData(CompositableBackendSpecificData* aBackendData) { - mCompositableBackendData = aBackendData; + mCompositableBackendData = aBackendData; } +void +TextureHost::UnsetCompositableBackendSpecificData(CompositableBackendSpecificData* aBackendData) +{ + mCompositableBackendData = nullptr; +} TextureHost::TextureHost(TextureFlags aFlags) : mActor(nullptr) @@ -327,12 +332,6 @@ TextureHost::PrintInfo(std::stringstream& aStream, const char* aPrefix) AppendToString(aStream, mFlags, " [flags=", "]"); } -void -TextureSource::SetCompositableBackendSpecificData(CompositableBackendSpecificData* aBackendData) -{ - mCompositableBackendData = aBackendData; -} - TextureSource::TextureSource() { MOZ_COUNT_CTOR(TextureSource); diff --git a/gfx/layers/composite/TextureHost.h b/gfx/layers/composite/TextureHost.h index ed07b39d25ca..db0afbc47344 100644 --- a/gfx/layers/composite/TextureHost.h +++ b/gfx/layers/composite/TextureHost.h @@ -131,11 +131,6 @@ public: * one device texture and must be tiled internally. */ virtual BigImageIterator* AsBigImageIterator() { return nullptr; } - - virtual void SetCompositableBackendSpecificData(CompositableBackendSpecificData* aBackendData); - -protected: - RefPtr mCompositableBackendData; }; /** @@ -443,6 +438,8 @@ public: virtual void SetCompositableBackendSpecificData(CompositableBackendSpecificData* aBackendData); + virtual void UnsetCompositableBackendSpecificData(CompositableBackendSpecificData* aBackendData); + // If a texture host holds a reference to shmem, it should override this method // to forget about the shmem _without_ releasing it. virtual void OnShutdown() {} diff --git a/gfx/layers/composite/TiledContentHost.cpp b/gfx/layers/composite/TiledContentHost.cpp index 49d9bbfdc19e..1222f1ae0f4d 100644 --- a/gfx/layers/composite/TiledContentHost.cpp +++ b/gfx/layers/composite/TiledContentHost.cpp @@ -4,7 +4,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ #include "TiledContentHost.h" -#include "ThebesLayerComposite.h" // for ThebesLayerComposite +#include "PaintedLayerComposite.h" // for PaintedLayerComposite #include "mozilla/gfx/BaseSize.h" // for BaseSize #include "mozilla/gfx/Matrix.h" // for Matrix4x4 #include "mozilla/layers/Compositor.h" // for Compositor diff --git a/gfx/layers/composite/TiledContentHost.h b/gfx/layers/composite/TiledContentHost.h index dfeb45070272..273e0ada7dcd 100644 --- a/gfx/layers/composite/TiledContentHost.h +++ b/gfx/layers/composite/TiledContentHost.h @@ -166,7 +166,7 @@ private: }; /** - * ContentHost for tiled Thebes layers. Since tiled layers are special snow + * ContentHost for tiled PaintedLayers. Since tiled layers are special snow * flakes, we have a unique update process. All the textures that back the * tiles are added in the usual way, but Updated is called on the host side * in response to a message that describes the transaction for every tile. diff --git a/gfx/layers/d3d10/ColorLayerD3D10.h b/gfx/layers/d3d10/ColorLayerD3D10.h index 73341ed35a2f..cdd085912ecd 100644 --- a/gfx/layers/d3d10/ColorLayerD3D10.h +++ b/gfx/layers/d3d10/ColorLayerD3D10.h @@ -24,4 +24,4 @@ public: } /* layers */ } /* mozilla */ -#endif /* GFX_THEBESLAYERD3D10_H */ +#endif /* GFX_PAINTEDLAYERD3D10_H */ diff --git a/gfx/layers/d3d10/ContainerLayerD3D10.cpp b/gfx/layers/d3d10/ContainerLayerD3D10.cpp index 6150a6ee39cd..116ae2f264b6 100644 --- a/gfx/layers/d3d10/ContainerLayerD3D10.cpp +++ b/gfx/layers/d3d10/ContainerLayerD3D10.cpp @@ -5,7 +5,7 @@ #include "ContainerLayerD3D10.h" -#include "ThebesLayerD3D10.h" +#include "PaintedLayerD3D10.h" #include "ReadbackProcessor.h" using namespace mozilla::gfx; @@ -255,8 +255,8 @@ ContainerLayerD3D10::Validate() Layer *layer = GetFirstChild(); while (layer) { - if (layer->GetType() == TYPE_THEBES) { - static_cast(layer)->Validate(&readback); + if (layer->GetType() == TYPE_PAINTED) { + static_cast(layer)->Validate(&readback); } else { static_cast(layer->ImplData())->Validate(); } diff --git a/gfx/layers/d3d10/LayerManagerD3D10.cpp b/gfx/layers/d3d10/LayerManagerD3D10.cpp index 6fc088fc4e7e..5e3ecabf046e 100644 --- a/gfx/layers/d3d10/LayerManagerD3D10.cpp +++ b/gfx/layers/d3d10/LayerManagerD3D10.cpp @@ -15,7 +15,7 @@ #include "dxgi.h" #include "ContainerLayerD3D10.h" -#include "ThebesLayerD3D10.h" +#include "PaintedLayerD3D10.h" #include "ColorLayerD3D10.h" #include "CanvasLayerD3D10.h" #include "ReadbackLayerD3D10.h" @@ -354,7 +354,7 @@ LayerManagerD3D10::EndEmptyTransaction(EndTransactionFlags aFlags) } void -LayerManagerD3D10::EndTransaction(DrawThebesLayerCallback aCallback, +LayerManagerD3D10::EndTransaction(DrawPaintedLayerCallback aCallback, void* aCallbackData, EndTransactionFlags aFlags) { @@ -392,10 +392,10 @@ LayerManagerD3D10::EndTransaction(DrawThebesLayerCallback aCallback, mTarget = nullptr; } -already_AddRefed -LayerManagerD3D10::CreateThebesLayer() +already_AddRefed +LayerManagerD3D10::CreatePaintedLayer() { - nsRefPtr layer = new ThebesLayerD3D10(this); + nsRefPtr layer = new PaintedLayerD3D10(this); return layer.forget(); } diff --git a/gfx/layers/d3d10/LayerManagerD3D10.h b/gfx/layers/d3d10/LayerManagerD3D10.h index 0c3ff954faf8..e7b27118c796 100644 --- a/gfx/layers/d3d10/LayerManagerD3D10.h +++ b/gfx/layers/d3d10/LayerManagerD3D10.h @@ -81,11 +81,11 @@ public: virtual bool EndEmptyTransaction(EndTransactionFlags aFlags = END_DEFAULT); struct CallbackInfo { - DrawThebesLayerCallback Callback; + DrawPaintedLayerCallback Callback; void *CallbackData; }; - virtual void EndTransaction(DrawThebesLayerCallback aCallback, + virtual void EndTransaction(DrawPaintedLayerCallback aCallback, void* aCallbackData, EndTransactionFlags aFlags = END_DEFAULT); @@ -105,7 +105,7 @@ public: return MAX_TEXTURE_SIZE; } - virtual already_AddRefed CreateThebesLayer(); + virtual already_AddRefed CreatePaintedLayer(); virtual already_AddRefed CreateContainerLayer(); virtual already_AddRefed CreateImageLayer(); virtual already_AddRefed CreateColorLayer(); diff --git a/gfx/layers/d3d10/ThebesLayerD3D10.cpp b/gfx/layers/d3d10/PaintedLayerD3D10.cpp similarity index 90% rename from gfx/layers/d3d10/ThebesLayerD3D10.cpp rename to gfx/layers/d3d10/PaintedLayerD3D10.cpp index 3b4d8b5132f2..a2428f10ebed 100644 --- a/gfx/layers/d3d10/ThebesLayerD3D10.cpp +++ b/gfx/layers/d3d10/PaintedLayerD3D10.cpp @@ -9,7 +9,7 @@ // typedefs conflicts. #include "mozilla/ArrayUtils.h" -#include "ThebesLayerD3D10.h" +#include "PaintedLayerD3D10.h" #include "gfxPlatform.h" #include "gfxWindowsPlatform.h" @@ -31,27 +31,27 @@ namespace layers { using namespace mozilla::gfx; -ThebesLayerD3D10::ThebesLayerD3D10(LayerManagerD3D10 *aManager) - : ThebesLayer(aManager, nullptr) +PaintedLayerD3D10::PaintedLayerD3D10(LayerManagerD3D10 *aManager) + : PaintedLayer(aManager, nullptr) , LayerD3D10(aManager) , mCurrentSurfaceMode(SurfaceMode::SURFACE_OPAQUE) { mImplData = static_cast(this); } -ThebesLayerD3D10::~ThebesLayerD3D10() +PaintedLayerD3D10::~PaintedLayerD3D10() { } void -ThebesLayerD3D10::InvalidateRegion(const nsIntRegion &aRegion) +PaintedLayerD3D10::InvalidateRegion(const nsIntRegion &aRegion) { mInvalidRegion.Or(mInvalidRegion, aRegion); mInvalidRegion.SimplifyOutward(20); mValidRegion.Sub(mValidRegion, mInvalidRegion); } -void ThebesLayerD3D10::CopyRegion(ID3D10Texture2D* aSrc, const nsIntPoint &aSrcOffset, +void PaintedLayerD3D10::CopyRegion(ID3D10Texture2D* aSrc, const nsIntPoint &aSrcOffset, ID3D10Texture2D* aDest, const nsIntPoint &aDestOffset, const nsIntRegion &aCopyRegion, nsIntRegion* aValidRegion) { @@ -84,7 +84,7 @@ void ThebesLayerD3D10::CopyRegion(ID3D10Texture2D* aSrc, const nsIntPoint &aSrcO } void -ThebesLayerD3D10::RenderLayer() +PaintedLayerD3D10::RenderLayer() { if (!mTexture) { return; @@ -145,7 +145,7 @@ ThebesLayerD3D10::RenderLayer() } void -ThebesLayerD3D10::Validate(ReadbackProcessor *aReadback) +PaintedLayerD3D10::Validate(ReadbackProcessor *aReadback) { if (mVisibleRegion.IsEmpty()) { return; @@ -189,7 +189,7 @@ ThebesLayerD3D10::Validate(ReadbackProcessor *aReadback) nsTArray readbackUpdates; nsIntRegion readbackRegion; if (aReadback && UsedForReadback()) { - aReadback->GetThebesLayerUpdates(this, &readbackUpdates, &readbackRegion); + aReadback->GetPaintedLayerUpdates(this, &readbackUpdates, &readbackRegion); } if (mTexture) { @@ -243,7 +243,7 @@ ThebesLayerD3D10::Validate(ReadbackProcessor *aReadback) if (!drawRegion.IsEmpty()) { LayerManagerD3D10::CallbackInfo cbInfo = mD3DManager->GetCallbackInfo(); if (!cbInfo.Callback) { - NS_ERROR("D3D10 should never need to update ThebesLayers in an empty transaction"); + NS_ERROR("D3D10 should never need to update PaintedLayers in an empty transaction"); return; } @@ -258,7 +258,7 @@ ThebesLayerD3D10::Validate(ReadbackProcessor *aReadback) nsRefPtr readbackTexture; HRESULT hr = device()->CreateTexture2D(&desc, nullptr, getter_AddRefs(readbackTexture)); if (FAILED(hr)) { - LayerManagerD3D10::ReportFailure(NS_LITERAL_CSTRING("ThebesLayerD3D10::Validate(): Failed to create texture"), + LayerManagerD3D10::ReportFailure(NS_LITERAL_CSTRING("PaintedLayerD3D10::Validate(): Failed to create texture"), hr); return; } @@ -277,19 +277,19 @@ ThebesLayerD3D10::Validate(ReadbackProcessor *aReadback) } void -ThebesLayerD3D10::LayerManagerDestroyed() +PaintedLayerD3D10::LayerManagerDestroyed() { mD3DManager = nullptr; } Layer* -ThebesLayerD3D10::GetLayer() +PaintedLayerD3D10::GetLayer() { return this; } void -ThebesLayerD3D10::VerifyContentType(SurfaceMode aMode) +PaintedLayerD3D10::VerifyContentType(SurfaceMode aMode) { if (mDrawTarget) { SurfaceFormat format = aMode != SurfaceMode::SURFACE_SINGLE_CHANNEL_ALPHA ? @@ -299,7 +299,7 @@ ThebesLayerD3D10::VerifyContentType(SurfaceMode aMode) mDrawTarget = Factory::CreateDrawTargetForD3D10Texture(mTexture, format); if (!mDrawTarget) { - NS_WARNING("Failed to create drawtarget for ThebesLayerD3D10."); + NS_WARNING("Failed to create drawtarget for PaintedLayerD3D10."); return; } @@ -316,7 +316,7 @@ ThebesLayerD3D10::VerifyContentType(SurfaceMode aMode) } void -ThebesLayerD3D10::FillTexturesBlackWhite(const nsIntRegion& aRegion, const nsIntPoint& aOffset) +PaintedLayerD3D10::FillTexturesBlackWhite(const nsIntRegion& aRegion, const nsIntPoint& aOffset) { if (mTexture && mTextureOnWhite) { // It would be more optimal to draw the actual geometry, but more code @@ -380,7 +380,7 @@ ThebesLayerD3D10::FillTexturesBlackWhite(const nsIntRegion& aRegion, const nsInt } void -ThebesLayerD3D10::DrawRegion(nsIntRegion &aRegion, SurfaceMode aMode) +PaintedLayerD3D10::DrawRegion(nsIntRegion &aRegion, SurfaceMode aMode) { nsIntRect visibleRect = mVisibleRegion.GetBounds(); @@ -413,7 +413,7 @@ ThebesLayerD3D10::DrawRegion(nsIntRegion &aRegion, SurfaceMode aMode) } void -ThebesLayerD3D10::CreateNewTextures(const gfx::IntSize &aSize, SurfaceMode aMode) +PaintedLayerD3D10::CreateNewTextures(const gfx::IntSize &aSize, SurfaceMode aMode) { if (aSize.width == 0 || aSize.height == 0) { // Nothing to do. @@ -429,14 +429,14 @@ ThebesLayerD3D10::CreateNewTextures(const gfx::IntSize &aSize, SurfaceMode aMode hr = device()->CreateTexture2D(&desc, nullptr, getter_AddRefs(mTexture)); if (FAILED(hr)) { - NS_WARNING("Failed to create new texture for ThebesLayerD3D10!"); + NS_WARNING("Failed to create new texture for PaintedLayerD3D10!"); return; } hr = device()->CreateShaderResourceView(mTexture, nullptr, getter_AddRefs(mSRView)); if (FAILED(hr)) { - NS_WARNING("Failed to create shader resource view for ThebesLayerD3D10."); + NS_WARNING("Failed to create shader resource view for PaintedLayerD3D10."); } mDrawTarget = nullptr; @@ -446,14 +446,14 @@ ThebesLayerD3D10::CreateNewTextures(const gfx::IntSize &aSize, SurfaceMode aMode hr = device()->CreateTexture2D(&desc, nullptr, getter_AddRefs(mTextureOnWhite)); if (FAILED(hr)) { - NS_WARNING("Failed to create new texture for ThebesLayerD3D10!"); + NS_WARNING("Failed to create new texture for PaintedLayerD3D10!"); return; } hr = device()->CreateShaderResourceView(mTextureOnWhite, nullptr, getter_AddRefs(mSRViewOnWhite)); if (FAILED(hr)) { - NS_WARNING("Failed to create shader resource view for ThebesLayerD3D10."); + NS_WARNING("Failed to create shader resource view for PaintedLayerD3D10."); } mDrawTarget = nullptr; @@ -468,7 +468,7 @@ ThebesLayerD3D10::CreateNewTextures(const gfx::IntSize &aSize, SurfaceMode aMode } if (!mDrawTarget) { - NS_WARNING("Failed to create DrawTarget for ThebesLayerD3D10."); + NS_WARNING("Failed to create DrawTarget for PaintedLayerD3D10."); mDrawTarget = nullptr; return; } diff --git a/gfx/layers/d3d10/ThebesLayerD3D10.h b/gfx/layers/d3d10/PaintedLayerD3D10.h similarity index 88% rename from gfx/layers/d3d10/ThebesLayerD3D10.h rename to gfx/layers/d3d10/PaintedLayerD3D10.h index d39429053688..c6d502d377b8 100644 --- a/gfx/layers/d3d10/ThebesLayerD3D10.h +++ b/gfx/layers/d3d10/PaintedLayerD3D10.h @@ -3,24 +3,24 @@ * 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 GFX_THEBESLAYERD3D10_H -#define GFX_THEBESLAYERD3D10_H +#ifndef GFX_PAINTEDLAYERD3D10_H +#define GFX_PAINTEDLAYERD3D10_H #include "LayerManagerD3D10.h" namespace mozilla { namespace layers { -class ThebesLayerD3D10 : public ThebesLayer, +class PaintedLayerD3D10 : public PaintedLayer, public LayerD3D10 { public: - ThebesLayerD3D10(LayerManagerD3D10 *aManager); - virtual ~ThebesLayerD3D10(); + PaintedLayerD3D10(LayerManagerD3D10 *aManager); + virtual ~PaintedLayerD3D10(); void Validate(ReadbackProcessor *aReadback); - /* ThebesLayer implementation */ + /* PaintedLayer implementation */ void InvalidateRegion(const nsIntRegion& aRegion); /* LayerD3D10 implementation */ @@ -70,4 +70,4 @@ private: } /* layers */ } /* mozilla */ -#endif /* GFX_THEBESLAYERD3D10_H */ +#endif /* GFX_PAINTEDLAYERD3D10_H */ diff --git a/gfx/layers/d3d10/ReadbackManagerD3D10.cpp b/gfx/layers/d3d10/ReadbackManagerD3D10.cpp index c8e32d8b3625..650087615adc 100644 --- a/gfx/layers/d3d10/ReadbackManagerD3D10.cpp +++ b/gfx/layers/d3d10/ReadbackManagerD3D10.cpp @@ -20,14 +20,14 @@ namespace layers { // mLayer may be released only on the main thread this object should always be // destroyed on the main thread! struct ReadbackTask { - // The texture that we copied the contents of the thebeslayer to. + // The texture that we copied the contents of the paintedlayer to. nsRefPtr mReadbackTexture; // This exists purely to keep the ReadbackLayer alive for the lifetime of // mUpdate. Note that this addref and release should occur -solely- on the // main thread. nsRefPtr mLayer; ReadbackProcessor::Update mUpdate; - // The origin in ThebesLayer coordinates of mReadbackTexture. + // The origin in PaintedLayer coordinates of mReadbackTexture. gfxPoint mOrigin; // mLayer->GetBackgroundOffset() when the task is created. We have // to save this in the ReadbackTask because it might change before @@ -64,7 +64,7 @@ public: HRESULT hr = mTask->mReadbackTexture->Map(0, D3D10_MAP_READ, 0, &mappedTex); if (FAILED(hr)) { - // If this fails we're never going to get our ThebesLayer content. + // If this fails we're never going to get our PaintedLayer content. update->mLayer->GetSink()->SetUnknown(update->mSequenceCounter); return NS_OK; } diff --git a/gfx/layers/d3d10/ReadbackManagerD3D10.h b/gfx/layers/d3d10/ReadbackManagerD3D10.h index cff964d85fc5..5aa5113746f3 100644 --- a/gfx/layers/d3d10/ReadbackManagerD3D10.h +++ b/gfx/layers/d3d10/ReadbackManagerD3D10.h @@ -34,7 +34,7 @@ public: * @param aUpdate ReadbackProcessor::Update object. This is a void pointer * since we cannot forward declare a nested class, and do not * export ReadbackProcessor.h - * @param aOrigin Origin of the aTexture surface in the ThebesLayer + * @param aOrigin Origin of the aTexture surface in the PaintedLayer * coordinate system. */ void PostTask(ID3D10Texture2D *aTexture, void *aUpdate, const gfxPoint &aOrigin); diff --git a/gfx/layers/d3d11/ReadbackManagerD3D11.cpp b/gfx/layers/d3d11/ReadbackManagerD3D11.cpp index 12213abf60d2..89536b857fa4 100644 --- a/gfx/layers/d3d11/ReadbackManagerD3D11.cpp +++ b/gfx/layers/d3d11/ReadbackManagerD3D11.cpp @@ -23,7 +23,7 @@ namespace layers { // mSink may be released only on the main thread this object should always be // destroyed on the main thread! struct ReadbackTask { - // The texture that we copied the contents of the thebeslayer to. + // The texture that we copied the contents of the paintedlayer to. nsRefPtr mReadbackTexture; // The sink that we're trying to read back to. RefPtr mSink; diff --git a/gfx/layers/d3d9/ContainerLayerD3D9.cpp b/gfx/layers/d3d9/ContainerLayerD3D9.cpp index 36a1272b0183..a9e486ce9718 100644 --- a/gfx/layers/d3d9/ContainerLayerD3D9.cpp +++ b/gfx/layers/d3d9/ContainerLayerD3D9.cpp @@ -5,7 +5,7 @@ #include "ContainerLayerD3D9.h" -#include "ThebesLayerD3D9.h" +#include "PaintedLayerD3D9.h" #include "ReadbackProcessor.h" using namespace mozilla::gfx; @@ -173,8 +173,8 @@ ContainerLayerD3D9::RenderLayer() d3drect.bottom = scissorRect.y + scissorRect.height; device()->SetScissorRect(&d3drect); - if (layerToRender->GetLayer()->GetType() == TYPE_THEBES) { - static_cast(layerToRender)->RenderThebesLayer(&readback); + if (layerToRender->GetLayer()->GetType() == TYPE_PAINTED) { + static_cast(layerToRender)->RenderPaintedLayer(&readback); } else { layerToRender->RenderLayer(); } diff --git a/gfx/layers/d3d9/DeviceManagerD3D9.cpp b/gfx/layers/d3d9/DeviceManagerD3D9.cpp index 167b953ac86a..ceb42c107ca2 100644 --- a/gfx/layers/d3d9/DeviceManagerD3D9.cpp +++ b/gfx/layers/d3d9/DeviceManagerD3D9.cpp @@ -5,7 +5,7 @@ #include "DeviceManagerD3D9.h" #include "LayerManagerD3D9Shaders.h" -#include "ThebesLayerD3D9.h" +#include "PaintedLayerD3D9.h" #include "nsIServiceManager.h" #include "nsIConsoleService.h" #include "nsPrintfCString.h" diff --git a/gfx/layers/d3d9/ImageLayerD3D9.cpp b/gfx/layers/d3d9/ImageLayerD3D9.cpp index 1dbecff83216..a7bd3b1cf4e7 100644 --- a/gfx/layers/d3d9/ImageLayerD3D9.cpp +++ b/gfx/layers/d3d9/ImageLayerD3D9.cpp @@ -10,7 +10,7 @@ #include "gfxSharedImageSurface.h" #include "ImageLayerD3D9.h" -#include "ThebesLayerD3D9.h" +#include "PaintedLayerD3D9.h" #include "gfxPlatform.h" #include "gfx2DGlue.h" #include "yuv_convert.h" diff --git a/gfx/layers/d3d9/LayerManagerD3D9.cpp b/gfx/layers/d3d9/LayerManagerD3D9.cpp index dd5e53f9233e..770c724499ce 100644 --- a/gfx/layers/d3d9/LayerManagerD3D9.cpp +++ b/gfx/layers/d3d9/LayerManagerD3D9.cpp @@ -5,7 +5,7 @@ #include "LayerManagerD3D9.h" -#include "ThebesLayerD3D9.h" +#include "PaintedLayerD3D9.h" #include "ContainerLayerD3D9.h" #include "ImageLayerD3D9.h" #include "ColorLayerD3D9.h" @@ -128,7 +128,7 @@ LayerManagerD3D9::EndEmptyTransaction(EndTransactionFlags aFlags) } void -LayerManagerD3D9::EndTransaction(DrawThebesLayerCallback aCallback, +LayerManagerD3D9::EndTransaction(DrawPaintedLayerCallback aCallback, void* aCallbackData, EndTransactionFlags aFlags) { @@ -167,10 +167,10 @@ LayerManagerD3D9::SetRoot(Layer *aLayer) mRoot = aLayer; } -already_AddRefed -LayerManagerD3D9::CreateThebesLayer() +already_AddRefed +LayerManagerD3D9::CreatePaintedLayer() { - nsRefPtr layer = new ThebesLayerD3D9(this); + nsRefPtr layer = new PaintedLayerD3D9(this); return layer.forget(); } diff --git a/gfx/layers/d3d9/LayerManagerD3D9.h b/gfx/layers/d3d9/LayerManagerD3D9.h index a8ae20f36b74..5f6ec52439d9 100644 --- a/gfx/layers/d3d9/LayerManagerD3D9.h +++ b/gfx/layers/d3d9/LayerManagerD3D9.h @@ -20,7 +20,7 @@ namespace mozilla { namespace layers { class LayerD3D9; -class ThebesLayerD3D9; +class PaintedLayerD3D9; /* * This is the LayerManager used for Direct3D 9. For now this will render on @@ -66,11 +66,11 @@ public: virtual bool EndEmptyTransaction(EndTransactionFlags aFlags = END_DEFAULT); struct CallbackInfo { - DrawThebesLayerCallback Callback; + DrawPaintedLayerCallback Callback; void *CallbackData; }; - virtual void EndTransaction(DrawThebesLayerCallback aCallback, + virtual void EndTransaction(DrawPaintedLayerCallback aCallback, void* aCallbackData, EndTransactionFlags aFlags = END_DEFAULT); @@ -91,7 +91,7 @@ public: return mDeviceManager->GetMaxTextureSize(); } - virtual already_AddRefed CreateThebesLayer(); + virtual already_AddRefed CreatePaintedLayer(); virtual already_AddRefed CreateContainerLayer(); diff --git a/gfx/layers/d3d9/ThebesLayerD3D9.cpp b/gfx/layers/d3d9/PaintedLayerD3D9.cpp similarity index 94% rename from gfx/layers/d3d9/ThebesLayerD3D9.cpp rename to gfx/layers/d3d9/PaintedLayerD3D9.cpp index 35c02b0989c8..c484b7c96362 100644 --- a/gfx/layers/d3d9/ThebesLayerD3D9.cpp +++ b/gfx/layers/d3d9/PaintedLayerD3D9.cpp @@ -9,7 +9,7 @@ // typedefs conflicts. #include "mozilla/ArrayUtils.h" -#include "ThebesLayerD3D9.h" +#include "PaintedLayerD3D9.h" #include "gfxPlatform.h" #include "gfxWindowsPlatform.h" @@ -24,15 +24,15 @@ namespace layers { using namespace gfx; -ThebesLayerD3D9::ThebesLayerD3D9(LayerManagerD3D9 *aManager) - : ThebesLayer(aManager, nullptr) +PaintedLayerD3D9::PaintedLayerD3D9(LayerManagerD3D9 *aManager) + : PaintedLayer(aManager, nullptr) , LayerD3D9(aManager) { mImplData = static_cast(this); aManager->deviceManager()->mLayersWithResources.AppendElement(this); } -ThebesLayerD3D9::~ThebesLayerD3D9() +PaintedLayerD3D9::~PaintedLayerD3D9() { if (mD3DManager) { mD3DManager->deviceManager()->mLayersWithResources.RemoveElement(this); @@ -47,7 +47,7 @@ ThebesLayerD3D9::~ThebesLayerD3D9() #define RETENTION_THRESHOLD 16384 void -ThebesLayerD3D9::InvalidateRegion(const nsIntRegion &aRegion) +PaintedLayerD3D9::InvalidateRegion(const nsIntRegion &aRegion) { mInvalidRegion.Or(mInvalidRegion, aRegion); mInvalidRegion.SimplifyOutward(20); @@ -55,7 +55,7 @@ ThebesLayerD3D9::InvalidateRegion(const nsIntRegion &aRegion) } void -ThebesLayerD3D9::CopyRegion(IDirect3DTexture9* aSrc, const nsIntPoint &aSrcOffset, +PaintedLayerD3D9::CopyRegion(IDirect3DTexture9* aSrc, const nsIntPoint &aSrcOffset, IDirect3DTexture9* aDest, const nsIntPoint &aDestOffset, const nsIntRegion &aCopyRegion, nsIntRegion* aValidRegion) { @@ -97,7 +97,7 @@ ThebesLayerD3D9::CopyRegion(IDirect3DTexture9* aSrc, const nsIntPoint &aSrcOffse } void -ThebesLayerD3D9::UpdateTextures(SurfaceMode aMode) +PaintedLayerD3D9::UpdateTextures(SurfaceMode aMode) { nsIntRect visibleRect = mVisibleRegion.GetBounds(); @@ -141,7 +141,7 @@ ThebesLayerD3D9::UpdateTextures(SurfaceMode aMode) } void -ThebesLayerD3D9::RenderRegion(const nsIntRegion& aRegion) +PaintedLayerD3D9::RenderRegion(const nsIntRegion& aRegion) { nsIntRegionRectIterator iter(aRegion); @@ -166,7 +166,7 @@ ThebesLayerD3D9::RenderRegion(const nsIntRegion& aRegion) } void -ThebesLayerD3D9::RenderThebesLayer(ReadbackProcessor* aReadback) +PaintedLayerD3D9::RenderPaintedLayer(ReadbackProcessor* aReadback) { if (mVisibleRegion.IsEmpty()) { return; @@ -208,10 +208,10 @@ ThebesLayerD3D9::RenderThebesLayer(ReadbackProcessor* aReadback) nsTArray readbackUpdates; nsIntRegion readbackRegion; if (aReadback && UsedForReadback()) { - aReadback->GetThebesLayerUpdates(this, &readbackUpdates, &readbackRegion); + aReadback->GetPaintedLayerUpdates(this, &readbackUpdates, &readbackRegion); } - // Because updates to D3D9 ThebesLayers are rendered with the CPU, we don't + // Because updates to D3D9 PaintedLayers are rendered with the CPU, we don't // have to do readback from D3D9 surfaces. Instead we make sure that any area // needed for readback is included in the drawRegion we ask layout to render. // Then the readback areas we need can be copied out of the temporary @@ -224,7 +224,7 @@ ThebesLayerD3D9::RenderThebesLayer(ReadbackProcessor* aReadback) if (!drawRegion.IsEmpty()) { LayerManagerD3D9::CallbackInfo cbInfo = mD3DManager->GetCallbackInfo(); if (!cbInfo.Callback) { - NS_ERROR("D3D9 should never need to update ThebesLayers in an empty transaction"); + NS_ERROR("D3D9 should never need to update PaintedLayers in an empty transaction"); return; } @@ -272,7 +272,7 @@ ThebesLayerD3D9::RenderThebesLayer(ReadbackProcessor* aReadback) } void -ThebesLayerD3D9::CleanResources() +PaintedLayerD3D9::CleanResources() { mTexture = nullptr; mTextureOnWhite = nullptr; @@ -280,26 +280,26 @@ ThebesLayerD3D9::CleanResources() } void -ThebesLayerD3D9::LayerManagerDestroyed() +PaintedLayerD3D9::LayerManagerDestroyed() { mD3DManager->deviceManager()->mLayersWithResources.RemoveElement(this); mD3DManager = nullptr; } Layer* -ThebesLayerD3D9::GetLayer() +PaintedLayerD3D9::GetLayer() { return this; } bool -ThebesLayerD3D9::IsEmpty() +PaintedLayerD3D9::IsEmpty() { return !mTexture; } void -ThebesLayerD3D9::VerifyContentType(SurfaceMode aMode) +PaintedLayerD3D9::VerifyContentType(SurfaceMode aMode) { if (!mTexture) return; @@ -480,7 +480,7 @@ FillSurface(gfxASurface* aSurface, const nsIntRegion& aRegion, } void -ThebesLayerD3D9::DrawRegion(nsIntRegion &aRegion, SurfaceMode aMode, +PaintedLayerD3D9::DrawRegion(nsIntRegion &aRegion, SurfaceMode aMode, const nsTArray& aReadbackUpdates) { nsIntRect visibleRect = mVisibleRegion.GetBounds(); @@ -619,7 +619,7 @@ ThebesLayerD3D9::DrawRegion(nsIntRegion &aRegion, SurfaceMode aMode, } void -ThebesLayerD3D9::CreateNewTextures(const gfx::IntSize &aSize, +PaintedLayerD3D9::CreateNewTextures(const gfx::IntSize &aSize, SurfaceMode aMode) { if (aSize.width == 0 || aSize.height == 0) { @@ -634,7 +634,7 @@ ThebesLayerD3D9::CreateNewTextures(const gfx::IntSize &aSize, aMode != SurfaceMode::SURFACE_SINGLE_CHANNEL_ALPHA ? D3DFMT_X8R8G8B8 : D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, getter_AddRefs(mTexture), nullptr); if (FAILED(hr)) { - ReportFailure(NS_LITERAL_CSTRING("ThebesLayerD3D9::CreateNewTextures(): Failed to create texture"), + ReportFailure(NS_LITERAL_CSTRING("PaintedLayerD3D9::CreateNewTextures(): Failed to create texture"), hr); return; } @@ -645,7 +645,7 @@ ThebesLayerD3D9::CreateNewTextures(const gfx::IntSize &aSize, D3DFMT_X8R8G8B8, D3DPOOL_DEFAULT, getter_AddRefs(mTextureOnWhite), nullptr); if (FAILED(hr)) { - ReportFailure(NS_LITERAL_CSTRING("ThebesLayerD3D9::CreateNewTextures(): Failed to create texture (2)"), + ReportFailure(NS_LITERAL_CSTRING("PaintedLayerD3D9::CreateNewTextures(): Failed to create texture (2)"), hr); return; } diff --git a/gfx/layers/d3d9/ThebesLayerD3D9.h b/gfx/layers/d3d9/PaintedLayerD3D9.h similarity index 85% rename from gfx/layers/d3d9/ThebesLayerD3D9.h rename to gfx/layers/d3d9/PaintedLayerD3D9.h index 54e542158bd8..4c6b3b3f142c 100644 --- a/gfx/layers/d3d9/ThebesLayerD3D9.h +++ b/gfx/layers/d3d9/PaintedLayerD3D9.h @@ -3,8 +3,8 @@ * 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 GFX_THEBESLAYERD3D9_H -#define GFX_THEBESLAYERD3D9_H +#ifndef GFX_PAINTEDLAYERD3D9_H +#define GFX_PAINTEDLAYERD3D9_H #include "Layers.h" #include "LayerManagerD3D9.h" @@ -15,24 +15,24 @@ namespace layers { class ReadbackProcessor; -class ThebesLayerD3D9 : public ThebesLayer, +class PaintedLayerD3D9 : public PaintedLayer, public LayerD3D9 { public: - ThebesLayerD3D9(LayerManagerD3D9 *aManager); - virtual ~ThebesLayerD3D9(); + PaintedLayerD3D9(LayerManagerD3D9 *aManager); + virtual ~PaintedLayerD3D9(); - /* ThebesLayer implementation */ + /* PaintedLayer implementation */ void InvalidateRegion(const nsIntRegion& aRegion); /* LayerD3D9 implementation */ Layer* GetLayer(); virtual bool IsEmpty(); - virtual void RenderLayer() { RenderThebesLayer(nullptr); } + virtual void RenderLayer() { RenderPaintedLayer(nullptr); } virtual void CleanResources(); virtual void LayerManagerDestroyed(); - void RenderThebesLayer(ReadbackProcessor* aReadback); + void RenderPaintedLayer(ReadbackProcessor* aReadback); private: /* @@ -81,4 +81,4 @@ private: } /* layers */ } /* mozilla */ -#endif /* GFX_THEBESLAYERD3D9_H */ +#endif /* GFX_PAINTEDLAYERD3D9_H */ diff --git a/gfx/layers/ipc/CompositableTransactionParent.cpp b/gfx/layers/ipc/CompositableTransactionParent.cpp index 61960d285474..c5f21413eb63 100644 --- a/gfx/layers/ipc/CompositableTransactionParent.cpp +++ b/gfx/layers/ipc/CompositableTransactionParent.cpp @@ -23,7 +23,7 @@ #include "mozilla/layers/LayersTypes.h" // for MOZ_LAYERS_LOG #include "mozilla/layers/TextureHost.h" // for TextureHost #include "mozilla/layers/TextureHostOGL.h" // for TextureHostOGL -#include "mozilla/layers/ThebesLayerComposite.h" +#include "mozilla/layers/PaintedLayerComposite.h" #include "mozilla/mozalloc.h" // for operator delete #include "mozilla/unused.h" #include "nsDebug.h" // for NS_WARNING, NS_ASSERTION @@ -88,15 +88,15 @@ CompositableParentManager::ReceiveCompositableUpdate(const CompositableOperation break; } case CompositableOperation::TOpPaintTextureRegion: { - MOZ_LAYERS_LOG(("[ParentSide] Paint ThebesLayer")); + MOZ_LAYERS_LOG(("[ParentSide] Paint PaintedLayer")); const OpPaintTextureRegion& op = aEdit.get_OpPaintTextureRegion(); CompositableHost* compositable = AsCompositable(op); Layer* layer = compositable->GetLayer(); - if (!layer || layer->GetType() != Layer::TYPE_THEBES) { + if (!layer || layer->GetType() != Layer::TYPE_PAINTED) { return false; } - ThebesLayerComposite* thebes = static_cast(layer); + PaintedLayerComposite* thebes = static_cast(layer); const ThebesBufferData& bufferData = op.bufferData(); @@ -117,7 +117,7 @@ CompositableParentManager::ReceiveCompositableUpdate(const CompositableOperation break; } case CompositableOperation::TOpPaintTextureIncremental: { - MOZ_LAYERS_LOG(("[ParentSide] Paint ThebesLayer")); + MOZ_LAYERS_LOG(("[ParentSide] Paint PaintedLayer")); const OpPaintTextureIncremental& op = aEdit.get_OpPaintTextureIncremental(); diff --git a/gfx/layers/ipc/LayerTransactionParent.cpp b/gfx/layers/ipc/LayerTransactionParent.cpp index ee295c48ddba..670928832c8a 100644 --- a/gfx/layers/ipc/LayerTransactionParent.cpp +++ b/gfx/layers/ipc/LayerTransactionParent.cpp @@ -26,7 +26,7 @@ #include "mozilla/layers/PCompositableParent.h" #include "mozilla/layers/PLayerParent.h" // for PLayerParent #include "mozilla/layers/TextureHostOGL.h" // for TextureHostOGL -#include "mozilla/layers/ThebesLayerComposite.h" +#include "mozilla/layers/PaintedLayerComposite.h" #include "mozilla/mozalloc.h" // for operator delete, etc #include "mozilla/unused.h" #include "nsCoord.h" // for NSAppUnitsToFloatPixels @@ -234,12 +234,12 @@ LayerTransactionParent::RecvUpdate(const InfallibleTArray& cset, switch (edit.type()) { // Create* ops - case Edit::TOpCreateThebesLayer: { - MOZ_LAYERS_LOG(("[ParentSide] CreateThebesLayer")); + case Edit::TOpCreatePaintedLayer: { + MOZ_LAYERS_LOG(("[ParentSide] CreatePaintedLayer")); - nsRefPtr layer = - layer_manager()->CreateThebesLayerComposite(); - AsLayerComposite(edit.get_OpCreateThebesLayer())->Bind(layer); + nsRefPtr layer = + layer_manager()->CreatePaintedLayerComposite(); + AsLayerComposite(edit.get_OpCreatePaintedLayer())->Bind(layer); break; } case Edit::TOpCreateContainerLayer: { @@ -329,17 +329,17 @@ LayerTransactionParent::RecvUpdate(const InfallibleTArray& cset, case Specific::Tnull_t: break; - case Specific::TThebesLayerAttributes: { - MOZ_LAYERS_LOG(("[ParentSide] thebes layer")); + case Specific::TPaintedLayerAttributes: { + MOZ_LAYERS_LOG(("[ParentSide] painted layer")); - ThebesLayerComposite* thebesLayer = layerParent->AsThebesLayerComposite(); - if (!thebesLayer) { + PaintedLayerComposite* paintedLayer = layerParent->AsPaintedLayerComposite(); + if (!paintedLayer) { return false; } - const ThebesLayerAttributes& attrs = - specific.get_ThebesLayerAttributes(); + const PaintedLayerAttributes& attrs = + specific.get_PaintedLayerAttributes(); - thebesLayer->SetValidRegion(attrs.validRegion()); + paintedLayer->SetValidRegion(attrs.validRegion()); break; } diff --git a/gfx/layers/ipc/LayersMessages.ipdlh b/gfx/layers/ipc/LayersMessages.ipdlh index 561f687631ed..521935573b07 100644 --- a/gfx/layers/ipc/LayersMessages.ipdlh +++ b/gfx/layers/ipc/LayersMessages.ipdlh @@ -54,7 +54,7 @@ struct TargetConfig { }; // Create a shadow layer for |layer| -struct OpCreateThebesLayer { PLayer layer; }; +struct OpCreatePaintedLayer { PLayer layer; }; struct OpCreateContainerLayer { PLayer layer; }; struct OpCreateImageLayer { PLayer layer; }; struct OpCreateColorLayer { PLayer layer; }; @@ -219,7 +219,7 @@ struct CommonLayerAttributes { string contentDescription; }; -struct ThebesLayerAttributes { +struct PaintedLayerAttributes { nsIntRegion validRegion; }; struct ContainerLayerAttributes { @@ -235,7 +235,7 @@ struct ImageLayerAttributes { GraphicsFilterType filter; IntSize scaleToSize union SpecificLayerAttributes { null_t; - ThebesLayerAttributes; + PaintedLayerAttributes; ContainerLayerAttributes; ColorLayerAttributes; CanvasLayerAttributes; @@ -430,7 +430,7 @@ union CompositableOperation { // A unit of a changeset; a set of these comprise a changeset union Edit { - OpCreateThebesLayer; + OpCreatePaintedLayer; OpCreateContainerLayer; OpCreateImageLayer; OpCreateColorLayer; diff --git a/gfx/layers/ipc/ShadowLayerParent.cpp b/gfx/layers/ipc/ShadowLayerParent.cpp index 628bb09620cb..f5d9f08d7349 100644 --- a/gfx/layers/ipc/ShadowLayerParent.cpp +++ b/gfx/layers/ipc/ShadowLayerParent.cpp @@ -10,7 +10,7 @@ #include "nsDebug.h" // for NS_RUNTIMEABORT #include "nsISupportsImpl.h" // for Layer::AddRef, etc -#include "mozilla/layers/ThebesLayerComposite.h" +#include "mozilla/layers/PaintedLayerComposite.h" #include "mozilla/layers/CanvasLayerComposite.h" #include "mozilla/layers/ColorLayerComposite.h" #include "mozilla/layers/ImageLayerComposite.h" @@ -85,11 +85,11 @@ ShadowLayerParent::AsRefLayerComposite() const : nullptr; } -ThebesLayerComposite* -ShadowLayerParent::AsThebesLayerComposite() const +PaintedLayerComposite* +ShadowLayerParent::AsPaintedLayerComposite() const { - return mLayer && mLayer->GetType() == Layer::TYPE_THEBES - ? static_cast(mLayer.get()) + return mLayer && mLayer->GetType() == Layer::TYPE_PAINTED + ? static_cast(mLayer.get()) : nullptr; } diff --git a/gfx/layers/ipc/ShadowLayerParent.h b/gfx/layers/ipc/ShadowLayerParent.h index 99071795ffaa..550edb46d3c0 100644 --- a/gfx/layers/ipc/ShadowLayerParent.h +++ b/gfx/layers/ipc/ShadowLayerParent.h @@ -25,7 +25,7 @@ class ColorLayerComposite; class ContainerLayerComposite; class ImageLayerComposite; class RefLayerComposite; -class ThebesLayerComposite; +class PaintedLayerComposite; class ShadowLayerParent : public PLayerParent { @@ -44,7 +44,7 @@ public: ColorLayerComposite* AsColorLayerComposite() const; ImageLayerComposite* AsImageLayerComposite() const; RefLayerComposite* AsRefLayerComposite() const; - ThebesLayerComposite* AsThebesLayerComposite() const; + PaintedLayerComposite* AsPaintedLayerComposite() const; private: virtual void ActorDestroy(ActorDestroyReason why) MOZ_OVERRIDE; diff --git a/gfx/layers/ipc/ShadowLayers.cpp b/gfx/layers/ipc/ShadowLayers.cpp index 8b3466aec2ff..15135f273857 100644 --- a/gfx/layers/ipc/ShadowLayers.cpp +++ b/gfx/layers/ipc/ShadowLayers.cpp @@ -205,9 +205,9 @@ CreatedLayer(Transaction* aTxn, ShadowableLayer* aLayer) } void -ShadowLayerForwarder::CreatedThebesLayer(ShadowableLayer* aThebes) +ShadowLayerForwarder::CreatedPaintedLayer(ShadowableLayer* aThebes) { - CreatedLayer(mTxn, aThebes); + CreatedLayer(mTxn, aThebes); } void ShadowLayerForwarder::CreatedContainerLayer(ShadowableLayer* aContainer) diff --git a/gfx/layers/ipc/ShadowLayers.h b/gfx/layers/ipc/ShadowLayers.h index b15b0cdde3bb..c01c46f17373 100644 --- a/gfx/layers/ipc/ShadowLayers.h +++ b/gfx/layers/ipc/ShadowLayers.h @@ -50,7 +50,7 @@ class ShadowableLayer; class ShmemTextureClient; class SurfaceDescriptor; class TextureClient; -class ThebesLayerComposite; +class PaintedLayerComposite; class ThebesBuffer; class ThebesBufferData; class TiledLayerComposer; @@ -189,7 +189,7 @@ public: * created, and a corresponding shadow layer should be created in * the compositing process. */ - void CreatedThebesLayer(ShadowableLayer* aThebes); + void CreatedPaintedLayer(ShadowableLayer* aThebes); void CreatedContainerLayer(ShadowableLayer* aContainer); void CreatedImageLayer(ShadowableLayer* aImage); void CreatedColorLayer(ShadowableLayer* aColor); diff --git a/gfx/layers/moz.build b/gfx/layers/moz.build index 414e2504bd2e..72348387a0d7 100644 --- a/gfx/layers/moz.build +++ b/gfx/layers/moz.build @@ -9,12 +9,12 @@ EXPORTS += [ 'basic/BasicImplData.h', 'basic/BasicLayers.h', 'basic/BasicLayersImpl.h', - 'basic/BasicThebesLayer.h', + 'basic/BasicPaintedLayer.h', 'client/ClientCanvasLayer.h', 'client/ClientContainerLayer.h', 'client/ClientLayerManager.h', - 'client/ClientThebesLayer.h', - 'client/ClientTiledThebesLayer.h', + 'client/ClientPaintedLayer.h', + 'client/ClientTiledPaintedLayer.h', 'composite/CompositableHost.h', 'composite/ImageHost.h', 'CopyableCanvasLayer.h', @@ -65,8 +65,8 @@ if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'windows': 'd3d9/ContainerLayerD3D9.cpp', 'd3d9/ImageLayerD3D9.cpp', 'd3d9/LayerManagerD3D9.cpp', + 'd3d9/PaintedLayerD3D9.cpp', 'd3d9/TextureD3D9.cpp', - 'd3d9/ThebesLayerD3D9.cpp', ] SOURCES += [ 'd3d9/CompositorD3D9.cpp', @@ -90,8 +90,8 @@ if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'windows': 'd3d10/ContainerLayerD3D10.cpp', 'd3d10/ImageLayerD3D10.cpp', 'd3d10/LayerManagerD3D10.cpp', + 'd3d10/PaintedLayerD3D10.cpp', 'd3d10/ReadbackManagerD3D10.cpp', - 'd3d10/ThebesLayerD3D10.cpp', 'd3d11/TextureD3D11.cpp', 'ipc/ShadowLayerUtilsD3D10.cpp', ] @@ -139,8 +139,8 @@ EXPORTS.mozilla.layers += [ 'composite/ImageHost.h', 'composite/ImageLayerComposite.h', 'composite/LayerManagerComposite.h', + 'composite/PaintedLayerComposite.h', 'composite/TextureHost.h', - 'composite/ThebesLayerComposite.h', 'Compositor.h', 'CompositorTypes.h', 'D3D9SurfaceImage.h', @@ -256,7 +256,7 @@ UNIFIED_SOURCES += [ 'basic/BasicImages.cpp', 'basic/BasicLayerManager.cpp', 'basic/BasicLayersImpl.cpp', - 'basic/BasicThebesLayer.cpp', + 'basic/BasicPaintedLayer.cpp', 'basic/TextureHostBasic.cpp', 'BufferUnrotate.cpp', 'client/CanvasClient.cpp', @@ -265,8 +265,8 @@ UNIFIED_SOURCES += [ 'client/ClientContainerLayer.cpp', 'client/ClientImageLayer.cpp', 'client/ClientLayerManager.cpp', - 'client/ClientThebesLayer.cpp', - 'client/ClientTiledThebesLayer.cpp', + 'client/ClientPaintedLayer.cpp', + 'client/ClientTiledPaintedLayer.cpp', 'client/CompositableClient.cpp', 'client/ContentClient.cpp', 'client/ImageClient.cpp', @@ -283,9 +283,9 @@ UNIFIED_SOURCES += [ 'composite/ImageHost.cpp', 'composite/ImageLayerComposite.cpp', 'composite/LayerManagerComposite.cpp', + 'composite/PaintedLayerComposite.cpp', 'composite/TextRenderer.cpp', 'composite/TextureHost.cpp', - 'composite/ThebesLayerComposite.cpp', 'composite/TiledContentHost.cpp', 'Compositor.cpp', 'CopyableCanvasLayer.cpp', diff --git a/gfx/layers/opengl/GrallocTextureHost.cpp b/gfx/layers/opengl/GrallocTextureHost.cpp index 56aba50cc1f9..0931005a952e 100644 --- a/gfx/layers/opengl/GrallocTextureHost.cpp +++ b/gfx/layers/opengl/GrallocTextureHost.cpp @@ -121,10 +121,9 @@ GrallocTextureSourceOGL::BindTexture(GLenum aTextureUnit, gfx::Filter aFilter) * texture using fEGLImageTargetTexture2D. */ MOZ_ASSERT(gl()); - if (!IsValid()) { + if (!IsValid() || !gl()->MakeCurrent()) { return; } - gl()->MakeCurrent(); GLuint tex = GetGLTexture(); GLuint textureTarget = GetTextureTarget(); @@ -132,8 +131,8 @@ GrallocTextureSourceOGL::BindTexture(GLenum aTextureUnit, gfx::Filter aFilter) gl()->fActiveTexture(aTextureUnit); gl()->fBindTexture(textureTarget, tex); - if (mCompositableBackendData) { - // There are two paths for locking/unlocking - if mCompositableBackendData is + if (mTextureBackendSpecificData) { + // There are two paths for locking/unlocking - if mTextureBackendSpecificData is // set, we use the texture on there, otherwise we use // CompositorBackendSpecificData from the compositor and bind the EGLImage // only in Lock(). @@ -153,29 +152,38 @@ GrallocTextureSourceOGL::BindTexture(GLenum aTextureUnit, gfx::Filter aFilter) #endif } -void GrallocTextureSourceOGL::Lock() +bool GrallocTextureSourceOGL::Lock() { - if (mCompositableBackendData) return; + if (mTextureBackendSpecificData) { + return true; + } MOZ_ASSERT(IsValid()); + if (!IsValid()) { + return false; + } + if (!gl()->MakeCurrent()) { + NS_WARNING("Failed to make the gl context current"); + return false; + } mTexture = mCompositor->GetTemporaryTexture(GetTextureTarget(), LOCAL_GL_TEXTURE0); GLuint textureTarget = GetTextureTarget(); - gl()->MakeCurrent(); gl()->fActiveTexture(LOCAL_GL_TEXTURE0); gl()->fBindTexture(textureTarget, mTexture); if (!mEGLImage) { mEGLImage = EGLImageCreateFromNativeBuffer(gl(), mGraphicBuffer->getNativeBuffer()); } gl()->fEGLImageTargetTexture2D(textureTarget, mEGLImage); + return true; } bool GrallocTextureSourceOGL::IsValid() const { - return !!gl() && !!mGraphicBuffer.get() && (!!mCompositor || !!mCompositableBackendData); + return !!gl() && !!mGraphicBuffer.get() && (!!mCompositor || !!mTextureBackendSpecificData); } gl::GLContext* @@ -218,22 +226,26 @@ GrallocTextureSourceOGL::GetTextureTarget() const } void -GrallocTextureSourceOGL::SetCompositableBackendSpecificData(CompositableBackendSpecificData* aBackendData) +GrallocTextureSourceOGL::SetTextureBackendSpecificData(TextureSharedDataGonkOGL* aBackendData) { if (!aBackendData) { DeallocateDeviceData(); - // Update mCompositableBackendData after calling DeallocateDeviceData(). - mCompositableBackendData = nullptr; + // Update mTextureBackendSpecificData after calling DeallocateDeviceData(). + mTextureBackendSpecificData = nullptr; return; } - if (mCompositableBackendData != aBackendData) { + if (mTextureBackendSpecificData != aBackendData) { mNeedsReset = true; } + if (!gl() || !gl()->MakeCurrent()) { + NS_WARNING("Failed to make the context current"); + return; + } + if (!mNeedsReset) { // Update binding to the EGLImage - gl()->MakeCurrent(); GLuint tex = GetGLTexture(); GLuint textureTarget = GetTextureTarget(); gl()->fActiveTexture(LOCAL_GL_TEXTURE0); @@ -243,17 +255,16 @@ GrallocTextureSourceOGL::SetCompositableBackendSpecificData(CompositableBackendS } if (!mCompositor) { - mCompositableBackendData = aBackendData; + mTextureBackendSpecificData = aBackendData; return; } // delete old EGLImage DeallocateDeviceData(); - // Update mCompositableBackendData after calling DeallocateDeviceData(). - mCompositableBackendData = aBackendData; + // Update mTextureBackendSpecificData after calling DeallocateDeviceData(). + mTextureBackendSpecificData = aBackendData; - gl()->MakeCurrent(); GLuint tex = GetGLTexture(); GLuint textureTarget = GetTextureTarget(); @@ -285,10 +296,11 @@ GrallocTextureSourceOGL::DeallocateDeviceData() { if (mEGLImage) { MOZ_ASSERT(gl()); - gl()->MakeCurrent(); - if (mCompositableBackendData) { - CompositableDataGonkOGL* backend = static_cast(mCompositableBackendData.get()); - backend->ClearBoundEGLImage(mEGLImage); + if (!gl() || !gl()->MakeCurrent()) { + return; + } + if (mTextureBackendSpecificData) { + mTextureBackendSpecificData->ClearBoundEGLImage(mEGLImage); } EGLImageDestroy(gl(), mEGLImage); mEGLImage = EGL_NO_IMAGE; @@ -433,10 +445,9 @@ GrallocTextureHostOGL::GetAsSurface() { TemporaryRef GrallocTextureSourceOGL::GetAsSurface() { - if (!IsValid()) { + if (!IsValid() || !gl()->MakeCurrent()) { return nullptr; } - gl()->MakeCurrent(); GLuint tex = GetGLTexture(); gl()->fActiveTexture(LOCAL_GL_TEXTURE0); @@ -457,9 +468,9 @@ GrallocTextureSourceOGL::GetAsSurface() { GLuint GrallocTextureSourceOGL::GetGLTexture() { - if (mCompositableBackendData) { - mCompositableBackendData->SetCompositor(mCompositor); - return static_cast(mCompositableBackendData.get())->GetTexture(); + if (mTextureBackendSpecificData) { + mTextureBackendSpecificData->SetCompositor(mCompositor); + return mTextureBackendSpecificData->GetTexture(); } return mTexture; @@ -468,9 +479,8 @@ GrallocTextureSourceOGL::GetGLTexture() void GrallocTextureSourceOGL::BindEGLImage() { - if (mCompositableBackendData) { - CompositableDataGonkOGL* backend = static_cast(mCompositableBackendData.get()); - backend->BindEGLImage(GetTextureTarget(), mEGLImage); + if (mTextureBackendSpecificData) { + mTextureBackendSpecificData->BindEGLImage(GetTextureTarget(), mEGLImage); } else { gl()->fEGLImageTargetTexture2D(GetTextureTarget(), mEGLImage); } @@ -479,9 +489,81 @@ GrallocTextureSourceOGL::BindEGLImage() void GrallocTextureHostOGL::SetCompositableBackendSpecificData(CompositableBackendSpecificData* aBackendData) { - mCompositableBackendData = aBackendData; + if(!aBackendData) { + return; + } + + // Update mTextureBackendSpecificData if it is not set yet. + if (!mTextureBackendSpecificData) { + MOZ_ASSERT(!mCompositableBackendData); + mCompositableBackendData = aBackendData; + CompositableDataGonkOGL* backend = static_cast(mCompositableBackendData.get()); + mTextureBackendSpecificData = backend->GetTextureBackendSpecificData(); + } + + // If TextureHost sharing by multiple CompositableHosts are detected, + // enable mBackendDatas usage. + if (!mBackendDatas && + mCompositableBackendData && + mCompositableBackendData != aBackendData && + mTextureBackendSpecificData->IsAllowingSharingTextureHost()) + { + mBackendDatas = MakeUnique > >(); + (*mBackendDatas)[mCompositableBackendData->GetId()] = mCompositableBackendData; + mCompositableBackendData = nullptr; + + // Get new mTextureBackendSpecificData + mTextureBackendSpecificData = + mTextureBackendSpecificData->GetNewTextureBackendSpecificData(mTextureSource->GetEGLImage()); + mTextureBackendSpecificData->SetOwnedByTextureHost(); + } + + // Update mCompositableBackendData. + if (mBackendDatas) + { + // Handle a case that TextureHost has ownership of TextureSharedDataGonkOGL. + MOZ_ASSERT(aBackendData->IsAllowingSharingTextureHost()); + (*mBackendDatas)[aBackendData->GetId()] = aBackendData; + if (mBackendDatas->size() > 200) { + NS_WARNING("Too many CompositableBackends"); + } + } else { + // Handle a case that CompositableHost has ownership of TextureSharedDataGonkOGL. + mCompositableBackendData = aBackendData; + CompositableDataGonkOGL* backend = static_cast(mCompositableBackendData.get()); + mTextureBackendSpecificData = backend->GetTextureBackendSpecificData(); + } + if (mTextureSource) { - mTextureSource->SetCompositableBackendSpecificData(aBackendData); + mTextureSource->SetTextureBackendSpecificData(mTextureBackendSpecificData); + } + +} + +void +GrallocTextureHostOGL::UnsetCompositableBackendSpecificData(CompositableBackendSpecificData* aBackendData) +{ + if(!aBackendData || + !mTextureBackendSpecificData) { + return; + } + + if (mBackendDatas) + { + // Handle a case that TextureHost has ownership of TextureSharedDataGonkOGL. + mBackendDatas->erase(aBackendData->GetId()); + if (mBackendDatas->size() == 0) { + mCompositableBackendData = nullptr; + mTextureBackendSpecificData = nullptr; + } + } else { + // Handle a case that CompositableHost has ownership of TextureSharedDataGonkOGL. + mCompositableBackendData = nullptr; + mTextureBackendSpecificData = nullptr; + } + + if (mTextureSource) { + mTextureSource->SetTextureBackendSpecificData(mTextureBackendSpecificData); } } diff --git a/gfx/layers/opengl/GrallocTextureHost.h b/gfx/layers/opengl/GrallocTextureHost.h index a5d0a5159f19..f977c9aa25a7 100644 --- a/gfx/layers/opengl/GrallocTextureHost.h +++ b/gfx/layers/opengl/GrallocTextureHost.h @@ -46,7 +46,7 @@ public: return LOCAL_GL_CLAMP_TO_EDGE; } - virtual void SetCompositableBackendSpecificData(CompositableBackendSpecificData* aBackendData) MOZ_OVERRIDE; + virtual void SetTextureBackendSpecificData(TextureSharedDataGonkOGL* aBackendData); void DeallocateDeviceData(); @@ -66,9 +66,15 @@ public: void BindEGLImage(); - void Lock(); + EGLImage GetEGLImage() + { + return mEGLImage; + } + + bool Lock(); protected: + RefPtr mTextureBackendSpecificData; CompositorOGL* mCompositor; GrallocTextureHostOGL* mTextureHost; android::sp mGraphicBuffer; @@ -126,6 +132,8 @@ public: virtual void SetCompositableBackendSpecificData(CompositableBackendSpecificData* aBackendData) MOZ_OVERRIDE; + virtual void UnsetCompositableBackendSpecificData(CompositableBackendSpecificData* aBackendData) MOZ_OVERRIDE; + bool IsValid() const; virtual const char* Name() MOZ_OVERRIDE { return "GrallocTextureHostOGL"; } @@ -134,6 +142,9 @@ private: NewSurfaceDescriptorGralloc mGrallocHandle; RefPtr mTextureSource; gfx::IntSize mSize; // See comment in textureClientOGL.h + + RefPtr mTextureBackendSpecificData; + UniquePtr > > mBackendDatas; }; } // namespace layers diff --git a/gfx/layers/opengl/TextureHostOGL.cpp b/gfx/layers/opengl/TextureHostOGL.cpp index ad2c022bd123..fc69ab8dcde9 100644 --- a/gfx/layers/opengl/TextureHostOGL.cpp +++ b/gfx/layers/opengl/TextureHostOGL.cpp @@ -121,47 +121,134 @@ FlagsToGLFlags(TextureFlags aFlags) } CompositableDataGonkOGL::CompositableDataGonkOGL() - : mTexture(0) +{ +} + +CompositableDataGonkOGL::~CompositableDataGonkOGL() +{ + ClearData(); +} + +void +CompositableDataGonkOGL::ClearData() +{ + CompositableBackendSpecificData::ClearData(); + mTextureBackendSpecificData = nullptr; + mCompositor = nullptr; +} + +void +CompositableDataGonkOGL::SetCompositor(Compositor* aCompositor) +{ + mCompositor = static_cast(aCompositor); + if (mTextureBackendSpecificData) { + mTextureBackendSpecificData->SetCompositor(aCompositor); + } +} + +TextureSharedDataGonkOGL* +CompositableDataGonkOGL::GetTextureBackendSpecificData() +{ + if (!mTextureBackendSpecificData) { + mTextureBackendSpecificData = new TextureSharedDataGonkOGL(); + mTextureBackendSpecificData->SetCompositor(mCompositor); + mTextureBackendSpecificData->SetAllowSharingTextureHost(IsAllowingSharingTextureHost()); + } + return mTextureBackendSpecificData; +} + +TextureSharedDataGonkOGL::TextureSharedDataGonkOGL() + : mOwnedByCompositableHost(true) + , mAllowSharingTextureHost(false) + , mTexture(0) , mBoundEGLImage(EGL_NO_IMAGE) { } -CompositableDataGonkOGL::~CompositableDataGonkOGL() + +TextureSharedDataGonkOGL::TextureSharedDataGonkOGL(GLuint aTexture, EGLImage aImage, CompositorOGL* aCompositor) + : mOwnedByCompositableHost(true) + , mAllowSharingTextureHost(false) + , mCompositor(aCompositor) + , mTexture(aTexture) + , mBoundEGLImage(aImage) +{ +} + +TextureSharedDataGonkOGL::~TextureSharedDataGonkOGL() { DeleteTextureIfPresent(); } gl::GLContext* -CompositableDataGonkOGL::gl() const +TextureSharedDataGonkOGL::gl() const { return mCompositor ? mCompositor->gl() : nullptr; } -void CompositableDataGonkOGL::SetCompositor(Compositor* aCompositor) +void +TextureSharedDataGonkOGL::SetCompositor(Compositor* aCompositor) { + if (gl() && mCompositor != aCompositor) { + DeleteTextureIfPresent(); + } mCompositor = static_cast(aCompositor); } -void CompositableDataGonkOGL::ClearData() +void +TextureSharedDataGonkOGL::ClearData() { - CompositableBackendSpecificData::ClearData(); DeleteTextureIfPresent(); } -GLuint CompositableDataGonkOGL::GetTexture() +TemporaryRef +TextureSharedDataGonkOGL::GetNewTextureBackendSpecificData(EGLImage aImage) +{ + MOZ_ASSERT(IsAllowingSharingTextureHost()); + + if (IsEGLImageBound(aImage)) + { + // If EGLImage is already bound to OpenGL Texture, + // handover the OpenGL Texture to caller + GLuint textureId = GetAndResetGLTextureOwnership(); + RefPtr data = new TextureSharedDataGonkOGL(textureId, aImage, mCompositor); + data->SetCompositor(mCompositor); + data->SetAllowSharingTextureHost(true); + return data; + } + + // Create brand new TextureSharedDataGonkOGL + RefPtr data = new TextureSharedDataGonkOGL(); + data->SetCompositor(mCompositor); + data->SetAllowSharingTextureHost(true); + return data; +} + +GLuint +TextureSharedDataGonkOGL::GetTexture() { if (!mTexture) { - if (gl()->MakeCurrent()) { + if (gl() && gl()->MakeCurrent()) { gl()->fGenTextures(1, &mTexture); } } return mTexture; } +GLuint +TextureSharedDataGonkOGL::GetAndResetGLTextureOwnership() +{ + GLuint texture = mTexture; + mTexture = 0; + mBoundEGLImage = EGL_NO_IMAGE; + return texture; +} + void -CompositableDataGonkOGL::DeleteTextureIfPresent() +TextureSharedDataGonkOGL::DeleteTextureIfPresent() { if (mTexture) { - if (gl()->MakeCurrent()) { + MOZ_ASSERT(gl()); + if (gl() && gl()->MakeCurrent()) { gl()->fDeleteTextures(1, &mTexture); } mTexture = 0; @@ -170,16 +257,19 @@ CompositableDataGonkOGL::DeleteTextureIfPresent() } void -CompositableDataGonkOGL::BindEGLImage(GLuint aTarget, EGLImage aImage) +TextureSharedDataGonkOGL::BindEGLImage(GLuint aTarget, EGLImage aImage) { if (mBoundEGLImage != aImage) { - gl()->fEGLImageTargetTexture2D(aTarget, aImage); + MOZ_ASSERT(gl()); + if (gl()) { + gl()->fEGLImageTargetTexture2D(aTarget, aImage); + } mBoundEGLImage = aImage; } } void -CompositableDataGonkOGL::ClearBoundEGLImage(EGLImage aImage) +TextureSharedDataGonkOGL::ClearBoundEGLImage(EGLImage aImage) { if (mBoundEGLImage == aImage) { DeleteTextureIfPresent(); @@ -187,6 +277,17 @@ CompositableDataGonkOGL::ClearBoundEGLImage(EGLImage aImage) } } +bool +TextureSharedDataGonkOGL::IsEGLImageBound(EGLImage aImage) +{ + if (mTexture != 0 && + aImage != EGL_NO_IMAGE && + aImage == mBoundEGLImage) { + return true; + } + return false; +} + #if defined(MOZ_WIDGET_GONK) && ANDROID_VERSION >= 17 bool TextureHostOGL::SetReleaseFence(const android::sp& aReleaseFence) diff --git a/gfx/layers/opengl/TextureHostOGL.h b/gfx/layers/opengl/TextureHostOGL.h index e560eb9b657b..3d345e89ce7c 100644 --- a/gfx/layers/opengl/TextureHostOGL.h +++ b/gfx/layers/opengl/TextureHostOGL.h @@ -57,6 +57,7 @@ namespace layers { class Compositor; class CompositorOGL; class TextureImageTextureSourceOGL; +class TextureSharedDataGonkOGL; /** * CompositableBackendSpecificData implementation for the Gonk OpenGL backend. @@ -69,18 +70,83 @@ class TextureImageTextureSourceOGL; */ class CompositableDataGonkOGL : public CompositableBackendSpecificData { -public: - CompositableDataGonkOGL(); +protected: virtual ~CompositableDataGonkOGL(); - virtual void SetCompositor(Compositor* aCompositor) MOZ_OVERRIDE; +public: + CompositableDataGonkOGL(); virtual void ClearData() MOZ_OVERRIDE; + virtual void SetCompositor(Compositor* aCompositor) MOZ_OVERRIDE; + + TextureSharedDataGonkOGL* GetTextureBackendSpecificData(); +protected: + nsRefPtr mTextureBackendSpecificData; + RefPtr mCompositor; +}; + +/** + * Manage actual shared resources of CompositableDataGonkOGL. + * The resources are split from CompositableDataGonkOGL to handle two use cases. + * Normally TextureHost is used from one CompositableHost at the same time. + * In this case, performance is good if the resources are owned by CompositableDataGonkOGL. + * But TextureHost could be shared among multiple ImageHosts. + * If it happens, performance is good if the resource is owned by TextureHost. + * The resources ownership is carryed over from CompositableDataGonkOGL to TextureHost. + * See Bug 1017351. + */ +class TextureSharedDataGonkOGL +{ +protected: + virtual ~TextureSharedDataGonkOGL(); + +public: + NS_INLINE_DECL_REFCOUNTING(TextureSharedDataGonkOGL) + + TextureSharedDataGonkOGL(); + TextureSharedDataGonkOGL(GLuint aTexture, EGLImage aImage, CompositorOGL* aCompositor); + + void SetCompositor(Compositor* aCompositor); + void ClearData(); + + // Mark TextureSharedDataGonkOGL as owned by TextureHost. + void SetOwnedByTextureHost() + { + mOwnedByCompositableHost = false; + } + + // Check if this is owned by CompositableHost or TextureHost. + bool IsOwnedByCompositableHost() + { + return mOwnedByCompositableHost; + } + + bool IsAllowingSharingTextureHost() + { + return mAllowSharingTextureHost; + } + + void SetAllowSharingTextureHost(bool aAllow) + { + mAllowSharingTextureHost = aAllow; + } + + // Create new TextureSharedDataGonkOGL. + // If aImage is already bound to OpenGL texture, the OpenGL textre is carried over + // to a new object. It could reduce calling fEGLImageTargetTexture2D() + // during resources ownership carry over from CompositableHost to TextureHost. + TemporaryRef GetNewTextureBackendSpecificData(EGLImage aImage); + GLuint GetTexture(); void DeleteTextureIfPresent(); gl::GLContext* gl() const; void BindEGLImage(GLuint aTarget, EGLImage aImage); void ClearBoundEGLImage(EGLImage aImage); + bool IsEGLImageBound(EGLImage aImage); protected: + GLuint GetAndResetGLTextureOwnership(); + + bool mOwnedByCompositableHost; + bool mAllowSharingTextureHost; RefPtr mCompositor; GLuint mTexture; EGLImage mBoundEGLImage; diff --git a/gfx/layers/protobuf/LayerScopePacket.pb.cc b/gfx/layers/protobuf/LayerScopePacket.pb.cc index be087a81bfaf..f80da69c550f 100644 --- a/gfx/layers/protobuf/LayerScopePacket.pb.cc +++ b/gfx/layers/protobuf/LayerScopePacket.pb.cc @@ -963,7 +963,7 @@ bool LayersPacket_Layer_LayerType_IsValid(int value) { const LayersPacket_Layer_LayerType LayersPacket_Layer::UnknownLayer; const LayersPacket_Layer_LayerType LayersPacket_Layer::LayerManager; const LayersPacket_Layer_LayerType LayersPacket_Layer::ContainerLayer; -const LayersPacket_Layer_LayerType LayersPacket_Layer::ThebesLayer; +const LayersPacket_Layer_LayerType LayersPacket_Layer::PaintedLayer; const LayersPacket_Layer_LayerType LayersPacket_Layer::CanvasLayer; const LayersPacket_Layer_LayerType LayersPacket_Layer::ImageLayer; const LayersPacket_Layer_LayerType LayersPacket_Layer::ColorLayer; diff --git a/gfx/layers/protobuf/LayerScopePacket.pb.h b/gfx/layers/protobuf/LayerScopePacket.pb.h index 40b614950a14..591cdcc4154e 100644 --- a/gfx/layers/protobuf/LayerScopePacket.pb.h +++ b/gfx/layers/protobuf/LayerScopePacket.pb.h @@ -49,7 +49,7 @@ enum LayersPacket_Layer_LayerType { LayersPacket_Layer_LayerType_UnknownLayer = 0, LayersPacket_Layer_LayerType_LayerManager = 1, LayersPacket_Layer_LayerType_ContainerLayer = 2, - LayersPacket_Layer_LayerType_ThebesLayer = 3, + LayersPacket_Layer_LayerType_PaintedLayer = 3, LayersPacket_Layer_LayerType_CanvasLayer = 4, LayersPacket_Layer_LayerType_ImageLayer = 5, LayersPacket_Layer_LayerType_ColorLayer = 6, @@ -904,7 +904,7 @@ class LayersPacket_Layer : public ::google::protobuf::MessageLite { static const LayerType UnknownLayer = LayersPacket_Layer_LayerType_UnknownLayer; static const LayerType LayerManager = LayersPacket_Layer_LayerType_LayerManager; static const LayerType ContainerLayer = LayersPacket_Layer_LayerType_ContainerLayer; - static const LayerType ThebesLayer = LayersPacket_Layer_LayerType_ThebesLayer; + static const LayerType PaintedLayer = LayersPacket_Layer_LayerType_PaintedLayer; static const LayerType CanvasLayer = LayersPacket_Layer_LayerType_CanvasLayer; static const LayerType ImageLayer = LayersPacket_Layer_LayerType_ImageLayer; static const LayerType ColorLayer = LayersPacket_Layer_LayerType_ColorLayer; diff --git a/gfx/layers/protobuf/LayerScopePacket.proto b/gfx/layers/protobuf/LayerScopePacket.proto index 44ce8fa5bdeb..37ff57ca42c2 100644 --- a/gfx/layers/protobuf/LayerScopePacket.proto +++ b/gfx/layers/protobuf/LayerScopePacket.proto @@ -31,7 +31,7 @@ message LayersPacket { UnknownLayer = 0; LayerManager = 1; ContainerLayer = 2; - ThebesLayer = 3; + PaintedLayer = 3; CanvasLayer = 4; ImageLayer = 5; ColorLayer = 6; @@ -94,7 +94,7 @@ message LayersPacket { optional uint64 mask = 19; // mask layer // Specific info (100 to max) - // Thebes Layer + // Painted Layer optional Region valid = 100; // Color Layer optional uint32 color = 101; diff --git a/gfx/tests/gtest/TestAsyncPanZoomController.cpp b/gfx/tests/gtest/TestAsyncPanZoomController.cpp index b340ec0ae3ee..7cf64d3802dc 100644 --- a/gfx/tests/gtest/TestAsyncPanZoomController.cpp +++ b/gfx/tests/gtest/TestAsyncPanZoomController.cpp @@ -1812,7 +1812,7 @@ TEST_F(APZHitTestingTester, HitTesting2) { EXPECT_EQ(Point(25, 75), transformToGecko * Point(25, 25)); } -TEST_F(APZCTreeManagerTester, ScrollableThebesLayers) { +TEST_F(APZCTreeManagerTester, ScrollablePaintedLayers) { CreateSimpleMultiLayerTree(); ScopedLayerTreeRegistration registration(0, root, mcc); diff --git a/gfx/tests/gtest/TestLayers.cpp b/gfx/tests/gtest/TestLayers.cpp index 1eaaf3b876cf..7cb13e697d8c 100644 --- a/gfx/tests/gtest/TestLayers.cpp +++ b/gfx/tests/gtest/TestLayers.cpp @@ -28,11 +28,11 @@ public: virtual already_AddRefed CreateColorLayer() { return nullptr; } virtual void BeginTransactionWithTarget(gfxContext* aTarget) {} virtual already_AddRefed CreateCanvasLayer() { return nullptr; } - virtual void EndTransaction(DrawThebesLayerCallback aCallback, + virtual void EndTransaction(DrawPaintedLayerCallback aCallback, void* aCallbackData, EndTransactionFlags aFlags = END_DEFAULT) {} virtual int32_t GetMaxTextureSize() const { return 0; } - virtual already_AddRefed CreateThebesLayer() { return nullptr; } + virtual already_AddRefed CreatePaintedLayer() { return nullptr; } }; class TestContainerLayer: public ContainerLayer { @@ -54,18 +54,18 @@ public: } }; -class TestThebesLayer: public ThebesLayer { +class TestPaintedLayer: public PaintedLayer { public: - explicit TestThebesLayer(LayerManager* aManager) - : ThebesLayer(aManager, nullptr) + explicit TestPaintedLayer(LayerManager* aManager) + : PaintedLayer(aManager, nullptr) {} virtual const char* Name() const { - return "TestThebesLayer"; + return "TestPaintedLayer"; } virtual LayerType GetType() const { - return TYPE_THEBES; + return TYPE_PAINTED; } virtual void InvalidateRegion(const nsIntRegion& aRegion) { @@ -107,7 +107,7 @@ TEST(Layers, Transform) { TEST(Layers, Type) { TestContainerLayer layer(nullptr); - ASSERT_EQ(nullptr, layer.AsThebesLayer()); + ASSERT_EQ(nullptr, layer.AsPaintedLayer()); ASSERT_EQ(nullptr, layer.AsRefLayer()); ASSERT_EQ(nullptr, layer.AsColorLayer()); } @@ -155,7 +155,7 @@ already_AddRefed CreateLayer(char aLayerType, LayerManager* aManager) { if (aLayerType == 'c') { layer = new TestContainerLayer(aManager); } else if (aLayerType == 't') { - layer = new TestThebesLayer(aManager); + layer = new TestPaintedLayer(aManager); } return layer.forget(); } @@ -242,8 +242,8 @@ TEST(Layers, LayerTree) { Layer* nullLayer = nullptr; ASSERT_NE(nullLayer, layers[0]->AsContainerLayer()); ASSERT_NE(nullLayer, layers[1]->AsContainerLayer()); - ASSERT_NE(nullLayer, layers[2]->AsThebesLayer()); - ASSERT_NE(nullLayer, layers[3]->AsThebesLayer()); + ASSERT_NE(nullLayer, layers[2]->AsPaintedLayer()); + ASSERT_NE(nullLayer, layers[3]->AsPaintedLayer()); } static void ValidateTreePointers(Layer* aLayer) { diff --git a/gfx/thebes/gfxCoreTextShaper.cpp b/gfx/thebes/gfxCoreTextShaper.cpp index 3abbb6330a75..93fe5a477976 100644 --- a/gfx/thebes/gfxCoreTextShaper.cpp +++ b/gfx/thebes/gfxCoreTextShaper.cpp @@ -125,7 +125,6 @@ gfxCoreTextShaper::ShapeText(gfxContext *aContext, CFAttributedStringRef attrStringObj = ::CFAttributedStringCreate(kCFAllocatorDefault, stringObj, attrObj); ::CFRelease(stringObj); - ::CFRelease(attrObj); // Create the CoreText line from our string, then we're done with it CTLineRef line = ::CTLineCreateWithAttributedString(attrStringObj); @@ -142,12 +141,34 @@ gfxCoreTextShaper::ShapeText(gfxContext *aContext, for (uint32_t runIndex = 0; runIndex < numRuns; runIndex++) { CTRunRef aCTRun = (CTRunRef)::CFArrayGetValueAtIndex(glyphRuns, runIndex); + CFDictionaryRef runAttr = ::CTRunGetAttributes(aCTRun); + if (runAttr != attrObj) { + // If Core Text manufactured a new dictionary, this may indicate + // unexpected font substitution. In that case, we fail (and fall + // back to harfbuzz shaping)... + const void* font1 = ::CFDictionaryGetValue(attrObj, kCTFontAttributeName); + const void* font2 = ::CFDictionaryGetValue(runAttr, kCTFontAttributeName); + if (font1 != font2) { + // ...except that if the fallback was only for a variation + // selector that is otherwise unsupported, we just ignore it. + CFRange range = ::CTRunGetStringRange(aCTRun); + if (range.length == 1 && + gfxFontUtils::IsVarSelector(aText[range.location - + startOffset])) { + continue; + } + NS_WARNING("unexpected font fallback in Core Text"); + success = false; + break; + } + } if (SetGlyphsFromRun(aShapedText, aOffset, aLength, aCTRun, startOffset) != NS_OK) { success = false; break; } } + ::CFRelease(attrObj); ::CFRelease(line); return success; diff --git a/gfx/thebes/gfxPlatformGtk.cpp b/gfx/thebes/gfxPlatformGtk.cpp index f1c9182bea2b..7e93674684c9 100644 --- a/gfx/thebes/gfxPlatformGtk.cpp +++ b/gfx/thebes/gfxPlatformGtk.cpp @@ -93,7 +93,7 @@ gfxPlatformGtk::CreateOffscreenSurface(const IntSize& size, // we should try to match GdkScreen *gdkScreen = gdk_screen_get_default(); if (gdkScreen) { - // When forcing Thebes Layers to use image surfaces for content, + // When forcing PaintedLayers to use image surfaces for content, // force creation of gfxImageSurface surfaces. if (UseXRender() && !UseImageOffscreenSurfaces()) { Screen *screen = gdk_x11_screen_get_xscreen(gdkScreen); diff --git a/hal/Hal.cpp b/hal/Hal.cpp index 83ca7701cb53..f09d5f622de7 100644 --- a/hal/Hal.cpp +++ b/hal/Hal.cpp @@ -6,6 +6,7 @@ #include "Hal.h" #include "HalImpl.h" +#include "HalLog.h" #include "HalSandbox.h" #include "nsThreadUtils.h" #include "nsXULAppAPI.h" @@ -129,7 +130,7 @@ Vibrate(const nsTArray& pattern, const WindowIdentifier &id) // only the window corresponding to the bottommost process has its // visibility state set correctly. if (!id.HasTraveledThroughIPC() && !WindowIsActive(id.GetWindow())) { - HAL_LOG(("Vibrate: Window is inactive, dropping vibrate.")); + HAL_LOG("Vibrate: Window is inactive, dropping vibrate."); return; } diff --git a/hal/Hal.h b/hal/Hal.h index 26eaff07ba98..b2aeec320198 100644 --- a/hal/Hal.h +++ b/hal/Hal.h @@ -13,7 +13,6 @@ #include "mozilla/Observer.h" #include "mozilla/Types.h" #include "nsTArray.h" -#include "prlog.h" #include "mozilla/dom/MozPowerManagerBinding.h" #include "mozilla/dom/battery/Types.h" #include "mozilla/dom/network/Types.h" @@ -47,10 +46,6 @@ typedef Observer AlarmObserver; class WindowIdentifier; -extern PRLogModuleInfo *GetHalLog(); -#define HAL_LOG(msg) PR_LOG(mozilla::hal::GetHalLog(), PR_LOG_DEBUG, msg) -#define HAL_ERR(msg) PR_LOG(mozilla::hal::GetHalLog(), PR_LOG_ERROR, msg) - typedef Observer SystemClockChangeObserver; typedef Observer SystemTimezoneChangeObserver; diff --git a/hal/HalLog.h b/hal/HalLog.h new file mode 100644 index 000000000000..9910d296bf7d --- /dev/null +++ b/hal/HalLog.h @@ -0,0 +1,33 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set sw=2 ts=8 et 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/. */ + +#ifndef mozilla_HalLog_h +#define mozilla_HalLog_h + +#include "prlog.h" + +/* + * HalLog.h contains internal macros and functions used for logging. + * + * This should be considered a private include and not used in non-HAL code. + * To enable logging in non-debug builds define the PR_FORCE_LOG macro here. + */ + +namespace mozilla { + +namespace hal { + +extern PRLogModuleInfo *GetHalLog(); +#define HAL_LOG(...) \ + PR_LOG(mozilla::hal::GetHalLog(), PR_LOG_DEBUG, (__VA_ARGS__)) +#define HAL_ERR(...) \ + PR_LOG(mozilla::hal::GetHalLog(), PR_LOG_ERROR, (__VA_ARGS__)) + +} // namespace hal + +} // namespace mozilla + +#endif // mozilla_HalLog_h diff --git a/hal/HalWakeLock.cpp b/hal/HalWakeLock.cpp index 0c1eee47a89e..df2020187003 100644 --- a/hal/HalWakeLock.cpp +++ b/hal/HalWakeLock.cpp @@ -3,7 +3,7 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this file, * You can obtain one at http://mozilla.org/MPL/2.0/. */ -#include "mozilla/Hal.h" +#include "Hal.h" #include "mozilla/HalWakeLock.h" #include "mozilla/Services.h" #include "mozilla/StaticPtr.h" diff --git a/hal/fallback/FallbackAlarm.cpp b/hal/fallback/FallbackAlarm.cpp index f7e08d0c37e1..aac6198f10c5 100644 --- a/hal/fallback/FallbackAlarm.cpp +++ b/hal/fallback/FallbackAlarm.cpp @@ -54,8 +54,7 @@ bool SetAlarm(int32_t aSeconds, int32_t aNanoseconds) { if (!sTimer) { - HAL_LOG(("We should have enabled the alarm")); - MOZ_ASSERT(false); + MOZ_ASSERT(false, "We should have enabled the alarm"); return false; } diff --git a/hal/fallback/FallbackProcessPriority.cpp b/hal/fallback/FallbackProcessPriority.cpp index 942243c24183..db8eecc071ee 100644 --- a/hal/fallback/FallbackProcessPriority.cpp +++ b/hal/fallback/FallbackProcessPriority.cpp @@ -3,6 +3,7 @@ * You can obtain one at http://mozilla.org/MPL/2.0/. */ #include "Hal.h" +#include "HalLog.h" using namespace mozilla::hal; @@ -15,9 +16,9 @@ SetProcessPriority(int aPid, ProcessCPUPriority aCPUPriority, uint32_t aBackgroundLRU) { - HAL_LOG(("FallbackProcessPriority - SetProcessPriority(%d, %s, %u)\n", - aPid, ProcessPriorityToString(aPriority, aCPUPriority), - aBackgroundLRU)); + HAL_LOG("FallbackProcessPriority - SetProcessPriority(%d, %s, %u)\n", + aPid, ProcessPriorityToString(aPriority, aCPUPriority), + aBackgroundLRU); } } // hal_impl diff --git a/hal/fallback/FallbackThreadPriority.cpp b/hal/fallback/FallbackThreadPriority.cpp index afab11a1889d..bd67b592d7a8 100644 --- a/hal/fallback/FallbackThreadPriority.cpp +++ b/hal/fallback/FallbackThreadPriority.cpp @@ -3,6 +3,7 @@ * You can obtain one at http://mozilla.org/MPL/2.0/. */ #include "Hal.h" +#include "HalLog.h" using namespace mozilla::hal; @@ -12,8 +13,8 @@ namespace hal_impl { void SetCurrentThreadPriority(ThreadPriority aPriority) { - HAL_LOG(("FallbackThreadPriority - SetCurrentThreadPriority(%d)\n", - ThreadPriorityToString(aPriority))); + HAL_LOG("FallbackThreadPriority - SetCurrentThreadPriority(%d)\n", + ThreadPriorityToString(aPriority)); } } // hal_impl diff --git a/hal/gonk/GonkDiskSpaceWatcher.cpp b/hal/gonk/GonkDiskSpaceWatcher.cpp index 0b88e8abb459..3d6788aa39c1 100644 --- a/hal/gonk/GonkDiskSpaceWatcher.cpp +++ b/hal/gonk/GonkDiskSpaceWatcher.cpp @@ -168,7 +168,7 @@ GonkDiskSpaceWatcher::DoStart() if (mFd == -1) { NS_WARNING("Error calling inotify_init()"); if (errno == ENOSYS) { - printf_stderr("Warning: No fanotify support in this device's kernel.\n"); + NS_WARNING("Warning: No fanotify support in this device's kernel.\n"); } return; } @@ -241,8 +241,7 @@ GonkDiskSpaceWatcher::OnFileCanReadWithoutBlocking(int aFd) // We should get an exact multiple of fanotify_event_metadata if (len <= 0 || (len % FAN_EVENT_METADATA_LEN != 0)) { - printf_stderr("About to crash: fanotify_event_metadata read error."); - MOZ_CRASH(); + MOZ_CRASH("About to crash: fanotify_event_metadata read error."); } fem = reinterpret_cast(buf); diff --git a/hal/gonk/GonkFMRadio.cpp b/hal/gonk/GonkFMRadio.cpp index 17108b0707f3..5f0406836769 100644 --- a/hal/gonk/GonkFMRadio.cpp +++ b/hal/gonk/GonkFMRadio.cpp @@ -14,6 +14,7 @@ */ #include "Hal.h" +#include "HalLog.h" #include "tavarua.h" #include "nsThreadUtils.h" #include "mozilla/FileUtils.h" @@ -113,20 +114,20 @@ initMsmFMRadio(hal::FMRadioSettings &aInfo) rc = setControl(V4L2_CID_PRIVATE_TAVARUA_STATE, FM_RECV); if (rc < 0) { - HAL_LOG(("Unable to turn on radio |%s|", strerror(errno))); + HAL_LOG("Unable to turn on radio |%s|", strerror(errno)); return; } int preEmphasis = aInfo.preEmphasis() <= 50; rc = setControl(V4L2_CID_PRIVATE_TAVARUA_EMPHASIS, preEmphasis); if (rc) { - HAL_LOG(("Unable to configure preemphasis")); + HAL_LOG("Unable to configure preemphasis"); return; } rc = setControl(V4L2_CID_PRIVATE_TAVARUA_RDS_STD, 0); if (rc) { - HAL_LOG(("Unable to configure RDS")); + HAL_LOG("Unable to configure RDS"); return; } @@ -142,13 +143,13 @@ initMsmFMRadio(hal::FMRadioSettings &aInfo) spacing = FM_CH_SPACE_200KHZ; break; default: - HAL_LOG(("Unsupported space value - %d", aInfo.spaceType())); + HAL_LOG("Unsupported space value - %d", aInfo.spaceType()); return; } rc = setControl(V4L2_CID_PRIVATE_TAVARUA_SPACING, spacing); if (rc) { - HAL_LOG(("Unable to configure spacing")); + HAL_LOG("Unable to configure spacing"); return; } @@ -166,13 +167,13 @@ initMsmFMRadio(hal::FMRadioSettings &aInfo) tuner.audmode = V4L2_TUNER_MODE_STEREO; rc = ioctl(fd, VIDIOC_S_TUNER, &tuner); if (rc < 0) { - HAL_LOG(("Unable to adjust band limits")); + HAL_LOG("Unable to adjust band limits"); return; } rc = setControl(V4L2_CID_PRIVATE_TAVARUA_REGION, TAVARUA_REGION_OTHER); if (rc < 0) { - HAL_LOG(("Unable to configure region")); + HAL_LOG("Unable to configure region"); return; } @@ -185,7 +186,7 @@ initMsmFMRadio(hal::FMRadioSettings &aInfo) rc = setControl(V4L2_CID_PRIVATE_TAVARUA_SET_AUDIO_PATH, noAnalog ? FM_DIGITAL_PATH : FM_ANALOG_PATH); if (rc < 0) { - HAL_LOG(("Unable to set audio path")); + HAL_LOG("Unable to set audio path"); return; } @@ -272,7 +273,7 @@ void EnableFMRadio(const hal::FMRadioSettings& aInfo) { if (sRadioEnabled) { - HAL_LOG(("Radio already enabled!")); + HAL_LOG("Radio already enabled!"); return; } @@ -282,7 +283,7 @@ EnableFMRadio(const hal::FMRadioSettings& aInfo) mozilla::ScopedClose fd(open("/dev/radio0", O_RDWR)); if (fd < 0) { - HAL_LOG(("Unable to open radio device")); + HAL_LOG("Unable to open radio device"); hal::NotifyFMRadioStatus(info); return; } @@ -290,23 +291,23 @@ EnableFMRadio(const hal::FMRadioSettings& aInfo) struct v4l2_capability cap; int rc = ioctl(fd, VIDIOC_QUERYCAP, &cap); if (rc < 0) { - HAL_LOG(("Unable to query radio device")); + HAL_LOG("Unable to query radio device"); hal::NotifyFMRadioStatus(info); return; } sMsmFMMode = !strcmp((char *)cap.driver, "radio-tavarua") || !strcmp((char *)cap.driver, "radio-iris"); - HAL_LOG(("Radio: %s (%s)\n", cap.driver, cap.card)); + HAL_LOG("Radio: %s (%s)\n", cap.driver, cap.card); if (!(cap.capabilities & V4L2_CAP_RADIO)) { - HAL_LOG(("/dev/radio0 isn't a radio")); + HAL_LOG("/dev/radio0 isn't a radio"); hal::NotifyFMRadioStatus(info); return; } if (!(cap.capabilities & V4L2_CAP_TUNER)) { - HAL_LOG(("/dev/radio0 doesn't support the tuner interface")); + HAL_LOG("/dev/radio0 doesn't support the tuner interface"); hal::NotifyFMRadioStatus(info); return; } @@ -316,7 +317,7 @@ EnableFMRadio(const hal::FMRadioSettings& aInfo) sRadioFD = fd.forget(); sMsmFMVersion = cap.version; if (pthread_create(&sRadioThread, nullptr, runMsmFMRadio, nullptr)) { - HAL_LOG(("Couldn't create radio thread")); + HAL_LOG("Couldn't create radio thread"); hal::NotifyFMRadioStatus(info); } return; @@ -329,7 +330,7 @@ EnableFMRadio(const hal::FMRadioSettings& aInfo) tuner.audmode = V4L2_TUNER_MODE_STEREO; rc = ioctl(fd, VIDIOC_S_TUNER, &tuner); if (rc < 0) { - HAL_LOG(("Unable to adjust band limits")); + HAL_LOG("Unable to adjust band limits"); } int emphasis; @@ -349,7 +350,7 @@ EnableFMRadio(const hal::FMRadioSettings& aInfo) } rc = setControl(V4L2_CID_TUNE_DEEMPHASIS, emphasis); if (rc < 0) { - HAL_LOG(("Unable to configure deemphasis")); + HAL_LOG("Unable to configure deemphasis"); } sRadioFD = fd.forget(); @@ -370,7 +371,7 @@ DisableFMRadio() if (sMsmFMMode) { int rc = setControl(V4L2_CID_PRIVATE_TAVARUA_STATE, FM_OFF); if (rc < 0) { - HAL_LOG(("Unable to turn off radio")); + HAL_LOG("Unable to turn off radio"); } pthread_join(sRadioThread, nullptr); @@ -408,7 +409,7 @@ FMRadioSeek(const hal::FMRadioSeekDirection& aDirection) hal::FM_RADIO_OPERATION_STATUS_SUCCESS)); if (rc < 0) { - HAL_LOG(("Could not initiate hardware seek")); + HAL_LOG("Could not initiate hardware seek"); return; } @@ -426,7 +427,7 @@ GetFMRadioSettings(hal::FMRadioSettings* aInfo) struct v4l2_tuner tuner = {0}; int rc = ioctl(sRadioFD, VIDIOC_G_TUNER, &tuner); if (rc < 0) { - HAL_LOG(("Could not query fm radio for settings")); + HAL_LOG("Could not query fm radio for settings"); return; } @@ -443,7 +444,7 @@ SetFMRadioFrequency(const uint32_t frequency) int rc = ioctl(sRadioFD, VIDIOC_S_FREQUENCY, &freq); if (rc < 0) - HAL_LOG(("Could not set radio frequency")); + HAL_LOG("Could not set radio frequency"); if (sMsmFMMode && rc >= 0) return; @@ -463,7 +464,7 @@ GetFMRadioFrequency() struct v4l2_frequency freq; int rc = ioctl(sRadioFD, VIDIOC_G_FREQUENCY, &freq); if (rc < 0) { - HAL_LOG(("Could not get radio frequency")); + HAL_LOG("Could not get radio frequency"); return 0; } @@ -482,7 +483,7 @@ GetFMRadioSignalStrength() struct v4l2_tuner tuner = {0}; int rc = ioctl(sRadioFD, VIDIOC_G_TUNER, &tuner); if (rc < 0) { - HAL_LOG(("Could not query fm radio for signal strength")); + HAL_LOG("Could not query fm radio for signal strength"); return 0; } diff --git a/hal/gonk/GonkHal.cpp b/hal/gonk/GonkHal.cpp index 6aeb5e431412..3a2637b28943 100644 --- a/hal/gonk/GonkHal.cpp +++ b/hal/gonk/GonkHal.cpp @@ -45,6 +45,7 @@ #include "Hal.h" #include "HalImpl.h" +#include "HalLog.h" #include "mozilla/ArrayUtils.h" #include "mozilla/dom/battery/Constants.h" #include "mozilla/FileUtils.h" @@ -518,7 +519,7 @@ GetCurrentBatteryCharge(int* aCharge) #ifdef DEBUG if ((*aCharge < 0) || (*aCharge > 100)) { - HAL_LOG(("charge level contains unknown value: %d", *aCharge)); + HAL_LOG("charge level contains unknown value: %d", *aCharge); } #endif @@ -543,7 +544,7 @@ GetCurrentBatteryCharging(int* aCharging) if (chargingSrc != BATTERY_NOT_CHARGING && chargingSrc != BATTERY_CHARGING_USB && chargingSrc != BATTERY_CHARGING_AC) { - HAL_LOG(("charging_source contained unknown value: %d", chargingSrc)); + HAL_LOG("charging_source contained unknown value: %d", chargingSrc); } #endif @@ -607,13 +608,13 @@ bool ReadFromFile(const char *filename, char (&buf)[n]) int fd = open(filename, O_RDONLY); ScopedClose autoClose(fd); if (fd < 0) { - HAL_LOG(("Unable to open file %s.", filename)); + HAL_LOG("Unable to open file %s.", filename); return false; } ssize_t numRead = read(fd, buf, n); if (numRead < 0) { - HAL_LOG(("Error reading from file %s.", filename)); + HAL_LOG("Error reading from file %s.", filename); return false; } @@ -626,12 +627,12 @@ bool WriteToFile(const char *filename, const char *toWrite) int fd = open(filename, O_WRONLY); ScopedClose autoClose(fd); if (fd < 0) { - HAL_LOG(("Unable to open file %s.", filename)); + HAL_LOG("Unable to open file %s.", filename); return false; } if (write(fd, toWrite, strlen(toWrite)) < 0) { - HAL_LOG(("Unable to write to file %s.", filename)); + HAL_LOG("Unable to write to file %s.", filename); return false; } @@ -719,8 +720,7 @@ SetScreenBrightness(double brightness) // Don't use De Morgan's law to push the ! into this expression; we want to // catch NaN too. if (!(0 <= brightness && brightness <= 1)) { - HAL_LOG(("SetScreenBrightness: Dropping illegal brightness %f.", - brightness)); + HAL_LOG("SetScreenBrightness: Dropping illegal brightness %f.", brightness); return; } @@ -809,12 +809,12 @@ AdjustSystemClock(int64_t aDeltaMilliseconds) } while (fd == -1 && errno == EINTR); ScopedClose autoClose(fd); if (fd < 0) { - HAL_LOG(("Failed to open /dev/alarm: %s", strerror(errno))); + HAL_LOG("Failed to open /dev/alarm: %s", strerror(errno)); return; } if (ioctl(fd, ANDROID_ALARM_SET_RTC, &now) < 0) { - HAL_LOG(("ANDROID_ALARM_SET_RTC failed: %s", strerror(errno))); + HAL_LOG("ANDROID_ALARM_SET_RTC failed: %s", strerror(errno)); } hal::NotifySystemClockChange(aDeltaMilliseconds); @@ -1040,7 +1040,7 @@ EnableAlarm() int alarmFd = open("/dev/alarm", O_RDWR); if (alarmFd < 0) { - HAL_LOG(("Failed to open alarm device: %s.", strerror(errno))); + HAL_LOG("Failed to open alarm device: %s.", strerror(errno)); return false; } @@ -1052,7 +1052,7 @@ EnableAlarm() actions.sa_flags = 0; actions.sa_handler = ShutDownAlarm; if (sigaction(SIGUSR1, &actions, nullptr)) { - HAL_LOG(("Failed to set SIGUSR1 signal for alarm-watcher thread.")); + HAL_LOG("Failed to set SIGUSR1 signal for alarm-watcher thread."); return false; } @@ -1068,7 +1068,7 @@ EnableAlarm() if (status) { alarmData = nullptr; delete sInternalLockCpuMonitor; - HAL_LOG(("Failed to create alarm-watcher thread. Status: %d.", status)); + HAL_LOG("Failed to create alarm-watcher thread. Status: %d.", status); return false; } @@ -1099,7 +1099,7 @@ bool SetAlarm(int32_t aSeconds, int32_t aNanoseconds) { if (!sAlarmData) { - HAL_LOG(("We should have enabled the alarm.")); + HAL_LOG("We should have enabled the alarm."); return false; } @@ -1112,7 +1112,7 @@ SetAlarm(int32_t aSeconds, int32_t aNanoseconds) ANDROID_ALARM_SET(ANDROID_ALARM_RTC_WAKEUP), &ts); if (result < 0) { - HAL_LOG(("Unable to set alarm: %s.", strerror(errno))); + HAL_LOG("Unable to set alarm: %s.", strerror(errno)); return false; } @@ -1294,7 +1294,7 @@ EnsureKernelLowMemKillerParamsSet() } kernelLowMemKillerParamsSet = true; - HAL_LOG(("Setting kernel's low-mem killer parameters.")); + HAL_LOG("Setting kernel's low-mem killer parameters."); // Set /sys/module/lowmemorykiller/parameters/{adj,minfree,notify_trigger} // according to our prefs. These files let us tune when the kernel kills @@ -1396,15 +1396,15 @@ SetNiceForPid(int aPid, int aNice) errno = 0; int origProcPriority = getpriority(PRIO_PROCESS, aPid); if (errno) { - HAL_LOG(("Unable to get nice for pid=%d; error %d. SetNiceForPid bailing.", - aPid, errno)); + HAL_LOG("Unable to get nice for pid=%d; error %d. SetNiceForPid bailing.", + aPid, errno); return; } int rv = setpriority(PRIO_PROCESS, aPid, aNice); if (rv) { - HAL_LOG(("Unable to set nice for pid=%d; error %d. SetNiceForPid bailing.", - aPid, errno)); + HAL_LOG("Unable to set nice for pid=%d; error %d. SetNiceForPid bailing.", + aPid, errno); return; } @@ -1418,7 +1418,7 @@ SetNiceForPid(int aPid, int aNice) DIR* tasksDir = opendir(nsPrintfCString("/proc/%d/task/", aPid).get()); if (!tasksDir) { - HAL_LOG(("Unable to open /proc/%d/task. SetNiceForPid bailing.", aPid)); + HAL_LOG("Unable to open /proc/%d/task. SetNiceForPid bailing.", aPid); return; } @@ -1451,9 +1451,9 @@ SetNiceForPid(int aPid, int aNice) // Get and set the task's new priority. int origtaskpriority = getpriority(PRIO_PROCESS, tid); if (errno) { - HAL_LOG(("Unable to get nice for tid=%d (pid=%d); error %d. This isn't " - "necessarily a problem; it could be a benign race condition.", - tid, aPid, errno)); + HAL_LOG("Unable to get nice for tid=%d (pid=%d); error %d. This isn't " + "necessarily a problem; it could be a benign race condition.", + tid, aPid, errno); continue; } @@ -1471,15 +1471,15 @@ SetNiceForPid(int aPid, int aNice) rv = setpriority(PRIO_PROCESS, tid, newtaskpriority); if (rv) { - HAL_LOG(("Unable to set nice for tid=%d (pid=%d); error %d. This isn't " - "necessarily a problem; it could be a benign race condition.", - tid, aPid, errno)); + HAL_LOG("Unable to set nice for tid=%d (pid=%d); error %d. This isn't " + "necessarily a problem; it could be a benign race condition.", + tid, aPid, errno); continue; } } - HAL_LOG(("Changed nice for pid %d from %d to %d.", - aPid, origProcPriority, aNice)); + HAL_LOG("Changed nice for pid %d from %d to %d.", + aPid, origProcPriority, aNice); closedir(tasksDir); } @@ -1490,8 +1490,8 @@ SetProcessPriority(int aPid, ProcessCPUPriority aCPUPriority, uint32_t aBackgroundLRU) { - HAL_LOG(("SetProcessPriority(pid=%d, priority=%d, cpuPriority=%d, LRU=%u)", - aPid, aPriority, aCPUPriority, aBackgroundLRU)); + HAL_LOG("SetProcessPriority(pid=%d, priority=%d, cpuPriority=%d, LRU=%u)", + aPid, aPriority, aCPUPriority, aBackgroundLRU); // If this is the first time SetProcessPriority was called, set the kernel's // OOM parameters according to our prefs. @@ -1513,11 +1513,11 @@ SetProcessPriority(int aPid, int clampedOomScoreAdj = clamped(oomScoreAdj, OOM_SCORE_ADJ_MIN, OOM_SCORE_ADJ_MAX); if(clampedOomScoreAdj != oomScoreAdj) { - HAL_LOG(("Clamping OOM adjustment for pid %d to %d", aPid, - clampedOomScoreAdj)); + HAL_LOG("Clamping OOM adjustment for pid %d to %d", aPid, + clampedOomScoreAdj); } else { - HAL_LOG(("Setting OOM adjustment for pid %d to %d", aPid, - clampedOomScoreAdj)); + HAL_LOG("Setting OOM adjustment for pid %d to %d", aPid, + clampedOomScoreAdj); } // We try the newer interface first, and fall back to the older interface @@ -1532,8 +1532,8 @@ SetProcessPriority(int aPid, nsPrintfCString("%d", oomAdj).get()); } } else { - HAL_ERR(("Unable to read oom_score_adj pref for priority %s; " - "are the prefs messed up?", ProcessPriorityToString(aPriority))); + HAL_ERR("Unable to read oom_score_adj pref for priority %s; " + "are the prefs messed up?", ProcessPriorityToString(aPriority)); MOZ_ASSERT(false); } @@ -1548,14 +1548,14 @@ SetProcessPriority(int aPid, rv = Preferences::GetInt("hal.processPriorityManager.gonk.LowCPUNice", &nice); } else { - HAL_ERR(("Unable to read niceness pref for priority %s; " - "are the prefs messed up?", ProcessPriorityToString(aPriority))); + HAL_ERR("Unable to read niceness pref for priority %s; " + "are the prefs messed up?", ProcessPriorityToString(aPriority)); MOZ_ASSERT(false); rv = NS_ERROR_FAILURE; } if (NS_SUCCEEDED(rv)) { - HAL_LOG(("Setting nice for pid %d to %d", aPid, nice)); + HAL_LOG("Setting nice for pid %d to %d", aPid, nice); SetNiceForPid(aPid, nice); } } @@ -1573,13 +1573,13 @@ SetThreadNiceValue(pid_t aTid, ThreadPriority aThreadPriority, int aValue) MOZ_ASSERT(aThreadPriority < NUM_THREAD_PRIORITY); MOZ_ASSERT(aThreadPriority >= 0); - HAL_LOG(("Setting thread %d to priority level %s; nice level %d", - aTid, ThreadPriorityToString(aThreadPriority), aValue)); + HAL_LOG("Setting thread %d to priority level %s; nice level %d", + aTid, ThreadPriorityToString(aThreadPriority), aValue); int rv = setpriority(PRIO_PROCESS, aTid, aValue); if (rv) { - HAL_LOG(("Failed to set thread %d to priority level %s; error %s", aTid, - ThreadPriorityToString(aThreadPriority), strerror(errno))); + HAL_LOG("Failed to set thread %d to priority level %s; error %s", aTid, + ThreadPriorityToString(aThreadPriority), strerror(errno)); } } @@ -1595,16 +1595,16 @@ SetRealTimeThreadPriority(pid_t aTid, MOZ_ASSERT(IsValidRealTimePriority(aValue, policy), "Invalid real time priority"); // Setting real time priorities requires using sched_setscheduler - HAL_LOG(("Setting thread %d to priority level %s; Real Time priority %d, " - "Schedule FIFO", aTid, ThreadPriorityToString(aThreadPriority), - aValue)); + HAL_LOG("Setting thread %d to priority level %s; Real Time priority %d, " + "Schedule FIFO", aTid, ThreadPriorityToString(aThreadPriority), + aValue); sched_param schedParam; schedParam.sched_priority = aValue; int rv = sched_setscheduler(aTid, policy, &schedParam); if (rv) { - HAL_LOG(("Failed to set thread %d to real time priority level %s; error %s", - aTid, ThreadPriorityToString(aThreadPriority), strerror(errno))); + HAL_LOG("Failed to set thread %d to real time priority level %s; error %s", + aTid, ThreadPriorityToString(aThreadPriority), strerror(errno)); } } @@ -1622,8 +1622,8 @@ SetThreadPriority(pid_t aTid, hal::ThreadPriority aThreadPriority) threadPriorityStr = ThreadPriorityToString(aThreadPriority); break; default: - HAL_ERR(("Unrecognized thread priority %d; Doing nothing", - aThreadPriority)); + HAL_ERR("Unrecognized thread priority %d; Doing nothing", + aThreadPriority); return; } @@ -1685,8 +1685,8 @@ SetCurrentThreadPriority(ThreadPriority aThreadPriority) break; } default: - HAL_LOG(("Unrecognized thread priority %d; Doing nothing", - aThreadPriority)); + HAL_LOG("Unrecognized thread priority %d; Doing nothing", + aThreadPriority); return; } } diff --git a/hal/gonk/GonkSensor.cpp b/hal/gonk/GonkSensor.cpp index b3a13ef93d56..7e6b2bade253 100644 --- a/hal/gonk/GonkSensor.cpp +++ b/hal/gonk/GonkSensor.cpp @@ -23,19 +23,13 @@ #include "base/thread.h" #include "Hal.h" +#include "HalLog.h" #include "HalSensor.h" #include "hardware/sensors.h" #include "nsThreadUtils.h" -#undef LOG - -#include - using namespace mozilla::hal; -#define LOGE(args...) __android_log_print(ANDROID_LOG_ERROR, "GonkSensor" , ## args) -#define LOGW(args...) __android_log_print(ANDROID_LOG_WARN, "GonkSensor" , ## args) - namespace mozilla { // The value from SensorDevice.h (Android) @@ -177,7 +171,7 @@ PollSensors() // didn't check sSensorDevice because already be done on creating pollingThread. int n = sSensorDevice->poll(sSensorDevice, buffer, numEventMax); if (n < 0) { - LOGE("Error polling for sensor data (err=%d)", n); + HAL_ERR("Error polling for sensor data (err=%d)", n); break; } @@ -206,7 +200,7 @@ PollSensors() HardwareSensorToHalSensor(sensors[index].type) != SENSOR_UNKNOWN) { buffer[i].type = sensors[index].type; } else { - LOGW("Could not determine sensor type of event"); + HAL_LOG("Could not determine sensor type of event"); continue; } } @@ -264,14 +258,14 @@ EnableSensorNotifications(SensorType aSensor) hw_get_module(SENSORS_HARDWARE_MODULE_ID, (hw_module_t const**)&sSensorModule); if (!sSensorModule) { - LOGE("Can't get sensor HAL module\n"); + HAL_ERR("Can't get sensor HAL module\n"); return; } sensors_open(&sSensorModule->common, &sSensorDevice); if (!sSensorDevice) { sSensorModule = nullptr; - LOGE("Can't get sensor poll device from module \n"); + HAL_ERR("Can't get sensor poll device from module \n"); return; } diff --git a/hal/gonk/GonkSwitch.cpp b/hal/gonk/GonkSwitch.cpp index dfa38ae91ad2..65c9e1b6b2e6 100644 --- a/hal/gonk/GonkSwitch.cpp +++ b/hal/gonk/GonkSwitch.cpp @@ -14,13 +14,13 @@ * limitations under the License. */ -#include #include #include #include "base/message_loop.h" #include "Hal.h" +#include "HalLog.h" #include "mozilla/FileUtils.h" #include "mozilla/RefPtr.h" #include "mozilla/Monitor.h" @@ -31,8 +31,6 @@ using namespace mozilla::hal; -#define LOG(args...) __android_log_print(ANDROID_LOG_INFO, "GonkSwitch" , ## args) - #define SWITCH_HEADSET_DEVPATH "/devices/virtual/switch/h2w" #define SWITCH_USB_DEVPATH_GB "/devices/virtual/switch/usb_configuration" #define SWITCH_USB_DEVPATH_ICS "/devices/virtual/android_usb/android0" @@ -110,7 +108,7 @@ protected: char state[16]; ssize_t bytesRead = read(fd, state, sizeof(state)); if (bytesRead < 0) { - LOG("Read data from %s fails", statePath.get()); + HAL_ERR("Read data from %s fails", statePath.get()); return; } diff --git a/hal/gonk/UeventPoller.cpp b/hal/gonk/UeventPoller.cpp index d394a1dfa9ce..a33faf1ca345 100644 --- a/hal/gonk/UeventPoller.cpp +++ b/hal/gonk/UeventPoller.cpp @@ -28,6 +28,7 @@ #include #include +#include "HalLog.h" #include "nsDebug.h" #include "base/message_loop.h" #include "mozilla/FileUtils.h" @@ -133,7 +134,8 @@ NetlinkPoller::OpenSocket() // Once there was any other place in the same process assigning saddr.nl_pid by // gettid(), we can detect it and print warning message. - printf_stderr("The netlink socket address saddr.nl_pid=%u is in use. Let the kernel re-assign.\n", saddr.nl_pid); + HAL_LOG("The netlink socket address saddr.nl_pid=%u is in use. " + "Let the kernel re-assign.\n", saddr.nl_pid); saddr.nl_pid = 0; } while (true); diff --git a/hal/linux/UPowerClient.cpp b/hal/linux/UPowerClient.cpp index ae678b5cda72..66dd97351e1e 100644 --- a/hal/linux/UPowerClient.cpp +++ b/hal/linux/UPowerClient.cpp @@ -3,7 +3,8 @@ * 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 +#include "Hal.h" +#include "HalLog.h" #include #include #include @@ -186,7 +187,7 @@ UPowerClient::BeginListening() mDBusConnection = dbus_g_bus_get(DBUS_BUS_SYSTEM, &error); if (!mDBusConnection) { - g_printerr("Failed to open connection to bus: %s\n", error->message); + HAL_LOG("Failed to open connection to bus: %s\n", error->message); g_error_free(error); return; } @@ -277,7 +278,7 @@ UPowerClient::UpdateTrackedDeviceSync() // If that fails, that likely means upower isn't installed. if (!dbus_g_proxy_call(mUPowerProxy, "EnumerateDevices", &error, G_TYPE_INVALID, typeGPtrArray, &devices, G_TYPE_INVALID)) { - g_printerr ("Error: %s\n", error->message); + HAL_LOG("Error: %s\n", error->message); g_error_free(error); return; } @@ -350,7 +351,7 @@ UPowerClient::GetDevicePropertiesSync(DBusGProxy* aProxy) if (!dbus_g_proxy_call(aProxy, "GetAll", &error, G_TYPE_STRING, "org.freedesktop.UPower.Device", G_TYPE_INVALID, typeGHashTable, &hashTable, G_TYPE_INVALID)) { - g_printerr("Error: %s\n", error->message); + HAL_LOG("Error: %s\n", error->message); g_error_free(error); return nullptr; } @@ -368,7 +369,7 @@ UPowerClient::GetDevicePropertiesCallback(DBusGProxy* aProxy, G_TYPE_VALUE); if (!dbus_g_proxy_end_call(aProxy, aCall, &error, typeGHashTable, &hashTable, G_TYPE_INVALID)) { - g_printerr("Error: %s\n", error->message); + HAL_LOG("Error: %s\n", error->message); g_error_free(error); } else { sInstance->UpdateSavedInfo(hashTable); diff --git a/hal/sandbox/SandboxHal.cpp b/hal/sandbox/SandboxHal.cpp index 3c857e34d2f6..f2faba6e4e36 100644 --- a/hal/sandbox/SandboxHal.cpp +++ b/hal/sandbox/SandboxHal.cpp @@ -5,6 +5,7 @@ * You can obtain one at http://mozilla.org/MPL/2.0/. */ #include "Hal.h" +#include "HalLog.h" #include "mozilla/AppProcessChecker.h" #include "mozilla/dom/ContentChild.h" #include "mozilla/dom/ContentParent.h" @@ -47,7 +48,7 @@ Hal() void Vibrate(const nsTArray& pattern, const WindowIdentifier &id) { - HAL_LOG(("Vibrate: Sending to parent process.")); + HAL_LOG("Vibrate: Sending to parent process."); AutoInfallibleTArray p(pattern); @@ -59,7 +60,7 @@ Vibrate(const nsTArray& pattern, const WindowIdentifier &id) void CancelVibrate(const WindowIdentifier &id) { - HAL_LOG(("CancelVibrate: Sending to parent process.")); + HAL_LOG("CancelVibrate: Sending to parent process."); WindowIdentifier newID(id); newID.AppendProcessID(); diff --git a/image/test/mochitest/test_animation2.html b/image/test/mochitest/test_animation2.html index 5b06ce33d56e..934df0fef432 100644 --- a/image/test/mochitest/test_animation2.html +++ b/image/test/mochitest/test_animation2.html @@ -20,7 +20,7 @@ Mozilla Bug 705580: Test animated GIFs that are converted to ImageLayers
    templateObject(), "baseline-callnative-template"); break; } + case ICStub::Call_StringSplit: { + ICCall_StringSplit *callStub = toCall_StringSplit(); + MarkObject(trc, &callStub->templateObject(), "baseline-callstringsplit-template"); + MarkString(trc, &callStub->expectedArg(), "baseline-callstringsplit-arg"); + MarkString(trc, &callStub->expectedThis(), "baseline-callstringsplit-this"); + break; + } case ICStub::GetElem_NativeSlot: { ICGetElem_NativeSlot *getElemStub = toGetElem_NativeSlot(); MarkShape(trc, &getElemStub->shape(), "baseline-getelem-native-shape"); @@ -8306,6 +8313,25 @@ GetTemplateObjectForNative(JSContext *cx, HandleScript script, jsbytecode *pc, return true; } +static bool +IsOptimizableCallStringSplit(Value callee, Value thisv, int argc, Value *args) +{ + if (argc != 1 || !thisv.isString() || !args[0].isString()) + return false; + + if (!thisv.toString()->isAtom() || !args[0].toString()->isAtom()) + return false; + + if (!callee.isObject() || !callee.toObject().is()) + return false; + + JSFunction &calleeFun = callee.toObject().as(); + if (!calleeFun.isNative() || calleeFun.native() != js::str_split) + return false; + + return true; +} + static bool TryAttachCallStub(JSContext *cx, ICCall_Fallback *stub, HandleScript script, jsbytecode *pc, JSOp op, uint32_t argc, Value *vp, bool constructing, bool isSpread, @@ -8323,6 +8349,15 @@ TryAttachCallStub(JSContext *cx, ICCall_Fallback *stub, HandleScript script, jsb RootedValue callee(cx, vp[0]); RootedValue thisv(cx, vp[1]); + // Don't attach an optimized call stub if we could potentially attach an + // optimized StringSplit stub. + if (stub->numOptimizedStubs() == 0 && IsOptimizableCallStringSplit(callee, thisv, argc, vp + 2)) + return true; + + JS_ASSERT_IF(stub->hasStub(ICStub::Call_StringSplit), stub->numOptimizedStubs() == 1); + + stub->unlinkStubsWithKind(cx, ICStub::Call_StringSplit); + if (!callee.isObject()) return true; @@ -8469,6 +8504,65 @@ TryAttachCallStub(JSContext *cx, ICCall_Fallback *stub, HandleScript script, jsb return true; } +static bool +CopyArray(JSContext *cx, HandleObject obj, MutableHandleValue result) +{ + JS_ASSERT(obj->is()); + uint32_t length = obj->as().length(); + JS_ASSERT(obj->getDenseInitializedLength() == length); + + RootedTypeObject type(cx, obj->getType(cx)); + if (!type) + return false; + + RootedObject newObj(cx, NewDenseArray(cx, length, type, NewArray_FullyAllocating)); + if (!newObj) + return false; + + newObj->setDenseInitializedLength(length); + newObj->initDenseElements(0, obj->getDenseElements(), length); + result.setObject(*newObj); + return true; +} + +static bool +TryAttachStringSplit(JSContext *cx, ICCall_Fallback *stub, HandleScript script, + uint32_t argc, Value *vp, jsbytecode *pc, HandleValue res) +{ + if (stub->numOptimizedStubs() != 0) + return true; + + RootedValue callee(cx, vp[0]); + RootedValue thisv(cx, vp[1]); + Value *args = vp + 2; + + if (!IsOptimizableCallStringSplit(callee, thisv, argc, args)) + return true; + + JS_ASSERT(res.toObject().is()); + JS_ASSERT(callee.isObject()); + JS_ASSERT(callee.toObject().is()); + + RootedString thisString(cx, thisv.toString()); + RootedString argString(cx, args[0].toString()); + RootedObject obj(cx, &res.toObject()); + RootedValue arr(cx); + + // Copy the array before storing in stub. + if (!CopyArray(cx, obj, &arr)) + return false; + + ICCall_StringSplit::Compiler compiler(cx, stub->fallbackMonitorStub()->firstMonitorStub(), + script->pcToOffset(pc), thisString, argString, + arr); + ICStub *newStub = compiler.getStub(compiler.getStubSpace(script)); + if (!newStub) + return false; + + stub->addNewStub(newStub); + return true; +} + static bool MaybeCloneFunctionAtCallsite(JSContext *cx, MutableHandleValue callee, HandleScript script, jsbytecode *pc) @@ -8559,6 +8653,11 @@ DoCallFallback(JSContext *cx, BaselineFrame *frame, ICCall_Fallback *stub_, uint if (!stub->addMonitorStubForValue(cx, script, res)) return false; + // If 'callee' is a potential Call_StringSplit, try to attach an + // optimized StringSplit stub. + if (!TryAttachStringSplit(cx, stub, script, argc, vp, pc, res)) + return false; + return true; } @@ -9241,6 +9340,100 @@ ICCallScriptedCompiler::generateStubCode(MacroAssembler &masm) return true; } +typedef bool (*CopyArrayFn)(JSContext *, HandleObject, MutableHandleValue); +static const VMFunction CopyArrayInfo = FunctionInfo(CopyArray); + +bool +ICCall_StringSplit::Compiler::generateStubCode(MacroAssembler &masm) +{ + // Stack Layout: [ ..., CalleeVal, ThisVal, Arg0Val, +ICStackValueOffset+ ] + GeneralRegisterSet regs = availableGeneralRegs(0); + Label failureRestoreArgc; +#ifdef DEBUG + Label oneArg; + Register argcReg = R0.scratchReg(); + masm.branch32(Assembler::Equal, argcReg, Imm32(1), &oneArg); + masm.assumeUnreachable("Expected argc == 1"); + masm.bind(&oneArg); +#endif + Register scratchReg = regs.takeAny(); + + // Guard that callee is native function js::str_split. + { + Address calleeAddr(BaselineStackReg, ICStackValueOffset + (2 * sizeof(Value))); + ValueOperand calleeVal = regs.takeAnyValue(); + + // Ensure that callee is an object. + masm.loadValue(calleeAddr, calleeVal); + masm.branchTestObject(Assembler::NotEqual, calleeVal, &failureRestoreArgc); + + // Ensure that callee is a function. + Register calleeObj = masm.extractObject(calleeVal, ExtractTemp0); + masm.branchTestObjClass(Assembler::NotEqual, calleeObj, scratchReg, + &JSFunction::class_, &failureRestoreArgc); + + // Ensure that callee's function impl is the native str_split. + masm.loadPtr(Address(calleeObj, JSFunction::offsetOfNativeOrScript()), scratchReg); + masm.branchPtr(Assembler::NotEqual, scratchReg, ImmPtr(js::str_split), &failureRestoreArgc); + + regs.add(calleeVal); + } + + // Guard argument. + { + // Ensure that arg is a string. + Address argAddr(BaselineStackReg, ICStackValueOffset); + ValueOperand argVal = regs.takeAnyValue(); + + masm.loadValue(argAddr, argVal); + masm.branchTestString(Assembler::NotEqual, argVal, &failureRestoreArgc); + + Register argString = masm.extractString(argVal, ExtractTemp0); + masm.branchPtr(Assembler::NotEqual, Address(BaselineStubReg, offsetOfExpectedArg()), + argString, &failureRestoreArgc); + regs.add(argVal); + } + + // Guard this-value. + { + // Ensure that thisv is a string. + Address thisvAddr(BaselineStackReg, ICStackValueOffset + sizeof(Value)); + ValueOperand thisvVal = regs.takeAnyValue(); + + masm.loadValue(thisvAddr, thisvVal); + masm.branchTestString(Assembler::NotEqual, thisvVal, &failureRestoreArgc); + + Register thisvString = masm.extractString(thisvVal, ExtractTemp0); + masm.branchPtr(Assembler::NotEqual, Address(BaselineStubReg, offsetOfExpectedThis()), + thisvString, &failureRestoreArgc); + regs.add(thisvVal); + } + + // Main stub body. + { + Register paramReg = regs.takeAny(); + + // Push arguments. + enterStubFrame(masm, scratchReg); + masm.loadPtr(Address(BaselineStubReg, offsetOfTemplateObject()), paramReg); + masm.push(paramReg); + + if (!callVM(CopyArrayInfo, masm)) + return false; + leaveStubFrame(masm); + regs.add(paramReg); + } + + // Enter type monitor IC to type-check result. + EmitEnterTypeMonitorIC(masm); + + // Guard failure path. + masm.bind(&failureRestoreArgc); + masm.move32(Imm32(1), R0.scratchReg()); + EmitStubGuardFailure(masm); + return true; +} + bool ICCall_Native::Compiler::generateStubCode(MacroAssembler &masm) { diff --git a/js/src/jit/BaselineIC.h b/js/src/jit/BaselineIC.h index 60228ed61c85..0c168187a44d 100644 --- a/js/src/jit/BaselineIC.h +++ b/js/src/jit/BaselineIC.h @@ -377,6 +377,7 @@ class ICEntry _(Call_ScriptedApplyArray) \ _(Call_ScriptedApplyArguments) \ _(Call_ScriptedFunCall) \ + _(Call_StringSplit) \ \ _(GetElem_Fallback) \ _(GetElem_NativeSlot) \ @@ -791,6 +792,7 @@ class ICStub case Call_ScriptedApplyArray: case Call_ScriptedApplyArguments: case Call_ScriptedFunCall: + case Call_StringSplit: case WarmUpCounter_Fallback: case GetElem_NativeSlot: case GetElem_NativePrototypeSlot: @@ -6047,6 +6049,91 @@ class ICCall_ScriptedFunCall : public ICMonitoredStub }; }; +class ICCall_StringSplit : public ICMonitoredStub +{ + friend class ICStubSpace; + + protected: + uint32_t pcOffset_; + HeapPtrString expectedThis_; + HeapPtrString expectedArg_; + HeapPtrObject templateObject_; + + ICCall_StringSplit(JitCode *stubCode, ICStub *firstMonitorStub, uint32_t pcOffset, HandleString thisString, + HandleString argString, HandleObject templateObject) + : ICMonitoredStub(ICStub::Call_StringSplit, stubCode, firstMonitorStub), + pcOffset_(pcOffset), expectedThis_(thisString), expectedArg_(argString), + templateObject_(templateObject) + { } + + public: + static inline ICCall_StringSplit *New(ICStubSpace *space, JitCode *code, + ICStub *firstMonitorStub, uint32_t pcOffset, HandleString thisString, + HandleString argString, HandleObject templateObject) + { + if (!code) + return nullptr; + return space->allocate(code, firstMonitorStub, pcOffset, thisString, + argString, templateObject); + } + + static size_t offsetOfExpectedThis() { + return offsetof(ICCall_StringSplit, expectedThis_); + } + + static size_t offsetOfExpectedArg() { + return offsetof(ICCall_StringSplit, expectedArg_); + } + + static size_t offsetOfTemplateObject() { + return offsetof(ICCall_StringSplit, templateObject_); + } + + HeapPtrString &expectedThis() { + return expectedThis_; + } + + HeapPtrString &expectedArg() { + return expectedArg_; + } + + HeapPtrObject &templateObject() { + return templateObject_; + } + + class Compiler : public ICCallStubCompiler { + protected: + ICStub *firstMonitorStub_; + uint32_t pcOffset_; + RootedString expectedThis_; + RootedString expectedArg_; + RootedObject templateObject_; + + bool generateStubCode(MacroAssembler &masm); + + virtual int32_t getKey() const { + return static_cast(kind); + } + + public: + Compiler(JSContext *cx, ICStub *firstMonitorStub, uint32_t pcOffset, HandleString thisString, + HandleString argString, HandleValue templateObject) + : ICCallStubCompiler(cx, ICStub::Call_StringSplit), + firstMonitorStub_(firstMonitorStub), + pcOffset_(pcOffset), + expectedThis_(cx, thisString), + expectedArg_(cx, argString), + templateObject_(cx, &templateObject.toObject()) + { } + + ICStub *getStub(ICStubSpace *space) { + return ICCall_StringSplit::New(space, getStubCode(), firstMonitorStub_, + pcOffset_, expectedThis_, expectedArg_, + templateObject_); + } + }; +}; + // Stub for performing a TableSwitch, updating the IC's return address to jump // to whatever point the switch is branching to. class ICTableSwitch : public ICStub diff --git a/js/src/jit/MIR.cpp b/js/src/jit/MIR.cpp index 53c31aa9abec..d6e2e09f2f51 100644 --- a/js/src/jit/MIR.cpp +++ b/js/src/jit/MIR.cpp @@ -1222,12 +1222,12 @@ MPhi::foldsTernary() if (testArg != test->input()) return nullptr; - // If testArg is a number type we can: + // If testArg is an int32 type we can: // - fold testArg ? testArg : 0 to testArg // - fold testArg ? 0 : testArg to 0 - if (IsNumberType(testArg->type()) && c->vp()->toNumber() == 0) { + if (testArg->type() == MIRType_Int32 && c->vp()->toNumber() == 0) { // When folding to the constant we need to hoist it. - if (trueDef == c) + if (trueDef == c && !c->block()->dominates(block())) c->block()->moveBefore(pred->lastIns(), c); return trueDef; } @@ -1239,7 +1239,7 @@ MPhi::foldsTernary() c->vp()->toString() == GetIonContext()->runtime->emptyString()) { // When folding to the constant we need to hoist it. - if (trueDef == c) + if (trueDef == c && !c->block()->dominates(block())) c->block()->moveBefore(pred->lastIns(), c); return trueDef; } diff --git a/js/src/jit/shared/CodeGenerator-shared.cpp b/js/src/jit/shared/CodeGenerator-shared.cpp index 97ecdeeaf40c..16227afe0d94 100644 --- a/js/src/jit/shared/CodeGenerator-shared.cpp +++ b/js/src/jit/shared/CodeGenerator-shared.cpp @@ -76,19 +76,24 @@ CodeGeneratorShared::CodeGeneratorShared(MIRGenerator *gen, LIRGraph *graph, Mac JS_ASSERT(graph->argumentSlotCount() == 0); frameDepth_ += gen->maxAsmJSStackArgBytes(); - // If the function uses any SIMD, we may need to insert padding so that - // local slots are aligned for SIMD. if (gen->usesSimd()) { - frameInitialAdjustment_ = ComputeByteAlignment(sizeof(AsmJSFrame), AsmJSStackAlignment); + // If the function uses any SIMD then we may need to insert padding + // so that local slots are aligned for SIMD. + frameInitialAdjustment_ = ComputeByteAlignment(sizeof(AsmJSFrame), + AsmJSStackAlignment); frameDepth_ += frameInitialAdjustment_; + // Keep the stack aligned. Some SIMD sequences build values on the + // stack and need the stack aligned. + frameDepth_ += ComputeByteAlignment(sizeof(AsmJSFrame) + frameDepth_, + AsmJSStackAlignment); + } else if (gen->performsCall()) { + // An MAsmJSCall does not align the stack pointer at calls sites but + // instead relies on the a priori stack adjustment. This must be the + // last adjustment of frameDepth_. + frameDepth_ += ComputeByteAlignment(sizeof(AsmJSFrame) + frameDepth_, + AsmJSStackAlignment); } - // An MAsmJSCall does not align the stack pointer at calls sites but instead - // relies on the a priori stack adjustment. This must be the last - // adjustment of frameDepth_. - if (gen->performsCall()) - frameDepth_ += ComputeByteAlignment(sizeof(AsmJSFrame) + frameDepth_, AsmJSStackAlignment); - // FrameSizeClass is only used for bailing, which cannot happen in // asm.js code. frameClass_ = FrameSizeClass::None(); diff --git a/js/src/jsobjinlines.h b/js/src/jsobjinlines.h index 7e8d49cd87c2..0d44423c22e2 100644 --- a/js/src/jsobjinlines.h +++ b/js/src/jsobjinlines.h @@ -543,6 +543,10 @@ JSObject::create(js::ExclusiveContext *cx, js::gc::AllocKind kind, js::gc::Initi if (span) obj->initializeSlotRange(0, span); + // JSFunction's fixed slots expect POD-style initialization. + if (type->clasp()->isJSFunction()) + memset(obj->fixedSlots(), 0, sizeof(js::HeapSlot) * GetGCKindSlots(kind)); + js::gc::TraceCreateObject(obj); return obj; diff --git a/layout/base/FrameLayerBuilder.cpp b/layout/base/FrameLayerBuilder.cpp index 873f1841869f..daebe822b80c 100644 --- a/layout/base/FrameLayerBuilder.cpp +++ b/layout/base/FrameLayerBuilder.cpp @@ -130,7 +130,7 @@ FrameLayerBuilder::DisplayItemData::BeginUpdate(Layer* aLayer, LayerState aState mContainerLayerGeneration = aContainerLayerGeneration; mUsed = true; - if (aLayer->AsThebesLayer()) { + if (aLayer->AsPaintedLayer()) { mItem = aItem; } @@ -241,17 +241,17 @@ static inline MaskLayerImageCache* GetMaskLayerImageCache() } /** - * We keep a stack of these to represent the ThebesLayers that are + * We keep a stack of these to represent the PaintedLayers that are * currently available to have display items added to. * We use a stack here because as much as possible we want to - * assign display items to existing ThebesLayers, and to the lowest - * ThebesLayer in z-order. This reduces the number of layers and + * assign display items to existing PaintedLayers, and to the lowest + * PaintedLayer in z-order. This reduces the number of layers and * makes it more likely a display item will be rendered to an opaque * layer, giving us the best chance of getting subpixel AA. */ -class ThebesLayerData { +class PaintedLayerData { public: - ThebesLayerData() : + PaintedLayerData() : mAnimatedGeometryRoot(nullptr), mFixedPosFrameForLayerData(nullptr), mReferenceFrame(nullptr), @@ -268,7 +268,7 @@ public: mAllDrawingAbove(false) {} /** - * Record that an item has been added to the ThebesLayer, so we + * Record that an item has been added to the PaintedLayer, so we * need to update our regions. * @param aVisibleRect the area of the item that's visible * @param aDrawRect the area of the item that would be drawn if it @@ -290,7 +290,7 @@ public: /** * Add aHitRegion, aMaybeHitRegion, and aDispatchToContentHitRegion to the - * hit regions for this ThebesLayer. + * hit regions for this PaintedLayer. */ void AccumulateEventRegions(const nsRegion& aHitRegion, const nsRegion& aMaybeHitRegion, @@ -324,7 +324,7 @@ public: } } - void CopyAboveRegion(ThebesLayerData* aOther) + void CopyAboveRegion(PaintedLayerData* aOther) { if (aOther->mAllDrawingAbove || mAllDrawingAbove) { SetAllDrawingAbove(); @@ -380,11 +380,11 @@ public: */ nsAutoCString mLog; - #define FLB_LOG_THEBES_DECISION(tld, ...) \ + #define FLB_LOG_PAINTED_LAYER_DECISION(tld, ...) \ tld->mLog.AppendPrintf("\t\t\t\t"); \ tld->mLog.AppendPrintf(__VA_ARGS__); #else - #define FLB_LOG_THEBES_DECISION(...) + #define FLB_LOG_PAINTED_LAYER_DECISION(...) #endif /** @@ -406,20 +406,20 @@ public: */ nsIntRegion mOpaqueRegion; /** - * The definitely-hit region for this ThebesLayer. + * The definitely-hit region for this PaintedLayer. */ nsRegion mHitRegion; /** - * The maybe-hit region for this ThebesLayer. + * The maybe-hit region for this PaintedLayer. */ nsRegion mMaybeHitRegion; /** - * The dispatch-to-content hit region for this ThebesLayer. + * The dispatch-to-content hit region for this PaintedLayer. */ nsRegion mDispatchToContentHitRegion; /** * The "active scrolled root" for all content in the layer. Must - * be non-null; all content in a ThebesLayer must have the same + * be non-null; all content in a PaintedLayer must have the same * active scrolled root. */ const nsIFrame* mAnimatedGeometryRoot; @@ -430,7 +430,7 @@ public: */ const nsIFrame* mFixedPosFrameForLayerData; const nsIFrame* mReferenceFrame; - ThebesLayer* mLayer; + PaintedLayer* mLayer; /** * If mIsSolidColorInVisibleRegion is true, this is the color of the visible * region. @@ -458,14 +458,14 @@ public: */ bool mForceTransparentSurface; /** - * Set if all layers below this ThebesLayer should be hidden. + * Set if all layers below this PaintedLayer should be hidden. */ bool mHideAllLayersBelow; /** * Set if the opaque region for this layer can be applied to the parent * animated geometry root of this layer's animated geometry root. - * We set this when a ThebesLayer's animated geometry root is a scrollframe - * and the ThebesLayer completely fills the displayport of the scrollframe. + * We set this when a PaintedLayer's animated geometry root is a scrollframe + * and the PaintedLayer completely fills the displayport of the scrollframe. */ bool mOpaqueForAnimatedGeometryRootParent; @@ -479,7 +479,7 @@ public: * image, a clip for SOME item in the layer. There is no guarantee which * item's clip will be stored here and mItemClip should not be used to clip * the whole layer - only some part of the clip should be used, as determined - * by ThebesDisplayItemLayerUserData::GetCommonClipCount() - which may even be + * by PaintedDisplayItemLayerUserData::GetCommonClipCount() - which may even be * no part at all. */ DisplayItemClip mItemClip; @@ -509,18 +509,18 @@ public: private: /** * The region of visible content above the layer and below the - * next ThebesLayerData currently in the stack, if any. Note that not - * all ThebesLayers for the container are in the ThebesLayerData stack. + * next PaintedLayerData currently in the stack, if any. Note that not + * all PaintedLayers for the container are in the PaintedLayerData stack. * Same coordinate system as mVisibleRegion. * This is a conservative approximation: it contains the true region. */ nsIntRegion mVisibleAboveRegion; /** * The region containing the bounds of all display items (regardless - * of visibility) in the layer and below the next ThebesLayerData + * of visibility) in the layer and below the next PaintedLayerData * currently in the stack, if any. - * Note that not all ThebesLayers for the container are in the - * ThebesLayerData stack. + * Note that not all PaintedLayers for the container are in the + * PaintedLayerData stack. * Same coordinate system as mVisibleRegion. */ nsIntRegion mDrawAboveRegion; @@ -541,7 +541,7 @@ struct NewLayerEntry { , mOpaqueForAnimatedGeometryRootParent(false) , mPropagateComponentAlphaFlattening(true) {} - // mLayer is null if the previous entry is for a ThebesLayer that hasn't + // mLayer is null if the previous entry is for a PaintedLayer that hasn't // been optimized to some other form (yet). nsRefPtr mLayer; const nsIFrame* mAnimatedGeometryRoot; @@ -594,7 +594,7 @@ public: mContainerLayer(aContainerLayer), mContainerBounds(aContainerBounds), mParameters(aParameters), - mNextFreeRecycledThebesLayer(0), + mNextFreeRecycledPaintedLayer(0), mFlattenToSingleLayer(aFlattenToSingleLayer) { nsPresContext* presContext = aContainerFrame->PresContext(); @@ -623,8 +623,8 @@ public: */ void ProcessDisplayItems(nsDisplayList* aList); /** - * This finalizes all the open ThebesLayers by popping every element off - * mThebesLayerDataStack, then sets the children of the container layer + * This finalizes all the open PaintedLayers by popping every element off + * mPaintedLayerDataStack, then sets the children of the container layer * to be all the layers in mNewChildLayers in that order and removes any * layers as children of the container that aren't in mNewChildLayers. * @param aTextContentFlags if any child layer has CONTENT_COMPONENT_ALPHA, @@ -694,27 +694,27 @@ public: const nsIntRect* aLayerContentsVisibleRect = nullptr) const; protected: - friend class ThebesLayerData; + friend class PaintedLayerData; /** - * Grab the next recyclable ThebesLayer, or create one if there are no - * more recyclable ThebesLayers. Does any necessary invalidation of - * a recycled ThebesLayer, and sets up the transform on the ThebesLayer + * Grab the next recyclable PaintedLayer, or create one if there are no + * more recyclable PaintedLayers. Does any necessary invalidation of + * a recycled PaintedLayer, and sets up the transform on the PaintedLayer * to account for scrolling. */ - already_AddRefed CreateOrRecycleThebesLayer(const nsIFrame* aAnimatedGeometryRoot, + already_AddRefed CreateOrRecyclePaintedLayer(const nsIFrame* aAnimatedGeometryRoot, const nsIFrame *aReferenceFrame, const nsPoint& aTopLeft); /** * Grab the next recyclable ColorLayer, or create one if there are no * more recyclable ColorLayers. */ - already_AddRefed CreateOrRecycleColorLayer(ThebesLayer* aThebes); + already_AddRefed CreateOrRecycleColorLayer(PaintedLayer* aPainted); /** * Grab the next recyclable ImageLayer, or create one if there are no * more recyclable ImageLayers. */ - already_AddRefed CreateOrRecycleImageLayer(ThebesLayer* aThebes); + already_AddRefed CreateOrRecycleImageLayer(PaintedLayer* aPainted); /** * Grab a recyclable ImageLayer for use as a mask layer for aLayer (that is a * mask layer which has been used for aLayer before), or create one if such @@ -722,25 +722,25 @@ protected: */ already_AddRefed CreateOrRecycleMaskImageLayerFor(Layer* aLayer); /** - * Grabs all ThebesLayers and ColorLayers from the ContainerLayer and makes them + * Grabs all PaintedLayers and ColorLayers from the ContainerLayer and makes them * available for recycling. */ void CollectOldLayers(); /** - * If aItem used to belong to a ThebesLayer, invalidates the area of - * aItem in that layer. If aNewLayer is a ThebesLayer, invalidates the area of + * If aItem used to belong to a PaintedLayer, invalidates the area of + * aItem in that layer. If aNewLayer is a PaintedLayer, invalidates the area of * aItem in that layer. */ void InvalidateForLayerChange(nsDisplayItem* aItem, - ThebesLayer* aNewLayer); + PaintedLayer* aNewLayer); /** - * Try to determine whether the ThebesLayer at aThebesLayerIndex + * Try to determine whether the PaintedLayer at aPaintedLayerIndex * has a single opaque color behind it, over the entire bounds of its visible * region. * If successful, return that color, otherwise return NS_RGBA(0,0,0,0). */ - nscolor FindOpaqueBackgroundColorFor(int32_t aThebesLayerIndex); + nscolor FindOpaqueBackgroundColorFor(int32_t aPaintedLayerIndex); /** * Find the fixed-pos frame, if any, containing (or equal to) * aAnimatedGeometryRoot. Only return a fixed-pos frame if its viewport @@ -803,21 +803,21 @@ protected: bool* aOpaqueForAnimatedGeometryRootParent); /** - * Indicate that we are done adding items to the ThebesLayer at the top of - * mThebesLayerDataStack. Set the final visible region and opaque-content + * Indicate that we are done adding items to the PaintedLayer at the top of + * mPaintedLayerDataStack. Set the final visible region and opaque-content * flag, and pop it off the stack. */ - void PopThebesLayerData(); + void PopPaintedLayerData(); /** - * Find the ThebesLayer to which we should assign the next display item. - * We scan the ThebesLayerData stack to find the topmost ThebesLayer + * Find the PaintedLayer to which we should assign the next display item. + * We scan the PaintedLayerData stack to find the topmost PaintedLayer * that is compatible with the display item (i.e., has the same * active scrolled root), and that has no content from other layers above * it and intersecting the aVisibleRect. - * Returns the layer, and also updates the ThebesLayerData. Will - * push a new ThebesLayerData onto the stack if no suitable existing - * layer is found. If we choose a ThebesLayer that's already on the - * ThebesLayerData stack, later elements on the stack will be popped off. + * Returns the layer, and also updates the PaintedLayerData. Will + * push a new PaintedLayerData onto the stack if no suitable existing + * layer is found. If we choose a PaintedLayer that's already on the + * PaintedLayerData stack, later elements on the stack will be popped off. * @param aVisibleRect the area of the next display item that's visible * @param aAnimatedGeometryRoot the active scrolled root for the next * display item @@ -828,15 +828,15 @@ protected: * and we will be adding fixed-pos metadata for this layer because the * display item returned true from ShouldFixToViewport. */ - ThebesLayerData* FindThebesLayerFor(nsDisplayItem* aItem, + PaintedLayerData* FindPaintedLayerFor(nsDisplayItem* aItem, const nsIntRect& aVisibleRect, const nsIFrame* aAnimatedGeometryRoot, const nsPoint& aTopLeft, bool aShouldFixToViewport); - ThebesLayerData* GetTopThebesLayerData() + PaintedLayerData* GetTopPaintedLayerData() { - return mThebesLayerDataStack.IsEmpty() ? nullptr - : mThebesLayerDataStack[mThebesLayerDataStack.Length() - 1].get(); + return mPaintedLayerDataStack.IsEmpty() ? nullptr + : mPaintedLayerDataStack[mPaintedLayerDataStack.Length() - 1].get(); } /* Build a mask layer to represent the clipping region. Will return null if @@ -846,7 +846,7 @@ protected: * aLayer is the layer to be clipped. * aLayerVisibleRegion is the region that will be set as aLayer's visible region, * relative to the container reference frame - * aRoundedRectClipCount is used when building mask layers for ThebesLayers, + * aRoundedRectClipCount is used when building mask layers for PaintedLayers, * SetupMaskLayer will build a mask layer for only the first * aRoundedRectClipCount rounded rects in aClip */ @@ -869,35 +869,35 @@ protected: DebugOnly mAccumulatedChildBounds; ContainerLayerParameters mParameters; /** - * The region of ThebesLayers that should be invalidated every time + * The region of PaintedLayers that should be invalidated every time * we recycle one. */ - nsIntRegion mInvalidThebesContent; - nsAutoTArray,1> mThebesLayerDataStack; + nsIntRegion mInvalidPaintedContent; + nsAutoTArray,1> mPaintedLayerDataStack; /** * We collect the list of children in here. During ProcessDisplayItems, * the layers in this array either have mContainerLayer as their parent, * or no parent. - * ThebesLayers have two entries in this array: the second one is used only if - * the ThebesLayer is optimized away to a ColorLayer or ImageLayer. - * It's essential that this array is only appended to, since ThebesLayerData - * records the index of its ThebesLayer in this array. + * PaintedLayers have two entries in this array: the second one is used only if + * the PaintedLayer is optimized away to a ColorLayer or ImageLayer. + * It's essential that this array is only appended to, since PaintedLayerData + * records the index of its PaintedLayer in this array. */ typedef nsAutoTArray AutoLayersArray; AutoLayersArray mNewChildLayers; - nsTArray > mRecycledThebesLayers; + nsTArray > mRecycledPaintedLayers; nsDataHashtable, nsRefPtr > mRecycledMaskImageLayers; - uint32_t mNextFreeRecycledThebesLayer; + uint32_t mNextFreeRecycledPaintedLayer; nscoord mAppUnitsPerDevPixel; bool mSnappingEnabled; bool mFlattenToSingleLayer; }; -class ThebesDisplayItemLayerUserData : public LayerUserData +class PaintedDisplayItemLayerUserData : public LayerUserData { public: - ThebesDisplayItemLayerUserData() : + PaintedDisplayItemLayerUserData() : mMaskClipCount(0), mForcedBackgroundColor(NS_RGBA(0,0,0,0)), mXScale(1.f), mYScale(1.f), @@ -906,7 +906,7 @@ public: mAnimatedGeometryRootPosition(0, 0) {} /** - * Record the number of clips in the Thebes layer's mask layer. + * Record the number of clips in the PaintedLayer's mask layer. * Should not be reset when the layer is recycled since it is used to track * changes in the use of mask layers. */ @@ -929,21 +929,21 @@ public: nscoord mAppUnitsPerDevPixel; /** - * The offset from the ThebesLayer's 0,0 to the + * The offset from the PaintedLayer's 0,0 to the * reference frame. This isn't necessarily the same as the transform - * set on the ThebesLayer since we might also be applying an extra + * set on the PaintedLayer since we might also be applying an extra * offset specified by the parent ContainerLayer/ */ nsIntPoint mTranslation; /** - * We try to make 0,0 of the ThebesLayer be the top-left of the + * We try to make 0,0 of the PaintedLayer be the top-left of the * border-box of the "active scrolled root" frame (i.e. the nearest ancestor * frame for the display items that is being actively scrolled). But - * we force the ThebesLayer transform to be an integer translation, and we may - * have a resolution scale, so we have to snap the ThebesLayer transform, so + * we force the PaintedLayer transform to be an integer translation, and we may + * have a resolution scale, so we have to snap the PaintedLayer transform, so * 0,0 may not be exactly the top-left of the active scrolled root. Here we - * store the coordinates in ThebesLayer space of the top-left of the + * store the coordinates in PaintedLayer space of the top-left of the * active scrolled root. */ gfxPoint mAnimatedGeometryRootPosition; @@ -993,15 +993,15 @@ struct MaskLayerUserData : public LayerUserData }; /** - * The address of gThebesDisplayItemLayerUserData is used as the user - * data key for ThebesLayers created by FrameLayerBuilder. - * It identifies ThebesLayers used to draw non-layer content, which are + * The address of gPaintedDisplayItemLayerUserData is used as the user + * data key for PaintedLayers created by FrameLayerBuilder. + * It identifies PaintedLayers used to draw non-layer content, which are * therefore eligible for recycling. We want display items to be able to - * create their own dedicated ThebesLayers in BuildLayer, if necessary, + * create their own dedicated PaintedLayers in BuildLayer, if necessary, * and we wouldn't want to accidentally recycle those. - * The user data is a ThebesDisplayItemLayerUserData. + * The user data is a PaintedDisplayItemLayerUserData. */ -uint8_t gThebesDisplayItemLayerUserData; +uint8_t gPaintedDisplayItemLayerUserData; /** * The address of gColorLayerUserData is used as the user * data key for ColorLayers created by FrameLayerBuilder. @@ -1036,10 +1036,10 @@ MaskLayerUserData* GetMaskLayerUserData(Layer* aLayer) return static_cast(aLayer->GetUserData(&gMaskLayerUserData)); } -ThebesDisplayItemLayerUserData* GetThebesDisplayItemLayerUserData(Layer* aLayer) +PaintedDisplayItemLayerUserData* GetPaintedDisplayItemLayerUserData(Layer* aLayer) { - return static_cast( - aLayer->GetUserData(&gThebesDisplayItemLayerUserData)); + return static_cast( + aLayer->GetUserData(&gPaintedDisplayItemLayerUserData)); } /* static */ void @@ -1053,14 +1053,14 @@ FrameLayerBuilder::Shutdown() void FrameLayerBuilder::Init(nsDisplayListBuilder* aBuilder, LayerManager* aManager, - ThebesLayerData* aLayerData) + PaintedLayerData* aLayerData) { mDisplayListBuilder = aBuilder; mRootPresContext = aBuilder->RootReferenceFrame()->PresContext()->GetRootPresContext(); if (mRootPresContext) { mInitialDOMGeneration = mRootPresContext->GetDOMGeneration(); } - mContainingThebesLayer = aLayerData; + mContainingPaintedLayer = aLayerData; aManager->SetUserData(&gLayerManagerLayerBuilder, this); } @@ -1124,12 +1124,12 @@ AppendToString(nsACString& s, const nsIntRegion& r, * apply the inverse of that transform before calling InvalidateRegion. */ static void -InvalidatePostTransformRegion(ThebesLayer* aLayer, const nsIntRegion& aRegion, +InvalidatePostTransformRegion(PaintedLayer* aLayer, const nsIntRegion& aRegion, const nsIntPoint& aTranslation) { // Convert the region from the coordinates of the container layer // (relative to the snapped top-left of the display list reference frame) - // to the ThebesLayer's own coordinates + // to the PaintedLayer's own coordinates nsIntRegion rgn = aRegion; rgn.MoveBy(-aTranslation); aLayer->InvalidateRegion(rgn); @@ -1143,12 +1143,12 @@ InvalidatePostTransformRegion(ThebesLayer* aLayer, const nsIntRegion& aRegion, } static void -InvalidatePostTransformRegion(ThebesLayer* aLayer, const nsRect& aRect, +InvalidatePostTransformRegion(PaintedLayer* aLayer, const nsRect& aRect, const DisplayItemClip& aClip, const nsIntPoint& aTranslation) { - ThebesDisplayItemLayerUserData* data = - static_cast(aLayer->GetUserData(&gThebesDisplayItemLayerUserData)); + PaintedDisplayItemLayerUserData* data = + static_cast(aLayer->GetUserData(&gPaintedDisplayItemLayerUserData)); nsRect rect = aClip.ApplyNonRoundedIntersection(aRect); @@ -1158,12 +1158,12 @@ InvalidatePostTransformRegion(ThebesLayer* aLayer, const nsRect& aRect, static nsIntPoint -GetTranslationForThebesLayer(ThebesLayer* aLayer) +GetTranslationForPaintedLayer(PaintedLayer* aLayer) { - ThebesDisplayItemLayerUserData* data = - static_cast - (aLayer->GetUserData(&gThebesDisplayItemLayerUserData)); - NS_ASSERTION(data, "Must be a tracked thebes layer!"); + PaintedDisplayItemLayerUserData* data = + static_cast + (aLayer->GetUserData(&gPaintedDisplayItemLayerUserData)); + NS_ASSERTION(data, "Must be a tracked painted layer!"); return data->mTranslation; } @@ -1213,16 +1213,16 @@ FrameLayerBuilder::RemoveFrameFromLayerManager(nsIFrame* aFrame, for (uint32_t i = 0; i < array->Length(); ++i) { DisplayItemData* data = array->ElementAt(i); - ThebesLayer* t = data->mLayer->AsThebesLayer(); + PaintedLayer* t = data->mLayer->AsPaintedLayer(); if (t) { - ThebesDisplayItemLayerUserData* thebesData = - static_cast(t->GetUserData(&gThebesDisplayItemLayerUserData)); - if (thebesData) { + PaintedDisplayItemLayerUserData* paintedData = + static_cast(t->GetUserData(&gPaintedDisplayItemLayerUserData)); + if (paintedData) { nsRegion old = data->mGeometry->ComputeInvalidationRegion(); - nsIntRegion rgn = old.ScaleToOutsidePixels(thebesData->mXScale, thebesData->mYScale, thebesData->mAppUnitsPerDevPixel); - rgn.MoveBy(-GetTranslationForThebesLayer(t)); - thebesData->mRegionToInvalidate.Or(thebesData->mRegionToInvalidate, rgn); - thebesData->mRegionToInvalidate.SimplifyOutward(8); + nsIntRegion rgn = old.ScaleToOutsidePixels(paintedData->mXScale, paintedData->mYScale, paintedData->mAppUnitsPerDevPixel); + rgn.MoveBy(-GetTranslationForPaintedLayer(t)); + paintedData->mRegionToInvalidate.Or(paintedData->mRegionToInvalidate, rgn); + paintedData->mRegionToInvalidate.SimplifyOutward(8); } } @@ -1291,7 +1291,7 @@ FrameLayerBuilder::ProcessRemovedDisplayItems(nsRefPtrHashKey* if (!data->mUsed) { // This item was visible, but isn't anymore. - ThebesLayer* t = data->mLayer->AsThebesLayer(); + PaintedLayer* t = data->mLayer->AsPaintedLayer(); if (t && data->mGeometry) { #ifdef MOZ_DUMP_PAINTING if (nsLayoutUtils::InvalidationDebuggingIsEnabled()) { @@ -1488,10 +1488,10 @@ FrameLayerBuilder::GetDebugOldLayerFor(nsIFrame* aFrame, uint32_t aDisplayItemKe } already_AddRefed -ContainerState::CreateOrRecycleColorLayer(ThebesLayer *aThebes) +ContainerState::CreateOrRecycleColorLayer(PaintedLayer *aPainted) { - ThebesDisplayItemLayerUserData* data = - static_cast(aThebes->GetUserData(&gThebesDisplayItemLayerUserData)); + PaintedDisplayItemLayerUserData* data = + static_cast(aPainted->GetUserData(&gPaintedDisplayItemLayerUserData)); nsRefPtr layer = data->mColorLayer; if (layer) { layer->SetMaskLayer(nullptr); @@ -1501,21 +1501,21 @@ ContainerState::CreateOrRecycleColorLayer(ThebesLayer *aThebes) layer = mManager->CreateColorLayer(); if (!layer) return nullptr; - // Mark this layer as being used for Thebes-painting display items + // Mark this layer as being used for painting display items data->mColorLayer = layer; layer->SetUserData(&gColorLayerUserData, nullptr); - // Remove other layer types we might have stored for this ThebesLayer + // Remove other layer types we might have stored for this PaintedLayer data->mImageLayer = nullptr; } return layer.forget(); } already_AddRefed -ContainerState::CreateOrRecycleImageLayer(ThebesLayer *aThebes) +ContainerState::CreateOrRecycleImageLayer(PaintedLayer *aPainted) { - ThebesDisplayItemLayerUserData* data = - static_cast(aThebes->GetUserData(&gThebesDisplayItemLayerUserData)); + PaintedDisplayItemLayerUserData* data = + static_cast(aPainted->GetUserData(&gPaintedDisplayItemLayerUserData)); nsRefPtr layer = data->mImageLayer; if (layer) { layer->SetMaskLayer(nullptr); @@ -1525,11 +1525,11 @@ ContainerState::CreateOrRecycleImageLayer(ThebesLayer *aThebes) layer = mManager->CreateImageLayer(); if (!layer) return nullptr; - // Mark this layer as being used for Thebes-painting display items + // Mark this layer as being used for painting display items data->mImageLayer = layer; layer->SetUserData(&gImageLayerUserData, nullptr); - // Remove other layer types we might have stored for this ThebesLayer + // Remove other layer types we might have stored for this PaintedLayer data->mColorLayer = nullptr; } return layer.forget(); @@ -1593,7 +1593,7 @@ ResetScrollPositionForLayerPixelAlignment(const nsIFrame* aAnimatedGeometryRoot) } static void -InvalidateEntireThebesLayer(ThebesLayer* aLayer, const nsIFrame* aAnimatedGeometryRoot) +InvalidateEntirePaintedLayer(PaintedLayer* aLayer, const nsIFrame* aAnimatedGeometryRoot) { #ifdef MOZ_DUMP_PAINTING if (nsLayoutUtils::InvalidationDebuggingIsEnabled()) { @@ -1606,14 +1606,14 @@ InvalidateEntireThebesLayer(ThebesLayer* aLayer, const nsIFrame* aAnimatedGeomet ResetScrollPositionForLayerPixelAlignment(aAnimatedGeometryRoot); } -already_AddRefed -ContainerState::CreateOrRecycleThebesLayer(const nsIFrame* aAnimatedGeometryRoot, +already_AddRefed +ContainerState::CreateOrRecyclePaintedLayer(const nsIFrame* aAnimatedGeometryRoot, const nsIFrame* aReferenceFrame, const nsPoint& aTopLeft) { - // We need a new thebes layer - nsRefPtr layer; - ThebesDisplayItemLayerUserData* data; + // We need a new painted layer + nsRefPtr layer; + PaintedDisplayItemLayerUserData* data; bool layerRecycled = false; #ifndef MOZ_WIDGET_ANDROID bool didResetScrollPositionForLayerPixelAlignment = false; @@ -1621,7 +1621,7 @@ ContainerState::CreateOrRecycleThebesLayer(const nsIFrame* aAnimatedGeometryRoot // Check whether the layer will be scrollable. This is used as a hint to // influence whether tiled layers are used or not. - LayerManager::ThebesLayerCreationHint creationHint = LayerManager::NONE; + LayerManager::PaintedLayerCreationHint creationHint = LayerManager::NONE; if (mParameters.mInLowPrecisionDisplayPort ) { creationHint = LayerManager::SCROLLABLE; } @@ -1631,14 +1631,14 @@ ContainerState::CreateOrRecycleThebesLayer(const nsIFrame* aAnimatedGeometryRoot creationHint = LayerManager::SCROLLABLE; } - if (mNextFreeRecycledThebesLayer < mRecycledThebesLayers.Length()) { + if (mNextFreeRecycledPaintedLayer < mRecycledPaintedLayers.Length()) { // Try to recycle a layer - layer = mRecycledThebesLayers[mNextFreeRecycledThebesLayer]; - ++mNextFreeRecycledThebesLayer; + layer = mRecycledPaintedLayers[mNextFreeRecycledPaintedLayer]; + ++mNextFreeRecycledPaintedLayer; // Check if the layer hint has changed and whether or not the layer should // be recreated because of it. - if (mManager->IsOptimizedFor(layer->AsThebesLayer(), creationHint)) { + if (mManager->IsOptimizedFor(layer->AsPaintedLayer(), creationHint)) { layerRecycled = true; // Clear clip rect and mask layer so we don't accidentally stay clipped. @@ -1646,17 +1646,17 @@ ContainerState::CreateOrRecycleThebesLayer(const nsIFrame* aAnimatedGeometryRoot layer->SetMaskLayer(nullptr); layer->ClearExtraDumpInfo(); - data = static_cast - (layer->GetUserData(&gThebesDisplayItemLayerUserData)); - NS_ASSERTION(data, "Recycled ThebesLayers must have user data"); + data = static_cast + (layer->GetUserData(&gPaintedDisplayItemLayerUserData)); + NS_ASSERTION(data, "Recycled PaintedLayers must have user data"); - // This gets called on recycled ThebesLayers that are going to be in the + // This gets called on recycled PaintedLayers that are going to be in the // final layer tree, so it's a convenient time to invalidate the - // content that changed where we don't know what ThebesLayer it belonged + // content that changed where we don't know what PaintedLayer it belonged // to, or if we need to invalidate the entire layer, we can do that. - // This needs to be done before we update the ThebesLayer to its new + // This needs to be done before we update the PaintedLayer to its new // transform. See nsGfxScrollFrame::InvalidateInternal, where - // we ensure that mInvalidThebesContent is updated according to the + // we ensure that mInvalidPaintedContent is updated according to the // scroll position as of the most recent paint. if (!FuzzyEqual(data->mXScale, mParameters.mXScale, 0.00001f) || !FuzzyEqual(data->mYScale, mParameters.mYScale, 0.00001f) || @@ -1666,7 +1666,7 @@ ContainerState::CreateOrRecycleThebesLayer(const nsIFrame* aAnimatedGeometryRoot printf_stderr("Recycled layer %p changed scale\n", layer.get()); } #endif - InvalidateEntireThebesLayer(layer, aAnimatedGeometryRoot); + InvalidateEntirePaintedLayer(layer, aAnimatedGeometryRoot); #ifndef MOZ_WIDGET_ANDROID didResetScrollPositionForLayerPixelAlignment = true; #endif @@ -1689,19 +1689,19 @@ ContainerState::CreateOrRecycleThebesLayer(const nsIFrame* aAnimatedGeometryRoot } // We do not need to Invalidate these areas in the widget because we - // assume the caller of InvalidateThebesLayerContents has ensured + // assume the caller of InvalidatePaintedLayerContents has ensured // the area is invalidated in the widget. } } if (!layerRecycled) { - // Create a new thebes layer - layer = mManager->CreateThebesLayerWithHint(creationHint); + // Create a new painted layer + layer = mManager->CreatePaintedLayerWithHint(creationHint); if (!layer) return nullptr; - // Mark this layer as being used for Thebes-painting display items - data = new ThebesDisplayItemLayerUserData(); - layer->SetUserData(&gThebesDisplayItemLayerUserData, data); + // Mark this layer as being used for painting display items + data = new PaintedDisplayItemLayerUserData(); + layer->SetUserData(&gPaintedDisplayItemLayerUserData, data); ResetScrollPositionForLayerPixelAlignment(aAnimatedGeometryRoot); #ifndef MOZ_WIDGET_ANDROID didResetScrollPositionForLayerPixelAlignment = true; @@ -1716,7 +1716,7 @@ ContainerState::CreateOrRecycleThebesLayer(const nsIFrame* aAnimatedGeometryRoot mLayerBuilder->SavePreviousDataForLayer(layer, data->mMaskClipCount); - // Set up transform so that 0,0 in the Thebes layer corresponds to the + // Set up transform so that 0,0 in the Painted layer corresponds to the // (pixel-snapped) top-left of the aAnimatedGeometryRoot. nsPoint offset = aAnimatedGeometryRoot->GetOffsetToCrossDoc(aReferenceFrame); nscoord appUnitsPerDevPixel = aAnimatedGeometryRoot->PresContext()->AppUnitsPerDevPixel(); @@ -1742,7 +1742,7 @@ ContainerState::CreateOrRecycleThebesLayer(const nsIFrame* aAnimatedGeometryRoot // from what we need. if (!animatedGeometryRootTopLeft.WithinEpsilonOf(data->mAnimatedGeometryRootPosition, SUBPIXEL_OFFSET_EPSILON)) { data->mAnimatedGeometryRootPosition = animatedGeometryRootTopLeft; - InvalidateEntireThebesLayer(layer, aAnimatedGeometryRoot); + InvalidateEntirePaintedLayer(layer, aAnimatedGeometryRoot); } else if (didResetScrollPositionForLayerPixelAlignment) { data->mAnimatedGeometryRootPosition = animatedGeometryRootTopLeft; } @@ -1829,13 +1829,13 @@ ContainerState::SetOuterVisibleRegionForLayer(Layer* aLayer, } nscolor -ContainerState::FindOpaqueBackgroundColorFor(int32_t aThebesLayerIndex) +ContainerState::FindOpaqueBackgroundColorFor(int32_t aPaintedLayerIndex) { - ThebesLayerData* target = mThebesLayerDataStack[aThebesLayerIndex]; - for (int32_t i = aThebesLayerIndex - 1; i >= 0; --i) { - ThebesLayerData* candidate = mThebesLayerDataStack[i]; + PaintedLayerData* target = mPaintedLayerDataStack[aPaintedLayerIndex]; + for (int32_t i = aPaintedLayerIndex - 1; i >= 0; --i) { + PaintedLayerData* candidate = mPaintedLayerDataStack[i]; if (candidate->IntersectsVisibleAboveRegion(target->mVisibleRegion)) { - // Some non-Thebes content between target and candidate; this is + // Some non-PaintedLayer content between target and candidate; this is // hopeless break; } @@ -1853,8 +1853,8 @@ ContainerState::FindOpaqueBackgroundColorFor(int32_t aThebesLayerIndex) nsRect appUnitRect = deviceRect.ToAppUnits(mAppUnitsPerDevPixel); appUnitRect.ScaleInverseRoundOut(mParameters.mXScale, mParameters.mYScale); - FrameLayerBuilder::ThebesLayerItemsEntry* entry = - mLayerBuilder->GetThebesLayerItemsEntry(candidate->mLayer); + FrameLayerBuilder::PaintedLayerItemsEntry* entry = + mLayerBuilder->GetPaintedLayerItemsEntry(candidate->mLayer); NS_ASSERTION(entry, "Must know about this layer!"); for (int32_t j = entry->mItems.Length() - 1; j >= 0; --j) { nsDisplayItem* item = entry->mItems[j].mItem; @@ -1901,7 +1901,7 @@ ContainerState::FindOpaqueBackgroundColorFor(int32_t aThebesLayerIndex) } void -ThebesLayerData::UpdateCommonClipCount( +PaintedLayerData::UpdateCommonClipCount( const DisplayItemClip& aCurrentClip) { if (!mLayer->Manager()->IsWidgetLayerManager()) { @@ -1917,7 +1917,7 @@ ThebesLayerData::UpdateCommonClipCount( } already_AddRefed -ThebesLayerData::CanOptimizeImageLayer(nsDisplayListBuilder* aBuilder) +PaintedLayerData::CanOptimizeImageLayer(nsDisplayListBuilder* aBuilder) { if (!mImage) { return nullptr; @@ -2042,23 +2042,23 @@ ContainerState::SetFixedPositionLayerData(Layer* aLayer, } static bool -CanOptimizeAwayThebesLayer(ThebesLayerData* aData, +CanOptimizeAwayPaintedLayer(PaintedLayerData* aData, FrameLayerBuilder* aLayerBuilder) { if (!aLayerBuilder->IsBuildingRetainedLayers()) { return false; } - // If there's no thebes layer with valid content in it that we can reuse, + // If there's no painted layer with valid content in it that we can reuse, // always create a color or image layer (and potentially throw away an - // existing completely invalid thebes layer). + // existing completely invalid painted layer). if (aData->mLayer->GetValidRegion().IsEmpty()) { return true; } - // There is an existing thebes layer we can reuse. Throwing it away can make + // There is an existing painted layer we can reuse. Throwing it away can make // compositing cheaper (see bug 946952), but it might cause us to re-allocate - // the thebes layer frequently due to an animation. So we only discard it if + // the painted layer frequently due to an animation. So we only discard it if // we're in tree compression mode, which is triggered at a low frequency. return aLayerBuilder->CheckInLayerTreeCompressionMode(); } @@ -2077,12 +2077,12 @@ static int32_t FindIndexOfLayerIn(nsTArray& aArray, #endif void -ContainerState::PopThebesLayerData() +ContainerState::PopPaintedLayerData() { - NS_ASSERTION(!mThebesLayerDataStack.IsEmpty(), "Can't pop"); + NS_ASSERTION(!mPaintedLayerDataStack.IsEmpty(), "Can't pop"); - int32_t lastIndex = mThebesLayerDataStack.Length() - 1; - ThebesLayerData* data = mThebesLayerDataStack[lastIndex]; + int32_t lastIndex = mPaintedLayerDataStack.Length() - 1; + PaintedLayerData* data = mPaintedLayerDataStack[lastIndex]; AdjustLayerDataForFixedPositioning(data->mFixedPosFrameForLayerData, data->mDrawRegion, @@ -2093,13 +2093,13 @@ ContainerState::PopThebesLayerData() nsRefPtr layer; nsRefPtr imageContainer = data->CanOptimizeImageLayer(mBuilder); - FLB_LOG_THEBES_DECISION(data, "Selecting layer for tld=%p\n", data); - FLB_LOG_THEBES_DECISION(data, " Solid=%i, hasImage=%i, canOptimizeAwayThebes=%i\n", + FLB_LOG_PAINTED_LAYER_DECISION(data, "Selecting layer for tld=%p\n", data); + FLB_LOG_PAINTED_LAYER_DECISION(data, " Solid=%i, hasImage=%i, canOptimizeAwayPaintedLayer=%i\n", data->mIsSolidColorInVisibleRegion, !!imageContainer, - CanOptimizeAwayThebesLayer(data, mLayerBuilder)); + CanOptimizeAwayPaintedLayer(data, mLayerBuilder)); if ((data->mIsSolidColorInVisibleRegion || imageContainer) && - CanOptimizeAwayThebesLayer(data, mLayerBuilder)) { + CanOptimizeAwayPaintedLayer(data, mLayerBuilder)) { NS_ASSERTION(!(data->mIsSolidColorInVisibleRegion && imageContainer), "Can't be a solid color as well as an image!"); if (imageContainer) { @@ -2118,7 +2118,7 @@ ContainerState::PopThebesLayerData() layer = imageLayer; mLayerBuilder->StoreOptimizedLayerForFrame(data->mImage, imageLayer); - FLB_LOG_THEBES_DECISION(data, " Selected image layer=%p\n", layer.get()); + FLB_LOG_PAINTED_LAYER_DECISION(data, " Selected image layer=%p\n", layer.get()); } else { nsRefPtr colorLayer = CreateOrRecycleColorLayer(data->mLayer); colorLayer->SetColor(data->mSolidColor); @@ -2128,17 +2128,17 @@ ContainerState::PopThebesLayerData() colorLayer->SetPostScale(data->mLayer->GetPostXScale(), data->mLayer->GetPostYScale()); nsIntRect visibleRect = data->mVisibleRegion.GetBounds(); - visibleRect.MoveBy(-GetTranslationForThebesLayer(data->mLayer)); + visibleRect.MoveBy(-GetTranslationForPaintedLayer(data->mLayer)); colorLayer->SetBounds(visibleRect); layer = colorLayer; - FLB_LOG_THEBES_DECISION(data, " Selected color layer=%p\n", layer.get()); + FLB_LOG_PAINTED_LAYER_DECISION(data, " Selected color layer=%p\n", layer.get()); } NS_ASSERTION(FindIndexOfLayerIn(mNewChildLayers, layer) < 0, "Layer already in list???"); NS_ASSERTION(newLayerEntry->mLayer == data->mLayer, - "Thebes layer at wrong index"); + "Painted layer at wrong index"); // Store optimized layer in reserved slot newLayerEntry = &mNewChildLayers[data->mNewChildLayersIndex + 1]; NS_ASSERTION(!newLayerEntry->mLayer, "Slot already occupied?"); @@ -2146,7 +2146,7 @@ ContainerState::PopThebesLayerData() newLayerEntry->mAnimatedGeometryRoot = data->mAnimatedGeometryRoot; newLayerEntry->mFixedPosFrameForLayerData = data->mFixedPosFrameForLayerData; - // Hide the ThebesLayer. We leave it in the layer tree so that we + // Hide the PaintedLayer. We leave it in the layer tree so that we // can find and recycle it later. nsIntRect emptyRect; data->mLayer->SetClipRect(&emptyRect); @@ -2157,7 +2157,7 @@ ContainerState::PopThebesLayerData() layer = data->mLayer; imageContainer = nullptr; layer->SetClipRect(nullptr); - FLB_LOG_THEBES_DECISION(data, " Selected thebes layer=%p\n", layer.get()); + FLB_LOG_PAINTED_LAYER_DECISION(data, " Selected painted layer=%p\n", layer.get()); } if (mLayerBuilder->IsBuildingRetainedLayers()) { @@ -2170,7 +2170,7 @@ ContainerState::PopThebesLayerData() } nsIntRect layerBounds = data->mBounds.GetBounds(); - layerBounds.MoveBy(-GetTranslationForThebesLayer(data->mLayer)); + layerBounds.MoveBy(-GetTranslationForPaintedLayer(data->mLayer)); layer->SetLayerBounds(layerBounds); #ifdef MOZ_DUMP_PAINTING @@ -2180,7 +2180,7 @@ ContainerState::PopThebesLayerData() nsIntRegion transparentRegion; transparentRegion.Sub(data->mVisibleRegion, data->mOpaqueRegion); bool isOpaque = transparentRegion.IsEmpty(); - // For translucent ThebesLayers, try to find an opaque background + // For translucent PaintedLayers, try to find an opaque background // color that covers the entire area beneath it so we can pull that // color into this layer to make it opaque. if (layer == data->mLayer) { @@ -2193,11 +2193,11 @@ ContainerState::PopThebesLayerData() } // Store the background color - ThebesDisplayItemLayerUserData* userData = - GetThebesDisplayItemLayerUserData(data->mLayer); + PaintedDisplayItemLayerUserData* userData = + GetPaintedDisplayItemLayerUserData(data->mLayer); NS_ASSERTION(userData, "where did our user data go?"); if (userData->mForcedBackgroundColor != backgroundColor) { - // Invalidate the entire target ThebesLayer since we're changing + // Invalidate the entire target PaintedLayer since we're changing // the background color #ifdef MOZ_DUMP_PAINTING if (nsLayoutUtils::InvalidationDebuggingIsEnabled()) { @@ -2218,8 +2218,8 @@ ContainerState::PopThebesLayerData() int32_t commonClipCount = std::max(0, data->mCommonClipCount); SetupMaskLayer(layer, data->mItemClip, data->mVisibleRegion, commonClipCount); // copy commonClipCount to the entry - FrameLayerBuilder::ThebesLayerItemsEntry* entry = mLayerBuilder-> - GetThebesLayerItemsEntry(static_cast(layer.get())); + FrameLayerBuilder::PaintedLayerItemsEntry* entry = mLayerBuilder-> + GetPaintedLayerItemsEntry(static_cast(layer.get())); entry->mCommonClipCount = commonClipCount; } else { // mask layer for image and color layers @@ -2242,38 +2242,38 @@ ContainerState::PopThebesLayerData() SetFixedPositionLayerData(layer, data->mFixedPosFrameForLayerData); - ThebesLayerData* containingThebesLayerData = - mLayerBuilder->GetContainingThebesLayerData(); - if (containingThebesLayerData) { + PaintedLayerData* containingPaintedLayerData = + mLayerBuilder->GetContainingPaintedLayerData(); + if (containingPaintedLayerData) { if (!data->mDispatchToContentHitRegion.GetBounds().IsEmpty()) { nsRect rect = nsLayoutUtils::TransformFrameRectToAncestor( mContainerReferenceFrame, data->mDispatchToContentHitRegion.GetBounds(), - containingThebesLayerData->mReferenceFrame); - containingThebesLayerData->mDispatchToContentHitRegion.Or( - containingThebesLayerData->mDispatchToContentHitRegion, rect); + containingPaintedLayerData->mReferenceFrame); + containingPaintedLayerData->mDispatchToContentHitRegion.Or( + containingPaintedLayerData->mDispatchToContentHitRegion, rect); } if (!data->mMaybeHitRegion.GetBounds().IsEmpty()) { nsRect rect = nsLayoutUtils::TransformFrameRectToAncestor( mContainerReferenceFrame, data->mMaybeHitRegion.GetBounds(), - containingThebesLayerData->mReferenceFrame); - containingThebesLayerData->mMaybeHitRegion.Or( - containingThebesLayerData->mMaybeHitRegion, rect); + containingPaintedLayerData->mReferenceFrame); + containingPaintedLayerData->mMaybeHitRegion.Or( + containingPaintedLayerData->mMaybeHitRegion, rect); } if (!data->mHitRegion.GetBounds().IsEmpty()) { // Our definitely-hit region must go to the maybe-hit-region since // this function is an approximation. Matrix4x4 matrix = nsLayoutUtils::GetTransformToAncestor( - mContainerReferenceFrame, containingThebesLayerData->mReferenceFrame); + mContainerReferenceFrame, containingPaintedLayerData->mReferenceFrame); Matrix matrix2D; bool isPrecise = matrix.Is2D(&matrix2D) && !matrix2D.HasNonAxisAlignedTransform(); nsRect rect = nsLayoutUtils::TransformFrameRectToAncestor( mContainerReferenceFrame, data->mHitRegion.GetBounds(), - containingThebesLayerData->mReferenceFrame); - nsRegion* dest = isPrecise ? &containingThebesLayerData->mHitRegion - : &containingThebesLayerData->mMaybeHitRegion; + containingPaintedLayerData->mReferenceFrame); + nsRegion* dest = isPrecise ? &containingPaintedLayerData->mHitRegion + : &containingPaintedLayerData->mMaybeHitRegion; dest->Or(*dest, rect); } } else { @@ -2286,7 +2286,7 @@ ContainerState::PopThebesLayerData() regions.mDispatchToContentHitRegion.Or(regions.mDispatchToContentHitRegion, ScaleRegionToOutsidePixels(data->mDispatchToContentHitRegion)); - nsIntPoint translation = -GetTranslationForThebesLayer(data->mLayer); + nsIntPoint translation = -GetTranslationForPaintedLayer(data->mLayer); regions.mHitRegion.MoveBy(translation); regions.mDispatchToContentHitRegion.MoveBy(translation); @@ -2294,14 +2294,14 @@ ContainerState::PopThebesLayerData() } if (lastIndex > 0) { - // Since we're going to pop off the last ThebesLayerData, the + // Since we're going to pop off the last PaintedLayerData, the // mVisibleAboveRegion of the second-to-last item will need to include // the regions of the last item. - ThebesLayerData* nextData = mThebesLayerDataStack[lastIndex - 1]; + PaintedLayerData* nextData = mPaintedLayerDataStack[lastIndex - 1]; nextData->CopyAboveRegion(data); } - mThebesLayerDataStack.RemoveElementAt(lastIndex); + mPaintedLayerDataStack.RemoveElementAt(lastIndex); } static bool @@ -2324,14 +2324,14 @@ IsItemAreaInWindowOpaqueRegion(nsDisplayListBuilder* aBuilder, } void -ThebesLayerData::Accumulate(ContainerState* aState, +PaintedLayerData::Accumulate(ContainerState* aState, nsDisplayItem* aItem, const nsIntRegion& aClippedOpaqueRegion, const nsIntRect& aVisibleRect, const nsIntRect& aDrawRect, const DisplayItemClip& aClip) { - FLB_LOG_THEBES_DECISION(this, "Accumulating dp=%s(%p), f=%p against tld=%p\n", aItem->Name(), aItem, aItem->Frame(), this); + FLB_LOG_PAINTED_LAYER_DECISION(this, "Accumulating dp=%s(%p), f=%p against tld=%p\n", aItem->Name(), aItem, aItem->Frame(), this); bool snap; nsRect itemBounds = aItem->GetBounds(aState->mBuilder, &snap); @@ -2342,7 +2342,7 @@ ThebesLayerData::Accumulate(ContainerState* aState, } if (aState->mParameters.mDisableSubpixelAntialiasingInDescendants) { // Disable component alpha. - // Note that the transform (if any) on the ThebesLayer is always an integer translation so + // Note that the transform (if any) on the PaintedLayer is always an integer translation so // we don't have to factor that in here. aItem->DisableComponentAlpha(); } @@ -2352,7 +2352,7 @@ ThebesLayerData::Accumulate(ContainerState* aState, if (!mIsSolidColorInVisibleRegion && mOpaqueRegion.Contains(aDrawRect) && mVisibleRegion.Contains(aVisibleRect) && !mImage) { - // A very common case! Most pages have a ThebesLayer with the page + // A very common case! Most pages have a PaintedLayer with the page // background (opaque) visible and most or all of the page content over the // top of that background. // The rest of this method won't do anything. mVisibleRegion, mOpaqueRegion @@ -2371,9 +2371,9 @@ ThebesLayerData::Accumulate(ContainerState* aState, aClippedOpaqueRegion.Contains(mVisibleRegion) && aItem->SupportsOptimizingToImage()) { mImage = static_cast(aItem); - FLB_LOG_THEBES_DECISION(this, " Tracking image: nsDisplayImageContainer covers the layer\n"); + FLB_LOG_PAINTED_LAYER_DECISION(this, " Tracking image: nsDisplayImageContainer covers the layer\n"); } else if (mImage) { - FLB_LOG_THEBES_DECISION(this, " No longer tracking image\n"); + FLB_LOG_PAINTED_LAYER_DECISION(this, " No longer tracking image\n"); mImage = nullptr; } @@ -2392,7 +2392,7 @@ ThebesLayerData::Accumulate(ContainerState* aState, nsRect bounds = aItem->GetBounds(aState->mBuilder, &snap); if (!aState->ScaleToInsidePixels(bounds, snap).Contains(aVisibleRect)) { isUniform = false; - FLB_LOG_THEBES_DECISION(this, " Display item does not cover the visible rect\n"); + FLB_LOG_PAINTED_LAYER_DECISION(this, " Display item does not cover the visible rect\n"); } } if (isUniform) { @@ -2406,11 +2406,11 @@ ThebesLayerData::Accumulate(ContainerState* aState, // we can just blend the colors together mSolidColor = NS_ComposeColors(mSolidColor, uniformColor); } else { - FLB_LOG_THEBES_DECISION(this, " Layer not a solid color: Can't blend colors togethers\n"); + FLB_LOG_PAINTED_LAYER_DECISION(this, " Layer not a solid color: Can't blend colors togethers\n"); mIsSolidColorInVisibleRegion = false; } } else { - FLB_LOG_THEBES_DECISION(this, " Layer is not a solid color: Display item is not uniform over the visible bound\n"); + FLB_LOG_PAINTED_LAYER_DECISION(this, " Layer is not a solid color: Display item is not uniform over the visible bound\n"); mIsSolidColorInVisibleRegion = false; } @@ -2456,8 +2456,8 @@ ThebesLayerData::Accumulate(ContainerState* aState, } } -ThebesLayerData* -ContainerState::FindThebesLayerFor(nsDisplayItem* aItem, +PaintedLayerData* +ContainerState::FindPaintedLayerFor(nsDisplayItem* aItem, const nsIntRect& aVisibleRect, const nsIFrame* aAnimatedGeometryRoot, const nsPoint& aTopLeft, @@ -2466,13 +2466,13 @@ ContainerState::FindThebesLayerFor(nsDisplayItem* aItem, int32_t i; int32_t lowestUsableLayerWithScrolledRoot = -1; int32_t topmostLayerWithScrolledRoot = -1; - for (i = mThebesLayerDataStack.Length() - 1; i >= 0; --i) { + for (i = mPaintedLayerDataStack.Length() - 1; i >= 0; --i) { // Don't let should-fix-to-viewport items share a layer with any other items. if (aShouldFixToViewport) { ++i; break; } - ThebesLayerData* data = mThebesLayerDataStack[i]; + PaintedLayerData* data = mPaintedLayerDataStack[i]; // Give up if there is content drawn above (in z-order) this layer that // intersects aItem's visible region; aItem must be placed in a // layer above this layer. @@ -2498,7 +2498,7 @@ ContainerState::FindThebesLayerFor(nsDisplayItem* aItem, if (topmostLayerWithScrolledRoot < 0) { --i; for (; i >= 0; --i) { - ThebesLayerData* data = mThebesLayerDataStack[i]; + PaintedLayerData* data = mPaintedLayerDataStack[i]; if (data->mAnimatedGeometryRoot == aAnimatedGeometryRoot) { topmostLayerWithScrolledRoot = i; break; @@ -2507,42 +2507,42 @@ ContainerState::FindThebesLayerFor(nsDisplayItem* aItem, } if (topmostLayerWithScrolledRoot >= 0) { - while (uint32_t(topmostLayerWithScrolledRoot + 1) < mThebesLayerDataStack.Length()) { - PopThebesLayerData(); + while (uint32_t(topmostLayerWithScrolledRoot + 1) < mPaintedLayerDataStack.Length()) { + PopPaintedLayerData(); } } - ThebesLayerData* thebesLayerData = nullptr; + PaintedLayerData* paintedLayerData = nullptr; if (lowestUsableLayerWithScrolledRoot < 0) { - nsRefPtr layer = - CreateOrRecycleThebesLayer(aAnimatedGeometryRoot, aItem->ReferenceFrame(), aTopLeft); + nsRefPtr layer = + CreateOrRecyclePaintedLayer(aAnimatedGeometryRoot, aItem->ReferenceFrame(), aTopLeft); - thebesLayerData = new ThebesLayerData(); - mThebesLayerDataStack.AppendElement(thebesLayerData); - thebesLayerData->mLayer = layer; - thebesLayerData->mAnimatedGeometryRoot = aAnimatedGeometryRoot; - thebesLayerData->mFixedPosFrameForLayerData = + paintedLayerData = new PaintedLayerData(); + mPaintedLayerDataStack.AppendElement(paintedLayerData); + paintedLayerData->mLayer = layer; + paintedLayerData->mAnimatedGeometryRoot = aAnimatedGeometryRoot; + paintedLayerData->mFixedPosFrameForLayerData = FindFixedPosFrameForLayerData(aAnimatedGeometryRoot, aShouldFixToViewport); - thebesLayerData->mReferenceFrame = aItem->ReferenceFrame(); - thebesLayerData->mSingleItemFixedToViewport = aShouldFixToViewport; + paintedLayerData->mReferenceFrame = aItem->ReferenceFrame(); + paintedLayerData->mSingleItemFixedToViewport = aShouldFixToViewport; NS_ASSERTION(FindIndexOfLayerIn(mNewChildLayers, layer) < 0, "Layer already in list???"); - thebesLayerData->mNewChildLayersIndex = mNewChildLayers.Length(); + paintedLayerData->mNewChildLayersIndex = mNewChildLayers.Length(); NewLayerEntry* newLayerEntry = mNewChildLayers.AppendElement(); newLayerEntry->mLayer = layer.forget(); newLayerEntry->mAnimatedGeometryRoot = aAnimatedGeometryRoot; - newLayerEntry->mFixedPosFrameForLayerData = thebesLayerData->mFixedPosFrameForLayerData; + newLayerEntry->mFixedPosFrameForLayerData = paintedLayerData->mFixedPosFrameForLayerData; // newLayerEntry->mOpaqueRegion is filled in later from - // thebesLayerData->mOpaqueRegion, if necessary. + // paintedLayerData->mOpaqueRegion, if necessary. // Allocate another entry for this layer's optimization to ColorLayer/ImageLayer mNewChildLayers.AppendElement(); } else { - thebesLayerData = mThebesLayerDataStack[lowestUsableLayerWithScrolledRoot]; + paintedLayerData = mPaintedLayerDataStack[lowestUsableLayerWithScrolledRoot]; } - return thebesLayerData; + return paintedLayerData; } #ifdef MOZ_DUMP_PAINTING @@ -2565,7 +2565,7 @@ PaintInactiveLayer(nsDisplayListBuilder* aBuilder, gfxContext* aContext, nsRenderingContext* aCtx) { - // This item has an inactive layer. Render it to a ThebesLayer + // This item has an inactive layer. Render it to a PaintedLayer // using a temporary BasicLayerManager. BasicLayerManager* basic = static_cast(aManager); nsRefPtr context = aContext; @@ -2593,7 +2593,7 @@ PaintInactiveLayer(nsDisplayListBuilder* aBuilder, basic->AbortTransaction(); } } else { - basic->EndTransaction(FrameLayerBuilder::DrawThebesLayer, aBuilder); + basic->EndTransaction(FrameLayerBuilder::DrawPaintedLayer, aBuilder); } FrameLayerBuilder *builder = static_cast(basic->GetUserData(&gLayerManagerLayerBuilder)); if (builder) { @@ -2627,7 +2627,7 @@ ContainerState::ChooseAnimatedGeometryRoot(const nsDisplayList& aList, { for (nsDisplayItem* item = aList.GetBottom(); item; item = item->GetAbove()) { LayerState layerState = item->GetLayerState(mBuilder, mManager, mParameters); - // Don't use an item that won't be part of any ThebesLayers to pick the + // Don't use an item that won't be part of any PaintedLayers to pick the // active scrolled root. if (layerState == LAYER_ACTIVE_FORCE) { continue; @@ -2723,15 +2723,15 @@ ContainerState::ComputeOpaqueRect(nsDisplayItem* aItem, /* * Iterate through the non-clip items in aList and its descendants. * For each item we compute the effective clip rect. Each item is assigned - * to a layer. We invalidate the areas in ThebesLayers where an item - * has moved from one ThebesLayer to another. Also, - * aState->mInvalidThebesContent is invalidated in every ThebesLayer. + * to a layer. We invalidate the areas in PaintedLayers where an item + * has moved from one PaintedLayer to another. Also, + * aState->mInvalidPaintedContent is invalidated in every PaintedLayer. * We set the clip rect for items that generated their own layer, and * create a mask layer to do any rounded rect clipping. - * (ThebesLayers don't need a clip rect on the layer, we clip the items + * (PaintedLayers don't need a clip rect on the layer, we clip the items * individually when we draw them.) * We set the visible rect for all layers, although the actual setting - * of visible rects for some ThebesLayers is deferred until the calling + * of visible rects for some PaintedLayers is deferred until the calling * of ContainerState::Finish. */ void @@ -2835,7 +2835,7 @@ ContainerState::ProcessDisplayItems(nsDisplayList* aList) if (mManager->IsWidgetLayerManager()) { animatedGeometryRoot = nsLayoutUtils::GetAnimatedGeometryRootFor(item, mBuilder, mManager); } else { - // For inactive layer subtrees, splitting content into ThebesLayers + // For inactive layer subtrees, splitting content into PaintedLayers // based on animated geometry roots is pointless. It's more efficient // to build the minimum number of layers. animatedGeometryRoot = mContainerAnimatedGeometryRoot; @@ -2867,7 +2867,7 @@ ContainerState::ProcessDisplayItems(nsDisplayList* aList) itemVisibleRect.IsEmpty(), "State is LAYER_ACTIVE_EMPTY but visible rect is not."); - // As long as the new layer isn't going to be a ThebesLayer, + // As long as the new layer isn't going to be a PaintedLayer, // InvalidateForLayerChange doesn't need the new layer pointer. // We also need to check the old data now, because BuildLayer // can overwrite it. @@ -2875,7 +2875,7 @@ ContainerState::ProcessDisplayItems(nsDisplayList* aList) // If the item would have its own layer but is invisible, just hide it. // Note that items without their own layers can't be skipped this - // way, since their ThebesLayer may decide it wants to draw them + // way, since their PaintedLayer may decide it wants to draw them // into its buffer even if they're currently covered. if (itemVisibleRect.IsEmpty() && !item->ShouldBuildLayerEvenIfInvisible(mBuilder)) { @@ -2893,8 +2893,8 @@ ContainerState::ProcessDisplayItems(nsDisplayList* aList) continue; } - NS_ASSERTION(!ownLayer->AsThebesLayer(), - "Should never have created a dedicated Thebes layer!"); + NS_ASSERTION(!ownLayer->AsPaintedLayer(), + "Should never have created a dedicated Painted layer!"); const nsIFrame* fixedPosFrame = FindFixedPosFrameForLayerData(animatedGeometryRoot, shouldFixToViewport); @@ -2931,7 +2931,7 @@ ContainerState::ProcessDisplayItems(nsDisplayList* aList) } else { ownLayer->SetClipRect(nullptr); } - ThebesLayerData* data = GetTopThebesLayerData(); + PaintedLayerData* data = GetTopPaintedLayerData(); if (data) { // Prerendered transform items can be updated without layer building // (async animations or an empty transaction), so we need to put items @@ -2955,7 +2955,7 @@ ContainerState::ProcessDisplayItems(nsDisplayList* aList) // Add the entire bounds rect to the mDrawAboveRegion. // The visible region may be excluding opaque content above the // item, and we need to ensure that that content is not placed - // in a ThebesLayer below the item! + // in a PaintedLayer below the item! data->AddDrawAboveRegion(itemDrawRect); } } @@ -3017,37 +3017,37 @@ ContainerState::ProcessDisplayItems(nsDisplayList* aList) /** * No need to allocate geometry for items that aren't - * part of a ThebesLayer. + * part of a PaintedLayer. */ mLayerBuilder->AddLayerDisplayItem(ownLayer, item, layerState, topLeft, nullptr); } else { - ThebesLayerData* thebesLayerData = - FindThebesLayerFor(item, itemVisibleRect, animatedGeometryRoot, topLeft, + PaintedLayerData* paintedLayerData = + FindPaintedLayerFor(item, itemVisibleRect, animatedGeometryRoot, topLeft, shouldFixToViewport); if (itemType == nsDisplayItem::TYPE_LAYER_EVENT_REGIONS) { nsDisplayLayerEventRegions* eventRegions = static_cast(item); - thebesLayerData->AccumulateEventRegions(eventRegions->HitRegion(), + paintedLayerData->AccumulateEventRegions(eventRegions->HitRegion(), eventRegions->MaybeHitRegion(), eventRegions->DispatchToContentHitRegion()); } else { // check to see if the new item has rounded rect clips in common with // other items in the layer - thebesLayerData->UpdateCommonClipCount(itemClip); + paintedLayerData->UpdateCommonClipCount(itemClip); - InvalidateForLayerChange(item, thebesLayerData->mLayer); + InvalidateForLayerChange(item, paintedLayerData->mLayer); - mLayerBuilder->AddThebesDisplayItem(thebesLayerData, item, itemClip, itemVisibleRect, + mLayerBuilder->AddPaintedDisplayItem(paintedLayerData, item, itemClip, itemVisibleRect, *this, layerState, topLeft); nsIntRegion opaquePixels = ComputeOpaqueRect(item, - animatedGeometryRoot, thebesLayerData->mFixedPosFrameForLayerData, + animatedGeometryRoot, paintedLayerData->mFixedPosFrameForLayerData, itemClip, aList, - &thebesLayerData->mHideAllLayersBelow, - &thebesLayerData->mOpaqueForAnimatedGeometryRootParent); - thebesLayerData->Accumulate(this, item, opaquePixels, + &paintedLayerData->mHideAllLayersBelow, + &paintedLayerData->mOpaqueForAnimatedGeometryRootParent); + paintedLayerData->Accumulate(this, item, opaquePixels, itemVisibleRect, itemDrawRect, itemClip); } } @@ -3062,7 +3062,7 @@ ContainerState::ProcessDisplayItems(nsDisplayList* aList) } void -ContainerState::InvalidateForLayerChange(nsDisplayItem* aItem, ThebesLayer* aNewLayer) +ContainerState::InvalidateForLayerChange(nsDisplayItem* aItem, PaintedLayer* aNewLayer) { NS_ASSERTION(aItem->GetPerFrameKey(), "Display items that render using Thebes must have a key"); @@ -3072,7 +3072,7 @@ ContainerState::InvalidateForLayerChange(nsDisplayItem* aItem, ThebesLayer* aNew if (aNewLayer != oldLayer && oldLayer) { // The item has changed layers. // Invalidate the old bounds in the old layer and new bounds in the new layer. - ThebesLayer* t = oldLayer->AsThebesLayer(); + PaintedLayer* t = oldLayer->AsPaintedLayer(); if (t && oldGeometry) { // Note that whenever the layer's scale changes, we invalidate the whole thing, // so it doesn't matter whether we are using the old scale at last paint @@ -3098,18 +3098,18 @@ void FrameLayerBuilder::ComputeGeometryChangeForItem(DisplayItemData* aData) { nsDisplayItem *item = aData->mItem; - ThebesLayer* thebesLayer = aData->mLayer->AsThebesLayer(); - if (!item || !thebesLayer) { + PaintedLayer* paintedLayer = aData->mLayer->AsPaintedLayer(); + if (!item || !paintedLayer) { aData->EndUpdate(); return; } - ThebesLayerItemsEntry* entry = mThebesLayerItems.GetEntry(thebesLayer); + PaintedLayerItemsEntry* entry = mPaintedLayerItems.GetEntry(paintedLayer); nsAutoPtr geometry(item->AllocateGeometry(mDisplayListBuilder)); - ThebesDisplayItemLayerUserData* layerData = - static_cast(aData->mLayer->GetUserData(&gThebesDisplayItemLayerUserData)); + PaintedDisplayItemLayerUserData* layerData = + static_cast(aData->mLayer->GetUserData(&gPaintedDisplayItemLayerUserData)); nsPoint shift = layerData->mAnimatedGeometryRootOrigin - layerData->mLastAnimatedGeometryRootOrigin; const DisplayItemClip& clip = item->GetClip(); @@ -3122,7 +3122,7 @@ FrameLayerBuilder::ComputeGeometryChangeForItem(DisplayItemData* aData) bool notifyRenderingChanged = true; if (!aData->mGeometry) { // This item is being added for the first time, invalidate its entire area. - //TODO: We call GetGeometry again in AddThebesDisplayItem, we should reuse this. + //TODO: We call GetGeometry again in AddPaintedDisplayItem, we should reuse this. combined = clip.ApplyNonRoundedIntersection(geometry->ComputeInvalidationRegion()); #ifdef MOZ_DUMP_PAINTING if (nsLayoutUtils::InvalidationDebuggingIsEnabled()) { @@ -3190,7 +3190,7 @@ FrameLayerBuilder::ComputeGeometryChangeForItem(DisplayItemData* aData) if (notifyRenderingChanged) { item->NotifyRenderingChanged(); } - InvalidatePostTransformRegion(thebesLayer, + InvalidatePostTransformRegion(paintedLayer, combined.ScaleToOutsidePixels(layerData->mXScale, layerData->mYScale, layerData->mAppUnitsPerDevPixel), layerData->mTranslation); } @@ -3199,7 +3199,7 @@ FrameLayerBuilder::ComputeGeometryChangeForItem(DisplayItemData* aData) } void -FrameLayerBuilder::AddThebesDisplayItem(ThebesLayerData* aLayerData, +FrameLayerBuilder::AddPaintedDisplayItem(PaintedLayerData* aLayerData, nsDisplayItem* aItem, const DisplayItemClip& aClip, const nsIntRect& aItemVisibleRect, @@ -3207,10 +3207,10 @@ FrameLayerBuilder::AddThebesDisplayItem(ThebesLayerData* aLayerData, LayerState aLayerState, const nsPoint& aTopLeft) { - ThebesLayer* layer = aLayerData->mLayer; - ThebesDisplayItemLayerUserData* thebesData = - static_cast - (layer->GetUserData(&gThebesDisplayItemLayerUserData)); + PaintedLayer* layer = aLayerData->mLayer; + PaintedDisplayItemLayerUserData* paintedData = + static_cast + (layer->GetUserData(&gPaintedDisplayItemLayerUserData)); nsRefPtr tempManager; nsIntRect intClip; bool hasClip = false; @@ -3228,19 +3228,19 @@ FrameLayerBuilder::AddThebesDisplayItem(ThebesLayerData* aLayerData, DisplayItemClip* oldClip = nullptr; GetOldLayerFor(aItem, nullptr, &oldClip); hasClip = aClip.ComputeRegionInClips(oldClip, - aTopLeft - thebesData->mLastAnimatedGeometryRootOrigin, + aTopLeft - paintedData->mLastAnimatedGeometryRootOrigin, &clip); if (hasClip) { - intClip = clip.GetBounds().ScaleToOutsidePixels(thebesData->mXScale, - thebesData->mYScale, - thebesData->mAppUnitsPerDevPixel); + intClip = clip.GetBounds().ScaleToOutsidePixels(paintedData->mXScale, + paintedData->mYScale, + paintedData->mAppUnitsPerDevPixel); } } AddLayerDisplayItem(layer, aItem, aLayerState, aTopLeft, tempManager); - ThebesLayerItemsEntry* entry = mThebesLayerItems.PutEntry(layer); + PaintedLayerItemsEntry* entry = mPaintedLayerItems.PutEntry(layer); if (entry) { entry->mContainerLayerFrame = aContainerState.GetContainerFrame(); if (entry->mContainerLayerGeneration == 0) { @@ -3269,7 +3269,7 @@ FrameLayerBuilder::AddThebesDisplayItem(ThebesLayerData* aLayerData, bool snap; nsRect visibleRect = aItem->GetVisibleRect().Intersect(aItem->GetBounds(mDisplayListBuilder, &snap)); - nsIntRegion rgn = visibleRect.ToOutsidePixels(thebesData->mAppUnitsPerDevPixel); + nsIntRegion rgn = visibleRect.ToOutsidePixels(paintedData->mAppUnitsPerDevPixel); SetOuterVisibleRegion(tmpLayer, &rgn); // If BuildLayer didn't call BuildContainerLayerFor, then our new layer won't have been @@ -3289,7 +3289,7 @@ FrameLayerBuilder::AddThebesDisplayItem(ThebesLayerData* aLayerData, layerBuilder->WillEndTransaction(); tempManager->AbortTransaction(); - nsIntPoint offset = GetLastPaintOffset(layer) - GetTranslationForThebesLayer(layer); + nsIntPoint offset = GetLastPaintOffset(layer) - GetTranslationForPaintedLayer(layer); props->MoveBy(-offset); nsIntRegion invalid = props->ComputeDifferences(tmpLayer, nullptr); if (aLayerState == LAYER_SVG_EFFECTS) { @@ -3303,14 +3303,14 @@ FrameLayerBuilder::AddThebesDisplayItem(ThebesLayerData* aLayerData, printf_stderr("Inactive LayerManager(%p) for display item %s(%p) has an invalid region - invalidating layer %p\n", tempManager.get(), aItem->Name(), aItem->Frame(), layer); } #endif - invalid.ScaleRoundOut(thebesData->mXScale, thebesData->mYScale); + invalid.ScaleRoundOut(paintedData->mXScale, paintedData->mYScale); if (hasClip) { invalid.And(invalid, intClip); } InvalidatePostTransformRegion(layer, invalid, - GetTranslationForThebesLayer(layer)); + GetTranslationForPaintedLayer(layer)); } } ClippedDisplayItem* cdi = @@ -3389,9 +3389,9 @@ FrameLayerBuilder::AddLayerDisplayItem(Layer* aLayer, } nsIntPoint -FrameLayerBuilder::GetLastPaintOffset(ThebesLayer* aLayer) +FrameLayerBuilder::GetLastPaintOffset(PaintedLayer* aLayer) { - ThebesLayerItemsEntry* entry = mThebesLayerItems.PutEntry(aLayer); + PaintedLayerItemsEntry* entry = mPaintedLayerItems.PutEntry(aLayer); if (entry) { if (entry->mContainerLayerGeneration == 0) { entry->mContainerLayerGeneration = mContainerLayerGeneration; @@ -3399,18 +3399,18 @@ FrameLayerBuilder::GetLastPaintOffset(ThebesLayer* aLayer) if (entry->mHasExplicitLastPaintOffset) return entry->mLastPaintOffset; } - return GetTranslationForThebesLayer(aLayer); + return GetTranslationForPaintedLayer(aLayer); } void -FrameLayerBuilder::SavePreviousDataForLayer(ThebesLayer* aLayer, uint32_t aClipCount) +FrameLayerBuilder::SavePreviousDataForLayer(PaintedLayer* aLayer, uint32_t aClipCount) { - ThebesLayerItemsEntry* entry = mThebesLayerItems.PutEntry(aLayer); + PaintedLayerItemsEntry* entry = mPaintedLayerItems.PutEntry(aLayer); if (entry) { if (entry->mContainerLayerGeneration == 0) { entry->mContainerLayerGeneration = mContainerLayerGeneration; } - entry->mLastPaintOffset = GetTranslationForThebesLayer(aLayer); + entry->mLastPaintOffset = GetTranslationForPaintedLayer(aLayer); entry->mHasExplicitLastPaintOffset = true; entry->mLastCommonClipCount = aClipCount; } @@ -3437,9 +3437,9 @@ ContainerState::CollectOldLayers() layer = layer->GetNextSibling()) { NS_ASSERTION(!layer->HasUserData(&gMaskLayerUserData), "Mask layer in layer tree; could not be recycled."); - if (layer->HasUserData(&gThebesDisplayItemLayerUserData)) { - NS_ASSERTION(layer->AsThebesLayer(), "Wrong layer type"); - mRecycledThebesLayers.AppendElement(static_cast(layer)); + if (layer->HasUserData(&gPaintedDisplayItemLayerUserData)) { + NS_ASSERTION(layer->AsPaintedLayer(), "Wrong layer type"); + mRecycledPaintedLayers.AppendElement(static_cast(layer)); } if (Layer* maskLayer = layer->GetMaskLayer()) { @@ -3524,7 +3524,7 @@ ContainerState::SetupScrollingMetadata(NewLayerEntry* aEntry) } layerClip = &tmpClipRect; // XXX this could cause IPC churn due to cliprects being updated - // twice during layer building --- for non-ThebesLayers that have + // twice during layer building --- for non-PaintedLayers that have // both CSS and scroll clipping. } } @@ -3619,8 +3619,8 @@ ContainerState::Finish(uint32_t* aTextContentFlags, LayerManagerData* aData, const nsIntRect& aContainerPixelBounds, nsDisplayList* aChildItems, bool& aHasComponentAlphaChildren) { - while (!mThebesLayerDataStack.IsEmpty()) { - PopThebesLayerData(); + while (!mPaintedLayerDataStack.IsEmpty()) { + PopPaintedLayerData(); } NS_ASSERTION(mContainerBounds.IsEqualInterior(mAccumulatedChildBounds), @@ -3861,7 +3861,7 @@ FrameLayerBuilder::RestoreDisplayItemData(nsRefPtrHashKey* aEnt } /* static */ PLDHashOperator -FrameLayerBuilder::RestoreThebesLayerItemEntries(ThebesLayerItemsEntry* aEntry, void* aUserArg) +FrameLayerBuilder::RestorePaintedLayerItemEntries(PaintedLayerItemsEntry* aEntry, void* aUserArg) { uint32_t *generation = static_cast(aUserArg); @@ -3921,9 +3921,9 @@ FrameLayerBuilder::BuildContainerLayerFor(nsDisplayListBuilder* aBuilder, if (oldLayer) { NS_ASSERTION(oldLayer->Manager() == aManager, "Wrong manager"); - if (oldLayer->HasUserData(&gThebesDisplayItemLayerUserData)) { - // The old layer for this item is actually our ThebesLayer - // because we rendered its layer into that ThebesLayer. So we + if (oldLayer->HasUserData(&gPaintedDisplayItemLayerUserData)) { + // The old layer for this item is actually our PaintedLayer + // because we rendered its layer into that PaintedLayer. So we // don't actually have a retained container layer. } else { NS_ASSERTION(oldLayer->GetType() == Layer::TYPE_CONTAINER, @@ -3949,7 +3949,7 @@ FrameLayerBuilder::BuildContainerLayerFor(nsDisplayListBuilder* aBuilder, if (aContainerItem && state == LAYER_ACTIVE_EMPTY) { // Empty layers only have metadata and should never have display items. We // early exit because later, invalidation will walk up the frame tree to - // determine which thebes layer gets invalidated. Since an empty layer + // determine which painted layer gets invalidated. Since an empty layer // should never have anything to paint, it should never be invalidated. NS_ASSERTION(aChildren->IsEmpty(), "Should have no children"); return containerLayer.forget(); @@ -3970,7 +3970,7 @@ FrameLayerBuilder::BuildContainerLayerFor(nsDisplayListBuilder* aBuilder, uint32_t oldGeneration = mContainerLayerGeneration; mContainerLayerGeneration = ++mMaxContainerLayerGeneration; - nsRefPtr thebesLayerInvalidRegion = nullptr; + nsRefPtr paintedLayerInvalidRegion = nullptr; if (mRetainingManager) { if (aContainerItem) { StoreDataForFrame(aContainerItem, containerLayer, LAYER_ACTIVE); @@ -4017,7 +4017,7 @@ FrameLayerBuilder::BuildContainerLayerFor(nsDisplayListBuilder* aBuilder, flattenToSingleLayer = true; data->mDisplayItems.EnumerateEntries(RestoreDisplayItemData, &mContainerLayerGeneration); - mThebesLayerItems.EnumerateEntries(RestoreThebesLayerItemEntries, + mPaintedLayerItems.EnumerateEntries(RestorePaintedLayerItemEntries, &mContainerLayerGeneration); aContainerFrame->AddStateBits(NS_FRAME_NO_COMPONENT_ALPHA); continue; @@ -4067,7 +4067,7 @@ FrameLayerBuilder::GetLeafLayerFor(nsDisplayListBuilder* aBuilder, Layer* layer = GetOldLayerFor(aItem); if (!layer) return nullptr; - if (layer->HasUserData(&gThebesDisplayItemLayerUserData)) { + if (layer->HasUserData(&gPaintedDisplayItemLayerUserData)) { // This layer was created to render Thebes-rendered content for this // display item. The display item should not use it for its own // layer rendering. @@ -4123,7 +4123,7 @@ FrameLayerBuilder::GetDedicatedLayer(nsIFrame* aFrame, uint32_t aDisplayItemKey) Layer* layer = element->mLayer; if (!layer->HasUserData(&gColorLayerUserData) && !layer->HasUserData(&gImageLayerUserData) && - !layer->HasUserData(&gThebesDisplayItemLayerUserData)) { + !layer->HasUserData(&gPaintedDisplayItemLayerUserData)) { return layer; } } @@ -4149,7 +4149,7 @@ PredictScaleForContent(nsIFrame* aFrame, nsIFrame* aAncestorWithScale, } gfxSize -FrameLayerBuilder::GetThebesLayerScaleForFrame(nsIFrame* aFrame) +FrameLayerBuilder::GetPaintedLayerScaleForFrame(nsIFrame* aFrame) { MOZ_ASSERT(aFrame, "need a frame"); nsIFrame* last = nullptr; @@ -4177,9 +4177,9 @@ FrameLayerBuilder::GetThebesLayerScaleForFrame(nsIFrame* aFrame) continue; } for (Layer* l = container->GetFirstChild(); l; l = l->GetNextSibling()) { - ThebesDisplayItemLayerUserData* data = - static_cast - (l->GetUserData(&gThebesDisplayItemLayerUserData)); + PaintedDisplayItemLayerUserData* data = + static_cast + (l->GetUserData(&gPaintedDisplayItemLayerUserData)); if (data) { return PredictScaleForContent(aFrame, f, gfxSize(data->mXScale, data->mYScale)); } @@ -4245,7 +4245,7 @@ FrameLayerBuilder::RecomputeVisibilityForItems(nsTArray& aIt const DisplayItemClip& clip = cdi->mItem->GetClip(); NS_ASSERTION(AppUnitsPerDevPixel(cdi->mItem) == aAppUnitsPerDevPixel, - "a thebes layer should contain items only at the same zoom"); + "a painted layer should contain items only at the same zoom"); NS_ABORT_IF_FALSE(clip.HasClip() || clip.GetRoundedRectCount() == 0, @@ -4392,16 +4392,16 @@ static void DrawForcedBackgroundColor(gfxContext* aContext, Layer* aLayer, nscol /* * A note on residual transforms: * - * In a transformed subtree we sometimes apply the ThebesLayer's - * "residual transform" when drawing content into the ThebesLayer. + * In a transformed subtree we sometimes apply the PaintedLayer's + * "residual transform" when drawing content into the PaintedLayer. * This is a translation by components in the range [-0.5,0.5) provided * by the layer system; applying the residual transform followed by the * transforms used by layer compositing ensures that the subpixel alignment - * of the content of the ThebesLayer exactly matches what it would be if + * of the content of the PaintedLayer exactly matches what it would be if * we used cairo/Thebes to draw directly to the screen without going through * retained layer buffers. * - * The visible and valid regions of the ThebesLayer are computed without + * The visible and valid regions of the PaintedLayer are computed without * knowing the residual transform (because we don't know what the residual * transform is going to be until we've built the layer tree!). So we have to * consider whether content painted in the range [x, xmost) might be painted @@ -4418,14 +4418,14 @@ static void DrawForcedBackgroundColor(gfxContext* aContext, Layer* aLayer, nscol */ /* static */ void -FrameLayerBuilder::DrawThebesLayer(ThebesLayer* aLayer, +FrameLayerBuilder::DrawPaintedLayer(PaintedLayer* aLayer, gfxContext* aContext, const nsIntRegion& aRegionToDraw, DrawRegionClip aClip, const nsIntRegion& aRegionToInvalidate, void* aCallbackData) { - PROFILER_LABEL("FrameLayerBuilder", "DrawThebesLayer", + PROFILER_LABEL("FrameLayerBuilder", "DrawPaintedLayer", js::ProfileEntry::Category::GRAPHICS); nsDisplayListBuilder* builder = static_cast @@ -4437,16 +4437,16 @@ FrameLayerBuilder::DrawThebesLayer(ThebesLayer* aLayer, if (layerBuilder->CheckDOMModified()) return; - ThebesLayerItemsEntry* entry = layerBuilder->mThebesLayerItems.GetEntry(aLayer); + PaintedLayerItemsEntry* entry = layerBuilder->mPaintedLayerItems.GetEntry(aLayer); NS_ASSERTION(entry, "We shouldn't be drawing into a layer with no items!"); if (!entry->mContainerLayerFrame) { return; } - ThebesDisplayItemLayerUserData* userData = - static_cast - (aLayer->GetUserData(&gThebesDisplayItemLayerUserData)); + PaintedDisplayItemLayerUserData* userData = + static_cast + (aLayer->GetUserData(&gPaintedDisplayItemLayerUserData)); NS_ASSERTION(userData, "where did our user data go?"); bool shouldDrawRectsSeparately = ShouldDrawRectsSeparately(aContext, aClip); @@ -4462,15 +4462,15 @@ FrameLayerBuilder::DrawThebesLayer(ThebesLayer* aLayer, } // make the origin of the context coincide with the origin of the - // ThebesLayer + // PaintedLayer gfxContextMatrixAutoSaveRestore saveMatrix(aContext); - nsIntPoint offset = GetTranslationForThebesLayer(aLayer); + nsIntPoint offset = GetTranslationForPaintedLayer(aLayer); nsPresContext* presContext = entry->mContainerLayerFrame->PresContext(); - if (!layerBuilder->GetContainingThebesLayerData()) { - // Recompute visibility of items in our ThebesLayer. Note that this + if (!layerBuilder->GetContainingPaintedLayerData()) { + // Recompute visibility of items in our PaintedLayer. Note that this // recomputes visibility for all descendants of our display items too, - // so there's no need to do this for the items in inactive ThebesLayers. + // so there's no need to do this for the items in inactive PaintedLayers. int32_t appUnitsPerDevPixel = presContext->AppUnitsPerDevPixel(); RecomputeVisibilityForItems(entry->mItems, builder, aRegionToDraw, offset, appUnitsPerDevPixel, @@ -4578,11 +4578,11 @@ CalculateBounds(const nsTArray& aRects, int32_t A2 } static void -SetClipCount(ThebesDisplayItemLayerUserData* aThebesData, +SetClipCount(PaintedDisplayItemLayerUserData* apaintedData, uint32_t aClipCount) { - if (aThebesData) { - aThebesData->mMaskClipCount = aClipCount; + if (apaintedData) { + apaintedData->mMaskClipCount = aClipCount; } } @@ -4595,11 +4595,11 @@ ContainerState::SetupMaskLayer(Layer *aLayer, // if the number of clips we are going to mask has decreased, then aLayer might have // cached graphics which assume the existence of a soon-to-be non-existent mask layer // in that case, invalidate the whole layer. - ThebesDisplayItemLayerUserData* thebesData = GetThebesDisplayItemLayerUserData(aLayer); - if (thebesData && - aRoundedRectClipCount < thebesData->mMaskClipCount) { - ThebesLayer* thebes = aLayer->AsThebesLayer(); - thebes->InvalidateRegion(thebes->GetValidRegion().GetBounds()); + PaintedDisplayItemLayerUserData* paintedData = GetPaintedDisplayItemLayerUserData(aLayer); + if (paintedData && + aRoundedRectClipCount < paintedData->mMaskClipCount) { + PaintedLayer* painted = aLayer->AsPaintedLayer(); + painted->InvalidateRegion(painted->GetValidRegion().GetBounds()); } // don't build an unnecessary mask @@ -4607,7 +4607,7 @@ ContainerState::SetupMaskLayer(Layer *aLayer, if (aClip.GetRoundedRectCount() == 0 || aRoundedRectClipCount == 0 || layerBounds.IsEmpty()) { - SetClipCount(thebesData, 0); + SetClipCount(paintedData, 0); return; } @@ -4624,7 +4624,7 @@ ContainerState::SetupMaskLayer(Layer *aLayer, if (*userData == newData) { aLayer->SetMaskLayer(maskLayer); - SetClipCount(thebesData, aRoundedRectClipCount); + SetClipCount(paintedData, aRoundedRectClipCount); return; } @@ -4678,7 +4678,7 @@ ContainerState::SetupMaskLayer(Layer *aLayer, // fail if we can't get the right surface if (!dt) { NS_WARNING("Could not create DrawTarget for mask layer."); - SetClipCount(thebesData, 0); + SetClipCount(paintedData, 0); return; } @@ -4725,7 +4725,7 @@ ContainerState::SetupMaskLayer(Layer *aLayer, userData->mImageKey = lookupKey; aLayer->SetMaskLayer(maskLayer); - SetClipCount(thebesData, aRoundedRectClipCount); + SetClipCount(paintedData, aRoundedRectClipCount); return; } diff --git a/layout/base/FrameLayerBuilder.h b/layout/base/FrameLayerBuilder.h index 74e3be0a4d95..7d4055a0ad99 100644 --- a/layout/base/FrameLayerBuilder.h +++ b/layout/base/FrameLayerBuilder.h @@ -27,7 +27,7 @@ namespace layers { class ContainerLayer; class LayerManager; class BasicLayerManager; -class ThebesLayer; +class PaintedLayer; } namespace gfx { @@ -36,7 +36,7 @@ class Matrix4x4; class FrameLayerBuilder; class LayerManagerData; -class ThebesLayerData; +class PaintedLayerData; class ContainerState; class RefCountedRegion { @@ -99,14 +99,14 @@ struct ContainerLayerParameters { bool mDisableSubpixelAntialiasingInDescendants; bool mInLowPrecisionDisplayPort; /** - * When this is false, ThebesLayer coordinates are drawn to with an integer + * When this is false, PaintedLayer coordinates are drawn to with an integer * translation and the scale in mXScale/mYScale. */ bool AllowResidualTranslation() { // If we're in a transformed subtree, but no ancestor transform is actively // changing, we'll use the residual translation when drawing into the - // ThebesLayer to ensure that snapping exactly matches the ideal transform. + // PaintedLayer to ensure that snapping exactly matches the ideal transform. return mInTransformedSubtree && !mInActiveTransformedSubtree; } }; @@ -124,7 +124,7 @@ struct ContainerLayerParameters { * That data enables us to retain layer trees. When constructing a * ContainerLayer, we first check to see if there's an existing * ContainerLayer for the same frame that can be recycled. If we recycle - * it, we also try to reuse its existing ThebesLayer children to render + * it, we also try to reuse its existing PaintedLayer children to render * the display items without layers of their own. The idea is that by * recycling layers deterministically, we can ensure that when nothing * changes in a display list, we will reuse the existing layers without @@ -135,7 +135,7 @@ struct ContainerLayerParameters { * locates the last layer used to render the display item, if any, and * return it as a candidate for recycling. * - * FrameLayerBuilder sets up ThebesLayers so that 0,0 in the Thebes layer + * FrameLayerBuilder sets up PaintedLayers so that 0,0 in the Painted layer * corresponds to the (pixel-snapped) top-left of the aAnimatedGeometryRoot. * It sets up ContainerLayers so that 0,0 in the container layer * corresponds to the snapped top-left of the display item reference frame. @@ -143,7 +143,7 @@ struct ContainerLayerParameters { * When we construct a container layer, we know the transform that will be * applied to the layer. If the transform scales the content, we can get * better results when intermediate buffers are used by pushing some scale - * from the container's transform down to the children. For ThebesLayer + * from the container's transform down to the children. For PaintedLayer * children, the scaling can be achieved by changing the size of the layer * and drawing into it with increased or decreased resolution. By convention, * integer types (nsIntPoint/nsIntSize/nsIntRect/nsIntRegion) are all in layer @@ -153,7 +153,7 @@ class FrameLayerBuilder : public layers::LayerUserData { public: typedef layers::ContainerLayer ContainerLayer; typedef layers::Layer Layer; - typedef layers::ThebesLayer ThebesLayer; + typedef layers::PaintedLayer PaintedLayer; typedef layers::ImageLayer ImageLayer; typedef layers::LayerManager LayerManager; typedef layers::BasicLayerManager BasicLayerManager; @@ -177,7 +177,7 @@ public: static void Shutdown(); void Init(nsDisplayListBuilder* aBuilder, LayerManager* aManager, - ThebesLayerData* aLayerData = nullptr); + PaintedLayerData* aLayerData = nullptr); /** * Call this to notify that we have just started a transaction on the @@ -208,7 +208,7 @@ public: * This gets called by display list code. It calls BuildLayer on the * items in the display list, making items with their own layers * children of the new container, and assigning all other items to - * ThebesLayer children created and managed by the FrameLayerBuilder. + * PaintedLayer children created and managed by the FrameLayerBuilder. * Returns a layer with clip rect cleared; it is the * caller's responsibility to add any clip rect. The visible region * is set based on what's in the layer. @@ -249,7 +249,7 @@ public: static void InvalidateAllLayersForFrame(nsIFrame *aFrame); /** - * Call this to determine if a frame has a dedicated (non-Thebes) layer + * Call this to determine if a frame has a dedicated (non-Painted) layer * for the given display item key. If there isn't one, we return null, * otherwise we return the layer. */ @@ -261,7 +261,7 @@ public: * This function can be called multiple times in a row to draw * different regions. */ - static void DrawThebesLayer(ThebesLayer* aLayer, + static void DrawPaintedLayer(PaintedLayer* aLayer, gfxContext* aContext, const nsIntRegion& aRegionToDraw, mozilla::layers::DrawRegionClip aClip, @@ -298,13 +298,13 @@ public: BasicLayerManager* aManager); /** - * Record aItem as a display item that is rendered by the ThebesLayer + * Record aItem as a display item that is rendered by the PaintedLayer * aLayer, with aClipRect, where aContainerLayerFrame is the frame * for the container layer this ThebesItem belongs to. * aItem must have an underlying frame. * @param aTopLeft offset from active scrolled root to reference frame */ - void AddThebesDisplayItem(ThebesLayerData* aLayer, + void AddPaintedDisplayItem(PaintedLayerData* aLayer, nsDisplayItem* aItem, const DisplayItemClip& aClip, const nsIntRect& aItemVisibleRect, @@ -355,13 +355,13 @@ public: * of the active scrolled root frame. It must be an integer * translation. */ - void SavePreviousDataForLayer(ThebesLayer* aLayer, uint32_t aClipCount); + void SavePreviousDataForLayer(PaintedLayer* aLayer, uint32_t aClipCount); /** * Get the translation transform that was in aLayer when we last painted. It's either * the transform saved by SaveLastPaintTransform, or else the transform * that's currently in the layer (which must be an integer translation). */ - nsIntPoint GetLastPaintOffset(ThebesLayer* aLayer); + nsIntPoint GetLastPaintOffset(PaintedLayer* aLayer); /** * Return the resolution at which we expect to render aFrame's contents, @@ -370,12 +370,12 @@ public: * being rendered at, as well as any currently-inactive transforms between * aFrame and that container layer. */ - static gfxSize GetThebesLayerScaleForFrame(nsIFrame* aFrame); + static gfxSize GetPaintedLayerScaleForFrame(nsIFrame* aFrame); /** * Stores a Layer as the dedicated layer in the DisplayItemData for a given frame/key pair. * - * Used when we optimize a ThebesLayer into an ImageLayer and want to retroactively update the + * Used when we optimize a PaintedLayer into an ImageLayer and want to retroactively update the * DisplayItemData so we can retrieve the layer from within layout. */ void StoreOptimizedLayerForFrame(nsDisplayItem* aItem, Layer* aLayer); @@ -446,7 +446,7 @@ public: * longer than the transaction. * * Updates the geometry, frame list and clip. - * For items within a ThebesLayer, a geometry object must be specifed to retain + * For items within a PaintedLayer, a geometry object must be specifed to retain * until the next transaction. * */ @@ -489,7 +489,7 @@ protected: * Given a frame and a display item key that uniquely identifies a * display item for the frame, find the layer that was last used to * render that display item. Returns null if there is no such layer. - * This could be a dedicated layer for the display item, or a ThebesLayer + * This could be a dedicated layer for the display item, or a PaintedLayer * that renders many display items. */ DisplayItemData* GetOldLayerForFrame(nsIFrame* aFrame, uint32_t aDisplayItemKey); @@ -534,12 +534,12 @@ protected: void* aClosure); /** * We store one of these for each display item associated with a - * ThebesLayer, in a hashtable that maps each ThebesLayer to an array - * of ClippedDisplayItems. (ThebesLayerItemsEntry is the hash entry + * PaintedLayer, in a hashtable that maps each PaintedLayer to an array + * of ClippedDisplayItems. (PaintedLayerItemsEntry is the hash entry * for that hashtable.) * These are only stored during the paint process, so that the - * DrawThebesLayer callback can figure out which items to draw for the - * ThebesLayer. + * DrawPaintedLayer callback can figure out which items to draw for the + * PaintedLayer. */ struct ClippedDisplayItem { ClippedDisplayItem(nsDisplayItem* aItem, uint32_t aGeneration) @@ -585,25 +585,25 @@ protected: * the paint process. This is the hashentry for that hashtable. */ public: - class ThebesLayerItemsEntry : public nsPtrHashKey { + class PaintedLayerItemsEntry : public nsPtrHashKey { public: - explicit ThebesLayerItemsEntry(const ThebesLayer *key) - : nsPtrHashKey(key) + explicit PaintedLayerItemsEntry(const PaintedLayer *key) + : nsPtrHashKey(key) , mContainerLayerFrame(nullptr) , mLastCommonClipCount(0) , mContainerLayerGeneration(0) , mHasExplicitLastPaintOffset(false) , mCommonClipCount(0) {} - ThebesLayerItemsEntry(const ThebesLayerItemsEntry &toCopy) : - nsPtrHashKey(toCopy.mKey), mItems(toCopy.mItems) + PaintedLayerItemsEntry(const PaintedLayerItemsEntry &toCopy) : + nsPtrHashKey(toCopy.mKey), mItems(toCopy.mItems) { NS_ERROR("Should never be called, since we ALLOW_MEMMOVE"); } nsTArray mItems; nsIFrame* mContainerLayerFrame; - // The translation set on this ThebesLayer before we started updating the + // The translation set on this PaintedLayer before we started updating the // layer tree. nsIntPoint mLastPaintOffset; uint32_t mLastCommonClipCount; @@ -612,7 +612,7 @@ public: bool mHasExplicitLastPaintOffset; /** * The first mCommonClipCount rounded rectangle clips are identical for - * all items in the layer. Computed in ThebesLayerData. + * all items in the layer. Computed in PaintedLayerData. */ uint32_t mCommonClipCount; @@ -620,22 +620,22 @@ public: }; /** - * Get the ThebesLayerItemsEntry object associated with aLayer in this + * Get the PaintedLayerItemsEntry object associated with aLayer in this * FrameLayerBuilder */ - ThebesLayerItemsEntry* GetThebesLayerItemsEntry(ThebesLayer* aLayer) + PaintedLayerItemsEntry* GetPaintedLayerItemsEntry(PaintedLayer* aLayer) { - return mThebesLayerItems.GetEntry(aLayer); + return mPaintedLayerItems.GetEntry(aLayer); } - ThebesLayerData* GetContainingThebesLayerData() + PaintedLayerData* GetContainingPaintedLayerData() { - return mContainingThebesLayer; + return mContainingPaintedLayer; } bool IsBuildingRetainedLayers() { - return !mContainingThebesLayer && mRetainingManager; + return !mContainingPaintedLayer && mRetainingManager; } /** @@ -657,7 +657,7 @@ protected: static PLDHashOperator RestoreDisplayItemData(nsRefPtrHashKey* aEntry, void *aUserArg); - static PLDHashOperator RestoreThebesLayerItemEntries(ThebesLayerItemsEntry* aEntry, + static PLDHashOperator RestorePaintedLayerItemEntries(PaintedLayerItemsEntry* aEntry, void *aUserArg); /** @@ -682,16 +682,16 @@ protected: */ nsDisplayListBuilder* mDisplayListBuilder; /** - * A map from ThebesLayers to the list of display items (plus + * A map from PaintedLayers to the list of display items (plus * clipping data) to be rendered in the layer. */ - nsTHashtable mThebesLayerItems; + nsTHashtable mPaintedLayerItems; /** * When building layers for an inactive layer, this is where the * inactive layer will be placed. */ - ThebesLayerData* mContainingThebesLayer; + PaintedLayerData* mContainingPaintedLayer; /** * Saved generation counter so we can detect DOM changes. diff --git a/layout/base/nsDisplayList.cpp b/layout/base/nsDisplayList.cpp index 543d9610afcf..6003118cc911 100644 --- a/layout/base/nsDisplayList.cpp +++ b/layout/base/nsDisplayList.cpp @@ -1237,7 +1237,7 @@ void nsDisplayList::PaintRoot(nsDisplayListBuilder* aBuilder, /** * We paint by executing a layer manager transaction, constructing a * single layer representing the display list, and then making it the - * root of the layer manager, drawing into the ThebesLayers. + * root of the layer manager, drawing into the PaintedLayers. */ void nsDisplayList::PaintForFrame(nsDisplayListBuilder* aBuilder, nsRenderingContext* aCtx, @@ -1385,7 +1385,7 @@ void nsDisplayList::PaintForFrame(nsDisplayListBuilder* aBuilder, MaybeSetupTransactionIdAllocator(layerManager, view); - layerManager->EndTransaction(FrameLayerBuilder::DrawThebesLayer, + layerManager->EndTransaction(FrameLayerBuilder::DrawPaintedLayer, aBuilder, flags); aBuilder->SetIsCompositingCheap(temp); layerBuilder->DidEndTransaction(); @@ -3222,7 +3222,7 @@ void nsDisplayWrapList::Paint(nsDisplayListBuilder* aBuilder, /** * Returns true if all descendant display items can be placed in the same - * ThebesLayer --- GetLayerState returns LAYER_INACTIVE or LAYER_NONE, + * PaintedLayer --- GetLayerState returns LAYER_INACTIVE or LAYER_NONE, * and they all have the expected animated geometry root. */ static LayerState diff --git a/layout/base/nsDisplayList.h b/layout/base/nsDisplayList.h index 429ac291eba7..60a2667f3984 100644 --- a/layout/base/nsDisplayList.h +++ b/layout/base/nsDisplayList.h @@ -1096,14 +1096,14 @@ public: * Return LAYER_INACTIVE if there is a layer --- BuildLayer will * not return null (unless there's an error) --- but the layer contents * are not changing frequently. In this case it makes sense to composite - * the layer into a ThebesLayer with other content, so we don't have to + * the layer into a PaintedLayer with other content, so we don't have to * recomposite it every time we paint. * Note: GetLayerState is only allowed to return LAYER_INACTIVE if all * descendant display items returned LAYER_INACTIVE or LAYER_NONE. Also, * all descendant display item frames must have an active scrolled root * that's either the same as this item's frame's active scrolled root, or * a descendant of this item's frame. This ensures that the entire - * set of display items can be collapsed onto a single ThebesLayer. + * set of display items can be collapsed onto a single PaintedLayer. * Return LAYER_ACTIVE if the layer is active, that is, its contents are * changing frequently. In this case it makes sense to keep the layer * as a separate buffer in VRAM and composite it into the destination @@ -1131,7 +1131,7 @@ public: #ifdef MOZ_DUMP_PAINTING /** - * Mark this display item as being painted via FrameLayerBuilder::DrawThebesLayer. + * Mark this display item as being painted via FrameLayerBuilder::DrawPaintedLayer. */ bool Painted() { return mPainted; } @@ -1378,7 +1378,7 @@ class nsDisplayList { public: typedef mozilla::layers::Layer Layer; typedef mozilla::layers::LayerManager LayerManager; - typedef mozilla::layers::ThebesLayer ThebesLayer; + typedef mozilla::layers::PaintedLayer PaintedLayer; /** * Create an empty list. @@ -1538,7 +1538,7 @@ public: * been removed from aVisibleRegion when we return. * This does not remove any items from the list, so we can recompute * visiblity with different regions later (see - * FrameLayerBuilder::DrawThebesLayer). + * FrameLayerBuilder::DrawPaintedLayer). * This method needs to be idempotent. * * @param aVisibleRegion the area that is visible, relative to the @@ -2495,14 +2495,14 @@ public: * One of these is created for each stacking context and pseudo-stacking-context. * It accumulates regions for event targets contributed by the border-boxes of * frames in its (pseudo) stacking context. A nsDisplayLayerEventRegions - * eventually contributes its regions to the ThebesLayer it is placed in by + * eventually contributes its regions to the PaintedLayer it is placed in by * FrameLayerBuilder. (We don't create a display item for every frame that * could be an event target (i.e. almost all frames), because that would be * high overhead.) * - * We always make leaf layers other than ThebesLayers transparent to events. + * We always make leaf layers other than PaintedLayers transparent to events. * For example, an event targeting a canvas or video will actually target the - * background of that element, which is logically in the ThebesLayer behind the + * background of that element, which is logically in the PaintedLayer behind the * CanvasFrame or ImageFrame. We only need to create a * nsDisplayLayerEventRegions when an element's background could be in front * of a lower z-order element with its own layer. diff --git a/layout/base/nsIPresShell.h b/layout/base/nsIPresShell.h index 24a7afa7aaa6..7fa2fc10d211 100644 --- a/layout/base/nsIPresShell.h +++ b/layout/base/nsIPresShell.h @@ -1380,8 +1380,8 @@ public: virtual void SynthesizeMouseMove(bool aFromScroll) = 0; enum PaintFlags { - /* Update the layer tree and paint ThebesLayers. If this is not specified, - * we may still have to do it if the layer tree lost ThebesLayer contents + /* Update the layer tree and paint PaintedLayers. If this is not specified, + * we may still have to do it if the layer tree lost PaintedLayer contents * we need for compositing. */ PAINT_LAYERS = 0x01, /* Composite layers to the window. */ diff --git a/layout/base/nsLayoutUtils.h b/layout/base/nsLayoutUtils.h index c45f8fc56d46..01d87e74eb72 100644 --- a/layout/base/nsLayoutUtils.h +++ b/layout/base/nsLayoutUtils.h @@ -491,7 +491,7 @@ public: * scrollframes which are actively being scrolled fall into this category. * Frames with certain CSS properties that are being animated (e.g. * 'left'/'top' etc) are also placed in this category. - * Frames with different active geometry roots are in different ThebesLayers, + * Frames with different active geometry roots are in different PaintedLayers, * so that we can animate the geometry root by changing its transform (either * on the main thread or in the compositor). * The animated geometry root is required to be a descendant (or equal to) diff --git a/layout/base/nsPresContext.cpp b/layout/base/nsPresContext.cpp index e58be6b1447f..10caddfc7324 100644 --- a/layout/base/nsPresContext.cpp +++ b/layout/base/nsPresContext.cpp @@ -824,14 +824,14 @@ nsPresContext::GetUserPreferences() } void -nsPresContext::InvalidateThebesLayers() +nsPresContext::InvalidatePaintedLayers() { if (!mShell) return; nsIFrame* rootFrame = mShell->FrameManager()->GetRootFrame(); if (rootFrame) { // FrameLayerBuilder caches invalidation-related values that depend on the - // appunits-per-dev-pixel ratio, so ensure that all ThebesLayer drawing + // appunits-per-dev-pixel ratio, so ensure that all PaintedLayer drawing // is completely flushed. rootFrame->InvalidateFrameSubtree(); } @@ -840,7 +840,7 @@ nsPresContext::InvalidateThebesLayers() void nsPresContext::AppUnitsPerDevPixelChanged() { - InvalidateThebesLayers(); + InvalidatePaintedLayers(); if (mDeviceContext) { mDeviceContext->FlushFontCache(); @@ -937,7 +937,7 @@ nsPresContext::UpdateAfterPreferencesChanged() mShell->SetPreferenceStyleRules(true); } - InvalidateThebesLayers(); + InvalidatePaintedLayers(); mDeviceContext->FlushFontCache(); nsChangeHint hint = nsChangeHint(0); diff --git a/layout/base/nsPresContext.h b/layout/base/nsPresContext.h index a496e32581fd..c5548fb9fb05 100644 --- a/layout/base/nsPresContext.h +++ b/layout/base/nsPresContext.h @@ -1161,7 +1161,7 @@ public: #endif protected: - void InvalidateThebesLayers(); + void InvalidatePaintedLayers(); void AppUnitsPerDevPixelChanged(); void HandleRebuildUserFontSet() { diff --git a/layout/generic/nsFrameStateBits.h b/layout/generic/nsFrameStateBits.h index 2ac1e7f7a382..2d04f97c23e3 100644 --- a/layout/generic/nsFrameStateBits.h +++ b/layout/generic/nsFrameStateBits.h @@ -184,7 +184,7 @@ FRAME_STATE_BIT(Generic, 36, NS_FRAME_UPDATE_LAYER_TREE) // Frame can accept absolutely positioned children. FRAME_STATE_BIT(Generic, 37, NS_FRAME_HAS_ABSPOS_CHILDREN) -// A display item for this frame has been painted as part of a ThebesLayer. +// A display item for this frame has been painted as part of a PaintedLayer. FRAME_STATE_BIT(Generic, 38, NS_FRAME_PAINTED_THEBES) // Frame is or is a descendant of something with a fixed height, unless that diff --git a/layout/generic/nsGfxScrollFrame.cpp b/layout/generic/nsGfxScrollFrame.cpp index c590c99faab7..25c1d7e62ee2 100644 --- a/layout/generic/nsGfxScrollFrame.cpp +++ b/layout/generic/nsGfxScrollFrame.cpp @@ -2273,7 +2273,7 @@ ClampAndAlignWithPixels(nscoord aDesired, double delta = desiredLayerVal - currentLayerVal; double nearestLayerVal = NS_round(delta) + currentLayerVal; - // Convert back from ThebesLayer space to appunits relative to the top-left + // Convert back from PaintedLayer space to appunits relative to the top-left // of the scrolled frame. nscoord aligned = NSToCoordRoundWithClamp(nearestLayerVal*aAppUnitsPerPixel/aRes); @@ -2368,15 +2368,15 @@ ScrollFrameHelper::ScrollToImpl(nsPoint aPt, const nsRect& aRange, nsIAtom* aOri nsPresContext* presContext = mOuter->PresContext(); nscoord appUnitsPerDevPixel = presContext->AppUnitsPerDevPixel(); // 'scale' is our estimate of the scale factor that will be applied - // when rendering the scrolled content to its own ThebesLayer. - gfxSize scale = FrameLayerBuilder::GetThebesLayerScaleForFrame(mScrolledFrame); + // when rendering the scrolled content to its own PaintedLayer. + gfxSize scale = FrameLayerBuilder::GetPaintedLayerScaleForFrame(mScrolledFrame); nsPoint curPos = GetScrollPosition(); nsPoint alignWithPos = mScrollPosForLayerPixelAlignment == nsPoint(-1,-1) ? curPos : mScrollPosForLayerPixelAlignment; // Try to align aPt with curPos so they have an integer number of layer // pixels between them. This gives us the best chance of scrolling without // having to invalidate due to changes in subpixel rendering. - // Note that when we actually draw into a ThebesLayer, the coordinates + // Note that when we actually draw into a PaintedLayer, the coordinates // that get mapped onto the layer buffer pixels are from the display list, // which are relative to the display root frame's top-left increasing down, // whereas here our coordinates are scroll positions which increase upward diff --git a/layout/generic/nsPluginFrame.cpp b/layout/generic/nsPluginFrame.cpp index ae26192e8711..de07fd378955 100644 --- a/layout/generic/nsPluginFrame.cpp +++ b/layout/generic/nsPluginFrame.cpp @@ -364,7 +364,7 @@ nsPluginFrame::PrepForDrawing(nsIWidget *aWidget) #ifdef XP_MACOSX // On Mac, we need to invalidate ourselves since even windowed // plugins are painted through Thebes and we need to ensure - // the Thebes layer containing the plugin is updated. + // the PaintedLayer containing the plugin is updated. if (parentWidget == GetNearestWidget()) { InvalidateFrame(); } @@ -1027,7 +1027,7 @@ nsDisplayPlugin::GetOpaqueRegion(nsDisplayListBuilder* aBuilder, // security reasons.) // We shouldn't be repainting the content under plugins much anyway // since there generally shouldn't be anything to invalidate or paint - // in ThebesLayers there. + // in PaintedLayers there. return result; } } diff --git a/layout/reftests/border-radius/reftest.list b/layout/reftests/border-radius/reftest.list index 876c24ec52e4..494038534a47 100644 --- a/layout/reftests/border-radius/reftest.list +++ b/layout/reftests/border-radius/reftest.list @@ -49,7 +49,7 @@ fuzzy-if(/^Windows\x20NT\x206\.2/.test(http.oscpu),1,5) == clipping-5-image.html fuzzy-if(/^Windows\x20NT\x206\.2/.test(http.oscpu),1,5) == clipping-5-overflow-hidden.html clipping-5-ref.html fuzzy-if(/^Windows\x20NT\x206\.2/.test(http.oscpu),1,5) fuzzy-if(Android,5,21) == clipping-5-refi.html clipping-5-ref.html fuzzy-if(true,1,7) fuzzy-if(cocoaWidget,1,99) fuzzy-if(Android&&browserIsRemote,7,89) fuzzy-if(Android&&!browserIsRemote,99,115) == clipping-5-refc.html clipping-5-ref.html # bug 732535 -fuzzy-if(winWidget,105,71) fuzzy-if(Android,8,464) == clipping-6.html clipping-6-ref.html # ThebesLayer and MaskLayer with transforms that aren't identical +fuzzy-if(winWidget,105,71) fuzzy-if(Android,8,464) == clipping-6.html clipping-6-ref.html # PaintedLayer and MaskLayer with transforms that aren't identical fuzzy-if(true,2,29) fuzzy-if(Android&&AndroidVersion<15,12,81) fuzzy-if(Android&&AndroidVersion>=15,255,586) == clipping-7.html clipping-7-ref.html # ColorLayer and MaskLayer with transforms that aren't identical. Reference image rendered without using layers (which causes fuzzy failures). fuzzy-if(/^Windows\x20NT\x206\.2/.test(http.oscpu),1,5) == clipping-and-zindex-1.html clipping-and-zindex-1-ref.html fuzzy-if(cocoaWidget,1,4) == intersecting-clipping-1-canvas.html intersecting-clipping-1-refc.html diff --git a/layout/svg/nsSVGIntegrationUtils.cpp b/layout/svg/nsSVGIntegrationUtils.cpp index bf7889299c70..94982c972ff1 100644 --- a/layout/svg/nsSVGIntegrationUtils.cpp +++ b/layout/svg/nsSVGIntegrationUtils.cpp @@ -397,7 +397,7 @@ public: gfxContextMatrixAutoSaveRestore autoSR(ctx); ctx->SetMatrix(ctx->CurrentMatrix().Translate(devPixelOffset)); - mLayerManager->EndTransaction(FrameLayerBuilder::DrawThebesLayer, mBuilder); + mLayerManager->EndTransaction(FrameLayerBuilder::DrawPaintedLayer, mBuilder); } private: @@ -541,7 +541,7 @@ nsSVGIntegrationUtils::PaintFramesWithEffects(nsRenderingContext* aCtx, nsFilterInstance::PaintFilteredFrame(aFrame, aCtx, tm, &callback, &dirtyRegion); } else { gfx->SetMatrix(matrixAutoSaveRestore.Matrix()); - aLayerManager->EndTransaction(FrameLayerBuilder::DrawThebesLayer, aBuilder); + aLayerManager->EndTransaction(FrameLayerBuilder::DrawPaintedLayer, aBuilder); gfx->SetMatrix(gfx->CurrentMatrix().Translate(devPixelOffsetToUserSpace)); } diff --git a/netwerk/protocol/http/nsHttpTransaction.cpp b/netwerk/protocol/http/nsHttpTransaction.cpp index 7b74246ed6b5..15c50476424c 100644 --- a/netwerk/protocol/http/nsHttpTransaction.cpp +++ b/netwerk/protocol/http/nsHttpTransaction.cpp @@ -148,11 +148,9 @@ nsHttpTransaction::~nsHttpTransaction() mTokenBucketCancel = nullptr; } - // Force the callbacks to be released right now + // Force the callbacks and connection to be released right now mCallbacks = nullptr; - - NS_IF_RELEASE(mConnection); - NS_IF_RELEASE(mConnInfo); + mConnection = nullptr; delete mResponseHead; delete mForTakeResponseHead; @@ -271,7 +269,7 @@ nsHttpTransaction::Init(uint32_t caps, !activityDistributorActive); if (NS_FAILED(rv)) return rv; - NS_ADDREF(mConnInfo = cinfo); + mConnInfo = cinfo; mCallbacks = callbacks; mConsumerTarget = target; mCaps = caps; @@ -375,7 +373,8 @@ nsHttpTransaction::Init(uint32_t caps, Classify(); - NS_ADDREF(*responseBody = mPipeIn); + nsCOMPtr tmp(mPipeIn); + tmp.forget(responseBody); return NS_OK; } @@ -383,14 +382,15 @@ nsHttpTransaction::Init(uint32_t caps, nsAHttpConnection * nsHttpTransaction::Connection() { - return mConnection; + MOZ_ASSERT(PR_GetCurrentThread() == gSocketThread); + return mConnection.get(); } already_AddRefed nsHttpTransaction::GetConnectionReference() { MutexAutoLock lock(mLock); - nsRefPtr connection = mConnection; + nsRefPtr connection(mConnection); return connection.forget(); } @@ -459,8 +459,7 @@ nsHttpTransaction::SetConnection(nsAHttpConnection *conn) { { MutexAutoLock lock(mLock); - NS_IF_RELEASE(mConnection); - NS_IF_ADDREF(mConnection = conn); + mConnection = conn; } if (conn) { @@ -473,7 +472,8 @@ void nsHttpTransaction::GetSecurityCallbacks(nsIInterfaceRequestor **cb) { MutexAutoLock lock(mLock); - NS_IF_ADDREF(*cb = mCallbacks); + nsCOMPtr tmp(mCallbacks); + tmp.forget(cb); } void @@ -936,7 +936,7 @@ nsHttpTransaction::Close(nsresult reason) if (relConn && mConnection) { MutexAutoLock lock(mLock); - NS_RELEASE(mConnection); + mConnection = nullptr; } // save network statistics in the end of transaction @@ -966,7 +966,7 @@ nsHttpTransaction::Close(nsresult reason) nsHttpConnectionInfo * nsHttpTransaction::ConnectionInfo() { - return mConnInfo; + return mConnInfo.get(); } nsresult @@ -1101,7 +1101,7 @@ nsHttpTransaction::Restart() if (mConnection) { mConnection->DontReuse(); MutexAutoLock lock(mLock); - NS_RELEASE(mConnection); + mConnection = nullptr; } // disable pipelining for the next attempt in case pipelining caused the diff --git a/netwerk/protocol/http/nsHttpTransaction.h b/netwerk/protocol/http/nsHttpTransaction.h index 3efebc9898cf..791b66f89c00 100644 --- a/netwerk/protocol/http/nsHttpTransaction.h +++ b/netwerk/protocol/http/nsHttpTransaction.h @@ -202,10 +202,10 @@ private: nsCOMPtr mRequestStream; uint64_t mRequestSize; - nsAHttpConnection *mConnection; // hard ref - nsHttpConnectionInfo *mConnInfo; // hard ref + nsRefPtr mConnection; + nsRefPtr mConnInfo; nsHttpRequestHead *mRequestHead; // weak ref - nsHttpResponseHead *mResponseHead; // hard ref + nsHttpResponseHead *mResponseHead; // owning pointer nsAHttpSegmentReader *mReader; nsAHttpSegmentWriter *mWriter; diff --git a/security/apps/AppTrustDomain.cpp b/security/apps/AppTrustDomain.cpp index 10e2ec9cae3c..da0361270546 100644 --- a/security/apps/AppTrustDomain.cpp +++ b/security/apps/AppTrustDomain.cpp @@ -238,7 +238,7 @@ AppTrustDomain::CheckRevocation(EndEntityOrCA, const CertID&, Time, } Result -AppTrustDomain::IsChainValid(const DERArray& certChain) +AppTrustDomain::IsChainValid(const DERArray& certChain, Time time) { SECStatus srv = ConstructCERTCertListFromReversedDERArray(certChain, mCertChain); diff --git a/security/apps/AppTrustDomain.h b/security/apps/AppTrustDomain.h index e8abf1531a5b..5bf53bff2a18 100644 --- a/security/apps/AppTrustDomain.h +++ b/security/apps/AppTrustDomain.h @@ -36,8 +36,8 @@ public: mozilla::pkix::Time time, /*optional*/ const mozilla::pkix::Input* stapledOCSPresponse, /*optional*/ const mozilla::pkix::Input* aiaExtension); - virtual Result IsChainValid(const mozilla::pkix::DERArray& certChain) - MOZ_OVERRIDE; + virtual Result IsChainValid(const mozilla::pkix::DERArray& certChain, + mozilla::pkix::Time time) MOZ_OVERRIDE; virtual Result CheckPublicKey(mozilla::pkix::Input subjectPublicKeyInfo) MOZ_OVERRIDE; virtual Result VerifySignedData( diff --git a/security/certverifier/CertVerifier.cpp b/security/certverifier/CertVerifier.cpp index 8078b3e1c733..869c93f60e56 100644 --- a/security/certverifier/CertVerifier.cpp +++ b/security/certverifier/CertVerifier.cpp @@ -35,11 +35,11 @@ const CertVerifier::Flags CertVerifier::FLAG_MUST_BE_EV = 2; CertVerifier::CertVerifier(ocsp_download_config odc, ocsp_strict_config osc, ocsp_get_config ogc, - pinning_enforcement_config pel) + PinningMode pinningMode) : mOCSPDownloadEnabled(odc == ocsp_on) , mOCSPStrict(osc == ocsp_strict) , mOCSPGETEnabled(ogc == ocsp_get_enabled) - , mPinningEnforcementLevel(pel) + , mPinningMode(pinningMode) { } @@ -81,78 +81,45 @@ IsCertBuiltInRoot(CERTCertificate* cert, bool& result) { return SECSuccess; } -struct ChainValidationCallbackState +Result +CertListContainsExpectedKeys(const CERTCertList* certList, + const char* hostname, Time time, + CertVerifier::PinningMode pinningMode) { - const char* hostname; - const CertVerifier::pinning_enforcement_config pinningEnforcementLevel; - const SECCertificateUsage usage; - const Time time; -}; + if (pinningMode == CertVerifier::pinningDisabled) { + PR_LOG(gCertVerifierLog, PR_LOG_DEBUG, + ("Pinning is disabled; not checking keys.")); + return Success; + } -SECStatus chainValidationCallback(void* state, const CERTCertList* certList, - PRBool* chainOK) -{ - ChainValidationCallbackState* callbackState = - reinterpret_cast(state); - - *chainOK = PR_FALSE; - - PR_LOG(gCertVerifierLog, PR_LOG_DEBUG, - ("verifycert: Inside the Callback \n")); - - // On sanity failure we fail closed. if (!certList) { - PR_LOG(gCertVerifierLog, PR_LOG_DEBUG, - ("verifycert: Short circuit, callback, sanity check failed \n")); - PR_SetError(PR_INVALID_STATE_ERROR, 0); - return SECFailure; - } - if (!callbackState) { - PR_LOG(gCertVerifierLog, PR_LOG_DEBUG, - ("verifycert: Short circuit, callback, no state! \n")); - PR_SetError(PR_INVALID_STATE_ERROR, 0); - return SECFailure; + return Result::FATAL_ERROR_INVALID_ARGS; } - if (callbackState->usage != certificateUsageSSLServer || - callbackState->pinningEnforcementLevel == CertVerifier::pinningDisabled) { - PR_LOG(gCertVerifierLog, PR_LOG_DEBUG, - ("verifycert: Callback shortcut pel=%d \n", - callbackState->pinningEnforcementLevel)); - *chainOK = PR_TRUE; - return SECSuccess; + CERTCertListNode* rootNode = CERT_LIST_TAIL(certList); + if (CERT_LIST_END(rootNode, certList)) { + return Result::FATAL_ERROR_INVALID_ARGS; } - for (CERTCertListNode* node = CERT_LIST_HEAD(certList); - !CERT_LIST_END(node, certList); - node = CERT_LIST_NEXT(node)) { - CERTCertificate* currentCert = node->cert; - if (CERT_LIST_END(CERT_LIST_NEXT(node), certList)) { - bool isBuiltInRoot = false; - SECStatus srv = IsCertBuiltInRoot(currentCert, isBuiltInRoot); - if (srv != SECSuccess) { - PR_LOG(gCertVerifierLog, PR_LOG_DEBUG, ("Is BuiltInRoot failure")); - return srv; - } - // If desired, the user can enable "allow user CA MITM mode", in which - // case key pinning is not enforced for certificates that chain to trust - // anchors that are not in Mozilla's root program - if (!isBuiltInRoot && - (callbackState->pinningEnforcementLevel == - CertVerifier::pinningAllowUserCAMITM)) { - *chainOK = PR_TRUE; - return SECSuccess; - } - } + bool isBuiltInRoot = false; + SECStatus srv = IsCertBuiltInRoot(rootNode->cert, isBuiltInRoot); + if (srv != SECSuccess) { + return MapPRErrorCodeToResult(PR_GetError()); + } + // If desired, the user can enable "allow user CA MITM mode", in which + // case key pinning is not enforced for certificates that chain to trust + // anchors that are not in Mozilla's root program + if (!isBuiltInRoot && pinningMode == CertVerifier::pinningAllowUserCAMITM) { + return Success; } - bool enforceTestMode = (callbackState->pinningEnforcementLevel == - CertVerifier::pinningEnforceTestMode); - *chainOK = PublicKeyPinningService:: - ChainHasValidPins(certList, callbackState->hostname, callbackState->time, - enforceTestMode); + bool enforceTestMode = (pinningMode == CertVerifier::pinningEnforceTestMode); + if (PublicKeyPinningService::ChainHasValidPins(certList, hostname, time, + enforceTestMode)) { + return Success; + } - return SECSuccess; + return Result::ERROR_KEY_PINNING_FAILURE; } static Result @@ -216,13 +183,6 @@ CertVerifier::VerifyCert(CERTCertificate* cert, SECCertificateUsage usage, return SECFailure; } - ChainValidationCallbackState callbackState = { - hostname, mPinningEnforcementLevel, usage, time - }; - CERTChainVerifyCallback callbackContainer; - callbackContainer.isChainValid = chainValidationCallback; - callbackContainer.isChainValidArg = &callbackState; - NSSCertDBTrustDomain::OCSPFetching ocspFetching = !mOCSPDownloadEnabled || (flags & FLAG_LOCAL_ONLY) ? NSSCertDBTrustDomain::NeverFetchOCSP @@ -250,8 +210,8 @@ CertVerifier::VerifyCert(CERTCertificate* cert, SECCertificateUsage usage, // XXX: We don't really have a trust bit for SSL client authentication so // just use trustEmail as it is the closest alternative. NSSCertDBTrustDomain trustDomain(trustEmail, ocspFetching, mOCSPCache, - pinArg, ocspGETConfig, nullptr, - builtChain); + pinArg, ocspGETConfig, pinningDisabled, + nullptr, builtChain); rv = BuildCertChain(trustDomain, certDER, time, EndEntityOrCA::MustBeEndEntity, KeyUsage::digitalSignature, @@ -276,8 +236,8 @@ CertVerifier::VerifyCert(CERTCertificate* cert, SECCertificateUsage usage, ocspFetching == NSSCertDBTrustDomain::NeverFetchOCSP ? NSSCertDBTrustDomain::LocalOnlyOCSPForEV : NSSCertDBTrustDomain::FetchOCSPForEV, - mOCSPCache, pinArg, ocspGETConfig, - &callbackContainer, builtChain); + mOCSPCache, pinArg, ocspGETConfig, mPinningMode, + hostname, builtChain); rv = BuildCertChainForOneKeyUsage(trustDomain, certDER, time, KeyUsage::digitalSignature,// (EC)DHE KeyUsage::keyEncipherment, // RSA @@ -300,8 +260,8 @@ CertVerifier::VerifyCert(CERTCertificate* cert, SECCertificateUsage usage, // Now try non-EV. NSSCertDBTrustDomain trustDomain(trustSSL, ocspFetching, mOCSPCache, - pinArg, ocspGETConfig, &callbackContainer, - builtChain); + pinArg, ocspGETConfig, mPinningMode, + hostname, builtChain); rv = BuildCertChainForOneKeyUsage(trustDomain, certDER, time, KeyUsage::digitalSignature, // (EC)DHE KeyUsage::keyEncipherment, // RSA @@ -314,8 +274,8 @@ CertVerifier::VerifyCert(CERTCertificate* cert, SECCertificateUsage usage, case certificateUsageSSLCA: { NSSCertDBTrustDomain trustDomain(trustSSL, ocspFetching, mOCSPCache, - pinArg, ocspGETConfig, nullptr, - builtChain); + pinArg, ocspGETConfig, pinningDisabled, + nullptr, builtChain); rv = BuildCertChain(trustDomain, certDER, time, EndEntityOrCA::MustBeCA, KeyUsage::keyCertSign, KeyPurposeId::id_kp_serverAuth, @@ -325,8 +285,8 @@ CertVerifier::VerifyCert(CERTCertificate* cert, SECCertificateUsage usage, case certificateUsageEmailSigner: { NSSCertDBTrustDomain trustDomain(trustEmail, ocspFetching, mOCSPCache, - pinArg, ocspGETConfig, nullptr, - builtChain); + pinArg, ocspGETConfig, pinningDisabled, + nullptr, builtChain); rv = BuildCertChain(trustDomain, certDER, time, EndEntityOrCA::MustBeEndEntity, KeyUsage::digitalSignature, @@ -340,8 +300,8 @@ CertVerifier::VerifyCert(CERTCertificate* cert, SECCertificateUsage usage, // usage it is trying to verify for, and base its algorithm choices // based on the result of the verification(s). NSSCertDBTrustDomain trustDomain(trustEmail, ocspFetching, mOCSPCache, - pinArg, ocspGETConfig, nullptr, - builtChain); + pinArg, ocspGETConfig, pinningDisabled, + nullptr, builtChain); rv = BuildCertChain(trustDomain, certDER, time, EndEntityOrCA::MustBeEndEntity, KeyUsage::keyEncipherment, // RSA @@ -360,7 +320,7 @@ CertVerifier::VerifyCert(CERTCertificate* cert, SECCertificateUsage usage, case certificateUsageObjectSigner: { NSSCertDBTrustDomain trustDomain(trustObjectSigning, ocspFetching, mOCSPCache, pinArg, ocspGETConfig, - nullptr, builtChain); + pinningDisabled, nullptr, builtChain); rv = BuildCertChain(trustDomain, certDER, time, EndEntityOrCA::MustBeEndEntity, KeyUsage::digitalSignature, @@ -388,14 +348,15 @@ CertVerifier::VerifyCert(CERTCertificate* cert, SECCertificateUsage usage, } NSSCertDBTrustDomain sslTrust(trustSSL, ocspFetching, mOCSPCache, pinArg, - ocspGETConfig, nullptr, builtChain); + ocspGETConfig, pinningDisabled, nullptr, + builtChain); rv = BuildCertChain(sslTrust, certDER, time, endEntityOrCA, keyUsage, eku, CertPolicyId::anyPolicy, stapledOCSPResponse); if (rv == Result::ERROR_UNKNOWN_ISSUER) { NSSCertDBTrustDomain emailTrust(trustEmail, ocspFetching, mOCSPCache, - pinArg, ocspGETConfig, nullptr, - builtChain); + pinArg, ocspGETConfig, pinningDisabled, + nullptr, builtChain); rv = BuildCertChain(emailTrust, certDER, time, endEntityOrCA, keyUsage, eku, CertPolicyId::anyPolicy, stapledOCSPResponse); @@ -403,7 +364,8 @@ CertVerifier::VerifyCert(CERTCertificate* cert, SECCertificateUsage usage, NSSCertDBTrustDomain objectSigningTrust(trustObjectSigning, ocspFetching, mOCSPCache, pinArg, ocspGETConfig, - nullptr, builtChain); + pinningDisabled, nullptr, + builtChain); rv = BuildCertChain(objectSigningTrust, certDER, time, endEntityOrCA, keyUsage, eku, CertPolicyId::anyPolicy, stapledOCSPResponse); @@ -418,7 +380,8 @@ CertVerifier::VerifyCert(CERTCertificate* cert, SECCertificateUsage usage, } if (rv != Success) { - if (rv != Result::ERROR_KEY_PINNING_FAILURE) { + if (rv != Result::ERROR_KEY_PINNING_FAILURE && + usage == certificateUsageSSLServer) { ScopedCERTCertificate certCopy(CERT_DupCertificate(cert)); if (!certCopy) { return SECFailure; @@ -432,13 +395,10 @@ CertVerifier::VerifyCert(CERTCertificate* cert, SECCertificateUsage usage, return SECFailure; } certCopy.forget(); // now owned by certList - PRBool chainOK = false; - srv = chainValidationCallback(&callbackState, certList, &chainOK); - if (srv != SECSuccess) { - return SECFailure; - } - if (!chainOK) { - rv = Result::ERROR_KEY_PINNING_FAILURE; + Result pinningResult = CertListContainsExpectedKeys(certList, hostname, + time, mPinningMode); + if (pinningResult != Success) { + rv = pinningResult; } } PR_SetError(MapResultToPRErrorCode(rv), 0); diff --git a/security/certverifier/CertVerifier.h b/security/certverifier/CertVerifier.h index 93ab1b5231e5..62ce8af87f17 100644 --- a/security/certverifier/CertVerifier.h +++ b/security/certverifier/CertVerifier.h @@ -47,7 +47,7 @@ public: /*optional out*/ ScopedCERTCertList* builtChain = nullptr, /*optional out*/ SECOidTag* evOidPolicy = nullptr); - enum pinning_enforcement_config { + enum PinningMode { pinningDisabled = 0, pinningAllowUserCAMITM = 1, pinningStrict = 2, @@ -63,8 +63,7 @@ public: bool IsOCSPDownloadEnabled() const { return mOCSPDownloadEnabled; } CertVerifier(ocsp_download_config odc, ocsp_strict_config osc, - ocsp_get_config ogc, - pinning_enforcement_config pinningEnforcementLevel); + ocsp_get_config ogc, PinningMode pinningMode); ~CertVerifier(); void ClearOCSPCache() { mOCSPCache.Clear(); } @@ -72,7 +71,7 @@ public: const bool mOCSPDownloadEnabled; const bool mOCSPStrict; const bool mOCSPGETEnabled; - const pinning_enforcement_config mPinningEnforcementLevel; + const PinningMode mPinningMode; private: OCSPCache mOCSPCache; @@ -80,6 +79,9 @@ private: void InitCertVerifierLog(); SECStatus IsCertBuiltInRoot(CERTCertificate* cert, bool& result); +mozilla::pkix::Result CertListContainsExpectedKeys( + const CERTCertList* certList, const char* hostname, mozilla::pkix::Time time, + CertVerifier::PinningMode pinningMode); } } // namespace mozilla::psm diff --git a/security/certverifier/NSSCertDBTrustDomain.cpp b/security/certverifier/NSSCertDBTrustDomain.cpp index 85fdd40332cf..bea082f41d79 100644 --- a/security/certverifier/NSSCertDBTrustDomain.cpp +++ b/security/certverifier/NSSCertDBTrustDomain.cpp @@ -52,14 +52,16 @@ NSSCertDBTrustDomain::NSSCertDBTrustDomain(SECTrustType certDBTrustType, OCSPCache& ocspCache, /*optional but shouldn't be*/ void* pinArg, CertVerifier::ocsp_get_config ocspGETConfig, - /*optional*/ CERTChainVerifyCallback* checkChainCallback, + CertVerifier::PinningMode pinningMode, + /*optional*/ const char* hostname, /*optional*/ ScopedCERTCertList* builtChain) : mCertDBTrustType(certDBTrustType) , mOCSPFetching(ocspFetching) , mOCSPCache(ocspCache) , mPinArg(pinArg) , mOCSPGetConfig(ocspGETConfig) - , mCheckChainCallback(checkChainCallback) + , mPinningMode(pinningMode) + , mHostname(hostname) , mBuiltChain(builtChain) { } @@ -633,16 +635,10 @@ NSSCertDBTrustDomain::VerifyAndMaybeCacheEncodedOCSPResponse( } Result -NSSCertDBTrustDomain::IsChainValid(const DERArray& certArray) +NSSCertDBTrustDomain::IsChainValid(const DERArray& certArray, Time time) { PR_LOG(gCertVerifierLog, PR_LOG_DEBUG, - ("NSSCertDBTrustDomain: Top of IsChainValid mCheckChainCallback=%p", - mCheckChainCallback)); - - if (!mBuiltChain && !mCheckChainCallback) { - // No need to create a CERTCertList, and nothing else to do. - return Success; - } + ("NSSCertDBTrustDomain: IsChainValid")); ScopedCERTCertList certList; SECStatus srv = ConstructCERTCertListFromReversedDERArray(certArray, @@ -651,19 +647,10 @@ NSSCertDBTrustDomain::IsChainValid(const DERArray& certArray) return MapPRErrorCodeToResult(PR_GetError()); } - if (mCheckChainCallback) { - if (!mCheckChainCallback->isChainValid) { - return Result::FATAL_ERROR_INVALID_ARGS; - } - PRBool chainOK; - srv = (mCheckChainCallback->isChainValid)( - mCheckChainCallback->isChainValidArg, certList.get(), &chainOK); - if (srv != SECSuccess) { - return MapPRErrorCodeToResult(PR_GetError()); - } - if (!chainOK) { - return Result::ERROR_KEY_PINNING_FAILURE; - } + Result result = CertListContainsExpectedKeys(certList, mHostname, time, + mPinningMode); + if (result != Success) { + return result; } if (mBuiltChain) { diff --git a/security/certverifier/NSSCertDBTrustDomain.h b/security/certverifier/NSSCertDBTrustDomain.h index 769b47200913..fa66fef4d801 100644 --- a/security/certverifier/NSSCertDBTrustDomain.h +++ b/security/certverifier/NSSCertDBTrustDomain.h @@ -53,8 +53,9 @@ public: NSSCertDBTrustDomain(SECTrustType certDBTrustType, OCSPFetching ocspFetching, OCSPCache& ocspCache, void* pinArg, CertVerifier::ocsp_get_config ocspGETConfig, - /*optional*/ CERTChainVerifyCallback* checkChainCallback = nullptr, - /*optional*/ ScopedCERTCertList* builtChain = nullptr); + CertVerifier::PinningMode pinningMode, + /*optional*/ const char* hostname = nullptr, + /*optional out*/ ScopedCERTCertList* builtChain = nullptr); virtual Result FindIssuer(mozilla::pkix::Input encodedIssuerName, IssuerChecker& checker, @@ -86,8 +87,8 @@ public: /*optional*/ const mozilla::pkix::Input* aiaExtension) MOZ_OVERRIDE; - virtual Result IsChainValid(const mozilla::pkix::DERArray& certChain) - MOZ_OVERRIDE; + virtual Result IsChainValid(const mozilla::pkix::DERArray& certChain, + mozilla::pkix::Time time) MOZ_OVERRIDE; private: enum EncodedResponseSource { @@ -104,7 +105,8 @@ private: OCSPCache& mOCSPCache; // non-owning! void* mPinArg; // non-owning! const CertVerifier::ocsp_get_config mOCSPGetConfig; - CERTChainVerifyCallback* mCheckChainCallback; // non-owning! + CertVerifier::PinningMode mPinningMode; + const char* mHostname; // non-owning - only used for pinning checks ScopedCERTCertList* mBuiltChain; // non-owning }; diff --git a/security/manager/ssl/src/SharedCertVerifier.h b/security/manager/ssl/src/SharedCertVerifier.h index db54b6aa218a..b5859de877d1 100644 --- a/security/manager/ssl/src/SharedCertVerifier.h +++ b/security/manager/ssl/src/SharedCertVerifier.h @@ -20,9 +20,8 @@ public: NS_INLINE_DECL_THREADSAFE_REFCOUNTING(SharedCertVerifier) SharedCertVerifier(ocsp_download_config odc, ocsp_strict_config osc, - ocsp_get_config ogc, - pinning_enforcement_config pinningEnforcementLevel) - : mozilla::psm::CertVerifier(odc, osc, ogc, pinningEnforcementLevel) + ocsp_get_config ogc, PinningMode pinningMode) + : mozilla::psm::CertVerifier(odc, osc, ogc, pinningMode) { } }; diff --git a/security/manager/ssl/src/nsNSSComponent.cpp b/security/manager/ssl/src/nsNSSComponent.cpp index daa45bd5681a..0f6b3596ef35 100644 --- a/security/manager/ssl/src/nsNSSComponent.cpp +++ b/security/manager/ssl/src/nsNSSComponent.cpp @@ -817,14 +817,12 @@ void nsNSSComponent::setValidationOptions(bool isInitialSetting, PublicSSLState()->SetOCSPStaplingEnabled(ocspStaplingEnabled); PrivateSSLState()->SetOCSPStaplingEnabled(ocspStaplingEnabled); - // Default pinning enforcement level is disabled. - CertVerifier::pinning_enforcement_config - pinningEnforcementLevel = - static_cast - (Preferences::GetInt("security.cert_pinning.enforcement_level", - CertVerifier::pinningDisabled)); - if (pinningEnforcementLevel > CertVerifier::pinningEnforceTestMode) { - pinningEnforcementLevel = CertVerifier::pinningDisabled; + CertVerifier::PinningMode pinningMode = + static_cast + (Preferences::GetInt("security.cert_pinning.enforcement_level", + CertVerifier::pinningDisabled)); + if (pinningMode > CertVerifier::pinningEnforceTestMode) { + pinningMode = CertVerifier::pinningDisabled; } CertVerifier::ocsp_download_config odc; @@ -832,8 +830,7 @@ void nsNSSComponent::setValidationOptions(bool isInitialSetting, CertVerifier::ocsp_get_config ogc; GetOCSPBehaviorFromPrefs(&odc, &osc, &ogc, lock); - mDefaultCertVerifier = new SharedCertVerifier(odc, osc, ogc, - pinningEnforcementLevel); + mDefaultCertVerifier = new SharedCertVerifier(odc, osc, ogc, pinningMode); } // Enable the TLS versions given in the prefs, defaulting to SSL 3.0 (min diff --git a/security/pkix/include/pkix/pkixtypes.h b/security/pkix/include/pkix/pkixtypes.h index 09825812b0d4..b80c0faa6314 100644 --- a/security/pkix/include/pkix/pkixtypes.h +++ b/security/pkix/include/pkix/pkixtypes.h @@ -282,7 +282,7 @@ public: // very wrong to assume that the certificate chain is valid. // // certChain.GetDER(0) is the trust anchor. - virtual Result IsChainValid(const DERArray& certChain) = 0; + virtual Result IsChainValid(const DERArray& certChain, Time time) = 0; // issuerCertToDup is only non-const so CERT_DupCertificate can be called on // it. diff --git a/security/pkix/lib/pkixbuild.cpp b/security/pkix/lib/pkixbuild.cpp index 0a786c8790f3..a4fbd66dceb4 100644 --- a/security/pkix/lib/pkixbuild.cpp +++ b/security/pkix/lib/pkixbuild.cpp @@ -246,7 +246,7 @@ BuildForward(TrustDomain& trustDomain, // This must be done here, after the chain is built but before any // revocation checks have been done. - return trustDomain.IsChainValid(chain); + return trustDomain.IsChainValid(chain, time); } if (subject.endEntityOrCA == EndEntityOrCA::MustBeCA) { diff --git a/security/pkix/test/gtest/pkixbuild_tests.cpp b/security/pkix/test/gtest/pkixbuild_tests.cpp index cb468d2ab7de..f37fe3eeda9e 100644 --- a/security/pkix/test/gtest/pkixbuild_tests.cpp +++ b/security/pkix/test/gtest/pkixbuild_tests.cpp @@ -165,7 +165,7 @@ private: return Success; } - virtual Result IsChainValid(const DERArray&) + virtual Result IsChainValid(const DERArray&, Time) { return Success; } diff --git a/security/pkix/test/gtest/pkixcert_extension_tests.cpp b/security/pkix/test/gtest/pkixcert_extension_tests.cpp index 284d9b6b0594..3a2d7d67e274 100644 --- a/security/pkix/test/gtest/pkixcert_extension_tests.cpp +++ b/security/pkix/test/gtest/pkixcert_extension_tests.cpp @@ -87,7 +87,7 @@ private: return Success; } - virtual Result IsChainValid(const DERArray&) + virtual Result IsChainValid(const DERArray&, Time) { return Success; } diff --git a/security/pkix/test/gtest/pkixocsp_CreateEncodedOCSPRequest_tests.cpp b/security/pkix/test/gtest/pkixocsp_CreateEncodedOCSPRequest_tests.cpp index 4a159ebf3799..c8e93b6bb3ba 100644 --- a/security/pkix/test/gtest/pkixocsp_CreateEncodedOCSPRequest_tests.cpp +++ b/security/pkix/test/gtest/pkixocsp_CreateEncodedOCSPRequest_tests.cpp @@ -53,7 +53,7 @@ private: return Result::FATAL_ERROR_LIBRARY_FAILURE; } - virtual Result IsChainValid(const DERArray&) + virtual Result IsChainValid(const DERArray&, Time) { ADD_FAILURE(); return Result::FATAL_ERROR_LIBRARY_FAILURE; diff --git a/security/pkix/test/gtest/pkixocsp_VerifyEncodedOCSPResponse.cpp b/security/pkix/test/gtest/pkixocsp_VerifyEncodedOCSPResponse.cpp index 10be77a32688..75320ecce931 100644 --- a/security/pkix/test/gtest/pkixocsp_VerifyEncodedOCSPResponse.cpp +++ b/security/pkix/test/gtest/pkixocsp_VerifyEncodedOCSPResponse.cpp @@ -63,7 +63,7 @@ public: return Result::FATAL_ERROR_LIBRARY_FAILURE; } - virtual Result IsChainValid(const DERArray&) + virtual Result IsChainValid(const DERArray&, Time) { ADD_FAILURE(); return Result::FATAL_ERROR_LIBRARY_FAILURE; diff --git a/testing/mozbase/mozlog/mozlog/structured/formatters/html/html.py b/testing/mozbase/mozlog/mozlog/structured/formatters/html/html.py index e32e97438314..aa5419426ef4 100755 --- a/testing/mozbase/mozlog/mozlog/structured/formatters/html/html.py +++ b/testing/mozbase/mozlog/mozlog/structured/formatters/html/html.py @@ -3,6 +3,7 @@ # License, v. 2.0. If a copy of the MPL was not distributed with this # file, You can obtain one at http://mozilla.org/MPL/2.0/. +import cgi import datetime import os @@ -96,7 +97,9 @@ class HTMLFormatter(base.BaseFormatter): pass log = html.div(class_='log') - for line in debug.get("stdout", "").splitlines(): + output = data.get('stack', '').splitlines() + output.extend(data.get('message', '').splitlines()) + for line in output: separator = line.startswith(' ' * 10) if separator: log.append(line[:80]) diff --git a/widget/gonk/HwcComposer2D.cpp b/widget/gonk/HwcComposer2D.cpp index 5403d07456ca..c3cd2741367f 100644 --- a/widget/gonk/HwcComposer2D.cpp +++ b/widget/gonk/HwcComposer2D.cpp @@ -389,7 +389,7 @@ HwcComposer2D::PrepareLayerList(Layer* aLayer, } } // Buffer rotation is not to be confused with the angled rotation done by a transform matrix - // It's a fancy ThebesLayer feature used for scrolling + // It's a fancy PaintedLayer feature used for scrolling if (state.BufferRotated()) { LOGD("%s Layer has a rotated buffer", aLayer->Name()); return false;