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

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

Issue 1585013002: MacViews: Use Cocoa folder icons in tree views. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 11 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 // MirroredSource generates image reps that are mirrors of those in |source|.
427 class MirroredSource : public ImageSkiaSource {
tapted 2016/01/14 23:43:50 For RTL, another approach is to flip the canvas wh
karandeepb 2016/01/18 00:31:18 Done.
428 public:
429 MirroredSource(const ImageSkia& source) : source_(source) {}
430 ~MirroredSource() override {}
431
432 // gfx::ImageSkiaSource overrides:
433 ImageSkiaRep GetImageForScale(float scale) override {
434 const ImageSkiaRep& image_rep = source_.GetRepresentation(scale);
435 const SkBitmap mirrored_bitmap =
436 SkBitmapOperations::CreateMirroredBitmap(image_rep.sk_bitmap());
437 return ImageSkiaRep(mirrored_bitmap, image_rep.scale());
438 }
439
440 private:
441 const ImageSkia source_;
442
443 DISALLOW_COPY_AND_ASSIGN(MirroredSource);
444 };
426 445
427 } // namespace 446 } // namespace
428 447
429 // static 448 // static
430 ImageSkia ImageSkiaOperations::CreateBlendedImage(const ImageSkia& first, 449 ImageSkia ImageSkiaOperations::CreateBlendedImage(const ImageSkia& first,
431 const ImageSkia& second, 450 const ImageSkia& second,
432 double alpha) { 451 double alpha) {
433 if (first.isNull() || second.isNull()) 452 if (first.isNull() || second.isNull())
434 return ImageSkia(); 453 return ImageSkia();
435 454
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
541 if (source.isNull()) 560 if (source.isNull())
542 return ImageSkia(); 561 return ImageSkia();
543 562
544 return ImageSkia(new RotatedSource(source, rotation), 563 return ImageSkia(new RotatedSource(source, rotation),
545 SkBitmapOperations::ROTATION_180_CW == rotation ? 564 SkBitmapOperations::ROTATION_180_CW == rotation ?
546 source.size() : 565 source.size() :
547 gfx::Size(source.height(), source.width())); 566 gfx::Size(source.height(), source.width()));
548 567
549 } 568 }
550 569
570 // static
571 ImageSkia ImageSkiaOperations::CreateMirroredImage(const ImageSkia& source) {
572 if (source.isNull())
573 return ImageSkia();
574
575 return ImageSkia(new MirroredSource(source), source.size());
576 }
577
551 } // namespace gfx 578 } // namespace gfx
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698