OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2011 Google Inc. | 2 * Copyright 2011 Google Inc. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 #include "SampleApp.h" | 8 #include "SampleApp.h" |
9 | 9 |
10 #include "OverView.h" | 10 #include "OverView.h" |
(...skipping 1103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1114 path.reset(); path.addArc(r, 240, 120); path.lineTo(cx, cy); | 1114 path.reset(); path.addArc(r, 240, 120); path.lineTo(cx, cy); |
1115 canvas->drawPath(path, set_color_ref(paint, SkColorSetRGB(0, 0, SkColorGetB(
c)))); | 1115 canvas->drawPath(path, set_color_ref(paint, SkColorSetRGB(0, 0, SkColorGetB(
c)))); |
1116 } | 1116 } |
1117 | 1117 |
1118 typedef void (*ShowLCDProc)(SkCanvas*, SkScalar, SkScalar, SkColor, SkScalar, Sk
Scalar); | 1118 typedef void (*ShowLCDProc)(SkCanvas*, SkScalar, SkScalar, SkColor, SkScalar, Sk
Scalar); |
1119 | 1119 |
1120 /* | 1120 /* |
1121 * Like drawBitmapRect but we manually draw each pixels in RGB | 1121 * Like drawBitmapRect but we manually draw each pixels in RGB |
1122 */ | 1122 */ |
1123 static void show_lcd_grid(SkCanvas* canvas, const SkBitmap& bitmap, | 1123 static void show_lcd_grid(SkCanvas* canvas, const SkBitmap& bitmap, |
1124 const SkIRect& origSrc, const SkRect& dst) { | 1124 const SkIRect& origSrc, const SkRect& dst, ShowLCDProc
proc) { |
1125 SkIRect src; | 1125 SkIRect src; |
1126 if (!src.intersect(origSrc, bitmap.bounds())) { | 1126 if (!src.intersect(origSrc, bitmap.bounds())) { |
1127 return; | 1127 return; |
1128 } | 1128 } |
1129 const SkScalar sx = dst.width() / src.width(); | 1129 const SkScalar sx = dst.width() / src.width(); |
1130 const SkScalar sy = dst.height() / src.height(); | 1130 const SkScalar sy = dst.height() / src.height(); |
1131 | 1131 |
1132 SkAutoCanvasRestore acr(canvas, true); | 1132 SkAutoCanvasRestore acr(canvas, true); |
1133 canvas->translate(dst.left(), dst.top()); | 1133 canvas->translate(dst.left(), dst.top()); |
1134 canvas->scale(sx, sy); | 1134 canvas->scale(sx, sy); |
1135 | 1135 |
1136 ShowLCDProc proc = show_lcd_box; | |
1137 if (true) { | |
1138 proc = show_lcd_circle; | |
1139 } | |
1140 | |
1141 for (int y = 0; y < src.height(); ++y) { | 1136 for (int y = 0; y < src.height(); ++y) { |
1142 for (int x = 0; x < src.width(); ++x) { | 1137 for (int x = 0; x < src.width(); ++x) { |
1143 proc(canvas, SkIntToScalar(x), SkIntToScalar(y), | 1138 proc(canvas, SkIntToScalar(x), SkIntToScalar(y), |
1144 bitmap.getColor(src.left() + x, src.top() + y), sx, sy); | 1139 bitmap.getColor(src.left() + x, src.top() + y), sx, sy); |
1145 } | 1140 } |
1146 } | 1141 } |
1147 } | 1142 } |
1148 | 1143 |
1149 void SampleWindow::showZoomer(SkCanvas* canvas) { | 1144 void SampleWindow::showZoomer(SkCanvas* canvas) { |
1150 int count = canvas->save(); | 1145 int count = canvas->save(); |
(...skipping 15 matching lines...) Expand all Loading... |
1166 SkIRect src; | 1161 SkIRect src; |
1167 src.set(0, 0, zoomedWidth / fFatBitsScale, zoomedHeight / fFatBitsScale); | 1162 src.set(0, 0, zoomedWidth / fFatBitsScale, zoomedHeight / fFatBitsScale); |
1168 src.offset(fMouseX - (src.width()>>1), fMouseY - (src.height()>>1)); | 1163 src.offset(fMouseX - (src.width()>>1), fMouseY - (src.height()>>1)); |
1169 SkRect dest; | 1164 SkRect dest; |
1170 dest.set(0, 0, SkIntToScalar(zoomedWidth), SkIntToScalar(zoomedHeight)); | 1165 dest.set(0, 0, SkIntToScalar(zoomedWidth), SkIntToScalar(zoomedHeight)); |
1171 dest.offset(SkIntToScalar(width - zoomedWidth), SkIntToScalar(height - zoome
dHeight)); | 1166 dest.offset(SkIntToScalar(width - zoomedWidth), SkIntToScalar(height - zoome
dHeight)); |
1172 SkPaint paint; | 1167 SkPaint paint; |
1173 // Clear the background behind our zoomed in view | 1168 // Clear the background behind our zoomed in view |
1174 paint.setColor(SK_ColorWHITE); | 1169 paint.setColor(SK_ColorWHITE); |
1175 canvas->drawRect(dest, paint); | 1170 canvas->drawRect(dest, paint); |
1176 if (fFatBitsScale < kMaxFatBitsScale) { | 1171 switch (fFatBitsScale) { |
1177 canvas->drawBitmapRect(bitmap, src, dest, NULL); | 1172 case kMaxFatBitsScale: |
1178 } else { | 1173 show_lcd_grid(canvas, bitmap, src, dest, show_lcd_box); |
1179 show_lcd_grid(canvas, bitmap, src, dest); | 1174 break; |
| 1175 case kMaxFatBitsScale - 1: |
| 1176 show_lcd_grid(canvas, bitmap, src, dest, show_lcd_circle); |
| 1177 break; |
| 1178 default: |
| 1179 canvas->drawBitmapRect(bitmap, src, dest, NULL); |
| 1180 break; |
1180 } | 1181 } |
1181 | 1182 |
1182 paint.setColor(SK_ColorBLACK); | 1183 paint.setColor(SK_ColorBLACK); |
1183 paint.setStyle(SkPaint::kStroke_Style); | 1184 paint.setStyle(SkPaint::kStroke_Style); |
1184 // Draw a border around the pixel in the middle | 1185 // Draw a border around the pixel in the middle |
1185 SkRect originalPixel; | 1186 SkRect originalPixel; |
1186 originalPixel.set(SkIntToScalar(fMouseX), SkIntToScalar(fMouseY), SkIntToSca
lar(fMouseX + 1), SkIntToScalar(fMouseY + 1)); | 1187 originalPixel.set(SkIntToScalar(fMouseX), SkIntToScalar(fMouseY), SkIntToSca
lar(fMouseX + 1), SkIntToScalar(fMouseY + 1)); |
1187 SkMatrix matrix; | 1188 SkMatrix matrix; |
1188 SkRect scalarSrc; | 1189 SkRect scalarSrc; |
1189 scalarSrc.set(src); | 1190 scalarSrc.set(src); |
(...skipping 1186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2376 setenv("ANDROID_ROOT", "/android/device/data", 0); | 2377 setenv("ANDROID_ROOT", "/android/device/data", 0); |
2377 #endif | 2378 #endif |
2378 SkGraphics::Init(); | 2379 SkGraphics::Init(); |
2379 SkEvent::Init(); | 2380 SkEvent::Init(); |
2380 } | 2381 } |
2381 | 2382 |
2382 void application_term() { | 2383 void application_term() { |
2383 SkEvent::Term(); | 2384 SkEvent::Term(); |
2384 SkGraphics::Term(); | 2385 SkGraphics::Term(); |
2385 } | 2386 } |
OLD | NEW |