Backout e401dfeab8b7 (bug 991572) for crashtest assertion. r=orange

This commit is contained in:
Jonathan Watt 2014-04-04 10:03:41 +01:00
parent 58d370ca0b
commit 5b2f8f3ee9
5 changed files with 39 additions and 6 deletions

View File

@ -6,7 +6,6 @@
#ifndef nsICanvasRenderingContextInternal_h___ #ifndef nsICanvasRenderingContextInternal_h___
#define nsICanvasRenderingContextInternal_h___ #define nsICanvasRenderingContextInternal_h___
#include "mozilla/gfx/2D.h"
#include "nsISupports.h" #include "nsISupports.h"
#include "nsIInputStream.h" #include "nsIInputStream.h"
#include "nsIDocShell.h" #include "nsIDocShell.h"
@ -15,8 +14,8 @@
#include "mozilla/RefPtr.h" #include "mozilla/RefPtr.h"
#define NS_ICANVASRENDERINGCONTEXTINTERNAL_IID \ #define NS_ICANVASRENDERINGCONTEXTINTERNAL_IID \
{ 0x3cc9e801, 0x1806, 0x4ff6, \ { 0x9a6a5bdf, 0x1261, 0x4057, \
{ 0x86, 0x14, 0xf9, 0xd0, 0xf4, 0xfb, 0x3b, 0x08 } } { 0x85, 0xcc, 0xaf, 0x97, 0x6c, 0x36, 0x99, 0xa9 } }
class gfxContext; class gfxContext;
class gfxASurface; class gfxASurface;
@ -85,6 +84,10 @@ public:
const char16_t *aEncoderOptions, const char16_t *aEncoderOptions,
nsIInputStream **aStream) = 0; 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 // This gets an Azure SourceSurface for the canvas, this will be a snapshot
// of the canvas at the time it was called. // of the canvas at the time it was called.
virtual mozilla::TemporaryRef<mozilla::gfx::SourceSurface> GetSurfaceSnapshot() = 0; virtual mozilla::TemporaryRef<mozilla::gfx::SourceSurface> GetSurfaceSnapshot() = 0;

View File

@ -1058,12 +1058,13 @@ CanvasRenderingContext2D::Render(gfxContext *ctx, GraphicsFilter aFilter, uint32
return NS_ERROR_FAILURE; return NS_ERROR_FAILURE;
} }
RefPtr<SourceSurface> surface = mTarget->Snapshot(); nsRefPtr<gfxASurface> surface;
if (!surface) {
if (NS_FAILED(GetThebesSurface(getter_AddRefs(surface)))) {
return NS_ERROR_FAILURE; return NS_ERROR_FAILURE;
} }
nsRefPtr<gfxPattern> pat = new gfxPattern(surface, Matrix()); nsRefPtr<gfxPattern> pat = new gfxPattern(surface);
pat->SetFilter(aFilter); pat->SetFilter(aFilter);
pat->SetExtend(gfxPattern::EXTEND_PAD); pat->SetExtend(gfxPattern::EXTEND_PAD);
@ -4159,6 +4160,27 @@ CanvasRenderingContext2D::PutImageData_explicit(int32_t x, int32_t y, uint32_t w
return NS_OK; return NS_OK;
} }
NS_IMETHODIMP
CanvasRenderingContext2D::GetThebesSurface(gfxASurface **surface)
{
EnsureTarget();
if (!IsTargetValid()) {
return NS_ERROR_FAILURE;
}
nsRefPtr<gfxASurface> thebesSurface =
gfxPlatform::GetPlatform()->GetThebesSurfaceForDrawTarget(mTarget);
if (!thebesSurface) {
return NS_ERROR_FAILURE;
}
*surface = thebesSurface;
NS_ADDREF(*surface);
return NS_OK;
}
static already_AddRefed<ImageData> static already_AddRefed<ImageData>
CreateImageData(JSContext* cx, CanvasRenderingContext2D* context, CreateImageData(JSContext* cx, CanvasRenderingContext2D* context,
uint32_t w, uint32_t h, ErrorResult& error) uint32_t w, uint32_t h, ErrorResult& error)

View File

@ -464,6 +464,7 @@ public:
NS_IMETHOD GetInputStream(const char* aMimeType, NS_IMETHOD GetInputStream(const char* aMimeType,
const char16_t* aEncoderOptions, const char16_t* aEncoderOptions,
nsIInputStream **aStream) MOZ_OVERRIDE; nsIInputStream **aStream) MOZ_OVERRIDE;
NS_IMETHOD GetThebesSurface(gfxASurface **surface) MOZ_OVERRIDE;
mozilla::TemporaryRef<mozilla::gfx::SourceSurface> GetSurfaceSnapshot() MOZ_OVERRIDE mozilla::TemporaryRef<mozilla::gfx::SourceSurface> GetSurfaceSnapshot() MOZ_OVERRIDE
{ EnsureTarget(); return mTarget->Snapshot(); } { EnsureTarget(); return mTarget->Snapshot(); }

View File

@ -827,6 +827,12 @@ WebGLContext::GetInputStream(const char* aMimeType,
encoder, aEncoderOptions, aStream); encoder, aEncoderOptions, aStream);
} }
NS_IMETHODIMP
WebGLContext::GetThebesSurface(gfxASurface **surface)
{
return NS_ERROR_NOT_AVAILABLE;
}
void WebGLContext::UpdateLastUseIndex() void WebGLContext::UpdateLastUseIndex()
{ {
static CheckedInt<uint64_t> sIndex = 0; static CheckedInt<uint64_t> sIndex = 0;

View File

@ -174,6 +174,7 @@ public:
NS_IMETHOD GetInputStream(const char* aMimeType, NS_IMETHOD GetInputStream(const char* aMimeType,
const char16_t* aEncoderOptions, const char16_t* aEncoderOptions,
nsIInputStream **aStream) MOZ_OVERRIDE; nsIInputStream **aStream) MOZ_OVERRIDE;
NS_IMETHOD GetThebesSurface(gfxASurface **surface) MOZ_OVERRIDE;
mozilla::TemporaryRef<mozilla::gfx::SourceSurface> GetSurfaceSnapshot() MOZ_OVERRIDE; mozilla::TemporaryRef<mozilla::gfx::SourceSurface> GetSurfaceSnapshot() MOZ_OVERRIDE;
NS_IMETHOD SetIsOpaque(bool b) MOZ_OVERRIDE { return NS_OK; }; NS_IMETHOD SetIsOpaque(bool b) MOZ_OVERRIDE { return NS_OK; };