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

Side by Side Diff: ui/gfx/image/image.cc

Issue 2665623002: Fix Jumplist favicons to have high resolution in HDPI Windows displays (Closed)
Patch Set: Update comments and remove redundant .h files. Created 3 years, 10 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "ui/gfx/image/image.h" 5 #include "ui/gfx/image/image.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <set> 8 #include <set>
9 #include <utility> 9 #include <utility>
10 10
(...skipping 464 matching lines...) Expand 10 before | Expand all | Expand 10 after
475 std::vector<ImagePNGRep> image_reps; 475 std::vector<ImagePNGRep> image_reps;
476 image_reps.push_back(ImagePNGRep(input, 1.0f)); 476 image_reps.push_back(ImagePNGRep(input, 1.0f));
477 return Image(image_reps); 477 return Image(image_reps);
478 } 478 }
479 479
480 const SkBitmap* Image::ToSkBitmap() const { 480 const SkBitmap* Image::ToSkBitmap() const {
481 // Possibly create and cache an intermediate ImageRepSkia. 481 // Possibly create and cache an intermediate ImageRepSkia.
482 return ToImageSkia()->bitmap(); 482 return ToImageSkia()->bitmap();
483 } 483 }
484 484
485 const SkBitmap* Image::ToSkBitmap2x() const {
486 // Possibly create and cache an intermediate ImageRepSkia.
487 return ToImageSkia()->bitmap2x();
488 }
489
485 const ImageSkia* Image::ToImageSkia() const { 490 const ImageSkia* Image::ToImageSkia() const {
486 internal::ImageRep* rep = GetRepresentation(kImageRepSkia, false); 491 internal::ImageRep* rep = GetRepresentation(kImageRepSkia, false);
487 if (!rep) { 492 if (!rep) {
488 std::unique_ptr<internal::ImageRep> scoped_rep; 493 std::unique_ptr<internal::ImageRep> scoped_rep;
489 switch (DefaultRepresentationType()) { 494 switch (DefaultRepresentationType()) {
490 case kImageRepPNG: { 495 case kImageRepPNG: {
491 internal::ImageRepPNG* png_rep = 496 internal::ImageRepPNG* png_rep =
492 GetRepresentation(kImageRepPNG, true)->AsImageRepPNG(); 497 GetRepresentation(kImageRepPNG, true)->AsImageRepPNG();
493 scoped_rep.reset(new internal::ImageRepSkia( 498 scoped_rep.reset(new internal::ImageRepSkia(
494 internal::ImageSkiaFromPNG(png_rep->image_reps()))); 499 internal::ImageSkiaFromPNG(png_rep->image_reps())));
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
646 image_png_reps.push_back(ImagePNGRep(png_bytes, 1.0f)); 651 image_png_reps.push_back(ImagePNGRep(png_bytes, 1.0f));
647 AddRepresentation( 652 AddRepresentation(
648 base::WrapUnique(new internal::ImageRepPNG(image_png_reps))); 653 base::WrapUnique(new internal::ImageRepPNG(image_png_reps)));
649 return png_bytes; 654 return png_bytes;
650 } 655 }
651 656
652 SkBitmap Image::AsBitmap() const { 657 SkBitmap Image::AsBitmap() const {
653 return IsEmpty() ? SkBitmap() : *ToSkBitmap(); 658 return IsEmpty() ? SkBitmap() : *ToSkBitmap();
654 } 659 }
655 660
661 SkBitmap Image::AsBitmap2x() const {
662 return IsEmpty() ? SkBitmap() : *ToSkBitmap2x();
663 }
664
656 ImageSkia Image::AsImageSkia() const { 665 ImageSkia Image::AsImageSkia() const {
657 return IsEmpty() ? ImageSkia() : *ToImageSkia(); 666 return IsEmpty() ? ImageSkia() : *ToImageSkia();
658 } 667 }
659 668
660 #if defined(OS_MACOSX) && !defined(OS_IOS) 669 #if defined(OS_MACOSX) && !defined(OS_IOS)
661 NSImage* Image::AsNSImage() const { 670 NSImage* Image::AsNSImage() const {
662 return IsEmpty() ? nil : ToNSImage(); 671 return IsEmpty() ? nil : ToNSImage();
663 } 672 }
664 #endif 673 #endif
665 674
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
761 storage_->representations().insert(std::make_pair(type, std::move(rep))); 770 storage_->representations().insert(std::make_pair(type, std::move(rep)));
762 771
763 // insert should not fail (implies that there was already a representation of 772 // insert should not fail (implies that there was already a representation of
764 // that type in the map). 773 // that type in the map).
765 CHECK(result.second) << "type was already in map."; 774 CHECK(result.second) << "type was already in map.";
766 775
767 return result.first->second.get(); 776 return result.first->second.get();
768 } 777 }
769 778
770 } // namespace gfx 779 } // namespace gfx
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698