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

Side by Side Diff: gfx/skbitmap_operations.cc

Issue 2963009: Windows: Fix opacity of drag images.... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: merge Created 10 years, 5 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 | « gfx/skbitmap_operations.h ('k') | gfx/skbitmap_operations_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) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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 "gfx/skbitmap_operations.h" 5 #include "gfx/skbitmap_operations.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <string.h> 8 #include <string.h>
9 9
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 650 matching lines...) Expand 10 before | Expand all | Expand 10 after
661 // there they should end up, so shifting left by 6 gives them in the 661 // there they should end up, so shifting left by 6 gives them in the
662 // correct position divided by 4. 662 // correct position divided by 4.
663 *result.getAddr32(dest_x, dest_y) = 663 *result.getAddr32(dest_x, dest_y) =
664 ((rb >> 2) & 0xFF00FF) | ((ag << 6) & 0xFF00FF00); 664 ((rb >> 2) & 0xFF00FF) | ((ag << 6) & 0xFF00FF00);
665 } 665 }
666 } 666 }
667 667
668 return result; 668 return result;
669 } 669 }
670 670
671 // static
672 SkBitmap SkBitmapOperations::UnPreMultiply(const SkBitmap& bitmap) {
673 if (bitmap.isNull())
674 return bitmap;
675 if (bitmap.isOpaque())
676 return bitmap;
677
678 SkBitmap opaque_bitmap;
679 opaque_bitmap.setConfig(bitmap.config(), bitmap.width(), bitmap.height());
680 opaque_bitmap.allocPixels();
681
682 {
683 SkAutoLockPixels bitmap_lock(bitmap);
684 SkAutoLockPixels opaque_bitmap_lock(opaque_bitmap);
685 for (int y = 0; y < opaque_bitmap.height(); y++) {
686 for (int x = 0; x < opaque_bitmap.width(); x++) {
687 uint32 src_pixel = *bitmap.getAddr32(x, y);
688 uint32* dst_pixel = opaque_bitmap.getAddr32(x, y);
689 SkColor unmultiplied = SkUnPreMultiply::PMColorToColor(src_pixel);
690 *dst_pixel = unmultiplied;
691 }
692 }
693 }
694
695 opaque_bitmap.setIsOpaque(true);
696 return opaque_bitmap;
697 }
OLDNEW
« no previous file with comments | « gfx/skbitmap_operations.h ('k') | gfx/skbitmap_operations_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698