From 2aca4e12149f1107087511d81eb78f54f22c0bc4 Mon Sep 17 00:00:00 2001 From: Jonathan Watt Date: Fri, 4 Apr 2014 10:03:41 +0100 Subject: [PATCH] Backout e401dfeab8b7 (bug 991572) for crashtest assertion. r=orange --- .../nsICanvasRenderingContextInternal.h | 9 ++++-- .../canvas/src/CanvasRenderingContext2D.cpp | 28 +++++++++++++++++-- content/canvas/src/CanvasRenderingContext2D.h | 1 + content/canvas/src/WebGLContext.cpp | 6 ++++ content/canvas/src/WebGLContext.h | 1 + 5 files changed, 39 insertions(+), 6 deletions(-) diff --git a/content/canvas/public/nsICanvasRenderingContextInternal.h b/content/canvas/public/nsICanvasRenderingContextInternal.h index 8f73a3255a95..a1a1fc28e72c 100644 --- a/content/canvas/public/nsICanvasRenderingContextInternal.h +++ b/content/canvas/public/nsICanvasRenderingContextInternal.h @@ -6,7 +6,6 @@ #ifndef nsICanvasRenderingContextInternal_h___ #define nsICanvasRenderingContextInternal_h___ -#include "mozilla/gfx/2D.h" #include "nsISupports.h" #include "nsIInputStream.h" #include "nsIDocShell.h" @@ -15,8 +14,8 @@ #include "mozilla/RefPtr.h" #define NS_ICANVASRENDERINGCONTEXTINTERNAL_IID \ -{ 0x3cc9e801, 0x1806, 0x4ff6, \ - { 0x86, 0x14, 0xf9, 0xd0, 0xf4, 0xfb, 0x3b, 0x08 } } +{ 0x9a6a5bdf, 0x1261, 0x4057, \ + { 0x85, 0xcc, 0xaf, 0x97, 0x6c, 0x36, 0x99, 0xa9 } } class gfxContext; class gfxASurface; @@ -85,6 +84,10 @@ public: const char16_t *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; + // This gets an Azure SourceSurface for the canvas, this will be a snapshot // of the canvas at the time it was called. virtual mozilla::TemporaryRef GetSurfaceSnapshot() = 0; diff --git a/content/canvas/src/CanvasRenderingContext2D.cpp b/content/canvas/src/CanvasRenderingContext2D.cpp index afed679c325e..edceb4d0eff0 100755 --- a/content/canvas/src/CanvasRenderingContext2D.cpp +++ b/content/canvas/src/CanvasRenderingContext2D.cpp @@ -1058,12 +1058,13 @@ CanvasRenderingContext2D::Render(gfxContext *ctx, GraphicsFilter aFilter, uint32 return NS_ERROR_FAILURE; } - RefPtr surface = mTarget->Snapshot(); - if (!surface) { + nsRefPtr surface; + + if (NS_FAILED(GetThebesSurface(getter_AddRefs(surface)))) { return NS_ERROR_FAILURE; } - nsRefPtr pat = new gfxPattern(surface, Matrix()); + nsRefPtr pat = new gfxPattern(surface); pat->SetFilter(aFilter); pat->SetExtend(gfxPattern::EXTEND_PAD); @@ -4159,6 +4160,27 @@ CanvasRenderingContext2D::PutImageData_explicit(int32_t x, int32_t y, uint32_t w return NS_OK; } +NS_IMETHODIMP +CanvasRenderingContext2D::GetThebesSurface(gfxASurface **surface) +{ + EnsureTarget(); + if (!IsTargetValid()) { + return NS_ERROR_FAILURE; + } + + nsRefPtr thebesSurface = + gfxPlatform::GetPlatform()->GetThebesSurfaceForDrawTarget(mTarget); + + if (!thebesSurface) { + return NS_ERROR_FAILURE; + } + + *surface = thebesSurface; + NS_ADDREF(*surface); + + return NS_OK; +} + static already_AddRefed CreateImageData(JSContext* cx, CanvasRenderingContext2D* context, uint32_t w, uint32_t h, ErrorResult& error) diff --git a/content/canvas/src/CanvasRenderingContext2D.h b/content/canvas/src/CanvasRenderingContext2D.h index 505ce2613769..55b685c0f9b0 100644 --- a/content/canvas/src/CanvasRenderingContext2D.h +++ b/content/canvas/src/CanvasRenderingContext2D.h @@ -464,6 +464,7 @@ public: NS_IMETHOD GetInputStream(const char* aMimeType, const char16_t* aEncoderOptions, nsIInputStream **aStream) MOZ_OVERRIDE; + NS_IMETHOD GetThebesSurface(gfxASurface **surface) MOZ_OVERRIDE; mozilla::TemporaryRef GetSurfaceSnapshot() MOZ_OVERRIDE { EnsureTarget(); return mTarget->Snapshot(); } diff --git a/content/canvas/src/WebGLContext.cpp b/content/canvas/src/WebGLContext.cpp index 338104db6721..b416c67a884b 100644 --- a/content/canvas/src/WebGLContext.cpp +++ b/content/canvas/src/WebGLContext.cpp @@ -827,6 +827,12 @@ WebGLContext::GetInputStream(const char* aMimeType, encoder, aEncoderOptions, aStream); } +NS_IMETHODIMP +WebGLContext::GetThebesSurface(gfxASurface **surface) +{ + return NS_ERROR_NOT_AVAILABLE; +} + void WebGLContext::UpdateLastUseIndex() { static CheckedInt sIndex = 0; diff --git a/content/canvas/src/WebGLContext.h b/content/canvas/src/WebGLContext.h index 0f0096ea6c34..b6177a428e9d 100644 --- a/content/canvas/src/WebGLContext.h +++ b/content/canvas/src/WebGLContext.h @@ -174,6 +174,7 @@ public: NS_IMETHOD GetInputStream(const char* aMimeType, const char16_t* aEncoderOptions, nsIInputStream **aStream) MOZ_OVERRIDE; + NS_IMETHOD GetThebesSurface(gfxASurface **surface) MOZ_OVERRIDE; mozilla::TemporaryRef GetSurfaceSnapshot() MOZ_OVERRIDE; NS_IMETHOD SetIsOpaque(bool b) MOZ_OVERRIDE { return NS_OK; };