зеркало из https://github.com/mozilla/pjs.git
Bug 544399. Use nsLayoutUtils::SurfaceFromElement when comparing canvases. r=vlad
--HG-- extra : rebase_source : 93f22c10faa3bad9dbff48cd823f38d4a6ffc22a
This commit is contained in:
Родитель
52ea6ab88a
Коммит
9e3c81a142
|
@ -63,6 +63,7 @@
|
|||
#include "nsICanvasElement.h"
|
||||
#include "gfxContext.h"
|
||||
#include "gfxImageSurface.h"
|
||||
#include "nsLayoutUtils.h"
|
||||
|
||||
#if defined(MOZ_X11) && defined(MOZ_WIDGET_GTK2)
|
||||
#include <gdk/gdk.h>
|
||||
|
@ -621,33 +622,10 @@ nsDOMWindowUtils::ElementFromPoint(PRInt32 aX, PRInt32 aY,
|
|||
static already_AddRefed<gfxImageSurface>
|
||||
CanvasToImageSurface(nsIDOMHTMLCanvasElement *canvas)
|
||||
{
|
||||
PRUint32 w, h;
|
||||
nsresult rv;
|
||||
|
||||
nsCOMPtr<nsICanvasElement> elt = do_QueryInterface(canvas);
|
||||
rv = elt->GetSize(&w, &h);
|
||||
if (NS_FAILED(rv))
|
||||
return nsnull;
|
||||
|
||||
nsRefPtr<gfxImageSurface> img = new gfxImageSurface(gfxIntSize(w, h), gfxASurface::ImageFormatARGB32);
|
||||
if (img == nsnull)
|
||||
return nsnull;
|
||||
|
||||
nsRefPtr<gfxContext> ctx = new gfxContext(img);
|
||||
if (ctx == nsnull)
|
||||
return nsnull;
|
||||
|
||||
ctx->SetOperator(gfxContext::OPERATOR_CLEAR);
|
||||
ctx->Paint();
|
||||
|
||||
ctx->SetOperator(gfxContext::OPERATOR_OVER);
|
||||
rv = elt->RenderContexts(ctx, gfxPattern::FILTER_NEAREST);
|
||||
if (NS_FAILED(rv))
|
||||
return nsnull;
|
||||
|
||||
ctx = nsnull;
|
||||
|
||||
return img.forget();
|
||||
nsLayoutUtils::SurfaceFromElementResult result =
|
||||
nsLayoutUtils::SurfaceFromElement(canvas,
|
||||
nsLayoutUtils::SFE_WANT_IMAGE_SURFACE);
|
||||
return static_cast<gfxImageSurface*>(result.mSurface.forget().get());
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
|
|
Загрузка…
Ссылка в новой задаче