зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1085167, part 2 - Get rid of nsRenderingContext's DeviceContext and any need for it to know about app-units-per-device-pixel. r=mattwoodrow
--HG-- extra : rebase_source : d8fb804f03a1cc4635d6acd7f66f5f21962de6d3
This commit is contained in:
Родитель
67d66c6dc4
Коммит
e3bd1068b9
|
@ -410,7 +410,7 @@ nsDeviceContext::CreateRenderingContext()
|
|||
dt->AddUserData(&gfxContext::sDontUseAsSourceKey, dt, nullptr);
|
||||
#endif
|
||||
|
||||
pContext->Init(this, dt);
|
||||
pContext->Init(dt);
|
||||
pContext->GetDrawTarget()->AddUserData(&sDisablePixelSnapping,
|
||||
(void*)0x1, nullptr);
|
||||
pContext->ThebesContext()->SetMatrix(gfxMatrix::Scaling(mPrintingScale,
|
||||
|
|
|
@ -20,12 +20,6 @@
|
|||
#include "nsRect.h" // for nsRect, nsIntRect
|
||||
#include "nsRegion.h" // for nsIntRegionRectIterator, etc
|
||||
|
||||
// XXXTodo: rename FORM_TWIPS to FROM_APPUNITS
|
||||
#define FROM_TWIPS(_x) ((gfxFloat)((_x)/(mP2A)))
|
||||
#define FROM_TWIPS_INT(_x) (NSToIntRound((gfxFloat)((_x)/(mP2A))))
|
||||
#define TO_TWIPS(_x) ((nscoord)((_x)*(mP2A)))
|
||||
#define GFX_RECT_FROM_TWIPS_RECT(_r) (gfxRect(FROM_TWIPS((_r).x), FROM_TWIPS((_r).y), FROM_TWIPS((_r).width), FROM_TWIPS((_r).height)))
|
||||
|
||||
// Hard limit substring lengths to 8000 characters ... this lets us statically
|
||||
// size the cluster buffer array in FindSafeLength
|
||||
#define MAX_GFX_TEXT_BUF_SIZE 8000
|
||||
|
@ -64,21 +58,16 @@ static int32_t FindSafeLength(const char *aString, uint32_t aLength,
|
|||
//// nsRenderingContext
|
||||
|
||||
void
|
||||
nsRenderingContext::Init(nsDeviceContext* aContext,
|
||||
gfxContext *aThebesContext)
|
||||
nsRenderingContext::Init(gfxContext *aThebesContext)
|
||||
{
|
||||
mDeviceContext = aContext;
|
||||
mThebes = aThebesContext;
|
||||
|
||||
mThebes->SetLineWidth(1.0);
|
||||
mP2A = mDeviceContext->AppUnitsPerDevPixel();
|
||||
}
|
||||
|
||||
void
|
||||
nsRenderingContext::Init(nsDeviceContext* aContext,
|
||||
DrawTarget *aDrawTarget)
|
||||
nsRenderingContext::Init(DrawTarget *aDrawTarget)
|
||||
{
|
||||
Init(aContext, new gfxContext(aDrawTarget));
|
||||
Init(new gfxContext(aDrawTarget));
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -15,7 +15,6 @@
|
|||
#include "nsBoundingMetrics.h" // for nsBoundingMetrics
|
||||
#include "nsColor.h" // for nscolor
|
||||
#include "nsCoord.h" // for nscoord, NSToIntRound
|
||||
#include "nsDeviceContext.h" // for nsDeviceContext
|
||||
#include "nsFontMetrics.h" // for nsFontMetrics
|
||||
#include "nsISupports.h" // for NS_INLINE_DECL_REFCOUNTING, etc
|
||||
#include "nsString.h" // for nsString
|
||||
|
@ -30,22 +29,16 @@ class nsRenderingContext MOZ_FINAL
|
|||
typedef mozilla::gfx::DrawTarget DrawTarget;
|
||||
|
||||
public:
|
||||
nsRenderingContext() : mP2A(0.) {}
|
||||
nsRenderingContext() {}
|
||||
|
||||
NS_INLINE_DECL_REFCOUNTING(nsRenderingContext)
|
||||
|
||||
void Init(nsDeviceContext* aContext, gfxContext* aThebesContext);
|
||||
void Init(nsDeviceContext* aContext, DrawTarget* aDrawTarget);
|
||||
void Init(gfxContext* aThebesContext);
|
||||
void Init(DrawTarget* aDrawTarget);
|
||||
|
||||
// These accessors will never return null.
|
||||
gfxContext *ThebesContext() { return mThebes; }
|
||||
DrawTarget *GetDrawTarget() { return mThebes->GetDrawTarget(); }
|
||||
nsDeviceContext *DeviceContext() { return mDeviceContext; }
|
||||
|
||||
int32_t AppUnitsPerDevPixel() const {
|
||||
// we know this is an int (it's stored as a double for convenience)
|
||||
return int32_t(mP2A);
|
||||
}
|
||||
|
||||
// Text
|
||||
|
||||
|
@ -79,10 +72,7 @@ private:
|
|||
int32_t GetMaxChunkLength();
|
||||
|
||||
nsRefPtr<gfxContext> mThebes;
|
||||
nsRefPtr<nsDeviceContext> mDeviceContext;
|
||||
nsRefPtr<nsFontMetrics> mFontMetrics;
|
||||
|
||||
double mP2A; // cached app units per device pixel value
|
||||
};
|
||||
|
||||
#endif // NSRENDERINGCONTEXT__H__
|
||||
|
|
|
@ -4212,7 +4212,7 @@ static void DebugPaintItem(nsRenderingContext* aDest,
|
|||
nsRefPtr<gfxContext> context = new gfxContext(tempDT);
|
||||
context->SetMatrix(gfxMatrix::Translation(-gfxPoint(bounds.x, bounds.y)));
|
||||
nsRefPtr<nsRenderingContext> ctx = new nsRenderingContext();
|
||||
ctx->Init(aDest->DeviceContext(), context);
|
||||
ctx->Init(context);
|
||||
|
||||
aItem->Paint(aBuilder, ctx);
|
||||
RefPtr<SourceSurface> surface = tempDT->Snapshot();
|
||||
|
@ -4479,7 +4479,7 @@ FrameLayerBuilder::DrawPaintedLayer(PaintedLayer* aLayer,
|
|||
}
|
||||
|
||||
nsRefPtr<nsRenderingContext> rc = new nsRenderingContext();
|
||||
rc->Init(presContext->DeviceContext(), aContext);
|
||||
rc->Init(aContext);
|
||||
|
||||
if (shouldDrawRectsSeparately) {
|
||||
nsIntRegionRectIterator it(aRegionToDraw);
|
||||
|
|
|
@ -1313,7 +1313,7 @@ nsCSSRendering::PaintBoxShadowOuter(nsPresContext* aPresContext,
|
|||
// Draw the widget shape
|
||||
gfxContextMatrixAutoSaveRestore save(shadowContext);
|
||||
nsRefPtr<nsRenderingContext> wrapperCtx = new nsRenderingContext();
|
||||
wrapperCtx->Init(aPresContext->DeviceContext(), shadowContext);
|
||||
wrapperCtx->Init(shadowContext);
|
||||
gfxPoint devPixelOffset =
|
||||
nsLayoutUtils::PointToGfxPoint(nsPoint(shadowItem->mXOffset,
|
||||
shadowItem->mYOffset),
|
||||
|
|
|
@ -4710,7 +4710,7 @@ nsLayoutUtils::PaintTextShadow(const nsIFrame* aFrame,
|
|||
// Conjure an nsRenderingContext from a gfxContext for drawing the text
|
||||
// to blur.
|
||||
nsRefPtr<nsRenderingContext> renderingContext = new nsRenderingContext();
|
||||
renderingContext->Init(presCtx->DeviceContext(), shadowContext);
|
||||
renderingContext->Init(shadowContext);
|
||||
|
||||
aDestCtx->Save();
|
||||
aDestCtx->NewPath();
|
||||
|
|
|
@ -3071,7 +3071,7 @@ PresShell::CreateReferenceRenderingContext()
|
|||
nsRefPtr<nsRenderingContext> rc;
|
||||
if (mPresContext->IsScreen()) {
|
||||
rc = new nsRenderingContext();
|
||||
rc->Init(devCtx, gfxPlatform::GetPlatform()->ScreenReferenceDrawTarget());
|
||||
rc->Init(gfxPlatform::GetPlatform()->ScreenReferenceDrawTarget());
|
||||
} else {
|
||||
rc = devCtx->CreateRenderingContext();
|
||||
}
|
||||
|
@ -4807,7 +4807,7 @@ PresShell::RenderDocument(const nsRect& aRect, uint32_t aFlags,
|
|||
AutoSaveRestoreRenderingState _(this);
|
||||
|
||||
nsRefPtr<nsRenderingContext> rc = new nsRenderingContext();
|
||||
rc->Init(devCtx, aThebesContext);
|
||||
rc->Init(aThebesContext);
|
||||
|
||||
bool wouldFlushRetainedLayers = false;
|
||||
uint32_t flags = nsLayoutUtils::PAINT_IGNORE_SUPPRESSION;
|
||||
|
@ -5061,8 +5061,6 @@ PresShell::PaintRangePaintInfo(nsTArray<nsAutoPtr<RangePaintInfo> >* aItems,
|
|||
if (!pc || aArea.width == 0 || aArea.height == 0)
|
||||
return nullptr;
|
||||
|
||||
nsDeviceContext* deviceContext = pc->DeviceContext();
|
||||
|
||||
// use the rectangle to create the surface
|
||||
nsIntRect pixelArea = aArea.ToOutsidePixels(pc->AppUnitsPerDevPixel());
|
||||
|
||||
|
@ -5075,7 +5073,7 @@ PresShell::PaintRangePaintInfo(nsTArray<nsAutoPtr<RangePaintInfo> >* aItems,
|
|||
// if the image is larger in one or both directions than half the size of
|
||||
// the available screen area, scale the image down to that size.
|
||||
nsRect maxSize;
|
||||
deviceContext->GetClientRect(maxSize);
|
||||
pc->DeviceContext()->GetClientRect(maxSize);
|
||||
nscoord maxWidth = pc->AppUnitsToDevPixels(maxSize.width >> 1);
|
||||
nscoord maxHeight = pc->AppUnitsToDevPixels(maxSize.height >> 1);
|
||||
bool resize = (pixelArea.width > maxWidth || pixelArea.height > maxHeight);
|
||||
|
@ -5128,7 +5126,7 @@ PresShell::PaintRangePaintInfo(nsTArray<nsAutoPtr<RangePaintInfo> >* aItems,
|
|||
}
|
||||
|
||||
nsRefPtr<nsRenderingContext> rc = new nsRenderingContext();
|
||||
rc->Init(deviceContext, ctx);
|
||||
rc->Init(ctx);
|
||||
|
||||
gfxMatrix initialTM = ctx->CurrentMatrix();
|
||||
|
||||
|
|
|
@ -300,7 +300,7 @@ nsDisplayCanvasBackgroundImage::Paint(nsDisplayListBuilder* aBuilder,
|
|||
ctx->SetMatrix(
|
||||
ctx->CurrentMatrix().Translate(-destRect.x, -destRect.y));
|
||||
context = new nsRenderingContext();
|
||||
context->Init(aCtx->DeviceContext(), ctx);
|
||||
context->Init(ctx);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
#include "nsPageFrame.h"
|
||||
|
||||
#include "mozilla/gfx/2D.h"
|
||||
#include "nsDeviceContext.h"
|
||||
#include "nsLayoutUtils.h"
|
||||
#include "nsPresContext.h"
|
||||
#include "nsRenderingContext.h"
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
#include "nsSimplePageSequenceFrame.h"
|
||||
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsDeviceContext.h"
|
||||
#include "nsPresContext.h"
|
||||
#include "gfxContext.h"
|
||||
#include "nsRenderingContext.h"
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
#include "mozilla/MathAlgorithms.h"
|
||||
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsDeviceContext.h"
|
||||
#include "nsIFrame.h"
|
||||
#include "nsLayoutUtils.h"
|
||||
#include "nsPresContext.h"
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
#include "mozilla/Likely.h"
|
||||
#include "mozilla/LookAndFeel.h"
|
||||
|
||||
#include "nsDeviceContext.h"
|
||||
#include "nsRuleNode.h"
|
||||
#include "nscore.h"
|
||||
#include "nsIWidget.h"
|
||||
|
|
|
@ -449,7 +449,7 @@ nsFilterInstance::BuildSourceImage(DrawTarget* aTargetDT)
|
|||
PreMultiply(deviceToFilterSpace));
|
||||
|
||||
nsRefPtr<nsRenderingContext> tmpCtx(new nsRenderingContext());
|
||||
tmpCtx->Init(mTargetFrame->PresContext()->DeviceContext(), ctx);
|
||||
tmpCtx->Init(ctx);
|
||||
mPaintCallback->Paint(tmpCtx, mTargetFrame, mPaintTransform, &dirty);
|
||||
|
||||
mSourceGraphic.mSourceSurface = offscreenDT->Snapshot();
|
||||
|
|
|
@ -642,7 +642,7 @@ PaintFrameCallback::operator()(gfxContext* aContext,
|
|||
mFrame->AddStateBits(NS_FRAME_DRAWING_AS_PAINTSERVER);
|
||||
|
||||
nsRefPtr<nsRenderingContext> context(new nsRenderingContext());
|
||||
context->Init(mFrame->PresContext()->DeviceContext(), aContext);
|
||||
context->Init(aContext);
|
||||
aContext->Save();
|
||||
|
||||
// Clip to aFillRect so that we don't paint outside.
|
||||
|
|
|
@ -227,7 +227,7 @@ nsSVGMaskFrame::GetMaskForMaskedFrame(gfxContext* aContext,
|
|||
aContext->CurrentMatrix() * gfxMatrix::Translation(-maskSurfaceRect.TopLeft());
|
||||
|
||||
nsRefPtr<nsRenderingContext> tmpCtx = new nsRenderingContext();
|
||||
tmpCtx->Init(this->PresContext()->DeviceContext(), maskDT);
|
||||
tmpCtx->Init(maskDT);
|
||||
tmpCtx->ThebesContext()->SetMatrix(maskSurfaceMatrix);
|
||||
|
||||
mMatrixForChildren = GetMaskTransform(aMaskedFrame) * aMatrix;
|
||||
|
|
|
@ -379,7 +379,7 @@ nsSVGPatternFrame::PaintPattern(const DrawTarget* aDrawTarget,
|
|||
}
|
||||
|
||||
nsRefPtr<nsRenderingContext> context(new nsRenderingContext());
|
||||
context->Init(aSource->PresContext()->DeviceContext(), dt);
|
||||
context->Init(dt);
|
||||
gfxContext* gfx = context->ThebesContext();
|
||||
|
||||
// Fill with transparent black
|
||||
|
|
|
@ -1589,7 +1589,7 @@ nsSVGUtils::PaintSVGGlyph(Element* aElement, gfxContext* aContext,
|
|||
aContext->GetDrawTarget()->AddUserData(&gfxTextContextPaint::sUserDataKey,
|
||||
aContextPaint, nullptr);
|
||||
nsRefPtr<nsRenderingContext> context(new nsRenderingContext());
|
||||
context->Init(frame->PresContext()->DeviceContext(), aContext);
|
||||
context->Init(aContext);
|
||||
svgFrame->NotifySVGChanged(nsISVGChildFrame::TRANSFORM_CHANGED);
|
||||
gfxMatrix m;
|
||||
if (frame->GetContent()->IsSVG()) {
|
||||
|
|
|
@ -4,6 +4,8 @@
|
|||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "nsNativeThemeCocoa.h"
|
||||
|
||||
#include "nsDeviceContext.h"
|
||||
#include "nsObjCExceptions.h"
|
||||
#include "nsNumberControlFrame.h"
|
||||
#include "nsRangeFrame.h"
|
||||
|
|
|
@ -4,8 +4,10 @@
|
|||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "nsNativeThemeWin.h"
|
||||
|
||||
#include "mozilla/EventStates.h"
|
||||
#include "mozilla/WindowsVersion.h"
|
||||
#include "nsDeviceContext.h"
|
||||
#include "nsRenderingContext.h"
|
||||
#include "nsRect.h"
|
||||
#include "nsSize.h"
|
||||
|
|
Загрузка…
Ссылка в новой задаче