kClear blend mode is drawn as kDstOut
kClear blend mode is drawn as kDstOut on hardware canvas for compatibility with Android O and older. On SDK released with Android P, the kClear blend mode is respected. Bug: 71602378 Test: Ran Flo app Change-Id: I6b0fa8b8bf5aa14aa5a351a914bf2ed0469ac660
This commit is contained in:
@@ -148,31 +148,6 @@ void SkiaRecordingCanvas::drawVectorDrawable(VectorDrawableRoot* tree) {
|
||||
// Recording Canvas draw operations: Bitmaps
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
inline static const SkPaint* bitmapPaint(const SkPaint* origPaint, SkPaint* tmpPaint,
|
||||
sk_sp<SkColorFilter> colorSpaceFilter) {
|
||||
if ((origPaint && origPaint->isAntiAlias()) || colorSpaceFilter) {
|
||||
if (origPaint) {
|
||||
*tmpPaint = *origPaint;
|
||||
}
|
||||
|
||||
if (colorSpaceFilter) {
|
||||
if (tmpPaint->getColorFilter()) {
|
||||
tmpPaint->setColorFilter(
|
||||
SkColorFilter::MakeComposeFilter(tmpPaint->refColorFilter(), colorSpaceFilter));
|
||||
} else {
|
||||
tmpPaint->setColorFilter(colorSpaceFilter);
|
||||
}
|
||||
LOG_ALWAYS_FATAL_IF(!tmpPaint->getColorFilter());
|
||||
}
|
||||
|
||||
|
||||
// disabling AA on bitmap draws matches legacy HWUI behavior
|
||||
tmpPaint->setAntiAlias(false);
|
||||
return tmpPaint;
|
||||
} else {
|
||||
return origPaint;
|
||||
}
|
||||
}
|
||||
|
||||
void SkiaRecordingCanvas::drawBitmap(Bitmap& bitmap, float left, float top, const SkPaint* paint) {
|
||||
SkPaint tmpPaint;
|
||||
|
||||
@@ -88,6 +88,45 @@ private:
|
||||
* @param height used to calculate recording bounds.
|
||||
*/
|
||||
void initDisplayList(uirenderer::RenderNode* renderNode, int width, int height);
|
||||
|
||||
inline static const SkPaint* bitmapPaint(const SkPaint* origPaint, SkPaint* tmpPaint,
|
||||
sk_sp<SkColorFilter> colorSpaceFilter) {
|
||||
bool fixBlending = false;
|
||||
bool fixAA = false;
|
||||
if (origPaint) {
|
||||
// kClear blend mode is drawn as kDstOut on HW for compatibility with Android O and
|
||||
// older.
|
||||
fixBlending = sApiLevel <= 27 && origPaint->getBlendMode() == SkBlendMode::kClear;
|
||||
fixAA = origPaint->isAntiAlias();
|
||||
}
|
||||
|
||||
if (fixBlending || fixAA || colorSpaceFilter) {
|
||||
if (origPaint) {
|
||||
*tmpPaint = *origPaint;
|
||||
}
|
||||
|
||||
if (fixBlending) {
|
||||
tmpPaint->setBlendMode(SkBlendMode::kDstOut);
|
||||
}
|
||||
|
||||
if (colorSpaceFilter) {
|
||||
if (tmpPaint->getColorFilter()) {
|
||||
tmpPaint->setColorFilter(SkColorFilter::MakeComposeFilter(
|
||||
tmpPaint->refColorFilter(), colorSpaceFilter));
|
||||
} else {
|
||||
tmpPaint->setColorFilter(colorSpaceFilter);
|
||||
}
|
||||
LOG_ALWAYS_FATAL_IF(!tmpPaint->getColorFilter());
|
||||
}
|
||||
|
||||
// disabling AA on bitmap draws matches legacy HWUI behavior
|
||||
tmpPaint->setAntiAlias(false);
|
||||
return tmpPaint;
|
||||
} else {
|
||||
return origPaint;
|
||||
}
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
}; // namespace skiapipeline
|
||||
|
||||
Reference in New Issue
Block a user