aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar Florin Malita <fmalita@google.com>2017-01-13 15:13:09 +0000
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2017-01-13 15:13:23 +0000
commite050ca783297db6d88d4d8d0f466f12020747cb8 (patch)
tree3c11f513fb0448b91505c3df807c14818584d617
parentc74dad6f1850ebed53b07366380724bd63fadf4f (diff)
Revert "Hide SkCanvas getDevice() & getTopDevice()}"
This reverts commit 76467a11a0aa4ba15f0f2e3ee078ba9b6ecbaa91. Reason for revert: we may need to revert the Chromium GDI change. Original change's description: > Hide SkCanvas getDevice() & getTopDevice()} > > No longer used externally. > > R=reed@google.com > > Change-Id: I450148010852c2567d136d2c85c8837c6dcbc6b9 > Reviewed-on: https://skia-review.googlesource.com/6974 > Reviewed-by: Mike Reed <reed@google.com> > Commit-Queue: Florin Malita <fmalita@chromium.org> > TBR=fmalita@chromium.org,reed@google.com,reviews@skia.org NOPRESUBMIT=true NOTREECHECKS=true NOTRY=true Change-Id: If8480aa5d36ff843c28409a5c94d51570ba0fc1c Reviewed-on: https://skia-review.googlesource.com/6991 Commit-Queue: Florin Malita <fmalita@google.com> Reviewed-by: Florin Malita <fmalita@google.com>
-rw-r--r--include/core/SkCanvas.h33
-rw-r--r--src/core/SkCanvas.cpp7
2 files changed, 35 insertions, 5 deletions
diff --git a/include/core/SkCanvas.h b/include/core/SkCanvas.h
index 909bbac718..704584a050 100644
--- a/include/core/SkCanvas.h
+++ b/include/core/SkCanvas.h
@@ -157,6 +157,36 @@ public:
SkISize getDeviceSize() const { return this->getBaseLayerSize(); }
/**
+ * DEPRECATED.
+ * Return the canvas' device object, which may be null. The device holds
+ * the bitmap of the pixels that the canvas draws into. The reference count
+ * of the returned device is not changed by this call.
+ */
+#ifndef SK_SUPPORT_LEGACY_GETDEVICE
+protected: // Can we make this private?
+#endif
+ SkBaseDevice* getDevice() const;
+public:
+ /**
+ * 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.
+ *
+ * @param updateMatrixClip If this is true, then before the device is
+ * returned, we ensure that its has been notified about the current
+ * matrix and clip. Note: this happens automatically when the device
+ * is drawn to, but is optional here, as there is a small perf hit
+ * sometimes.
+ */
+#ifndef SK_SUPPORT_LEGACY_GETTOPDEVICE
+private:
+#endif
+ SkBaseDevice* getTopDevice(bool updateMatrixClip = false) const;
+public:
+
+ /**
* Create a new surface matching the specified info, one that attempts to
* be maximally compatible when used with this canvas. If there is no matching Surface type,
* NULL is returned.
@@ -1522,9 +1552,6 @@ private:
: kNotOpaque_ShaderOverrideOpacity);
}
- SkBaseDevice* getDevice() const;
- SkBaseDevice* getTopDevice() const;
-
class MCRec;
sk_sp<SkClipStack> fClipStack;
diff --git a/src/core/SkCanvas.cpp b/src/core/SkCanvas.cpp
index e3374dde52..067ccdc4ef 100644
--- a/src/core/SkCanvas.cpp
+++ b/src/core/SkCanvas.cpp
@@ -853,7 +853,10 @@ SkBaseDevice* SkCanvas::getDevice() const {
return rec->fLayer->fDevice;
}
-SkBaseDevice* SkCanvas::getTopDevice() const {
+SkBaseDevice* SkCanvas::getTopDevice(bool updateMatrixClip) const {
+ if (updateMatrixClip) {
+ const_cast<SkCanvas*>(this)->updateDeviceCMCache();
+ }
return fMCRec->fTopLayer->fDevice;
}
@@ -1400,7 +1403,7 @@ void* SkCanvas::accessTopLayerPixels(SkImageInfo* info, size_t* rowBytes, SkIPoi
*rowBytes = pmap.rowBytes();
}
if (origin) {
- *origin = this->getTopDevice()->getOrigin();
+ *origin = this->getTopDevice(false)->getOrigin();
}
return pmap.writable_addr();
}