| Index: src/core/SkCanvas.cpp
|
| diff --git a/src/core/SkCanvas.cpp b/src/core/SkCanvas.cpp
|
| index dfc3f93789d643cabd95dd75ec12ee190bb7f8ac..7b98ad0ec2e7637f1611c38ecd6ea18488242c5d 100644
|
| --- a/src/core/SkCanvas.cpp
|
| +++ b/src/core/SkCanvas.cpp
|
| @@ -710,6 +710,50 @@ void SkCanvas::writePixels(const SkBitmap& bitmap, int x, int y,
|
| }
|
| }
|
|
|
| +bool SkCanvas::writePixels(const SkImageInfo& origInfo, const void* pixels, size_t rowBytes,
|
| + int x, int y) {
|
| + switch (origInfo.colorType()) {
|
| + case kUnknown_SkColorType:
|
| + case kIndex_8_SkColorType:
|
| + return false;
|
| + default:
|
| + break;
|
| + }
|
| + if (NULL == pixels || rowBytes < origInfo.minRowBytes()) {
|
| + return false;
|
| + }
|
| +
|
| + const SkISize size = this->getBaseLayerSize();
|
| + SkIRect target = SkIRect::MakeXYWH(x, y, origInfo.width(), origInfo.height());
|
| + if (!target.intersect(0, 0, size.width(), size.height())) {
|
| + return false;
|
| + }
|
| +
|
| + // should we call this->flush() for the device?
|
| + SkBaseDevice* device = this->getDevice();
|
| + if (!device) {
|
| + return false;
|
| + }
|
| +
|
| + SkImageInfo info = origInfo;
|
| + // the intersect may have shrunk info's logical size
|
| + info.fWidth = target.width();
|
| + info.fHeight = target.height();
|
| +
|
| + // if x or y are negative, then we have to adjust pixels
|
| + if (x > 0) {
|
| + x = 0;
|
| + }
|
| + if (y > 0) {
|
| + y = 0;
|
| + }
|
| + // here x,y are either 0 or negative
|
| + pixels = ((const char*)pixels - y * rowBytes - x * info.bytesPerPixel());
|
| +
|
| + // The device can assert that the requested area is always contained in its bounds
|
| + return device->writePixelsDirect(info, pixels, rowBytes, target.x(), target.y());
|
| +}
|
| +
|
| SkCanvas* SkCanvas::canvasForDrawIter() {
|
| return this;
|
| }
|
|
|