Chromium Code Reviews| Index: cc/tiles/software_image_decode_controller.cc |
| diff --git a/cc/tiles/software_image_decode_controller.cc b/cc/tiles/software_image_decode_controller.cc |
| index bca4e99010465dde00a3a517f0164d4ecdca1f33..b27bb869124b51ff607d4306f4053c6b96ed6612 100644 |
| --- a/cc/tiles/software_image_decode_controller.cc |
| +++ b/cc/tiles/software_image_decode_controller.cc |
| @@ -833,6 +833,45 @@ void SoftwareImageDecodeController::SanityCheckState(int line, |
| #endif // DCHECK_IS_ON() |
| } |
| +namespace { |
|
vmpstr
2016/09/23 18:45:39
Move this to the top of the file please.
|
| + |
| +bool shouldDrawHighQuality(const DrawImage& image, |
|
vmpstr
2016/09/23 18:45:39
ShouldDrawHighQuality
|
| + const gfx::Size& target_size) { |
| + // Drop from high to medium if the the matrix we applied wasn't decomposable, |
| + // or if the scaled image will be too large. |
| + if (!image.matrix_is_decomposable()) { |
|
vmpstr
2016/09/23 18:45:39
braces optional for one liners
|
| + return false; |
| + } |
| + |
| + base::CheckedNumeric<size_t> size = 4u; |
| + size *= target_size.width(); |
| + size *= target_size.height(); |
| + if (size.ValueOrDefault(std::numeric_limits<size_t>::max()) > |
| + kMaxHighQualityImageSizeBytes) { |
| + return false; |
| + } |
| + |
| + // Filtering twice due to non-trivial transforms or subpixel phase produces |
| + // results worse than kMedium or kLow. Just steer clear. |
| + if (!image.matrix().isScaleTranslate()) { |
|
vmpstr
2016/09/23 18:45:39
Can you reorder these checks so that the easy chec
|
| + return false; |
| + } |
| + |
| + SkRect dest; |
| + image.matrix().mapRectScaleTranslate(&dest, SkRect::Make(image.src_rect())); |
| + const SkIRect idest = dest.round(); |
| + if (!SkScalarNearlyEqual(dest.left(), idest.left()) || |
| + !SkScalarNearlyEqual(dest.top(), idest.top()) || |
| + !SkScalarNearlyEqual(dest.right(), idest.right()) || |
| + !SkScalarNearlyEqual(dest.bottom(), idest.bottom())) { |
| + return false; |
| + } |
| + |
| + return true; |
| +} |
|
vmpstr
2016/09/23 18:45:39
I wonder if we should just drop to medium for down
|
| + |
| +} // anonymous namespace |
| + |
| // SoftwareImageDecodeControllerKey |
| ImageDecodeControllerKey ImageDecodeControllerKey::FromDrawImage( |
| const DrawImage& image) { |
| @@ -860,20 +899,9 @@ ImageDecodeControllerKey ImageDecodeControllerKey::FromDrawImage( |
| quality = std::min(quality, kLow_SkFilterQuality); |
| } |
| - // Drop from high to medium if the the matrix we applied wasn't decomposable, |
| - // or if the scaled image will be too large. |
| - if (quality == kHigh_SkFilterQuality) { |
| - if (!image.matrix_is_decomposable()) { |
| - quality = kMedium_SkFilterQuality; |
| - } else { |
| - base::CheckedNumeric<size_t> size = 4u; |
| - size *= target_size.width(); |
| - size *= target_size.height(); |
| - if (size.ValueOrDefault(std::numeric_limits<size_t>::max()) > |
| - kMaxHighQualityImageSizeBytes) { |
| - quality = kMedium_SkFilterQuality; |
| - } |
| - } |
| + if (quality == kHigh_SkFilterQuality && |
| + !shouldDrawHighQuality(image, target_size)) { |
| + quality = kMedium_SkFilterQuality; |
| } |
| // Drop from medium to low if the matrix we applied wasn't decomposable or if |