OLD | NEW |
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 Loading... |
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 Loading... |
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 543 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
630 SkBitmap bitmap; | 631 SkBitmap bitmap; |
631 bitmap.setConfig(SkBitmap::kARGB_8888_Config, 32, 32); | 632 bitmap.setConfig(SkBitmap::kARGB_8888_Config, 32, 32); |
632 bitmap.allocPixels(); | 633 bitmap.allocPixels(); |
633 bitmap.eraseARGB(255, 255, 0, 0); | 634 bitmap.eraseARGB(255, 255, 0, 0); |
634 empty_image_ = gfx::Image(bitmap); | 635 empty_image_ = gfx::Image(bitmap); |
635 } | 636 } |
636 return empty_image_; | 637 return empty_image_; |
637 } | 638 } |
638 | 639 |
639 } // namespace ui | 640 } // namespace ui |
OLD | NEW |