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

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

Issue 2258833002: Re-write many calls to WrapUnique() with MakeUnique() (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 4 years, 4 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 | « cc/tiles/raster_tile_priority_queue_all.cc ('k') | cc/tiles/tile_manager_unittest.cc » ('j') | 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_controller.h" 5 #include "cc/tiles/software_image_decode_controller.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 526 matching lines...) Expand 10 before | Expand all | Expand 10 after
537 "read pixels"); 537 "read pixels");
538 bool result = image->readPixels(decoded_info, decoded_pixels->data(), 538 bool result = image->readPixels(decoded_info, decoded_pixels->data(),
539 decoded_info.minRowBytes(), 0, 0, 539 decoded_info.minRowBytes(), 0, 0,
540 SkImage::kDisallow_CachingHint); 540 SkImage::kDisallow_CachingHint);
541 541
542 if (!result) { 542 if (!result) {
543 decoded_pixels->Unlock(); 543 decoded_pixels->Unlock();
544 return nullptr; 544 return nullptr;
545 } 545 }
546 } 546 }
547 return base::WrapUnique( 547 return base::MakeUnique<DecodedImage>(decoded_info, std::move(decoded_pixels),
548 new DecodedImage(decoded_info, std::move(decoded_pixels), 548 SkSize::Make(0, 0),
549 SkSize::Make(0, 0), next_tracing_id_.GetNext())); 549 next_tracing_id_.GetNext());
550 } 550 }
551 551
552 std::unique_ptr<SoftwareImageDecodeController::DecodedImage> 552 std::unique_ptr<SoftwareImageDecodeController::DecodedImage>
553 SoftwareImageDecodeController::GetSubrectImageDecode( 553 SoftwareImageDecodeController::GetSubrectImageDecode(
554 const ImageKey& key, 554 const ImageKey& key,
555 sk_sp<const SkImage> image) { 555 sk_sp<const SkImage> image) {
556 // Construct a key to use in GetDecodedImageForDrawInternal(). 556 // Construct a key to use in GetDecodedImageForDrawInternal().
557 // This allows us to reuse an image in any cache if available. 557 // This allows us to reuse an image in any cache if available.
558 gfx::Rect full_image_rect(image->width(), image->height()); 558 gfx::Rect full_image_rect(image->width(), image->height());
559 DrawImage original_size_draw_image(std::move(image), 559 DrawImage original_size_draw_image(std::move(image),
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
652 DCHECK(key.filter_quality() == kHigh_SkFilterQuality || 652 DCHECK(key.filter_quality() == kHigh_SkFilterQuality ||
653 key.filter_quality() == kMedium_SkFilterQuality); 653 key.filter_quality() == kMedium_SkFilterQuality);
654 { 654 {
655 TRACE_EVENT0("disabled-by-default-cc.debug", 655 TRACE_EVENT0("disabled-by-default-cc.debug",
656 "SoftwareImageDecodeController::ScaleImage - scale pixels"); 656 "SoftwareImageDecodeController::ScaleImage - scale pixels");
657 bool result = 657 bool result =
658 decoded_pixmap.scalePixels(scaled_pixmap, key.filter_quality()); 658 decoded_pixmap.scalePixels(scaled_pixmap, key.filter_quality());
659 DCHECK(result) << key.ToString(); 659 DCHECK(result) << key.ToString();
660 } 660 }
661 661
662 return base::WrapUnique( 662 return base::MakeUnique<DecodedImage>(
663 new DecodedImage(scaled_info, std::move(scaled_pixels), 663 scaled_info, std::move(scaled_pixels),
664 SkSize::Make(-key.src_rect().x(), -key.src_rect().y()), 664 SkSize::Make(-key.src_rect().x(), -key.src_rect().y()),
665 next_tracing_id_.GetNext())); 665 next_tracing_id_.GetNext());
666 } 666 }
667 667
668 void SoftwareImageDecodeController::DrawWithImageFinished( 668 void SoftwareImageDecodeController::DrawWithImageFinished(
669 const DrawImage& image, 669 const DrawImage& image,
670 const DecodedDrawImage& decoded_image) { 670 const DecodedDrawImage& decoded_image) {
671 TRACE_EVENT1("disabled-by-default-cc.debug", 671 TRACE_EVENT1("disabled-by-default-cc.debug",
672 "SoftwareImageDecodeController::DrawWithImageFinished", "key", 672 "SoftwareImageDecodeController::DrawWithImageFinished", "key",
673 ImageKey::FromDrawImage(image).ToString()); 673 ImageKey::FromDrawImage(image).ToString());
674 ImageKey key = ImageKey::FromDrawImage(image); 674 ImageKey key = ImageKey::FromDrawImage(image);
675 if (!decoded_image.image()) 675 if (!decoded_image.image())
(...skipping 396 matching lines...) Expand 10 before | Expand all | Expand 10 after
1072 void SoftwareImageDecodeController::MemoryBudget::ResetUsage() { 1072 void SoftwareImageDecodeController::MemoryBudget::ResetUsage() {
1073 current_usage_bytes_ = 0; 1073 current_usage_bytes_ = 0;
1074 } 1074 }
1075 1075
1076 size_t SoftwareImageDecodeController::MemoryBudget::GetCurrentUsageSafe() 1076 size_t SoftwareImageDecodeController::MemoryBudget::GetCurrentUsageSafe()
1077 const { 1077 const {
1078 return current_usage_bytes_.ValueOrDie(); 1078 return current_usage_bytes_.ValueOrDie();
1079 } 1079 }
1080 1080
1081 } // namespace cc 1081 } // namespace cc
OLDNEW
« no previous file with comments | « cc/tiles/raster_tile_priority_queue_all.cc ('k') | cc/tiles/tile_manager_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698