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

Side by Side Diff: ui/gfx/skbitmap_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/skbitmap_operations.h" 5 #include "ui/gfx/skbitmap_operations.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 #include <string.h> 9 #include <string.h>
10 #include <algorithm> 10 #include <algorithm>
(...skipping 676 matching lines...) Expand 10 before | Expand all | Expand 10 after
687 for (int x = 0; x < image.width(); ++x) { 687 for (int x = 0; x < image.width(); ++x) {
688 uint32_t* dst = transposed.getAddr32(y, x); 688 uint32_t* dst = transposed.getAddr32(y, x);
689 *dst = image_row[x]; 689 *dst = image_row[x];
690 } 690 }
691 } 691 }
692 692
693 return transposed; 693 return transposed;
694 } 694 }
695 695
696 // static 696 // static
697 SkBitmap SkBitmapOperations::CreateMirroredBitmap(const SkBitmap& image) {
698 DCHECK(image.colorType() == kN32_SkColorType);
699
700 SkBitmap mirrored;
701 mirrored.allocN32Pixels(image.width(), image.height());
702
703 SkAutoLockPixels lock_image(image);
704 SkAutoLockPixels lock_mirrored(mirrored);
705
706 for (int y = 0; y < image.height(); ++y) {
707 uint32_t* image_row_src = image.getAddr32(0, y);
708 uint32_t* image_row_dst = mirrored.getAddr32(0, y);
709 for (int src_x = image.width() - 1, dst_x = 0; src_x >= 0; --src_x, ++dst_x)
710 image_row_dst[dst_x] = image_row_src[src_x];
711 }
712
713 return mirrored;
714 }
715
716 // static
697 SkBitmap SkBitmapOperations::CreateColorMask(const SkBitmap& bitmap, 717 SkBitmap SkBitmapOperations::CreateColorMask(const SkBitmap& bitmap,
698 SkColor c) { 718 SkColor c) {
699 DCHECK(bitmap.colorType() == kN32_SkColorType); 719 DCHECK(bitmap.colorType() == kN32_SkColorType);
700 720
701 SkBitmap color_mask; 721 SkBitmap color_mask;
702 color_mask.allocN32Pixels(bitmap.width(), bitmap.height()); 722 color_mask.allocN32Pixels(bitmap.width(), bitmap.height());
703 color_mask.eraseARGB(0, 0, 0, 0); 723 color_mask.eraseARGB(0, 0, 0, 0);
704 724
705 SkCanvas canvas(color_mask); 725 SkCanvas canvas(color_mask);
706 726
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
786 canvas.translate(SkFloatToScalar(result.width() * 0.5f), 806 canvas.translate(SkFloatToScalar(result.width() * 0.5f),
787 SkFloatToScalar(result.height() * 0.5f)); 807 SkFloatToScalar(result.height() * 0.5f));
788 canvas.rotate(angle); 808 canvas.rotate(angle);
789 canvas.translate(-SkFloatToScalar(source.width() * 0.5f), 809 canvas.translate(-SkFloatToScalar(source.width() * 0.5f),
790 -SkFloatToScalar(source.height() * 0.5f)); 810 -SkFloatToScalar(source.height() * 0.5f));
791 canvas.drawBitmap(source, 0, 0); 811 canvas.drawBitmap(source, 0, 0);
792 canvas.flush(); 812 canvas.flush();
793 813
794 return result; 814 return result;
795 } 815 }
OLDNEW
« ui/gfx/image/image_skia_operations.cc ('K') | « ui/gfx/skbitmap_operations.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698