Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 323d3cd5 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Brought back compatibility check for falling back on dest_out whenever...

Merge "Brought back compatibility check for falling back on dest_out whenever clear is used as a blend mode to draw bitmaps"
parents 78017c4e f9f964d8
Loading
Loading
Loading
Loading
+6 −17
Original line number Original line Diff line number Diff line
@@ -161,8 +161,7 @@ void SkiaRecordingCanvas::drawVectorDrawable(VectorDrawableRoot* tree) {
// Recording Canvas draw operations: Bitmaps
// Recording Canvas draw operations: Bitmaps
// ----------------------------------------------------------------------------
// ----------------------------------------------------------------------------


SkiaCanvas::PaintCoW&& SkiaRecordingCanvas::filterBitmap(PaintCoW&& paint,
SkiaCanvas::PaintCoW&& SkiaRecordingCanvas::filterBitmap(PaintCoW&& paint) {
                                                         sk_sp<SkColorFilter> colorSpaceFilter) {
    bool fixBlending = false;
    bool fixBlending = false;
    bool fixAA = false;
    bool fixAA = false;
    if (paint) {
    if (paint) {
@@ -172,23 +171,13 @@ SkiaCanvas::PaintCoW&& SkiaRecordingCanvas::filterBitmap(PaintCoW&& paint,
        fixAA = paint->isAntiAlias();
        fixAA = paint->isAntiAlias();
    }
    }


    if (fixBlending || fixAA || colorSpaceFilter) {
    if (fixBlending || fixAA) {
        SkPaint& tmpPaint = paint.writeable();
        SkPaint& tmpPaint = paint.writeable();


        if (fixBlending) {
        if (fixBlending) {
            tmpPaint.setBlendMode(SkBlendMode::kDstOut);
            tmpPaint.setBlendMode(SkBlendMode::kDstOut);
        }
        }


        if (colorSpaceFilter) {
            if (tmpPaint.getColorFilter()) {
                tmpPaint.setColorFilter(SkColorFilters::Compose(
                        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
        // disabling AA on bitmap draws matches legacy HWUI behavior
        tmpPaint.setAntiAlias(false);
        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) {
void SkiaRecordingCanvas::drawBitmap(Bitmap& bitmap, float left, float top, const SkPaint* paint) {
    sk_sp<SkImage> image = bitmap.makeImage();
    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
    // 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
    // it is not safe to store a raw SkImage pointer, because the image object will be destroyed
    // when this function ends.
    // when this function ends.
@@ -212,7 +201,7 @@ void SkiaRecordingCanvas::drawBitmap(Bitmap& bitmap, const SkMatrix& matrix, con
    concat(matrix);
    concat(matrix);


    sk_sp<SkImage> image = bitmap.makeImage();
    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()) {
    if (!bitmap.isImmutable() && image.get() && !image->unique()) {
        mDisplayList->mMutableImages.push_back(image.get());
        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);
    SkRect dstRect = SkRect::MakeLTRB(dstLeft, dstTop, dstRight, dstBottom);


    sk_sp<SkImage> image = bitmap.makeImage();
    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());
                            SkCanvas::kFast_SrcRectConstraint, bitmap.palette());
    if (!bitmap.isImmutable() && image.get() && !image->unique() && !srcRect.isEmpty() &&
    if (!bitmap.isImmutable() && image.get() && !image->unique() && !srcRect.isEmpty() &&
        !dstRect.isEmpty()) {
        !dstRect.isEmpty()) {
@@ -263,7 +252,7 @@ void SkiaRecordingCanvas::drawNinePatch(Bitmap& bitmap, const Res_png_9patch& ch
        filteredPaint.writeable().setFilterQuality(kLow_SkFilterQuality);
        filteredPaint.writeable().setFilterQuality(kLow_SkFilterQuality);
    }
    }
    sk_sp<SkImage> image = bitmap.makeImage();
    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());
                               bitmap.palette());
    if (!bitmap.isImmutable() && image.get() && !image->unique() && !dst.isEmpty()) {
    if (!bitmap.isImmutable() && image.get() && !image->unique() && !dst.isEmpty()) {
        mDisplayList->mMutableImages.push_back(image.get());
        mDisplayList->mMutableImages.push_back(image.get());
+1 −1
Original line number Original line Diff line number Diff line
@@ -90,7 +90,7 @@ private:
     */
     */
    void initDisplayList(uirenderer::RenderNode* renderNode, int width, int height);
    void initDisplayList(uirenderer::RenderNode* renderNode, int width, int height);


    PaintCoW&& filterBitmap(PaintCoW&& paint, sk_sp<SkColorFilter> colorSpaceFilter);
    PaintCoW&& filterBitmap(PaintCoW&& paint);
};
};


}  // namespace skiapipeline
}  // namespace skiapipeline