Ensure that SkDeferredCanvas::onCreateCompatibleDevice unrefs its temp device.

Also update my GM to use createCompatibleDevice.

Review URL: https://codereview.appspot.com/6357061

git-svn-id: http://skia.googlecode.com/svn/trunk@4450 2bbb7eff-a529-9590-31e7-b0007b416f81
This commit is contained in:
scroggo@google.com 2012-07-03 15:16:30 +00:00
parent 44f7c4a6f8
commit d7dbd423f2
2 changed files with 6 additions and 8 deletions

View File

@ -72,13 +72,11 @@ protected:
canvas->translate(0, SkIntToScalar(bitmap.height() + 20));
canvas->drawBitmap(subset, 0, 0);
}
/*
// Now do the same but with a device bitmap as source image
SkRefPtr<SkDevice> primaryDevice(canvas->getDevice());
SkRefPtr<SkDevice> secondDevice(canvas->createCompatibleDevice(
SkAutoTUnref<SkDevice> secondDevice(canvas->createCompatibleDevice(
SkBitmap::kARGB_8888_Config, bitmap.width(),
bitmap.height(), true));
secondDevice->unref();
SkCanvas secondCanvas(secondDevice.get());
secondCanvas.writePixels(bitmap, 0, 0);
@ -91,7 +89,7 @@ protected:
canvas->drawBitmap(deviceBitmap, 0, 0);
canvas->drawBitmap(deviceSubset, 0, 0);
*/
}
private:

View File

@ -589,9 +589,9 @@ SkDevice* SkDeferredCanvas::DeferredDevice::onCreateCompatibleDevice(
// Save layer usage not supported, and not required by SkDeferredCanvas.
SkASSERT(usage != kSaveLayer_Usage);
// Create a compatible non-deferred device.
SkDevice* compatibleDevice =
fImmediateDevice->createCompatibleDevice(config, width, height,
isOpaque);
SkAutoTUnref<SkDevice> compatibleDevice
(fImmediateDevice->createCompatibleDevice(config, width, height,
isOpaque));
return SkNEW_ARGS(DeferredDevice, (compatibleDevice, fDeviceContext));
}