In which a series of things around attachToCanvas and writePixels are fixed
Review URL: https://codereview.appspot.com/6506051/
git-svn-id: http://skia.googlecode.com/svn/trunk@5341 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/src/core/SkCanvas.cpp b/src/core/SkCanvas.cpp
index dc6da11..ba8042d 100644
--- a/src/core/SkCanvas.cpp
+++ b/src/core/SkCanvas.cpp
@@ -644,7 +644,11 @@
Config8888 config8888) {
SkDevice* device = this->getDevice();
if (device) {
- device->writePixels(bitmap, x, y, config8888);
+ if (SkIRect::Intersects(SkIRect::MakeSize(this->getDeviceSize()),
+ SkIRect::MakeXYWH(x, y, bitmap.width(), bitmap.height()))) {
+ device->accessBitmap(true);
+ device->writePixels(bitmap, x, y, config8888);
+ }
}
}
diff --git a/src/core/SkDevice.cpp b/src/core/SkDevice.cpp
index f8bed65..10d89d5 100644
--- a/src/core/SkDevice.cpp
+++ b/src/core/SkDevice.cpp
@@ -9,6 +9,7 @@
#include "SkDraw.h"
#include "SkImageFilter.h"
#include "SkMetaData.h"
+#include "SkRasterClip.h"
#include "SkRect.h"
SK_DEFINE_INST_COUNT(SkDevice)
@@ -299,8 +300,13 @@
SkPaint paint;
paint.setXfermodeMode(SkXfermode::kSrc_Mode);
- SkCanvas canvas(this);
- canvas.drawSprite(*sprite, x, y, &paint);
+ SkRasterClip clip(SkIRect::MakeWH(fBitmap.width(), fBitmap.height()));
+ SkDraw draw;
+ draw.fRC = &clip;
+ draw.fClip = &clip.bwRgn();
+ draw.fBitmap = &fBitmap; // canvas should have already called accessBitmap
+ draw.fMatrix = &SkMatrix::I();
+ this->drawSprite(draw, *sprite, x, y, paint);
}
///////////////////////////////////////////////////////////////////////////////