back out bug 430873 to fix test failures

This commit is contained in:
Olli.Pettay@helsinki.fi 2008-04-29 07:43:35 -07:00
Родитель 2111d4317d
Коммит 2e56184516
4 изменённых файлов: 20 добавлений и 80 удалений

Просмотреть файл

@ -50,8 +50,6 @@ class nsIFrame;
class nsIRenderingContext;
class nsICanvasRenderingContextInternal;
struct _cairo_surface;
class nsICanvasElement : public nsISupports {
@ -94,13 +92,6 @@ public:
* is relative to the origin of the canvas frame.
*/
NS_IMETHOD InvalidateFrameSubrect (const nsRect& damageRect) = 0;
/*
* Get the number of contexts in this canvas, and request a context at
* an index.
*/
virtual PRInt32 CountContexts () = 0;
virtual nsICanvasRenderingContextInternal *GetContextAtIndex (PRInt32 index) = 0;
};
NS_DEFINE_STATIC_IID_ACCESSOR(nsICanvasElement, NS_ICANVASELEMENT_IID)

Просмотреть файл

@ -47,7 +47,6 @@
{ 0xeab854fd, 0xaa5e, 0x44bb, { 0x8c, 0xc5, 0x8d, 0x02, 0xf8, 0x4b, 0x02, 0x16 } }
class gfxContext;
class gfxASurface;
class nsICanvasRenderingContextInternal : public nsISupports {
public:
@ -73,10 +72,6 @@ public:
NS_IMETHOD GetInputStream(const char *aMimeType,
const PRUnichar *aEncoderOptions,
nsIInputStream **aStream) = 0;
// If this canvas context can be represented with a simple Thebes surface,
// return the surface. Otherwise returns an error.
NS_IMETHOD GetThebesSurface(gfxASurface **surface) = 0;
};
NS_DEFINE_STATIC_IID_ACCESSOR(nsICanvasRenderingContextInternal,

Просмотреть файл

@ -295,7 +295,6 @@ public:
NS_IMETHOD GetInputStream(const char* aMimeType,
const PRUnichar* aEncoderOptions,
nsIInputStream **aStream);
NS_IMETHOD GetThebesSurface(gfxASurface **surface);
// nsISupports interface
NS_DECL_ISUPPORTS
@ -412,8 +411,8 @@ protected:
// cairo helpers
nsresult CairoSurfaceFromElement(nsIDOMElement *imgElt,
PRBool forceCopy,
cairo_surface_t **aCairoSurface,
PRUint8 **imgDataOut,
PRInt32 *widthOut, PRInt32 *heightOut,
nsIPrincipal **prinOut,
PRBool *forceWriteOnlyOut);
@ -1090,11 +1089,12 @@ nsCanvasRenderingContext2D::CreatePattern(nsIDOMHTMLElement *image,
}
cairo_surface_t *imgSurf = nsnull;
PRUint8 *imgData = nsnull;
PRInt32 imgWidth, imgHeight;
nsCOMPtr<nsIPrincipal> principal;
PRBool forceWriteOnly = PR_FALSE;
rv = CairoSurfaceFromElement(image, PR_TRUE,
&imgSurf, &imgWidth, &imgHeight,
rv = CairoSurfaceFromElement(image, &imgSurf, &imgData,
&imgWidth, &imgHeight,
getter_AddRefs(principal), &forceWriteOnly);
if (NS_FAILED(rv))
return rv;
@ -1918,11 +1918,12 @@ nsCanvasRenderingContext2D::DrawImage()
cairo_matrix_t surfMat;
cairo_pattern_t *pat;
cairo_path_t *old_path;
PRUint8 *imgData = nsnull;
PRInt32 imgWidth, imgHeight;
nsCOMPtr<nsIPrincipal> principal;
PRBool forceWriteOnly = PR_FALSE;
rv = CairoSurfaceFromElement(imgElt, PR_FALSE,
&imgSurf, &imgWidth, &imgHeight,
rv = CairoSurfaceFromElement(imgElt, &imgSurf, &imgData,
&imgWidth, &imgHeight,
getter_AddRefs(principal), &forceWriteOnly);
if (NS_FAILED(rv))
return rv;
@ -2153,15 +2154,12 @@ nsCanvasRenderingContext2D::ConvertJSValToXPCObject(nsISupports** aSupports, REF
/* cairo ARGB32 surfaces are ARGB stored as a packed 32-bit integer; on little-endian
* platforms, they appear as BGRA bytes in the surface data. The color values are also
* stored with premultiplied alpha.
*
* If forceCopy is FALSE, a surface may be returned that's only valid during the current
* operation. If it's TRUE, a copy will always be made that can safely be retained.
*/
nsresult
nsCanvasRenderingContext2D::CairoSurfaceFromElement(nsIDOMElement *imgElt,
PRBool forceCopy,
cairo_surface_t **aCairoSurface,
PRUint8 **imgData,
PRInt32 *widthOut,
PRInt32 *heightOut,
nsIPrincipal **prinOut,
@ -2204,30 +2202,20 @@ nsCanvasRenderingContext2D::CairoSurfaceFromElement(nsIDOMElement *imgElt,
rv = canvas->GetSize(&w, &h);
NS_ENSURE_SUCCESS(rv, rv);
nsRefPtr<gfxASurface> sourceSurface;
nsRefPtr<gfxImageSurface> surf =
new gfxImageSurface (gfxIntSize(w, h), gfxASurface::ImageFormatARGB32);
nsRefPtr<gfxContext> ctx = new gfxContext(surf);
ctx->SetOperator(gfxContext::OPERATOR_CLEAR);
ctx->Paint();
ctx->SetOperator(gfxContext::OPERATOR_OVER);
if (!forceCopy && canvas->CountContexts() == 1) {
nsICanvasRenderingContextInternal *srcCanvas = canvas->GetContextAtIndex(0);
rv = srcCanvas->GetThebesSurface(getter_AddRefs(sourceSurface));
if (NS_FAILED(rv))
sourceSurface = nsnull;
}
rv = canvas->RenderContexts(ctx);
if (NS_FAILED(rv))
return rv;
if (sourceSurface == nsnull) {
nsRefPtr<gfxASurface> surf =
gfxPlatform::GetPlatform()->CreateOffscreenSurface
(gfxIntSize(w, h), gfxASurface::ImageFormatARGB32);
nsRefPtr<gfxContext> ctx = new gfxContext(surf);
ctx->SetOperator(gfxContext::OPERATOR_OVER);
rv = canvas->RenderContexts(ctx);
if (NS_FAILED(rv))
return rv;
sourceSurface = surf;
}
*aCairoSurface = sourceSurface->CairoSurface();
*aCairoSurface = surf->CairoSurface();
cairo_surface_reference(*aCairoSurface);
*imgData = surf->Data();
*widthOut = w;
*heightOut = h;
@ -2276,6 +2264,7 @@ nsCanvasRenderingContext2D::CairoSurfaceFromElement(nsIDOMElement *imgElt,
*aCairoSurface = gfxsurf->CairoSurface();
cairo_surface_reference (*aCairoSurface);
*imgData = nsnull;
return NS_OK;
}
@ -2658,18 +2647,3 @@ nsCanvasRenderingContext2D::PutImageData()
return Redraw();
}
NS_IMETHODIMP
nsCanvasRenderingContext2D::GetThebesSurface(gfxASurface **surface)
{
if (!mThebesSurface) {
*surface = nsnull;
return NS_ERROR_NOT_AVAILABLE;
}
*surface = mThebesSurface.get();
NS_ADDREF(*surface);
return NS_OK;
}

Просмотреть файл

@ -93,8 +93,6 @@ public:
virtual void SetWriteOnly();
NS_IMETHOD InvalidateFrame ();
NS_IMETHOD InvalidateFrameSubrect (const nsRect& damageRect);
virtual PRInt32 CountContexts();
virtual nsICanvasRenderingContextInternal *GetContextAtIndex (PRInt32 index);
NS_IMETHOD_(PRBool) IsAttributeMapped(const nsIAtom* aAttribute) const;
nsMapRuleToAttributesFunc GetAttributeMappingFunction() const;
@ -555,21 +553,3 @@ nsHTMLCanvasElement::InvalidateFrameSubrect(const nsRect& damageRect)
return NS_OK;
}
PRInt32
nsHTMLCanvasElement::CountContexts()
{
if (mCurrentContext)
return 1;
return 0;
}
nsICanvasRenderingContextInternal *
nsHTMLCanvasElement::GetContextAtIndex (PRInt32 index)
{
if (mCurrentContext && index == 0)
return mCurrentContext.get();
return NULL;
}