aboutsummaryrefslogtreecommitdiffhomepage
path: root/include/core/SkDevice.h
diff options
context:
space:
mode:
authorGravatar vandebo@chromium.org <vandebo@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81>2010-10-13 22:13:05 +0000
committerGravatar vandebo@chromium.org <vandebo@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81>2010-10-13 22:13:05 +0000
commit8d84fac294682647694b0d2d8a87ac2bd19b6aab (patch)
tree2bfd3dea3c5c79bf42003ce620a51069526f28f0 /include/core/SkDevice.h
parent60eaa398ebdded0fb7957724c170baabef811e17 (diff)
Refactor SkCanvas so that backends don't need to override it.
Methods or classes that should go away are marked deprecated. The only thing I know of that breaks backward compatibility is SkCanvas((SkDevice*)NULL), but that is fairly unlikely to occur in the wild because that constructor had a default value of NULL. Review URL: http://codereview.appspot.com/2103045 git-svn-id: http://skia.googlecode.com/svn/trunk@604 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'include/core/SkDevice.h')
-rw-r--r--include/core/SkDevice.h42
1 files changed, 34 insertions, 8 deletions
diff --git a/include/core/SkDevice.h b/include/core/SkDevice.h
index 4d678c6a40..b7a9cbcb3a 100644
--- a/include/core/SkDevice.h
+++ b/include/core/SkDevice.h
@@ -22,26 +22,52 @@
#include "SkCanvas.h"
#include "SkColor.h"
+class SkDevice;
class SkDraw;
struct SkIRect;
class SkMatrix;
class SkRegion;
+/** \class SkDeviceFactory
+
+ Devices that extend SkDevice should also provide a SkDeviceFactory class
+ to pass into SkCanvas. Doing so will eliminate the need to extend
+ SkCanvas as well.
+*/
+class SkDeviceFactory : public SkRefCnt {
+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 {
public:
SkDevice();
- /** Construct a new device, extracting the width/height/config/isOpaque values from
- the bitmap. If transferPixelOwnership is true, and the bitmap claims to own its
- own pixels (getOwnsPixels() == true), then transfer this responsibility to the
- device, and call setOwnsPixels(false) on the bitmap.
-
- Subclasses may override the destructor, which is virtual, even though this class
- doesn't have one. SkRefCnt does.
-
+ /** Construct a new device, extracting the width/height/config/isOpaque
+ values from the bitmap. Subclasses may override the destructor, which
+ is virtual, even though this class doesn't have one. SkRefCnt does.
+
@param bitmap A copy of this bitmap is made and stored in the device
*/
SkDevice(const SkBitmap& bitmap);
+ virtual SkDeviceFactory* getDeviceFactory() {
+ return SkNEW(SkRasterDeviceFactory);
+ }
+
/** Return the width of the device (in pixels).
*/
int width() const { return fBitmap.width(); }