Bug 981621 - Don't crash if we fail to create SkiaGL backing texture r=gwright

This commit is contained in:
James Willcox 2014-03-26 13:21:50 -05:00
parent cddb418a57
commit d426ef8502
4 changed files with 12 additions and 6 deletions

View File

@ -979,7 +979,7 @@ public:
}
#ifdef USE_SKIA_GPU
virtual void InitWithGrContext(GrContext* aGrContext,
virtual bool InitWithGrContext(GrContext* aGrContext,
const IntSize &aSize,
SurfaceFormat aFormat)
{

View File

@ -659,7 +659,7 @@ DrawTargetSkia::Init(const IntSize &aSize, SurfaceFormat aFormat)
}
#ifdef USE_SKIA_GPU
void
bool
DrawTargetSkia::InitWithGrContext(GrContext* aGrContext,
const IntSize &aSize,
SurfaceFormat aFormat)
@ -681,12 +681,17 @@ DrawTargetSkia::InitWithGrContext(GrContext* aGrContext,
targetDescriptor.fSampleCnt = 0;
SkAutoTUnref<GrTexture> skiaTexture(mGrContext->createUncachedTexture(targetDescriptor, NULL, 0));
if (!skiaTexture) {
return false;
}
mTexture = (uint32_t)skiaTexture->getTextureHandle();
SkAutoTUnref<SkBaseDevice> device(new SkGpuDevice(mGrContext.get(), skiaTexture->asRenderTarget()));
SkAutoTUnref<SkCanvas> canvas(new SkCanvas(device.get()));
mCanvas = canvas.get();
return true;
}
#endif

View File

@ -106,7 +106,7 @@ public:
void Init(unsigned char* aData, const IntSize &aSize, int32_t aStride, SurfaceFormat aFormat);
#ifdef USE_SKIA_GPU
void InitWithGrContext(GrContext* aGrContext,
bool InitWithGrContext(GrContext* aGrContext,
const IntSize &aSize,
SurfaceFormat aFormat) MOZ_OVERRIDE;
#endif

View File

@ -590,9 +590,10 @@ Factory::CreateDrawTargetSkiaWithGrContext(GrContext* aGrContext,
const IntSize &aSize,
SurfaceFormat aFormat)
{
DrawTargetSkia* newDrawTargetSkia = new DrawTargetSkia();
newDrawTargetSkia->InitWithGrContext(aGrContext, aSize, aFormat);
RefPtr<DrawTarget> newTarget = newDrawTargetSkia;
RefPtr<DrawTarget> newTarget = new DrawTargetSkia();
if (!newTarget->InitWithGrContext(aGrContext, aSize, aFormat)) {
return nullptr;
}
return newTarget;
}