зеркало из https://github.com/mozilla/pjs.git
Bug 606279, part 4: Only allocate an image large enough to cover the <canvas>. r=joe a=blocking-fennec
This commit is contained in:
Родитель
d7320f4dd7
Коммит
b734072332
|
@ -57,7 +57,7 @@ public:
|
|||
const nsRect& documentRect, const gfxMatrix& transform,
|
||||
const nsString& bgcolor,
|
||||
PRUint32 renderFlags, PRBool flushLayout,
|
||||
nsIntSize* renderedSize, nsCString& data);
|
||||
const nsIntSize& renderSize, nsCString& data);
|
||||
|
||||
private:
|
||||
|
||||
|
|
|
@ -105,7 +105,8 @@ DocumentRendererChild::RenderDocument(nsIDOMWindow *window,
|
|||
const nsString& bgcolor,
|
||||
PRUint32 renderFlags,
|
||||
PRBool flushLayout,
|
||||
nsIntSize* renderedSize, nsCString& data)
|
||||
const nsIntSize& renderSize,
|
||||
nsCString& data)
|
||||
{
|
||||
if (flushLayout)
|
||||
FlushLayoutForTree(window);
|
||||
|
@ -130,21 +131,18 @@ DocumentRendererChild::RenderDocument(nsIDOMWindow *window,
|
|||
|
||||
nsIPresShell* presShell = presContext->PresShell();
|
||||
|
||||
PRInt32 w = nsPresContext::AppUnitsToIntCSSPixels(documentRect.width);
|
||||
PRInt32 h = nsPresContext::AppUnitsToIntCSSPixels(documentRect.height);
|
||||
|
||||
// Draw directly into the output array.
|
||||
data.SetLength(w * h * 4);
|
||||
data.SetLength(renderSize.width * renderSize.height * 4);
|
||||
|
||||
nsRefPtr<gfxImageSurface> surf =
|
||||
new gfxImageSurface(reinterpret_cast<uint8*>(data.BeginWriting()),
|
||||
gfxIntSize(w, h),
|
||||
4 * w,
|
||||
gfxIntSize(renderSize.width, renderSize.height),
|
||||
4 * renderSize.width,
|
||||
gfxASurface::ImageFormatARGB32);
|
||||
nsRefPtr<gfxContext> ctx = new gfxContext(surf);
|
||||
ctx->SetMatrix(transform);
|
||||
|
||||
presShell->RenderDocument(documentRect, renderFlags, bgColor, ctx);
|
||||
*renderedSize = nsIntSize(w, h);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -3748,7 +3748,8 @@ nsCanvasRenderingContext2D::AsyncDrawXULElement(nsIDOMXULElement* aElem, float a
|
|||
child->SendPDocumentRendererConstructor(rect,
|
||||
mThebes->CurrentMatrix(),
|
||||
nsString(aBGColor),
|
||||
renderDocFlags, flush);
|
||||
renderDocFlags, flush,
|
||||
nsIntSize(mWidth, mHeight));
|
||||
if (!pdocrender)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
|
|
|
@ -280,11 +280,12 @@ child:
|
|||
* default background color |bgcolor|. |renderFlags| are the
|
||||
* nsIPresShell::RenderDocument() flags to use on the remote side,
|
||||
* and if true, |flushLayout| will do just that before rendering
|
||||
* the document.
|
||||
* the document. The rendered image will be of size |renderSize|.
|
||||
*/
|
||||
PDocumentRenderer(nsRect documentRect, gfxMatrix transform,
|
||||
nsString bgcolor,
|
||||
PRUint32 renderFlags, bool flushLayout);
|
||||
PRUint32 renderFlags, bool flushLayout,
|
||||
nsIntSize renderSize);
|
||||
|
||||
/**
|
||||
* Sent by the chrome process when it no longer wants this remote
|
||||
|
|
|
@ -597,7 +597,8 @@ TabChild::AllocPDocumentRenderer(const nsRect& documentRect,
|
|||
const gfxMatrix& transform,
|
||||
const nsString& bgcolor,
|
||||
const PRUint32& renderFlags,
|
||||
const bool& flushLayout)
|
||||
const bool& flushLayout,
|
||||
const nsIntSize& renderSize)
|
||||
{
|
||||
return new DocumentRendererChild();
|
||||
}
|
||||
|
@ -615,7 +616,8 @@ TabChild::RecvPDocumentRendererConstructor(PDocumentRendererChild* actor,
|
|||
const gfxMatrix& transform,
|
||||
const nsString& bgcolor,
|
||||
const PRUint32& renderFlags,
|
||||
const bool& flushLayout)
|
||||
const bool& flushLayout,
|
||||
const nsIntSize& renderSize)
|
||||
{
|
||||
DocumentRendererChild *render = static_cast<DocumentRendererChild *>(actor);
|
||||
|
||||
|
@ -629,17 +631,16 @@ TabChild::RecvPDocumentRendererConstructor(PDocumentRendererChild* actor,
|
|||
return true; // silently ignore
|
||||
}
|
||||
|
||||
nsIntSize renderedSize;
|
||||
nsCString data;
|
||||
bool ret = render->RenderDocument(window,
|
||||
documentRect, transform,
|
||||
bgcolor,
|
||||
renderFlags, flushLayout,
|
||||
&renderedSize, data);
|
||||
renderSize, data);
|
||||
if (!ret)
|
||||
return true; // silently ignore
|
||||
|
||||
return PDocumentRendererChild::Send__delete__(actor, renderedSize, data);
|
||||
return PDocumentRendererChild::Send__delete__(actor, renderSize, data);
|
||||
}
|
||||
|
||||
PContentDialogChild*
|
||||
|
|
|
@ -201,14 +201,16 @@ public:
|
|||
virtual PDocumentRendererChild*
|
||||
AllocPDocumentRenderer(const nsRect& documentRect, const gfxMatrix& transform,
|
||||
const nsString& bgcolor,
|
||||
const PRUint32& renderFlags, const bool& flushLayout);
|
||||
const PRUint32& renderFlags, const bool& flushLayout,
|
||||
const nsIntSize& renderSize);
|
||||
virtual bool DeallocPDocumentRenderer(PDocumentRendererChild* actor);
|
||||
virtual bool RecvPDocumentRendererConstructor(PDocumentRendererChild* actor,
|
||||
const nsRect& documentRect,
|
||||
const gfxMatrix& transform,
|
||||
const nsString& bgcolor,
|
||||
const PRUint32& renderFlags,
|
||||
const bool& flushLayout);
|
||||
const bool& flushLayout,
|
||||
const nsIntSize& renderSize);
|
||||
|
||||
virtual PContentDialogChild* AllocPContentDialog(const PRUint32&,
|
||||
const nsCString&,
|
||||
|
|
|
@ -223,7 +223,8 @@ TabParent::AllocPDocumentRenderer(const nsRect& documentRect,
|
|||
const gfxMatrix& transform,
|
||||
const nsString& bgcolor,
|
||||
const PRUint32& renderFlags,
|
||||
const bool& flushLayout)
|
||||
const bool& flushLayout,
|
||||
const nsIntSize& renderSize)
|
||||
{
|
||||
return new DocumentRendererParent();
|
||||
}
|
||||
|
|
|
@ -135,7 +135,8 @@ public:
|
|||
virtual PDocumentRendererParent*
|
||||
AllocPDocumentRenderer(const nsRect& documentRect, const gfxMatrix& transform,
|
||||
const nsString& bgcolor,
|
||||
const PRUint32& renderFlags, const bool& flushLayout);
|
||||
const PRUint32& renderFlags, const bool& flushLayout,
|
||||
const nsIntSize& renderSize);
|
||||
virtual bool DeallocPDocumentRenderer(PDocumentRendererParent* actor);
|
||||
|
||||
virtual PContentPermissionRequestParent* AllocPContentPermissionRequest(const nsCString& aType, const IPC::URI& uri);
|
||||
|
|
Загрузка…
Ссылка в новой задаче