Bug 933030 - Eliminate thebes use in CanvasRenderingContext2D.cpp. r=roc

This commit is contained in:
Andreas Gal 2013-10-31 23:19:22 -04:00
parent 2b63dcc7e8
commit 66170c4517

View File

@ -1060,9 +1060,9 @@ CanvasRenderingContext2D::GetImageBuffer(uint8_t** aImageBuffer,
*aImageBuffer = nullptr;
*aFormat = 0;
nsRefPtr<gfxASurface> surface;
nsresult rv = GetThebesSurface(getter_AddRefs(surface));
if (NS_FAILED(rv)) {
EnsureTarget();
RefPtr<SourceSurface> snapshot = mTarget->Snapshot();
if (!snapshot) {
return;
}
@ -1072,26 +1072,24 @@ CanvasRenderingContext2D::GetImageBuffer(uint8_t** aImageBuffer,
return;
}
nsRefPtr<gfxImageSurface> imgsurf =
new gfxImageSurface(imageBuffer,
gfxIntSize(mWidth, mHeight),
mWidth * 4,
gfxImageFormatARGB32);
if (!imgsurf || imgsurf->CairoStatus()) {
RefPtr<DrawTarget> dt =
Factory::CreateDrawTargetForData(mTarget->GetType(),
imageBuffer,
IntSize(mWidth, mHeight),
mWidth * 4,
FORMAT_B8G8R8A8);
if (!dt) {
delete[] imageBuffer;
return;
}
nsRefPtr<gfxContext> ctx = new gfxContext(imgsurf);
if (!ctx || ctx->HasError()) {
delete[] imageBuffer;
return;
}
ctx->SetOperator(gfxContext::OPERATOR_SOURCE);
ctx->SetSource(surface, gfxPoint(0, 0));
ctx->Paint();
IntSize size = snapshot->GetSize();
dt->DrawSurface(snapshot,
mgfx::Rect(0, 0, mWidth, mHeight),
mgfx::Rect(0, 0, size.width, size.height),
DrawSurfaceOptions(),
DrawOptions(1.0f, OP_SOURCE));
dt->Flush();
*aImageBuffer = imageBuffer;
*aFormat = imgIEncoder::INPUT_FORMAT_HOSTARGB;