Snap the bitmap as it may be changed later
Bug: skia: Change-Id: If06510f6fd3b64cce3440a543973c9c83913da10 Reviewed-on: https://skia-review.googlesource.com/120141 Reviewed-by: Brian Salomon <bsalomon@google.com> Commit-Queue: Yuqian Li <liyuqian@google.com>
This commit is contained in:
parent
a16e1b6c00
commit
6b7b1dcc86
@ -161,6 +161,15 @@ void SkThreadedBMPDevice::drawPath(const SkPath& path, const SkPaint& paint,
|
||||
}
|
||||
}
|
||||
|
||||
SkBitmap SkThreadedBMPDevice::snapBitmap(const SkBitmap& bitmap) {
|
||||
// We can't use bitmap.isImmutable() because it could be temporarily immutable
|
||||
// TODO(liyuqian): use genID to reduce the copy frequency
|
||||
SkBitmap snap;
|
||||
snap.allocPixels(bitmap.info());
|
||||
bitmap.readPixels(snap.pixmap());
|
||||
return snap;
|
||||
}
|
||||
|
||||
void SkThreadedBMPDevice::drawBitmap(const SkBitmap& bitmap, const SkMatrix& matrix,
|
||||
const SkRect* dstOrNull, const SkPaint& paint) {
|
||||
SkRect drawBounds;
|
||||
@ -173,16 +182,18 @@ void SkThreadedBMPDevice::drawBitmap(const SkBitmap& bitmap, const SkMatrix& mat
|
||||
clonedDstOrNull = fAlloc.make<SkRect>(*dstOrNull);
|
||||
}
|
||||
|
||||
SkBitmap snap = this->snapBitmap(bitmap);
|
||||
fQueue.push(drawBounds, [=](SkArenaAlloc*, const DrawState& ds, const SkIRect& tileBounds){
|
||||
TileDraw(ds, tileBounds).drawBitmap(bitmap, matrix, clonedDstOrNull, paint);
|
||||
TileDraw(ds, tileBounds).drawBitmap(snap, matrix, clonedDstOrNull, paint);
|
||||
});
|
||||
}
|
||||
|
||||
void SkThreadedBMPDevice::drawSprite(const SkBitmap& bitmap, int x, int y, const SkPaint& paint) {
|
||||
SkRect drawBounds = SkRect::MakeXYWH(x, y, bitmap.width(), bitmap.height());
|
||||
SkBitmap snap = this->snapBitmap(bitmap);
|
||||
fQueue.push<false>(drawBounds, [=](SkArenaAlloc*, const DrawState& ds,
|
||||
const SkIRect& tileBounds){
|
||||
TileDraw(ds, tileBounds).drawSprite(bitmap, x, y, paint);
|
||||
TileDraw(ds, tileBounds).drawSprite(snap, x, y, paint);
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -183,6 +183,8 @@ private:
|
||||
return clone;
|
||||
}
|
||||
|
||||
SkBitmap snapBitmap(const SkBitmap& bitmap);
|
||||
|
||||
const int fTileCnt;
|
||||
const int fThreadCnt;
|
||||
SkTArray<SkIRect> fTileBounds;
|
||||
|
Loading…
Reference in New Issue
Block a user