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

Side by Side Diff: skia/ext/image_operations.cc

Issue 160034: Our masker didn't account for the source image also having alpha.... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 11 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 | « no previous file | skia/ext/image_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) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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 #define _USE_MATH_DEFINES 5 #define _USE_MATH_DEFINES
6 #include <cmath> 6 #include <cmath>
7 #include <limits> 7 #include <limits>
8 #include <vector> 8 #include <vector>
9 9
10 #include "skia/ext/image_operations.h" 10 #include "skia/ext/image_operations.h"
(...skipping 377 matching lines...) Expand 10 before | Expand all | Expand 10 after
388 SkAutoLockPixels lock_alpha(alpha); 388 SkAutoLockPixels lock_alpha(alpha);
389 SkAutoLockPixels lock_masked(masked); 389 SkAutoLockPixels lock_masked(masked);
390 390
391 for (int y = 0; y < rgb.height(); y++) { 391 for (int y = 0; y < rgb.height(); y++) {
392 uint32* rgb_row = rgb.getAddr32(0, y); 392 uint32* rgb_row = rgb.getAddr32(0, y);
393 uint32* alpha_row = alpha.getAddr32(0, y); 393 uint32* alpha_row = alpha.getAddr32(0, y);
394 uint32* dst_row = masked.getAddr32(0, y); 394 uint32* dst_row = masked.getAddr32(0, y);
395 395
396 for (int x = 0; x < rgb.width(); x++) { 396 for (int x = 0; x < rgb.width(); x++) {
397 uint32 alpha_pixel = alpha_row[x]; 397 uint32 alpha_pixel = alpha_row[x];
398 uint32 rgb_pixel = rgb_row[x]; 398 SkColor rgb_pixel = SkUnPreMultiply::PMColorToColor(rgb_row[x]);
399 399
400 int alpha = SkColorGetA(alpha_pixel); 400 int alpha = SkAlphaMul(SkColorGetA(rgb_pixel), SkColorGetA(alpha_pixel));
401 dst_row[x] = SkColorSetARGB(alpha, 401 dst_row[x] = SkColorSetARGB(alpha,
402 SkAlphaMul(SkColorGetR(rgb_pixel), alpha), 402 SkAlphaMul(SkColorGetR(rgb_pixel), alpha),
403 SkAlphaMul(SkColorGetG(rgb_pixel), alpha), 403 SkAlphaMul(SkColorGetG(rgb_pixel), alpha),
404 SkAlphaMul(SkColorGetB(rgb_pixel), alpha)); 404 SkAlphaMul(SkColorGetB(rgb_pixel), alpha));
405 } 405 }
406 } 406 }
407 407
408 return masked; 408 return masked;
409 } 409 }
410 410
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after
659 // Since bitmaps are refcounted, this copy will be fast. 659 // Since bitmaps are refcounted, this copy will be fast.
660 SkBitmap current = bitmap; 660 SkBitmap current = bitmap;
661 while (current.width() >= min_w * 2 && current.height() >= min_h * 2 && 661 while (current.width() >= min_w * 2 && current.height() >= min_h * 2 &&
662 current.width() > 1 && current.height() > 1) 662 current.width() > 1 && current.height() > 1)
663 current = DownsampleByTwo(current); 663 current = DownsampleByTwo(current);
664 return current; 664 return current;
665 } 665 }
666 666
667 } // namespace skia 667 } // namespace skia
668 668
OLDNEW
« no previous file with comments | « no previous file | skia/ext/image_operations_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698