Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2174)

Unified Diff: include/core/SkDevice.h

Issue 22978012: Split SkDevice into SkBaseDevice and SkBitmapDevice (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: Updating to ToT (10994) Created 7 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « include/core/SkCanvas.h ('k') | include/core/SkDraw.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: include/core/SkDevice.h
===================================================================
--- include/core/SkDevice.h (revision 10994)
+++ include/core/SkDevice.h (working copy)
@@ -25,59 +25,23 @@
class GrRenderTarget;
-class SK_API SkDevice : public SkRefCnt {
+class SK_API SkBaseDevice : public SkRefCnt {
public:
- SK_DECLARE_INST_COUNT(SkDevice)
+ SK_DECLARE_INST_COUNT(SkBaseDevice)
/**
- * Construct a new device with the specified bitmap as its backend. It is
- * valid for the bitmap to have no pixels associated with it. In that case,
- * any drawing to this device will have no effect.
+ * Construct a new device.
*/
- SkDevice(const SkBitmap& bitmap);
+ SkBaseDevice();
/**
- * Construct a new device with the specified bitmap as its backend. It is
- * valid for the bitmap to have no pixels associated with it. In that case,
- * any drawing to this device will have no effect.
+ * Construct a new device.
*/
- SkDevice(const SkBitmap& bitmap, const SkDeviceProperties& deviceProperties);
+ SkBaseDevice(const SkDeviceProperties& deviceProperties);
- /**
- * Create a new raster device and have the pixels be automatically
- * allocated. The rowBytes of the device will be computed automatically
- * based on the config and the width.
- *
- * @param config The desired config for the pixels. If the request cannot
- * be met, the closest matching support config will be used.
- * @param width width (in pixels) of the device
- * @param height height (in pixels) of the device
- * @param isOpaque Set to true if it is known that all of the pixels will
- * be drawn to opaquely. Used as an accelerator when drawing
- * these pixels to another device.
- */
- SkDevice(SkBitmap::Config config, int width, int height, bool isOpaque = false);
+ virtual ~SkBaseDevice();
/**
- * Create a new raster device and have the pixels be automatically
- * allocated. The rowBytes of the device will be computed automatically
- * based on the config and the width.
- *
- * @param config The desired config for the pixels. If the request cannot
- * be met, the closest matching support config will be used.
- * @param width width (in pixels) of the device
- * @param height height (in pixels) of the device
- * @param isOpaque Set to true if it is known that all of the pixels will
- * be drawn to opaquely. Used as an accelerator when drawing
- * these pixels to another device.
- * @param deviceProperties Properties which affect compositing.
- */
- SkDevice(SkBitmap::Config config, int width, int height, bool isOpaque,
- const SkDeviceProperties& deviceProperties);
-
- virtual ~SkDevice();
-
- /**
* Creates a device that is of the same type as this device (e.g. SW-raster,
* GPU, or PDF). The backing store for this device is created automatically
* (e.g. offscreen pixels or FBO or whatever is appropriate).
@@ -88,9 +52,9 @@
* draw into this device such that all of the pixels will
* be opaque.
*/
- SkDevice* createCompatibleDevice(SkBitmap::Config config,
- int width, int height,
- bool isOpaque);
+ SkBaseDevice* createCompatibleDevice(SkBitmap::Config config,
+ int width, int height,
+ bool isOpaque);
SkMetaData& getMetaData();
@@ -99,14 +63,14 @@
kVector_Capability = 0x2, //!< mask indicating a vector representation
kAll_Capabilities = 0x3
};
- virtual uint32_t getDeviceCapabilities() { return 0; }
+ virtual uint32_t getDeviceCapabilities() = 0;
/** Return the width of the device (in pixels).
*/
- virtual int width() const { return fBitmap.width(); }
+ virtual int width() const = 0;
/** Return the height of the device (in pixels).
*/
- virtual int height() const { return fBitmap.height(); }
+ virtual int height() const = 0;
/** Return the image properties of the device. */
virtual const SkDeviceProperties& getDeviceProperties() const {
@@ -119,17 +83,17 @@
* canvas. The root device will have its top-left at 0,0, but other devices
* such as those associated with saveLayer may have a non-zero origin.
*/
- void getGlobalBounds(SkIRect* bounds) const;
+ virtual void getGlobalBounds(SkIRect* bounds) const = 0;
/** Returns true if the device's bitmap's config treats every pixels as
implicitly opaque.
*/
- bool isOpaque() const { return fBitmap.isOpaque(); }
+ virtual bool isOpaque() const = 0;
+
+ /** DEPRECATED - Return the bitmap config of the device's pixels
+ */
+ virtual SkBitmap::Config config() const = 0;
- /** Return the bitmap config of the device's pixels
- */
- SkBitmap::Config config() const { return fBitmap.getConfig(); }
-
/** Return the bitmap associated with this device. Call this each time you need
to access the bitmap, as it notifies the subclass to perform any flushing
etc. before you examine the pixels.
@@ -154,12 +118,12 @@
* not kARGB_8888_Config then this parameter is ignored.
*/
virtual void writePixels(const SkBitmap& bitmap, int x, int y,
- SkCanvas::Config8888 config8888 = SkCanvas::kNative_Premul_Config8888);
+ SkCanvas::Config8888 config8888 = SkCanvas::kNative_Premul_Config8888) = 0;
/**
* Return the device's associated gpu render target, or NULL.
*/
- virtual GrRenderTarget* accessRenderTarget() { return NULL; }
+ virtual GrRenderTarget* accessRenderTarget() = 0;
/**
@@ -171,7 +135,7 @@
/**
* onAttachToCanvas is invoked whenever a device is installed in a canvas
* (i.e., setDevice, saveLayer (for the new device created by the save),
- * and SkCanvas' SkDevice & SkBitmap -taking ctors). It allows the
+ * and SkCanvas' SkBaseDevice & SkBitmap -taking ctors). It allows the
* devices to prepare for drawing (e.g., locking their pixels, etc.)
*/
virtual void onAttachToCanvas(SkCanvas*) {
@@ -213,9 +177,9 @@
* textflags parameter (output) and return true. If the paint is fine as
* is, then ignore the textflags parameter and return false.
*
- * The baseclass SkDevice filters based on its depth and blitters.
+ * The baseclass SkBaseDevice filters based on its depth and blitters.
*/
- virtual bool filterTextFlags(const SkPaint& paint, TextFlags*);
+ virtual bool filterTextFlags(const SkPaint& paint, TextFlags*) = 0;
/**
*
@@ -234,12 +198,12 @@
* passed in).
*/
virtual void setMatrixClip(const SkMatrix&, const SkRegion&,
- const SkClipStack&);
+ const SkClipStack&) {};
/** Clears the entire device to the specified color (including alpha).
* Ignores the clip.
*/
- virtual void clear(SkColor color);
+ virtual void clear(SkColor color) = 0;
/**
* Deprecated name for clear.
@@ -251,15 +215,15 @@
and are handling any looping from the paint, and any effects from the
DrawFilter.
*/
- virtual void drawPaint(const SkDraw&, const SkPaint& paint);
+ virtual void drawPaint(const SkDraw&, const SkPaint& paint) = 0;
virtual void drawPoints(const SkDraw&, SkCanvas::PointMode mode, size_t count,
- const SkPoint[], const SkPaint& paint);
+ const SkPoint[], const SkPaint& paint) = 0;
virtual void drawRect(const SkDraw&, const SkRect& r,
- const SkPaint& paint);
+ const SkPaint& paint) = 0;
virtual void drawOval(const SkDraw&, const SkRect& oval,
- const SkPaint& paint);
+ const SkPaint& paint) = 0;
virtual void drawRRect(const SkDraw&, const SkRRect& rr,
- const SkPaint& paint);
+ const SkPaint& paint) = 0;
/**
* If pathIsMutable, then the implementation is allowed to cast path to a
@@ -275,11 +239,11 @@
virtual void drawPath(const SkDraw&, const SkPath& path,
const SkPaint& paint,
const SkMatrix* prePathMatrix = NULL,
- bool pathIsMutable = false);
+ bool pathIsMutable = false) = 0;
virtual void drawBitmap(const SkDraw&, const SkBitmap& bitmap,
- const SkMatrix& matrix, const SkPaint& paint);
+ const SkMatrix& matrix, const SkPaint& paint) = 0;
virtual void drawSprite(const SkDraw&, const SkBitmap& bitmap,
- int x, int y, const SkPaint& paint);
+ int x, int y, const SkPaint& paint) = 0;
/**
* The default impl. will create a bitmap-shader from the bitmap,
@@ -288,35 +252,35 @@
virtual void drawBitmapRect(const SkDraw&, const SkBitmap&,
const SkRect* srcOrNull, const SkRect& dst,
const SkPaint& paint,
- SkCanvas::DrawBitmapRectFlags flags);
+ SkCanvas::DrawBitmapRectFlags flags) = 0;
/**
* Does not handle text decoration.
* Decorations (underline and stike-thru) will be handled by SkCanvas.
*/
virtual void drawText(const SkDraw&, const void* text, size_t len,
- SkScalar x, SkScalar y, const SkPaint& paint);
+ SkScalar x, SkScalar y, const SkPaint& paint) = 0;
virtual void drawPosText(const SkDraw&, const void* text, size_t len,
const SkScalar pos[], SkScalar constY,
- int scalarsPerPos, const SkPaint& paint);
+ int scalarsPerPos, const SkPaint& paint) = 0;
virtual void drawTextOnPath(const SkDraw&, const void* text, size_t len,
const SkPath& path, const SkMatrix* matrix,
- const SkPaint& paint);
+ const SkPaint& paint) = 0;
#ifdef SK_BUILD_FOR_ANDROID
virtual void drawPosTextOnPath(const SkDraw& draw, const void* text, size_t len,
const SkPoint pos[], const SkPaint& paint,
- const SkPath& path, const SkMatrix* matrix);
+ const SkPath& path, const SkMatrix* matrix) = 0;
#endif
virtual void drawVertices(const SkDraw&, SkCanvas::VertexMode, int vertexCount,
const SkPoint verts[], const SkPoint texs[],
const SkColor colors[], SkXfermode* xmode,
const uint16_t indices[], int indexCount,
- const SkPaint& paint);
+ const SkPaint& paint) = 0;
/** The SkDevice passed will be an SkDevice which was returned by a call to
onCreateCompatibleDevice on this device with kSaveLayer_Usage.
*/
- virtual void drawDevice(const SkDraw&, SkDevice*, int x, int y,
- const SkPaint&);
+ virtual void drawDevice(const SkDraw&, SkBaseDevice*, int x, int y,
+ const SkPaint&) = 0;
/**
* On success (returns true), copy the device pixels into the bitmap.
@@ -352,21 +316,11 @@
///////////////////////////////////////////////////////////////////////////
/** Update as needed the pixel value in the bitmap, so that the caller can
- access the pixels directly. Note: only the pixels field should be
- altered. The config/width/height/rowbytes must remain unchanged.
- @param bitmap The device's bitmap
- @return Echo the bitmap parameter, or an alternate (shadow) bitmap
- maintained by the subclass.
+ access the pixels directly.
+ @return The device contents as a bitmap
*/
- virtual const SkBitmap& onAccessBitmap(SkBitmap*);
+ virtual const SkBitmap& onAccessBitmap() = 0;
- SkPixelRef* getPixelRef() const { return fBitmap.pixelRef(); }
- // just for subclasses, to assign a custom pixelref
- SkPixelRef* setPixelRef(SkPixelRef* pr, size_t offset) {
- fBitmap.setPixelRef(pr, offset);
- return pr;
- }
-
/**
* Implements readPixels API. The caller will ensure that:
* 1. bitmap has pixel config kARGB_8888_Config.
@@ -376,13 +330,13 @@
*/
virtual bool onReadPixels(const SkBitmap& bitmap,
int x, int y,
- SkCanvas::Config8888 config8888);
+ SkCanvas::Config8888 config8888) = 0;
/** Called when this device is installed into a Canvas. Balanaced by a call
to unlockPixels() when the device is removed from a Canvas.
*/
- virtual void lockPixels();
- virtual void unlockPixels();
+ virtual void lockPixels() = 0;
+ virtual void unlockPixels() = 0;
/**
* Returns true if the device allows processing of this imagefilter. If
@@ -390,7 +344,7 @@
* some subclasses that do not support pixel manipulations after drawing
* has occurred (e.g. printing). The default implementation returns true.
*/
- virtual bool allowImageFilter(SkImageFilter*);
+ virtual bool allowImageFilter(SkImageFilter*) = 0;
/**
* Override and return true for filters that the device can handle
@@ -399,7 +353,7 @@
* Returning false means the SkCanvas will have apply the filter itself,
* and just pass the resulting image to the device.
*/
- virtual bool canHandleImageFilter(SkImageFilter*);
+ virtual bool canHandleImageFilter(SkImageFilter*) = 0;
/**
* Related (but not required) to canHandleImageFilter, this method returns
@@ -409,7 +363,7 @@
* it just returns false and leaves result and offset unchanged.
*/
virtual bool filterImage(SkImageFilter*, const SkBitmap&, const SkMatrix&,
- SkBitmap* result, SkIPoint* offset);
+ SkBitmap* result, SkIPoint* offset) = 0;
// This is equal kBGRA_Premul_Config8888 or kRGBA_Premul_Config8888 if
// either is identical to kNative_Premul_Config8888. Otherwise, -1.
@@ -424,31 +378,31 @@
friend class SkDeviceImageFilterProxy;
friend class SkSurface_Raster;
+
// used to change the backend's pixels (and possibly config/rowbytes)
// but cannot change the width/height, so there should be no change to
// any clip information.
- void replaceBitmapBackendForRasterSurface(const SkBitmap&);
+ virtual void replaceBitmapBackendForRasterSurface(const SkBitmap&) = 0;
// just called by SkCanvas when built as a layer
void setOrigin(int x, int y) { fOrigin.set(x, y); }
// just called by SkCanvas for saveLayer
- SkDevice* createCompatibleDeviceForSaveLayer(SkBitmap::Config config,
- int width, int height,
- bool isOpaque);
+ SkBaseDevice* createCompatibleDeviceForSaveLayer(SkBitmap::Config config,
+ int width, int height,
+ bool isOpaque);
/**
* Subclasses should override this to implement createCompatibleDevice.
*/
- virtual SkDevice* onCreateCompatibleDevice(SkBitmap::Config config,
- int width, int height,
- bool isOpaque,
- Usage usage);
+ virtual SkBaseDevice* onCreateCompatibleDevice(SkBitmap::Config config,
+ int width, int height,
+ bool isOpaque,
+ Usage usage) = 0;
/** Causes any deferred drawing to the device to be completed.
*/
- virtual void flush() {}
+ virtual void flush() = 0;
- SkBitmap fBitmap;
SkIPoint fOrigin;
SkMetaData* fMetaData;
/**
@@ -466,6 +420,4 @@
typedef SkRefCnt INHERITED;
};
-typedef SkDevice SkBaseDevice;
-
#endif
« no previous file with comments | « include/core/SkCanvas.h ('k') | include/core/SkDraw.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698