add getTopLayer(), so clients don't have to use a LayerIter just to get
authorreed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>
Wed, 30 Mar 2011 00:18:03 +0000 (00:18 +0000)
committerreed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>
Wed, 30 Mar 2011 00:18:03 +0000 (00:18 +0000)
the top. (very common for chrome)

git-svn-id: http://skia.googlecode.com/svn/trunk@1016 2bbb7eff-a529-9590-31e7-b0007b416f81

include/core/SkCanvas.h
src/core/SkCanvas.cpp

index 0a1b393..2dbf207 100644 (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.
index 368bdfd..e518b45 100644 (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);