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/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 Loading... | |
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 static_cast<int>(image_rep.sk_bitmap().width()), |
pkotwicz
2012/08/29 22:07:43
Can't you use ImageSkiaRep::GetWidth() and ImageSk
tbarzic
2012/08/29 22:18:13
Won't that return rep's size in dip? I need actual
pkotwicz
2012/08/29 23:14:47
Sorry. My bad. You can use ImageSkiaRep::pixel_wid
tbarzic
2012/08/29 23:25:56
yeah, now I feel silly for not noticing those two
| |
137 static_cast<int>(image_.size().height() * scale)); | 136 static_cast<int>(image_rep.sk_bitmap().height())); |
138 alpha.allocPixels(); | 137 alpha.allocPixels(); |
139 alpha.eraseColor(SkColorSetARGB(alpha_ * 256, 0, 0, 0)); | 138 alpha.eraseColor(SkColorSetARGB(alpha_ * 256, 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 Loading... | |
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 |
OLD | NEW |