Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(203)

Unified Diff: gm/gmmain.cpp

Issue 13165011: Add tile rendering to GM (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: Created 7 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: gm/gmmain.cpp
===================================================================
--- gm/gmmain.cpp (revision 8454)
+++ gm/gmmain.cpp (working copy)
@@ -411,16 +411,57 @@
return kEmpty_ErrorCombination;
}
+ static void bitmap_copy_subset(const SkBitmap& src, SkBitmap* dst, int xDst,
+ int yDst) {
+ for (int y = 0; y <src.height() && y + yDst < dst->height() ; y++) {
+ for (int x = 0; x < src.width() && x + xDst < dst->width() ; x++) {
+ *dst->getAddr32(xDst + x, yDst + y) = *src.getAddr32(x, y);
+ }
+ }
+ }
+
static void generate_image_from_picture(GM* gm, const ConfigData& gRec,
SkPicture* pict, SkBitmap* bitmap,
- SkScalar scale = SK_Scalar1) {
+ SkScalar scale = SK_Scalar1,
+ bool tile = false) {
SkISize size = gm->getISize();
setup_bitmap(gRec, size, bitmap);
- SkCanvas canvas(*bitmap);
- installFilter(&canvas);
- canvas.scale(scale, scale);
- canvas.drawPicture(*pict);
- complete_bitmap(bitmap);
+
+ if (tile) {
+ // Generate the result image by rendering to tiles and accumulating
+ // the results in 'bitmap'
+
+ // This 16x16 tiling matches the settings applied to 'pict' in
+ // 'generate_new_picture'
+ SkISize tileSize = SkISize::Make(16, 16);
+
+ SkBitmap tileBM;
+ setup_bitmap(gRec, tileSize, &tileBM);
+ SkCanvas tileCanvas(tileBM);
+ installFilter(&tileCanvas);
+
+ for (int yTile = 0; yTile < (size.height()+15)/16; ++yTile) {
+ for (int xTile = 0; xTile < (size.width()+15)/16; ++xTile) {
+ int saveCount = tileCanvas.save();
+ SkMatrix mat(tileCanvas.getTotalMatrix());
+ mat.postTranslate(SkIntToScalar(-xTile*tileSize.width()),
+ SkIntToScalar(-yTile*tileSize.height()));
+ tileCanvas.setMatrix(mat);
+ pict->draw(&tileCanvas);
+ tileCanvas.flush();
+ tileCanvas.restoreToCount(saveCount);
+ bitmap_copy_subset(tileBM, bitmap,
bsalomon 2013/04/01 17:36:43 Maybe create an SkCanvas around bitmap and drawBit
robertphillips 2013/04/01 18:21:52 What does that buy us?
bsalomon 2013/04/01 18:28:27 Faster, works with different src/dst bitmap types,
robertphillips 2013/04/02 13:29:53 Done.
+ xTile * tileSize.width(),
+ yTile * tileSize.height());
+ }
+ }
+ } else {
+ SkCanvas canvas(*bitmap);
+ installFilter(&canvas);
+ canvas.scale(scale, scale);
+ canvas.drawPicture(*pict);
+ complete_bitmap(bitmap);
+ }
}
static void generate_pdf(GM* gm, SkDynamicMemoryWStream& pdf) {
@@ -1319,7 +1360,11 @@
gm, kTileGrid_BbhType, SkPicture::kUsePathBoundsForClip_RecordingFlag, recordScale);
SkAutoUnref aur(pict);
SkBitmap bitmap;
- gmmain.generate_image_from_picture(gm, compareConfig, pict, &bitmap, replayScale);
+ // We cannot yet pass 'true' to generate_image_from_picture to
+ // perform actual tiled rendering (see Issue 1198 -
+ // https://code.google.com/p/skia/issues/detail?id=1198)
+ gmmain.generate_image_from_picture(gm, compareConfig, pict, &bitmap,
+ replayScale /*, true */);
SkString suffix("-tilegrid");
if (SK_Scalar1 != replayScale) {
suffix += "-scale-";
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698