diff --git a/engine/src/flutter/flow/raster_cache.cc b/engine/src/flutter/flow/raster_cache.cc index 74bdd619b04..e603a37d766 100644 --- a/engine/src/flutter/flow/raster_cache.cc +++ b/engine/src/flutter/flow/raster_cache.cc @@ -34,8 +34,17 @@ void RasterCacheResult::draw(SkCanvas& canvas, const SkPaint* paint) const { SkRect bounds = RasterCacheUtil::GetDeviceBounds(logical_rect_, canvas.getTotalMatrix()); - FML_DCHECK(std::abs(bounds.width() - image_->dimensions().width()) <= 1 && - std::abs(bounds.height() - image_->dimensions().height()) <= 1); +#ifndef NDEBUG + // The image dimensions should always be larger than the device bounds and + // smaller than the device bounds plus one pixel, at the same time, we must + // introduce epsilon to solve the round-off error. The value of epsilon is + // 1/512, which represents half of an AA sample. + float epsilon = 1 / 512.0; + FML_DCHECK(image_->dimensions().width() - bounds.width() > -epsilon && + image_->dimensions().height() - bounds.height() > -epsilon && + image_->dimensions().width() - bounds.width() < 1 + epsilon && + image_->dimensions().height() - bounds.height() < 1 + epsilon); +#endif canvas.resetMatrix(); flow_.Step(); canvas.drawImage(image_, bounds.fLeft, bounds.fTop, SkSamplingOptions(),