Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(138)

Side by Side Diff: cc/tiles/software_image_decode_cache.cc

Issue 2908143005: cc: Allow SkImage::makeColorSpace to fail (Closed)
Patch Set: cc: Allow SkImage::makeColorSpace to fail Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "cc/tiles/software_image_decode_cache.h" 5 #include "cc/tiles/software_image_decode_cache.h"
6 6
7 #include <inttypes.h> 7 #include <inttypes.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <algorithm> 10 #include <algorithm>
(...skipping 569 matching lines...) Expand 10 before | Expand all | Expand 10 after
580 base::DiscardableMemoryAllocator::GetInstance() 580 base::DiscardableMemoryAllocator::GetInstance()
581 ->AllocateLockedDiscardableMemory(decoded_info.minRowBytes() * 581 ->AllocateLockedDiscardableMemory(decoded_info.minRowBytes() *
582 decoded_info.height()); 582 decoded_info.height());
583 } 583 }
584 if (target_color_space) { 584 if (target_color_space) {
585 TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("cc.debug"), 585 TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("cc.debug"),
586 "SoftwareImageDecodeCache::GetOriginalSizeImageDecode - " 586 "SoftwareImageDecodeCache::GetOriginalSizeImageDecode - "
587 "color conversion"); 587 "color conversion");
588 image = image->makeColorSpace(target_color_space, 588 image = image->makeColorSpace(target_color_space,
589 SkTransferFunctionBehavior::kIgnore); 589 SkTransferFunctionBehavior::kIgnore);
590 DCHECK(image); 590 // Because image is a lazy-decode image, the call to makeColorSpace will
591 // fail if image decode fails.
592 if (!image) {
593 decoded_pixels->Unlock();
594 return nullptr;
595 }
591 } 596 }
592 { 597 {
593 TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("cc.debug"), 598 TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("cc.debug"),
594 "SoftwareImageDecodeCache::GetOriginalSizeImageDecode - " 599 "SoftwareImageDecodeCache::GetOriginalSizeImageDecode - "
595 "read pixels"); 600 "read pixels");
596 bool result = image->readPixels(decoded_info, decoded_pixels->data(), 601 bool result = image->readPixels(decoded_info, decoded_pixels->data(),
597 decoded_info.minRowBytes(), 0, 0, 602 decoded_info.minRowBytes(), 0, 0,
598 SkImage::kDisallow_CachingHint); 603 SkImage::kDisallow_CachingHint);
599 604
600 if (!result) { 605 if (!result) {
(...skipping 580 matching lines...) Expand 10 before | Expand all | Expand 10 after
1181 } 1186 }
1182 } 1187 }
1183 } 1188 }
1184 1189
1185 void SoftwareImageDecodeCache::OnPurgeMemory() { 1190 void SoftwareImageDecodeCache::OnPurgeMemory() {
1186 base::AutoLock lock(lock_); 1191 base::AutoLock lock(lock_);
1187 ReduceCacheUsageUntilWithinLimit(0); 1192 ReduceCacheUsageUntilWithinLimit(0);
1188 } 1193 }
1189 1194
1190 } // namespace cc 1195 } // namespace cc
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698