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

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

Issue 10783015: Add ability to store hidpi theme images in data pack (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 4 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/gfx/image/image_skia_operations.h ('k') | ui/gfx/image/image_skia_unittest.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/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 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
136 ImageSkiaRep source_rep = source_.GetRepresentation(scale_factor); 136 ImageSkiaRep source_rep = source_.GetRepresentation(scale_factor);
137 float scale = ui::GetScaleFactorScale(source_rep.scale_factor()); 137 float scale = ui::GetScaleFactorScale(source_rep.scale_factor());
138 return ImageSkiaRep( 138 return ImageSkiaRep(
139 SkBitmapOperations::CreateTiledBitmap( 139 SkBitmapOperations::CreateTiledBitmap(
140 source_rep.sk_bitmap(), 140 source_rep.sk_bitmap(),
141 src_x_ * scale, src_y_ * scale, dst_w_ * scale, dst_h_ * scale), 141 src_x_ * scale, src_y_ * scale, dst_w_ * scale, dst_h_ * scale),
142 source_rep.scale_factor()); 142 source_rep.scale_factor());
143 } 143 }
144 144
145 private: 145 private:
146 const ImageSkia& source_; 146 const ImageSkia source_;
147 const int src_x_; 147 const int src_x_;
148 const int src_y_; 148 const int src_y_;
149 const int dst_w_; 149 const int dst_w_;
150 const int dst_h_; 150 const int dst_h_;
151 151
152 DISALLOW_COPY_AND_ASSIGN(TiledImageSource); 152 DISALLOW_COPY_AND_ASSIGN(TiledImageSource);
153 }; 153 };
154 154
155 class HSLImageSource : public gfx::ImageSkiaSource {
156 public:
157 HSLImageSource(const ImageSkia& image,
158 const color_utils::HSL& hsl_shift)
159 : image_(image),
160 hsl_shift_(hsl_shift) {
161 }
162
163 virtual ~HSLImageSource() {
164 }
165
166 // gfx::ImageSkiaSource overrides:
167 virtual ImageSkiaRep GetImageForScale(ui::ScaleFactor scale_factor) OVERRIDE {
168 ImageSkiaRep image_rep = image_.GetRepresentation(scale_factor);
169 return gfx::ImageSkiaRep(
170 SkBitmapOperations::CreateHSLShiftedBitmap(image_rep.sk_bitmap(),
171 hsl_shift_), image_rep.scale_factor());
172 }
173
174 private:
175 const gfx::ImageSkia image_;
176 const color_utils::HSL hsl_shift_;
177
178 DISALLOW_COPY_AND_ASSIGN(HSLImageSource);
179 };
180
155 // ImageSkiaSource which uses SkBitmapOperations::CreateButtonBackground 181 // ImageSkiaSource which uses SkBitmapOperations::CreateButtonBackground
156 // to generate image reps for the target image. 182 // to generate image reps for the target image.
157 class ButtonImageSource: public gfx::ImageSkiaSource { 183 class ButtonImageSource: public gfx::ImageSkiaSource {
158 public: 184 public:
159 ButtonImageSource(SkColor color, 185 ButtonImageSource(SkColor color,
160 const ImageSkia& image, 186 const ImageSkia& image,
161 const ImageSkia& mask) 187 const ImageSkia& mask)
162 : color_(color), 188 : color_(color),
163 image_(image), 189 image_(image),
164 mask_(mask) { 190 mask_(mask) {
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
303 329
304 // static 330 // static
305 ImageSkia ImageSkiaOperations::CreateTiledImage(const ImageSkia& source, 331 ImageSkia ImageSkiaOperations::CreateTiledImage(const ImageSkia& source,
306 int src_x, int src_y, 332 int src_x, int src_y,
307 int dst_w, int dst_h) { 333 int dst_w, int dst_h) {
308 return ImageSkia(new TiledImageSource(source, src_x, src_y, dst_w, dst_h), 334 return ImageSkia(new TiledImageSource(source, src_x, src_y, dst_w, dst_h),
309 gfx::Size(dst_w, dst_h)); 335 gfx::Size(dst_w, dst_h));
310 } 336 }
311 337
312 // static 338 // static
339 ImageSkia ImageSkiaOperations::CreateHSLShiftedImage(
340 const ImageSkia& image,
341 const color_utils::HSL& hsl_shift) {
342 return ImageSkia(new HSLImageSource(image, hsl_shift), image.size());
343 }
344
345 // static
313 ImageSkia ImageSkiaOperations::CreateButtonBackground(SkColor color, 346 ImageSkia ImageSkiaOperations::CreateButtonBackground(SkColor color,
314 const ImageSkia& image, 347 const ImageSkia& image,
315 const ImageSkia& mask) { 348 const ImageSkia& mask) {
316 return ImageSkia(new ButtonImageSource(color, image, mask), mask.size()); 349 return ImageSkia(new ButtonImageSource(color, image, mask), mask.size());
317 } 350 }
318 351
319 // static 352 // static
320 ImageSkia ImageSkiaOperations::ExtractSubset(const ImageSkia& image, 353 ImageSkia ImageSkiaOperations::ExtractSubset(const ImageSkia& image,
321 const Rect& subset_bounds) { 354 const Rect& subset_bounds) {
322 gfx::Rect clipped_bounds = subset_bounds.Intersect(gfx::Rect(image.size())); 355 gfx::Rect clipped_bounds = subset_bounds.Intersect(gfx::Rect(image.size()));
(...skipping 16 matching lines...) Expand all
339 const ImageSkia& source, 372 const ImageSkia& source,
340 const ShadowValues& shadows) { 373 const ShadowValues& shadows) {
341 const gfx::Insets shadow_padding = -gfx::ShadowValue::GetMargin(shadows); 374 const gfx::Insets shadow_padding = -gfx::ShadowValue::GetMargin(shadows);
342 gfx::Size shadow_image_size = source.size(); 375 gfx::Size shadow_image_size = source.size();
343 shadow_image_size.Enlarge(shadow_padding.width(), 376 shadow_image_size.Enlarge(shadow_padding.width(),
344 shadow_padding.height()); 377 shadow_padding.height());
345 return ImageSkia(new DropShadowSource(source, shadows), shadow_image_size); 378 return ImageSkia(new DropShadowSource(source, shadows), shadow_image_size);
346 } 379 }
347 380
348 } // namespace gfx 381 } // namespace gfx
OLDNEW
« no previous file with comments | « ui/gfx/image/image_skia_operations.h ('k') | ui/gfx/image/image_skia_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698