add getTopLayer(), so clients don't have to use a LayerIter just to get

the top. (very common for chrome)



git-svn-id: http://skia.googlecode.com/svn/trunk@1016 2bbb7eff-a529-9590-31e7-b0007b416f81
This commit is contained in:
reed@google.com 2011-03-30 00:18:03 +00:00
parent 11f0b51976
commit 9266fed56a
2 changed files with 13 additions and 0 deletions

View File

@ -99,6 +99,15 @@ public:
*/
SkDevice* setDevice(SkDevice* device);
/**
* saveLayer() can create another device (which is later drawn onto
* the previous device). getTopDevice() returns the top-most device current
* installed. Note that this can change on other calls like save/restore,
* so do not access this device after subsequent canvas calls.
* The reference count of the device is not changed.
*/
SkDevice* getTopDevice() const;
/** May be overridden by subclasses. This returns a compatible device
for this canvas, with the specified config/width/height. If the device
is raster, the pixels will be allocated automatically.

View File

@ -472,6 +472,10 @@ SkDevice* SkCanvas::getDevice() const {
return rec->fLayer->fDevice;
}
SkDevice* SkCanvas::getTopDevice() const {
return fMCRec->fTopLayer->fDevice;
}
SkDevice* SkCanvas::setDevice(SkDevice* device) {
// return root device
SkDeque::F2BIter iter(fMCStack);