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

Side by Side Diff: ui/gfx/skbitmap_operations.cc

Issue 1142113002: Remove SK_SUPPORT_LEGACY_PUBLIC_IMAGEINFO_FIELDS (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebased Created 5 years, 7 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
« no previous file with comments | « ui/gfx/ipc/gfx_param_traits.cc ('k') | no next file » | 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/skbitmap_operations.h" 5 #include "ui/gfx/skbitmap_operations.h"
6 6
7 #include <string.h> 7 #include <string.h>
8 #include <algorithm> 8 #include <algorithm>
9 9
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 636 matching lines...) Expand 10 before | Expand all | Expand 10 after
647 return result; 647 return result;
648 } 648 }
649 649
650 // static 650 // static
651 SkBitmap SkBitmapOperations::UnPreMultiply(const SkBitmap& bitmap) { 651 SkBitmap SkBitmapOperations::UnPreMultiply(const SkBitmap& bitmap) {
652 if (bitmap.isNull()) 652 if (bitmap.isNull())
653 return bitmap; 653 return bitmap;
654 if (bitmap.isOpaque()) 654 if (bitmap.isOpaque())
655 return bitmap; 655 return bitmap;
656 656
657 SkImageInfo info = bitmap.info(); 657 const SkImageInfo& info = bitmap.info();
658 info.fAlphaType = kOpaque_SkAlphaType; 658 SkImageInfo opaque_info =
659 SkImageInfo::Make(info.width(), info.height(), info.colorType(),
660 kOpaque_SkAlphaType, info.profileType());
659 SkBitmap opaque_bitmap; 661 SkBitmap opaque_bitmap;
660 opaque_bitmap.allocPixels(info); 662 opaque_bitmap.allocPixels(opaque_info);
661 663
662 { 664 {
663 SkAutoLockPixels bitmap_lock(bitmap); 665 SkAutoLockPixels bitmap_lock(bitmap);
664 SkAutoLockPixels opaque_bitmap_lock(opaque_bitmap); 666 SkAutoLockPixels opaque_bitmap_lock(opaque_bitmap);
665 for (int y = 0; y < opaque_bitmap.height(); y++) { 667 for (int y = 0; y < opaque_bitmap.height(); y++) {
666 for (int x = 0; x < opaque_bitmap.width(); x++) { 668 for (int x = 0; x < opaque_bitmap.width(); x++) {
667 uint32 src_pixel = *bitmap.getAddr32(x, y); 669 uint32 src_pixel = *bitmap.getAddr32(x, y);
668 uint32* dst_pixel = opaque_bitmap.getAddr32(x, y); 670 uint32* dst_pixel = opaque_bitmap.getAddr32(x, y);
669 SkColor unmultiplied = SkUnPreMultiply::PMColorToColor(src_pixel); 671 SkColor unmultiplied = SkUnPreMultiply::PMColorToColor(src_pixel);
670 *dst_pixel = unmultiplied; 672 *dst_pixel = unmultiplied;
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
784 canvas.translate(SkFloatToScalar(result.width() * 0.5f), 786 canvas.translate(SkFloatToScalar(result.width() * 0.5f),
785 SkFloatToScalar(result.height() * 0.5f)); 787 SkFloatToScalar(result.height() * 0.5f));
786 canvas.rotate(angle); 788 canvas.rotate(angle);
787 canvas.translate(-SkFloatToScalar(source.width() * 0.5f), 789 canvas.translate(-SkFloatToScalar(source.width() * 0.5f),
788 -SkFloatToScalar(source.height() * 0.5f)); 790 -SkFloatToScalar(source.height() * 0.5f));
789 canvas.drawBitmap(source, 0, 0); 791 canvas.drawBitmap(source, 0, 0);
790 canvas.flush(); 792 canvas.flush();
791 793
792 return result; 794 return result;
793 } 795 }
OLDNEW
« no previous file with comments | « ui/gfx/ipc/gfx_param_traits.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698