NS_IMETHODIMP DeviceContextImpl::CreateRenderingContext(nsIWidget *aWidget, nsIRenderingContext *&aContext)
{
    nsresult rv;

    aContext = nsnull;
    nsCOMPtr<nsIRenderingContext> pContext;
    rv = CreateRenderingContextInstance(*getter_AddRefs(pContext));
    if (NS_SUCCEEDED(rv)) {
        rv = InitRenderingContext(pContext, aWidget);
        if (NS_SUCCEEDED(rv)) {
            aContext = pContext;
            NS_ADDREF(aContext);
        }
    }

    return rv;
}
Example #2
0
NS_IMETHODIMP
nsThebesDeviceContext::CreateRenderingContext(nsRenderingContext *&aContext)
{
    nsresult rv = NS_OK;

    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;
}
Example #3
0
NS_IMETHODIMP
nsThebesDeviceContext::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;
}