Bug 984796: Fix some small errors in path flattening code. r=jwatt

This commit is contained in:
Bas Schouten 2014-03-22 00:55:36 +01:00
parent e4556546fd
commit 8294a52e33
3 changed files with 32 additions and 4 deletions

View File

@ -10,6 +10,15 @@
namespace mozilla {
namespace gfx {
static float CubicRoot(float aValue) {
if (aValue < 0.0) {
return -CubicRoot(-aValue);
}
else {
return powf(aValue, 1.0f / 3.0f);
}
}
struct BezierControlPoints
{
BezierControlPoints() {}
@ -269,8 +278,8 @@ FindInflectionApproximationRange(BezierControlPoints aControlPoints,
if (cp21.x == 0 && cp21.y == 0) {
// In this case s3 becomes lim[n->0] (cp41.x * n) / n - (cp41.y * n) / n = cp41.x - cp41.y.
*aMin = aT - pow(aTolerance / (cp41.x - cp41.y), Float(1. / 3.));
*aMax = aT + pow(aTolerance / (cp41.x - cp41.y), Float(1. / 3.));;
*aMin = aT - CubicRoot(double(aTolerance / (cp41.x - cp41.y)));
*aMax = aT + CubicRoot(aTolerance / (cp41.x - cp41.y));
return;
}
@ -285,7 +294,7 @@ FindInflectionApproximationRange(BezierControlPoints aControlPoints,
return;
}
Float tf = pow(abs(aTolerance / s3), Float(1. / 3.));
Float tf = CubicRoot(abs(aTolerance / s3));
*aMin = aT - tf * (1 - aT);
*aMax = aT + tf * (1 - aT);
@ -445,7 +454,7 @@ FlattenBezier(const BezierControlPoints &aControlPoints,
&remainingCP, t1min);
FlattenBezierCurveSegment(prevCPs, aSink, aTolerance);
}
if (t1max < 1.0 && (count == 1 || t2min > t1max)) {
if (t1max >= 0 && t1max < 1.0 && (count == 1 || t2min > t1max)) {
// The second inflection point's approximation range begins after the end
// of the first, approximate the first inflection point by a line and
// subsequently flatten up until the end or the next inflection point.

View File

@ -213,10 +213,21 @@ ClientLayerManager::EndTransaction(DrawThebesLayerCallback aCallback,
if (mWidget) {
mWidget->PrepareWindowEffects();
}
printf_stderr("XXX - Bas - Wanting to draw client side!");
FlushRendering();
printf_stderr("XXX - Bas - Starting to draw client side!");
EndTransactionInternal(aCallback, aCallbackData, aFlags);
printf_stderr("XXX - Bas - Finished validation!");
ForwardTransaction(!(aFlags & END_NO_REMOTE_COMPOSITE));
if (mRepeatTransaction) {
printf_stderr("XXX - Bas - Repeating transaction!");
mRepeatTransaction = false;
mIsRepeatTransaction = true;
BeginTransaction();
@ -229,6 +240,8 @@ ClientLayerManager::EndTransaction(DrawThebesLayerCallback aCallback,
for (size_t i = 0; i < mTexturePools.Length(); i++) {
mTexturePools[i]->ReturnDeferredClients();
}
printf_stderr("XXX - Bas - Finished drawing client side!");
}
bool
@ -412,6 +425,8 @@ ClientLayerManager::ForwardTransaction(bool aScheduleComposite)
NS_WARNING("failed to forward Layers transaction");
}
printf_stderr("XXX - Bas - Forwarded transaction!");
mForwarder->RemoveTexturesIfNecessary();
mPhase = PHASE_NONE;

View File

@ -207,6 +207,8 @@ LayerManagerComposite::EndTransaction(DrawThebesLayerCallback aCallback,
NS_ASSERTION(!aCallback && !aCallbackData, "Not expecting callbacks here");
mInTransaction = false;
printf_stderr("XXX - Bas - Starting to draw host side!");
if (!mIsCompositorReady) {
return;
}
@ -252,6 +254,8 @@ LayerManagerComposite::EndTransaction(DrawThebesLayerCallback aCallback,
Log();
MOZ_LAYERS_LOG(("]----- EndTransaction"));
#endif
printf_stderr("XXX - Bas - Finished compositing host side!");
}
already_AddRefed<gfxASurface>