support both box and circle lcd

BUG=skia:
TBR=

Review URL: https://codereview.chromium.org/1292943003
This commit is contained in:
reed 2015-08-15 14:02:29 -07:00 committed by Commit bot
parent 5f629b42e5
commit 8a41adb1d1

View File

@ -1121,7 +1121,7 @@ typedef void (*ShowLCDProc)(SkCanvas*, SkScalar, SkScalar, SkColor, SkScalar, Sk
* Like drawBitmapRect but we manually draw each pixels in RGB * Like drawBitmapRect but we manually draw each pixels in RGB
*/ */
static void show_lcd_grid(SkCanvas* canvas, const SkBitmap& bitmap, 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; SkIRect src;
if (!src.intersect(origSrc, bitmap.bounds())) { if (!src.intersect(origSrc, bitmap.bounds())) {
return; return;
@ -1133,11 +1133,6 @@ static void show_lcd_grid(SkCanvas* canvas, const SkBitmap& bitmap,
canvas->translate(dst.left(), dst.top()); canvas->translate(dst.left(), dst.top());
canvas->scale(sx, sy); 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 y = 0; y < src.height(); ++y) {
for (int x = 0; x < src.width(); ++x) { for (int x = 0; x < src.width(); ++x) {
proc(canvas, SkIntToScalar(x), SkIntToScalar(y), proc(canvas, SkIntToScalar(x), SkIntToScalar(y),
@ -1173,10 +1168,16 @@ void SampleWindow::showZoomer(SkCanvas* canvas) {
// Clear the background behind our zoomed in view // Clear the background behind our zoomed in view
paint.setColor(SK_ColorWHITE); paint.setColor(SK_ColorWHITE);
canvas->drawRect(dest, paint); canvas->drawRect(dest, paint);
if (fFatBitsScale < kMaxFatBitsScale) { 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); canvas->drawBitmapRect(bitmap, src, dest, NULL);
} else { break;
show_lcd_grid(canvas, bitmap, src, dest);
} }
paint.setColor(SK_ColorBLACK); paint.setColor(SK_ColorBLACK);