Brought back compatibility check for falling back on dest_out

whenever clear is used as a blend mode to draw bitmaps

Modified SkiaRecordingCanvas to call filterBitmap instead of
filterPaint in order to conduct the necessary compatibility checks
to use dest_out instead of clear whenever a bitmap is drawn

Test: In progress..
Bug: 131689368
Change-Id: I56d015e773b312cac948d850ca2997d8df0cc66d
Merged-In: I56d015e773b312cac948d850ca2997d8df0cc66d
This commit is contained in:
Nader Jawad
2019-05-24 10:33:55 -07:00
parent 0c1f41d303
commit 476d0d1605
2 changed files with 7 additions and 18 deletions

View File

@@ -161,8 +161,7 @@ void SkiaRecordingCanvas::drawVectorDrawable(VectorDrawableRoot* tree) {
// Recording Canvas draw operations: Bitmaps
// ----------------------------------------------------------------------------
SkiaCanvas::PaintCoW&& SkiaRecordingCanvas::filterBitmap(PaintCoW&& paint,
sk_sp<SkColorFilter> colorSpaceFilter) {
SkiaCanvas::PaintCoW&& SkiaRecordingCanvas::filterBitmap(PaintCoW&& paint) {
bool fixBlending = false;
bool fixAA = false;
if (paint) {
@@ -172,23 +171,13 @@ SkiaCanvas::PaintCoW&& SkiaRecordingCanvas::filterBitmap(PaintCoW&& paint,
fixAA = paint->isAntiAlias();
}
if (fixBlending || fixAA || colorSpaceFilter) {
if (fixBlending || fixAA) {
SkPaint& tmpPaint = paint.writeable();
if (fixBlending) {
tmpPaint.setBlendMode(SkBlendMode::kDstOut);
}
if (colorSpaceFilter) {
if (tmpPaint.getColorFilter()) {
tmpPaint.setColorFilter(SkColorFilter::MakeComposeFilter(
tmpPaint.refColorFilter(), std::move(colorSpaceFilter)));
} else {
tmpPaint.setColorFilter(std::move(colorSpaceFilter));
}
LOG_ALWAYS_FATAL_IF(!tmpPaint.getColorFilter());
}
// disabling AA on bitmap draws matches legacy HWUI behavior
tmpPaint.setAntiAlias(false);
}
@@ -198,7 +187,7 @@ SkiaCanvas::PaintCoW&& SkiaRecordingCanvas::filterBitmap(PaintCoW&& paint,
void SkiaRecordingCanvas::drawBitmap(Bitmap& bitmap, float left, float top, const SkPaint* paint) {
sk_sp<SkImage> image = bitmap.makeImage();
mRecorder.drawImage(image, left, top, filterPaint(paint), bitmap.palette());
mRecorder.drawImage(image, left, top, filterBitmap(paint), bitmap.palette());
// if image->unique() is true, then mRecorder.drawImage failed for some reason. It also means
// it is not safe to store a raw SkImage pointer, because the image object will be destroyed
// when this function ends.
@@ -212,7 +201,7 @@ void SkiaRecordingCanvas::drawBitmap(Bitmap& bitmap, const SkMatrix& matrix, con
concat(matrix);
sk_sp<SkImage> image = bitmap.makeImage();
mRecorder.drawImage(image, 0, 0, filterPaint(paint), bitmap.palette());
mRecorder.drawImage(image, 0, 0, filterBitmap(paint), bitmap.palette());
if (!bitmap.isImmutable() && image.get() && !image->unique()) {
mDisplayList->mMutableImages.push_back(image.get());
}
@@ -225,7 +214,7 @@ void SkiaRecordingCanvas::drawBitmap(Bitmap& bitmap, float srcLeft, float srcTop
SkRect dstRect = SkRect::MakeLTRB(dstLeft, dstTop, dstRight, dstBottom);
sk_sp<SkImage> image = bitmap.makeImage();
mRecorder.drawImageRect(image, srcRect, dstRect, filterPaint(paint),
mRecorder.drawImageRect(image, srcRect, dstRect, filterBitmap(paint),
SkCanvas::kFast_SrcRectConstraint, bitmap.palette());
if (!bitmap.isImmutable() && image.get() && !image->unique() && !srcRect.isEmpty() &&
!dstRect.isEmpty()) {
@@ -263,7 +252,7 @@ void SkiaRecordingCanvas::drawNinePatch(Bitmap& bitmap, const Res_png_9patch& ch
filteredPaint.writeable().setFilterQuality(kLow_SkFilterQuality);
}
sk_sp<SkImage> image = bitmap.makeImage();
mRecorder.drawImageLattice(image, lattice, dst, filterPaint(std::move(filteredPaint)),
mRecorder.drawImageLattice(image, lattice, dst, filterBitmap(std::move(filteredPaint)),
bitmap.palette());
if (!bitmap.isImmutable() && image.get() && !image->unique() && !dst.isEmpty()) {
mDisplayList->mMutableImages.push_back(image.get());

View File

@@ -90,7 +90,7 @@ private:
*/
void initDisplayList(uirenderer::RenderNode* renderNode, int width, int height);
PaintCoW&& filterBitmap(PaintCoW&& paint, sk_sp<SkColorFilter> colorSpaceFilter);
PaintCoW&& filterBitmap(PaintCoW&& paint);
};
} // namespace skiapipeline