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