diff options
author | 2010-10-26 19:47:30 +0000 | |
---|---|---|
committer | 2010-10-26 19:47:30 +0000 | |
commit | 35fc62b960db6739b19c59576085663796951e47 (patch) | |
tree | a8f3c6354267feb10bbdb9f507d623396baaeede | |
parent | ddbbd805b5b453e12cda0b3300e5655d8fb2bc19 (diff) |
Move the device capability method to SkDevice.
These are not the capabilities of the factory, but of the device. Additionally, it is more often needed when you have a device then when you have a factory, which caused creating of a new factory.
Review URL: http://codereview.appspot.com/2720041
git-svn-id: http://skia.googlecode.com/svn/trunk@618 2bbb7eff-a529-9590-31e7-b0007b416f81
-rw-r--r-- | include/core/SkDevice.h | 14 | ||||
-rw-r--r-- | include/pdf/SkPDFDevice.h | 3 | ||||
-rw-r--r-- | src/core/SkCanvas.cpp | 6 | ||||
-rw-r--r-- | src/gl/SkGLDevice.h | 3 |
4 files changed, 13 insertions, 13 deletions
diff --git a/include/core/SkDevice.h b/include/core/SkDevice.h index 3932ad35c5..0ff3241776 100644 --- a/include/core/SkDevice.h +++ b/include/core/SkDevice.h @@ -38,19 +38,12 @@ class SkDeviceFactory { public: virtual SkDevice* newDevice(SkBitmap::Config config, int width, int height, bool isOpaque, bool isForLayer) = 0; - - enum Capabilities { - kGL_Capability = 0x1, //!< mask to indicate this device supports GL - kAll_Capabilities = 0x1 - }; - virtual uint32_t getDeviceCapabilities() = 0; }; class SkRasterDeviceFactory : public SkDeviceFactory { public: virtual SkDevice* newDevice(SkBitmap::Config config, int width, int height, bool isOpaque, bool isForLayer); - virtual uint32_t getDeviceCapabilities() { return 0; } }; class SkDevice : public SkRefCnt { @@ -68,6 +61,13 @@ public: return SkNEW(SkRasterDeviceFactory); } + enum Capabilities { + kGL_Capability = 0x1, //!< mask indicating GL support + kVector_Capability = 0x2, //!< mask indicating a vector representation + kAll_Capabilities = 0x3 + }; + virtual uint32_t getDeviceCapabilities() { return 0; } + /** Return the width of the device (in pixels). */ virtual int width() const { return fBitmap.width(); } diff --git a/include/pdf/SkPDFDevice.h b/include/pdf/SkPDFDevice.h index fb74c63a1b..b972dd4752 100644 --- a/include/pdf/SkPDFDevice.h +++ b/include/pdf/SkPDFDevice.h @@ -31,7 +31,6 @@ class SkPDFStream; class SkPDFDeviceFactory : public SkDeviceFactory { virtual SkDevice* newDevice(SkBitmap::Config config, int width, int height, bool isOpaque, bool isForLayer); - virtual uint32_t getDeviceCapabilities() { return 0; } }; /** \class SkPDFDevice @@ -52,6 +51,8 @@ public: return SkNEW(SkPDFDeviceFactory); } + virtual uint32_t getDeviceCapabilities() { return kVector_Capability; } + virtual int width() const { return fWidth; }; virtual int height() const { return fHeight; }; diff --git a/src/core/SkCanvas.cpp b/src/core/SkCanvas.cpp index bb8c2be9b3..5a855bb636 100644 --- a/src/core/SkCanvas.cpp +++ b/src/core/SkCanvas.cpp @@ -536,8 +536,7 @@ SkDevice* SkCanvas::setBitmapDevice(const SkBitmap& bitmap) { ////////////////////////////////////////////////////////////////////////////// bool SkCanvas::getViewport(SkIPoint* size) const { - if ((fDeviceFactory->getDeviceCapabilities() - & SkDeviceFactory::kGL_Capability) == 0) + if ((getDevice()->getDeviceCapabilities() & SkDevice::kGL_Capability) == 0) return false; if (size) size->set(getDevice()->width(), getDevice()->height()); @@ -545,8 +544,7 @@ bool SkCanvas::getViewport(SkIPoint* size) const { } bool SkCanvas::setViewport(int width, int height) { - if ((fDeviceFactory->getDeviceCapabilities() - & SkDeviceFactory::kGL_Capability) == 0) + if ((getDevice()->getDeviceCapabilities() & SkDevice::kGL_Capability) == 0) return false; this->setDevice(createDevice(SkBitmap::kARGB_8888_Config, width, height, false, false))->unref(); diff --git a/src/gl/SkGLDevice.h b/src/gl/SkGLDevice.h index 61916c1c5c..a939b07f76 100644 --- a/src/gl/SkGLDevice.h +++ b/src/gl/SkGLDevice.h @@ -15,7 +15,6 @@ class SkGLDeviceFactory : public SkDeviceFactory { public: virtual SkDevice* newDevice(SkBitmap::Config config, int width, int height, bool isOpaque, bool isForLayer); - virtual uint32_t getDeviceCapabilities() { return kGL_Capability; } }; struct SkGLDrawProcs; @@ -29,6 +28,8 @@ public: return SkNEW(SkGLDeviceFactory); } + virtual uint32_t getDeviceCapabilities() { return kGL_Capability; } + // used to identify GLTextCache data in the glyphcache static void GlyphCacheAuxProc(void* data); |