Bug 598531 - pixman hitting slow path. disable scaling. r=roc a=blocking-fennec

This commit is contained in:
Oleg Romashin 2010-09-23 16:06:27 -07:00
Родитель fc9f34a329
Коммит 05caed919c
4 изменённых файлов: 40 добавлений и 15 удалений

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

@ -106,11 +106,23 @@ ThebesLayerBuffer::DrawBufferQuadrant(gfxContext* aTarget,
pattern->SetFilter(filter);
#endif
gfxContextMatrixAutoSaveRestore saveMatrix(aTarget);
// Transform from user -> buffer space.
gfxMatrix transform;
transform.Scale(aXRes, aYRes);
transform.Translate(-quadrantTranslation);
// in common cases the matrix after scaling by 1/aRes is close to 1.0,
// so we want to make it 1.0 in both cases
transform.Scale(1.0 / aXRes, 1.0 / aYRes);
transform.NudgeToIntegers();
gfxMatrix ctxMatrix = aTarget->CurrentMatrix();
ctxMatrix.Scale(1.0 / aXRes, 1.0 / aYRes);
ctxMatrix.NudgeToIntegers();
aTarget->SetMatrix(ctxMatrix);
pattern->SetMatrix(transform);
aTarget->SetPattern(pattern);

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

@ -318,26 +318,12 @@ gfxContext::CurrentMatrix() const
return gfxMatrix(*reinterpret_cast<gfxMatrix*>(&mat));
}
static void NudgeToInteger(double *aVal)
{
float f = float(*aVal);
float r = NS_roundf(f);
if (f == r) {
*aVal = r;
}
}
void
gfxContext::NudgeCurrentMatrixToIntegers()
{
cairo_matrix_t mat;
cairo_get_matrix(mCairo, &mat);
NudgeToInteger(&mat.xx);
NudgeToInteger(&mat.xy);
NudgeToInteger(&mat.yx);
NudgeToInteger(&mat.yy);
NudgeToInteger(&mat.x0);
NudgeToInteger(&mat.y0);
gfxMatrix(*reinterpret_cast<gfxMatrix*>(&mat)).NudgeToIntegers();
cairo_set_matrix(mCairo, &mat);
}

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

@ -193,3 +193,23 @@ gfx3DMatrix::Is2D(gfxMatrix* aMatrix) const
}
return PR_TRUE;
}
static void NudgeToInteger(double *aVal)
{
float f = float(*aVal);
float r = NS_roundf(f);
if (f == r) {
*aVal = r;
}
}
void
gfxMatrix::NudgeToIntegers(void)
{
NudgeToInteger(&xx);
NudgeToInteger(&xy);
NudgeToInteger(&yx);
NudgeToInteger(&yy);
NudgeToInteger(&x0);
NudgeToInteger(&y0);
}

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

@ -258,6 +258,13 @@ public:
return gfxSize(minor, major);
}
/**
* Snap matrix components that are close to integers
* to integers. In particular, components that are integral when
* converted to single precision are set to those integers.
*/
void NudgeToIntegers(void);
private:
static PRBool FuzzyEqual(gfxFloat aV1, gfxFloat aV2) {
return fabs(aV2 - aV1) < 1e-6;