Commit 414fa9b7 authored by Khushal's avatar Khushal Committed by Commit Bot

cc: Avoid unnecessary temp allocation for original decodes in GPU cache.

The change in [1] inadvertantly caused us to allocate a temporary buffer
for decoding an image and then copying into the target memory, if
requested with kNone_SkFilterQuality. Fix it.

[1]: https://chromium-review.googlesource.com/c/chromium/src/+/1106608

R=ericrk@chromium.org

Bug: 855416
Cq-Include-Trybots: luci.chromium.try:android_optional_gpu_tests_rel;master.tryserver.blink:linux_trusty_blink_rel
Change-Id: I01d23176ae12808022f67286025243bcaab655ed
Reviewed-on: https://chromium-review.googlesource.com/1119348Reviewed-by: default avatarEric Karl <ericrk@chromium.org>
Commit-Queue: Khushal <khushalsagar@chromium.org>
Cr-Commit-Position: refs/heads/master@{#571337}
parent 5ea6fa63
...@@ -138,12 +138,18 @@ bool DrawAndScaleImage(const DrawImage& draw_image, SkPixmap* target_pixmap) { ...@@ -138,12 +138,18 @@ bool DrawAndScaleImage(const DrawImage& draw_image, SkPixmap* target_pixmap) {
sk_sp<SkColorSpace> color_space = target_pixmap->info().refColorSpace(); sk_sp<SkColorSpace> color_space = target_pixmap->info().refColorSpace();
const PaintImage& paint_image = draw_image.paint_image(); const PaintImage& paint_image = draw_image.paint_image();
SkISize supported_size = const bool is_original_decode =
paint_image.GetSupportedDecodeSize(pixmap.bounds().size()); SkISize::Make(paint_image.width(), paint_image.height()) ==
pixmap.bounds().size();
const bool is_nearest_neighbor = const bool is_nearest_neighbor =
draw_image.filter_quality() == kNone_SkFilterQuality; draw_image.filter_quality() == kNone_SkFilterQuality;
if (supported_size == pixmap.bounds().size() && !is_nearest_neighbor) {
SkISize supported_size =
paint_image.GetSupportedDecodeSize(pixmap.bounds().size());
// We can directly decode into target pixmap if we are doing an original
// decode or we are decoding to scale without nearest neighbor filtering.
const bool can_directly_decode = is_original_decode || !is_nearest_neighbor;
if (supported_size == pixmap.bounds().size() && can_directly_decode) {
SkImageInfo info = pixmap.info(); SkImageInfo info = pixmap.info();
return paint_image.Decode(pixmap.writable_addr(), &info, color_space, return paint_image.Decode(pixmap.writable_addr(), &info, color_space,
draw_image.frame_index()); draw_image.frame_index());
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment