Change SkTileGride geometry calculations to match the Chromium compositor.
This patch changes the semantics of tileWidth/Height to include the border region, and
uses an offset to take into account the fact that there is no outer border for outer
tiles. This patch also fixes a previous bug where the right column and bottom row were
considered to be included in bounds that are expressed as an SkIRect.
Companion Chromium CL required for roll: https://codereview.chromium.org/12221077/
TEST=TileGrid unit test
Review URL: https://codereview.appspot.com/7350050
git-svn-id: http://skia.googlecode.com/svn/trunk@7885 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/tools/PictureRenderer.cpp b/tools/PictureRenderer.cpp
index 16768c7..caab64a 100644
--- a/tools/PictureRenderer.cpp
+++ b/tools/PictureRenderer.cpp
@@ -42,6 +42,9 @@
void PictureRenderer::init(SkPicture* pict) {
SkASSERT(NULL == fPicture);
SkASSERT(NULL == fCanvas.get());
+ fGridInfo.fMargin.setEmpty();
+ fGridInfo.fOffset.setZero();
+ fGridInfo.fTileInterval.set(1, 1);
if (fPicture != NULL || NULL != fCanvas.get()) {
return;
}
@@ -800,8 +803,8 @@
case kRTree_BBoxHierarchyType:
return SkNEW(RTreePicture);
case kTileGrid_BBoxHierarchyType:
- return SkNEW_ARGS(SkTileGridPicture, (fGridWidth, fGridHeight, fPicture->width(),
- fPicture->height()));
+ return SkNEW_ARGS(SkTileGridPicture, (fPicture->width(),
+ fPicture->height(), fGridInfo));
}
SkASSERT(0); // invalid bbhType
return NULL;
diff --git a/tools/PictureRenderer.h b/tools/PictureRenderer.h
index b054a54..47fc7d7 100644
--- a/tools/PictureRenderer.h
+++ b/tools/PictureRenderer.h
@@ -19,6 +19,7 @@
#include "SkString.h"
#include "SkTDArray.h"
#include "SkThreadPool.h"
+#include "SkTileGridPicture.h"
#include "SkTypes.h"
#if SK_SUPPORT_GPU
@@ -170,8 +171,7 @@
}
void setGridSize(int width, int height) {
- fGridWidth = width;
- fGridHeight = height;
+ fGridInfo.fTileInterval.set(width, height);
}
bool isUsingBitmapDevice() {
@@ -255,8 +255,6 @@
: fPicture(NULL)
, fDeviceType(kBitmap_DeviceType)
, fBBoxHierarchyType(kNone_BBoxHierarchyType)
- , fGridWidth(0)
- , fGridHeight(0)
, fScaleFactor(SK_Scalar1)
#if SK_SUPPORT_GPU
, fGrContext(NULL)
@@ -279,7 +277,7 @@
BBoxHierarchyType fBBoxHierarchyType;
DrawFilterFlags fDrawFilters[SkDrawFilter::kTypeCount];
SkString fDrawFiltersConfig;
- int fGridWidth, fGridHeight; // used when fBBoxHierarchyType is TileGrid
+ SkTileGridPicture::TileGridInfo fGridInfo; // used when fBBoxHierarchyType is TileGrid
void buildBBoxHierarchy();