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

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

Issue 11081007: Remove implicit flooring Scale() method from Point and Size. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 2 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 | Annotate | Revision Log
« no previous file with comments | « ui/aura/root_window.cc ('k') | ui/base/x/x11_util.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 11 matching lines...) Expand all
22 #include "ui/base/l10n/l10n_util.h" 22 #include "ui/base/l10n/l10n_util.h"
23 #include "ui/base/layout.h" 23 #include "ui/base/layout.h"
24 #include "ui/base/resource/data_pack.h" 24 #include "ui/base/resource/data_pack.h"
25 #include "ui/base/ui_base_paths.h" 25 #include "ui/base/ui_base_paths.h"
26 #include "ui/base/ui_base_switches.h" 26 #include "ui/base/ui_base_switches.h"
27 #include "ui/gfx/codec/jpeg_codec.h" 27 #include "ui/gfx/codec/jpeg_codec.h"
28 #include "ui/gfx/codec/png_codec.h" 28 #include "ui/gfx/codec/png_codec.h"
29 #include "ui/gfx/image/image_skia.h" 29 #include "ui/gfx/image/image_skia.h"
30 #include "ui/gfx/image/image_skia_source.h" 30 #include "ui/gfx/image/image_skia_source.h"
31 #include "ui/gfx/screen.h" 31 #include "ui/gfx/screen.h"
32 #include "ui/gfx/size_conversions.h"
32 #include "ui/gfx/skbitmap_operations.h" 33 #include "ui/gfx/skbitmap_operations.h"
33 34
34 namespace ui { 35 namespace ui {
35 36
36 namespace { 37 namespace {
37 38
38 // Font sizes relative to base font. 39 // Font sizes relative to base font.
39 const int kSmallFontSizeDelta = -2; 40 const int kSmallFontSizeDelta = -2;
40 const int kMediumFontSizeDelta = 3; 41 const int kMediumFontSizeDelta = 3;
41 const int kLargeFontSizeDelta = 8; 42 const int kLargeFontSizeDelta = 8;
(...skipping 24 matching lines...) Expand all
66 resource_id_(resource_id), 67 resource_id_(resource_id),
67 size_in_dip_(size_in_dip) { 68 size_in_dip_(size_in_dip) {
68 } 69 }
69 virtual ~ResourceBundleImageSource() {} 70 virtual ~ResourceBundleImageSource() {}
70 71
71 // gfx::ImageSkiaSource overrides: 72 // gfx::ImageSkiaSource overrides:
72 virtual gfx::ImageSkiaRep GetImageForScale( 73 virtual gfx::ImageSkiaRep GetImageForScale(
73 ui::ScaleFactor scale_factor) OVERRIDE { 74 ui::ScaleFactor scale_factor) OVERRIDE {
74 scoped_ptr<SkBitmap> result(rb_->LoadBitmap(resource_id_, scale_factor)); 75 scoped_ptr<SkBitmap> result(rb_->LoadBitmap(resource_id_, scale_factor));
75 float scale = ui::GetScaleFactorScale(scale_factor); 76 float scale = ui::GetScaleFactorScale(scale_factor);
76 gfx::Size size_in_pixel = size_in_dip_.Scale(scale); 77 gfx::Size size_in_pixel = gfx::ToFlooredSize(size_in_dip_.Scale(scale));
77 78
78 if (scale_factor != SCALE_FACTOR_100P && 79 if (scale_factor != SCALE_FACTOR_100P &&
79 (!result.get() || 80 (!result.get() ||
80 result->width() != size_in_pixel.width() || 81 result->width() != size_in_pixel.width() ||
81 result->height() != size_in_pixel.height())) { 82 result->height() != size_in_pixel.height())) {
82 83
83 // If non 1x resource is missing from |image| or is the incorrect 84 // If non 1x resource is missing from |image| or is the incorrect
84 // size and --highlight-missing-scaled-resources is specified, logs 85 // size and --highlight-missing-scaled-resources is specified, logs
85 // the resource id and creates a version of the resource at the correct 86 // the resource id and creates a version of the resource at the correct
86 // size. Blends the created resource with red to make it 87 // size. Blends the created resource with red to make it
(...skipping 541 matching lines...) Expand 10 before | Expand all | Expand 10 after
628 SkBitmap bitmap; 629 SkBitmap bitmap;
629 bitmap.setConfig(SkBitmap::kARGB_8888_Config, 32, 32); 630 bitmap.setConfig(SkBitmap::kARGB_8888_Config, 32, 32);
630 bitmap.allocPixels(); 631 bitmap.allocPixels();
631 bitmap.eraseARGB(255, 255, 0, 0); 632 bitmap.eraseARGB(255, 255, 0, 0);
632 empty_image_ = gfx::Image(bitmap); 633 empty_image_ = gfx::Image(bitmap);
633 } 634 }
634 return empty_image_; 635 return empty_image_;
635 } 636 }
636 637
637 } // namespace ui 638 } // namespace ui
OLDNEW
« no previous file with comments | « ui/aura/root_window.cc ('k') | ui/base/x/x11_util.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698