зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1082530, part 3 - Get rid of gfxContext::FLAG_DISABLE_SNAPPING and use DrawTarget UserData to store information on whether to disable pixel snapping. r=mattwoodrow
This commit is contained in:
Родитель
2e12270def
Коммит
5a3d8c69bd
|
@ -34,6 +34,7 @@
|
|||
#include "mozilla/gfx/BasePoint.h" // for BasePoint
|
||||
#include "mozilla/gfx/BaseRect.h" // for BaseRect
|
||||
#include "mozilla/gfx/Matrix.h" // for Matrix
|
||||
#include "mozilla/gfx/PathHelpers.h"
|
||||
#include "mozilla/gfx/Rect.h" // for IntRect, Rect
|
||||
#include "mozilla/layers/LayersTypes.h" // for BufferMode::BUFFER_NONE, etc
|
||||
#include "mozilla/mozalloc.h" // for operator new
|
||||
|
@ -486,8 +487,12 @@ BasicLayerManager::EndTransactionInternal(DrawPaintedLayerCallback aCallback,
|
|||
if (mRoot) {
|
||||
// Need to do this before we call ApplyDoubleBuffering,
|
||||
// which depends on correct effective transforms
|
||||
mSnapEffectiveTransforms =
|
||||
mTarget ? !(mTarget->GetFlags() & gfxContext::FLAG_DISABLE_SNAPPING) : true;
|
||||
if (mTarget) {
|
||||
mSnapEffectiveTransforms =
|
||||
!mTarget->GetDrawTarget()->GetUserData(&sDisablePixelSnapping);
|
||||
} else {
|
||||
mSnapEffectiveTransforms = true;
|
||||
}
|
||||
mRoot->ComputeEffectiveTransforms(mTarget ? Matrix4x4::From2D(ToMatrix(mTarget->CurrentMatrix())) : Matrix4x4());
|
||||
|
||||
ToData(mRoot)->Validate(aCallback, aCallbackData, nullptr);
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
#include "gfxImageSurface.h" // for gfxImageSurface
|
||||
#include "gfxPoint.h" // for gfxSize
|
||||
#include "mozilla/Attributes.h" // for MOZ_FINAL
|
||||
#include "mozilla/gfx/PathHelpers.h"
|
||||
#include "mozilla/Preferences.h" // for Preferences
|
||||
#include "mozilla/Services.h" // for GetObserverService
|
||||
#include "mozilla/mozalloc.h" // for operator new
|
||||
|
@ -48,6 +49,7 @@
|
|||
#endif
|
||||
|
||||
using namespace mozilla;
|
||||
using namespace mozilla::gfx;
|
||||
using mozilla::services::GetObserverService;
|
||||
|
||||
class nsFontCache MOZ_FINAL : public nsIObserver
|
||||
|
@ -409,7 +411,8 @@ nsDeviceContext::CreateRenderingContext()
|
|||
#endif
|
||||
|
||||
pContext->Init(this, dt);
|
||||
pContext->ThebesContext()->SetFlag(gfxContext::FLAG_DISABLE_SNAPPING);
|
||||
pContext->GetDrawTarget()->AddUserData(&sDisablePixelSnapping,
|
||||
(void*)0x1, nullptr);
|
||||
pContext->ThebesContext()->SetMatrix(gfxMatrix::Scaling(mPrintingScale,
|
||||
mPrintingScale));
|
||||
|
||||
|
|
|
@ -88,7 +88,6 @@ gfxContext::gfxContext(DrawTarget *aTarget, const Point& aDeviceOffset)
|
|||
: mPathIsRect(false)
|
||||
, mTransformChanged(false)
|
||||
, mRefCairo(nullptr)
|
||||
, mFlags(0)
|
||||
, mDT(aTarget)
|
||||
, mOriginalDT(aTarget)
|
||||
{
|
||||
|
@ -489,7 +488,7 @@ gfxContext::UserToDevice(const gfxRect& rect) const
|
|||
bool
|
||||
gfxContext::UserToDevicePixelSnapped(gfxRect& rect, bool ignoreScale) const
|
||||
{
|
||||
if (GetFlags() & FLAG_DISABLE_SNAPPING)
|
||||
if (mDT->GetUserData(&sDisablePixelSnapping))
|
||||
return false;
|
||||
|
||||
// if we're not at 1.0 scale, don't snap, unless we're
|
||||
|
@ -530,7 +529,7 @@ gfxContext::UserToDevicePixelSnapped(gfxRect& rect, bool ignoreScale) const
|
|||
bool
|
||||
gfxContext::UserToDevicePixelSnapped(gfxPoint& pt, bool ignoreScale) const
|
||||
{
|
||||
if (GetFlags() & FLAG_DISABLE_SNAPPING)
|
||||
if (mDT->GetUserData(&sDisablePixelSnapping))
|
||||
return false;
|
||||
|
||||
// if we're not at 1.0 scale, don't snap, unless we're
|
||||
|
|
|
@ -576,18 +576,6 @@ public:
|
|||
|
||||
mozilla::gfx::Point GetDeviceOffset() const;
|
||||
|
||||
enum {
|
||||
/**
|
||||
* When this flag is set, snapping to device pixels is disabled.
|
||||
* It simply never does anything.
|
||||
*/
|
||||
FLAG_DISABLE_SNAPPING = (1 << 1),
|
||||
};
|
||||
|
||||
void SetFlag(int32_t aFlag) { mFlags |= aFlag; }
|
||||
void ClearFlag(int32_t aFlag) { mFlags &= ~aFlag; }
|
||||
int32_t GetFlags() const { return mFlags; }
|
||||
|
||||
// Work out whether cairo will snap inter-glyph spacing to pixels.
|
||||
void GetRoundOffsetsToPixels(bool *aRoundX, bool *aRoundY);
|
||||
|
||||
|
@ -695,7 +683,6 @@ private:
|
|||
const AzureState &CurrentState() const { return mStateStack[mStateStack.Length() - 1]; }
|
||||
|
||||
cairo_t *mRefCairo;
|
||||
int32_t mFlags;
|
||||
|
||||
mozilla::RefPtr<DrawTarget> mDT;
|
||||
mozilla::RefPtr<DrawTarget> mOriginalDT;
|
||||
|
|
Загрузка…
Ссылка в новой задаче