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 #include "SampleApp.h" | 7 #include "SampleApp.h" |
8 | 8 |
9 #include "SkData.h" | 9 #include "SkData.h" |
10 #include "SkCanvas.h" | 10 #include "SkCanvas.h" |
11 #include "SkDevice.h" | 11 #include "SkDevice.h" |
12 #include "SkGraphics.h" | 12 #include "SkGraphics.h" |
13 #include "SkImageDecoder.h" | 13 #include "SkImageDecoder.h" |
14 #include "SkImageEncoder.h" | 14 #include "SkImageEncoder.h" |
15 #include "SkPaint.h" | 15 #include "SkPaint.h" |
16 #include "SkPicture.h" | 16 #include "SkPicture.h" |
17 #include "SkPictureRecorder.h" | 17 #include "SkPictureRecorder.h" |
18 #include "SkStream.h" | 18 #include "SkStream.h" |
19 #include "SkSurface.h" | |
19 #include "SkTSort.h" | 20 #include "SkTSort.h" |
20 #include "SkTime.h" | 21 #include "SkTime.h" |
21 #include "SkWindow.h" | 22 #include "SkWindow.h" |
22 | 23 |
23 #include "SampleCode.h" | 24 #include "SampleCode.h" |
24 #include "SkTypeface.h" | 25 #include "SkTypeface.h" |
25 | 26 |
26 #if SK_SUPPORT_GPU | 27 #if SK_SUPPORT_GPU |
27 #include "gl/GrGLInterface.h" | 28 #include "gl/GrGLInterface.h" |
28 #include "gl/GrGLUtil.h" | 29 #include "gl/GrGLUtil.h" |
(...skipping 1156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1185 this->INHERITED::draw(canvas); | 1186 this->INHERITED::draw(canvas); |
1186 } | 1187 } |
1187 } | 1188 } |
1188 | 1189 |
1189 SkBitmap diff; | 1190 SkBitmap diff; |
1190 if (bitmap_diff(canvas, orig, &diff)) { | 1191 if (bitmap_diff(canvas, orig, &diff)) { |
1191 } | 1192 } |
1192 } else { | 1193 } else { |
1193 SkSize tile = this->tileSize(); | 1194 SkSize tile = this->tileSize(); |
1194 | 1195 |
1195 for (SkScalar y = 0; y < height(); y += tile.height()) { | 1196 if (fTilingMode != kNo_Tiling) { |
1196 for (SkScalar x = 0; x < width(); x += tile.width()) { | 1197 const int w = SkScalarRoundToInt(tile.width()); |
1197 SkAutoCanvasRestore acr(canvas, true); | 1198 const int h = SkScalarRoundToInt(tile.height()); |
1198 canvas->clipRect(SkRect::MakeXYWH(x, y, | 1199 SkImageInfo info = SkImageInfo::MakeN32Premul(w, h); |
1199 tile.width(), | 1200 SkAutoTUnref<SkSurface> surface(canvas->newSurface(info)); |
1200 tile.height())); | 1201 SkCanvas* tileCanvas = surface->getCanvas(); |
1201 this->INHERITED::draw(canvas); | 1202 |
1203 for (SkScalar y = 0; y < height(); y += tile.height()) { | |
1204 for (SkScalar x = 0; x < width(); x += tile.width()) { | |
1205 SkAutoCanvasRestore acr(tileCanvas, true); | |
1206 tileCanvas->translate(-x, -y); | |
1207 tileCanvas->clear(0); | |
1208 this->INHERITED::draw(tileCanvas); | |
1209 surface->draw(canvas, x, y, NULL); | |
1210 } | |
1202 } | 1211 } |
1203 } | |
1204 | 1212 |
1205 if (fTilingMode != kNo_Tiling) { | 1213 // for drawing the borders between tiles |
1206 SkPaint paint; | 1214 SkPaint paint; |
1207 paint.setColor(0x60FF00FF); | 1215 paint.setColor(0x60FF00FF); |
1208 paint.setStyle(SkPaint::kStroke_Style); | 1216 paint.setStyle(SkPaint::kStroke_Style); |
1209 | 1217 |
1210 for (SkScalar y = 0; y < height(); y += tile.height()) { | 1218 for (SkScalar y = 0; y < height(); y += tile.height()) { |
1211 for (SkScalar x = 0; x < width(); x += tile.width()) { | 1219 for (SkScalar x = 0; x < width(); x += tile.width()) { |
1212 canvas->drawRect(SkRect::MakeXYWH(x, y, | 1220 canvas->drawRect(SkRect::MakeXYWH(x, y, tile.width(), tile.h eight()), paint); |
1213 tile.width(), | |
1214 tile.height()), | |
1215 paint); | |
1216 } | 1221 } |
1217 } | 1222 } |
1223 } else { | |
1224 this->INHERITED::draw(canvas); | |
mtklein
2014/05/30 14:56:45
The context for this guy seems easy to get lost.
| |
1218 } | 1225 } |
1219 } | 1226 } |
1220 if (fShowZoomer && !fSaveToPdf) { | 1227 if (fShowZoomer && !fSaveToPdf) { |
1221 showZoomer(canvas); | 1228 showZoomer(canvas); |
1222 } | 1229 } |
1223 if (fMagnify && !fSaveToPdf) { | 1230 if (fMagnify && !fSaveToPdf) { |
1224 magnify(canvas); | 1231 magnify(canvas); |
1225 } | 1232 } |
1226 | 1233 |
1227 if (fMeasureFPS && fMeasureFPS_Time) { | 1234 if (fMeasureFPS && fMeasureFPS_Time) { |
(...skipping 1330 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2558 SkGraphics::Init(); | 2565 SkGraphics::Init(); |
2559 SkEvent::Init(); | 2566 SkEvent::Init(); |
2560 } | 2567 } |
2561 | 2568 |
2562 // FIXME: this should be in a header | 2569 // FIXME: this should be in a header |
2563 void application_term(); | 2570 void application_term(); |
2564 void application_term() { | 2571 void application_term() { |
2565 SkEvent::Term(); | 2572 SkEvent::Term(); |
2566 SkGraphics::Term(); | 2573 SkGraphics::Term(); |
2567 } | 2574 } |
OLD | NEW |