Chromium Code Reviews| Index: samplecode/SampleApp.cpp |
| diff --git a/samplecode/SampleApp.cpp b/samplecode/SampleApp.cpp |
| index 473220e7943f8e49ffda1d32a5887d7c411f659e..2691165b670007e69acda859f987d76230a43f42 100644 |
| --- a/samplecode/SampleApp.cpp |
| +++ b/samplecode/SampleApp.cpp |
| @@ -16,6 +16,7 @@ |
| #include "SkPicture.h" |
| #include "SkPictureRecorder.h" |
| #include "SkStream.h" |
| +#include "SkSurface.h" |
| #include "SkTSort.h" |
| #include "SkTime.h" |
| #include "SkWindow.h" |
| @@ -1192,29 +1193,35 @@ void SampleWindow::draw(SkCanvas* canvas) { |
| } else { |
| SkSize tile = this->tileSize(); |
| - for (SkScalar y = 0; y < height(); y += tile.height()) { |
| - for (SkScalar x = 0; x < width(); x += tile.width()) { |
| - SkAutoCanvasRestore acr(canvas, true); |
| - canvas->clipRect(SkRect::MakeXYWH(x, y, |
| - tile.width(), |
| - tile.height())); |
| - this->INHERITED::draw(canvas); |
| + if (fTilingMode != kNo_Tiling) { |
| + const int w = SkScalarRoundToInt(tile.width()); |
| + const int h = SkScalarRoundToInt(tile.height()); |
| + SkImageInfo info = SkImageInfo::MakeN32Premul(w, h); |
| + SkAutoTUnref<SkSurface> surface(canvas->newSurface(info)); |
| + SkCanvas* tileCanvas = surface->getCanvas(); |
| + |
| + for (SkScalar y = 0; y < height(); y += tile.height()) { |
| + for (SkScalar x = 0; x < width(); x += tile.width()) { |
| + SkAutoCanvasRestore acr(tileCanvas, true); |
| + tileCanvas->translate(-x, -y); |
| + tileCanvas->clear(0); |
| + this->INHERITED::draw(tileCanvas); |
| + surface->draw(canvas, x, y, NULL); |
| + } |
| } |
| - } |
| - if (fTilingMode != kNo_Tiling) { |
| + // for drawing the borders between tiles |
| SkPaint paint; |
| paint.setColor(0x60FF00FF); |
| paint.setStyle(SkPaint::kStroke_Style); |
| for (SkScalar y = 0; y < height(); y += tile.height()) { |
| for (SkScalar x = 0; x < width(); x += tile.width()) { |
| - canvas->drawRect(SkRect::MakeXYWH(x, y, |
| - tile.width(), |
| - tile.height()), |
| - paint); |
| + canvas->drawRect(SkRect::MakeXYWH(x, y, tile.width(), tile.height()), paint); |
| } |
| } |
| + } else { |
| + this->INHERITED::draw(canvas); |
|
mtklein
2014/05/30 14:56:45
The context for this guy seems easy to get lost.
|
| } |
| } |
| if (fShowZoomer && !fSaveToPdf) { |