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

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

Issue 10806077: Upstream the rest of skia diff (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Init Created 8 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
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 349 matching lines...) Expand 10 before | Expand all | Expand 10 after
360 360
361 // static 361 // static
362 SkBitmap ImageOperations::ResizeSubpixel(const SkBitmap& source, 362 SkBitmap ImageOperations::ResizeSubpixel(const SkBitmap& source,
363 int dest_width, int dest_height, 363 int dest_width, int dest_height,
364 const SkIRect& dest_subset) { 364 const SkIRect& dest_subset) {
365 TRACE_EVENT2("skia", "ImageOperations::ResizeSubpixel", 365 TRACE_EVENT2("skia", "ImageOperations::ResizeSubpixel",
366 "src_pixels", source.width()*source.height(), 366 "src_pixels", source.width()*source.height(),
367 "dst_pixels", dest_width*dest_height); 367 "dst_pixels", dest_width*dest_height);
368 // Currently only works on Linux/BSD because these are the only platforms 368 // Currently only works on Linux/BSD because these are the only platforms
369 // where SkFontHost::GetSubpixelOrder is defined. 369 // where SkFontHost::GetSubpixelOrder is defined.
370 #if defined(OS_POSIX) && !defined(OS_MACOSX) 370 #if defined(OS_POSIX) && !defined(OS_MACOSX) && !defined(OS_ANDROID)
371 // Understand the display. 371 // Understand the display.
372 const SkFontHost::LCDOrder order = SkFontHost::GetSubpixelOrder(); 372 const SkFontHost::LCDOrder order = SkFontHost::GetSubpixelOrder();
373 const SkFontHost::LCDOrientation orientation = 373 const SkFontHost::LCDOrientation orientation =
374 SkFontHost::GetSubpixelOrientation(); 374 SkFontHost::GetSubpixelOrientation();
375 375
376 // Decide on which dimension, if any, to deploy subpixel rendering. 376 // Decide on which dimension, if any, to deploy subpixel rendering.
377 int w = 1; 377 int w = 1;
378 int h = 1; 378 int h = 1;
379 switch (orientation) { 379 switch (orientation) {
380 case SkFontHost::kHorizontal_LCDOrientation: 380 case SkFontHost::kHorizontal_LCDOrientation:
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
458 a = a > b ? a : b; 458 a = a > b ? a : b;
459 *dst = SkPackARGB32(a, r, g, b); 459 *dst = SkPackARGB32(a, r, g, b);
460 } 460 }
461 src_row += h * row_words; 461 src_row += h * row_words;
462 dst_row += result.rowBytes() / 4; 462 dst_row += result.rowBytes() / 4;
463 } 463 }
464 result.setIsOpaque(img.isOpaque()); 464 result.setIsOpaque(img.isOpaque());
465 return result; 465 return result;
466 #else 466 #else
467 return SkBitmap(); 467 return SkBitmap();
468 #endif // OS_POSIX && !OS_MACOSX 468 #endif // OS_POSIX && !OS_MACOSX && !defined(OS_ANDROID)
469 } 469 }
470 470
471 // static 471 // static
472 SkBitmap ImageOperations::ResizeBasic(const SkBitmap& source, 472 SkBitmap ImageOperations::ResizeBasic(const SkBitmap& source,
473 ResizeMethod method, 473 ResizeMethod method,
474 int dest_width, int dest_height, 474 int dest_width, int dest_height,
475 const SkIRect& dest_subset) { 475 const SkIRect& dest_subset) {
476 TRACE_EVENT2("skia", "ImageOperations::ResizeBasic", 476 TRACE_EVENT2("skia", "ImageOperations::ResizeBasic",
477 "src_pixels", source.width()*source.height(), 477 "src_pixels", source.width()*source.height(),
478 "dst_pixels", dest_width*dest_height); 478 "dst_pixels", dest_width*dest_height);
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
539 539
540 // static 540 // static
541 SkBitmap ImageOperations::Resize(const SkBitmap& source, 541 SkBitmap ImageOperations::Resize(const SkBitmap& source,
542 ResizeMethod method, 542 ResizeMethod method,
543 int dest_width, int dest_height) { 543 int dest_width, int dest_height) {
544 SkIRect dest_subset = { 0, 0, dest_width, dest_height }; 544 SkIRect dest_subset = { 0, 0, dest_width, dest_height };
545 return Resize(source, method, dest_width, dest_height, dest_subset); 545 return Resize(source, method, dest_width, dest_height, dest_subset);
546 } 546 }
547 547
548 } // namespace skia 548 } // namespace skia
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698