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

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

Issue 331283002: stop calling deprecated setConfig (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase + android typo Created 6 years, 6 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 | « skia/ext/convolver_unittest.cc ('k') | skia/ext/image_operations_bench.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) 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 #define _USE_MATH_DEFINES 5 #define _USE_MATH_DEFINES
6 #include <algorithm> 6 #include <algorithm>
7 #include <cmath> 7 #include <cmath>
8 #include <limits> 8 #include <limits>
9 9
10 #include "skia/ext/image_operations.h" 10 #include "skia/ext/image_operations.h"
(...skipping 375 matching lines...) Expand 10 before | Expand all | Expand 10 after
386 dest_subset.fLeft + dest_subset.width() * w, 386 dest_subset.fLeft + dest_subset.width() * w,
387 dest_subset.fTop + dest_subset.height() * h }; 387 dest_subset.fTop + dest_subset.height() * h };
388 SkBitmap img = ResizeBasic(source, ImageOperations::RESIZE_LANCZOS3, width, 388 SkBitmap img = ResizeBasic(source, ImageOperations::RESIZE_LANCZOS3, width,
389 height, subset, allocator); 389 height, subset, allocator);
390 const int row_words = img.rowBytes() / 4; 390 const int row_words = img.rowBytes() / 4;
391 if (w == 1 && h == 1) 391 if (w == 1 && h == 1)
392 return img; 392 return img;
393 393
394 // Render into subpixels. 394 // Render into subpixels.
395 SkBitmap result; 395 SkBitmap result;
396 result.setConfig(SkBitmap::kARGB_8888_Config, dest_subset.width(), 396 result.setInfo(SkImageInfo::MakeN32(dest_subset.width(), dest_subset.height(),
397 dest_subset.height(), 0, img.alphaType()); 397 img.alphaType()));
398 result.allocPixels(allocator, NULL); 398 result.allocPixels(allocator, NULL);
399 if (!result.readyToDraw()) 399 if (!result.readyToDraw())
400 return img; 400 return img;
401 401
402 SkAutoLockPixels locker(img); 402 SkAutoLockPixels locker(img);
403 if (!img.readyToDraw()) 403 if (!img.readyToDraw())
404 return img; 404 return img;
405 405
406 uint32* src_row = img.getAddr32(0, 0); 406 uint32* src_row = img.getAddr32(0, 0);
407 uint32* dst_row = result.getAddr32(0, 0); 407 uint32* dst_row = result.getAddr32(0, 0);
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
502 dest_width, dest_height, dest_subset); 502 dest_width, dest_height, dest_subset);
503 503
504 // Get a source bitmap encompassing this touched area. We construct the 504 // Get a source bitmap encompassing this touched area. We construct the
505 // offsets and row strides such that it looks like a new bitmap, while 505 // offsets and row strides such that it looks like a new bitmap, while
506 // referring to the old data. 506 // referring to the old data.
507 const uint8* source_subset = 507 const uint8* source_subset =
508 reinterpret_cast<const uint8*>(source.getPixels()); 508 reinterpret_cast<const uint8*>(source.getPixels());
509 509
510 // Convolve into the result. 510 // Convolve into the result.
511 SkBitmap result; 511 SkBitmap result;
512 result.setConfig(SkBitmap::kARGB_8888_Config, dest_subset.width(), 512 result.setInfo(SkImageInfo::MakeN32(dest_subset.width(), dest_subset.height(), source.alphaType()));
513 dest_subset.height(), 0, source.alphaType());
514 result.allocPixels(allocator, NULL); 513 result.allocPixels(allocator, NULL);
515 if (!result.readyToDraw()) 514 if (!result.readyToDraw())
516 return SkBitmap(); 515 return SkBitmap();
517 516
518 BGRAConvolve2D(source_subset, static_cast<int>(source.rowBytes()), 517 BGRAConvolve2D(source_subset, static_cast<int>(source.rowBytes()),
519 !source.isOpaque(), filter.x_filter(), filter.y_filter(), 518 !source.isOpaque(), filter.x_filter(), filter.y_filter(),
520 static_cast<int>(result.rowBytes()), 519 static_cast<int>(result.rowBytes()),
521 static_cast<unsigned char*>(result.getPixels()), 520 static_cast<unsigned char*>(result.getPixels()),
522 true); 521 true);
523 522
524 base::TimeDelta delta = base::TimeTicks::Now() - resize_start; 523 base::TimeDelta delta = base::TimeTicks::Now() - resize_start;
525 UMA_HISTOGRAM_TIMES("Image.ResampleMS", delta); 524 UMA_HISTOGRAM_TIMES("Image.ResampleMS", delta);
526 525
527 return result; 526 return result;
528 } 527 }
529 528
530 // static 529 // static
531 SkBitmap ImageOperations::Resize(const SkBitmap& source, 530 SkBitmap ImageOperations::Resize(const SkBitmap& source,
532 ResizeMethod method, 531 ResizeMethod method,
533 int dest_width, int dest_height, 532 int dest_width, int dest_height,
534 SkBitmap::Allocator* allocator) { 533 SkBitmap::Allocator* allocator) {
535 SkIRect dest_subset = { 0, 0, dest_width, dest_height }; 534 SkIRect dest_subset = { 0, 0, dest_width, dest_height };
536 return Resize(source, method, dest_width, dest_height, dest_subset, 535 return Resize(source, method, dest_width, dest_height, dest_subset,
537 allocator); 536 allocator);
538 } 537 }
539 538
540 } // namespace skia 539 } // namespace skia
OLDNEW
« no previous file with comments | « skia/ext/convolver_unittest.cc ('k') | skia/ext/image_operations_bench.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698