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

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

Issue 10905005: Change browser/page action default icon defined in manifest to support hidpi. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: disable unittest on android Created 8 years, 3 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 | « chrome/test/data/extensions/manifest_tests/script_badge_basic.json ('k') | no next file » | 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/gfx/image/image_skia_operations.h" 5 #include "ui/gfx/image/image_skia_operations.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "skia/ext/image_operations.h" 9 #include "skia/ext/image_operations.h"
10 #include "skia/ext/platform_canvas.h" 10 #include "skia/ext/platform_canvas.h"
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
124 alpha_(alpha) { 124 alpha_(alpha) {
125 } 125 }
126 126
127 virtual ~TransparentImageSource() {} 127 virtual ~TransparentImageSource() {}
128 128
129 private: 129 private:
130 // gfx::ImageSkiaSource overrides: 130 // gfx::ImageSkiaSource overrides:
131 virtual ImageSkiaRep GetImageForScale(ui::ScaleFactor scale_factor) OVERRIDE { 131 virtual ImageSkiaRep GetImageForScale(ui::ScaleFactor scale_factor) OVERRIDE {
132 ImageSkiaRep image_rep = image_.GetRepresentation(scale_factor); 132 ImageSkiaRep image_rep = image_.GetRepresentation(scale_factor);
133 SkBitmap alpha; 133 SkBitmap alpha;
134 const float scale = ui::GetScaleFactorScale(image_rep.scale_factor());
135 alpha.setConfig(SkBitmap::kARGB_8888_Config, 134 alpha.setConfig(SkBitmap::kARGB_8888_Config,
136 static_cast<int>(image_.size().width() * scale), 135 image_rep.pixel_width(),
137 static_cast<int>(image_.size().height() * scale)); 136 image_rep.pixel_height());
138 alpha.allocPixels(); 137 alpha.allocPixels();
139 alpha.eraseColor(SkColorSetARGB(alpha_ * 255, 0, 0, 0)); 138 alpha.eraseColor(SkColorSetARGB(alpha_ * 255, 0, 0, 0));
140 return ImageSkiaRep(SkBitmapOperations::CreateMaskedBitmap( 139 return ImageSkiaRep(
141 image_rep.sk_bitmap(), alpha), 140 SkBitmapOperations::CreateMaskedBitmap(image_rep.sk_bitmap(), alpha),
142 image_rep.scale_factor()); 141 image_rep.scale_factor());
143 } 142 }
144 143
145 ImageSkia image_; 144 ImageSkia image_;
146 double alpha_; 145 double alpha_;
147 146
148 DISALLOW_COPY_AND_ASSIGN(TransparentImageSource); 147 DISALLOW_COPY_AND_ASSIGN(TransparentImageSource);
149 }; 148 };
150 149
151 class MaskedImageSource : public gfx::ImageSkiaSource { 150 class MaskedImageSource : public gfx::ImageSkiaSource {
152 public: 151 public:
(...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after
450 const ImageSkia& source, 449 const ImageSkia& source,
451 const ShadowValues& shadows) { 450 const ShadowValues& shadows) {
452 const gfx::Insets shadow_padding = -gfx::ShadowValue::GetMargin(shadows); 451 const gfx::Insets shadow_padding = -gfx::ShadowValue::GetMargin(shadows);
453 gfx::Size shadow_image_size = source.size(); 452 gfx::Size shadow_image_size = source.size();
454 shadow_image_size.Enlarge(shadow_padding.width(), 453 shadow_image_size.Enlarge(shadow_padding.width(),
455 shadow_padding.height()); 454 shadow_padding.height());
456 return ImageSkia(new DropShadowSource(source, shadows), shadow_image_size); 455 return ImageSkia(new DropShadowSource(source, shadows), shadow_image_size);
457 } 456 }
458 457
459 } // namespace gfx 458 } // namespace gfx
OLDNEW
« no previous file with comments | « chrome/test/data/extensions/manifest_tests/script_badge_basic.json ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698