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

Side by Side Diff: ui/base/resource/resource_bundle.cc

Issue 12939015: Fix sizing when auto-scaling a missing resource at a non-integer scale factor. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Make rounding test Windows only. Created 7 years, 8 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 | ui/base/resource/resource_bundle_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 (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/base/resource/resource_bundle.h" 5 #include "ui/base/resource/resource_bundle.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/file_util.h" 10 #include "base/file_util.h"
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 &image, &fell_back_to_1x); 79 &image, &fell_back_to_1x);
80 if (!found) 80 if (!found)
81 return gfx::ImageSkiaRep(); 81 return gfx::ImageSkiaRep();
82 82
83 if (fell_back_to_1x) { 83 if (fell_back_to_1x) {
84 // GRIT fell back to the 100% image, so rescale it to the correct size. 84 // GRIT fell back to the 100% image, so rescale it to the correct size.
85 float scale = GetScaleFactorScale(scale_factor); 85 float scale = GetScaleFactorScale(scale_factor);
86 image = skia::ImageOperations::Resize( 86 image = skia::ImageOperations::Resize(
87 image, 87 image,
88 skia::ImageOperations::RESIZE_LANCZOS3, 88 skia::ImageOperations::RESIZE_LANCZOS3,
89 gfx::ToFlooredInt(image.width() * scale), 89 gfx::ToCeiledInt(image.width() * scale),
90 gfx::ToFlooredInt(image.height() * scale)); 90 gfx::ToCeiledInt(image.height() * scale));
91 // If --highlight-missing-scaled-resources is specified, log the resource 91 // If --highlight-missing-scaled-resources is specified, log the resource
92 // id and blend the created resource with red. 92 // id and blend the created resource with red.
93 if (ShouldHighlightMissingScaledResources()) { 93 if (ShouldHighlightMissingScaledResources()) {
94 LOG(ERROR) << "Missing " << scale << "x scaled resource. id=" 94 LOG(ERROR) << "Missing " << scale << "x scaled resource. id="
95 << resource_id_; 95 << resource_id_;
96 96
97 SkBitmap mask; 97 SkBitmap mask;
98 mask.setConfig(SkBitmap::kARGB_8888_Config, 98 mask.setConfig(SkBitmap::kARGB_8888_Config,
99 image.width(), image.height()); 99 image.width(), image.height());
100 mask.allocPixels(); 100 mask.allocPixels();
(...skipping 609 matching lines...) Expand 10 before | Expand all | Expand 10 after
710 // static 710 // static
711 bool ResourceBundle::DecodePNG(const unsigned char* buf, 711 bool ResourceBundle::DecodePNG(const unsigned char* buf,
712 size_t size, 712 size_t size,
713 SkBitmap* bitmap, 713 SkBitmap* bitmap,
714 bool* fell_back_to_1x) { 714 bool* fell_back_to_1x) {
715 *fell_back_to_1x = PNGContainsFallbackMarker(buf, size); 715 *fell_back_to_1x = PNGContainsFallbackMarker(buf, size);
716 return gfx::PNGCodec::Decode(buf, size, bitmap); 716 return gfx::PNGCodec::Decode(buf, size, bitmap);
717 } 717 }
718 718
719 } // namespace ui 719 } // namespace ui
OLDNEW
« no previous file with comments | « no previous file | ui/base/resource/resource_bundle_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698