Merge m-i to m-c.

This commit is contained in:
Kyle Huey 2011-07-09 20:19:36 -07:00
commit acd2f08755
61 changed files with 5004 additions and 2627 deletions

View File

@ -122,6 +122,11 @@ public:
CanvasLayer *aOldLayer,
LayerManager *aManager) = 0;
// Return true if the canvas should be forced to be "inactive" to ensure
// it can be drawn to the screen even if it's too large to be blitted by
// an accelerated CanvasLayer.
virtual PRBool ShouldForceInactiveLayer(LayerManager *aManager) { return PR_FALSE; }
virtual void MarkContextClean() = 0;
// Redraw the dirty rectangle of this canvas.

View File

@ -349,10 +349,11 @@ public:
NS_IMETHOD SetIsOpaque(PRBool isOpaque);
NS_IMETHOD Reset();
already_AddRefed<CanvasLayer> GetCanvasLayer(nsDisplayListBuilder* aBuilder,
CanvasLayer *aOldLayer,
LayerManager *aManager);
void MarkContextClean();
virtual already_AddRefed<CanvasLayer> GetCanvasLayer(nsDisplayListBuilder* aBuilder,
CanvasLayer *aOldLayer,
LayerManager *aManager);
virtual PRBool ShouldForceInactiveLayer(LayerManager *aManager);
virtual void MarkContextClean();
NS_IMETHOD SetIsIPC(PRBool isIPC);
// this rect is in canvas device space
NS_IMETHOD Redraw(const gfxRect &r);
@ -1071,9 +1072,7 @@ nsCanvasRenderingContext2D::SetDimensions(PRInt32 width, PRInt32 height)
gfxASurface::gfxImageFormat format = GetImageFormat();
if (PR_GetEnv("MOZ_CANVAS_IMAGE_SURFACE")) {
surface = new gfxImageSurface(gfxIntSize(width, height), format);
} else {
if (!PR_GetEnv("MOZ_CANVAS_IMAGE_SURFACE")) {
nsCOMPtr<nsIContent> content =
do_QueryInterface(static_cast<nsIDOMHTMLCanvasElement*>(mCanvasElement));
nsIDocument* ownerDoc = nsnull;
@ -1093,8 +1092,15 @@ nsCanvasRenderingContext2D::SetDimensions(PRInt32 width, PRInt32 height)
}
}
if (surface && surface->CairoStatus() != 0)
surface = NULL;
if (!surface || surface->CairoStatus()) {
// If we couldn't create a surface of the type we want, fall back
// to an image surface. This lets us handle surface sizes that
// the underlying cairo backend might not handle.
surface = new gfxImageSurface(gfxIntSize(width, height), format);
if (!surface || surface->CairoStatus()) {
surface = nsnull;
}
}
}
if (surface) {
if (gCanvasMemoryReporter == nsnull) {
@ -4017,6 +4023,12 @@ nsCanvasRenderingContext2D::GetCanvasLayer(nsDisplayListBuilder* aBuilder,
return canvasLayer.forget();
}
PRBool
nsCanvasRenderingContext2D::ShouldForceInactiveLayer(LayerManager *aManager)
{
return !aManager->CanUseCanvasLayerForSize(gfxIntSize(mWidth, mHeight));
}
void
nsCanvasRenderingContext2D::MarkContextClean()
{

View File

@ -194,79 +194,6 @@ public:
NS_DECL_ISUPPORTS
protected:
nsCanvasGradientAzure(Type aType) : mType(aType)
{}
nsTArray<GradientStop> mRawStops;
RefPtr<GradientStops> mStops;
Type mType;
};
class nsCanvasRadialGradientAzure : public nsCanvasGradientAzure
{
public:
nsCanvasRadialGradientAzure(const Point &aBeginOrigin, Float aBeginRadius,
const Point &aEndOrigin, Float aEndRadius)
: nsCanvasGradientAzure(RADIAL)
, mCenter(aEndOrigin)
, mRadius(aEndRadius)
{
mOffsetStart = aBeginRadius / mRadius;
mOffsetRatio = 1 - mOffsetStart;
mOrigin = ((mCenter * aBeginRadius) - (aBeginOrigin * mRadius)) /
(aBeginRadius - mRadius);
}
/* nsIDOMCanvasGradient */
NS_IMETHOD AddColorStop (float offset,
const nsAString& colorstr)
{
if (!FloatValidate(offset) || offset < 0.0 || offset > 1.0) {
return NS_ERROR_DOM_INDEX_SIZE_ERR;
}
nscolor color;
nsCSSParser parser;
nsresult rv = parser.ParseColorString(nsString(colorstr),
nsnull, 0, &color);
if (NS_FAILED(rv)) {
return NS_ERROR_DOM_SYNTAX_ERR;
}
mStops = nsnull;
GradientStop newStop;
newStop.offset = offset * mOffsetRatio + mOffsetStart;
newStop.color = Color::FromABGR(color);
mRawStops.AppendElement(newStop);
return NS_OK;
}
// XXX - Temporary gradient code, this will be fixed soon as per bug 666097
Point mCenter;
Float mRadius;
Point mOrigin;
Float mOffsetStart;
Float mOffsetRatio;
};
class nsCanvasLinearGradientAzure : public nsCanvasGradientAzure
{
public:
nsCanvasLinearGradientAzure(const Point &aBegin, const Point &aEnd)
: nsCanvasGradientAzure(LINEAR)
, mBegin(aBegin)
, mEnd(aEnd)
{
}
/* nsIDOMCanvasGradient */
NS_IMETHOD AddColorStop (float offset,
const nsAString& colorstr)
@ -295,6 +222,44 @@ public:
return NS_OK;
}
protected:
nsCanvasGradientAzure(Type aType) : mType(aType)
{}
nsTArray<GradientStop> mRawStops;
RefPtr<GradientStops> mStops;
Type mType;
};
class nsCanvasRadialGradientAzure : public nsCanvasGradientAzure
{
public:
nsCanvasRadialGradientAzure(const Point &aBeginOrigin, Float aBeginRadius,
const Point &aEndOrigin, Float aEndRadius)
: nsCanvasGradientAzure(RADIAL)
, mCenter1(aBeginOrigin)
, mCenter2(aEndOrigin)
, mRadius1(aBeginRadius)
, mRadius2(aEndRadius)
{
}
Point mCenter1;
Point mCenter2;
Float mRadius1;
Float mRadius2;
};
class nsCanvasLinearGradientAzure : public nsCanvasGradientAzure
{
public:
nsCanvasLinearGradientAzure(const Point &aBegin, const Point &aEnd)
: nsCanvasGradientAzure(LINEAR)
, mBegin(aBegin)
, mEnd(aEnd)
{
}
protected:
friend class nsCanvasRenderingContext2DAzure;
@ -827,8 +792,8 @@ protected:
static_cast<nsCanvasRadialGradientAzure*>(state.gradientStyles[aStyle].get());
mPattern = new (mRadialGradientPattern.addr())
RadialGradientPattern(gradient->mCenter, gradient->mOrigin, gradient->mRadius,
gradient->GetGradientStopsForTarget(aRT));
RadialGradientPattern(gradient->mCenter1, gradient->mCenter2, gradient->mRadius1,
gradient->mRadius2, gradient->GetGradientStopsForTarget(aRT));
} else if (state.patternStyles[aStyle]) {
if (aCtx->mCanvasElement) {
CanvasUtils::DoDrawImageSecurityCheck(aCtx->HTMLCanvasElement(),

View File

@ -6,17 +6,6 @@
<body>
<canvas id="c" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<script>
function IsAzureEnabled() {
var enabled = false;
try {
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
enabled = Components.classes["@mozilla.org/gfx/info;1"].getService(Components.interfaces.nsIGfxInfo).AzureEnabled;
} catch (e) { }
return enabled;
}
function isPixel(ctx, x,y, r,g,b,a, pos, colour, d) {
var pixel = ctx.getImageData(x, y, 1, 1);
@ -59,28 +48,15 @@ g.addColorStop(1, '#0f0');
ctx.fillStyle = g;
ctx.fillRect(0, 0, 100, 50);
if (IsAzureEnabled()) {
// XXX - See Bug 666097.
todo_isPixel(ctx, 1,1, 0,255,0,255, "1,1", "0,255,0,255", 0);
todo_isPixel(ctx, 50,1, 0,255,0,255, "50,1", "0,255,0,255", 0);
todo_isPixel(ctx, 98,1, 0,255,0,255, "98,1", "0,255,0,255", 0);
todo_isPixel(ctx, 1,25, 0,255,0,255, "1,25", "0,255,0,255", 0);
todo_isPixel(ctx, 50,25, 0,255,0,255, "50,25", "0,255,0,255", 0);
todo_isPixel(ctx, 98,25, 0,255,0,255, "98,25", "0,255,0,255", 0);
todo_isPixel(ctx, 1,48, 0,255,0,255, "1,48", "0,255,0,255", 0);
todo_isPixel(ctx, 50,48, 0,255,0,255, "50,48", "0,255,0,255", 0);
todo_isPixel(ctx, 98,48, 0,255,0,255, "98,48", "0,255,0,255", 0);
} else {
isPixel(ctx, 1,1, 0,255,0,255, "1,1", "0,255,0,255", 0);
isPixel(ctx, 50,1, 0,255,0,255, "50,1", "0,255,0,255", 0);
isPixel(ctx, 98,1, 0,255,0,255, "98,1", "0,255,0,255", 0);
isPixel(ctx, 1,25, 0,255,0,255, "1,25", "0,255,0,255", 0);
isPixel(ctx, 50,25, 0,255,0,255, "50,25", "0,255,0,255", 0);
isPixel(ctx, 98,25, 0,255,0,255, "98,25", "0,255,0,255", 0);
isPixel(ctx, 1,48, 0,255,0,255, "1,48", "0,255,0,255", 0);
isPixel(ctx, 50,48, 0,255,0,255, "50,48", "0,255,0,255", 0);
isPixel(ctx, 98,48, 0,255,0,255, "98,48", "0,255,0,255", 0);
}
isPixel(ctx, 1,1, 0,255,0,255, "1,1", "0,255,0,255", 0);
isPixel(ctx, 50,1, 0,255,0,255, "50,1", "0,255,0,255", 0);
isPixel(ctx, 98,1, 0,255,0,255, "98,1", "0,255,0,255", 0);
isPixel(ctx, 1,25, 0,255,0,255, "1,25", "0,255,0,255", 0);
isPixel(ctx, 50,25, 0,255,0,255, "50,25", "0,255,0,255", 0);
isPixel(ctx, 98,25, 0,255,0,255, "98,25", "0,255,0,255", 0);
isPixel(ctx, 1,48, 0,255,0,255, "1,48", "0,255,0,255", 0);
isPixel(ctx, 50,48, 0,255,0,255, "50,48", "0,255,0,255", 0);
isPixel(ctx, 98,48, 0,255,0,255, "98,48", "0,255,0,255", 0);
SimpleTest.finish();

View File

@ -6399,28 +6399,15 @@ g.addColorStop(1, '#f00');
ctx.fillStyle = g;
ctx.fillRect(0, 0, 100, 50);
if (IsAzureEnabled()) {
// XXX - See Bug 666097.
todo_isPixel(ctx, 1, 1, 0, 255, 0, 255, 0);
todo_isPixel(ctx, 50, 1, 0, 255, 0, 255, 0);
todo_isPixel(ctx, 98, 1, 0, 255, 0, 255, 0);
todo_isPixel(ctx, 1, 25, 0, 255, 0, 255, 0);
todo_isPixel(ctx, 50, 25, 0, 255, 0, 255, 0);
todo_isPixel(ctx, 98, 25, 0, 255, 0, 255, 0);
todo_isPixel(ctx, 1, 48, 0, 255, 0, 255, 0);
todo_isPixel(ctx, 50, 48, 0, 255, 0, 255, 0);
todo_isPixel(ctx, 98, 48, 0, 255, 0, 255, 0);
} else {
isPixel(ctx, 1, 1, 0, 255, 0, 255, 0);
isPixel(ctx, 50, 1, 0, 255, 0, 255, 0);
isPixel(ctx, 98, 1, 0, 255, 0, 255, 0);
isPixel(ctx, 1, 25, 0, 255, 0, 255, 0);
isPixel(ctx, 50, 25, 0, 255, 0, 255, 0);
isPixel(ctx, 98, 25, 0, 255, 0, 255, 0);
isPixel(ctx, 1, 48, 0, 255, 0, 255, 0);
isPixel(ctx, 50, 48, 0, 255, 0, 255, 0);
isPixel(ctx, 98, 48, 0, 255, 0, 255, 0);
}
isPixel(ctx, 1, 1, 0, 255, 0, 255, 0);
isPixel(ctx, 50, 1, 0, 255, 0, 255, 0);
isPixel(ctx, 98, 1, 0, 255, 0, 255, 0);
isPixel(ctx, 1, 25, 0, 255, 0, 255, 0);
isPixel(ctx, 50, 25, 0, 255, 0, 255, 0);
isPixel(ctx, 98, 25, 0, 255, 0, 255, 0);
isPixel(ctx, 1, 48, 0, 255, 0, 255, 0);
isPixel(ctx, 50, 48, 0, 255, 0, 255, 0);
isPixel(ctx, 98, 48, 0, 255, 0, 255, 0);
}
</script>
@ -6570,29 +6557,15 @@ g.addColorStop(1, '#0f0');
ctx.fillStyle = g;
ctx.fillRect(0, 0, 100, 50);
if (IsAzureEnabled()) {
// XXX - See Bug 666097.
todo_isPixel(ctx, 1, 1, 0, 255, 0, 255, 0);
todo_isPixel(ctx, 50, 1, 0, 255, 0, 255, 0);
todo_isPixel(ctx, 98, 1, 0, 255, 0, 255, 0);
todo_isPixel(ctx, 1, 25, 0, 255, 0, 255, 0);
todo_isPixel(ctx, 50, 25, 0, 255, 0, 255, 0);
todo_isPixel(ctx, 98, 25, 0, 255, 0, 255, 0);
todo_isPixel(ctx, 1, 48, 0, 255, 0, 255, 0);
todo_isPixel(ctx, 50, 48, 0, 255, 0, 255, 0);
todo_isPixel(ctx, 98, 48, 0, 255, 0, 255, 0);
} else {
isPixel(ctx, 1, 1, 0, 255, 0, 255, 0);
isPixel(ctx, 50, 1, 0, 255, 0, 255, 0);
isPixel(ctx, 98, 1, 0, 255, 0, 255, 0);
isPixel(ctx, 1, 25, 0, 255, 0, 255, 0);
isPixel(ctx, 50, 25, 0, 255, 0, 255, 0);
isPixel(ctx, 98, 25, 0, 255, 0, 255, 0);
isPixel(ctx, 1, 48, 0, 255, 0, 255, 0);
isPixel(ctx, 50, 48, 0, 255, 0, 255, 0);
isPixel(ctx, 98, 48, 0, 255, 0, 255, 0);
}
isPixel(ctx, 1, 1, 0, 255, 0, 255, 0);
isPixel(ctx, 50, 1, 0, 255, 0, 255, 0);
isPixel(ctx, 98, 1, 0, 255, 0, 255, 0);
isPixel(ctx, 1, 25, 0, 255, 0, 255, 0);
isPixel(ctx, 50, 25, 0, 255, 0, 255, 0);
isPixel(ctx, 98, 25, 0, 255, 0, 255, 0);
isPixel(ctx, 1, 48, 0, 255, 0, 255, 0);
isPixel(ctx, 50, 48, 0, 255, 0, 255, 0);
isPixel(ctx, 98, 48, 0, 255, 0, 255, 0);
}
</script>

View File

@ -170,6 +170,10 @@ public:
already_AddRefed<CanvasLayer> GetCanvasLayer(nsDisplayListBuilder* aBuilder,
CanvasLayer *aOldLayer,
LayerManager *aManager);
// Should return true if the canvas layer should always be marked inactive.
// We should return true here if we can't do accelerated compositing with
// a non-BasicCanvasLayer.
PRBool ShouldForceInactiveLayer(LayerManager *aManager);
// Call this whenever we need future changes to the canvas
// to trigger fresh invalidation requests. This needs to be called
@ -193,6 +197,7 @@ protected:
const nsAString& aType,
nsIDOMFile** aResult);
nsresult GetContextHelper(const nsAString& aContextId,
PRBool aForceThebes,
nsICanvasRenderingContextInternal **aContext);
nsString mCurrentContextId;

View File

@ -380,11 +380,12 @@ nsHTMLCanvasElement::MozGetAsFileImpl(const nsAString& aName,
nsresult
nsHTMLCanvasElement::GetContextHelper(const nsAString& aContextId,
PRBool aForceThebes,
nsICanvasRenderingContextInternal **aContext)
{
NS_ENSURE_ARG(aContext);
NS_LossyConvertUTF16toASCII ctxId(aContextId);
NS_ConvertUTF16toUTF8 ctxId(aContextId);
// check that ctxId is clamped to A-Za-z0-9_-
for (PRUint32 i = 0; i < ctxId.Length(); i++) {
@ -402,6 +403,10 @@ nsHTMLCanvasElement::GetContextHelper(const nsAString& aContextId,
nsCString ctxString("@mozilla.org/content/canvas-rendering-context;1?id=");
ctxString.Append(ctxId);
if (aForceThebes && ctxId.EqualsASCII("2d")) {
ctxString.AssignASCII("@mozilla.org/content/2dthebes-canvas-rendering-context;1");
}
nsresult rv;
nsCOMPtr<nsICanvasRenderingContextInternal> ctx =
do_CreateInstance(ctxString.get(), &rv);
@ -433,8 +438,10 @@ nsHTMLCanvasElement::GetContext(const nsAString& aContextId,
{
nsresult rv;
if (mCurrentContextId.IsEmpty()) {
rv = GetContextHelper(aContextId, getter_AddRefs(mCurrentContext));
PRBool forceThebes = PR_FALSE;
while (mCurrentContextId.IsEmpty()) {
rv = GetContextHelper(aContextId, forceThebes, getter_AddRefs(mCurrentContext));
NS_ENSURE_SUCCESS(rv, rv);
if (!mCurrentContext) {
return NS_OK;
@ -506,11 +513,18 @@ nsHTMLCanvasElement::GetContext(const nsAString& aContextId,
rv = UpdateContext(contextProps);
if (NS_FAILED(rv)) {
mCurrentContext = nsnull;
if (!forceThebes) {
// Try again with a Thebes context
forceThebes = PR_TRUE;
continue;
}
return rv;
}
mCurrentContextId.Assign(aContextId);
} else if (!mCurrentContextId.Equals(aContextId)) {
break;
}
if (!mCurrentContextId.Equals(aContextId)) {
//XXX eventually allow for more than one active context on a given canvas
return NS_OK;
}
@ -535,7 +549,7 @@ nsHTMLCanvasElement::MozGetIPCContext(const nsAString& aContextId,
nsresult rv;
if (mCurrentContextId.IsEmpty()) {
rv = GetContextHelper(aContextId, getter_AddRefs(mCurrentContext));
rv = GetContextHelper(aContextId, PR_FALSE, getter_AddRefs(mCurrentContext));
NS_ENSURE_SUCCESS(rv, rv);
if (!mCurrentContext) {
return NS_OK;
@ -700,6 +714,12 @@ nsHTMLCanvasElement::GetCanvasLayer(nsDisplayListBuilder* aBuilder,
return mCurrentContext->GetCanvasLayer(aBuilder, aOldLayer, aManager);
}
PRBool
nsHTMLCanvasElement::ShouldForceInactiveLayer(LayerManager *aManager)
{
return !mCurrentContext || mCurrentContext->ShouldForceInactiveLayer(aManager);
}
void
nsHTMLCanvasElement::MarkContextClean()
{

View File

@ -310,6 +310,10 @@ nsresult nsBuiltinDecoderReader::DecodeToTarget(PRInt64 aTarget)
if (HasAudio()) {
// Decode audio forward to the seek target.
PRInt64 targetSample = 0;
if (!UsecsToSamples(aTarget, mInfo.mAudioRate, targetSample)) {
return NS_ERROR_FAILURE;
}
PRBool eof = PR_FALSE;
while (HasAudio() && !eof) {
while (!eof && mAudioQueue.GetSize() == 0) {
@ -322,14 +326,53 @@ nsresult nsBuiltinDecoderReader::DecodeToTarget(PRInt64 aTarget)
}
}
}
nsAutoPtr<SoundData> audio(mAudioQueue.PeekFront());
if (audio && audio->mTime + audio->mDuration <= aTarget) {
mAudioQueue.PopFront();
const SoundData* audio = mAudioQueue.PeekFront();
if (!audio)
break;
PRInt64 startSample = 0;
if (!UsecsToSamples(audio->mTime, mInfo.mAudioRate, startSample)) {
return NS_ERROR_FAILURE;
}
if (startSample + audio->mSamples <= targetSample) {
// Our seek target lies after the samples in this SoundData. Pop it
// off the queue, and keep decoding forwards.
delete mAudioQueue.PopFront();
audio = nsnull;
} else {
audio.forget();
continue;
}
// The seek target lies somewhere in this SoundData's samples, strip off
// any samples which lie before the seek target, so we'll begin playback
// exactly at the seek target.
NS_ASSERTION(targetSample >= startSample, "Target must at or be after data start.");
NS_ASSERTION(startSample + audio->mSamples > targetSample, "Data must end after target.");
PRInt64 samplesToPrune = targetSample - startSample;
if (samplesToPrune > audio->mSamples) {
// We've messed up somehow. Don't try to trim samples, the |samples|
// variable below will overflow.
NS_WARNING("Can't prune more samples that we have!");
break;
}
PRUint32 samples = audio->mSamples - static_cast<PRUint32>(samplesToPrune);
PRUint32 channels = audio->mChannels;
nsAutoArrayPtr<SoundDataValue> audioData(new SoundDataValue[samples * channels]);
memcpy(audioData.get(),
audio->mAudioData.get() + (samplesToPrune * channels),
samples * channels * sizeof(SoundDataValue));
PRInt64 duration;
if (!SamplesToUsecs(samples, mInfo.mAudioRate, duration)) {
return NS_ERROR_FAILURE;
}
nsAutoPtr<SoundData> data(new SoundData(audio->mOffset,
aTarget,
duration,
samples,
audioData.forget(),
channels));
delete mAudioQueue.PopFront();
mAudioQueue.PushFront(data.forget());
break;
}
}
return NS_OK;

View File

@ -1496,6 +1496,7 @@ nsSHistory::LoadEntry(PRInt32 aIndex, long aLoadType, PRUint32 aHistCmd)
if (!canNavigate) {
// If the listener asked us not to proceed with
// the operation, simply return.
mRequestedIndex = -1;
return NS_OK; // XXX Maybe I can return some other error code?
}

View File

@ -9089,6 +9089,8 @@ nsGlobalWindow::RunTimeout(nsTimeout *aTimeout)
dummy_timeout.AddRef();
last_insertion_point = mTimeoutInsertionPoint;
// If we ever start setting mTimeoutInsertionPoint to a non-dummy timeout,
// the logic in ResetTimersForNonBackgroundWindow will need to change.
mTimeoutInsertionPoint = &dummy_timeout;
for (timeout = FirstTimeout();
@ -9426,7 +9428,16 @@ nsresult nsGlobalWindow::ResetTimersForNonBackgroundWindow()
TimeStamp now = TimeStamp::Now();
for (nsTimeout *timeout = FirstTimeout(); IsTimeout(timeout); ) {
// If mTimeoutInsertionPoint is non-null, we're in the middle of firing
// timers and the timers we're planning to fire all come before
// mTimeoutInsertionPoint; mTimeoutInsertionPoint itself is a dummy timeout
// with an mWhen that may be semi-bogus. In that case, we don't need to do
// anything with mTimeoutInsertionPoint or anything before it, so should
// start at the timer after mTimeoutInsertionPoint, if there is one.
// Otherwise, start at the beginning of the list.
for (nsTimeout *timeout = mTimeoutInsertionPoint ?
mTimeoutInsertionPoint->Next() : FirstTimeout();
IsTimeout(timeout); ) {
// It's important that this check be <= so that we guarantee that
// taking NS_MAX with |now| won't make a quantity equal to
// timeout->mWhen below.

View File

@ -914,8 +914,14 @@ protected:
// These member variable are used only on inner windows.
nsRefPtr<nsEventListenerManager> mListenerManager;
// mTimeouts is generally sorted by mWhen, unless mTimeoutInsertionPoint is
// non-null. In that case, the dummy timeout pointed to by
// mTimeoutInsertionPoint may have a later mWhen than some of the timeouts
// that come after it.
PRCList mTimeouts;
// If mTimeoutInsertionPoint is non-null, insertions should happen after it.
// This is a dummy timeout at the moment; if that ever changes, the logic in
// ResetTimersForNonBackgroundWindow needs to change.
nsTimeout* mTimeoutInsertionPoint;
PRUint32 mTimeoutPublicIdCounter;
PRUint32 mTimeoutFiringDepth;

View File

@ -246,22 +246,25 @@ public:
* aStops GradientStops object for this gradient, this should match the
* backend type of the draw target this pattern will be used with.
*/
RadialGradientPattern(const Point &aCenter,
const Point &aOrigin,
Float aRadius,
RadialGradientPattern(const Point &aCenter1,
const Point &aCenter2,
Float aRadius1,
Float aRadius2,
GradientStops *aStops)
: mCenter(aCenter)
, mOrigin(aOrigin)
, mRadius(aRadius)
: mCenter1(aCenter1)
, mCenter2(aCenter2)
, mRadius1(aRadius1)
, mRadius2(aRadius2)
, mStops(aStops)
{
}
virtual PatternType GetType() const { return PATTERN_RADIAL_GRADIENT; }
Point mCenter;
Point mOrigin;
Float mRadius;
Point mCenter1;
Point mCenter2;
Float mRadius1;
Float mRadius2;
RefPtr<GradientStops> mStops;
};

View File

@ -229,7 +229,7 @@ DrawTargetD2D::DrawSurface(SourceSurface *aSurface,
{
RefPtr<ID2D1Bitmap> bitmap;
ID2D1RenderTarget *rt = GetRTForOperator(aOptions.mCompositionOp);
ID2D1RenderTarget *rt = GetRTForOperation(aOptions.mCompositionOp, ColorPattern(Color()));
PrepareForDrawing(rt);
@ -279,7 +279,7 @@ DrawTargetD2D::DrawSurface(SourceSurface *aSurface,
rt->DrawBitmap(bitmap, D2DRect(aDest), aOptions.mAlpha, D2DFilter(aSurfOptions.mFilter), D2DRect(srcRect));
FinalizeRTForOperator(aOptions.mCompositionOp, aDest);
FinalizeRTForOperation(aOptions.mCompositionOp, ColorPattern(Color()), aDest);
}
void
@ -693,7 +693,7 @@ DrawTargetD2D::FillRect(const Rect &aRect,
const Pattern &aPattern,
const DrawOptions &aOptions)
{
ID2D1RenderTarget *rt = GetRTForOperator(aOptions.mCompositionOp);
ID2D1RenderTarget *rt = GetRTForOperation(aOptions.mCompositionOp, aPattern);
PrepareForDrawing(rt);
@ -703,7 +703,7 @@ DrawTargetD2D::FillRect(const Rect &aRect,
rt->FillRectangle(D2DRect(aRect), brush);
}
FinalizeRTForOperator(aOptions.mCompositionOp, aRect);
FinalizeRTForOperation(aOptions.mCompositionOp, aPattern, aRect);
}
void
@ -712,7 +712,7 @@ DrawTargetD2D::StrokeRect(const Rect &aRect,
const StrokeOptions &aStrokeOptions,
const DrawOptions &aOptions)
{
ID2D1RenderTarget *rt = GetRTForOperator(aOptions.mCompositionOp);
ID2D1RenderTarget *rt = GetRTForOperation(aOptions.mCompositionOp, aPattern);
PrepareForDrawing(rt);
@ -724,7 +724,7 @@ DrawTargetD2D::StrokeRect(const Rect &aRect,
rt->DrawRectangle(D2DRect(aRect), brush, aStrokeOptions.mLineWidth, strokeStyle);
}
FinalizeRTForOperator(aOptions.mCompositionOp, aRect);
FinalizeRTForOperation(aOptions.mCompositionOp, aPattern, aRect);
}
void
@ -734,7 +734,7 @@ DrawTargetD2D::StrokeLine(const Point &aStart,
const StrokeOptions &aStrokeOptions,
const DrawOptions &aOptions)
{
ID2D1RenderTarget *rt = GetRTForOperator(aOptions.mCompositionOp);
ID2D1RenderTarget *rt = GetRTForOperation(aOptions.mCompositionOp, aPattern);
PrepareForDrawing(rt);
@ -746,7 +746,7 @@ DrawTargetD2D::StrokeLine(const Point &aStart,
rt->DrawLine(D2DPoint(aStart), D2DPoint(aEnd), brush, aStrokeOptions.mLineWidth, strokeStyle);
}
FinalizeRTForOperator(aOptions.mCompositionOp, Rect(0, 0, Float(mSize.width), Float(mSize.height)));
FinalizeRTForOperation(aOptions.mCompositionOp, aPattern, Rect(0, 0, Float(mSize.width), Float(mSize.height)));
}
void
@ -762,7 +762,7 @@ DrawTargetD2D::Stroke(const Path *aPath,
const PathD2D *d2dPath = static_cast<const PathD2D*>(aPath);
ID2D1RenderTarget *rt = GetRTForOperator(aOptions.mCompositionOp);
ID2D1RenderTarget *rt = GetRTForOperation(aOptions.mCompositionOp, aPattern);
PrepareForDrawing(rt);
@ -774,7 +774,7 @@ DrawTargetD2D::Stroke(const Path *aPath,
rt->DrawGeometry(d2dPath->mGeometry, brush, aStrokeOptions.mLineWidth, strokeStyle);
}
FinalizeRTForOperator(aOptions.mCompositionOp, Rect(0, 0, Float(mSize.width), Float(mSize.height)));
FinalizeRTForOperation(aOptions.mCompositionOp, aPattern, Rect(0, 0, Float(mSize.width), Float(mSize.height)));
}
void
@ -789,7 +789,7 @@ DrawTargetD2D::Fill(const Path *aPath,
const PathD2D *d2dPath = static_cast<const PathD2D*>(aPath);
ID2D1RenderTarget *rt = GetRTForOperator(aOptions.mCompositionOp);
ID2D1RenderTarget *rt = GetRTForOperation(aOptions.mCompositionOp, aPattern);
PrepareForDrawing(rt);
@ -805,7 +805,7 @@ DrawTargetD2D::Fill(const Path *aPath,
d2dPath->mGeometry->GetBounds(D2D1::IdentityMatrix(), &d2dbounds);
bounds = ToRect(d2dbounds);
}
FinalizeRTForOperator(aOptions.mCompositionOp, bounds);
FinalizeRTForOperation(aOptions.mCompositionOp, aPattern, bounds);
}
void
@ -821,7 +821,7 @@ DrawTargetD2D::FillGlyphs(ScaledFont *aFont,
ScaledFontDWrite *font = static_cast<ScaledFontDWrite*>(aFont);
ID2D1RenderTarget *rt = GetRTForOperator(aOptions.mCompositionOp);
ID2D1RenderTarget *rt = GetRTForOperation(aOptions.mCompositionOp, aPattern);
PrepareForDrawing(rt);
@ -857,7 +857,7 @@ DrawTargetD2D::FillGlyphs(ScaledFont *aFont,
rt->DrawGlyphRun(D2D1::Point2F(), &glyphRun, brush);
}
FinalizeRTForOperator(aOptions.mCompositionOp, Rect(0, 0, (Float)mSize.width, (Float)mSize.height));
FinalizeRTForOperation(aOptions.mCompositionOp, aPattern, Rect(0, 0, (Float)mSize.width, (Float)mSize.height));
}
void
@ -986,13 +986,13 @@ DrawTargetD2D::CreatePathBuilder(FillRule aFillRule) const
}
TemporaryRef<GradientStops>
DrawTargetD2D::CreateGradientStops(GradientStop *aStops, uint32_t aNumStops) const
DrawTargetD2D::CreateGradientStops(GradientStop *rawStops, uint32_t aNumStops) const
{
D2D1_GRADIENT_STOP *stops = new D2D1_GRADIENT_STOP[aNumStops];
for (uint32_t i = 0; i < aNumStops; i++) {
stops[i].position = aStops[i].offset;
stops[i].color = D2DColor(aStops[i].color);
stops[i].position = rawStops[i].offset;
stops[i].color = D2DColor(rawStops[i].color);
}
RefPtr<ID2D1GradientStopCollection> stopCollection;
@ -1290,9 +1290,9 @@ DrawTargetD2D::GetBlendStateForOperator(CompositionOp aOperator)
* drawing operation other than OVER is required.
*/
ID2D1RenderTarget*
DrawTargetD2D::GetRTForOperator(CompositionOp aOperator)
DrawTargetD2D::GetRTForOperation(CompositionOp aOperator, const Pattern &aPattern)
{
if (aOperator == OP_OVER) {
if (aOperator == OP_OVER && !IsPatternSupportedByD2D(aPattern)) {
return mRT;
}
@ -1331,9 +1331,9 @@ DrawTargetD2D::GetRTForOperator(CompositionOp aOperator)
* to the surface.
*/
void
DrawTargetD2D::FinalizeRTForOperator(CompositionOp aOperator, const Rect &aBounds)
DrawTargetD2D::FinalizeRTForOperation(CompositionOp aOperator, const Pattern &aPattern, const Rect &aBounds)
{
if (aOperator == OP_OVER) {
if (aOperator == OP_OVER && !IsPatternSupportedByD2D(aPattern)) {
return;
}
@ -1377,13 +1377,26 @@ DrawTargetD2D::FinalizeRTForOperator(CompositionOp aOperator, const Rect &aBound
viewport.TopLeftY = 0;
mDevice->RSSetViewports(1, &viewport);
mPrivateData->mEffect->GetVariableByName("tex")->AsShaderResource()->SetResource(mSRView);
mPrivateData->mEffect->GetVariableByName("QuadDesc")->AsVector()->
SetFloatVector(ShaderConstantRectD3D10(-1.0f, 1.0f, 2.0f, -2.0f));
mPrivateData->mEffect->GetVariableByName("TexCoords")->AsVector()->
SetFloatVector(ShaderConstantRectD3D10(0, 0, 1.0f, 1.0f));
mPrivateData->mEffect->GetTechniqueByName("SampleTexture")->GetPassByIndex(0)->Apply(0);
if (!IsPatternSupportedByD2D(aPattern)) {
mPrivateData->mEffect->GetVariableByName("TexCoords")->AsVector()->
SetFloatVector(ShaderConstantRectD3D10(0, 0, 1.0f, 1.0f));
mPrivateData->mEffect->GetVariableByName("tex")->AsShaderResource()->SetResource(mSRView);
mPrivateData->mEffect->GetTechniqueByName("SampleTexture")->GetPassByIndex(0)->Apply(0);
} else if (aPattern.GetType() == PATTERN_RADIAL_GRADIENT) {
const RadialGradientPattern *pat = static_cast<const RadialGradientPattern*>(&aPattern);
if (pat->mCenter1 == pat->mCenter2 && pat->mRadius1 == pat->mRadius2) {
// Draw nothing!
return;
}
mPrivateData->mEffect->GetVariableByName("mask")->AsShaderResource()->SetResource(mSRView);
SetupEffectForRadialGradient(pat);
}
mDevice->OMSetBlendState(GetBlendStateForOperator(aOperator), NULL, 0xffffffff);
@ -1504,6 +1517,12 @@ DrawTargetD2D::PopAllClips()
TemporaryRef<ID2D1Brush>
DrawTargetD2D::CreateBrushForPattern(const Pattern &aPattern, Float aAlpha)
{
if (IsPatternSupportedByD2D(aPattern)) {
RefPtr<ID2D1SolidColorBrush> colBrush;
mRT->CreateSolidColorBrush(D2D1::ColorF(1.0f, 1.0f, 1.0f, 1.0f), byRef(colBrush));
return colBrush;
}
if (aPattern.GetType() == PATTERN_COLOR) {
RefPtr<ID2D1SolidColorBrush> colBrush;
Color color = static_cast<const ColorPattern*>(&aPattern)->mColor;
@ -1542,13 +1561,15 @@ DrawTargetD2D::CreateBrushForPattern(const Pattern &aPattern, Float aAlpha)
return NULL;
}
mRT->CreateRadialGradientBrush(D2D1::RadialGradientBrushProperties(D2DPoint(pat->mCenter),
D2DPoint(pat->mOrigin - pat->mCenter),
pat->mRadius,
pat->mRadius),
D2D1::BrushProperties(aAlpha),
stops->mStopCollection,
byRef(gradBrush));
// This will not be a complex radial gradient brush.
mRT->CreateRadialGradientBrush(
D2D1::RadialGradientBrushProperties(D2DPoint(pat->mCenter1),
D2D1::Point2F(),
pat->mRadius2, pat->mRadius2),
D2D1::BrushProperties(aAlpha),
stops->mStopCollection,
byRef(gradBrush));
return gradBrush;
} else if (aPattern.GetType() == PATTERN_SURFACE) {
RefPtr<ID2D1BitmapBrush> bmBrush;
@ -1687,6 +1708,133 @@ DrawTargetD2D::CreateStrokeStyleForOptions(const StrokeOptions &aStrokeOptions)
return style;
}
TemporaryRef<ID3D10Texture1D>
DrawTargetD2D::CreateGradientTexture(const GradientStopsD2D *aStops)
{
CD3D10_TEXTURE1D_DESC desc(DXGI_FORMAT_B8G8R8A8_UNORM, 4096, 1, 1);
std::vector<D2D1_GRADIENT_STOP> rawStops;
rawStops.resize(aStops->mStopCollection->GetGradientStopCount());
aStops->mStopCollection->GetGradientStops(&rawStops.front(), rawStops.size());
std::vector<unsigned char> textureData;
textureData.resize(4096 * 4);
unsigned char *texData = &textureData.front();
float prevColorPos = 0;
float nextColorPos = 1.0f;
D2D1_COLOR_F prevColor = rawStops[0].color;
D2D1_COLOR_F nextColor = prevColor;
if (rawStops.size() >= 2) {
nextColor = rawStops[1].color;
nextColorPos = rawStops[1].position;
}
uint32_t stopPosition = 2;
// Not the most optimized way but this will do for now.
for (int i = 0; i < 4096; i++) {
// The 4095 seems a little counter intuitive, but we want the gradient
// color at offset 0 at the first pixel, and at offset 1.0f at the last
// pixel.
float pos = float(i) / 4095;
if (pos > nextColorPos) {
prevColor = nextColor;
prevColorPos = nextColorPos;
if (rawStops.size() > stopPosition) {
nextColor = rawStops[stopPosition].color;
nextColorPos = rawStops[stopPosition++].position;
} else {
nextColorPos = 1.0f;
}
}
float interp = (pos - prevColorPos) / (nextColorPos - prevColorPos);
Color newColor(prevColor.r + (nextColor.r - prevColor.r) * interp,
prevColor.g + (nextColor.g - prevColor.g) * interp,
prevColor.b + (nextColor.b - prevColor.b) * interp,
prevColor.a + (nextColor.a - prevColor.a) * interp);
texData[i * 4] = (char)(255.0f * newColor.b);
texData[i * 4 + 1] = (char)(255.0f * newColor.g);
texData[i * 4 + 2] = (char)(255.0f * newColor.r);
texData[i * 4 + 3] = (char)(255.0f * newColor.a);
}
D3D10_SUBRESOURCE_DATA data;
data.pSysMem = &textureData.front();
RefPtr<ID3D10Texture1D> tex;
mDevice->CreateTexture1D(&desc, &data, byRef(tex));
return tex;
}
void
DrawTargetD2D::SetupEffectForRadialGradient(const RadialGradientPattern *aPattern)
{
mPrivateData->mEffect->GetTechniqueByName("SampleRadialGradient")->GetPassByIndex(0)->Apply(0);
mPrivateData->mEffect->GetVariableByName("MaskTexCoords")->AsVector()->
SetFloatVector(ShaderConstantRectD3D10(0, 0, 1.0f, 1.0f));
float dimensions[] = { float(mSize.width), float(mSize.height), 0, 0 };
mPrivateData->mEffect->GetVariableByName("dimensions")->AsVector()->
SetFloatVector(dimensions);
const GradientStopsD2D *stops =
static_cast<const GradientStopsD2D*>(aPattern->mStops.get());
RefPtr<ID3D10Texture1D> tex = CreateGradientTexture(stops);
RefPtr<ID3D10ShaderResourceView> srView;
mDevice->CreateShaderResourceView(tex, NULL, byRef(srView));
mPrivateData->mEffect->GetVariableByName("tex")->AsShaderResource()->SetResource(srView);
Point dc = aPattern->mCenter2 - aPattern->mCenter1;
float dr = aPattern->mRadius2 - aPattern->mRadius1;
float diffv[] = { dc.x, dc.y, dr, 0 };
mPrivateData->mEffect->GetVariableByName("diff")->AsVector()->
SetFloatVector(diffv);
float center1[] = { aPattern->mCenter1.x, aPattern->mCenter1.y, dr, 0 };
mPrivateData->mEffect->GetVariableByName("center1")->AsVector()->
SetFloatVector(center1);
mPrivateData->mEffect->GetVariableByName("radius1")->AsScalar()->
SetFloat(aPattern->mRadius1);
mPrivateData->mEffect->GetVariableByName("sq_radius1")->AsScalar()->
SetFloat(pow(aPattern->mRadius1, 2));
Matrix invTransform = mTransform;
if (!invTransform.Invert()) {
// Bail if the matrix is singular.
return;
}
float matrix[] = { invTransform._11, invTransform._12, 0, 0,
invTransform._21, invTransform._22, 0, 0,
invTransform._31, invTransform._32, 1.0f, 0,
0, 0, 0, 1.0f };
mPrivateData->mEffect->GetVariableByName("DeviceSpaceToUserSpace")->
AsMatrix()->SetMatrix(matrix);
float A = dc.x * dc.x + dc.y * dc.y - dr * dr;
if (A == 0) {
mPrivateData->mEffect->GetTechniqueByName("SampleRadialGradient")->
GetPassByIndex(1)->Apply(0);
} else {
mPrivateData->mEffect->GetVariableByName("A")->AsScalar()->SetFloat(A);
mPrivateData->mEffect->GetTechniqueByName("SampleRadialGradient")->
GetPassByIndex(0)->Apply(0);
}
}
ID2D1Factory*
DrawTargetD2D::factory()
{

View File

@ -50,6 +50,7 @@ namespace mozilla {
namespace gfx {
class SourceSurfaceD2DTarget;
class GradientStopsD2D;
struct PrivateD3D10DataD2D
{
@ -154,9 +155,8 @@ private:
void MarkChanged();
ID3D10BlendState *GetBlendStateForOperator(CompositionOp aOperator);
ID2D1RenderTarget *GetRTForOperator(CompositionOp aOperator);
void FinalizeRTForOperator(CompositionOp aOperator, const Rect &aBounds);
void EnsureViews();
ID2D1RenderTarget *GetRTForOperation(CompositionOp aOperator, const Pattern &aPattern);
void FinalizeRTForOperation(CompositionOp aOperator, const Pattern &aPattern, const Rect &aBounds); void EnsureViews();
void PopAllClips();
TemporaryRef<ID2D1RenderTarget> CreateRTForTexture(ID3D10Texture2D *aTexture);
@ -165,6 +165,12 @@ private:
TemporaryRef<ID2D1Brush> CreateBrushForPattern(const Pattern &aPattern, Float aAlpha = 1.0f);
TemporaryRef<ID2D1StrokeStyle> CreateStrokeStyleForOptions(const StrokeOptions &aStrokeOptions);
TemporaryRef<ID3D10Texture1D> CreateGradientTexture(const GradientStopsD2D *aStops);
void SetupEffectForRadialGradient(const RadialGradientPattern *aPattern);
static const uint32_t test = 4;
IntSize mSize;
RefPtr<ID3D10Device1> mDevice;

View File

@ -151,6 +151,29 @@ static inline int BytesPerPixel(SurfaceFormat aFormat)
}
}
static bool IsPatternSupportedByD2D(const Pattern &aPattern)
{
if (aPattern.GetType() != PATTERN_RADIAL_GRADIENT) {
return false;
}
const RadialGradientPattern *pat =
static_cast<const RadialGradientPattern*>(&aPattern);
if (pat->mRadius1 != 0) {
return true;
}
Point diff = pat->mCenter2 - pat->mCenter1;
if (sqrt(diff.x * diff.x + diff.y * diff.y) >= pat->mRadius2) {
// Inner point lies outside the circle.
return true;
}
return false;
}
/**
* This structure is used to pass rectangles to our shader constant. We can use
* this for passing rectangular areas to SetVertexShaderConstant. In the format

View File

@ -24,6 +24,18 @@ cbuffer cb1
float4 ShadowColor;
}
cbuffer cb2
{
float3x3 DeviceSpaceToUserSpace;
float2 dimensions;
// Precalculate as much as we can!
float3 diff;
float2 center1;
float A;
float radius1;
float sq_radius1;
}
struct VS_OUTPUT
{
float4 Position : SV_Position;
@ -31,6 +43,13 @@ struct VS_OUTPUT
float2 MaskTexCoord : TEXCOORD1;
};
struct VS_RADIAL_OUTPUT
{
float4 Position : SV_Position;
float2 MaskTexCoord : TEXCOORD0;
float2 PixelCoord : TEXCOORD1;
};
Texture2D tex;
Texture2D mask;
@ -94,6 +113,25 @@ VS_OUTPUT SampleTextureVS(float3 pos : POSITION)
return Output;
}
VS_RADIAL_OUTPUT SampleRadialVS(float3 pos : POSITION)
{
VS_RADIAL_OUTPUT Output;
Output.Position.w = 1.0f;
Output.Position.x = pos.x * QuadDesc.z + QuadDesc.x;
Output.Position.y = pos.y * QuadDesc.w + QuadDesc.y;
Output.Position.z = 0;
Output.MaskTexCoord.x = pos.x * MaskTexCoords.z + MaskTexCoords.x;
Output.MaskTexCoord.y = pos.y * MaskTexCoords.w + MaskTexCoords.y;
// For the radial gradient pixel shader we need to pass in the pixel's
// coordinates in user space for the color to be correctly determined.
Output.PixelCoord.x = ((Output.Position.x + 1.0f) / 2.0f) * dimensions.x;
Output.PixelCoord.y = ((1.0f - Output.Position.y) / 2.0f) * dimensions.y;
Output.PixelCoord.xy = mul(float3(Output.PixelCoord.x, Output.PixelCoord.y, 1.0f), DeviceSpaceToUserSpace).xy;
return Output;
}
float4 SampleTexturePS( VS_OUTPUT In) : SV_Target
{
return tex.Sample(sSampler, In.TexCoord);
@ -104,6 +142,68 @@ float4 SampleMaskTexturePS( VS_OUTPUT In) : SV_Target
return tex.Sample(sSampler, In.TexCoord) * mask.Sample(sMaskSampler, In.MaskTexCoord).a;
};
float4 SampleRadialGradientPS( VS_RADIAL_OUTPUT In) : SV_Target
{
// Radial gradient painting is defined as the set of circles whose centers
// are described by C(t) = (C2 - C1) * t + C1; with radii
// R(t) = (R2 - R1) * t + R1; for R(t) > 0. This shader solves the
// quadratic equation that arises when calculating t for pixel (x, y).
//
// A more extensive derrivation can be found in the pixman radial gradient
// code.
float2 p = In.PixelCoord;
float3 dp = float3(p - center1, radius1);
// dpx * dcx + dpy * dcy + r * dr
float B = dot(dp, diff);
float C = pow(dp.x, 2) + pow(dp.y, 2) - sq_radius1;
float det = pow(B, 2) - A * C;
if (det < 0) {
return float4(0, 0, 0, 0);
}
float sqrt_det = sqrt(abs(det));
float2 t = (B + float2(sqrt_det, -sqrt_det)) / A;
float2 isValid = step(float2(-radius1, -radius1), t * diff.z);
if (max(isValid.x, isValid.y) <= 0) {
return float4(0, 0, 0, 0);
}
float upper_t = lerp(t.y, t.x, isValid.x);
// Multiply the output color by the input mask for the operation.
return tex.Sample(sSampler, float2(upper_t, 0.5)) * mask.Sample(sMaskSampler, In.MaskTexCoord).a;
};
float4 SampleRadialGradientA0PS( VS_RADIAL_OUTPUT In) : SV_Target
{
// This simpler shader is used for the degenerate case where A is 0,
// i.e. we're actually solving a linear equation.
float2 p = In.PixelCoord;
float3 dp = float3(p - center1, radius1);
// dpx * dcx + dpy * dcy + r * dr
float B = dot(dp, diff);
float C = pow(dp.x, 2) + pow(dp.y, 2) - pow(radius1, 2);
float t = 0.5 * C / B;
if (-radius1 >= t * diff.z) {
return float4(0, 0, 0, 0);
}
return tex.Sample(sSampler, float2(t, 0.5)) * mask.Sample(sMaskSampler, In.MaskTexCoord).a;
};
float4 SampleShadowHPS( VS_OUTPUT In) : SV_Target
{
float outputStrength = 0;
@ -166,6 +266,24 @@ technique10 SampleTexture
}
}
technique10 SampleRadialGradient
{
pass P0
{
SetRasterizerState(TextureRast);
SetVertexShader(CompileShader(vs_4_0_level_9_3, SampleRadialVS()));
SetGeometryShader(NULL);
SetPixelShader(CompileShader(ps_4_0_level_9_3, SampleRadialGradientPS()));
}
pass P1
{
SetRasterizerState(TextureRast);
SetVertexShader(CompileShader(vs_4_0_level_9_3, SampleRadialVS()));
SetGeometryShader(NULL);
SetPixelShader(CompileShader(ps_4_0_level_9_3, SampleRadialGradientA0PS()));
}
}
technique10 SampleMaskedTexture
{
pass P0

File diff suppressed because it is too large Load Diff

View File

@ -434,6 +434,7 @@ public:
CreateDrawTarget(const mozilla::gfx::IntSize &aSize,
mozilla::gfx::SurfaceFormat aFormat);
virtual bool CanUseCanvasLayerForSize(const gfxIntSize &aSize) { return PR_TRUE; }
/**
* Return the name of the layer manager's backend.

View File

@ -115,6 +115,15 @@ public:
const CallbackInfo &GetCallbackInfo() { return mCurrentCallbackInfo; }
// D3D10 guarantees textures can be at least this size
enum {
MAX_TEXTURE_SIZE = 8192
};
virtual bool CanUseCanvasLayerForSize(const gfxIntSize &aSize)
{
return aSize <= gfxIntSize(MAX_TEXTURE_SIZE, MAX_TEXTURE_SIZE);
}
virtual already_AddRefed<ThebesLayer> CreateThebesLayer();
virtual already_AddRefed<ContainerLayer> CreateContainerLayer();

View File

@ -181,6 +181,7 @@ SwapChainD3D9::Reset()
DeviceManagerD3D9::DeviceManagerD3D9()
: mDeviceResetCount(0)
, mMaxTextureSize(0)
, mHasDynamicTextures(false)
, mDeviceWasRemoved(false)
{
@ -646,6 +647,7 @@ DeviceManagerD3D9::VerifyCaps()
caps.MaxTextureWidth < 4096) {
return false;
}
mMaxTextureSize = NS_MIN(caps.MaxTextureHeight, caps.MaxTextureWidth);
if ((caps.PixelShaderVersion & 0xffff) < 0x200 ||
(caps.VertexShaderVersion & 0xffff) < 0x200) {

View File

@ -168,6 +168,8 @@ public:
*/
nsTArray<LayerD3D9*> mLayersWithResources;
PRInt32 GetMaxTextureSize() { return mMaxTextureSize; }
private:
friend class SwapChainD3D9;
@ -238,6 +240,8 @@ private:
PRUint32 mDeviceResetCount;
PRUint32 mMaxTextureSize;
/* If this device supports dynamic textures */
bool mHasDynamicTextures;

View File

@ -141,6 +141,14 @@ public:
void SetRoot(Layer* aLayer);
virtual bool CanUseCanvasLayerForSize(const gfxIntSize &aSize)
{
if (!mDeviceManager)
return false;
PRInt32 maxSize = mDeviceManager->GetMaxTextureSize();
return aSize <= gfxIntSize(maxSize, maxSize);
}
virtual already_AddRefed<ThebesLayer> CreateThebesLayer();
virtual already_AddRefed<ContainerLayer> CreateContainerLayer();

View File

@ -138,6 +138,14 @@ public:
virtual void SetRoot(Layer* aLayer) { mRoot = aLayer; }
virtual bool CanUseCanvasLayerForSize(const gfxIntSize &aSize)
{
if (!mGLContext)
return false;
PRInt32 maxSize = mGLContext->GetMaxTextureSize();
return aSize <= gfxIntSize(maxSize, maxSize);
}
virtual already_AddRefed<ThebesLayer> CreateThebesLayer();
virtual already_AddRefed<ContainerLayer> CreateContainerLayer();

View File

@ -1,6 +1,6 @@
url-prefix ../../jsreftest.html?test=e4x/GC/
script regress-280844-1.js
script regress-280844-2.js
skip-if(Android) script regress-280844-1.js
skip-if(Android) script regress-280844-2.js
skip-if(!xulRuntime.shell) script regress-292455.js # does not always dismiss alert
script regress-313952-01.js
script regress-313952-02.js

View File

@ -80,17 +80,17 @@ script regress-375406.js
script regress-378492.js
script regress-380833.js
script regress-383255.js
silentfail script regress-394941.js
skip-if(Android) silentfail script regress-394941.js
script regress-407323.js
script regress-426520.js
script regress-453915.js
silentfail script regress-458679-01.js
silentfail script regress-458679-02.js
skip-if(Android) silentfail script regress-458679-01.js
skip-if(Android) silentfail script regress-458679-02.js
script regress-460180.js
script regress-465063.js
script regress-470619.js
script regress-473709.js
script regress-474319.js
skip-if(Android) script regress-473709.js
skip-if(Android) script regress-474319.js
script regress-477053.js
script regress-561031.js
script regress-587434.js

View File

@ -48,7 +48,7 @@ script 13.4.4.7.js
script 13.4.4.8.js
script 13.4.4.9.js
script regress-291930.js
silentfail script regress-324422-1.js
skip-if(Android) silentfail script regress-324422-1.js
skip script regress-324422-2.js # slow
skip script regress-324688.js # bug 528404 - disable due to random timeouts
script regress-336921.js

View File

@ -9,5 +9,5 @@ script function-bind.js
script function-call.js
script redefine-arguments-length.js
script builtin-no-prototype.js
script Function-arguments-gc.js
skip-if(Android) script Function-arguments-gc.js
script builtin-no-construct.js

View File

@ -5,7 +5,7 @@ random script regress-101964.js # bogus perf test (bug 467263)
script regress-107138.js
fails-if(!xulRuntime.shell) script regress-108440.js # bug - NS_ERROR_DOM_NOT_SUPPORTED_ERR line 74
script regress-154338.js
skip-if(xulRuntime.XPCOMABI.match(/x86_64/)) script regress-157652.js # No test results
skip-if(xulRuntime.XPCOMABI.match(/x86_64/)||Android) script regress-157652.js # No test results
script regress-178722.js
script regress-255555.js
script regress-299644.js
@ -14,7 +14,7 @@ script regress-310351.js
script regress-311515.js
script regress-313153.js
script regress-315509-01.js
skip-if(xulRuntime.XPCOMABI.match(/x86_64/)) script regress-330812.js # No test results
skip-if(xulRuntime.XPCOMABI.match(/x86_64/)||Android) script regress-330812.js # No test results
script regress-345961.js
script regress-348810.js
script regress-350256-01.js

View File

@ -12,5 +12,5 @@ script regress-332472.js
script regress-333728.js
script regress-342359.js
script regress-347674.js
script regress-350650-n.js
skip-if(Android) script regress-350650-n.js
script regress-350837.js

View File

@ -7,9 +7,9 @@ script regress-178389.js
script regress-222029-001.js
script regress-222029-002.js
script regress-292215.js
#silentfail script regress-338001.js # disabled pending bug 657444
#silentfail script regress-338121-01.js # disabled pending bug 657444
#silentfail script regress-338121-02.js # disabled pending bug 657444
#silentfail script regress-338121-03.js # disabled pending bug 657444
#skip-if(Android) silentfail script regress-338001.js # disabled pending bug 657444
#skip-if(Android) silentfail script regress-338121-01.js # disabled pending bug 657444
#skip-if(Android) silentfail script regress-338121-02.js # disabled pending bug 657444
#skip-if(Android) silentfail script regress-338121-03.js # disabled pending bug 657444
script regress-344052.js
script regress-364023.js

View File

@ -17,10 +17,10 @@ skip script regress-338653.js # slow, killed on x86_64
script regress-341877-01.js
script regress-341877-02.js
skip script regress-346794.js # slow, killed
script regress-348532.js
skip-if(Android) script regress-348532.js
script regress-352606.js
skip script regress-383269-01.js # unreliable - based on GC timing
skip script regress-383269-02.js # unreliable - based on GC timing
script regress-390078.js
script regress-418128.js
script regress-440558.js
skip-if(Android) script regress-440558.js

View File

@ -91,7 +91,7 @@ script regress-275378.js
script regress-276103.js
script regress-278873.js
script regress-280769-1.js
silentfail script regress-280769-2.js
skip-if(Android) silentfail script regress-280769-2.js
script regress-280769-3.js
script regress-280769-4.js
script regress-280769-5.js
@ -111,7 +111,7 @@ script regress-295052.js
script regress-295666.js
script regress-299209.js
script regress-299641.js
skip-if(!xulRuntime.shell) script regress-303213.js # bug 524731
skip-if(!xulRuntime.shell||Android) script regress-303213.js # bug 524731
script regress-306633.js
script regress-306727.js
script regress-306794.js
@ -125,7 +125,7 @@ script regress-311071.js
script regress-311629.js
script regress-312260.js
script regress-31255.js
script regress-312588.js
skip-if(Android) script regress-312588.js
random script regress-313967-01.js # BigO
random script regress-313967-02.js # BigO
skip-if(xulRuntime.OS=="WINNT"&&isDebugBuild) slow script regress-314401.js
@ -151,8 +151,8 @@ script regress-328012.js
script regress-328664.js
script regress-328897.js
script regress-329383.js
script regress-329530.js
script regress-330352.js
skip-if(Android) script regress-329530.js
skip-if(Android) script regress-330352.js
script regress-330951.js
script regress-334807-01.js
script regress-334807-02.js

View File

@ -44,9 +44,9 @@ script regress-328556.js
skip script regress-330569.js # Yarr doesn't bail on complex regexps.
script regress-333541.js
skip script regress-335700.js # bug xxx - reftest hang, BigO
skip-if(!xulRuntime.shell) slow script regress-336409-1.js # no results reported.
skip-if(!xulRuntime.shell||Android) slow script regress-336409-1.js # no results reported.
skip-if(!xulRuntime.shell&&((Android||(isDebugBuild&&xulRuntime.OS=="Linux")||xulRuntime.XPCOMABI.match(/x86_64/)))) silentfail script regress-336409-2.js # can fail silently due to out of memory, bug 615011 - timeouts on slow debug Linux
skip-if(!xulRuntime.shell) silentfail script regress-336410-1.js # can fail silently due to out of memory
skip-if(!xulRuntime.shell||Android) silentfail script regress-336410-1.js # can fail silently due to out of memory
skip-if(!xulRuntime.shell&&((isDebugBuild&&xulRuntime.OS=="Linux")||Android||xulRuntime.XPCOMABI.match(/x86_64/)||xulRuntime.OS=="WINNT")) silentfail script regress-336410-2.js # can fail silently due to out of memory, bug 621348 - timeouts on slow debug Linux
script regress-338804-01.js
script regress-338804-02.js
@ -152,11 +152,11 @@ script regress-394967.js
script regress-396326.js
skip script regress-406572.js
script regress-407019.js
script regress-407501.js
skip-if(Android) script regress-407501.js
skip-if(!xulRuntime.shell) slow script regress-407720.js
script regress-412926.js
script regress-414755.js
script regress-416354.js
skip-if(Android) script regress-414755.js
skip-if(Android) script regress-416354.js
script regress-416460.js
script regress-416834.js
skip script regress-418730.js # obsolete test
@ -184,14 +184,14 @@ skip script regress-437288-01.js # obsolete test
script regress-44009.js
script regress-443569.js
script regress-446386.js
script regress-452168.js
skip-if(Android) script regress-452168.js
script regress-452178.js
script regress-452329.js
script regress-452338.js
script regress-452565.js
script regress-453249.js
script regress-454040.js
script regress-454142.js
skip-if(Android) script regress-454142.js
script regress-454704.js
script regress-455380.js
script regress-455408.js
@ -205,7 +205,7 @@ script regress-465276.js
script regress-469625.js
script regress-469761.js
script regress-472599.js
script regress-472787.js
skip-if(Android) script regress-472787.js
script regress-476447.js
script regress-479487.js
script regress-479551.js

View File

@ -6,8 +6,8 @@ script regress-414098.js
fails-if(!xulRuntime.shell) script regress-455464-01.js # bug - NS_ERROR_DOM_NOT_SUPPORTED_ERR line 1
fails-if(!xulRuntime.shell) script regress-455464-02.js # bug - NS_ERROR_DOM_NOT_SUPPORTED_ERR line 49
fails-if(!xulRuntime.shell) script regress-455464-03.js # bug - NS_ERROR_DOM_NOT_SUPPORTED_ERR line 1
fails-if(!xulRuntime.shell&&!isDebugBuild) skip-if(!xulRuntime.shell&&isDebugBuild) script regress-455464-04.js # bug xxx - hangs reftests in debug, ### bug xxx - NS_ERROR_DOM_NOT_SUPPORTED_ERR in opt
skip-if(!xulRuntime.shell) slow script regress-456826.js # bug 504632
fails-if(!xulRuntime.shell&&!isDebugBuild) skip-if((!xulRuntime.shell&&isDebugBuild)||Android) script regress-455464-04.js # bug xxx - hangs reftests in debug, ### bug xxx - NS_ERROR_DOM_NOT_SUPPORTED_ERR in opt
skip-if(!xulRuntime.shell||Android) slow script regress-456826.js # bug 504632
script regress-457521.js
script regress-465443.js
script regress-470310.js

View File

@ -1,3 +1,3 @@
url-prefix ../../jsreftest.html?test=js1_7/GC/
script regress-341675.js
script regress-381374.js
skip-if(Android) script regress-381374.js

View File

@ -63,7 +63,7 @@ script regress-470300-02.js
script regress-473282.js
script regress-474771-01.js
script regress-474771-02.js
script regress-476257.js
skip-if(Android) script regress-476257.js
script regress-477048.js
script regress-589112.js
script regress-590813.js

View File

@ -65,4 +65,4 @@ script regress-470223.js
script regress-470388-01.js
script regress-470388-02.js
script regress-470388-03.js
script regress-474771.js
skip-if(Android) script regress-474771.js

View File

@ -36,7 +36,7 @@ skip-if(!xulRuntime.shell) slow script regress-476414-01.js
skip-if(!xulRuntime.shell) slow script regress-476414-02.js
fails-if(!xulRuntime.shell) script regress-476427.js # NS_ERROR_DOM_NOT_SUPPORTED_ERR
script regress-476653.js
script regress-476869.js
skip-if(Android) script regress-476869.js
script regress-476871-02.js
skip script regress-479252.js
skip script regress-479381.js

View File

@ -26,7 +26,7 @@ script regress-463783.js
script regress-464092-01.js
script regress-464092-02.js
script regress-464096.js
script regress-464418.js
skip-if(Android) script regress-464418.js
script regress-464978.js
script regress-465220.js
script regress-465234.js
@ -64,7 +64,7 @@ script regress-468711.js
script regress-469547.js
script regress-469625-02.js
script regress-469625-03.js
script regress-471373.js # bug xxx No test results reported
skip-if(Android) script regress-471373.js # bug xxx No test results reported
script regress-471660.js
script regress-472450-01.js
script regress-472450-02.js
@ -72,7 +72,7 @@ script regress-472528-01.js
script regress-472528-02.js
script regress-472703.js
script regress-474769.js
script regress-474771.js
skip-if(Android) script regress-474771.js
script regress-474935.js
script regress-476655.js
script regress-477234.js

View File

@ -9,7 +9,7 @@ script regress-452498-224.js
script regress-466905-04.js
skip script regress-466905-05.js # no-op in browser, fails in shell - see bug 554793
script regress-477158.js
script regress-477187.js
skip-if(Android) script regress-477187.js
script regress-520572.js
script new-parenthesization.js
fails-if(Android) script strict-warning.js

View File

@ -8,7 +8,7 @@ script regress-452498-039.js
script regress-452498-040.js
script regress-452498-050.js
script regress-452498-051.js
script regress-452498-052-a.js
skip-if(Android) script regress-452498-052-a.js
script regress-452498-052.js
script regress-452498-053.js
script regress-452498-054.js
@ -28,7 +28,7 @@ script regress-452498-082.js
script regress-452498-091.js
script regress-452498-092.js
script regress-452498-098.js
script regress-452498-099-a.js
skip-if(Android) script regress-452498-099-a.js
script regress-452498-099.js
script regress-452498-101.js
script regress-452498-102.js
@ -50,7 +50,7 @@ script regress-452498-123.js
script regress-452498-129.js
script regress-452498-130.js
script regress-452498-131.js
script regress-452498-135-a.js
skip-if(Android) script regress-452498-135-a.js
script regress-452498-135.js
script regress-452498-138.js
script regress-452498-139.js
@ -68,11 +68,11 @@ script regress-452498-191.js
script regress-452498-192.js
script regress-466905-01.js
script regress-466905-02.js
script regress-479430-01.js
script regress-479430-02.js
script regress-479430-03.js
script regress-479430-04.js
script regress-479430-05.js
skip-if(Android) script regress-479430-01.js
skip-if(Android) script regress-479430-02.js
skip-if(Android) script regress-479430-03.js
skip-if(Android) script regress-479430-04.js
skip-if(Android) script regress-479430-05.js
script regress-495773.js
script regress-495907.js
script regress-496922.js
@ -81,7 +81,7 @@ script regress-507295.js
script regress-507424.js
script regress-509354.js
script regress-515885.js
skip-if(isDebugBuild&&!xulRuntime.shell) script regress-524743.js # hang
skip-if((isDebugBuild&&!xulRuntime.shell)||Android) script regress-524743.js # hang
script regress-522123.js
script regress-524264.js
script regress-530879.js

View File

@ -9,7 +9,7 @@ skip-if(!xulRuntime.shell) script worker-fib.js
skip-if(!xulRuntime.shell) script worker-init.js
skip-if(!xulRuntime.shell) script worker-simple.js
skip-if(!xulRuntime.shell) script worker-terminate.js
skip-if(!xulRuntime.shell) script worker-timeout.js
skip-if(!xulRuntime.shell||Android) script worker-timeout.js
script regress-558541.js
script scripted-proxies.js
script watch-undefined-setter.js

View File

@ -29,7 +29,7 @@ script regress-559438.js
script regress-560101.js
script regress-560998-1.js
script regress-560998-2.js
script regress-563210.js
skip-if(Android) script regress-563210.js
script regress-563221.js
script regress-566549.js
script regress-566914.js
@ -84,7 +84,7 @@ skip-if(!xulRuntime.shell) script regress-618576.js # uses evalcx
fails-if(!xulRuntime.shell) script regress-618652.js
script regress-619003-1.js
script regress-619003-2.js
script regress-620376-1.js
skip-if(Android) script regress-620376-1.js
script regress-620376-2.js
script regress-621814.js
script regress-620750.js

View File

@ -54,7 +54,6 @@ _TEST_FILES = bug500931_helper.html \
file_evalInSandbox.html \
file_wrappers-2.html \
test_bug92773.html \
test_bug361111.xul \
test_bug384632.html \
test_bug390488.html \
test_bug393269.html \
@ -95,6 +94,10 @@ _TEST_FILES = bug500931_helper.html \
file_bug658560.html \
$(NULL)
_CHROME_FILES = \
test_bug361111.xul \
$(NULL)
ifneq ($(OS_TARGET),Android)
ifndef MOZ_PLATFORM_MAEMO
_TEST_FILES += test_bug657267.html \
@ -107,3 +110,7 @@ endif
libs:: $(_TEST_FILES)
$(INSTALL) $^ $(DEPTH)/_tests/testing/mochitest/tests/$(relativesrcdir)
libs:: $(_CHROME_FILES)
$(INSTALL) $^ $(DEPTH)/_tests/testing/mochitest/chrome/$(relativesrcdir)

View File

@ -1,13 +1,13 @@
<?xml version="1.0"?>
<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
<?xml-stylesheet href="/tests/SimpleTest/test.css" type="text/css"?>
<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=361111
-->
<window title="Mozilla Bug 361111"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<script type="application/javascript" src="/MochiKit/packed.js" />
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"/>
<script type="application/javascript" src="chrome://mochikit/content/MochiKit/packed.js" />
<script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/>
<!-- test results are displayed in the html:body -->
<body xmlns="http://www.w3.org/1999/xhtml">

View File

@ -106,6 +106,9 @@ public:
virtual LayerState GetLayerState(nsDisplayListBuilder* aBuilder,
LayerManager* aManager)
{
if (CanvasElementFromContent(mFrame->GetContent())->ShouldForceInactiveLayer(aManager))
return LAYER_INACTIVE;
// If compositing is cheap, just do that
if (aManager->IsCompositingCheap())
return mozilla::LAYER_ACTIVE;

View File

@ -1545,7 +1545,7 @@ random-if(!winWidget) == 574907-2.html 574907-2-ref.html
random-if(!winWidget) fails-if(winWidget&&!d2d) random-if(winWidget&&d2d) != 574907-3.html 574907-3-notref.html
== 577838-1.html 577838-1-ref.html
== 577838-2.html 577838-2-ref.html
fails-if(Android) random-if(layersGPUAccelerated) fails-if(/^Windows\x20NT\x205\.1/.test(http.oscpu)) fails-if(/Mac\x20OS\x20X\x2010\.5/.test(http.oscpu)) == 579323-1.html 579323-1-ref.html # bug 623450 for WinXP and bug 627560 for OSX 10.5
fails-if(Android) random-if(layersGPUAccelerated) == 579323-1.html 579323-1-ref.html
== 579349-1.html 579349-1-ref.html
== 579655-1.html 579655-1-ref.html
fails-if(Android) == 579808-1.html 579808-1-ref.html
@ -1622,7 +1622,7 @@ fails-if(Android) == 625409-1.html 625409-1-ref.html
== 630835-1.html about:blank
== 631352-1.html 631352-1-ref.html
fails-if(Android) == 632423-1.html 632423-1-ref.html
skip-if(Android) fails-if(winWidget) == 632781-verybig.html 632781-ref.html # large canvas elements are not drawn on Windows, see bug 633936
skip-if(Android) == 632781-verybig.html 632781-ref.html
== 632781-normalsize.html 632781-ref.html
== 633344-1.html 633344-1-ref.html
fails-if(Android) == 634232-1.html 634232-1-ref.html

View File

@ -1,4 +1,5 @@
== default-size.html default-size-ref.html
== size-1.html size-1-ref.html
== image-rendering-test.html image-rendering-ref.html
== image-shadow.html image-shadow-ref.html

View File

@ -0,0 +1,9 @@
<!DOCTYPE HTML>
<html>
<body>
<div style="background:lime; width:100px; height:30000px;"></div>
<script>
window.scrollTo(0, 100000);
</script>
</body>
</html>

View File

@ -0,0 +1,12 @@
<!DOCTYPE HTML>
<html>
<body>
<canvas style="display:block" id="c" width="100" height="30000"></canvas>
<script>
var ctx = document.getElementById("c").getContext("2d");
ctx.fillStyle = "lime";
ctx.fillRect(0, 0, 100, 30000);
window.scrollTo(0, 100000);
</script>
</body>
</html>

View File

@ -338,9 +338,9 @@ nsSVGGeometryFrame::SetupCairoStroke(gfxContext *aContext)
}
PRUint16
nsSVGGeometryFrame::GetHittestMask()
nsSVGGeometryFrame::GetHitTestFlags()
{
PRUint16 mask = 0;
PRUint16 flags = 0;
switch(GetStyleVisibility()->mPointerEvents) {
case NS_STYLE_POINTER_EVENTS_NONE:
@ -349,49 +349,49 @@ nsSVGGeometryFrame::GetHittestMask()
case NS_STYLE_POINTER_EVENTS_VISIBLEPAINTED:
if (GetStyleVisibility()->IsVisible()) {
if (GetStyleSVG()->mFill.mType != eStyleSVGPaintType_None)
mask |= HITTEST_MASK_FILL;
flags |= SVG_HIT_TEST_FILL;
if (GetStyleSVG()->mStroke.mType != eStyleSVGPaintType_None)
mask |= HITTEST_MASK_STROKE;
flags |= SVG_HIT_TEST_STROKE;
if (GetStyleSVG()->mStrokeOpacity > 0)
mask |= HITTEST_MASK_CHECK_MRECT;
flags |= SVG_HIT_TEST_CHECK_MRECT;
}
break;
case NS_STYLE_POINTER_EVENTS_VISIBLEFILL:
if (GetStyleVisibility()->IsVisible()) {
mask |= HITTEST_MASK_FILL;
flags |= SVG_HIT_TEST_FILL;
}
break;
case NS_STYLE_POINTER_EVENTS_VISIBLESTROKE:
if (GetStyleVisibility()->IsVisible()) {
mask |= HITTEST_MASK_STROKE;
flags |= SVG_HIT_TEST_STROKE;
}
break;
case NS_STYLE_POINTER_EVENTS_VISIBLE:
if (GetStyleVisibility()->IsVisible()) {
mask |= HITTEST_MASK_FILL | HITTEST_MASK_STROKE;
flags |= SVG_HIT_TEST_FILL | SVG_HIT_TEST_STROKE;
}
break;
case NS_STYLE_POINTER_EVENTS_PAINTED:
if (GetStyleSVG()->mFill.mType != eStyleSVGPaintType_None)
mask |= HITTEST_MASK_FILL;
flags |= SVG_HIT_TEST_FILL;
if (GetStyleSVG()->mStroke.mType != eStyleSVGPaintType_None)
mask |= HITTEST_MASK_STROKE;
flags |= SVG_HIT_TEST_STROKE;
if (GetStyleSVG()->mStrokeOpacity)
mask |= HITTEST_MASK_CHECK_MRECT;
flags |= SVG_HIT_TEST_CHECK_MRECT;
break;
case NS_STYLE_POINTER_EVENTS_FILL:
mask |= HITTEST_MASK_FILL;
flags |= SVG_HIT_TEST_FILL;
break;
case NS_STYLE_POINTER_EVENTS_STROKE:
mask |= HITTEST_MASK_STROKE;
flags |= SVG_HIT_TEST_STROKE;
break;
case NS_STYLE_POINTER_EVENTS_ALL:
mask |= HITTEST_MASK_FILL | HITTEST_MASK_STROKE;
flags |= SVG_HIT_TEST_FILL | SVG_HIT_TEST_STROKE;
break;
default:
NS_ERROR("not reached");
break;
}
return mask;
return flags;
}

View File

@ -46,9 +46,9 @@ class gfxContext;
typedef nsFrame nsSVGGeometryFrameBase;
#define HITTEST_MASK_FILL 0x01
#define HITTEST_MASK_STROKE 0x02
#define HITTEST_MASK_CHECK_MRECT 0x04
#define SVG_HIT_TEST_FILL 0x01
#define SVG_HIT_TEST_STROKE 0x02
#define SVG_HIT_TEST_CHECK_MRECT 0x04
/* nsSVGGeometryFrame is a base class for SVG objects that directly
* have geometry (circle, ellipse, line, polyline, polygon, path, and
@ -106,7 +106,14 @@ public:
protected:
nsSVGPaintServerFrame *GetPaintServer(const nsStyleSVGPaint *aPaint,
const FramePropertyDescriptor *aProperty);
virtual PRUint16 GetHittestMask();
/**
* This function returns a set of bit flags indicating which parts of the
* element (fill, stroke, bounds) should intercept pointer events. It takes
* into account the type of element and the value of the 'pointer-events'
* property on the element.
*/
virtual PRUint16 GetHitTestFlags();
private:
nsresult GetStrokeDashArray(double **arr, PRUint32 *count);

View File

@ -415,8 +415,8 @@ nsSVGGlyphFrame::PaintSVG(nsSVGRenderState *aContext,
NS_IMETHODIMP_(nsIFrame*)
nsSVGGlyphFrame::GetFrameForPoint(const nsPoint &aPoint)
{
PRUint16 mask = GetHittestMask();
if (!mask) {
PRUint16 hitTestFlags = GetHitTestFlags();
if (!hitTestFlags) {
return nsnull;
}
@ -431,7 +431,7 @@ nsSVGGlyphFrame::GetFrameForPoint(const nsPoint &aPoint)
//
// http://www.w3.org/TR/SVG11/interact.html#PointerEventsProperty
//
// Currently we just test the character cells if GetHittestMask says we're
// Currently we just test the character cells if GetHitTestFlags says we're
// supposed to be testing either the fill OR the stroke:
PRInt32 i;
@ -448,7 +448,7 @@ nsSVGGlyphFrame::GetFrameForPoint(const nsPoint &aPoint)
PresContext()->AppUnitsToGfxUnits(aPoint.y)));
PRBool isHit = PR_FALSE;
if (mask & HITTEST_MASK_FILL || mask & HITTEST_MASK_STROKE) {
if (hitTestFlags & SVG_HIT_TEST_FILL || hitTestFlags & SVG_HIT_TEST_STROKE) {
isHit = context->PointInFill(userSpacePoint);
}

View File

@ -91,7 +91,7 @@ public:
// nsSVGPathGeometryFrame methods:
NS_IMETHOD UpdateCoveredRegion();
virtual PRUint16 GetHittestMask();
virtual PRUint16 GetHitTestFlags();
// nsIFrame interface:
NS_IMETHOD AttributeChanged(PRInt32 aNameSpaceID,
@ -460,9 +460,9 @@ nsSVGImageFrame::UpdateCoveredRegion()
}
PRUint16
nsSVGImageFrame::GetHittestMask()
nsSVGImageFrame::GetHitTestFlags()
{
PRUint16 mask = 0;
PRUint16 flags = 0;
switch(GetStyleVisibility()->mPointerEvents) {
case NS_STYLE_POINTER_EVENTS_NONE:
@ -471,31 +471,31 @@ nsSVGImageFrame::GetHittestMask()
case NS_STYLE_POINTER_EVENTS_AUTO:
if (GetStyleVisibility()->IsVisible()) {
/* XXX: should check pixel transparency */
mask |= HITTEST_MASK_FILL;
flags |= SVG_HIT_TEST_FILL;
}
break;
case NS_STYLE_POINTER_EVENTS_VISIBLEFILL:
case NS_STYLE_POINTER_EVENTS_VISIBLESTROKE:
case NS_STYLE_POINTER_EVENTS_VISIBLE:
if (GetStyleVisibility()->IsVisible()) {
mask |= HITTEST_MASK_FILL;
flags |= SVG_HIT_TEST_FILL;
}
break;
case NS_STYLE_POINTER_EVENTS_PAINTED:
/* XXX: should check pixel transparency */
mask |= HITTEST_MASK_FILL;
flags |= SVG_HIT_TEST_FILL;
break;
case NS_STYLE_POINTER_EVENTS_FILL:
case NS_STYLE_POINTER_EVENTS_STROKE:
case NS_STYLE_POINTER_EVENTS_ALL:
mask |= HITTEST_MASK_FILL;
flags |= SVG_HIT_TEST_FILL;
break;
default:
NS_ERROR("not reached");
break;
}
return mask;
return flags;
}
//----------------------------------------------------------------------

View File

@ -153,14 +153,14 @@ nsSVGPathGeometryFrame::PaintSVG(nsSVGRenderState *aContext,
NS_IMETHODIMP_(nsIFrame*)
nsSVGPathGeometryFrame::GetFrameForPoint(const nsPoint &aPoint)
{
PRUint16 fillRule, mask;
PRUint16 fillRule, hitTestFlags;
if (GetStateBits() & NS_STATE_SVG_CLIPPATH_CHILD) {
mask = HITTEST_MASK_FILL;
hitTestFlags = SVG_HIT_TEST_FILL;
fillRule = GetClipRule();
} else {
mask = GetHittestMask();
if (!mask || ((mask & HITTEST_MASK_CHECK_MRECT) &&
!mRect.Contains(aPoint)))
hitTestFlags = GetHitTestFlags();
if (!hitTestFlags || ((hitTestFlags & SVG_HIT_TEST_CHECK_MRECT) &&
!mRect.Contains(aPoint)))
return nsnull;
fillRule = GetStyleSVG()->mFillRule;
}
@ -180,9 +180,9 @@ nsSVGPathGeometryFrame::GetFrameForPoint(const nsPoint &aPoint)
else
context->SetFillRule(gfxContext::FILL_RULE_WINDING);
if (mask & HITTEST_MASK_FILL)
if (hitTestFlags & SVG_HIT_TEST_FILL)
isHit = context->PointInFill(userSpacePoint);
if (!isHit && (mask & HITTEST_MASK_STROKE)) {
if (!isHit && (hitTestFlags & SVG_HIT_TEST_STROKE)) {
SetupCairoStrokeHitGeometry(context);
isHit = context->PointInStroke(userSpacePoint);
}

View File

@ -40,15 +40,6 @@
function redirect(aURL)
{
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
const Cc = Components.classes;
const Ci = Components.interfaces;
// Can't just set window.location because of security restrictions
// that don't care about our UniversalXPConnectness
var webNav = window.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIWebNavigation);
webNav.loadURI(aURL + location.search,
SpecialPowers.loadURI(window, aURL + location.search,
null, null, null, null);
}

View File

@ -500,12 +500,7 @@ class Mochitest(object):
manifest = self.addChromeToProfile(options)
self.copyExtraFilesToProfile(options)
# We only need special powers in non-chrome harnesses
if (not options.browserChrome and
not options.chrome and
not options.a11y):
self.installSpecialPowersExtension(options)
self.installSpecialPowersExtension(options)
self.installExtensionsToProfile(options)
return manifest

View File

@ -208,6 +208,12 @@ SpecialPowers.prototype = {
.createInstance(Ci.nsIXMLHttpRequest);
},
loadURI: function(window, uri, referrer, charset, x, y) {
var webNav = window.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIWebNavigation);
webNav.loadURI(uri, referrer, charset, x, y);
},
gc: function() {
this.DOMWindowUtils.garbageCollect();
},
@ -342,12 +348,9 @@ SpecialPowersManager.prototype = {
handleEvent: function handleEvent(aEvent) {
var window = aEvent.target.defaultView;
// Need to make sure we are called on what we care about -
// content windows. DOMWindowCreated is called on *all* HTMLDocuments,
// some of which belong to chrome windows or other special content.
//
// only add SpecialPowers to data pages, not about:*
var uri = window.document.documentURIObject;
if (uri.scheme === "chrome" || uri.spec.split(":")[0] == "about") {
if (uri.spec.split(":")[0] == "about") {
return;
}

View File

@ -109,7 +109,7 @@ SimpleTest.todo = function(condition, name, diag) {
SimpleTest._getCurrentTestURL = function() {
return parentRunner && parentRunner.currentTestURL ||
typeof gTestPath == "string" && gTestPath ||
"";
"unknown test url";
};
SimpleTest._logResult = function(test, passString, failString) {

View File

@ -42,13 +42,7 @@ TestRunner._urls = [];
TestRunner.timeout = 5 * 60 * 1000; // 5 minutes.
TestRunner.maxTimeouts = 4; // halt testing after too many timeouts
// running in e10s build and need to use IPC?
if (typeof SpecialPowers != 'undefined') {
TestRunner.ipcMode = SpecialPowers.hasContentProcesses();
} else {
TestRunner.ipcMode = false;
}
TestRunner.ipcMode = SpecialPowers.hasContentProcesses();
TestRunner._expectingProcessCrash = false;
/**
@ -170,9 +164,7 @@ TestRunner._makeIframe = function (url, retry) {
TestRunner.runTests = function (/*url...*/) {
TestRunner.log("SimpleTest START");
if (typeof SpecialPowers != "undefined") {
SpecialPowers.registerProcessCrashObservers();
}
SpecialPowers.registerProcessCrashObservers();
TestRunner._urls = flattenArguments(arguments);
$('testframe').src="";
@ -233,10 +225,6 @@ TestRunner.runNextTest = function() {
};
TestRunner.expectChildProcessCrash = function() {
if (typeof SpecialPowers == "undefined") {
throw "TestRunner.expectChildProcessCrash must only be called from plain mochitests.";
}
TestRunner._expectingProcessCrash = true;
};
@ -278,14 +266,10 @@ TestRunner.testFinished = function(tests) {
TestRunner.runNextTest();
}
if (typeof SpecialPowers != 'undefined') {
SpecialPowers.executeAfterFlushingMessageQueue(function() {
cleanUpCrashDumpFiles();
runNextTest();
});
} else {
SpecialPowers.executeAfterFlushingMessageQueue(function() {
cleanUpCrashDumpFiles();
runNextTest();
}
});
};
/**

View File

@ -280,6 +280,15 @@ static int EnumSizeForCocoaSize(NSControlSize cocoaControlSize) {
return regularControlSize;
}
static NSControlSize CocoaSizeForEnum(PRInt32 enumControlSize) {
if (enumControlSize == miniControlSize)
return NSMiniControlSize;
else if (enumControlSize == smallControlSize)
return NSSmallControlSize;
else
return NSRegularControlSize;
}
static void InflateControlRect(NSRect* rect, NSControlSize cocoaControlSize, const float marginSet[][3][4])
{
if (!marginSet)
@ -556,6 +565,49 @@ struct CellRenderSettings {
float margins[1][3][4];
};
/*
* This is a helper method that returns the required NSControlSize given a size
* and the size of the three controls plus a tolerance.
* size - The width or the height of the element to draw.
* sizes - An array with the all the width/height of the element for its
* different sizes.
* tolerance - The tolerance as passed to DrawCellWithSnapping.
* NOTE: returns NSRegularControlSize if all values in 'sizes' are zero.
*/
static NSControlSize FindControlSize(CGFloat size, CGFloat* sizes, CGFloat tolerance)
{
for (PRUint32 i = miniControlSize; i <= regularControlSize; ++i) {
if (sizes[i] == 0) {
continue;
}
CGFloat next = 0;
// Find next value.
for (PRUint32 j = i+1; j <= regularControlSize; ++j) {
if (sizes[j] != 0) {
next = sizes[j];
break;
}
}
// If it's the latest value, we pick it.
if (next == 0) {
return CocoaSizeForEnum(i);
}
if (size <= sizes[i] + tolerance && size < next) {
return CocoaSizeForEnum(i);
}
}
// If we are here, that means sizes[] was an array with only empty values
// or the algorithm above is wrong.
// The former can happen but the later would be wrong.
NS_ASSERTION(sizes[0] == 0 && sizes[1] == 0 && sizes[2] == 0,
"We found no control! We shouldn't be there!");
return CocoaSizeForEnum(regularControlSize);
}
/*
* Draw the given NSCell into the given cgContext with a nice control size.
*
@ -583,18 +635,12 @@ static void DrawCellWithSnapping(NSCell *cell,
const NSSize smallSize = sizes[EnumSizeForCocoaSize(NSSmallControlSize)];
const NSSize regularSize = sizes[EnumSizeForCocoaSize(NSRegularControlSize)];
NSControlSize controlSizeX = NSRegularControlSize, controlSizeY = NSRegularControlSize;
HIRect drawRect = destRect;
if (rectWidth <= miniSize.width + snapTolerance && rectWidth < smallSize.width)
controlSizeX = NSMiniControlSize;
else if(rectWidth <= smallSize.width + snapTolerance && rectWidth < regularSize.width)
controlSizeX = NSSmallControlSize;
if (rectHeight <= miniSize.height + snapTolerance && rectHeight < smallSize.height)
controlSizeY = NSMiniControlSize;
else if(rectHeight <= smallSize.height + snapTolerance && rectHeight < regularSize.height)
controlSizeY = NSSmallControlSize;
CGFloat controlWidths[3] = { miniSize.width, smallSize.width, regularSize.width };
NSControlSize controlSizeX = FindControlSize(rectWidth, controlWidths, snapTolerance);
CGFloat controlHeights[3] = { miniSize.height, smallSize.height, regularSize.height };
NSControlSize controlSizeY = FindControlSize(rectHeight, controlHeights, snapTolerance);
NSControlSize controlSize = NSRegularControlSize;
int sizeIndex = 0;