This commit is contained in:
Ryan VanderMeulen 2013-04-12 15:07:48 -04:00
Родитель b9fc7c787b 3dccb9916c
Коммит 216a7c9381
164 изменённых файлов: 2410 добавлений и 1614 удалений

Просмотреть файл

@ -35,13 +35,15 @@ DIST_GARBAGE = config.cache config.log config.status* config-defs.h \
netwerk/necko-config.h xpcom/xpcom-config.h xpcom/xpcom-private.h \
$(topsrcdir)/.mozconfig.mk $(topsrcdir)/.mozconfig.out
ifndef MOZ_PROFILE_USE
default alldep all:: CLOBBER $(topsrcdir)/configure config.status
$(RM) -r $(DIST)/sdk
$(RM) -r $(DIST)/include
$(RM) -r $(DIST)/private
$(RM) -r $(DIST)/public
$(RM) $(DIST)/bin/chrome.manifest $(DIST)/bin/components/components.manifest
$(RM) -r $(DIST)/bin
$(RM) -r _tests
endif
CLOBBER: $(topsrcdir)/CLOBBER
@echo "STOP! The CLOBBER file has changed."

Просмотреть файл

@ -11,11 +11,6 @@ this.EXPORTED_SYMBOLS = ["TelURIParser"];
*/
this.TelURIParser = {
parseURI: function(scheme, uri) {
// Ignore MWI and USSD codes. See 794034.
if (uri.indexOf('*') != -1 || uri.indexOf('#') != -1) {
return null;
}
// https://www.ietf.org/rfc/rfc2806.txt
let subscriber = uri.slice((scheme + ':').length);
@ -114,6 +109,11 @@ this.TelURIParser = {
}
}
// Ignore MWI and USSD codes. See 794034.
if (number.match(/[#\*]/) && !number.match(/^[#\*]\d+$/)) {
return null;
}
return number || null;
}
};

Просмотреть файл

@ -0,0 +1,18 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
function run_test() {
Components.utils.import("resource:///modules/TelURIParser.jsm")
// blocked numbers
do_check_eq(TelURIParser.parseURI('tel', 'tel:#1234*'), null);
do_check_eq(TelURIParser.parseURI('tel', 'tel:*1234#'), null);
do_check_eq(TelURIParser.parseURI('tel', 'tel:*1234*'), null);
do_check_eq(TelURIParser.parseURI('tel', 'tel:#1234#'), null);
do_check_eq(TelURIParser.parseURI('tel', 'tel:*#*#7780#*#*'), null);
do_check_eq(TelURIParser.parseURI('tel', 'tel:*1234AB'), null);
// white list
do_check_eq(TelURIParser.parseURI('tel', 'tel:*1234'), '*1234');
do_check_eq(TelURIParser.parseURI('tel', 'tel:#1234'), '#1234');
}

Просмотреть файл

@ -4,6 +4,8 @@ tail =
[test_bug793310.js]
[test_bug832946.js]
[test_signintowebsite.js]
head = head_identity.js
tail =

Просмотреть файл

@ -227,6 +227,18 @@
<menuitem value="20" label="20"/>
<menuitem value="22" label="22"/>
<menuitem value="24" label="24"/>
<menuitem value="26" label="26"/>
<menuitem value="28" label="28"/>
<menuitem value="30" label="30"/>
<menuitem value="32" label="32"/>
<menuitem value="34" label="34"/>
<menuitem value="36" label="36"/>
<menuitem value="40" label="40"/>
<menuitem value="44" label="44"/>
<menuitem value="48" label="48"/>
<menuitem value="56" label="56"/>
<menuitem value="64" label="64"/>
<menuitem value="72" label="72"/>
</menupopup>
</menulist>
</hbox>

Просмотреть файл

@ -151,6 +151,9 @@ libs-%:
$(NSINSTALL) -D $(DIST)/install
@$(MAKE) -C ../../toolkit/locales libs-$*
@$(MAKE) -C ../../services/sync/locales AB_CD=$* XPI_NAME=locale-$*
ifdef MOZ_WEBAPP_RUNTIME
@$(MAKE) -C ../../webapprt/locales AB_CD=$* XPI_NAME=locale-$*
endif
@$(MAKE) -C ../../extensions/spellcheck/locales AB_CD=$* XPI_NAME=locale-$*
@$(MAKE) -C ../../intl/locales AB_CD=$* XPI_NAME=locale-$*
@$(MAKE) libs AB_CD=$* XPI_NAME=locale-$* PREF_DIR=$(PREF_DIR)

Просмотреть файл

@ -6,8 +6,8 @@ def test(mod, path, entity = None):
import re
# ignore anything but Firefox
if mod not in ("netwerk", "dom", "toolkit", "security/manager",
"browser", "browser/metro", "extensions/reporter",
"extensions/spellcheck",
"browser", "browser/metro", "webapprt",
"extensions/reporter", "extensions/spellcheck",
"other-licenses/branding/firefox",
"browser/branding/official",
"services/sync"):

Просмотреть файл

@ -132,9 +132,3 @@
% locale pdf.js @AB_CD@ %locale/pdfviewer/
locale/pdfviewer/viewer.properties (%pdfviewer/viewer.properties)
locale/pdfviewer/chrome.properties (%pdfviewer/chrome.properties)
#ifdef MOZ_WEBAPP_RUNTIME
../../webapprt/chrome/@AB_CD@.jar:
% locale webapprt @AB_CD@ %locale/webapprt/
locale/webapprt/webapp.dtd (%webapprt/webapp.dtd)
locale/webapprt/webapp.properties (%webapprt/webapp.properties)
#endif

Просмотреть файл

@ -17,6 +17,7 @@ dirs = browser
# RFE: that needs to be supported by compare-locales, too, though
toolkit = toolkit/locales/l10n.ini
services_sync = services/sync/locales/l10n.ini
webapprt = webapprt/locales/l10n.ini
[extras]
dirs = extensions/spellcheck

Просмотреть файл

@ -188,8 +188,13 @@ var ContextMenuUI = {
return false;
}
let coords =
aMessage.target.msgBrowserToClient(aMessage, true);
let coords = { x: aMessage.json.xPos, y: aMessage.json.yPos };
// chrome calls don't need to be translated and as such
// don't provide target.
if (aMessage.target) {
coords = aMessage.target.msgBrowserToClient(aMessage, true);
}
this._menuPopup.show(Util.extend({}, this._defaultPositionOptions, {
xPos: coords.x,
yPos: coords.y,

Просмотреть файл

@ -202,6 +202,11 @@ if test "$CPU_ARCH" = "arm"; then
HAVE_ARM_SIMD=1
fi
AC_MSG_CHECKING(ARM version support in compiler)
dnl Determine the target ARM architecture (5 for ARMv5, v5T, v5E, etc.; 6 for ARMv6, v6K, etc.)
ARM_ARCH=`${CC-cc} ${CFLAGS} -dM -E - < /dev/null | sed -n 's/.*__ARM_ARCH_\([[0-9]]*\).*/\1/p'`
AC_MSG_RESULT("$ARM_ARCH")
AC_MSG_CHECKING(for ARM NEON support in compiler)
# We try to link so that this also fails when
# building with LTO.
@ -212,16 +217,23 @@ if test "$CPU_ARCH" = "arm"; then
if test "$result" = "yes"; then
AC_DEFINE(HAVE_ARM_NEON)
HAVE_ARM_NEON=1
dnl We don't need to build NEON support if we're targetting a non-NEON device.
dnl This matches media/webrtc/trunk/webrtc/build/common.gypi.
if test -n "$ARM_ARCH"; then
if test "$ARM_ARCH" -lt 7; then
BUILD_ARM_NEON=0
else
BUILD_ARM_NEON=1
fi
fi
fi
AC_MSG_CHECKING(ARM version support in compiler)
dnl Determine the target ARM architecture (5 for ARMv5, v5T, v5E, etc.; 6 for ARMv6, v6K, etc.)
ARM_ARCH=`${CC-cc} ${CFLAGS} -dM -E - < /dev/null | sed -n 's/.*__ARM_ARCH_\([[0-9]]*\).*/\1/p'`
AC_MSG_RESULT("$ARM_ARCH")
fi # CPU_ARCH = arm
AC_SUBST(HAVE_ARM_SIMD)
AC_SUBST(HAVE_ARM_NEON)
AC_SUBST(BUILD_ARM_NEON)
if test -n "$MOZ_ARCH"; then
NSPR_CONFIGURE_ARGS="$NSPR_CONFIGURE_ARGS --with-arch=$MOZ_ARCH"

Просмотреть файл

@ -38,6 +38,7 @@ import android.net.wifi.WifiInfo;
import android.net.wifi.WifiManager;
import android.net.wifi.WifiManager.WifiLock;
import android.os.BatteryManager;
import android.os.Build;
import android.os.Build.VERSION;
import android.os.Bundle;
import android.os.Handler;
@ -74,6 +75,7 @@ public class SUTAgentAndroid extends Activity
private static String RegSvrIPPort = "";
private static String HardwareID = "";
private static String Pool = "";
private static String Abi = "";
private static String sRegString = "";
private static boolean LogCommands = false;
@ -172,6 +174,7 @@ public class SUTAgentAndroid extends Activity
SUTAgentAndroid.RegSvrIPPort = dc.GetIniData("Registration Server", "PORT", sIniFile);
SUTAgentAndroid.HardwareID = dc.GetIniData("Registration Server", "HARDWARE", sIniFile);
SUTAgentAndroid.Pool = dc.GetIniData("Registration Server", "POOL", sIniFile);
SUTAgentAndroid.Abi = android.os.Build.CPU_ABI;
log(dc, "onCreate");
tv = (TextView) this.findViewById(R.id.Textview01);
@ -277,6 +280,7 @@ public class SUTAgentAndroid extends Activity
String sConfig = "Unique ID: " + sUniqueID + lineSep;
sConfig += "HWID: " + hwid + lineSep;
sConfig += "ABI: " + Abi + lineSep;
sConfig += "OS Info" + lineSep;
sConfig += "\t" + dc.GetOSInfo() + lineSep;
sConfig += "Screen Info" + lineSep;
@ -302,6 +306,7 @@ public class SUTAgentAndroid extends Activity
sRegString += "&MEMORY=" + dc.GetMemoryConfig();
sRegString += "&HARDWARE=" + HardwareID;
sRegString += "&POOL=" + Pool;
sRegString += "&ABI=" + Abi;
String sTemp = Uri.encode(sRegString,"=&");
sRegString = "register " + sTemp;

Просмотреть файл

@ -222,11 +222,12 @@ NS_IMETHODIMP
nsDOMDataChannel::GetReadyState(nsAString& aReadyState)
{
uint16_t readyState = mDataChannel->GetReadyState();
// From the WebRTC spec
const char * stateName[] = {
"Connecting",
"Open",
"Closing",
"Closed"
"connecting",
"open",
"closing",
"closed"
};
MOZ_ASSERT(/*readyState >= mozilla::DataChannel::CONNECTING && */ // Always true due to datatypes
readyState <= mozilla::DataChannel::CLOSED);

Просмотреть файл

@ -5693,9 +5693,10 @@ HTMLInputElement::IsValidEmailAddress(const nsAString& aValue)
NS_ERROR("nsIIDNService isn't present!");
}
// If the email address is empty, begins with a '@' or ends with a '.',
// we know it's invalid.
if (length == 0 || value[0] == '@' || value[length-1] == '.') {
// If the email address is empty, begins with an '@'
// or ends with a '.' or '-', we know it's invalid.
if (length == 0 || value[0] == '@' || value[length-1] == '.' ||
value[length-1] == '-') {
return false;
}
@ -5713,14 +5714,13 @@ HTMLInputElement::IsValidEmailAddress(const nsAString& aValue)
}
}
// There is no domain name (or it's one-character long),
// that's not a valid email address.
// If there is no domain name, that's not a valid email address.
if (++i >= length) {
return false;
}
// The domain name can't begin with a dot.
if (value[i] == '.') {
// The domain name can't begin with a dot or a dash.
if (value[i] == '.' || value[i] == '-') {
return false;
}
@ -5729,7 +5729,12 @@ HTMLInputElement::IsValidEmailAddress(const nsAString& aValue)
PRUnichar c = value[i];
if (c == '.') {
// A dot can't follow a dot.
// A dot can't follow a dot or a dash.
if (value[i-1] == '.' || value[i-1] == '-') {
return false;
}
} else if (c == '-'){
// A dash can't follow a dot.
if (value[i-1] == '.') {
return false;
}

Просмотреть файл

@ -3,6 +3,7 @@
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=555559
https://bugzilla.mozilla.org/show_bug.cgi?id=668817
https://bugzilla.mozilla.org/show_bug.cgi?id=854812
-->
<head>
<title>Test for &lt;input type='email'&gt; validity</title>
@ -12,6 +13,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=668817
<body>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=555559">Mozilla Bug 555559</a>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=668817">Mozilla Bug 668817</a>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=854812">Mozilla Bug 854812</a>
<p id="display"></p>
<div id="content" style="display: none">
<form>
@ -110,6 +112,16 @@ var values = [
// Long strings with UTF-8.
[ 'this.is.email.should.be.longer.than.sixty.four.characters.föö@mözillä.tld', true ],
[ 'this-is-email-should-be-longer-than-sixty-four-characters-föö@mözillä.tld', true, true ],
// The domains labels (sub-domains or tld) can't start or finish with a '-'
[ 'foo@foo-bar', true ],
[ 'foo@-foo', false ],
[ 'foo@foo-.bar', false ],
[ 'foo@-.-', false ],
[ 'foo@fo-o.bar', true ],
[ 'foo@fo-o.-bar', false ],
[ 'foo@fo-o.bar-', false ],
[ 'foo@fo-o.-', false ],
[ 'foo@fo--o', true ],
];
// Multiple values, we don't check e-mail validity, only multiple stuff.
@ -161,9 +173,8 @@ for (c of illegalCharacters) {
legalCharacters = "abcdefghijklmnopqrstuvwxyz";
legalCharacters += "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
legalCharacters += "0123456789";
legalCharacters += "-";
// Add domain legal characters (except '.' because it's special).
// Add domain legal characters (except '.' and '-' because they are special).
for (c of legalCharacters) {
values.push(["foo@foo.bar" + c, true]);
}

Просмотреть файл

@ -10,13 +10,24 @@
#include "AudioNodeEngine.h"
#include "AudioNodeStream.h"
#include "AudioDestinationNode.h"
#include "PannerNode.h"
#include "speex/speex_resampler.h"
namespace mozilla {
namespace dom {
NS_IMPL_CYCLE_COLLECTION_INHERITED_2(AudioBufferSourceNode, AudioNode,
mBuffer, mPlaybackRate)
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(AudioBufferSourceNode, AudioNode)
NS_IMPL_CYCLE_COLLECTION_UNLINK(mBuffer)
NS_IMPL_CYCLE_COLLECTION_UNLINK(mPlaybackRate)
if (tmp->Context()) {
tmp->Context()->UnregisterAudioBufferSourceNode(tmp);
}
NS_IMPL_CYCLE_COLLECTION_UNLINK_END
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(AudioBufferSourceNode, AudioNode)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mBuffer)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mPlaybackRate)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(AudioBufferSourceNode)
NS_INTERFACE_MAP_END_INHERITING(AudioNode)
@ -33,6 +44,7 @@ public:
mOffset(0), mDuration(0),
mLoopStart(0), mLoopEnd(0),
mSampleRate(0), mPosition(0), mChannels(0), mPlaybackRate(1.0f),
mDopplerShift(1.0f),
mDestination(static_cast<AudioNodeStream*>(aDestination->Stream())),
mPlaybackRateTimeline(1.0f), mLoop(false)
{}
@ -56,7 +68,8 @@ public:
LOOP,
LOOPSTART,
LOOPEND,
PLAYBACKRATE
PLAYBACKRATE,
DOPPLERSHIFT
};
virtual void SetTimelineParameter(uint32_t aIndex, const dom::AudioParamTimeline& aValue)
{
@ -87,6 +100,16 @@ public:
NS_ERROR("Bad AudioBufferSourceNodeEngine StreamTimeParameter");
}
}
virtual void SetDoubleParameter(uint32_t aIndex, double aParam)
{
switch (aIndex) {
case DOPPLERSHIFT:
mDopplerShift = aParam;
break;
default:
NS_ERROR("Bad AudioBufferSourceNodeEngine double parameter.");
};
}
virtual void SetInt32Parameter(uint32_t aIndex, int32_t aParam)
{
switch (aIndex) {
@ -115,7 +138,7 @@ public:
if (!mResampler) {
mChannels = aChannels;
mResampler = speex_resampler_init(mChannels, mSampleRate,
IdealAudioRate(),
ComputeFinalOutSampleRate(),
SPEEX_RESAMPLER_QUALITY_DEFAULT,
nullptr);
}
@ -165,9 +188,7 @@ public:
uint32_t aAvailableInInputBuffer,
uint32_t& aFramesRead,
uint32_t& aFramesWritten) {
// Compute the sample rate we want to resample to.
double finalSampleRate = mSampleRate / mPlaybackRate;
double finalPlaybackRate = finalSampleRate / IdealAudioRate();
double finalPlaybackRate = static_cast<double>(mSampleRate) / ComputeFinalOutSampleRate();
uint32_t availableInOuputBuffer = WEBAUDIO_BLOCK_SIZE - aBufferOffset;
uint32_t inputSamples, outputSamples;
@ -247,9 +268,7 @@ public:
uint32_t numFrames = std::min(std::min(WEBAUDIO_BLOCK_SIZE - *aOffsetWithinBlock,
aBufferMax - aBufferOffset),
uint32_t(mStop - *aCurrentPosition));
if (numFrames == WEBAUDIO_BLOCK_SIZE &&
mSampleRate == IdealAudioRate() &&
mPlaybackRate == 1.0f) {
if (numFrames == WEBAUDIO_BLOCK_SIZE && !ShouldResample()) {
BorrowFromInputBuffer(aOutput, aChannels, aBufferOffset);
*aOffsetWithinBlock += numFrames;
*aCurrentPosition += numFrames;
@ -259,7 +278,7 @@ public:
MOZ_ASSERT(*aOffsetWithinBlock == 0);
AllocateAudioBlock(aChannels, aOutput);
}
if (mSampleRate == IdealAudioRate() && mPlaybackRate == 1.0f) {
if (!ShouldResample()) {
CopyFromInputBuffer(aOutput, aChannels, aBufferOffset, *aOffsetWithinBlock, numFrames);
*aOffsetWithinBlock += numFrames;
*aCurrentPosition += numFrames;
@ -285,6 +304,37 @@ public:
return mStart + mPosition;
}
int32_t ComputeFinalOutSampleRate() const
{
return static_cast<uint32_t>(IdealAudioRate() / (mPlaybackRate * mDopplerShift));
}
bool ShouldResample() const
{
return !(mPlaybackRate == 1.0 &&
mDopplerShift == 1.0 &&
mSampleRate == IdealAudioRate());
}
void UpdateSampleRateIfNeeded(AudioNodeStream* aStream)
{
if (mPlaybackRateTimeline.HasSimpleValue()) {
mPlaybackRate = mPlaybackRateTimeline.GetValue();
} else {
mPlaybackRate = mPlaybackRateTimeline.GetValueAtTime<TrackTicks>(aStream->GetCurrentPosition());
}
uint32_t currentOutSampleRate, currentInSampleRate;
if (ShouldResample()) {
SpeexResamplerState* resampler = Resampler(mChannels);
speex_resampler_get_rate(resampler, &currentInSampleRate, &currentOutSampleRate);
uint32_t finalSampleRate = ComputeFinalOutSampleRate();
if (currentOutSampleRate != finalSampleRate) {
speex_resampler_set_rate(resampler, currentInSampleRate, finalSampleRate);
}
}
}
virtual void ProduceAudioBlock(AudioNodeStream* aStream,
const AudioChunk& aInput,
AudioChunk* aOutput,
@ -302,16 +352,7 @@ public:
// WebKit treats the playbackRate as a k-rate parameter in their code,
// despite the spec saying that it should be an a-rate parameter. We treat
// it as k-rate. Spec bug: https://www.w3.org/Bugs/Public/show_bug.cgi?id=21592
float newPlaybackRate;
if (mPlaybackRateTimeline.HasSimpleValue()) {
newPlaybackRate = mPlaybackRateTimeline.GetValue();
} else {
newPlaybackRate = mPlaybackRateTimeline.GetValueAtTime<TrackTicks>(aStream->GetCurrentPosition());
}
if (newPlaybackRate != mPlaybackRate) {
mPlaybackRate = newPlaybackRate;
speex_resampler_set_rate(Resampler(mChannels), mSampleRate, mSampleRate / mPlaybackRate);
}
UpdateSampleRateIfNeeded(aStream);
uint32_t written = 0;
TrackTicks currentPosition = GetPosition(aStream);
@ -362,6 +403,7 @@ public:
uint32_t mPosition;
uint32_t mChannels;
float mPlaybackRate;
float mDopplerShift;
AudioNodeStream* mDestination;
AudioParamTimeline mPlaybackRateTimeline;
bool mLoop;
@ -374,6 +416,7 @@ AudioBufferSourceNode::AudioBufferSourceNode(AudioContext* aContext)
, mLoop(false)
, mStartCalled(false)
, mPlaybackRate(new AudioParam(this, SendPlaybackRateToStream, 1.0f))
, mPannerNode(nullptr)
{
SetProduceOwnOutput(true);
mStream = aContext->Graph()->CreateAudioNodeStream(
@ -384,6 +427,10 @@ AudioBufferSourceNode::AudioBufferSourceNode(AudioContext* aContext)
AudioBufferSourceNode::~AudioBufferSourceNode()
{
//
if (Context()) {
Context()->UnregisterAudioBufferSourceNode(this);
}
DestroyMediaStream();
}
@ -492,5 +539,11 @@ AudioBufferSourceNode::SendPlaybackRateToStream(AudioNode* aNode)
SendTimelineParameterToStream(This, AudioBufferSourceNodeEngine::PLAYBACKRATE, *This->mPlaybackRate);
}
void
AudioBufferSourceNode::SendDopplerShiftToStream(double aDopplerShift)
{
SendDoubleParameterToStream(AudioBufferSourceNodeEngine::DOPPLERSHIFT, aDopplerShift);
}
}
}

Просмотреть файл

@ -9,6 +9,7 @@
#include "AudioNode.h"
#include "AudioBuffer.h"
#include "AudioParam.h"
#include "mozilla/dom/BindingUtils.h"
namespace mozilla {
@ -36,6 +37,18 @@ public:
{
return 0;
}
virtual AudioBufferSourceNode* AsAudioBufferSourceNode() MOZ_OVERRIDE
{
return this;
}
void UnregisterPannerNode() {
mPannerNode = nullptr;
}
void RegisterPannerNode(PannerNode* aPannerNode) {
mPannerNode = aPannerNode;
}
void JSBindingFinalized()
{
@ -107,6 +120,7 @@ public:
{
mLoopEnd = aEnd;
}
void SendDopplerShiftToStream(double aDopplerShift);
virtual void NotifyMainThreadStateChanged() MOZ_OVERRIDE;
@ -118,6 +132,7 @@ private:
bool mLoop;
bool mStartCalled;
nsRefPtr<AudioParam> mPlaybackRate;
PannerNode* mPannerNode;
};
}

Просмотреть файл

@ -71,6 +71,7 @@ AudioContext::CreateBufferSource()
{
nsRefPtr<AudioBufferSourceNode> bufferNode =
new AudioBufferSourceNode(this);
mAudioBufferSourceNodes.AppendElement(bufferNode);
return bufferNode.forget();
}
@ -128,6 +129,7 @@ already_AddRefed<PannerNode>
AudioContext::CreatePanner()
{
nsRefPtr<PannerNode> pannerNode = new PannerNode(this);
mPannerNodes.AppendElement(pannerNode);
return pannerNode.forget();
}
@ -187,6 +189,29 @@ AudioContext::RemoveFromDecodeQueue(WebAudioDecodeJob* aDecodeJob)
mDecodeJobs.RemoveElement(aDecodeJob);
}
void
AudioContext::UnregisterAudioBufferSourceNode(AudioBufferSourceNode* aNode)
{
mAudioBufferSourceNodes.RemoveElement(aNode);
}
void
AudioContext::UnregisterPannerNode(PannerNode* aNode)
{
mPannerNodes.RemoveElement(aNode);
}
void
AudioContext::UpdatePannerSource()
{
for (unsigned i = 0; i < mAudioBufferSourceNodes.Length(); i++) {
mAudioBufferSourceNodes[i]->UnregisterPannerNode();
}
for (unsigned i = 0; i < mPannerNodes.Length(); i++) {
mPannerNodes[i]->FindConnectedSources();
}
}
MediaStreamGraph*
AudioContext::Graph() const
{

Просмотреть файл

@ -138,6 +138,9 @@ public:
MediaStreamGraph* Graph() const;
MediaStream* DestinationStream() const;
void UnregisterAudioBufferSourceNode(AudioBufferSourceNode* aNode);
void UnregisterPannerNode(PannerNode* aNode);
void UpdatePannerSource();
private:
void RemoveFromDecodeQueue(WebAudioDecodeJob* aDecodeJob);
@ -150,6 +153,10 @@ private:
nsRefPtr<AudioListener> mListener;
MediaBufferDecoder mDecoder;
nsTArray<nsAutoPtr<WebAudioDecodeJob> > mDecodeJobs;
// Two arrays containing all the PannerNodes and AudioBufferSourceNodes,
// to compute the doppler shift. Those are weak pointers.
nsTArray<PannerNode*> mPannerNodes;
nsTArray<AudioBufferSourceNode*> mAudioBufferSourceNodes;
};
}

Просмотреть файл

@ -49,6 +49,7 @@ AudioListener::RegisterPannerNode(PannerNode* aPannerNode)
aPannerNode->SendThreeDPointParameterToStream(PannerNode::LISTENER_VELOCITY, mVelocity);
aPannerNode->SendDoubleParameterToStream(PannerNode::LISTENER_DOPPLER_FACTOR, mDopplerFactor);
aPannerNode->SendDoubleParameterToStream(PannerNode::LISTENER_SPEED_OF_SOUND, mSpeedOfSound);
UpdatePannersVelocity();
}
void
@ -71,6 +72,15 @@ AudioListener::SendThreeDPointParameterToStream(uint32_t aIndex, const ThreeDPoi
}
}
void AudioListener::UpdatePannersVelocity()
{
for (uint32_t i = 0; i < mPanners.Length(); ++i) {
if (mPanners[i]) {
mPanners[i]->SendDopplerToSourcesIfNeeded();
}
}
}
}
}

Просмотреть файл

@ -80,6 +80,11 @@ public:
SendThreeDPointParameterToStream(PannerNode::LISTENER_POSITION, mPosition);
}
const ThreeDPoint& Position() const
{
return mPosition;
}
void SetOrientation(double aX, double aY, double aZ,
double aXUp, double aYUp, double aZUp)
{
@ -101,6 +106,11 @@ public:
SendThreeDPointParameterToStream(PannerNode::LISTENER_UPVECTOR, mUpVector);
}
const ThreeDPoint& Velocity() const
{
return mVelocity;
}
void SetVelocity(double aX, double aY, double aZ)
{
if (WebAudioUtils::FuzzyEqual(mVelocity.x, aX) &&
@ -112,6 +122,7 @@ public:
mVelocity.y = aY;
mVelocity.z = aZ;
SendThreeDPointParameterToStream(PannerNode::LISTENER_VELOCITY, mVelocity);
UpdatePannersVelocity();
}
void RegisterPannerNode(PannerNode* aPannerNode);
@ -119,6 +130,7 @@ public:
private:
void SendDoubleParameterToStream(uint32_t aIndex, double aValue);
void SendThreeDPointParameterToStream(uint32_t aIndex, const ThreeDPoint& aValue);
void UpdatePannersVelocity();
private:
friend class PannerNode;

Просмотреть файл

@ -173,6 +173,9 @@ AudioNode::Connect(AudioNode& aDestination, uint32_t aOutput,
input->mStreamPort =
ps->AllocateInputPort(mStream, MediaInputPort::FLAG_BLOCK_INPUT);
}
// This connection may have connected a panner and a source.
Context()->UpdatePannerSource();
}
void
@ -239,6 +242,9 @@ AudioNode::Disconnect(uint32_t aOutput, ErrorResult& aRv)
for (uint32_t i = 0; i < outputsToUpdate.Length(); ++i) {
outputsToUpdate[i]->UpdateOutputEnded();
}
// This disconnection may have disconnected a panner and a source.
Context()->UpdatePannerSource();
}
}

Просмотреть файл

@ -80,6 +80,10 @@ public:
UpdateOutputEnded();
}
virtual AudioBufferSourceNode* AsAudioBufferSourceNode() {
return nullptr;
}
AudioContext* GetParentObject() const
{
return mContext;
@ -135,6 +139,11 @@ public:
}
}
const nsTArray<InputNode>& InputNodes() const
{
return mInputNodes;
}
protected:
static void Callback(AudioNode* aNode) { /* not implemented */ }

Просмотреть файл

@ -8,6 +8,7 @@
#include "AudioNodeEngine.h"
#include "AudioNodeStream.h"
#include "AudioListener.h"
#include "AudioBufferSourceNode.h"
namespace mozilla {
namespace dom {
@ -179,6 +180,7 @@ PannerNode::PannerNode(AudioContext* aContext)
PannerNode::~PannerNode()
{
Context()->UnregisterPannerNode(this);
DestroyMediaStream();
}
@ -416,6 +418,96 @@ PannerNodeEngine::ComputeConeGain()
return gain;
}
float
PannerNode::ComputeDopplerShift()
{
double dopplerShift = 1.0; // Initialize to default value
AudioListener* listener = Context()->Listener();
if (listener->DopplerFactor() > 0) {
// Don't bother if both source and listener have no velocity.
if (!mVelocity.IsZero() || !listener->Velocity().IsZero()) {
// Calculate the source to listener vector.
ThreeDPoint sourceToListener = mPosition - listener->Velocity();
double sourceListenerMagnitude = sourceToListener.Magnitude();
double listenerProjection = sourceToListener.DotProduct(listener->Velocity()) / sourceListenerMagnitude;
double sourceProjection = sourceToListener.DotProduct(mVelocity) / sourceListenerMagnitude;
listenerProjection = -listenerProjection;
sourceProjection = -sourceProjection;
double scaledSpeedOfSound = listener->DopplerFactor() / listener->DopplerFactor();
listenerProjection = min(listenerProjection, scaledSpeedOfSound);
sourceProjection = min(sourceProjection, scaledSpeedOfSound);
dopplerShift = ((listener->SpeedOfSound() - listener->DopplerFactor() * listenerProjection) / (listener->SpeedOfSound() - listener->DopplerFactor() * sourceProjection));
WebAudioUtils::FixNaN(dopplerShift); // Avoid illegal values
// Limit the pitch shifting to 4 octaves up and 3 octaves down.
dopplerShift = min(dopplerShift, 16.);
dopplerShift = max(dopplerShift, 0.125);
}
}
return dopplerShift;
}
void
PannerNode::FindConnectedSources()
{
mSources.Clear();
std::set<AudioNode*> cycleSet;
FindConnectedSources(this, mSources, cycleSet);
for (unsigned i = 0; i < mSources.Length(); i++) {
mSources[i]->RegisterPannerNode(this);
}
}
void
PannerNode::FindConnectedSources(AudioNode* aNode,
nsTArray<AudioBufferSourceNode*>& aSources,
std::set<AudioNode*>& aNodesSeen)
{
if (!aNode) {
return;
}
const nsTArray<InputNode>& inputNodes = aNode->InputNodes();
for(unsigned i = 0; i < inputNodes.Length(); i++) {
// Return if we find a node that we have seen already.
if (aNodesSeen.find(inputNodes[i].mInputNode) != aNodesSeen.end()) {
return;
}
aNodesSeen.insert(inputNodes[i].mInputNode);
// Recurse
FindConnectedSources(inputNodes[i].mInputNode, aSources, aNodesSeen);
// Check if this node is an AudioBufferSourceNode
AudioBufferSourceNode* node = inputNodes[i].mInputNode->AsAudioBufferSourceNode();
if (node) {
aSources.AppendElement(node);
}
}
}
void
PannerNode::SendDopplerToSourcesIfNeeded()
{
// Don't bother sending the doppler shift if both the source and the listener
// are not moving, because the doppler shift is going to be 1.0.
if (!(Context()->Listener()->Velocity().IsZero() && mVelocity.IsZero())) {
for(uint32_t i = 0; i < mSources.Length(); i++) {
mSources[i]->SendDopplerShiftToStream(ComputeDopplerShift());
}
}
}
}
}

Просмотреть файл

@ -15,11 +15,13 @@
#include "ThreeDPoint.h"
#include "mozilla/WeakPtr.h"
#include "WebAudioUtils.h"
#include <set>
namespace mozilla {
namespace dom {
class AudioContext;
class AudioBufferSourceNode;
class PannerNode : public AudioNode,
public SupportsWeakPtr<PannerNode>
@ -92,6 +94,7 @@ public:
mVelocity.y = aY;
mVelocity.z = aZ;
SendThreeDPointParameterToStream(VELOCITY, mVelocity);
SendDopplerToSourcesIfNeeded();
}
double RefDistance() const
@ -172,6 +175,11 @@ public:
SendDoubleParameterToStream(CONE_OUTER_GAIN, mConeOuterGain);
}
float ComputeDopplerShift();
void SendDopplerToSourcesIfNeeded();
void FindConnectedSources();
void FindConnectedSources(AudioNode* aNode, nsTArray<AudioBufferSourceNode*>& aSources, std::set<AudioNode*>& aSeenNodes);
private:
friend class AudioListener;
friend class PannerNodeEngine;
@ -207,6 +215,10 @@ private:
double mConeInnerAngle;
double mConeOuterAngle;
double mConeOuterGain;
// An array of all the AudioBufferSourceNode connected directly or indirectly
// to this AudioPannerNode.
nsTArray<AudioBufferSourceNode*> mSources;
};
}

Просмотреть файл

@ -66,6 +66,13 @@ struct WebAudioUtils {
{
return std::pow(10.0f, 0.05f * aDecibel);
}
static void FixNaN(double& aDouble)
{
if (MOZ_DOUBLE_IS_NaN(aDouble) || MOZ_DOUBLE_IS_INFINITE(aDouble)) {
aDouble = 0.0;
}
}
};
}

Просмотреть файл

@ -60,7 +60,8 @@ BEGIN_BLUETOOTH_NAMESPACE
enum BluetoothSocketType {
RFCOMM = 1,
SCO = 2,
L2CAP = 3
L2CAP = 3,
EL2CAP = 4
};
class BluetoothSignal;

Просмотреть файл

@ -230,12 +230,7 @@ BluetoothOppManager::BluetoothOppManager() : mConnected(false)
, mWaitingForConfirmationFlag(false)
{
mConnectedDeviceAddress.AssignLiteral(BLUETOOTH_ADDRESS_NONE);
mSocket = new BluetoothSocket(this,
BluetoothSocketType::RFCOMM,
true,
true);
mPrevSocketStatus = mSocket->GetConnectionStatus();
Listen();
}
BluetoothOppManager::~BluetoothOppManager()
@ -261,15 +256,21 @@ BluetoothOppManager::Connect(const nsAString& aDeviceObjectPath,
{
MOZ_ASSERT(NS_IsMainThread());
SocketConnectionStatus s = mSocket->GetConnectionStatus();
if (s == SocketConnectionStatus::SOCKET_CONNECTED ||
s == SocketConnectionStatus::SOCKET_CONNECTING) {
if (mSocket) {
NS_WARNING("BluetoothOppManager has been already connected");
return false;
}
Disconnect();
// Stop listening because currently we only support one connection at a time.
if (mRfcommSocket) {
mRfcommSocket->Disconnect();
mRfcommSocket = nullptr;
}
if (mL2capSocket) {
mL2capSocket->Disconnect();
mL2capSocket = nullptr;
}
BluetoothService* bs = BluetoothService::Get();
if (!bs) {
@ -281,6 +282,8 @@ BluetoothOppManager::Connect(const nsAString& aDeviceObjectPath,
BluetoothUuidHelper::GetString(BluetoothServiceClass::OBJECT_PUSH, uuid);
mRunnable = aRunnable;
mSocket =
new BluetoothSocket(this, BluetoothSocketType::RFCOMM, true, true);
nsresult rv = bs->GetSocketViaService(aDeviceObjectPath,
uuid,
@ -296,7 +299,10 @@ BluetoothOppManager::Connect(const nsAString& aDeviceObjectPath,
void
BluetoothOppManager::Disconnect()
{
if (mSocket) {
mSocket->Disconnect();
mSocket = nullptr;
}
}
nsresult
@ -314,20 +320,35 @@ BluetoothOppManager::Listen()
{
MOZ_ASSERT(NS_IsMainThread());
if (mSocket->GetConnectionStatus() ==
SocketConnectionStatus::SOCKET_LISTENING) {
NS_WARNING("BluetoothOppManager has been already listening");
return true;
}
Disconnect();
if (!mSocket->Listen(BluetoothReservedChannels::CHANNEL_OPUSH)) {
NS_WARNING("[OPP] Can't listen on socket!");
if (mSocket) {
NS_WARNING("mSocket exists. Failed to listen.");
return false;
}
mPrevSocketStatus = mSocket->GetConnectionStatus();
if (!mRfcommSocket) {
mRfcommSocket =
new BluetoothSocket(this, BluetoothSocketType::RFCOMM, true, true);
if (!mRfcommSocket->Listen(BluetoothReservedChannels::CHANNEL_OPUSH)) {
NS_WARNING("[OPP] Can't listen on RFCOMM socket!");
mRfcommSocket = nullptr;
return false;
}
}
if (!mL2capSocket) {
mL2capSocket =
new BluetoothSocket(this, BluetoothSocketType::EL2CAP, true, true);
if (!mL2capSocket->Listen(BluetoothReservedChannels::CHANNEL_OPUSH_L2CAP)) {
NS_WARNING("[OPP] Can't listen on L2CAP socket!");
mRfcommSocket->Disconnect();
mRfcommSocket = nullptr;
mL2capSocket = nullptr;
return false;
}
}
return true;
}
@ -865,8 +886,10 @@ BluetoothOppManager::ClientDataHandler(UnixSocketRawData* aMessage)
// Most devices will directly terminate connection after receiving
// Disconnect request, so we make a delay here. If the socket hasn't been
// disconnected, we will close it.
if (mSocket) {
MessageLoop::current()->
PostDelayedTask(FROM_HERE, new CloseSocketTask(mSocket), 1000);
}
} else if (mLastCommand == ObexRequestCode::Connect) {
MOZ_ASSERT(!sFileName.IsEmpty());
MOZ_ASSERT(mBlob);
@ -1305,7 +1328,28 @@ BluetoothOppManager::ReceivingFileConfirmation()
void
BluetoothOppManager::OnConnectSuccess(BluetoothSocket* aSocket)
{
MOZ_ASSERT(aSocket == mSocket);
MOZ_ASSERT(aSocket);
/**
* If the created connection is an inbound connection, close another server
* socket because currently only one file-transfer session is allowed. After
* that, we need to make sure that both server socket would be nulled out.
* As for outbound connections, we do nothing since sockets have been already
* handled in function Connect().
*/
if (aSocket == mRfcommSocket) {
MOZ_ASSERT(!mSocket);
mRfcommSocket.swap(mSocket);
mL2capSocket->Disconnect();
mL2capSocket = nullptr;
} else if (aSocket == mL2capSocket) {
MOZ_ASSERT(!mSocket);
mL2capSocket.swap(mSocket);
mRfcommSocket->Disconnect();
mRfcommSocket = nullptr;
}
if (mRunnable) {
BluetoothReply* reply = new BluetoothReply(BluetoothReplySuccess(true));
@ -1319,14 +1363,11 @@ BluetoothOppManager::OnConnectSuccess(BluetoothSocket* aSocket)
// Cache device address since we can't get socket address when a remote
// device disconnect with us.
mSocket->GetAddress(mConnectedDeviceAddress);
mPrevSocketStatus = mSocket->GetConnectionStatus();
}
void
BluetoothOppManager::OnConnectError(BluetoothSocket* aSocket)
{
MOZ_ASSERT(aSocket == mSocket);
if (mRunnable) {
nsString errorStr;
errorStr.AssignLiteral("Failed to connect with a bluetooth opp manager!");
@ -1338,15 +1379,22 @@ BluetoothOppManager::OnConnectError(BluetoothSocket* aSocket)
mRunnable.forget();
}
mSocket->Disconnect();
mPrevSocketStatus = mSocket->GetConnectionStatus();
mSocket = nullptr;
mRfcommSocket = nullptr;
mL2capSocket = nullptr;
Listen();
}
void
BluetoothOppManager::OnDisconnect(BluetoothSocket* aSocket)
{
MOZ_ASSERT(aSocket == mSocket);
MOZ_ASSERT(aSocket);
if (aSocket != mSocket) {
// Do nothing when a listening server socket is closed.
return;
}
/**
* It is valid for a bluetooth device which is transfering file via OPP
@ -1355,32 +1403,28 @@ BluetoothOppManager::OnDisconnect(BluetoothSocket* aSocket)
* and notify the transfer has been completed (but failed). We also call
* AfterOppDisconnected here to ensure all variables will be cleaned.
*/
if (mPrevSocketStatus == SocketConnectionStatus::SOCKET_CONNECTED) {
if (mTransferMode) {
if (!mSuccessFlag) {
if (mTransferMode) {
DeleteReceivedFile();
} else if (mDsFile) {
nsString data;
CopyASCIItoUTF16("modified", data);
}
FileTransferComplete();
} else if (mTransferMode && mDsFile) {
NS_NAMED_LITERAL_STRING(data, "modified");
nsCOMPtr<nsIObserverService> obs =
mozilla::services::GetObserverService();
if (obs) {
obs->NotifyObservers(mDsFile, "file-watcher-notify", data.get());
} else {
NS_WARNING("Couldn't get ObserverService");
}
}
}
if (!mSuccessFlag) {
FileTransferComplete();
}
Listen();
} else if (mPrevSocketStatus == SocketConnectionStatus::SOCKET_CONNECTING) {
NS_WARNING("BluetoothOppManager got unexpected socket status!");
}
AfterOppDisconnected();
mConnectedDeviceAddress.AssignLiteral(BLUETOOTH_ADDRESS_NONE);
mSuccessFlag = false;
mSocket = nullptr;
Listen();
}

Просмотреть файл

@ -103,11 +103,6 @@ private:
void ValidateFileName();
bool IsReservedChar(PRUnichar c);
/**
* RFCOMM socket status.
*/
mozilla::ipc::SocketConnectionStatus mPrevSocketStatus;
/**
* OBEX session status.
* Set when OBEX session is established.
@ -188,7 +183,18 @@ private:
nsRefPtr<BluetoothReplyRunnable> mRunnable;
nsRefPtr<DeviceStorageFile> mDsFile;
// If a connection has been established, mSocket will be the socket
// communicating with the remote socket. We maintain the invariant that if
// mSocket is non-null, mRfcommSocket and mL2capSocket must be null (and vice
// versa).
nsRefPtr<BluetoothSocket> mSocket;
// Server sockets. Once an inbound connection is established, it will hand
// over the ownership to mSocket, and get a new server socket while Listen()
// is called.
nsRefPtr<BluetoothSocket> mRfcommSocket;
nsRefPtr<BluetoothSocket> mL2capSocket;
};
END_BLUETOOTH_NAMESPACE

Просмотреть файл

@ -66,29 +66,31 @@ public:
};
void
BluetoothScoManager::NotifyAudioManager(const nsAString& aAddress) {
BluetoothScoManager::NotifyAudioManager(const nsAString& aAddress)
{
MOZ_ASSERT(NS_IsMainThread());
nsCOMPtr<nsIObserverService> obs =
do_GetService("@mozilla.org/observer-service;1");
NS_ENSURE_TRUE_VOID(obs);
nsCOMPtr<nsIAudioManager> am =
do_GetService("@mozilla.org/telephony/audiomanager;1");
NS_ENSURE_TRUE_VOID(am);
if (aAddress.IsEmpty()) {
if (NS_FAILED(obs->NotifyObservers(nullptr, BLUETOOTH_SCO_STATUS_CHANGED, nullptr))) {
NS_WARNING("Failed to notify bluetooth-sco-status-changed observsers!");
return;
}
am->SetForceForUse(am->USE_COMMUNICATION, am->FORCE_NONE);
} else {
if (NS_FAILED(obs->NotifyObservers(nullptr, BLUETOOTH_SCO_STATUS_CHANGED, aAddress.BeginReading()))) {
NS_WARNING("Failed to notify bluetooth-sco-status-changed observsers!");
return;
}
}
nsCOMPtr<nsIAudioManager> am =
do_GetService("@mozilla.org/telephony/audiomanager;1");
NS_ENSURE_TRUE_VOID(am);
am->SetForceForUse(am->USE_COMMUNICATION, am->FORCE_BT_SCO);
}
}
NS_IMPL_ISUPPORTS1(BluetoothScoManagerObserver, nsIObserver)

Просмотреть файл

@ -28,9 +28,9 @@
#include <sys/socket.h>
#include <bluetooth/bluetooth.h>
#include <bluetooth/sco.h>
#include <bluetooth/rfcomm.h>
#include <bluetooth/l2cap.h>
#include <bluetooth/rfcomm.h>
#include <bluetooth/sco.h>
#include "BluetoothUnixSocketConnector.h"
#include "nsThreadUtils.h"
@ -39,6 +39,9 @@ using namespace mozilla::ipc;
USING_BLUETOOTH_NAMESPACE
static const int RFCOMM_SO_SNDBUF = 70 * 1024; // 70 KB send buffer
static const int L2CAP_SO_SNDBUF = 400 * 1024; // 400 KB send buffer
static const int L2CAP_SO_RCVBUF = 400 * 1024; // 400 KB receive buffer
static const int L2CAP_MAX_MTU = 65000;
static
int get_bdaddr(const char *str, bdaddr_t *ba)
@ -74,7 +77,8 @@ bool
BluetoothUnixSocketConnector::SetUp(int aFd)
{
int lm = 0;
int sndbuf;
int sndbuf, rcvbuf;
/* kernel does not yet support LM for SCO */
switch (mType) {
case BluetoothSocketType::RFCOMM:
@ -82,6 +86,7 @@ BluetoothUnixSocketConnector::SetUp(int aFd)
lm |= mEncrypt ? RFCOMM_LM_ENCRYPT : 0;
break;
case BluetoothSocketType::L2CAP:
case BluetoothSocketType::EL2CAP:
lm |= mAuth ? L2CAP_LM_AUTH : 0;
lm |= mEncrypt ? L2CAP_LM_ENCRYPT : 0;
break;
@ -92,10 +97,18 @@ BluetoothUnixSocketConnector::SetUp(int aFd)
}
if (lm) {
if (mType == BluetoothSocketType::RFCOMM) {
if (setsockopt(aFd, SOL_RFCOMM, RFCOMM_LM, &lm, sizeof(lm))) {
NS_WARNING("setsockopt(RFCOMM_LM) failed, throwing");
return false;
}
} else if (mType == BluetoothSocketType::L2CAP ||
mType == BluetoothSocketType::EL2CAP) {
if (setsockopt(aFd, SOL_L2CAP, L2CAP_LM, &lm, sizeof(lm))) {
NS_WARNING("setsockopt(L2CAP_LM) failed, throwing");
return false;
}
}
}
if (mType == BluetoothSocketType::RFCOMM) {
@ -106,6 +119,44 @@ BluetoothUnixSocketConnector::SetUp(int aFd)
}
}
/* Setting L2CAP socket options */
if (mType == BluetoothSocketType::L2CAP ||
mType == BluetoothSocketType::EL2CAP) {
struct l2cap_options opts;
int optlen = sizeof(opts), err;
err = getsockopt(aFd, SOL_L2CAP, L2CAP_OPTIONS, &opts, &optlen);
if (!err) {
/* setting MTU for [E]L2CAP */
opts.omtu = opts.imtu = L2CAP_MAX_MTU;
/* Enable ERTM for [E]L2CAP */
if (mType == BluetoothSocketType::EL2CAP) {
opts.flush_to = 0xffff; /* infinite */
opts.mode = L2CAP_MODE_ERTM;
opts.fcs = 1;
opts.txwin_size = 64;
opts.max_tx = 10;
}
err = setsockopt(aFd, SOL_L2CAP, L2CAP_OPTIONS, &opts, optlen);
}
/* Set larger SNDBUF & RCVBUF for EL2CAP connections */
if (mType == BluetoothSocketType::EL2CAP) {
sndbuf = L2CAP_SO_SNDBUF;
if (setsockopt(aFd, SOL_SOCKET, SO_SNDBUF, &sndbuf, sizeof(sndbuf))) {
NS_WARNING("setsockopt(SO_SNDBUF) failed, throwing");
return false;
}
rcvbuf = L2CAP_SO_RCVBUF;
if (setsockopt(aFd, SOL_SOCKET, SO_RCVBUF, &rcvbuf, sizeof(rcvbuf))) {
NS_WARNING("setsockopt(SO_RCVBUF) failed, throwing");
return false;
}
}
}
return true;
}
@ -125,6 +176,9 @@ BluetoothUnixSocketConnector::Create()
case BluetoothSocketType::L2CAP:
fd = socket(PF_BLUETOOTH, SOCK_SEQPACKET, BTPROTO_L2CAP);
break;
case BluetoothSocketType::EL2CAP:
fd = socket(PF_BLUETOOTH, SOCK_STREAM, BTPROTO_L2CAP);
break;
default:
MOZ_NOT_REACHED();
}
@ -136,7 +190,9 @@ BluetoothUnixSocketConnector::Create()
if (!SetUp(fd)) {
NS_WARNING("Could not set up socket!");
return -1;
}
return fd;
}
@ -156,6 +212,9 @@ BluetoothUnixSocketConnector::CreateAddr(bool aIsServer,
}
}
// Initialize
memset(&aAddr, 0, sizeof(aAddr));
switch (mType) {
case BluetoothSocketType::RFCOMM:
struct sockaddr_rc addr_rc;
@ -164,6 +223,14 @@ BluetoothUnixSocketConnector::CreateAddr(bool aIsServer,
aAddr.rc.rc_channel = mChannel;
memcpy(&aAddr.rc.rc_bdaddr, &bd_address_obj, sizeof(bd_address_obj));
break;
case BluetoothSocketType::L2CAP:
case BluetoothSocketType::EL2CAP:
struct sockaddr_l2 addr_l2;
aAddrSize = sizeof(addr_l2);
aAddr.l2.l2_family = AF_BLUETOOTH;
aAddr.l2.l2_psm = mChannel;
memcpy(&aAddr.l2.l2_bdaddr, &bd_address_obj, sizeof(bdaddr_t));
break;
case BluetoothSocketType::SCO:
struct sockaddr_sco addr_sco;
aAddrSize = sizeof(addr_sco);
@ -189,6 +256,10 @@ BluetoothUnixSocketConnector::GetSocketAddr(const sockaddr_any& aAddr,
case BluetoothSocketType::SCO:
get_bdaddr_as_string((bdaddr_t*)(&aAddr.sco.sco_bdaddr), addr);
break;
case BluetoothSocketType::L2CAP:
case BluetoothSocketType::EL2CAP:
get_bdaddr_as_string((bdaddr_t*)(&aAddr.l2.l2_bdaddr), addr);
break;
default:
MOZ_NOT_REACHED("Socket should be either RFCOMM or SCO!");
}

Просмотреть файл

@ -56,6 +56,7 @@ enum BluetoothReservedChannels {
CHANNEL_SIM_ACCESS = 15,
CHANNEL_PBAP_PSE = 19,
CHANNEL_FTP = 20,
CHANNEL_OPUSH_L2CAP = 5255
};
END_BLUETOOTH_NAMESPACE

Просмотреть файл

@ -4,7 +4,7 @@
"use strict";
const DEBUG = false;
let DEBUG = false;
function debug(s) { dump("-*- ContactManager: " + s + "\n"); }
const Cc = Components.classes;
@ -637,6 +637,7 @@ ContactManager.prototype = {
},
find: function(aOptions) {
DEBUG = false;
if (DEBUG) debug("find! " + JSON.stringify(aOptions));
let request = this.createRequest();
let options = { findOptions: aOptions };
@ -701,6 +702,7 @@ ContactManager.prototype = {
},
clear: function() {
DEBUG = true;
if (DEBUG) debug("clear");
let request;
request = this.createRequest();

Просмотреть файл

@ -6,7 +6,7 @@
this.EXPORTED_SYMBOLS = ['ContactDB'];
const DEBUG = false;
let DEBUG = false;
function debug(s) { dump("-*- ContactDB component: " + s + "\n"); }
const Cu = Components.utils;
@ -461,6 +461,7 @@ ContactDB.prototype = {
},
clear: function clear(aSuccessCb, aErrorCb) {
DEBUG = true;
this.newTxn("readwrite", STORE_NAME, function (txn, store) {
if (DEBUG) debug("Going to clear all!");
store.clear();
@ -618,6 +619,7 @@ ContactDB.prototype = {
* - count
*/
find: function find(aSuccessCb, aFailureCb, aOptions) {
DEBUG = false;
if (DEBUG) debug("ContactDB:find val:" + aOptions.filterValue + " by: " + aOptions.filterBy + " op: " + aOptions.filterOp);
let self = this;
this.newTxn("readonly", STORE_NAME, function (txn, store) {

Просмотреть файл

@ -4,7 +4,7 @@
"use strict";
const DEBUG = false;
let DEBUG = false;
function debug(s) { dump("-*- Fallback ContactService component: " + s + "\n"); }
const Cu = Components.utils;
@ -90,6 +90,7 @@ let ContactService = {
switch (aMessage.name) {
case "Contacts:Find":
DEBUG = false;
if (!this.assertPermission(aMessage, "contacts-read")) {
return null;
}
@ -150,6 +151,7 @@ let ContactService = {
);
break;
case "Contacts:Clear":
DEBUG = true;
if (!this.assertPermission(aMessage, "contacts-write")) {
return null;
}

Просмотреть файл

@ -946,6 +946,7 @@ MmsService.prototype = {
intermediate.deliveryStatus = [DELIVERY_STATUS_PENDING];
intermediate.timestamp = Date.now();
intermediate.sender = null;
intermediate.transactionId = intermediate.headers["x-mms-transaction-id"];
if (intermediate.headers.from) {
intermediate.sender = intermediate.headers.from.address;
} else {
@ -1048,70 +1049,39 @@ MmsService.prototype = {
},
/**
* Handle incoming M-Notification.ind PDU.
* A helper function to broadcast the mms sent system message and notify observers.
*
* @param notification
* The parsed MMS message object.
* @params aDomMessage
* The nsIDOMMozMmsMessage object.
*/
handleNotificationIndication: function handleNotificationIndication(notification) {
let url = notification.headers["x-mms-content-location"].uri;
// TODO: bug 810091 - don't download message twice when receiving duplicated
// notification.
broadcastSentMessageEvent: function broadcastSentMessageEvent(aDomMessage) {
// Broadcasting a 'sms-sent' system message to open apps.
this.broadcastMmsSystemMessage("sms-sent", aDomMessage);
let transactionId = notification.headers["x-mms-transaction-id"];
// For X-Mms-Report-Allowed
let wish = notification.headers["x-mms-delivery-report"];
// Notifying observers an MMS message is sent.
Services.obs.notifyObservers(aDomMessage, kSmsSentObserverTopic, null);
},
let savableMessage = this.convertIntermediateToSavable(notification);
/**
* A helper function to broadcast the mms received system message and notify observers.
*
* @params aDomMessage
* The nsIDOMMozMmsMessage object.
*/
broadcastReceivedMessageEvent :function broadcastReceivedMessageEvent(aDomMessage) {
// Broadcasting a 'sms-received' system message to open apps.
this.broadcastMmsSystemMessage("sms-received", aDomMessage);
gMobileMessageDatabaseService.saveReceivedMessage(savableMessage,
(function (rv, domMessage) {
let success = Components.isSuccessCode(rv);
if (!success) {
// At this point we could send a message to content to notify the
// user that storing an incoming MMS notification indication failed,
// ost likely due to a full disk.
debug("Could not store MMS " + JSON.stringify(savableMessage) +
", error code " + rv);
// Because MMSC will resend the notification indication once we don't
// response the notification. Hope the end user will clean some space
// for the resent notification indication.
return;
}
// Notifying observers an MMS message is comming.
Services.obs.notifyObservers(aDomMessage, kSmsReceivedObserverTopic, null);
},
// Broadcasting an 'sms-received' system message to open apps.
this.broadcastMmsSystemMessage("sms-received", domMessage);
// Notifying observers a new notification indication is coming.
Services.obs.notifyObservers(domMessage, kSmsReceivedObserverTopic, null);
let retrievalMode = RETRIEVAL_MODE_MANUAL;
try {
retrievalMode = Services.prefs.getCharPref(PREF_RETRIEVAL_MODE);
} catch (e) {}
let isRoaming = gMmsConnection.isDataConnRoaming();
if ((retrievalMode === RETRIEVAL_MODE_AUTOMATIC_HOME && isRoaming) ||
RETRIEVAL_MODE_MANUAL === retrievalMode ||
RETRIEVAL_MODE_NEVER === retrievalMode) {
let mmsStatus = RETRIEVAL_MODE_NEVER === retrievalMode
? MMS.MMS_PDU_STATUS_REJECTED
: MMS.MMS_PDU_STATUS_DEFERRED;
// For X-Mms-Report-Allowed
let reportAllowed = this.getReportAllowed(this.confSendDeliveryReport,
wish);
let transaction = new NotifyResponseTransaction(transactionId,
/**
* Callback for retrieveMessage.
*/
retrieveMessageCallback: function retrieveMessageCallback(wish,
savableMessage,
mmsStatus,
reportAllowed);
transaction.run();
return;
}
// For RETRIEVAL_MODE_AUTOMATIC or RETRIEVAL_MODE_AUTOMATIC_HOME but not
// roaming, proceed to retrieve MMS.
this.retrieveMessage(url, (function responseNotify(mmsStatus,
retrievedMessage) {
debug("retrievedMessage = " + JSON.stringify(retrievedMessage));
@ -1121,8 +1091,10 @@ MmsService.prototype = {
if (wish == null && retrievedMessage) {
wish = retrievedMessage.headers["x-mms-delivery-report"];
}
let reportAllowed = this.getReportAllowed(this.confSendDeliveryReport,
wish);
let transactionId = retrievedMessage.headers["x-mms-transaction-id"];
// If the mmsStatus isn't MMS_PDU_STATUS_RETRIEVED after retrieving,
// something must be wrong with MMSC, so stop updating the DB record.
@ -1150,22 +1122,95 @@ MmsService.prototype = {
transaction.run();
if (!success) {
// At this point we could send a message to content to
// notify the user that storing an incoming MMS failed,
// most likely due to a full disk. The end user has to
// retrieve the MMS again.
// At this point we could send a message to content to notify the user
// that storing an incoming MMS failed, most likely due to a full disk.
// The end user has to retrieve the MMS again.
debug("Could not store MMS " + domMessage.id +
", error code " + rv);
return;
}
// Broadcasting an 'sms-received' system message to open apps.
this.broadcastMmsSystemMessage("sms-received", domMessage);
this.broadcastReceivedMessageEvent(domMessage);
}).bind(this));
},
// Notifying observers an MMS message is received.
Services.obs.notifyObservers(domMessage, kSmsReceivedObserverTopic, null);
}).bind(this));
}).bind(this));
/**
* Callback for saveReceivedMessage.
*/
saveReceivedMessageCallback: function saveReceivedMessageCallback(savableMessage,
rv,
domMessage) {
let success = Components.isSuccessCode(rv);
if (!success) {
// At this point we could send a message to content to notify the
// user that storing an incoming MMS notification indication failed,
// ost likely due to a full disk.
debug("Could not store MMS " + JSON.stringify(savableMessage) +
", error code " + rv);
// Because MMSC will resend the notification indication once we don't
// response the notification. Hope the end user will clean some space
// for the resent notification indication.
return;
}
// For X-Mms-Report-Allowed and X-Mms-Transaction-Id
let wish = savableMessage.headers["x-mms-delivery-report"];
let transactionId = savableMessage.headers["x-mms-transaction-id"];
this.broadcastReceivedMessageEvent(domMessage);
let retrievalMode = RETRIEVAL_MODE_MANUAL;
try {
retrievalMode = Services.prefs.getCharPref(PREF_RETRIEVAL_MODE);
} catch (e) {}
let isRoaming = gMmsConnection.isDataConnRoaming();
if ((retrievalMode === RETRIEVAL_MODE_AUTOMATIC_HOME && isRoaming) ||
RETRIEVAL_MODE_MANUAL === retrievalMode ||
RETRIEVAL_MODE_NEVER === retrievalMode) {
let mmsStatus = RETRIEVAL_MODE_NEVER === retrievalMode
? MMS.MMS_PDU_STATUS_REJECTED
: MMS.MMS_PDU_STATUS_DEFERRED;
// For X-Mms-Report-Allowed
let reportAllowed = this.getReportAllowed(this.confSendDeliveryReport,
wish);
let transaction = new NotifyResponseTransaction(transactionId,
mmsStatus,
reportAllowed);
transaction.run();
return;
}
let url = savableMessage.headers["x-mms-content-location"].uri;
// For RETRIEVAL_MODE_AUTOMATIC or RETRIEVAL_MODE_AUTOMATIC_HOME but not
// roaming, proceed to retrieve MMS.
this.retrieveMessage(url, this.retrieveMessageCallback.bind(this, wish, savableMessage));
},
/**
* Handle incoming M-Notification.ind PDU.
*
* @param notification
* The parsed MMS message object.
*/
handleNotificationIndication: function handleNotificationIndication(notification) {
let transactionId = notification.headers["x-mms-transaction-id"];
gMobileMessageDatabaseService.getMessageRecordByTransactionId(transactionId,
(function (aRv, aMessageRecord) {
if (Ci.nsIMobileMessageCallback.SUCCESS_NO_ERROR === aRv
&& aMessageRecord) {
debug("We already got the NotificationIndication with transactionId = "
+ transactionId + " before.");
return;
}
let savableMessage = this.convertIntermediateToSavable(notification);
gMobileMessageDatabaseService
.saveReceivedMessage(savableMessage,
this.saveReceivedMessageCallback.bind(this, savableMessage));
}).bind(this));
},
@ -1307,9 +1352,8 @@ MmsService.prototype = {
return;
}
self.broadcastMmsSystemMessage("sms-sent", aDomMessage);
self.broadcastSentMessageEvent(domMessage);
aRequest.notifyMessageSent(aDomMessage);
Services.obs.notifyObservers(aDomMessage, kSmsSentObserverTopic, null);
});
};
@ -1411,9 +1455,7 @@ MmsService.prototype = {
}
// Notifying observers a new MMS message is retrieved.
aRequest.notifyMessageGot(domMessage);
// Broadcasting an 'sms-received' system message to open apps.
this.broadcastMmsSystemMessage("sms-received", domMessage);
Services.obs.notifyObservers(domMessage, kSmsReceivedObserverTopic, null);
this.broadcastReceivedMessageEvent(domMessage);
let transaction = new AcknowledgeTransaction(transactionId, reportAllowed);
transaction.run();
}).bind(this));

Просмотреть файл

@ -24,7 +24,7 @@ interface nsIRilMobileMessageDatabaseRecordCallback : nsISupports
void notify(in nsresult aRv, in jsval aMessageRecord);
};
[scriptable, uuid(8f49216f-bc0c-420e-b77e-7f1cbdcd245f)]
[scriptable, uuid(0ead3154-542d-4e2c-a624-9e3cec504758)]
interface nsIRilMobileMessageDatabaseService : nsIMobileMessageDatabaseService
{
/**
@ -40,6 +40,7 @@ interface nsIRilMobileMessageDatabaseService : nsIMobileMessageDatabaseService
* - |delivery| DOMString: the delivery state of received message
* - |deliveryStatus| DOMString Array: the delivery status of received message
* - |receivers| DOMString Array: the phone numbers of receivers
* - |transactionId| DOMString: the transaction ID from MMS pdu header.
*
* Note: |deliveryStatus| should only contain single string to specify
* the delivery status of MMS message for the phone owner self.
@ -82,4 +83,12 @@ interface nsIRilMobileMessageDatabaseService : nsIMobileMessageDatabaseService
*/
void getMessageRecordById(in long aMessageId,
in nsIRilMobileMessageDatabaseRecordCallback aCallback);
/**
* |aTransactionId| DOMString: the transaction ID of MMS pdu.
* |aCallback| nsIRilMobileMessageDatabaseCallback: a callback which takes
* result flag and message record as parameters.
*/
void getMessageRecordByTransactionId(in DOMString aTransactionId,
in nsIRilMobileMessageDatabaseRecordCallback aCallback);
};

Просмотреть файл

@ -21,7 +21,7 @@ const RIL_GETTHREADSCURSOR_CID =
const DEBUG = false;
const DB_NAME = "sms";
const DB_VERSION = 8;
const DB_VERSION = 9;
const MESSAGE_STORE_NAME = "sms";
const THREAD_STORE_NAME = "thread";
const PARTICIPANT_STORE_NAME = "participant";
@ -30,6 +30,7 @@ const MOST_RECENT_STORE_NAME = "most-recent";
const DELIVERY_SENDING = "sending";
const DELIVERY_SENT = "sent";
const DELIVERY_RECEIVED = "received";
const DELIVERY_NOT_DOWNLOADED = "not-downloaded";
const DELIVERY_STATUS_NOT_APPLICABLE = "not-applicable";
const DELIVERY_STATUS_SUCCESS = "success";
@ -200,6 +201,10 @@ MobileMessageDatabaseService.prototype = {
if (DEBUG) debug("Upgrade to version 8. Add participant/thread stores.");
self.upgradeSchema7(db, event.target.transaction);
break;
case 8:
if (DEBUG) debug("Upgrade to version 9. Add transactionId index for incoming MMS.");
self.upgradeSchema8(event.target.transaction);
break;
default:
event.target.transaction.abort();
callback("Old database version: " + event.oldVersion, null);
@ -559,6 +564,39 @@ MobileMessageDatabaseService.prototype = {
};
},
/**
* Add transactionId index for MMS.
*/
upgradeSchema8: function upgradeSchema8(transaction) {
let messageStore = transaction.objectStore(MESSAGE_STORE_NAME);
// Delete "transactionId" index.
if (messageStore.indexNames.contains("transactionId")) {
messageStore.deleteIndex("transactionId");
}
// Create new "transactionId" indexes.
messageStore.createIndex("transactionId", "transactionIdIndex", { unique: true });
// Populate new "transactionIdIndex" attributes.
messageStore.openCursor().onsuccess = function(event) {
let cursor = event.target.result;
if (!cursor) {
return;
}
let messageRecord = cursor.value;
if ("mms" == messageRecord.type &&
(DELIVERY_NOT_DOWNLOADED == messageRecord.delivery ||
DELIVERY_RECEIVED == messageRecord.delivery)) {
messageRecord.transactionIdIndex =
messageRecord.headers["x-mms-transaction-id"];
cursor.update(messageRecord);
}
cursor.continue();
};
},
createDomMessageFromRecord: function createDomMessageFromRecord(aMessageRecord) {
if (DEBUG) {
debug("createDomMessageFromRecord: " + JSON.stringify(aMessageRecord));
@ -908,6 +946,7 @@ MobileMessageDatabaseService.prototype = {
if ((aMessage.type != "sms" && aMessage.type != "mms") ||
(aMessage.type == "sms" && aMessage.messageClass == undefined) ||
(aMessage.type == "mms" && (aMessage.delivery == undefined ||
aMessage.transactionId == undefined ||
!Array.isArray(aMessage.deliveryStatus) ||
!Array.isArray(aMessage.receivers))) ||
aMessage.sender == undefined ||
@ -950,6 +989,10 @@ MobileMessageDatabaseService.prototype = {
aMessage.readIndex = [FILTER_READ_UNREAD, timestamp];
aMessage.read = FILTER_READ_UNREAD;
if (aMessage.type == "mms") {
aMessage.transactionIdIndex = aMessage.transactionId;
}
if (aMessage.type == "sms") {
aMessage.delivery = DELIVERY_RECEIVED;
aMessage.deliveryStatus = DELIVERY_STATUS_SUCCESS;
@ -1120,6 +1163,37 @@ MobileMessageDatabaseService.prototype = {
});
},
getMessageRecordByTransactionId: function getMessageRecordByTransactionId(aTransactionId, aCallback) {
if (DEBUG) debug("Retrieving message with transaction ID " + aTransactionId);
this.newTxn(READ_ONLY, function (error, txn, messageStore) {
if (error) {
if (DEBUG) debug(error);
aCallback.notify(Ci.nsIMobileMessageCallback.INTERNAL_ERROR, null);
return;
}
let request = messageStore.index("transactionId").get(aTransactionId);
txn.oncomplete = function oncomplete(event) {
if (DEBUG) debug("Transaction " + txn + " completed.");
let messageRecord = request.result;
if (!messageRecord) {
if (DEBUG) debug("Transaction ID " + aTransactionId + " not found");
aCallback.notify(Ci.nsIMobileMessageCallback.NOT_FOUND_ERROR, null);
return;
}
aCallback.notify(Ci.nsIMobileMessageCallback.SUCCESS_NO_ERROR, messageRecord);
};
txn.onerror = function onerror(event) {
if (DEBUG) {
if (event.target)
debug("Caught error on transaction", event.target.errorCode);
}
aCallback.notify(Ci.nsIMobileMessageCallback.INTERNAL_ERROR, null);
};
});
},
getMessageRecordById: function getMessageRecordById(aMessageId, aCallback) {
if (DEBUG) debug("Retrieving message with ID " + aMessageId);
this.newTxn(READ_ONLY, function (error, txn, messageStore) {

Просмотреть файл

@ -218,14 +218,6 @@ public:
*/
virtual void MakeCurrent(MakeCurrentFlags aFlags = 0) = 0;
/**
* Modifies the TextureIdentifier in aInfo to a more reliable kind. For use by
* when creating texture hosts/clients. If the desired texture cannot be
* created, this method allows the compositor to suggest a less desirable, but
* more reliable kind of texture.
*/
virtual void FallbackTextureInfo(TextureInfo& aInfo) {}
/**
* Creates a Surface that can be used as a rendering target by this
* compositor.

Просмотреть файл

@ -75,7 +75,6 @@ enum TextureHostFlags
TEXTURE_HOST_DEFAULT = 0, // The default texture host for the given
// SurfaceDescriptor
TEXTURE_HOST_TILED = 1 << 0, // A texture host that supports tiling
TEXTURE_HOST_DIRECT = 1 << 1 // Direct texturing
};
/**
@ -95,6 +94,14 @@ struct TextureFactoryIdentifier
{}
};
/**
* Identify a texture to a compositable. Many textures can have the same id, but
* the id is unique for any texture owned by a particular compositable.
*/
typedef uint32_t TextureIdentifier;
const TextureIdentifier TextureFront = 1;
const TextureIdentifier TextureBack = 2;
/**
* Information required by the compositor from the content-side for creating or
* using compositables and textures.
@ -110,6 +117,19 @@ struct TextureInfo
, mTextureHostFlags(0)
, mTextureFlags(0)
{}
TextureInfo(CompositableType aType)
: mCompositableType(aType)
, mTextureHostFlags(0)
, mTextureFlags(0)
{}
bool operator==(const TextureInfo& aOther) const
{
return mCompositableType == aOther.mCompositableType &&
mTextureHostFlags == aOther.mTextureHostFlags &&
mTextureFlags == aOther.mTextureFlags;
}
};

Просмотреть файл

@ -67,7 +67,6 @@ class SpecificLayerAttributes;
class SurfaceDescriptor;
class Compositor;
class LayerComposite;
struct TextureIdentifier;
struct TextureFactoryIdentifier;
struct EffectMask;
@ -157,7 +156,12 @@ public:
* for its widget going away. After this call, only user data calls
* are valid on the layer manager.
*/
virtual void Destroy() { mDestroyed = true; mUserData.Destroy(); }
virtual void Destroy()
{
mDestroyed = true;
mUserData.Destroy();
mRoot = nullptr;
}
bool IsDestroyed() { return mDestroyed; }
virtual ShadowLayerForwarder* AsShadowForwarder()

Просмотреть файл

@ -175,12 +175,10 @@ EXPORTS_mozilla/layers =\
SharedPlanarYCbCrImage.h \
ShmemYCbCrImage.h \
TaskThrottler.h \
TextureChild.h \
TextureClient.h \
TextureHost.h \
TextureClientOGL.h \
TextureHostOGL.h \
TextureParent.h \
TiledContentClient.h \
$(NULL)
@ -214,10 +212,8 @@ CPPSRCS += \
ISurfaceAllocator.cpp \
TextureClient.cpp \
TextureClientOGL.cpp \
TextureHostOGL.cpp \
TextureChild.cpp \
TextureHost.cpp \
TextureParent.cpp \
TextureHostOGL.cpp \
TiledContentClient.cpp \
TiledContentHost.cpp \
$(NULL)

Просмотреть файл

@ -8,7 +8,6 @@
#include "mozilla/layers/PLayerChild.h"
#include "mozilla/layers/PLayersChild.h"
#include "mozilla/layers/PLayersParent.h"
#include "mozilla/layers/TextureChild.h"
#include "gfxSharedImageSurface.h"
#include "gfxImageSurface.h"
@ -1244,13 +1243,12 @@ BasicShadowLayerManager::ForwardTransaction()
const OpTextureSwap& ots = reply.get_OpTextureSwap();
PTextureChild* textureChild = ots.textureChild();
MOZ_ASSERT(textureChild);
CompositableChild* compositableChild =
static_cast<CompositableChild*>(ots.compositableChild());
MOZ_ASSERT(compositableChild);
TextureClient* texClient =
static_cast<TextureChild*>(textureChild)->GetTextureClient();
texClient->SetDescriptorFromReply(ots.image());
compositableChild->GetCompositableClient()
->SetDescriptorFromReply(ots.textureId(), ots.image());
break;
}

Просмотреть файл

@ -36,23 +36,24 @@ CanvasClient::CreateCanvasClient(LayersBackend aParentBackend,
}
void
CanvasClient::SetBuffer(const TextureIdentifier& aTextureIdentifier,
const SurfaceDescriptor& aBuffer)
CanvasClient::Updated()
{
mTextureClient->SetDescriptor(aBuffer);
mForwarder->UpdateTexture(this, 1, mTextureClient->GetDescriptor());
}
CanvasClient2D::CanvasClient2D(CompositableForwarder* aFwd,
TextureFlags aFlags)
: CanvasClient(aFwd, aFlags)
{
mTextureInfo.mCompositableType = BUFFER_IMAGE_SINGLE;
}
void
CanvasClient2D::Update(gfx::IntSize aSize, BasicCanvasLayer* aLayer)
{
if (!mTextureClient) {
mTextureClient = CreateTextureClient(TEXTURE_SHMEM, mFlags);
mTextureClient = CreateTextureClient(TEXTURE_SHMEM);
}
bool isOpaque = (aLayer->GetContentFlags() & Layer::CONTENT_OPAQUE);
@ -70,13 +71,14 @@ CanvasClientWebGL::CanvasClientWebGL(CompositableForwarder* aFwd,
TextureFlags aFlags)
: CanvasClient(aFwd, aFlags)
{
mTextureInfo.mCompositableType = BUFFER_IMAGE_BUFFERED;
}
void
CanvasClientWebGL::Update(gfx::IntSize aSize, BasicCanvasLayer* aLayer)
{
if (!mTextureClient) {
mTextureClient = CreateTextureClient(TEXTURE_STREAM_GL, mFlags);
mTextureClient = CreateTextureClient(TEXTURE_STREAM_GL);
}
NS_ASSERTION(aLayer->mGLContext, "CanvasClientWebGL should only be used with GL canvases");

Просмотреть файл

@ -14,7 +14,6 @@ namespace mozilla {
namespace layers {
class BasicCanvasLayer;
class TextureIdentifier;
/**
* Compositable client for 2d and webgl canvas.
@ -33,22 +32,25 @@ public:
TextureFlags aFlags);
CanvasClient(CompositableForwarder* aFwd, TextureFlags aFlags)
: CompositableClient(aFwd), mFlags(aFlags)
{}
: CompositableClient(aFwd)
{
mTextureInfo.mTextureFlags = aFlags;
}
virtual ~CanvasClient() {}
virtual void Update(gfx::IntSize aSize, BasicCanvasLayer* aLayer) = 0;
virtual void SetBuffer(const TextureIdentifier& aTextureIdentifier,
const SurfaceDescriptor& aBuffer);
virtual void Updated()
virtual void Updated();
virtual void SetDescriptorFromReply(TextureIdentifier aTextureId,
const SurfaceDescriptor& aDescriptor) MOZ_OVERRIDE
{
mTextureClient->Updated();
mTextureClient->SetDescriptorFromReply(aDescriptor);
}
protected:
RefPtr<TextureClient> mTextureClient;
TextureFlags mFlags;
TextureInfo mTextureInfo;
};
// Used for 2D canvases and WebGL canvas on non-GL systems where readback is requried.
@ -58,9 +60,9 @@ public:
CanvasClient2D(CompositableForwarder* aLayerForwarder,
TextureFlags aFlags);
CompositableType GetType() const MOZ_OVERRIDE
TextureInfo GetTextureInfo() const MOZ_OVERRIDE
{
return BUFFER_IMAGE_SINGLE;
return mTextureInfo;
}
virtual void Update(gfx::IntSize aSize, BasicCanvasLayer* aLayer);
@ -74,9 +76,9 @@ public:
CanvasClientWebGL(CompositableForwarder* aFwd,
TextureFlags aFlags);
CompositableType GetType() const MOZ_OVERRIDE
TextureInfo GetTextureInfo() const MOZ_OVERRIDE
{
return BUFFER_IMAGE_BUFFERED;
return mTextureInfo;
}
virtual void Update(gfx::IntSize aSize, BasicCanvasLayer* aLayer);

Просмотреть файл

@ -6,7 +6,6 @@
#include "mozilla/layers/CompositableClient.h"
#include "mozilla/layers/TextureClient.h"
#include "mozilla/layers/TextureClientOGL.h"
#include "mozilla/layers/TextureChild.h"
#include "mozilla/layers/ShadowLayersChild.h"
#include "mozilla/layers/CompositableForwarder.h"
@ -70,32 +69,11 @@ CompositableClient::GetAsyncID() const
void
CompositableChild::Destroy()
{
int numChildren = ManagedPTextureChild().Length();
for (int i = numChildren-1; i >= 0; --i) {
TextureChild* texture =
static_cast<TextureChild*>(
ManagedPTextureChild()[i]);
texture->Destroy();
}
Send__delete__(this);
}
PTextureChild*
CompositableChild::AllocPTexture(const TextureInfo& aInfo)
{
return new TextureChild();
}
bool
CompositableChild::DeallocPTexture(PTextureChild* aActor)
{
delete aActor;
return true;
}
TemporaryRef<TextureClient>
CompositableClient::CreateTextureClient(TextureClientType aTextureClientType,
TextureFlags aFlags)
CompositableClient::CreateTextureClient(TextureClientType aTextureClientType)
{
MOZ_ASSERT(GetForwarder(), "Can't create a texture client if the compositable is not connected to the compositor.");
LayersBackend parentBackend = GetForwarder()->GetCompositorBackendType();
@ -104,27 +82,27 @@ CompositableClient::CreateTextureClient(TextureClientType aTextureClientType,
switch (aTextureClientType) {
case TEXTURE_SHARED_GL:
if (parentBackend == LAYERS_OPENGL) {
result = new TextureClientSharedOGL(GetForwarder(), GetType());
result = new TextureClientSharedOGL(GetForwarder(), GetTextureInfo());
}
break;
case TEXTURE_SHARED_GL_EXTERNAL:
if (parentBackend == LAYERS_OPENGL) {
result = new TextureClientSharedOGLExternal(GetForwarder(), GetType());
result = new TextureClientSharedOGLExternal(GetForwarder(), GetTextureInfo());
}
break;
case TEXTURE_STREAM_GL:
if (parentBackend == LAYERS_OPENGL) {
result = new TextureClientStreamOGL(GetForwarder(), GetType());
result = new TextureClientStreamOGL(GetForwarder(), GetTextureInfo());
}
break;
case TEXTURE_YCBCR:
result = new TextureClientShmemYCbCr(GetForwarder(), GetType());
result = new TextureClientShmemYCbCr(GetForwarder(), GetTextureInfo());
break;
case TEXTURE_CONTENT:
// fall through to TEXTURE_SHMEM
case TEXTURE_SHMEM:
if (parentBackend == LAYERS_OPENGL) {
result = new TextureClientShmem(GetForwarder(), GetType());
result = new TextureClientShmem(GetForwarder(), GetTextureInfo());
}
break;
default:
@ -134,12 +112,7 @@ CompositableClient::CreateTextureClient(TextureClientType aTextureClientType,
MOZ_ASSERT(result, "Failed to create TextureClient");
MOZ_ASSERT(result->SupportsType(aTextureClientType),
"Created the wrong texture client?");
result->SetFlags(aFlags);
TextureChild* textureChild = static_cast<TextureChild*>(
GetIPDLActor()->SendPTextureConstructor(result->GetTextureInfo()));
result->SetIPDLActor(textureChild);
textureChild->SetClient(result);
result->SetFlags(GetTextureInfo().mTextureFlags);
return result.forget();
}

Просмотреть файл

@ -71,17 +71,22 @@ public:
virtual ~CompositableClient();
virtual CompositableType GetType() const
virtual TextureInfo GetTextureInfo() const
{
NS_WARNING("This method should be overridden");
return BUFFER_UNKNOWN;
MOZ_NOT_REACHED("This method should be overridden");
return TextureInfo();
}
LayersBackend GetCompositorBackendType() const;
TemporaryRef<TextureClient>
CreateTextureClient(TextureClientType aTextureClientType,
TextureFlags aFlags);
CreateTextureClient(TextureClientType aTextureClientType);
virtual void SetDescriptorFromReply(TextureIdentifier aTextureId,
const SurfaceDescriptor& aDescriptor)
{
MOZ_NOT_REACHED("If you want to call this, you should have implemented it");
}
/**
* Establishes the connection with compositor side through IPDL
@ -131,9 +136,6 @@ public:
MOZ_COUNT_DTOR(CompositableChild);
}
virtual PTextureChild* AllocPTexture(const TextureInfo& aInfo) MOZ_OVERRIDE;
virtual bool DeallocPTexture(PTextureChild* aActor) MOZ_OVERRIDE;
void Destroy();
void SetClient(CompositableClient* aClient)

Просмотреть файл

@ -74,7 +74,6 @@ ContentClientRemote::DestroyBuffers()
}
MOZ_ASSERT(mTextureClient->GetAccessMode() == TextureClient::ACCESS_READ_WRITE);
// dont't call m*mTextureClient->Destroyed();
mTextureClient = nullptr;
DestroyFrontBuffer();
@ -119,15 +118,15 @@ ContentClientRemote::CreateDTBuffer(ContentType aType,
mOldTextures.AppendElement(mTextureClient);
DestroyBuffers();
}
mTextureClient = CreateTextureClient(TEXTURE_CONTENT, aFlags | HostRelease);
mTextureInfo.mTextureFlags = aFlags | HostRelease;
mTextureClient = CreateTextureClient(TEXTURE_CONTENT);
mContentType = aType;
mSize = gfx::IntSize(aRect.width, aRect.height);
mTextureClient->EnsureAllocated(mSize, mContentType);
// note that LockSurfaceDescriptor doesn't actually lock anything
MOZ_ASSERT(IsSurfaceDescriptorValid(*mTextureClient->LockSurfaceDescriptor()));
MOZ_ASSERT(IsSurfaceDescriptorValid(*mTextureClient->GetDescriptor()));
CreateFrontBufferAndNotify(aRect, aFlags | HostRelease);
CreateFrontBufferAndNotify(aRect);
RefPtr<DrawTarget> ret = mTextureClient->LockDrawTarget();
return ret.forget();
@ -147,15 +146,15 @@ ContentClientRemote::CreateBuffer(ContentType aType,
mOldTextures.AppendElement(mTextureClient);
DestroyBuffers();
}
mTextureClient = CreateTextureClient(TEXTURE_CONTENT, aFlags | HostRelease);
mTextureInfo.mTextureFlags = aFlags | HostRelease;
mTextureClient = CreateTextureClient(TEXTURE_CONTENT);
mContentType = aType;
mSize = gfx::IntSize(aRect.width, aRect.height);
mTextureClient->EnsureAllocated(mSize, mContentType);
// note that LockSurfaceDescriptor doesn't actually lock anything
MOZ_ASSERT(IsSurfaceDescriptorValid(*mTextureClient->LockSurfaceDescriptor()));
MOZ_ASSERT(IsSurfaceDescriptorValid(*mTextureClient->GetDescriptor()));
CreateFrontBufferAndNotify(aRect, aFlags | HostRelease);
CreateFrontBufferAndNotify(aRect);
nsRefPtr<gfxASurface> ret = mTextureClient->LockSurface();
return ret.forget();
@ -197,7 +196,6 @@ ContentClientRemote::Updated(const nsIntRegion& aRegionToDraw,
aVisibleRegion,
aDidSelfCopy);
// don't call m*Client->Updated*()
MOZ_ASSERT(mTextureClient);
mTextureClient->SetAccessMode(TextureClient::ACCESS_NONE);
LockFrontBuffer();
@ -242,16 +240,18 @@ ContentClientDoubleBuffered::~ContentClientDoubleBuffered()
}
void
ContentClientDoubleBuffered::CreateFrontBufferAndNotify(const nsIntRect& aBufferRect,
uint32_t aFlags)
ContentClientDoubleBuffered::CreateFrontBufferAndNotify(const nsIntRect& aBufferRect)
{
mFrontClient = CreateTextureClient(TEXTURE_CONTENT, aFlags);
mFrontClient = CreateTextureClient(TEXTURE_CONTENT);
mFrontClient->EnsureAllocated(mSize, mContentType);
mFrontBufferRect = aBufferRect;
mFrontBufferRotation = nsIntPoint();
mForwarder->CreatedDoubleBuffer(this, mFrontClient, mTextureClient);
mForwarder->CreatedDoubleBuffer(this,
*mFrontClient->GetDescriptor(),
*mTextureClient->GetDescriptor(),
mTextureInfo);
}
void
@ -260,7 +260,6 @@ ContentClientDoubleBuffered::DestroyFrontBuffer()
MOZ_ASSERT(mFrontClient);
MOZ_ASSERT(mFrontClient->GetAccessMode() != TextureClient::ACCESS_NONE);
// dont't call mFrontClient->Destroyed();
mFrontClient = nullptr;
}
@ -415,10 +414,11 @@ ContentClientSingleBuffered::~ContentClientSingleBuffered()
}
void
ContentClientSingleBuffered::CreateFrontBufferAndNotify(const nsIntRect& aBufferRect,
uint32_t aFlags)
ContentClientSingleBuffered::CreateFrontBufferAndNotify(const nsIntRect& aBufferRect)
{
mForwarder->CreatedSingleBuffer(this, mTextureClient);
mForwarder->CreatedSingleBuffer(this,
*mTextureClient->GetDescriptor(),
mTextureInfo);
}
void

Просмотреть файл

@ -74,11 +74,6 @@ public:
virtual ~ContentClient()
{}
CompositableType GetType() const MOZ_OVERRIDE
{
return BUFFER_CONTENT;
}
typedef ThebesLayerBuffer::PaintState PaintState;
typedef ThebesLayerBuffer::ContentType ContentType;
@ -124,10 +119,10 @@ public:
virtual TemporaryRef<gfx::DrawTarget>
CreateDTBuffer(ContentType aType, const nsIntRect& aRect, uint32_t aFlags);
virtual CompositableType GetType() const MOZ_OVERRIDE
virtual TextureInfo GetTextureInfo() const MOZ_OVERRIDE
{
MOZ_ASSERT(false, "Should not be called on non-remote ContentClient");
return BUFFER_UNKNOWN;
MOZ_NOT_REACHED("Should not be called on non-remote ContentClient");
return TextureInfo();
}
@ -203,6 +198,11 @@ public:
void DestroyBuffers();
virtual TextureInfo GetTextureInfo() const MOZ_OVERRIDE
{
return mTextureInfo;
}
protected:
/**
* Swap out the old backing buffer for |aBuffer| and attributes.
@ -217,7 +217,7 @@ protected:
// Create the front buffer for the ContentClient/Host pair if necessary
// and notify the compositor that we have created the buffer(s).
virtual void CreateFrontBufferAndNotify(const nsIntRect& aBufferRect, uint32_t aFlags) = 0;
virtual void CreateFrontBufferAndNotify(const nsIntRect& aBufferRect) = 0;
virtual void DestroyFrontBuffer() {}
// We're about to hand off to the compositor, if you've got a back buffer,
// lock it now.
@ -226,8 +226,9 @@ protected:
RefPtr<TextureClient> mTextureClient;
// keep a record of texture clients we have created and need to keep
// around, then unlock when we are done painting
nsTArray<RefPtr<TextureClient>> mOldTextures;
nsTArray<RefPtr<TextureClient> > mOldTextures;
TextureInfo mTextureInfo;
bool mIsNewBuffer;
bool mFrontAndBackBufferDiffer;
gfx::IntSize mSize;
@ -250,20 +251,17 @@ class ContentClientDoubleBuffered : public ContentClientRemote
public:
ContentClientDoubleBuffered(CompositableForwarder* aFwd)
: ContentClientRemote(aFwd)
{}
~ContentClientDoubleBuffered();
CompositableType GetType() const MOZ_OVERRIDE
{
return BUFFER_CONTENT_DIRECT;
mTextureInfo.mCompositableType = BUFFER_CONTENT_DIRECT;
}
~ContentClientDoubleBuffered();
virtual void SwapBuffers(const nsIntRegion& aFrontUpdatedRegion) MOZ_OVERRIDE;
virtual void SyncFrontBufferToBackBuffer() MOZ_OVERRIDE;
protected:
virtual void CreateFrontBufferAndNotify(const nsIntRect& aBufferRect, uint32_t aFlags) MOZ_OVERRIDE;
virtual void CreateFrontBufferAndNotify(const nsIntRect& aBufferRect) MOZ_OVERRIDE;
virtual void DestroyFrontBuffer() MOZ_OVERRIDE;
virtual void LockFrontBuffer() MOZ_OVERRIDE;
@ -300,18 +298,15 @@ class ContentClientSingleBuffered : public ContentClientRemote
public:
ContentClientSingleBuffered(CompositableForwarder* aFwd)
: ContentClientRemote(aFwd)
{}
~ContentClientSingleBuffered();
virtual CompositableType GetType() const MOZ_OVERRIDE
{
return BUFFER_CONTENT;
mTextureInfo.mCompositableType = BUFFER_CONTENT;
}
~ContentClientSingleBuffered();
virtual void SyncFrontBufferToBackBuffer() MOZ_OVERRIDE;
protected:
virtual void CreateFrontBufferAndNotify(const nsIntRect& aBufferRect, uint32_t aFlags) MOZ_OVERRIDE;
virtual void CreateFrontBufferAndNotify(const nsIntRect& aBufferRect) MOZ_OVERRIDE;
};
}

Просмотреть файл

@ -78,8 +78,10 @@ ImageClientSingle::ImageClientSingle(CompositableForwarder* aFwd,
TextureFlags aFlags,
CompositableType aType)
: ImageClient(aFwd, aType)
, mFlags(aFlags)
{}
, mTextureInfo(aType)
{
mTextureInfo.mTextureFlags = aFlags;
}
void
ImageClientSingle::EnsureTextureClient(TextureClientType aType)
@ -89,7 +91,7 @@ ImageClientSingle::EnsureTextureClient(TextureClientType aType)
if (mTextureClient && mTextureClient->SupportsType(aType)) {
return;
}
mTextureClient = CreateTextureClient(aType, mFlags);
mTextureClient = CreateTextureClient(aType);
}
bool
@ -189,7 +191,7 @@ ImageClientSingle::UpdateImage(ImageContainer* aContainer,
void
ImageClientSingle::Updated()
{
mTextureClient->Updated();
mForwarder->UpdateTexture(this, 1, mTextureClient->GetDescriptor());
}
ImageClientBridge::ImageClientBridge(CompositableForwarder* aFwd,

Просмотреть файл

@ -38,11 +38,6 @@ public:
virtual ~ImageClient() {}
virtual CompositableType GetType() const MOZ_OVERRIDE
{
return mType;
}
/**
* Update this ImageClient from aContainer in aLayer
* returns false if this is the wrong kind of ImageClient for aContainer.
@ -91,9 +86,21 @@ public:
void EnsureTextureClient(TextureClientType aType);
virtual void Updated();
virtual void SetDescriptorFromReply(TextureIdentifier aTextureId,
const SurfaceDescriptor& aDescriptor) MOZ_OVERRIDE
{
mTextureClient->SetDescriptorFromReply(aDescriptor);
}
virtual TextureInfo GetTextureInfo() const MOZ_OVERRIDE
{
return mTextureInfo;
}
private:
RefPtr<TextureClient> mTextureClient;
TextureFlags mFlags;
TextureInfo mTextureInfo;
};
/**
@ -115,6 +122,11 @@ public:
mLayer = aLayer;
}
virtual TextureInfo GetTextureInfo() const MOZ_OVERRIDE
{
return TextureInfo(mType);
}
protected:
uint64_t mAsyncContainerID;
ShadowableLayer* mLayer;

Просмотреть файл

@ -12,7 +12,6 @@
#include "mozilla/layers/ShadowLayers.h"
#include "mozilla/layers/SharedPlanarYCbCrImage.h"
#include "GLContext.h"
#include "mozilla/layers/TextureChild.h"
#include "BasicLayers.h" // for PaintContext
#include "ShmemYCbCrImage.h"
#include "gfxReusableSurfaceWrapper.h"
@ -24,56 +23,23 @@ namespace mozilla {
namespace layers {
TextureClient::TextureClient(CompositableForwarder* aForwarder,
CompositableType aCompositableType)
const TextureInfo& aTextureInfo)
: mForwarder(aForwarder)
, mTextureChild(nullptr)
, mTextureInfo(aTextureInfo)
, mAccessMode(ACCESS_READ_WRITE)
{
MOZ_COUNT_CTOR(TextureClient);
mTextureInfo.mCompositableType = aCompositableType;
}
TextureClient::~TextureClient()
{
MOZ_COUNT_DTOR(TextureClient);
MOZ_ASSERT(mDescriptor.type() == SurfaceDescriptor::T__None, "Need to release surface!");
if (mTextureChild) {
static_cast<TextureChild*>(mTextureChild)->SetClient(nullptr);
static_cast<TextureChild*>(mTextureChild)->Destroy();
mTextureChild = nullptr;
}
}
void
TextureClient::Destroyed()
{
// The owning layer must be locked at some point in the chain of callers
// by calling Hold.
mForwarder->DestroyedThebesBuffer(mDescriptor);
}
void
TextureClient::Updated()
{
if (mDescriptor.type() != SurfaceDescriptor::T__None &&
mDescriptor.type() != SurfaceDescriptor::Tnull_t) {
mForwarder->UpdateTexture(this, SurfaceDescriptor(mDescriptor));
mDescriptor = SurfaceDescriptor();
} else {
NS_WARNING("Trying to send a null SurfaceDescriptor.");
}
}
void
TextureClient::SetIPDLActor(PTextureChild* aChild) {
mTextureChild = aChild;
}
TextureClientShmem::TextureClientShmem(CompositableForwarder* aForwarder,
CompositableType aCompositableType)
: TextureClient(aForwarder, aCompositableType)
const TextureInfo& aTextureInfo)
: TextureClient(aForwarder, aTextureInfo)
, mSurface(nullptr)
, mSurfaceAsImage(nullptr)
{
@ -94,6 +60,7 @@ TextureClientShmem::ReleaseResources()
if (IsSurfaceDescriptorValid(mDescriptor)) {
mForwarder->DestroySharedSurface(&mDescriptor);
mDescriptor = SurfaceDescriptor();
}
}
@ -210,15 +177,16 @@ TextureClientShmemYCbCr::EnsureAllocated(gfx::IntSize aSize,
TextureClientTile::TextureClientTile(const TextureClientTile& aOther)
: TextureClient(aOther.mForwarder, aOther.mTextureInfo.mCompositableType)
, mSurface(aOther.mSurface)
: TextureClient(aOther.mForwarder, aOther.mTextureInfo)
, mSurface(aOther.mSurface)
{}
TextureClientTile::~TextureClientTile()
{}
TextureClientTile::TextureClientTile(CompositableForwarder* aForwarder, CompositableType aCompositableType)
: TextureClient(aForwarder, aCompositableType)
TextureClientTile::TextureClientTile(CompositableForwarder* aForwarder,
const TextureInfo& aTextureInfo)
: TextureClient(aForwarder, aTextureInfo)
, mSurface(nullptr)
{
mTextureInfo.mTextureHostFlags = TEXTURE_HOST_TILED;

Просмотреть файл

@ -82,9 +82,7 @@ public:
virtual gfxASurface* LockSurface() { return nullptr; }
virtual gfx::DrawTarget* LockDrawTarget() { return nullptr; }
// note that this is often used simply as a getter for mDescriptor, not to
// lock anything, that is probably bad.
virtual SurfaceDescriptor* LockSurfaceDescriptor() { return &mDescriptor; }
virtual SurfaceDescriptor* LockSurfaceDescriptor() { return GetDescriptor(); }
virtual void ReleaseResources() {}
/**
* This unlocks the current DrawableTexture and allows the host to composite
@ -105,26 +103,14 @@ public:
*/
virtual void SetDescriptorFromReply(const SurfaceDescriptor& aDescriptor)
{
// default implem
// default implementation
SetDescriptor(aDescriptor);
}
virtual void SetDescriptor(const SurfaceDescriptor& aDescriptor)
{
mDescriptor = aDescriptor;
}
/**
* Adds this TextureClient's data to the current layer transaction.
* Gives up ownership of any shared resource.
*/
virtual void Updated();
virtual void Destroyed();
void SetIPDLActor(PTextureChild* aTextureChild);
PTextureChild* GetIPDLActor() const
{
return mTextureChild;
}
SurfaceDescriptor* GetDescriptor() { return &mDescriptor; }
CompositableForwarder* GetForwarder() const
{
@ -157,21 +143,20 @@ public:
protected:
TextureClient(CompositableForwarder* aForwarder,
CompositableType aCompositableType);
const TextureInfo& aTextureInfo);
CompositableForwarder* mForwarder;
// So far all TextureClients use a SurfaceDescriptor, so it makes sense to
// keep the reference here.
SurfaceDescriptor mDescriptor;
TextureInfo mTextureInfo;
PTextureChild* mTextureChild;
AccessMode mAccessMode;
};
class TextureClientShmem : public TextureClient
{
public:
TextureClientShmem(CompositableForwarder* aForwarder, CompositableType aCompositableType);
TextureClientShmem(CompositableForwarder* aForwarder, const TextureInfo& aTextureInfo);
~TextureClientShmem() { ReleaseResources(); }
virtual bool SupportsType(TextureClientType aType) MOZ_OVERRIDE
@ -201,8 +186,8 @@ private:
class TextureClientShmemYCbCr : public TextureClient
{
public:
TextureClientShmemYCbCr(CompositableForwarder* aForwarder, CompositableType aCompositableType)
: TextureClient(aForwarder, aCompositableType)
TextureClientShmemYCbCr(CompositableForwarder* aForwarder, const TextureInfo& aTextureInfo)
: TextureClient(aForwarder, aTextureInfo)
{ }
~TextureClientShmemYCbCr() { ReleaseResources(); }
@ -219,7 +204,7 @@ class TextureClientTile : public TextureClient
public:
TextureClientTile(const TextureClientTile& aOther);
TextureClientTile(CompositableForwarder* aForwarder,
CompositableType aCompositableType);
const TextureInfo& aTextureInfo);
~TextureClientTile();
virtual void EnsureAllocated(gfx::IntSize aSize,

Просмотреть файл

@ -181,7 +181,7 @@ BasicTiledLayerBuffer::ValidateTileInternal(BasicTiledLayerTile aTile,
{
if (aTile.IsPlaceholderTile()) {
RefPtr<TextureClient> textureClient =
new TextureClientTile(mManager, BUFFER_TILED);
new TextureClientTile(mManager, TextureInfo(BUFFER_TILED));
aTile.mTextureClient = static_cast<TextureClientTile*>(textureClient.get());
}
aTile.mTextureClient->EnsureAllocated(gfx::IntSize(GetTileLength(), GetTileLength()), GetContentType());

Просмотреть файл

@ -32,17 +32,6 @@ CanvasLayerComposite::~CanvasLayerComposite()
CleanupResources();
}
void
CanvasLayerComposite::EnsureImageHost(CompositableType aHostType)
{
if (!mImageHost ||
mImageHost->GetType() != aHostType) {
RefPtr<CompositableHost> bufferHost
= CompositableHost::Create(aHostType, mCompositeManager->GetCompositor());
mImageHost = static_cast<ImageHost*>(bufferHost.get());
}
}
void CanvasLayerComposite::SetCompositableHost(CompositableHost* aHost) {
mImageHost = static_cast<ImageHost*>(aHost);
}

Просмотреть файл

@ -72,8 +72,6 @@ protected:
#endif
private:
void EnsureImageHost(CompositableType aHostType);
RefPtr<ImageHost> mImageHost;
};

Просмотреть файл

@ -7,7 +7,6 @@
#include "ImageHost.h"
#include "ContentHost.h"
#include "TiledContentHost.h"
#include "mozilla/layers/TextureParent.h"
#include "Effects.h"
#include "mozilla/layers/CompositableTransactionParent.h"
@ -44,24 +43,24 @@ CompositableHost::AddMaskEffect(EffectChain& aEffects,
}
/* static */ TemporaryRef<CompositableHost>
CompositableHost::Create(CompositableType aType, Compositor* aCompositor)
CompositableHost::Create(const TextureInfo& aTextureInfo, Compositor* aCompositor)
{
RefPtr<CompositableHost> result;
switch (aType) {
switch (aTextureInfo.mCompositableType) {
case BUFFER_IMAGE_BUFFERED:
result = new ImageHostBuffered(aCompositor, aType);
result = new ImageHostBuffered(aTextureInfo, aCompositor);
return result;
case BUFFER_IMAGE_SINGLE:
result = new ImageHostSingle(aCompositor, aType);
result = new ImageHostSingle(aTextureInfo, aCompositor);
return result;
case BUFFER_TILED:
result = new TiledContentHost(aCompositor);
result = new TiledContentHost(aTextureInfo, aCompositor);
return result;
case BUFFER_CONTENT:
result = new ContentHostSingleBuffered(aCompositor);
result = new ContentHostSingleBuffered(aTextureInfo, aCompositor);
return result;
case BUFFER_CONTENT_DIRECT:
result = new ContentHostDoubleBuffered(aCompositor);
result = new ContentHostDoubleBuffered(aTextureInfo, aCompositor);
return result;
default:
MOZ_NOT_REACHED("Unknown CompositableType");
@ -69,19 +68,6 @@ CompositableHost::Create(CompositableType aType, Compositor* aCompositor)
}
}
PTextureParent*
CompositableParent::AllocPTexture(const TextureInfo& aInfo)
{
return new TextureParent(aInfo, this);
}
bool
CompositableParent::DeallocPTexture(PTextureParent* aActor)
{
delete aActor;
return true;
}
void
CompositableParent::ActorDestroy(ActorDestroyReason why)
{
@ -91,15 +77,15 @@ CompositableParent::ActorDestroy(ActorDestroyReason why)
}
CompositableParent::CompositableParent(CompositableParentManager* aMgr,
CompositableType aType,
const TextureInfo& aTextureInfo,
uint64_t aID)
: mManager(aMgr)
, mType(aType)
, mType(aTextureInfo.mCompositableType)
, mID(aID)
, mCompositorID(0)
{
MOZ_COUNT_CTOR(CompositableParent);
mHost = CompositableHost::Create(aType);
mHost = CompositableHost::Create(aTextureInfo);
if (aID) {
CompositableMap::Set(aID, this);
}

Просмотреть файл

@ -48,8 +48,10 @@ class SurfaceDescriptor;
class CompositableHost : public RefCounted<CompositableHost>
{
public:
CompositableHost(Compositor* aCompositor = nullptr)
: mCompositor(aCompositor)
CompositableHost(const TextureInfo& aTextureInfo,
Compositor* aCompositor = nullptr)
: mTextureInfo(aTextureInfo)
, mCompositor(aCompositor)
, mLayer(nullptr)
{
MOZ_COUNT_CTOR(CompositableHost);
@ -60,7 +62,7 @@ public:
MOZ_COUNT_DTOR(CompositableHost);
}
static TemporaryRef<CompositableHost> Create(CompositableType aType,
static TemporaryRef<CompositableHost> Create(const TextureInfo& aTextureInfo,
Compositor* aCompositor = nullptr);
virtual CompositableType GetType() = 0;
@ -88,11 +90,7 @@ public:
/**
* Update the content host.
* aTextureInfo identifies the texture host which should be updated.
* aNewBack is the new data
* aUpdated is the region which should be updated
* aNewfront may point to the old data in this content host after the call
* aNewBackResult may point to the updated data in this content host
* aUpdatedRegionBack is the region in aNewBackResult which has been updated
*/
virtual void UpdateThebes(const ThebesBufferData& aData,
@ -103,8 +101,26 @@ public:
MOZ_ASSERT(false, "should be implemented or not used");
}
virtual void AddTextureHost(TextureHost* aTextureHost,
ISurfaceAllocator* aAllocator = nullptr) = 0;
/**
* Ensure that a suitable texture host exists in this compositable. The
* compositable host may or may not create a new texture host. If a texture
* host is replaced, then the compositable is responsible for enusring it is
* destroyed correctly (without leaking resources).
* aTextureId - identifies the texture within the compositable, how the
* compositable chooses to use this is between the compositable client and
* host and will vary between types of compositable.
* aSurface - the new or existing texture host should support surface
* descriptors of the same type and, if necessary, this specific surface
* descriptor. Whether it is necessary or not depends on the protocol between
* the compositable client and host.
* aAllocator - the allocator used to allocate and de-allocate resources.
* aTextureInfo - contains flags for the texture.
*/
virtual bool EnsureTextureHost(TextureIdentifier aTextureId,
const SurfaceDescriptor& aSurface,
ISurfaceAllocator* aAllocator,
const TextureInfo& aTextureInfo) = 0;
virtual TextureHost* GetTextureHost() { return nullptr; }
virtual LayerRenderState GetRenderState() = 0;
@ -145,6 +161,7 @@ public:
#endif
protected:
TextureInfo mTextureInfo;
Compositor* mCompositor;
Layer* mLayer;
};
@ -155,10 +172,9 @@ class CompositableParent : public PCompositableParent
{
public:
CompositableParent(CompositableParentManager* aMgr,
CompositableType aType, uint64_t aID = 0);
const TextureInfo& aTextureInfo,
uint64_t aID = 0);
~CompositableParent();
PTextureParent* AllocPTexture(const TextureInfo& aInfo) MOZ_OVERRIDE;
bool DeallocPTexture(PTextureParent* aActor) MOZ_OVERRIDE;
virtual void ActorDestroy(ActorDestroyReason why) MOZ_OVERRIDE;

Просмотреть файл

@ -11,8 +11,9 @@ namespace mozilla {
using namespace gfx;
namespace layers {
ContentHostBase::ContentHostBase(Compositor* aCompositor)
: ContentHost(aCompositor)
ContentHostBase::ContentHostBase(const TextureInfo& aTextureInfo,
Compositor* aCompositor)
: ContentHost(aTextureInfo, aCompositor)
, mPaintWillResample(false)
, mInitialised(false)
{}
@ -204,12 +205,24 @@ ContentHostSingleBuffered::~ContentHostSingleBuffered()
DestroyFrontHost();
}
void
ContentHostSingleBuffered::SetTextureHosts(TextureHost* aNewFront,
TextureHost* aNewBack /*=nullptr*/)
bool
ContentHostSingleBuffered::EnsureTextureHost(TextureIdentifier aTextureId,
const SurfaceDescriptor& aSurface,
ISurfaceAllocator* aAllocator,
const TextureInfo& aTextureInfo)
{
MOZ_ASSERT(!aNewBack);
mNewFrontHost = aNewFront;
MOZ_ASSERT(aTextureId == TextureFront);
mNewFrontHost = TextureHost::CreateTextureHost(aSurface.type(),
aTextureInfo.mTextureHostFlags,
aTextureInfo.mTextureFlags);
mNewFrontHost->SetBuffer(new SurfaceDescriptor(aSurface), aAllocator);
Compositor* compositor = GetCompositor();
if (compositor) {
mNewFrontHost->SetCompositor(compositor);
}
return true;
}
void
@ -275,17 +288,36 @@ ContentHostDoubleBuffered::~ContentHostDoubleBuffered()
DestroyFrontHost();
}
void
ContentHostDoubleBuffered::SetTextureHosts(TextureHost* aNewFront,
TextureHost* aNewBack /*=nullptr*/)
bool
ContentHostDoubleBuffered::EnsureTextureHost(TextureIdentifier aTextureId,
const SurfaceDescriptor& aSurface,
ISurfaceAllocator* aAllocator,
const TextureInfo& aTextureInfo)
{
MOZ_ASSERT(aNewBack);
// the actual TextureHosts are created in reponse to the PTexture constructor
// we just match them up here
mNewFrontHost = aNewFront;
mBackHost = aNewBack;
RefPtr<TextureHost> newHost = TextureHost::CreateTextureHost(aSurface.type(),
aTextureInfo.mTextureHostFlags,
aTextureInfo.mTextureFlags);
newHost->SetBuffer(new SurfaceDescriptor(aSurface), aAllocator);
Compositor* compositor = GetCompositor();
if (compositor) {
newHost->SetCompositor(compositor);
}
if (aTextureId == TextureFront) {
mNewFrontHost = newHost;
return true;
}
if (aTextureId == TextureBack) {
mBackHost = newHost;
mBufferRect = nsIntRect();
mBufferRotation = nsIntPoint();
return true;
}
NS_ERROR("Bad texture identifier");
return false;
}
void

Просмотреть файл

@ -39,8 +39,8 @@ public:
#endif
protected:
ContentHost(Compositor* aCompositor)
: CompositableHost(aCompositor)
ContentHost(const TextureInfo& aTextureInfo, Compositor* aCompositor)
: CompositableHost(aTextureInfo, aCompositor)
{}
};
@ -61,7 +61,7 @@ public:
typedef ThebesLayerBuffer::ContentType ContentType;
typedef ThebesLayerBuffer::PaintState PaintState;
ContentHostBase(Compositor* aCompositor);
ContentHostBase(const TextureInfo& aTextureInfo, Compositor* aCompositor);
~ContentHostBase();
virtual void Composite(EffectChain& aEffectChain,
@ -97,14 +97,6 @@ public:
}
#endif
// Set one or both texture hosts. We do not use AddTextureHost because for
// double buffering, we need to add two hosts and know which is which.
virtual void SetTextureHosts(TextureHost* aNewFront,
TextureHost* aNewBack = nullptr) = 0;
// For double buffered ContentHosts we want to set both TextureHosts at
// once so we ignore this call.
virtual void AddTextureHost(TextureHost* aTextureHost,
ISurfaceAllocator* aAllocator = nullptr) MOZ_OVERRIDE {}
virtual TextureHost* GetTextureHost() MOZ_OVERRIDE;
void SetPaintWillResample(bool aResample) { mPaintWillResample = aResample; }
@ -143,8 +135,9 @@ protected:
class ContentHostDoubleBuffered : public ContentHostBase
{
public:
ContentHostDoubleBuffered(Compositor* aCompositor)
: ContentHostBase(aCompositor)
ContentHostDoubleBuffered(const TextureInfo& aTextureInfo,
Compositor* aCompositor)
: ContentHostBase(aTextureInfo, aCompositor)
{}
~ContentHostDoubleBuffered();
@ -156,9 +149,10 @@ public:
const nsIntRegion& aOldValidRegionBack,
nsIntRegion* aUpdatedRegionBack);
// We expect both TextureHosts.
virtual void SetTextureHosts(TextureHost* aNewFront,
TextureHost* aNewBack = nullptr) MOZ_OVERRIDE;
virtual bool EnsureTextureHost(TextureIdentifier aTextureId,
const SurfaceDescriptor& aSurface,
ISurfaceAllocator* aAllocator,
const TextureInfo& aTextureInfo) MOZ_OVERRIDE;
virtual void DestroyTextures() MOZ_OVERRIDE;
#ifdef MOZ_LAYERS_HAVE_LOG
@ -179,8 +173,9 @@ protected:
class ContentHostSingleBuffered : public ContentHostBase
{
public:
ContentHostSingleBuffered(Compositor* aCompositor)
: ContentHostBase(aCompositor)
ContentHostSingleBuffered(const TextureInfo& aTextureInfo,
Compositor* aCompositor)
: ContentHostBase(aTextureInfo, aCompositor)
{}
virtual ~ContentHostSingleBuffered();
@ -191,9 +186,10 @@ public:
const nsIntRegion& aOldValidRegionBack,
nsIntRegion* aUpdatedRegionBack);
// We expect only one TextureHost.
virtual void SetTextureHosts(TextureHost* aNewFront,
TextureHost* aNewBack = nullptr) MOZ_OVERRIDE;
virtual bool EnsureTextureHost(TextureIdentifier aTextureId,
const SurfaceDescriptor& aSurface,
ISurfaceAllocator* aAllocator,
const TextureInfo& aTextureInfo) MOZ_OVERRIDE;
virtual void DestroyTextures() MOZ_OVERRIDE;
#ifdef MOZ_LAYERS_HAVE_LOG

Просмотреть файл

@ -24,13 +24,28 @@ ImageHostSingle::SetCompositor(Compositor* aCompositor) {
}
}
void
ImageHostSingle::AddTextureHost(TextureHost* aHost, ISurfaceAllocator* aAllocator)
bool
ImageHostSingle::EnsureTextureHost(TextureIdentifier aTextureId,
const SurfaceDescriptor& aSurface,
ISurfaceAllocator* aAllocator,
const TextureInfo& aTextureInfo)
{
mTextureHost = aHost;
if (mCompositor) {
mTextureHost->SetCompositor(mCompositor);
if (mTextureHost &&
mTextureHost->GetBuffer() &&
mTextureHost->GetBuffer()->type() == aSurface.type()) {
return false;
}
mTextureHost = TextureHost::CreateTextureHost(aSurface.type(),
mTextureInfo.mTextureHostFlags,
mTextureInfo.mTextureFlags);
Compositor* compositor = GetCompositor();
if (compositor) {
mTextureHost->SetCompositor(compositor);
}
return true;
}
void
@ -134,18 +149,22 @@ ImageHostBuffered::Update(const SurfaceDescriptor& aImage,
return GetTextureHost()->IsValid();
}
void
ImageHostBuffered::AddTextureHost(TextureHost* aHost,
ISurfaceAllocator* aAllocator)
bool
ImageHostBuffered::EnsureTextureHost(TextureIdentifier aTextureId,
const SurfaceDescriptor& aSurface,
ISurfaceAllocator* aAllocator,
const TextureInfo& aTextureInfo)
{
MOZ_ASSERT(aAllocator);
mTextureHost = aHost;
if (mCompositor) {
mTextureHost->SetCompositor(mCompositor);
}
mTextureHost->SetBuffer(new SurfaceDescriptor(null_t()),
aAllocator);
bool result = ImageHostSingle::EnsureTextureHost(aTextureId,
aSurface,
aAllocator,
aTextureInfo);
if (result) {
mTextureHost->SetBuffer(new SurfaceDescriptor(null_t()), aAllocator);
mPictureRect = nsIntRect(0, 0, -1, -1);
}
return result;
}
}

Просмотреть файл

@ -24,8 +24,8 @@ public:
TextureHost* GetTextureHost() MOZ_OVERRIDE { return nullptr; }
protected:
ImageHost(Compositor* aCompositor)
: CompositableHost(aCompositor)
ImageHost(const TextureInfo& aTextureInfo, Compositor* aCompositor)
: CompositableHost(aTextureInfo, aCompositor)
{
MOZ_COUNT_CTOR(ImageHost);
}
@ -40,17 +40,18 @@ protected:
class ImageHostSingle : public ImageHost
{
public:
ImageHostSingle(Compositor* aCompositor, CompositableType aType)
: ImageHost(aCompositor)
ImageHostSingle(const TextureInfo& aTextureInfo, Compositor* aCompositor)
: ImageHost(aTextureInfo, aCompositor)
, mTextureHost(nullptr)
, mType(aType)
, mHasPictureRect(false)
{}
virtual CompositableType GetType() { return mType; }
virtual CompositableType GetType() { return mTextureInfo.mCompositableType; }
virtual void AddTextureHost(TextureHost* aTextureHost,
ISurfaceAllocator* aAllocator = nullptr) MOZ_OVERRIDE;
virtual bool EnsureTextureHost(TextureIdentifier aTextureId,
const SurfaceDescriptor& aSurface,
ISurfaceAllocator* aAllocator,
const TextureInfo& aTextureInfo) MOZ_OVERRIDE;
TextureHost* GetTextureHost() MOZ_OVERRIDE { return mTextureHost; }
@ -89,7 +90,6 @@ public:
protected:
RefPtr<TextureHost> mTextureHost;
nsIntRect mPictureRect;
CompositableType mType;
bool mHasPictureRect;
};
@ -99,15 +99,18 @@ protected:
class ImageHostBuffered : public ImageHostSingle
{
public:
ImageHostBuffered(Compositor* aCompositor, CompositableType aType)
: ImageHostSingle(aCompositor, aType)
ImageHostBuffered(const TextureInfo& aTextureInfo, Compositor* aCompositor)
: ImageHostSingle(aTextureInfo, aCompositor)
{}
virtual bool Update(const SurfaceDescriptor& aImage,
SurfaceDescriptor* aResult = nullptr) MOZ_OVERRIDE;
virtual void AddTextureHost(TextureHost* aTextureHost,
ISurfaceAllocator* aAllocator = nullptr) MOZ_OVERRIDE;
virtual bool EnsureTextureHost(TextureIdentifier aTextureId,
const SurfaceDescriptor& aSurface,
ISurfaceAllocator* aAllocator,
const TextureInfo& aTextureInfo) MOZ_OVERRIDE;
};
}

Просмотреть файл

@ -290,7 +290,7 @@ public:
virtual TiledLayerComposer* AsTiledLayerComposer() { return NULL; }
virtual void EnsureBuffer(CompositableType aHostType)
virtual void EnsureBuffer(CompositableType aType)
{
MOZ_ASSERT(false, "Should not be called unless overriden.");
}

Просмотреть файл

@ -45,7 +45,6 @@ TextureHost::TextureHost()
: mFlags(0)
, mBuffer(nullptr)
, mFormat(gfx::FORMAT_UNKNOWN)
, mTextureParent(nullptr)
, mDeAllocator(nullptr)
{
MOZ_COUNT_CTOR(TextureHost);

Просмотреть файл

@ -232,19 +232,6 @@ public:
mFlags & NeedsYFlip ? LAYER_RENDER_STATE_Y_FLIPPED : 0);
}
// IPC
void SetTextureParent(TextureParent* aParent)
{
MOZ_ASSERT(!mTextureParent || mTextureParent == aParent);
mTextureParent = aParent;
}
TextureParent* GetIPDLActor() const
{
return mTextureParent;
}
#ifdef MOZ_LAYERS_HAVE_LOG
virtual const char *Name() = 0;
virtual void PrintInfo(nsACString& aTo, const char* aPrefix);
@ -306,7 +293,6 @@ protected:
SurfaceDescriptor* mBuffer;
gfx::SurfaceFormat mFormat;
TextureParent* mTextureParent;
ISurfaceAllocator* mDeAllocator;
};

Просмотреть файл

@ -48,13 +48,14 @@ ThebesLayerComposite::SetCompositableHost(CompositableHost* aHost)
}
void
ThebesLayerComposite::EnsureBuffer(CompositableType aHostType)
ThebesLayerComposite::EnsureBuffer(CompositableType aType)
{
MOZ_ASSERT(aHostType == BUFFER_TILED, "Should only be called for tiled layers.");
MOZ_ASSERT(aType == BUFFER_TILED,
"Should only be called for tiled layers.");
if (!mBuffer ||
mBuffer->GetType() != aHostType) {
mBuffer->GetType() != aType) {
RefPtr<CompositableHost> bufferHost
= CompositableHost::Create(aHostType, mCompositeManager->GetCompositor());
= CompositableHost::Create(TextureInfo(aType), mCompositeManager->GetCompositor());
NS_ASSERTION(bufferHost->GetType() == BUFFER_TILED, "bad buffer type");
mBuffer = static_cast<ContentHost*>(bufferHost.get());
mRequiresTiledProperties = true;

Просмотреть файл

@ -58,7 +58,7 @@ public:
virtual LayerComposite* AsLayerComposite() MOZ_OVERRIDE { return this; }
virtual void EnsureBuffer(CompositableType aHostType) MOZ_OVERRIDE;
virtual void EnsureBuffer(CompositableType aType) MOZ_OVERRIDE;
#ifdef MOZ_LAYERS_HAVE_LOG
virtual const char* Name() const MOZ_OVERRIDE { return "ThebesLayerComposite"; }

Просмотреть файл

@ -284,7 +284,7 @@ TiledTexture::Validate(gfxReusableSurfaceWrapper* aReusableSurface, Compositor*
// convert placeholder tile to a real tile
mTextureHost = TextureHost::CreateTextureHost(SurfaceDescriptor::Tnull_t,
TEXTURE_HOST_TILED,
0);
flags);
mTextureHost->SetCompositor(aCompositor);
flags |= NewTile;
}

Просмотреть файл

@ -126,8 +126,8 @@ class TiledContentHost : public ContentHost,
public TiledLayerComposer
{
public:
TiledContentHost(Compositor* aCompositor)
: ContentHost(aCompositor)
TiledContentHost(const TextureInfo& aTextureInfo, Compositor* aCompositor)
: ContentHost(aTextureInfo, aCompositor)
, mVideoMemoryTiledBuffer(aCompositor)
, mLowPrecisionVideoMemoryTiledBuffer(aCompositor)
, mPendingUpload(false)
@ -181,10 +181,13 @@ public:
virtual TiledLayerComposer* AsTiledLayerComposer() { return this; }
virtual void AddTextureHost(TextureHost* aTextureHost,
ISurfaceAllocator* aAllocator = nullptr)
virtual bool EnsureTextureHost(TextureIdentifier aTextureId,
const SurfaceDescriptor& aSurface,
ISurfaceAllocator* aAllocator,
const TextureInfo& aTextureInfo) MOZ_OVERRIDE
{
MOZ_ASSERT(false, "Does nothing");
MOZ_NOT_REACHED("Does nothing");
return false;
}
#ifdef MOZ_LAYERS_HAVE_LOG

Просмотреть файл

@ -56,10 +56,12 @@ public:
* moves to the compositor.
*/
virtual void CreatedSingleBuffer(CompositableClient* aCompositable,
TextureClient* aBuffer) = 0;
const SurfaceDescriptor& aDescriptor,
const TextureInfo& aTextureInfo) = 0;
virtual void CreatedDoubleBuffer(CompositableClient* aCompositable,
TextureClient* aFront,
TextureClient* aBack) = 0;
const SurfaceDescriptor& aFrontDescriptor,
const SurfaceDescriptor& aBackDescriptor,
const TextureInfo& aTextureInfo) = 0;
/**
* Tell the compositor that a Compositable is killing its buffer(s),
@ -68,15 +70,16 @@ public:
virtual void DestroyThebesBuffer(CompositableClient* aCompositable) = 0;
/**
* Communicate to the compositor that the texture identified by aLayer
* and aIdentifier has been updated to aImage.
* Communicate to the compositor that the texture identified by aCompositable
* and aTextureId has been updated to aImage.
*/
virtual void UpdateTexture(TextureClient* aTexture,
const SurfaceDescriptor& aImage) = 0;
virtual void UpdateTexture(CompositableClient* aCompositable,
TextureIdentifier aTextureId,
SurfaceDescriptor* aDescriptor) = 0;
/**
* Communicate to the compositor that aRegion in the texture identified by aLayer
* and aIdentifier has been updated to aThebesBuffer.
* Communicate to the compositor that aRegion in the texture identified by
* aCompositable and aIdentifier has been updated to aThebesBuffer.
*/
virtual void UpdateTextureRegion(CompositableClient* aCompositable,
const ThebesBufferData& aThebesBufferData,

Просмотреть файл

@ -13,62 +13,27 @@
#include "mozilla/layers/ContentHost.h"
#include "ShadowLayerParent.h"
#include "TiledLayerBuffer.h"
#include "mozilla/layers/TextureParent.h"
#include "LayerManagerComposite.h"
#include "CompositorParent.h"
namespace mozilla {
namespace layers {
//--------------------------------------------------
// Convenience accessors
template<class OpPaintT>
Layer* GetLayerFromOpPaint(const OpPaintT& op)
{
PTextureParent* textureParent = op.textureParent();
CompositableHost* compoHost
= static_cast<CompositableParent*>(textureParent->Manager())->GetCompositableHost();
return compoHost ? compoHost->GetLayer() : nullptr;
}
bool
CompositableParentManager::ReceiveCompositableUpdate(const CompositableOperation& aEdit,
EditReplyVector& replyv)
{
switch (aEdit.type()) {
case CompositableOperation::TOpCreatedSingleBuffer: {
MOZ_LAYERS_LOG(("[ParentSide] Created single buffer"));
const OpCreatedSingleBuffer& op = aEdit.get_OpCreatedSingleBuffer();
CompositableParent* compositableParent = static_cast<CompositableParent*>(op.compositableParent());
TextureParent* textureParent = static_cast<TextureParent*>(op.bufferParent());
case CompositableOperation::TOpCreatedTexture: {
MOZ_LAYERS_LOG(("[ParentSide] Created texture"));
const OpCreatedTexture& op = aEdit.get_OpCreatedTexture();
CompositableParent* compositableParent =
static_cast<CompositableParent*>(op.compositableParent());
CompositableHost* compositable = compositableParent->GetCompositableHost();
textureParent->EnsureTextureHost(op.descriptor().type());
textureParent->GetTextureHost()->SetBuffer(new SurfaceDescriptor(op.descriptor()),
compositableParent->GetCompositableManager());
ContentHostBase* content = static_cast<ContentHostBase*>(compositableParent->GetCompositableHost());
content->SetTextureHosts(textureParent->GetTextureHost());
break;
}
case CompositableOperation::TOpCreatedDoubleBuffer: {
MOZ_LAYERS_LOG(("[ParentSide] Created double buffer"));
const OpCreatedDoubleBuffer& op = aEdit.get_OpCreatedDoubleBuffer();
CompositableParent* compositableParent = static_cast<CompositableParent*>(op.compositableParent());
TextureParent* frontParent = static_cast<TextureParent*>(op.frontParent());
TextureParent* backParent = static_cast<TextureParent*>(op.backParent());
frontParent->EnsureTextureHost(op.frontDescriptor().type());
backParent->EnsureTextureHost(op.backDescriptor().type());
frontParent->GetTextureHost()->SetBuffer(new SurfaceDescriptor(op.frontDescriptor()),
compositableParent->GetCompositableManager());
backParent->GetTextureHost()->SetBuffer(new SurfaceDescriptor(op.backDescriptor()),
compositableParent->GetCompositableManager());
ContentHostBase* content = static_cast<ContentHostBase*>(compositableParent->GetCompositableHost());
content->SetTextureHosts(frontParent->GetTextureHost(),
backParent->GetTextureHost());
compositable->EnsureTextureHost(op.textureId(), op.descriptor(),
compositableParent->GetCompositableManager(),
op.textureInfo());
break;
}
@ -85,9 +50,12 @@ CompositableParentManager::ReceiveCompositableUpdate(const CompositableOperation
MOZ_LAYERS_LOG(("[ParentSide] Paint Texture X"));
const OpPaintTexture& op = aEdit.get_OpPaintTexture();
TextureParent* textureParent = static_cast<TextureParent*>(op.textureParent());
CompositableHost* compositable = textureParent->GetCompositableHost();
Layer* layer = GetLayerFromOpPaint(op);
CompositableParent* compositableParent =
static_cast<CompositableParent*>(op.compositableParent());
CompositableHost* compositable =
compositableParent->GetCompositableHost();
Layer* layer = compositable ? compositable->GetLayer() : nullptr;
ShadowLayer* shadowLayer = layer ? layer->AsShadowLayer() : nullptr;
if (shadowLayer) {
Compositor* compositor = static_cast<LayerManagerComposite*>(layer->Manager())->GetCompositor();
@ -105,18 +73,21 @@ CompositableParentManager::ReceiveCompositableUpdate(const CompositableOperation
}
const SurfaceDescriptor& descriptor = op.image();
textureParent->EnsureTextureHost(descriptor.type());
MOZ_ASSERT(textureParent->GetTextureHost());
compositable->EnsureTextureHost(op.textureId(),
descriptor,
compositableParent->GetCompositableManager(),
TextureInfo());
MOZ_ASSERT(compositable->GetTextureHost());
SurfaceDescriptor newBack;
bool shouldRecomposite = compositable->Update(op.image(), &newBack);
bool shouldRecomposite = compositable->Update(descriptor, &newBack);
if (IsSurfaceDescriptorValid(newBack)) {
replyv.push_back(OpTextureSwap(op.textureParent(), nullptr, newBack));
replyv.push_back(OpTextureSwap(compositableParent, nullptr, op.textureId(), newBack));
}
if (shouldRecomposite && textureParent->GetCompositorID()) {
if (shouldRecomposite && compositableParent->GetCompositorID()) {
CompositorParent* cp
= CompositorParent::GetCompositor(textureParent->GetCompositorID());
= CompositorParent::GetCompositor(compositableParent->GetCompositorID());
if (cp) {
cp->ScheduleComposition();
}

Просмотреть файл

@ -30,6 +30,7 @@ CompositorChild::~CompositorChild()
void
CompositorChild::Destroy()
{
mLayerManager->Destroy();
mLayerManager = NULL;
while (size_t len = ManagedPLayersChild().Length()) {
ShadowLayersChild* layers =

Просмотреть файл

@ -12,7 +12,6 @@
#include "mozilla/Monitor.h"
#include "mozilla/ReentrantMonitor.h"
#include "mozilla/layers/CompositableClient.h"
#include "mozilla/layers/TextureChild.h"
#include "nsXULAppAPI.h"
#include "mozilla/layers/TextureClient.h"
#include "mozilla/layers/ImageClient.h"
@ -78,13 +77,20 @@ struct AutoEndTransaction {
};
void
ImageBridgeChild::UpdateTexture(TextureClient* aTexture,
const SurfaceDescriptor& aImage)
ImageBridgeChild::UpdateTexture(CompositableClient* aCompositable,
TextureIdentifier aTextureId,
SurfaceDescriptor* aDescriptor)
{
MOZ_ASSERT(aImage.type() != SurfaceDescriptor::T__None, "[debug] STOP");
MOZ_ASSERT(aTexture);
MOZ_ASSERT(aTexture->GetIPDLActor());
mTxn->AddEdit(OpPaintTexture(nullptr, aTexture->GetIPDLActor(), aImage));
if (aDescriptor->type() != SurfaceDescriptor::T__None &&
aDescriptor->type() != SurfaceDescriptor::Tnull_t) {
MOZ_ASSERT(aCompositable);
MOZ_ASSERT(aCompositable->GetIPDLActor());
mTxn->AddEdit(OpPaintTexture(nullptr, aCompositable->GetIPDLActor(), 1,
SurfaceDescriptor(*aDescriptor)));
*aDescriptor = SurfaceDescriptor();
} else {
NS_WARNING("Trying to send a null SurfaceDescriptor.");
}
}
void
@ -206,7 +212,7 @@ ImageBridgeChild::Connect(CompositableClient* aCompositable)
MOZ_ASSERT(aCompositable);
uint64_t id = 0;
CompositableChild* child = static_cast<CompositableChild*>(
SendPCompositableConstructor(aCompositable->GetType(), &id));
SendPCompositableConstructor(aCompositable->GetTextureInfo(), &id));
MOZ_ASSERT(child);
child->SetAsyncID(id);
aCompositable->SetIPDLActor(child);
@ -215,7 +221,7 @@ ImageBridgeChild::Connect(CompositableClient* aCompositable)
}
PCompositableChild*
ImageBridgeChild::AllocPCompositable(const CompositableType& aType, uint64_t* aID)
ImageBridgeChild::AllocPCompositable(const TextureInfo& aInfo, uint64_t* aID)
{
return new CompositableChild();
}
@ -336,10 +342,14 @@ ImageBridgeChild::EndTransaction()
switch (reply.type()) {
case EditReply::TOpTextureSwap: {
const OpTextureSwap& ots = reply.get_OpTextureSwap();
PTextureChild* textureChild = ots.textureChild();
MOZ_ASSERT(textureChild);
TextureClient* texClient = static_cast<TextureChild*>(textureChild)->GetTextureClient();
texClient->SetDescriptor(ots.image());
CompositableChild* compositableChild =
static_cast<CompositableChild*>(ots.compositableChild());
MOZ_ASSERT(compositableChild);
compositableChild->GetCompositableClient()
->SetDescriptorFromReply(ots.textureId(), ots.image());
break;
}
default:
@ -475,8 +485,7 @@ ImageBridgeChild::CreateImageClientNow(CompositableType aType)
mCompositorBackend = LAYERS_OPENGL;
RefPtr<ImageClient> client
= ImageClient::CreateImageClient(mCompositorBackend,
aType, this, 0);
= ImageClient::CreateImageClient(mCompositorBackend, aType, this, 0);
MOZ_ASSERT(client, "failed to create ImageClient");
if (client) {
client->Connect();

Просмотреть файл

@ -165,7 +165,7 @@ public:
*/
MessageLoop * GetMessageLoop() const;
PCompositableChild* AllocPCompositable(const CompositableType& aType, uint64_t* aID) MOZ_OVERRIDE;
PCompositableChild* AllocPCompositable(const TextureInfo& aInfo, uint64_t* aID) MOZ_OVERRIDE;
bool DeallocPCompositable(PCompositableChild* aActor) MOZ_OVERRIDE;
/**
@ -231,11 +231,12 @@ public:
virtual void Connect(CompositableClient* aCompositable) MOZ_OVERRIDE;
/**
* Communicate to the compositor that the texture identified by aLayer
* and aIdentifier has been updated to aImage.
* Communicate to the compositor that the texture identified by aCompositable
* and aTextureId has been updated to aDescriptor.
*/
virtual void UpdateTexture(TextureClient* aTexture,
const SurfaceDescriptor& aImage) MOZ_OVERRIDE;
virtual void UpdateTexture(CompositableClient* aCompositable,
TextureIdentifier aTextureId,
SurfaceDescriptor* aDescriptor) MOZ_OVERRIDE;
/**
* Communicate the picture rect of a YUV image in aLayer to the compositor
@ -247,12 +248,14 @@ public:
// at the moment we don't need to implement these. They are only used for
// thebes layers which don't support async updates.
virtual void CreatedSingleBuffer(CompositableClient* aCompositable,
TextureClient* aBuffer) MOZ_OVERRIDE {
const SurfaceDescriptor& aDescriptor,
const TextureInfo& aTextureInfo) MOZ_OVERRIDE {
NS_RUNTIMEABORT("should not be called");
}
virtual void CreatedDoubleBuffer(CompositableClient* aCompositable,
TextureClient* aFront,
TextureClient* aBack) MOZ_OVERRIDE {
const SurfaceDescriptor& aFrontDescriptor,
const SurfaceDescriptor& aBackDescriptor,
const TextureInfo& aTextureInfo) MOZ_OVERRIDE {
NS_RUNTIMEABORT("should not be called");
}
virtual void DestroyThebesBuffer(CompositableClient* aCompositable) MOZ_OVERRIDE {

Просмотреть файл

@ -48,8 +48,7 @@ ImageBridgeParent::RecvUpdate(const EditArray& aEdits, EditReplyArray* aReply)
{
EditReplyVector replyv;
for (EditArray::index_type i = 0; i < aEdits.Length(); ++i) {
ReceiveCompositableUpdate(aEdits[i],
replyv);
ReceiveCompositableUpdate(aEdits[i], replyv);
}
aReply->SetCapacity(replyv.size());
@ -140,12 +139,12 @@ ImageBridgeParent::DeallocPGrallocBuffer(PGrallocBufferParent* actor)
}
PCompositableParent*
ImageBridgeParent::AllocPCompositable(const CompositableType& aType,
ImageBridgeParent::AllocPCompositable(const TextureInfo& aInfo,
uint64_t* aID)
{
uint64_t id = GenImageContainerID();
*aID = id;
return new CompositableParent(this, aType, id);
return new CompositableParent(this, aInfo, id);
}
bool ImageBridgeParent::DeallocPCompositable(PCompositableParent* aActor)

Просмотреть файл

@ -45,7 +45,7 @@ public:
virtual bool RecvUpdate(const EditArray& aEdits, EditReplyArray* aReply);
virtual bool RecvUpdateNoSwap(const EditArray& aEdits);
PCompositableParent* AllocPCompositable(const CompositableType& aType,
PCompositableParent* AllocPCompositable(const TextureInfo& aInfo,
uint64_t*) MOZ_OVERRIDE;
bool DeallocPCompositable(PCompositableParent* aActor) MOZ_OVERRIDE;

Просмотреть файл

@ -11,7 +11,6 @@ include protocol PCompositor;
include protocol PGrallocBuffer;
include protocol PLayer;
include protocol PRenderFrame;
include protocol PTexture;
include "mozilla/WidgetUtils.h";
include "mozilla/TimeStamp.h";
@ -28,7 +27,7 @@ using mozilla::TimeStamp;
using mozilla::ScreenRotation;
using nsCSSProperty;
using mozilla::dom::ScreenOrientation;
using mozilla::layers::CompositableType;
using mozilla::layers::TextureInfo;
using mozilla::gfx::Margin;
namespace mozilla {
@ -242,17 +241,11 @@ struct OpPaintTiledLayerBuffer {
uintptr_t tiledLayerBuffer;
};
struct OpCreatedSingleBuffer {
struct OpCreatedTexture {
PCompositable compositable;
PTexture buffer;
uint32_t textureId;
SurfaceDescriptor descriptor;
};
struct OpCreatedDoubleBuffer {
PCompositable compositable;
PTexture front;
SurfaceDescriptor frontDescriptor;
PTexture back;
SurfaceDescriptor backDescriptor;
TextureInfo textureInfo;
};
struct OpDestroyThebesBuffer {
@ -260,7 +253,8 @@ struct OpDestroyThebesBuffer {
};
struct OpPaintTexture {
PTexture texture;
PCompositable compositable;
uint32_t textureId;
SurfaceDescriptor image;
};
@ -278,8 +272,7 @@ struct OpUpdatePictureRect {
union CompositableOperation {
OpUpdatePictureRect;
OpCreatedSingleBuffer;
OpCreatedDoubleBuffer;
OpCreatedTexture;
OpDestroyThebesBuffer;
OpPaintTexture;
@ -320,7 +313,8 @@ struct OpContentBufferSwap {
};
struct OpTextureSwap {
PTexture texture;
PCompositable compositable;
uint32_t textureId;
SurfaceDescriptor image;
};
@ -331,11 +325,5 @@ union EditReply {
OpTextureSwap;
};
struct OpTextureReply {
PTexture texture;
SurfaceDescriptor image;
};
} // namespace
} // namespace

Просмотреть файл

@ -7,21 +7,16 @@
include protocol PLayers;
include protocol PImageBridge;
include protocol PTexture;
include "mozilla/layers/CompositorTypes.h";
include protocol PCompositor;
using mozilla::layers::TextureInfo;
namespace mozilla {
namespace layers {
async protocol PCompositable
{
manager PImageBridge or PLayers;
manages PTexture;
parent:
async PTexture(TextureInfo info);
async __delete__();
};

Просмотреть файл

@ -7,12 +7,11 @@ include LayersSurfaces;
include LayerTransaction;
include protocol PGrallocBuffer;
include protocol PCompositable;
include protocol PTexture;
include "mozilla/layers/CompositorTypes.h";
using ImageHandle;
using mozilla::layers::CompositableType;
using mozilla::layers::TextureInfo;
namespace mozilla {
namespace layers {
@ -49,7 +48,7 @@ parent:
// before sending __delete__.
sync Stop();
sync PCompositable(CompositableType aType) returns (uint64_t id);
sync PCompositable(TextureInfo aInfo) returns (uint64_t id);
};

Просмотреть файл

@ -12,7 +12,6 @@ include protocol PCompositor;
include protocol PGrallocBuffer;
include protocol PLayer;
include protocol PRenderFrame;
include protocol PTexture;
include "mozilla/WidgetUtils.h";
include "mozilla/TimeStamp.h";
@ -20,6 +19,8 @@ include "mozilla/dom/ScreenOrientation.h";
include "nsCSSProperty.h";
include "gfxipc/ShadowLayerUtils.h";
using mozilla::layers::TextureInfo;
/**
* The layers protocol is spoken between thread contexts that manage
* layer (sub)trees. The protocol comprises atomically publishing
@ -46,7 +47,7 @@ parent:
sync PGrallocBuffer(gfxIntSize size, gfxContentType content)
returns (MaybeMagicGrallocBufferHandle handle);
async PLayer();
async PCompositable(CompositableType aType);
async PCompositable(TextureInfo aTextureInfo);
// The isFirstPaint flag can be used to indicate that this is the first update
// for a particular document.

Просмотреть файл

@ -1,27 +0,0 @@
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*-
* vim: sw=2 ts=8 et :
*/
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
include protocol PCompositable;
include LayersSurfaces;
namespace mozilla {
namespace layers {
/**
* PTexture should be removed in the short term.
* in the mean time it is used to match TextureClients and textureHosts.
*/
async protocol PTexture
{
manager PCompositable;
parent:
async __delete__();
};
}
}

Просмотреть файл

@ -16,7 +16,6 @@
#include "mozilla/layers/PLayerChild.h"
#include "mozilla/layers/PLayersChild.h"
#include "mozilla/layers/PLayersParent.h"
#include "mozilla/layers/TextureChild.h"
#include "mozilla/layers/LayerTransaction.h"
#include "mozilla/layers/LayersSurfaces.h"
#include "ShadowLayers.h"
@ -25,7 +24,6 @@
#include "RenderTrace.h"
#include "GeckoProfiler.h"
#include "nsXULAppAPI.h"
#include "mozilla/layers/TextureClient.h"
#include "mozilla/layers/ImageClient.h"
#include "mozilla/layers/CanvasClient.h"
#include "mozilla/layers/ContentClient.h"
@ -302,15 +300,22 @@ ShadowLayerForwarder::PaintedTiledLayerBuffer(ShadowableLayer* aLayer,
}
void
ShadowLayerForwarder::UpdateTexture(TextureClient* aTexture,
const SurfaceDescriptor& aImage)
ShadowLayerForwarder::UpdateTexture(CompositableClient* aCompositable,
TextureIdentifier aTextureId,
SurfaceDescriptor* aDescriptor)
{
MOZ_ASSERT(aImage.type() != SurfaceDescriptor::T__None);
MOZ_ASSERT(aImage.type() != SurfaceDescriptor::Tnull_t);
MOZ_ASSERT(aTexture);
MOZ_ASSERT(aTexture->GetIPDLActor());
mTxn->AddPaint(OpPaintTexture(nullptr, aTexture->GetIPDLActor(), aImage));
if (aDescriptor->type() != SurfaceDescriptor::T__None &&
aDescriptor->type() != SurfaceDescriptor::Tnull_t) {
MOZ_ASSERT(aCompositable);
MOZ_ASSERT(aCompositable->GetIPDLActor());
mTxn->AddPaint(OpPaintTexture(nullptr, aCompositable->GetIPDLActor(), 1,
SurfaceDescriptor(*aDescriptor)));
*aDescriptor = SurfaceDescriptor();
} else {
NS_WARNING("Trying to send a null SurfaceDescriptor.");
}
}
void
ShadowLayerForwarder::UpdateTextureRegion(CompositableClient* aCompositable,
const ThebesBufferData& aThebesBufferData,
@ -701,7 +706,7 @@ ShadowLayerForwarder::Connect(CompositableClient* aCompositable)
#endif
MOZ_ASSERT(aCompositable);
CompositableChild* child = static_cast<CompositableChild*>(
mShadowManager->SendPCompositableConstructor(aCompositable->GetType()));
mShadowManager->SendPCompositableConstructor(aCompositable->GetTextureInfo()));
MOZ_ASSERT(child);
aCompositable->SetIPDLActor(child);
child->SetClient(aCompositable);
@ -709,29 +714,35 @@ ShadowLayerForwarder::Connect(CompositableClient* aCompositable)
void
ShadowLayerForwarder::CreatedSingleBuffer(CompositableClient* aCompositable,
TextureClient* aBuffer)
const SurfaceDescriptor& aDescriptor,
const TextureInfo& aTextureInfo)
{
MOZ_ASSERT(aBuffer->LockSurfaceDescriptor()->type() != SurfaceDescriptor::T__None &&
aBuffer->LockSurfaceDescriptor()->type() != SurfaceDescriptor::Tnull_t);
mTxn->AddEdit(OpCreatedSingleBuffer(nullptr, aCompositable->GetIPDLActor(),
nullptr, aBuffer->GetIPDLActor(),
*aBuffer->LockSurfaceDescriptor()));
MOZ_ASSERT(aDescriptor.type() != SurfaceDescriptor::T__None &&
aDescriptor.type() != SurfaceDescriptor::Tnull_t);
mTxn->AddEdit(OpCreatedTexture(nullptr, aCompositable->GetIPDLActor(),
TextureFront,
aDescriptor,
aTextureInfo));
}
void
ShadowLayerForwarder::CreatedDoubleBuffer(CompositableClient* aCompositable,
TextureClient* aFront,
TextureClient* aBack)
const SurfaceDescriptor& aFrontDescriptor,
const SurfaceDescriptor& aBackDescriptor,
const TextureInfo& aTextureInfo)
{
MOZ_ASSERT(aFront->LockSurfaceDescriptor()->type() != SurfaceDescriptor::T__None &&
aBack->LockSurfaceDescriptor()->type() != SurfaceDescriptor::T__None &&
aFront->LockSurfaceDescriptor()->type() != SurfaceDescriptor::Tnull_t &&
aBack->LockSurfaceDescriptor()->type() != SurfaceDescriptor::Tnull_t);
mTxn->AddEdit(OpCreatedDoubleBuffer(nullptr, aCompositable->GetIPDLActor(),
nullptr, aFront->GetIPDLActor(),
*aFront->LockSurfaceDescriptor(),
nullptr, aBack->GetIPDLActor(),
*aBack->LockSurfaceDescriptor()));
MOZ_ASSERT(aFrontDescriptor.type() != SurfaceDescriptor::T__None &&
aBackDescriptor.type() != SurfaceDescriptor::T__None &&
aFrontDescriptor.type() != SurfaceDescriptor::Tnull_t &&
aBackDescriptor.type() != SurfaceDescriptor::Tnull_t);
mTxn->AddEdit(OpCreatedTexture(nullptr, aCompositable->GetIPDLActor(),
TextureFront,
aFrontDescriptor,
aTextureInfo));
mTxn->AddEdit(OpCreatedTexture(nullptr, aCompositable->GetIPDLActor(),
TextureBack,
aBackDescriptor,
aTextureInfo));
}
void

Просмотреть файл

@ -155,10 +155,12 @@ public:
void Connect(CompositableClient* aCompositable);
virtual void CreatedSingleBuffer(CompositableClient* aCompositable,
TextureClient* aBuffer) MOZ_OVERRIDE;
const SurfaceDescriptor& aDescriptor,
const TextureInfo& aTextureInfo) MOZ_OVERRIDE;
virtual void CreatedDoubleBuffer(CompositableClient* aCompositable,
TextureClient* aFront,
TextureClient* aBack) MOZ_OVERRIDE;
const SurfaceDescriptor& aFrontDescriptor,
const SurfaceDescriptor& aBackDescriptor,
const TextureInfo& aTextureInfo) MOZ_OVERRIDE;
virtual void DestroyThebesBuffer(CompositableClient* aCompositable) MOZ_OVERRIDE;
/**
@ -270,8 +272,9 @@ public:
* Communicate to the compositor that the texture identified by aLayer
* and aIdentifier has been updated to aImage.
*/
void UpdateTexture(TextureClient* aTexture,
const SurfaceDescriptor& aImage);
virtual void UpdateTexture(CompositableClient* aCompositable,
TextureIdentifier aTextureId,
SurfaceDescriptor* aDescriptor) MOZ_OVERRIDE;
/**
* Communicate to the compositor that aRegion in the texture identified by aLayer

Просмотреть файл

@ -63,7 +63,7 @@ ShadowLayersChild::DeallocPLayer(PLayerChild* actor)
}
PCompositableChild*
ShadowLayersChild::AllocPCompositable(const CompositableType& aType)
ShadowLayersChild::AllocPCompositable(const TextureInfo& aInfo)
{
return new CompositableChild();
}

Просмотреть файл

@ -38,7 +38,7 @@ protected:
virtual PLayerChild* AllocPLayer() MOZ_OVERRIDE;
virtual bool DeallocPLayer(PLayerChild* actor) MOZ_OVERRIDE;
virtual PCompositableChild* AllocPCompositable(const CompositableType& aType) MOZ_OVERRIDE;
virtual PCompositableChild* AllocPCompositable(const TextureInfo& aInfo) MOZ_OVERRIDE;
virtual bool DeallocPCompositable(PCompositableChild* actor) MOZ_OVERRIDE;
};

Просмотреть файл

@ -20,7 +20,6 @@
#include "ShadowLayerUtils.h"
#include "TiledLayerBuffer.h"
#include "gfxPlatform.h"
#include "mozilla/layers/TextureParent.h"
#include "CompositableHost.h"
typedef std::vector<mozilla::layers::EditReply> EditReplyVector;
@ -46,13 +45,6 @@ cast(const PCompositableParent* in)
static_cast<const CompositableParent*>(in));
}
template<class OpPaintT>
static TextureHost*
AsTextureHost(const OpPaintT& op)
{
return static_cast<TextureParent*>(op.textureParent())->GetTextureHost();
}
template<class OpCreateT>
static ShadowLayerParent*
AsShadowLayer(const OpCreateT& op)
@ -510,9 +502,9 @@ ShadowLayersParent::DeallocPLayer(PLayerParent* actor)
}
PCompositableParent*
ShadowLayersParent::AllocPCompositable(const CompositableType& aType)
ShadowLayersParent::AllocPCompositable(const TextureInfo& aInfo)
{
return new CompositableParent(this, aType);
return new CompositableParent(this, aInfo);
}
bool

Просмотреть файл

@ -86,7 +86,7 @@ protected:
virtual PLayerParent* AllocPLayer() MOZ_OVERRIDE;
virtual bool DeallocPLayer(PLayerParent* actor) MOZ_OVERRIDE;
virtual PCompositableParent* AllocPCompositable(const CompositableType& aType) MOZ_OVERRIDE;
virtual PCompositableParent* AllocPCompositable(const TextureInfo& aInfo) MOZ_OVERRIDE;
virtual bool DeallocPCompositable(PCompositableParent* actor) MOZ_OVERRIDE;
void Attach(ShadowLayerParent* aLayerParent, CompositableParent* aCompositable);

Просмотреть файл

@ -1,29 +0,0 @@
/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 2 -*-
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "mozilla/layers/TextureChild.h"
#include "mozilla/layers/TextureClient.h"
namespace mozilla {
namespace layers {
CompositableClient*
TextureChild::GetCompositableClient()
{
return static_cast<CompositableChild*>(Manager())->GetCompositableClient();
}
void
TextureChild::Destroy()
{
if (mTextureClient) {
mTextureClient->SetIPDLActor(nullptr);
mTextureClient = nullptr;
}
Send__delete__(this);
}
} // namespace
} // namespace

Просмотреть файл

@ -1,50 +0,0 @@
/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 2 -*-
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef MOZILLA_LAYERS_TEXTURECHILD_H
#define MOZILLA_LAYERS_TEXTURECHILD_H
#include "mozilla/layers/PTextureChild.h"
#include "CompositableClient.h"
namespace mozilla {
namespace layers {
class TextureClient;
class TextureChild : public PTextureChild
{
public:
TextureChild()
: mTextureClient(nullptr)
{
MOZ_COUNT_CTOR(TextureClient);
}
~TextureChild()
{
MOZ_COUNT_DTOR(TextureClient);
}
void SetClient(TextureClient* aTextureClient)
{
mTextureClient = aTextureClient;
}
CompositableClient* GetCompositableClient();
TextureClient* GetTextureClient() const
{
return mTextureClient;
}
void Destroy();
private:
TextureClient* mTextureClient;
};
} // namespace
} // namespace
#endif

Просмотреть файл

@ -1,94 +0,0 @@
/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 2 -*-
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "mozilla/layers/TextureParent.h"
#include "mozilla/layers/Compositor.h"
#include "CompositableHost.h"
#include "ShadowLayerParent.h"
#include "LayerManagerComposite.h"
#include "Compositor.h"
#include "mozilla/layers/CompositableTransactionParent.h"
namespace mozilla {
namespace layers {
TextureParent::TextureParent(const TextureInfo& aInfo,
CompositableParent* aCompositable)
: mTextureInfo(aInfo)
, mLastSurfaceType(SurfaceDescriptor::Tnull_t)
{
MOZ_COUNT_CTOR(TextureParent);
}
TextureParent::~TextureParent()
{
MOZ_COUNT_DTOR(TextureParent);
}
bool
TextureParent::EnsureTextureHost(SurfaceDescriptor::Type aSurfaceType)
{
if (!SurfaceTypeChanged(aSurfaceType)) {
return false;
}
MOZ_ASSERT(!mTextureHost || mTextureHost->GetIPDLActor() == this);
CompositableParent* compParent = static_cast<CompositableParent*>(Manager());
CompositableHost* compositable = compParent->GetCompositableHost();
mTextureHost = TextureHost::CreateTextureHost(aSurfaceType,
mTextureInfo.mTextureHostFlags,
mTextureInfo.mTextureFlags);
mTextureHost->SetTextureParent(this);
compositable->AddTextureHost(mTextureHost,
compParent->GetCompositableManager());
mLastSurfaceType = aSurfaceType;
Compositor* compositor = compositable->GetCompositor();
if (compositor) {
mTextureHost->SetCompositor(compositor);
}
return true;
}
void TextureParent::SetTextureHost(TextureHost* aHost)
{
MOZ_ASSERT(!mTextureHost || mTextureHost == aHost);
mTextureHost = aHost;
}
CompositableHost* TextureParent::GetCompositableHost() const
{
CompositableParent* actor = static_cast<CompositableParent*>(Manager());
return actor->GetCompositableHost();
}
uint64_t
TextureParent::GetCompositorID()
{
return static_cast<CompositableParent*>(Manager())->GetCompositorID();
}
TextureHost* TextureParent::GetTextureHost() const
{
return mTextureHost;
}
bool TextureParent::SurfaceTypeChanged(SurfaceDescriptor::Type aNewSurfaceType)
{
return mLastSurfaceType != aNewSurfaceType;
}
void TextureParent::SetCurrentSurfaceType(SurfaceDescriptor::Type aNewSurfaceType)
{
mLastSurfaceType = aNewSurfaceType;
}
} // namespace
} // namespace

Просмотреть файл

@ -1,55 +0,0 @@
/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 2 -*-
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef MOZILLA_LAYERS_TEXTUREPARENT_H
#define MOZILLA_LAYERS_TEXTUREPARENT_H
#include "mozilla/layers/PTextureParent.h"
#include "mozilla/layers/CompositorTypes.h"
#include "CompositableHost.h"
namespace mozilla {
namespace layers {
class TextureHost;
class CompositableHost;
class TextureInfo;
class TextureParent : public PTextureParent
{
public:
TextureParent(const TextureInfo& aInfo, CompositableParent* aCompositable);
virtual ~TextureParent();
void SetTextureHost(TextureHost* aHost);
TextureHost* GetTextureHost() const;
CompositableHost* GetCompositableHost() const;
const TextureInfo& GetTextureInfo() const
{
return mTextureInfo;
}
bool SurfaceTypeChanged(SurfaceDescriptor::Type aNewSurfaceType);
void SetCurrentSurfaceType(SurfaceDescriptor::Type aNewSurfaceType);
SurfaceDescriptor::Type GetSurfaceType() const
{
return mLastSurfaceType;
}
uint64_t GetCompositorID();
bool EnsureTextureHost(SurfaceDescriptor::Type aSurfaceType);
private:
TextureInfo mTextureInfo;
RefPtr<TextureHost> mTextureHost;
SurfaceDescriptor::Type mLastSurfaceType;
};
} // namespace
} // namespace
#endif

Просмотреть файл

@ -11,5 +11,4 @@ IPDLSRCS = \
PImageBridge.ipdl \
PLayer.ipdl \
PLayers.ipdl \
PTexture.ipdl \
$(NULL)

Просмотреть файл

@ -640,13 +640,6 @@ CompositorOGL::SetLayerProgramProjectionMatrix(const gfx3DMatrix& aMatrix)
}
}
void
CompositorOGL::FallbackTextureInfo(TextureInfo& aId)
{
// Try again without direct texturing enabled
aId.mTextureHostFlags &= ~TEXTURE_HOST_DIRECT;
}
TemporaryRef<CompositingRenderTarget>
CompositorOGL::CreateRenderTarget(const IntRect &aRect, SurfaceInitMode aInit)
{

Просмотреть файл

@ -39,8 +39,6 @@ public:
return TextureFactoryIdentifier(LAYERS_OPENGL, GetMaxTextureSize());
}
virtual void FallbackTextureInfo(TextureInfo& aId) MOZ_OVERRIDE;
virtual TemporaryRef<CompositingRenderTarget>
CreateRenderTarget(const gfx::IntRect &aRect, SurfaceInitMode aInit) MOZ_OVERRIDE;

Просмотреть файл

@ -12,8 +12,8 @@ namespace mozilla {
namespace layers {
TextureClientSharedOGL::TextureClientSharedOGL(CompositableForwarder* aForwarder,
CompositableType aCompositableType)
: TextureClient(aForwarder, aCompositableType)
const TextureInfo& aTextureInfo)
: TextureClient(aForwarder, aTextureInfo)
, mGL(nullptr)
{
}

Просмотреть файл

@ -15,7 +15,7 @@ namespace layers {
class TextureClientSharedOGL : public TextureClient
{
public:
TextureClientSharedOGL(CompositableForwarder* aForwarder, CompositableType aCompositableType);
TextureClientSharedOGL(CompositableForwarder* aForwarder, const TextureInfo& aTextureInfo);
~TextureClientSharedOGL() { ReleaseResources(); }
virtual bool SupportsType(TextureClientType aType) MOZ_OVERRIDE { return aType == TEXTURE_SHARED_GL; }
@ -34,8 +34,8 @@ protected:
class TextureClientSharedOGLExternal : public TextureClientSharedOGL
{
public:
TextureClientSharedOGLExternal(CompositableForwarder* aForwarder, CompositableType aCompositableType)
: TextureClientSharedOGL(aForwarder, aCompositableType)
TextureClientSharedOGLExternal(CompositableForwarder* aForwarder, const TextureInfo& aTextureInfo)
: TextureClientSharedOGL(aForwarder, aTextureInfo)
{}
virtual bool SupportsType(TextureClientType aType) MOZ_OVERRIDE { return aType == TEXTURE_SHARED_GL_EXTERNAL; }
@ -45,8 +45,8 @@ public:
class TextureClientStreamOGL : public TextureClient
{
public:
TextureClientStreamOGL(CompositableForwarder* aForwarder, CompositableType aCompositableType)
: TextureClient(aForwarder, aCompositableType)
TextureClientStreamOGL(CompositableForwarder* aForwarder, const TextureInfo& aTextureInfo)
: TextureClient(aForwarder, aTextureInfo)
{}
~TextureClientStreamOGL() { ReleaseResources(); }

Просмотреть файл

@ -157,7 +157,7 @@ TextureImageTextureHostOGL::UpdateImpl(const SurfaceDescriptor& aImage,
nsIntRegion* aRegion)
{
if (!mGL) {
NS_WARNING("trying to update TextureImageTextureHostOGL without a compositor ?");
NS_WARNING("trying to update TextureImageTextureHostOGL without a compositor?");
return;
}
AutoOpenSurface surf(OPEN_READ_ONLY, aImage);

Просмотреть файл

@ -15,6 +15,7 @@
#ifdef MOZ_B2G_BT
#include <bluetooth/bluetooth.h>
#include <bluetooth/sco.h>
#include <bluetooth/l2cap.h>
#include <bluetooth/rfcomm.h>
#endif
#include <stdlib.h>
@ -33,6 +34,7 @@ union sockaddr_any {
#ifdef MOZ_B2G_BT
sockaddr_sco sco;
sockaddr_rc rc;
sockaddr_l2 l2;
#endif
// ... others
};

Просмотреть файл

@ -49,7 +49,7 @@
* dangerous-looking actions cannot trigger a GC: js_malloc, cx->malloc_,
* rt->malloc_, and friends and JS_ReportOutOfMemory.
*
* The following family of four classes will exactly root a stack location.
* The following family of three classes will exactly root a stack location.
* Incorrect usage of these classes will result in a compile error in almost
* all cases. Therefore, it is very hard to be incorrectly rooted if you use
* these classes exclusively. These classes are all templated on the type T of
@ -58,7 +58,7 @@
* - Rooted<T> declares a variable of type T, whose value is always rooted.
* Rooted<T> may be automatically coerced to a Handle<T>, below. Rooted<T>
* should be used whenever a local variable's value may be held live across a
* call which can trigger a GC. This is generally true of
* call which can trigger a GC.
*
* - Handle<T> is a const reference to a Rooted<T>. Functions which take GC
* things or values as arguments and need to root those arguments should
@ -90,16 +90,16 @@
* The following diagram explains the list of supported, implicit type
* conversions between classes of this family:
*
* RawT -----> Rooted<T> ----> Handle<T>
* Rooted<T> ----> Handle<T>
* | ^
* | |
* | |
* +---> MutableHandle<T>
* (via &)
*
* Currently all of these types implicit conversion to RawT. These are present
* only for the purpose of bootstrapping exact rooting and will be removed in
* the future (Bug 817164).
* Currently, all of these types have an implicit conversion to RawT. These are
* present only for the purpose of bootstrapping exact rooting and will be
* removed in the future (Bug 817164).
*/
namespace js {

Просмотреть файл

@ -202,6 +202,11 @@ if test "$CPU_ARCH" = "arm"; then
HAVE_ARM_SIMD=1
fi
AC_MSG_CHECKING(ARM version support in compiler)
dnl Determine the target ARM architecture (5 for ARMv5, v5T, v5E, etc.; 6 for ARMv6, v6K, etc.)
ARM_ARCH=`${CC-cc} ${CFLAGS} -dM -E - < /dev/null | sed -n 's/.*__ARM_ARCH_\([[0-9]]*\).*/\1/p'`
AC_MSG_RESULT("$ARM_ARCH")
AC_MSG_CHECKING(for ARM NEON support in compiler)
# We try to link so that this also fails when
# building with LTO.
@ -212,16 +217,23 @@ if test "$CPU_ARCH" = "arm"; then
if test "$result" = "yes"; then
AC_DEFINE(HAVE_ARM_NEON)
HAVE_ARM_NEON=1
dnl We don't need to build NEON support if we're targetting a non-NEON device.
dnl This matches media/webrtc/trunk/webrtc/build/common.gypi.
if test -n "$ARM_ARCH"; then
if test "$ARM_ARCH" -lt 7; then
BUILD_ARM_NEON=0
else
BUILD_ARM_NEON=1
fi
fi
fi
AC_MSG_CHECKING(ARM version support in compiler)
dnl Determine the target ARM architecture (5 for ARMv5, v5T, v5E, etc.; 6 for ARMv6, v6K, etc.)
ARM_ARCH=`${CC-cc} ${CFLAGS} -dM -E - < /dev/null | sed -n 's/.*__ARM_ARCH_\([[0-9]]*\).*/\1/p'`
AC_MSG_RESULT("$ARM_ARCH")
fi # CPU_ARCH = arm
AC_SUBST(HAVE_ARM_SIMD)
AC_SUBST(HAVE_ARM_NEON)
AC_SUBST(BUILD_ARM_NEON)
if test -n "$MOZ_ARCH"; then
NSPR_CONFIGURE_ARGS="$NSPR_CONFIGURE_ARGS --with-arch=$MOZ_ARCH"

Некоторые файлы не были показаны из-за слишком большого количества измененных файлов Показать больше