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

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

Issue 159381: Attempt to fix the ImageOperations::CreateMaskedBitmap UMR by bringing the un... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 11 years, 4 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 370 matching lines...) Expand 10 before | Expand all | Expand 10 after
381 381
382 SkBitmap masked; 382 SkBitmap masked;
383 masked.setConfig(SkBitmap::kARGB_8888_Config, rgb.width(), rgb.height(), 0); 383 masked.setConfig(SkBitmap::kARGB_8888_Config, rgb.width(), rgb.height(), 0);
384 masked.allocPixels(); 384 masked.allocPixels();
385 masked.eraseARGB(0, 0, 0, 0); 385 masked.eraseARGB(0, 0, 0, 0);
386 386
387 SkAutoLockPixels lock_rgb(rgb); 387 SkAutoLockPixels lock_rgb(rgb);
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 < masked.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 < masked.width(); x++) {
397 uint32 alpha_pixel = alpha_row[x]; 397 uint32 alpha_pixel = alpha_row[x];
398 SkColor rgb_pixel = SkUnPreMultiply::PMColorToColor(rgb_row[x]); 398 SkColor rgb_pixel = SkUnPreMultiply::PMColorToColor(rgb_row[x]);
399 399
400 int alpha = SkAlphaMul(SkColorGetA(rgb_pixel), 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 }
(...skipping 252 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