Index: src/core/SkDevice.cpp |
=================================================================== |
--- src/core/SkDevice.cpp (revision 10711) |
+++ src/core/SkDevice.cpp (working copy) |
@@ -16,6 +16,7 @@ |
#include "SkShader.h" |
SK_DEFINE_INST_COUNT(SkDevice) |
+SK_DEFINE_INST_COUNT(SkRasterDevice) |
/////////////////////////////////////////////////////////////////////////////// |
@@ -24,20 +25,13 @@ |
/////////////////////////////////////////////////////////////////////////////// |
-SkDevice::SkDevice(const SkBitmap& bitmap) |
- : fBitmap(bitmap), fLeakyProperties(SkDeviceProperties::MakeDefault()) |
-#ifdef SK_DEBUG |
- , fAttachedToCanvas(false) |
-#endif |
-{ |
- fOrigin.setZero(); |
- fMetaData = NULL; |
- |
+SkRasterDevice::SkRasterDevice(const SkBitmap& bitmap) |
+ : fBitmap(bitmap) { |
SkASSERT(SkBitmap::kARGB_4444_Config != bitmap.config()); |
} |
-SkDevice::SkDevice(const SkBitmap& bitmap, const SkDeviceProperties& deviceProperties) |
- : fBitmap(bitmap), fLeakyProperties(deviceProperties) |
+SkDevice::SkDevice() |
+ : fLeakyProperties(SkDeviceProperties::MakeDefault()) |
#ifdef SK_DEBUG |
, fAttachedToCanvas(false) |
#endif |
@@ -46,15 +40,22 @@ |
fMetaData = NULL; |
} |
-SkDevice::SkDevice(SkBitmap::Config config, int width, int height, bool isOpaque) |
- : fLeakyProperties(SkDeviceProperties::MakeDefault()) |
+SkRasterDevice::SkRasterDevice(const SkBitmap& bitmap, const SkDeviceProperties& deviceProperties) |
+ : SkDevice(deviceProperties) |
+ , fBitmap(bitmap) { |
+} |
+ |
+SkDevice::SkDevice(const SkDeviceProperties& deviceProperties) |
+ : fLeakyProperties(deviceProperties) |
#ifdef SK_DEBUG |
, fAttachedToCanvas(false) |
#endif |
{ |
fOrigin.setZero(); |
fMetaData = NULL; |
+} |
+SkRasterDevice::SkRasterDevice(SkBitmap::Config config, int width, int height, bool isOpaque) { |
fBitmap.setConfig(config, width, height); |
fBitmap.allocPixels(); |
fBitmap.setIsOpaque(isOpaque); |
@@ -63,15 +64,9 @@ |
} |
} |
-SkDevice::SkDevice(SkBitmap::Config config, int width, int height, bool isOpaque, |
- const SkDeviceProperties& deviceProperties) |
- : fLeakyProperties(deviceProperties) |
-#ifdef SK_DEBUG |
- , fAttachedToCanvas(false) |
-#endif |
-{ |
- fOrigin.setZero(); |
- fMetaData = NULL; |
+SkRasterDevice::SkRasterDevice(SkBitmap::Config config, int width, int height, bool isOpaque, |
+ const SkDeviceProperties& deviceProperties) |
+ : SkDevice(deviceProperties) { |
fBitmap.setConfig(config, width, height); |
fBitmap.allocPixels(); |
@@ -85,7 +80,10 @@ |
delete fMetaData; |
} |
-void SkDevice::replaceBitmapBackendForRasterSurface(const SkBitmap& bm) { |
+SkRasterDevice::~SkRasterDevice() { |
+} |
+ |
+void SkRasterDevice::replaceBitmapBackendForRasterSurface(const SkBitmap& bm) { |
SkASSERT(bm.width() == fBitmap.width()); |
SkASSERT(bm.height() == fBitmap.height()); |
fBitmap = bm; // intent is to use bm's pixelRef (and rowbytes/config) |
@@ -106,11 +104,11 @@ |
isOpaque, kSaveLayer_Usage); |
} |
-SkDevice* SkDevice::onCreateCompatibleDevice(SkBitmap::Config config, |
- int width, int height, |
- bool isOpaque, |
- Usage usage) { |
- return SkNEW_ARGS(SkDevice,(config, width, height, isOpaque, fLeakyProperties)); |
+SkDevice* SkRasterDevice::onCreateCompatibleDevice(SkBitmap::Config config, |
+ int width, int height, |
+ bool isOpaque, |
+ Usage usage) { |
+ return SkNEW_ARGS(SkRasterDevice,(config, width, height, isOpaque, this->getDeviceProperties())); |
} |
SkMetaData& SkDevice::getMetaData() { |
@@ -122,54 +120,53 @@ |
return *fMetaData; |
} |
-void SkDevice::lockPixels() { |
+void SkRasterDevice::lockPixels() { |
if (fBitmap.lockPixelsAreWritable()) { |
fBitmap.lockPixels(); |
} |
} |
-void SkDevice::unlockPixels() { |
+void SkRasterDevice::unlockPixels() { |
if (fBitmap.lockPixelsAreWritable()) { |
fBitmap.unlockPixels(); |
} |
} |
const SkBitmap& SkDevice::accessBitmap(bool changePixels) { |
- const SkBitmap& bitmap = this->onAccessBitmap(&fBitmap); |
+ const SkBitmap& bitmap = this->onAccessBitmap(); |
if (changePixels) { |
bitmap.notifyPixelsChanged(); |
} |
return bitmap; |
} |
-void SkDevice::getGlobalBounds(SkIRect* bounds) const { |
+void SkRasterDevice::getGlobalBounds(SkIRect* bounds) const { |
if (bounds) { |
- bounds->setXYWH(fOrigin.x(), fOrigin.y(), |
+ const SkIPoint& origin = this->getOrigin(); |
+ bounds->setXYWH(origin.x(), origin.y(), |
fBitmap.width(), fBitmap.height()); |
} |
} |
-void SkDevice::clear(SkColor color) { |
+void SkRasterDevice::clear(SkColor color) { |
fBitmap.eraseColor(color); |
} |
-const SkBitmap& SkDevice::onAccessBitmap(SkBitmap* bitmap) {return *bitmap;} |
- |
-void SkDevice::setMatrixClip(const SkMatrix& matrix, const SkRegion& region, |
- const SkClipStack& clipStack) { |
+const SkBitmap& SkRasterDevice::onAccessBitmap() { |
+ return fBitmap; |
} |
-bool SkDevice::canHandleImageFilter(SkImageFilter*) { |
+bool SkRasterDevice::canHandleImageFilter(SkImageFilter*) { |
return false; |
} |
-bool SkDevice::filterImage(SkImageFilter* filter, const SkBitmap& src, |
- const SkMatrix& ctm, SkBitmap* result, |
- SkIPoint* offset) { |
+bool SkRasterDevice::filterImage(SkImageFilter* filter, const SkBitmap& src, |
+ const SkMatrix& ctm, SkBitmap* result, |
+ SkIPoint* offset) { |
return false; |
} |
-bool SkDevice::allowImageFilter(SkImageFilter*) { |
+bool SkRasterDevice::allowImageFilter(SkImageFilter*) { |
return true; |
} |
@@ -232,9 +229,9 @@ |
#include <SkConfig8888.h> |
-bool SkDevice::onReadPixels(const SkBitmap& bitmap, |
- int x, int y, |
- SkCanvas::Config8888 config8888) { |
+bool SkRasterDevice::onReadPixels(const SkBitmap& bitmap, |
+ int x, int y, |
+ SkCanvas::Config8888 config8888) { |
SkASSERT(SkBitmap::kARGB_8888_Config == bitmap.config()); |
SkASSERT(!bitmap.isNull()); |
SkASSERT(SkIRect::MakeWH(this->width(), this->height()).contains(SkIRect::MakeXYWH(x, y, bitmap.width(), bitmap.height()))); |
@@ -257,9 +254,9 @@ |
return true; |
} |
-void SkDevice::writePixels(const SkBitmap& bitmap, |
- int x, int y, |
- SkCanvas::Config8888 config8888) { |
+void SkRasterDevice::writePixels(const SkBitmap& bitmap, |
+ int x, int y, |
+ SkCanvas::Config8888 config8888) { |
if (bitmap.isNull() || bitmap.getTexture()) { |
return; |
} |
@@ -328,22 +325,22 @@ |
/////////////////////////////////////////////////////////////////////////////// |
-void SkDevice::drawPaint(const SkDraw& draw, const SkPaint& paint) { |
+void SkRasterDevice::drawPaint(const SkDraw& draw, const SkPaint& paint) { |
draw.drawPaint(paint); |
} |
-void SkDevice::drawPoints(const SkDraw& draw, SkCanvas::PointMode mode, size_t count, |
+void SkRasterDevice::drawPoints(const SkDraw& draw, SkCanvas::PointMode mode, size_t count, |
const SkPoint pts[], const SkPaint& paint) { |
CHECK_FOR_NODRAW_ANNOTATION(paint); |
draw.drawPoints(mode, count, pts, paint); |
} |
-void SkDevice::drawRect(const SkDraw& draw, const SkRect& r, const SkPaint& paint) { |
+void SkRasterDevice::drawRect(const SkDraw& draw, const SkRect& r, const SkPaint& paint) { |
CHECK_FOR_NODRAW_ANNOTATION(paint); |
draw.drawRect(r, paint); |
} |
-void SkDevice::drawOval(const SkDraw& draw, const SkRect& oval, const SkPaint& paint) { |
+void SkRasterDevice::drawOval(const SkDraw& draw, const SkRect& oval, const SkPaint& paint) { |
CHECK_FOR_NODRAW_ANNOTATION(paint); |
SkPath path; |
@@ -353,7 +350,7 @@ |
this->drawPath(draw, path, paint, NULL, true); |
} |
-void SkDevice::drawRRect(const SkDraw& draw, const SkRRect& rrect, const SkPaint& paint) { |
+void SkRasterDevice::drawRRect(const SkDraw& draw, const SkRRect& rrect, const SkPaint& paint) { |
CHECK_FOR_NODRAW_ANNOTATION(paint); |
SkPath path; |
@@ -363,21 +360,21 @@ |
this->drawPath(draw, path, paint, NULL, true); |
} |
-void SkDevice::drawPath(const SkDraw& draw, const SkPath& path, |
- const SkPaint& paint, const SkMatrix* prePathMatrix, |
- bool pathIsMutable) { |
+void SkRasterDevice::drawPath(const SkDraw& draw, const SkPath& path, |
+ const SkPaint& paint, const SkMatrix* prePathMatrix, |
+ bool pathIsMutable) { |
CHECK_FOR_NODRAW_ANNOTATION(paint); |
draw.drawPath(path, paint, prePathMatrix, pathIsMutable); |
} |
-void SkDevice::drawBitmap(const SkDraw& draw, const SkBitmap& bitmap, |
- const SkMatrix& matrix, const SkPaint& paint) { |
+void SkRasterDevice::drawBitmap(const SkDraw& draw, const SkBitmap& bitmap, |
+ const SkMatrix& matrix, const SkPaint& paint) { |
draw.drawBitmap(bitmap, matrix, paint); |
} |
-void SkDevice::drawBitmapRect(const SkDraw& draw, const SkBitmap& bitmap, |
- const SkRect* src, const SkRect& dst, |
- const SkPaint& paint) { |
+void SkRasterDevice::drawBitmapRect(const SkDraw& draw, const SkBitmap& bitmap, |
+ const SkRect* src, const SkRect& dst, |
+ const SkPaint& paint) { |
SkMatrix matrix; |
SkRect bitmapBounds, tmpSrc, tmpDst; |
SkBitmap tmpBitmap; |
@@ -461,56 +458,56 @@ |
this->drawRect(draw, *dstPtr, paintWithShader); |
} |
-void SkDevice::drawSprite(const SkDraw& draw, const SkBitmap& bitmap, |
- int x, int y, const SkPaint& paint) { |
+void SkRasterDevice::drawSprite(const SkDraw& draw, const SkBitmap& bitmap, |
+ int x, int y, const SkPaint& paint) { |
draw.drawSprite(bitmap, x, y, paint); |
} |
-void SkDevice::drawText(const SkDraw& draw, const void* text, size_t len, |
- SkScalar x, SkScalar y, const SkPaint& paint) { |
+void SkRasterDevice::drawText(const SkDraw& draw, const void* text, size_t len, |
+ SkScalar x, SkScalar y, const SkPaint& paint) { |
draw.drawText((const char*)text, len, x, y, paint); |
} |
-void SkDevice::drawPosText(const SkDraw& draw, const void* text, size_t len, |
- const SkScalar xpos[], SkScalar y, |
- int scalarsPerPos, const SkPaint& paint) { |
+void SkRasterDevice::drawPosText(const SkDraw& draw, const void* text, size_t len, |
+ const SkScalar xpos[], SkScalar y, |
+ int scalarsPerPos, const SkPaint& paint) { |
draw.drawPosText((const char*)text, len, xpos, y, scalarsPerPos, paint); |
} |
-void SkDevice::drawTextOnPath(const SkDraw& draw, const void* text, |
- size_t len, const SkPath& path, |
- const SkMatrix* matrix, |
- const SkPaint& paint) { |
+void SkRasterDevice::drawTextOnPath(const SkDraw& draw, const void* text, |
+ size_t len, const SkPath& path, |
+ const SkMatrix* matrix, |
+ const SkPaint& paint) { |
draw.drawTextOnPath((const char*)text, len, path, matrix, paint); |
} |
#ifdef SK_BUILD_FOR_ANDROID |
-void SkDevice::drawPosTextOnPath(const SkDraw& draw, const void* text, size_t len, |
- const SkPoint pos[], const SkPaint& paint, |
- const SkPath& path, const SkMatrix* matrix) { |
+void SkRasterDevice::drawPosTextOnPath(const SkDraw& draw, const void* text, size_t len, |
+ const SkPoint pos[], const SkPaint& paint, |
+ const SkPath& path, const SkMatrix* matrix) { |
draw.drawPosTextOnPath((const char*)text, len, pos, paint, path, matrix); |
} |
#endif |
-void SkDevice::drawVertices(const SkDraw& draw, SkCanvas::VertexMode vmode, |
- int vertexCount, |
- const SkPoint verts[], const SkPoint textures[], |
- const SkColor colors[], SkXfermode* xmode, |
- const uint16_t indices[], int indexCount, |
- const SkPaint& paint) { |
+void SkRasterDevice::drawVertices(const SkDraw& draw, SkCanvas::VertexMode vmode, |
+ int vertexCount, |
+ const SkPoint verts[], const SkPoint textures[], |
+ const SkColor colors[], SkXfermode* xmode, |
+ const uint16_t indices[], int indexCount, |
+ const SkPaint& paint) { |
draw.drawVertices(vmode, vertexCount, verts, textures, colors, xmode, |
indices, indexCount, paint); |
} |
-void SkDevice::drawDevice(const SkDraw& draw, SkDevice* device, |
- int x, int y, const SkPaint& paint) { |
+void SkRasterDevice::drawDevice(const SkDraw& draw, SkDevice* device, |
+ int x, int y, const SkPaint& paint) { |
const SkBitmap& src = device->accessBitmap(false); |
draw.drawSprite(src, x, y, paint); |
} |
/////////////////////////////////////////////////////////////////////////////// |
-bool SkDevice::filterTextFlags(const SkPaint& paint, TextFlags* flags) { |
+bool SkRasterDevice::filterTextFlags(const SkPaint& paint, TextFlags* flags) { |
if (!paint.isLCDRenderText() || !paint.isAntiAlias()) { |
// we're cool with the paint as is |
return false; |