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

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

Issue 2209053004: Enhance chrome.app.window API with icon property (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Review v2 + Badge Icon Created 4 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
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 <stddef.h> 7 #include <stddef.h>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 405 matching lines...) Expand 10 before | Expand all | Expand 10 after
416 return ImageSkiaRep(rotated_bitmap, image_rep.scale()); 416 return ImageSkiaRep(rotated_bitmap, image_rep.scale());
417 } 417 }
418 418
419 private: 419 private:
420 const ImageSkia source_; 420 const ImageSkia source_;
421 const SkBitmapOperations::RotationAmount rotation_; 421 const SkBitmapOperations::RotationAmount rotation_;
422 422
423 DISALLOW_COPY_AND_ASSIGN(RotatedSource); 423 DISALLOW_COPY_AND_ASSIGN(RotatedSource);
424 }; 424 };
425 425
426 class ImageWithBadgeSource : public gfx::CanvasImageSource {
427 public:
428 ImageWithBadgeSource(const ImageSkia& first, const ImageSkia& second)
429 : gfx::CanvasImageSource(first.size(), false /* is opaque */),
430 first_(first),
431 second_(second) {}
432
433 ~ImageWithBadgeSource() override {}
434
435 // gfx::CanvasImageSource override.
436 void Draw(Canvas* canvas) override {
437 canvas->DrawImageInt(first_, 0, 0);
438 canvas->DrawImageInt(second_, (first_.width() - second_.width()),
439 (first_.height() - second_.height()));
440 }
441
442 private:
443 const ImageSkia first_;
444 const ImageSkia second_;
445
446 DISALLOW_COPY_AND_ASSIGN(ImageWithBadgeSource);
447 };
426 448
427 } // namespace 449 } // namespace
428 450
429 // static 451 // static
430 ImageSkia ImageSkiaOperations::CreateBlendedImage(const ImageSkia& first, 452 ImageSkia ImageSkiaOperations::CreateBlendedImage(const ImageSkia& first,
431 const ImageSkia& second, 453 const ImageSkia& second,
432 double alpha) { 454 double alpha) {
433 if (first.isNull() || second.isNull()) 455 if (first.isNull() || second.isNull())
434 return ImageSkia(); 456 return ImageSkia();
435 457
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
541 if (source.isNull()) 563 if (source.isNull())
542 return ImageSkia(); 564 return ImageSkia();
543 565
544 return ImageSkia(new RotatedSource(source, rotation), 566 return ImageSkia(new RotatedSource(source, rotation),
545 SkBitmapOperations::ROTATION_180_CW == rotation ? 567 SkBitmapOperations::ROTATION_180_CW == rotation ?
546 source.size() : 568 source.size() :
547 gfx::Size(source.height(), source.width())); 569 gfx::Size(source.height(), source.width()));
548 570
549 } 571 }
550 572
573 // static
574 ImageSkia ImageSkiaOperations::CreateImageWithBadge(const ImageSkia& first,
575 const ImageSkia& second) {
576 if (first.isNull() || second.isNull())
577 return ImageSkia();
stevenjb 2016/08/08 22:26:46 It seems reasonable that if 'first' (the icon) is
Andra Paraschiv 2016/08/09 11:34:47 Yes, we could do this way. Also, should we return
Reilly Grant (use Gerrit) 2016/08/09 19:08:45 If the icon is not yet available we should use the
Andra Paraschiv 2016/08/10 14:19:57 Done.
578
579 return ImageSkia(new ImageWithBadgeSource(first, second), first.size());
580 }
581
551 } // namespace gfx 582 } // namespace gfx
OLDNEW
« ui/gfx/image/image_skia_operations.h ('K') | « ui/gfx/image/image_skia_operations.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698