From 8a41adb1d14385ef0b9d49c469f1eec031cc0813 Mon Sep 17 00:00:00 2001 From: reed Date: Sat, 15 Aug 2015 14:02:29 -0700 Subject: [PATCH] support both box and circle lcd BUG=skia: TBR= Review URL: https://codereview.chromium.org/1292943003 --- samplecode/SampleApp.cpp | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/samplecode/SampleApp.cpp b/samplecode/SampleApp.cpp index 55a9aaceb9..ae9c88b7da 100644 --- a/samplecode/SampleApp.cpp +++ b/samplecode/SampleApp.cpp @@ -1121,7 +1121,7 @@ typedef void (*ShowLCDProc)(SkCanvas*, SkScalar, SkScalar, SkColor, SkScalar, Sk * Like drawBitmapRect but we manually draw each pixels in RGB */ static void show_lcd_grid(SkCanvas* canvas, const SkBitmap& bitmap, - const SkIRect& origSrc, const SkRect& dst) { + const SkIRect& origSrc, const SkRect& dst, ShowLCDProc proc) { SkIRect src; if (!src.intersect(origSrc, bitmap.bounds())) { return; @@ -1133,11 +1133,6 @@ static void show_lcd_grid(SkCanvas* canvas, const SkBitmap& bitmap, canvas->translate(dst.left(), dst.top()); canvas->scale(sx, sy); - ShowLCDProc proc = show_lcd_box; - if (true) { - proc = show_lcd_circle; - } - for (int y = 0; y < src.height(); ++y) { for (int x = 0; x < src.width(); ++x) { proc(canvas, SkIntToScalar(x), SkIntToScalar(y), @@ -1173,10 +1168,16 @@ void SampleWindow::showZoomer(SkCanvas* canvas) { // Clear the background behind our zoomed in view paint.setColor(SK_ColorWHITE); canvas->drawRect(dest, paint); - if (fFatBitsScale < kMaxFatBitsScale) { - canvas->drawBitmapRect(bitmap, src, dest, NULL); - } else { - show_lcd_grid(canvas, bitmap, src, dest); + switch (fFatBitsScale) { + case kMaxFatBitsScale: + show_lcd_grid(canvas, bitmap, src, dest, show_lcd_box); + break; + case kMaxFatBitsScale - 1: + show_lcd_grid(canvas, bitmap, src, dest, show_lcd_circle); + break; + default: + canvas->drawBitmapRect(bitmap, src, dest, NULL); + break; } paint.setColor(SK_ColorBLACK);