mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-25 22:01:30 +00:00
Bug 933549. Preqrequisites - Matrix::HasNonIntegerTranslation and SetAntialiasingFlags. r=mattwoodrow
This commit is contained in:
parent
7cfa650c85
commit
d0f667997d
@ -156,6 +156,25 @@ public:
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the matrix is anything other than a straight
|
||||
* translation by integers.
|
||||
*/
|
||||
bool HasNonIntegerTranslation() const {
|
||||
return HasNonTranslation() ||
|
||||
!FuzzyEqual(_31, floor(_31 + 0.5)) ||
|
||||
!FuzzyEqual(_32, floor(_32 + 0.5));
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the matrix has any transform other
|
||||
* than a straight translation.
|
||||
*/
|
||||
bool HasNonTranslation() const {
|
||||
return !FuzzyEqual(_11, 1.0) || !FuzzyEqual(_22, 1.0) ||
|
||||
!FuzzyEqual(_12, 0.0) || !FuzzyEqual(_21, 0.0);
|
||||
}
|
||||
|
||||
/* Returns true if the matrix is an identity matrix.
|
||||
*/
|
||||
bool IsIdentity() const
|
||||
|
@ -1497,41 +1497,46 @@ PrintInfo(nsACString& aTo, LayerComposite* aLayerComposite)
|
||||
return aTo;
|
||||
}
|
||||
|
||||
void
|
||||
SetAntialiasingFlags(Layer* aLayer, DrawTarget* aTarget)
|
||||
{
|
||||
if (aTarget->GetFormat() != FORMAT_B8G8R8A8) {
|
||||
aTarget->SetPermitSubpixelAA(permitSubpixelAA);
|
||||
return;
|
||||
}
|
||||
|
||||
const nsIntRect& bounds = aLayer->GetVisibleRegion().GetBounds();
|
||||
gfx::Rect transformedBounds = aTarget->GetTransform().TransformBounds(gfx::Rect(Float(bounds.x), Float(bounds.y),
|
||||
Float(bounds.width), Float(bounds.height)));
|
||||
transformedBounds.RoundOut();
|
||||
IntRect intTransformedBounds;
|
||||
transformedBounds.ToIntRect(&intTransformedBounds);
|
||||
permitSubpixelAA &= !(aLayer->GetContentFlags() & Layer::CONTENT_COMPONENT_ALPHA) ||
|
||||
aTarget->GetOpaqueRect().Contains(intTransformedBounds);
|
||||
aTarget->SetPermitSubpixelAA(permitSubpixelAA);
|
||||
}
|
||||
|
||||
void
|
||||
SetAntialiasingFlags(Layer* aLayer, gfxContext* aTarget)
|
||||
{
|
||||
bool permitSubpixelAA = !(aLayer->GetContentFlags() & Layer::CONTENT_DISABLE_SUBPIXEL_AA);
|
||||
if (!aTarget->IsCairo()) {
|
||||
RefPtr<DrawTarget> dt = aTarget->GetDrawTarget();
|
||||
|
||||
if (dt->GetFormat() != FORMAT_B8G8R8A8) {
|
||||
dt->SetPermitSubpixelAA(permitSubpixelAA);
|
||||
return;
|
||||
}
|
||||
|
||||
const nsIntRect& bounds = aLayer->GetVisibleRegion().GetBounds();
|
||||
gfx::Rect transformedBounds = dt->GetTransform().TransformBounds(gfx::Rect(Float(bounds.x), Float(bounds.y),
|
||||
Float(bounds.width), Float(bounds.height)));
|
||||
transformedBounds.RoundOut();
|
||||
IntRect intTransformedBounds;
|
||||
transformedBounds.ToIntRect(&intTransformedBounds);
|
||||
permitSubpixelAA &= !(aLayer->GetContentFlags() & Layer::CONTENT_COMPONENT_ALPHA) ||
|
||||
dt->GetOpaqueRect().Contains(intTransformedBounds);
|
||||
dt->SetPermitSubpixelAA(permitSubpixelAA);
|
||||
} else {
|
||||
nsRefPtr<gfxASurface> surface = aTarget->CurrentSurface();
|
||||
if (surface->GetContentType() != GFX_CONTENT_COLOR_ALPHA) {
|
||||
// Destination doesn't have alpha channel; no need to set any special flags
|
||||
surface->SetSubpixelAntialiasingEnabled(permitSubpixelAA);
|
||||
return;
|
||||
}
|
||||
|
||||
const nsIntRect& bounds = aLayer->GetVisibleRegion().GetBounds();
|
||||
permitSubpixelAA &= !(aLayer->GetContentFlags() & Layer::CONTENT_COMPONENT_ALPHA) ||
|
||||
surface->GetOpaqueRect().Contains(
|
||||
aTarget->UserToDevice(gfxRect(bounds.x, bounds.y, bounds.width, bounds.height)));
|
||||
surface->SetSubpixelAntialiasingEnabled(permitSubpixelAA);
|
||||
SetAntialiasingFlags(aLayer, aTarget->GetDrawTarget());
|
||||
return;
|
||||
}
|
||||
|
||||
nsRefPtr<gfxASurface> surface = aTarget->CurrentSurface();
|
||||
if (surface->GetContentType() != GFX_CONTENT_COLOR_ALPHA) {
|
||||
// Destination doesn't have alpha channel; no need to set any special flags
|
||||
surface->SetSubpixelAntialiasingEnabled(permitSubpixelAA);
|
||||
return;
|
||||
}
|
||||
|
||||
const nsIntRect& bounds = aLayer->GetVisibleRegion().GetBounds();
|
||||
permitSubpixelAA &= !(aLayer->GetContentFlags() & Layer::CONTENT_COMPONENT_ALPHA) ||
|
||||
surface->GetOpaqueRect().Contains(
|
||||
aTarget->UserToDevice(gfxRect(bounds.x, bounds.y, bounds.width, bounds.height)));
|
||||
surface->SetSubpixelAntialiasingEnabled(permitSubpixelAA);
|
||||
}
|
||||
|
||||
PRLogModuleInfo* LayerManager::sLog;
|
||||
|
@ -2042,8 +2042,8 @@ protected:
|
||||
uint64_t mId;
|
||||
};
|
||||
|
||||
void
|
||||
SetAntialiasingFlags(Layer* aLayer, gfxContext* aTarget);
|
||||
void SetAntialiasingFlags(Layer* aLayer, gfxContext* aTarget);
|
||||
void SetAntialiasingFlags(Layer* aLayer, gfx::DrawTarget* aTarget);
|
||||
|
||||
#ifdef MOZ_DUMP_PAINTING
|
||||
void WriteSnapshotToDumpFile(Layer* aLayer, gfxASurface* aSurf);
|
||||
|
Loading…
Reference in New Issue
Block a user