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

Unified Diff: skia/ext/image_operations.cc

Issue 761903003: Update from https://crrev.com/306655 (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 6 years 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « skia/ext/image_operations.h ('k') | skia/ext/image_operations_bench.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: skia/ext/image_operations.cc
diff --git a/skia/ext/image_operations.cc b/skia/ext/image_operations.cc
index bf063d7719b20170537d483698a5d37a052152d0..17c99973aeebcfd238f03296689633f269888a5a 100644
--- a/skia/ext/image_operations.cc
+++ b/skia/ext/image_operations.cc
@@ -342,134 +342,9 @@ SkBitmap ImageOperations::Resize(const SkBitmap& source,
int dest_width, int dest_height,
const SkIRect& dest_subset,
SkBitmap::Allocator* allocator) {
- if (method == ImageOperations::RESIZE_SUBPIXEL) {
- return ResizeSubpixel(source, dest_width, dest_height,
- dest_subset, allocator);
- } else {
- return ResizeBasic(source, method, dest_width, dest_height, dest_subset,
- allocator);
- }
-}
-
-// static
-SkBitmap ImageOperations::ResizeSubpixel(const SkBitmap& source,
- int dest_width, int dest_height,
- const SkIRect& dest_subset,
- SkBitmap::Allocator* allocator) {
- TRACE_EVENT2("skia", "ImageOperations::ResizeSubpixel",
- "src_pixels", source.width()*source.height(),
- "dst_pixels", dest_width*dest_height);
- // Currently only works on Linux/BSD because these are the only platforms
- // where SkFontHost::GetSubpixelOrder is defined.
-#if defined(OS_LINUX) && !defined(GTV)
- // Understand the display.
- const SkFontHost::LCDOrder order = SkFontHost::GetSubpixelOrder();
- const SkFontHost::LCDOrientation orientation =
- SkFontHost::GetSubpixelOrientation();
-
- // Decide on which dimension, if any, to deploy subpixel rendering.
- int w = 1;
- int h = 1;
- switch (orientation) {
- case SkFontHost::kHorizontal_LCDOrientation:
- w = dest_width < source.width() ? 3 : 1;
- break;
- case SkFontHost::kVertical_LCDOrientation:
- h = dest_height < source.height() ? 3 : 1;
- break;
- }
-
- // Resize the image.
- const int width = dest_width * w;
- const int height = dest_height * h;
- SkIRect subset = { dest_subset.fLeft, dest_subset.fTop,
- dest_subset.fLeft + dest_subset.width() * w,
- dest_subset.fTop + dest_subset.height() * h };
- SkBitmap img = ResizeBasic(source, ImageOperations::RESIZE_LANCZOS3, width,
- height, subset, allocator);
- const int row_words = img.rowBytes() / 4;
- if (w == 1 && h == 1)
- return img;
-
- // Render into subpixels.
- SkBitmap result;
- result.setInfo(SkImageInfo::MakeN32(dest_subset.width(), dest_subset.height(),
- img.alphaType()));
- result.allocPixels(allocator, NULL);
- if (!result.readyToDraw())
- return img;
-
- SkAutoLockPixels locker(img);
- if (!img.readyToDraw())
- return img;
-
- uint32* src_row = img.getAddr32(0, 0);
- uint32* dst_row = result.getAddr32(0, 0);
- for (int y = 0; y < dest_subset.height(); y++) {
- uint32* src = src_row;
- uint32* dst = dst_row;
- for (int x = 0; x < dest_subset.width(); x++, src += w, dst++) {
- uint8 r = 0, g = 0, b = 0, a = 0;
- switch (order) {
- case SkFontHost::kRGB_LCDOrder:
- switch (orientation) {
- case SkFontHost::kHorizontal_LCDOrientation:
- r = SkGetPackedR32(src[0]);
- g = SkGetPackedG32(src[1]);
- b = SkGetPackedB32(src[2]);
- a = SkGetPackedA32(src[1]);
- break;
- case SkFontHost::kVertical_LCDOrientation:
- r = SkGetPackedR32(src[0 * row_words]);
- g = SkGetPackedG32(src[1 * row_words]);
- b = SkGetPackedB32(src[2 * row_words]);
- a = SkGetPackedA32(src[1 * row_words]);
- break;
- }
- break;
- case SkFontHost::kBGR_LCDOrder:
- switch (orientation) {
- case SkFontHost::kHorizontal_LCDOrientation:
- b = SkGetPackedB32(src[0]);
- g = SkGetPackedG32(src[1]);
- r = SkGetPackedR32(src[2]);
- a = SkGetPackedA32(src[1]);
- break;
- case SkFontHost::kVertical_LCDOrientation:
- b = SkGetPackedB32(src[0 * row_words]);
- g = SkGetPackedG32(src[1 * row_words]);
- r = SkGetPackedR32(src[2 * row_words]);
- a = SkGetPackedA32(src[1 * row_words]);
- break;
- }
- break;
- case SkFontHost::kNONE_LCDOrder:
- NOTREACHED();
- }
- // Premultiplied alpha is very fragile.
- a = a > r ? a : r;
- a = a > g ? a : g;
- a = a > b ? a : b;
- *dst = SkPackARGB32(a, r, g, b);
- }
- src_row += h * row_words;
- dst_row += result.rowBytes() / 4;
- }
- return result;
-#else
- return SkBitmap();
-#endif // OS_POSIX && !OS_MACOSX && !defined(OS_ANDROID)
-}
-
-// static
-SkBitmap ImageOperations::ResizeBasic(const SkBitmap& source,
- ResizeMethod method,
- int dest_width, int dest_height,
- const SkIRect& dest_subset,
- SkBitmap::Allocator* allocator) {
- TRACE_EVENT2("skia", "ImageOperations::ResizeBasic",
- "src_pixels", source.width()*source.height(),
- "dst_pixels", dest_width*dest_height);
+ TRACE_EVENT2("disabled-by-default-skia", "ImageOperations::Resize",
+ "src_pixels", source.width() * source.height(), "dst_pixels",
+ dest_width * dest_height);
// Ensure that the ResizeMethod enumeration is sound.
SkASSERT(((RESIZE_FIRST_QUALITY_METHOD <= method) &&
(method <= RESIZE_LAST_QUALITY_METHOD)) ||
« no previous file with comments | « skia/ext/image_operations.h ('k') | skia/ext/image_operations_bench.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698