зеркало из https://github.com/mozilla/pjs.git
Bug 651017, part 7: remove nsDeviceContext::CreateRenderingContextInstance and the CreateRenderingContext overload that takes a widget.
--HG-- rename : gfx/src/nsThebesDeviceContext.cpp => gfx/src/nsDeviceContext.cpp rename : gfx/src/nsThebesDeviceContext.h => gfx/src/nsDeviceContext.h extra : rebase_source : 6be7fe432488dcf2fb5b2faa0e178dccab480285
This commit is contained in:
Родитель
b69bb8a5da
Коммит
b30f8db70b
|
@ -442,60 +442,17 @@ nsDeviceContext::Init(nsIWidget *aWidget)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsDeviceContext::CreateRenderingContext(nsIWidget *aWidget,
|
||||
nsRenderingContext *&aContext)
|
||||
{
|
||||
nsresult rv;
|
||||
|
||||
aContext = nsnull;
|
||||
nsRefPtr<nsRenderingContext> pContext;
|
||||
rv = CreateRenderingContextInstance(*getter_AddRefs(pContext));
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
nsRefPtr<gfxASurface> surface(aWidget->GetThebesSurface());
|
||||
if (surface) {
|
||||
pContext->Init(this, surface);
|
||||
aContext = pContext;
|
||||
NS_ADDREF(aContext);
|
||||
} else {
|
||||
rv = NS_ERROR_FAILURE;
|
||||
}
|
||||
}
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsDeviceContext::CreateRenderingContext(nsRenderingContext *&aContext)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
NS_ABORT_IF_FALSE(mPrintingSurface, "only call for printing dcs");
|
||||
|
||||
nsRefPtr<nsRenderingContext> pContext = new nsRenderingContext();
|
||||
|
||||
aContext = nsnull;
|
||||
nsRefPtr<nsRenderingContext> pContext;
|
||||
rv = CreateRenderingContextInstance(*getter_AddRefs(pContext));
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
if (mPrintingSurface) {
|
||||
pContext->Init(this, mPrintingSurface);
|
||||
pContext->Scale(mPrintingScale, mPrintingScale);
|
||||
aContext = pContext;
|
||||
NS_ADDREF(aContext);
|
||||
} else {
|
||||
rv = NS_ERROR_FAILURE;
|
||||
}
|
||||
}
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsDeviceContext::CreateRenderingContextInstance(nsRenderingContext *&aContext)
|
||||
{
|
||||
nsRefPtr<nsRenderingContext> renderingContext = new nsRenderingContext();
|
||||
if (!renderingContext)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
aContext = renderingContext;
|
||||
NS_ADDREF(aContext);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
|
|
@ -97,28 +97,13 @@ public:
|
|||
nsresult InitForPrinting(nsIDeviceContextSpec *aDevSpec);
|
||||
|
||||
/**
|
||||
* Create a rendering context and initialize it from an nsIWidget
|
||||
* @param aWidget widget to initialize context from
|
||||
* @param aContext out parameter for new rendering context
|
||||
* @return error status
|
||||
*/
|
||||
nsresult CreateRenderingContext(nsIWidget *aWidget,
|
||||
nsRenderingContext *&aContext);
|
||||
|
||||
/**
|
||||
* Create a rendering context and initialize it.
|
||||
* Create a rendering context and initialize it. Only call this
|
||||
* method on device contexts that were initialized for printing.
|
||||
* @param aContext out parameter for new rendering context
|
||||
* @return error status
|
||||
*/
|
||||
nsresult CreateRenderingContext(nsRenderingContext *&aContext);
|
||||
|
||||
/**
|
||||
* Create an uninitalised rendering context.
|
||||
* @param aContext out parameter for new rendering context
|
||||
* @return error status
|
||||
*/
|
||||
nsresult CreateRenderingContextInstance(nsRenderingContext *&aContext);
|
||||
|
||||
/**
|
||||
* Gets the number of app units in one CSS pixel; this number is global,
|
||||
* not unique to each device context.
|
||||
|
|
|
@ -1892,11 +1892,7 @@ FrameLayerBuilder::DrawThebesLayer(ThebesLayer* aLayer,
|
|||
}
|
||||
}
|
||||
|
||||
nsRefPtr<nsRenderingContext> rc;
|
||||
nsresult rv =
|
||||
presContext->DeviceContext()->CreateRenderingContextInstance(*getter_AddRefs(rc));
|
||||
if (NS_FAILED(rv))
|
||||
return;
|
||||
nsRefPtr<nsRenderingContext> rc = new nsRenderingContext();
|
||||
rc->Init(presContext->DeviceContext(), aContext);
|
||||
|
||||
Clip currentClip;
|
||||
|
|
|
@ -1197,15 +1197,13 @@ nsCSSRendering::PaintBoxShadowOuter(nsPresContext* aPresContext,
|
|||
|
||||
// Draw the widget shape
|
||||
gfxContextMatrixAutoSaveRestore save(shadowContext);
|
||||
nsDeviceContext* devCtx = aPresContext->DeviceContext();
|
||||
nsRefPtr<nsRenderingContext> wrapperCtx;
|
||||
devCtx->CreateRenderingContextInstance(*getter_AddRefs(wrapperCtx));
|
||||
wrapperCtx->Init(devCtx, shadowContext);
|
||||
wrapperCtx->Translate(nsPoint(shadowItem->mXOffset, shadowItem->mYOffset));
|
||||
nsRefPtr<nsRenderingContext> wrapperCtx = new nsRenderingContext();
|
||||
wrapperCtx->Init(aPresContext->DeviceContext(), shadowContext);
|
||||
wrapperCtx->Translate(nsPoint(shadowItem->mXOffset,
|
||||
shadowItem->mYOffset));
|
||||
|
||||
nsRect nativeRect;
|
||||
nativeRect.IntersectRect(frameRect, aDirtyRect);
|
||||
|
||||
aPresContext->GetTheme()->DrawWidgetBackground(wrapperCtx, aForFrame,
|
||||
styleDisplay->mAppearance, aFrameArea, nativeRect);
|
||||
} else {
|
||||
|
|
|
@ -3761,10 +3761,8 @@ PresShell::GetReferenceRenderingContext()
|
|||
nsDeviceContext* devCtx = mPresContext->DeviceContext();
|
||||
nsRefPtr<nsRenderingContext> rc;
|
||||
if (mPresContext->IsScreen()) {
|
||||
devCtx->CreateRenderingContextInstance(*getter_AddRefs(rc));
|
||||
if (rc) {
|
||||
rc = new nsRenderingContext();
|
||||
rc->Init(devCtx, gfxPlatform::GetPlatform()->ScreenReferenceSurface());
|
||||
}
|
||||
} else {
|
||||
devCtx->CreateRenderingContext(*getter_AddRefs(rc));
|
||||
}
|
||||
|
@ -5283,8 +5281,7 @@ PresShell::RenderDocument(const nsRect& aRect, PRUint32 aFlags,
|
|||
|
||||
AutoSaveRestoreRenderingState _(this);
|
||||
|
||||
nsRefPtr<nsRenderingContext> rc;
|
||||
devCtx->CreateRenderingContextInstance(*getter_AddRefs(rc));
|
||||
nsRefPtr<nsRenderingContext> rc = new nsRenderingContext();
|
||||
rc->Init(devCtx, aThebesContext);
|
||||
|
||||
PRBool wouldFlushRetainedLayers = PR_FALSE;
|
||||
|
@ -5608,8 +5605,7 @@ PresShell::PaintRangePaintInfo(nsTArray<nsAutoPtr<RangePaintInfo> >* aItems,
|
|||
context.Rectangle(gfxRect(0, 0, pixelArea.width, pixelArea.height));
|
||||
context.Fill();
|
||||
|
||||
nsRefPtr<nsRenderingContext> rc;
|
||||
deviceContext->CreateRenderingContextInstance(*getter_AddRefs(rc));
|
||||
nsRefPtr<nsRenderingContext> rc = new nsRenderingContext();
|
||||
rc->Init(deviceContext, surface);
|
||||
|
||||
if (aRegion) {
|
||||
|
|
|
@ -159,10 +159,10 @@ inFlasher::DrawElementOutline(nsIDOMElement* aElement)
|
|||
nsPoint offset;
|
||||
nsIWidget* widget = frame->GetNearestWidget(offset);
|
||||
if (widget) {
|
||||
nsRefPtr<nsRenderingContext> rcontext;
|
||||
frame->PresContext()->DeviceContext()->
|
||||
CreateRenderingContext(widget, *getter_AddRefs(rcontext));
|
||||
if (rcontext) {
|
||||
nsRefPtr<nsRenderingContext> rcontext = new nsRenderingContext();
|
||||
rcontext->Init(frame->PresContext()->DeviceContext(),
|
||||
widget->GetThebesSurface());
|
||||
|
||||
nsRect rect(offset, frame->GetSize());
|
||||
if (mInvert) {
|
||||
rcontext->InvertRect(rect);
|
||||
|
@ -173,7 +173,6 @@ inFlasher::DrawElementOutline(nsIDOMElement* aElement)
|
|||
isFirstFrame, isLastFrame);
|
||||
isFirstFrame = PR_FALSE;
|
||||
}
|
||||
}
|
||||
frame = frame->GetNextContinuation();
|
||||
}
|
||||
|
||||
|
|
|
@ -1465,11 +1465,9 @@ nsRenderingContext*
|
|||
nsSVGRenderState::GetRenderingContext(nsIFrame *aFrame)
|
||||
{
|
||||
if (!mRenderingContext) {
|
||||
nsDeviceContext* devCtx = aFrame->PresContext()->DeviceContext();
|
||||
devCtx->CreateRenderingContextInstance(*getter_AddRefs(mRenderingContext));
|
||||
if (!mRenderingContext)
|
||||
return nsnull;
|
||||
mRenderingContext->Init(devCtx, mGfxContext);
|
||||
mRenderingContext = new nsRenderingContext();
|
||||
mRenderingContext->Init(aFrame->PresContext()->DeviceContext(),
|
||||
mGfxContext);
|
||||
}
|
||||
return mRenderingContext;
|
||||
}
|
||||
|
|
|
@ -621,20 +621,17 @@ void nsTextBoxFrame::PaintOneShadow(gfxContext* aCtx,
|
|||
shadowColor = aForegroundColor;
|
||||
|
||||
// Conjure an nsRenderingContext from a gfxContext for DrawText
|
||||
nsRefPtr<nsRenderingContext> renderingContext = nsnull;
|
||||
nsDeviceContext* devCtx = PresContext()->DeviceContext();
|
||||
devCtx->CreateRenderingContextInstance(*getter_AddRefs(renderingContext));
|
||||
if (!renderingContext)
|
||||
return;
|
||||
renderingContext->Init(devCtx, shadowContext);
|
||||
nsRefPtr<nsRenderingContext> renderingContext = new nsRenderingContext();
|
||||
renderingContext->Init(PresContext()->DeviceContext(), shadowContext);
|
||||
|
||||
aCtx->Save();
|
||||
aCtx->NewPath();
|
||||
aCtx->SetColor(gfxRGBA(shadowColor));
|
||||
|
||||
// Draw the text onto our alpha-only surface to capture the alpha values.
|
||||
// Remember that the box blur context has a device offset on it, so we don't need to
|
||||
// translate any coordinates to fit on the surface.
|
||||
// Draw the text onto our alpha-only surface to capture the alpha
|
||||
// values. Remember that the box blur context has a device offset
|
||||
// on it, so we don't need to translate any coordinates to fit on
|
||||
// the surface.
|
||||
DrawText(*renderingContext, shadowRect, &shadowColor);
|
||||
contextBoxBlur.DoPaint();
|
||||
aCtx->Restore();
|
||||
|
|
Загрузка…
Ссылка в новой задаче