| 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 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 72 // will show the scaled image blended with red instead. | 72 // will show the scaled image blended with red instead. |
| 73 class ResourceBundle::ResourceBundleImageSource : public gfx::ImageSkiaSource { | 73 class ResourceBundle::ResourceBundleImageSource : public gfx::ImageSkiaSource { |
| 74 public: | 74 public: |
| 75 ResourceBundleImageSource(int resource_id, const gfx::Size& size_in_dip) | 75 ResourceBundleImageSource(int resource_id, const gfx::Size& size_in_dip) |
| 76 : resource_id_(resource_id), | 76 : resource_id_(resource_id), |
| 77 size_in_dip_(size_in_dip) { | 77 size_in_dip_(size_in_dip) { |
| 78 } | 78 } |
| 79 virtual ~ResourceBundleImageSource() {} | 79 virtual ~ResourceBundleImageSource() {} |
| 80 | 80 |
| 81 // gfx::ImageSkiaSource overrides: | 81 // gfx::ImageSkiaSource overrides: |
| 82 virtual gfx::ImageSkiaRep GetImageForScale(ui::ScaleFactor scale_factor) { | 82 virtual gfx::ImageSkiaRep GetImageForScale( |
| 83 ui::ScaleFactor scale_factor) OVERRIDE { |
| 83 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); | 84 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); |
| 84 | 85 |
| 85 scoped_ptr<SkBitmap> result(rb.LoadBitmap(resource_id_, scale_factor)); | 86 scoped_ptr<SkBitmap> result(rb.LoadBitmap(resource_id_, scale_factor)); |
| 86 gfx::Size size_in_pixel = | 87 gfx::Size size_in_pixel = |
| 87 size_in_dip_.Scale(ui::GetScaleFactorScale(scale_factor)); | 88 size_in_dip_.Scale(ui::GetScaleFactorScale(scale_factor)); |
| 88 | 89 |
| 89 if (scale_factor == SCALE_FACTOR_200P && | 90 if (scale_factor == SCALE_FACTOR_200P && |
| 90 (!result.get() || | 91 (!result.get() || |
| 91 result->width() != size_in_pixel.width() || | 92 result->width() != size_in_pixel.width() || |
| 92 result->height() != size_in_pixel.height())) { | 93 result->height() != size_in_pixel.height())) { |
| (...skipping 538 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 631 SkBitmap bitmap; | 632 SkBitmap bitmap; |
| 632 bitmap.setConfig(SkBitmap::kARGB_8888_Config, 32, 32); | 633 bitmap.setConfig(SkBitmap::kARGB_8888_Config, 32, 32); |
| 633 bitmap.allocPixels(); | 634 bitmap.allocPixels(); |
| 634 bitmap.eraseARGB(255, 255, 0, 0); | 635 bitmap.eraseARGB(255, 255, 0, 0); |
| 635 empty_image_ = gfx::Image(bitmap); | 636 empty_image_ = gfx::Image(bitmap); |
| 636 } | 637 } |
| 637 return empty_image_; | 638 return empty_image_; |
| 638 } | 639 } |
| 639 | 640 |
| 640 } // namespace ui | 641 } // namespace ui |
| OLD | NEW |