Index: tools/VisualBench/VisualSKPBench.cpp |
diff --git a/tools/VisualBench/VisualSKPBench.cpp b/tools/VisualBench/VisualSKPBench.cpp |
index 628265e53e103d9a485fd4d5c6dc76fc01c960a8..5d15d7ef2071c6ea7d35ccd027ff423d598e12b2 100644 |
--- a/tools/VisualBench/VisualSKPBench.cpp |
+++ b/tools/VisualBench/VisualSKPBench.cpp |
@@ -14,6 +14,7 @@ |
VisualSKPBench::VisualSKPBench(const char* name, const SkPicture* pic) |
: fPic(SkRef(pic)) |
+ , fCullRect(fPic->cullRect().roundOut()) |
, fName(name) { |
fUniqueName.printf("%s", name); |
} |
@@ -30,7 +31,17 @@ bool VisualSKPBench::isSuitableFor(Backend backend) { |
return backend != kNonRendering_Backend; |
} |
+SkIPoint VisualSKPBench::onGetSize() { |
+ return SkIPoint::Make(fCullRect.width(), fCullRect.height()); |
+} |
+ |
void VisualSKPBench::onDraw(int loops, SkCanvas* canvas) { |
+ bool isOffset = SkToBool(fCullRect.left() | fCullRect.top()); |
+ if (isOffset) { |
+ canvas->save(); |
+ canvas->translate(SkIntToScalar(-fCullRect.left()), SkIntToScalar(-fCullRect.top())); |
+ } |
+ |
for (int i = 0; i < loops; i++) { |
canvas->drawPicture(fPic); |
#if SK_SUPPORT_GPU |
@@ -40,4 +51,8 @@ void VisualSKPBench::onDraw(int loops, SkCanvas* canvas) { |
} |
#endif |
} |
+ |
+ if (isOffset) { |
+ canvas->restore(); |
+ } |
} |