Turn on the kUsePathBoundsForClip_RecordingFlag in bench, gm and tools that use class PictureRenderer

Chrome uses this flag for recording to skpicture in order to improve performance.
Therefore, skai benchmarks should run with this flag enabled, and we need 
gm and render_pictures test coverage to validate it.  In gm, the vanilla 
SkPicture test step will still run without the flag to ensure that case still gets test
coverage, while the SkPicture test steps that use rtree and tileGrid will now run with
the flag enabled.
Review URL: https://codereview.appspot.com/7111043

git-svn-id: http://skia.googlecode.com/svn/trunk@7234 2bbb7eff-a529-9590-31e7-b0007b416f81
This commit is contained in:
junov@chromium.org 2013-01-16 18:43:36 +00:00
parent ca1b3ff634
commit 20bd04e365
3 changed files with 21 additions and 12 deletions

View File

@ -775,7 +775,8 @@ int tool_main(int argc, char** argv) {
canvas = new SkDeferredCanvas(device);
break;
case kRecord_benchModes:
canvas = pictureRecordTo.beginRecording(dim.fX, dim.fY);
canvas = pictureRecordTo.beginRecording(dim.fX, dim.fY,
SkPicture::kUsePathBoundsForClip_RecordingFlag);
canvas->ref();
break;
case kPictureRecord_benchModes: {
@ -784,10 +785,12 @@ int tool_main(int argc, char** argv) {
// pictureRecordFrom. As the benchmark, we will time how
// long it takes to playback pictureRecordFrom into
// pictureRecordTo.
SkCanvas* tempCanvas = pictureRecordFrom.beginRecording(dim.fX, dim.fY);
SkCanvas* tempCanvas = pictureRecordFrom.beginRecording(dim.fX, dim.fY,
SkPicture::kUsePathBoundsForClip_RecordingFlag);
bench->draw(tempCanvas);
pictureRecordFrom.endRecording();
canvas = pictureRecordTo.beginRecording(dim.fX, dim.fY);
canvas = pictureRecordTo.beginRecording(dim.fX, dim.fY,
SkPicture::kUsePathBoundsForClip_RecordingFlag);
canvas->ref();
break;
}
@ -845,7 +848,8 @@ int tool_main(int argc, char** argv) {
|| benchMode == kPictureRecord_benchModes)) {
// This will clear the recorded commands so that they do not
// acculmulate.
canvas = pictureRecordTo.beginRecording(dim.fX, dim.fY);
canvas = pictureRecordTo.beginRecording(dim.fX, dim.fY,
SkPicture::kUsePathBoundsForClip_RecordingFlag);
}
timer.start();

View File

@ -617,7 +617,8 @@ public:
return retval;
}
static SkPicture* generate_new_picture(GM* gm, BbhType bbhType, SkScalar scale = SK_Scalar1) {
static SkPicture* generate_new_picture(GM* gm, BbhType bbhType, uint32_t recordFlags,
SkScalar scale = SK_Scalar1) {
// Pictures are refcounted so must be on heap
SkPicture* pict;
int width = SkScalarCeilToInt(SkScalarMul(SkIntToScalar(gm->getISize().width()), scale));
@ -628,8 +629,9 @@ public:
} else {
pict = new SkPicture;
}
uint32_t recordFlags = (kNone_BbhType == bbhType) ?
0 : SkPicture::kOptimizeForClippedPlayback_RecordingFlag;
if (kNone_BbhType != bbhType) {
recordFlags |= SkPicture::kOptimizeForClippedPlayback_RecordingFlag;
}
SkCanvas* cv = pict->beginRecording(width, height, recordFlags);
cv->scale(scale, scale);
invokeGM(gm, cv, false, false);
@ -1344,7 +1346,7 @@ int tool_main(int argc, char** argv) {
ErrorBitfield pictErrors = ERROR_NONE;
//SkAutoTUnref<SkPicture> pict(generate_new_picture(gm));
SkPicture* pict = gmmain.generate_new_picture(gm, kNone_BbhType);
SkPicture* pict = gmmain.generate_new_picture(gm, kNone_BbhType, 0);
SkAutoUnref aur(pict);
if ((ERROR_NONE == testErrors) && doReplay) {
@ -1387,7 +1389,8 @@ int tool_main(int argc, char** argv) {
}
if (!(gmFlags & GM::kSkipPicture_Flag) && doRTree) {
SkPicture* pict = gmmain.generate_new_picture(gm, kRTree_BbhType);
SkPicture* pict = gmmain.generate_new_picture(gm, kRTree_BbhType,
SkPicture::kUsePathBoundsForClip_RecordingFlag);
SkAutoUnref aur(pict);
SkBitmap bitmap;
gmmain.generate_image_from_picture(gm, compareConfig, pict,
@ -1407,7 +1410,8 @@ int tool_main(int argc, char** argv) {
// We record with the reciprocal scale to obtain a replay
// result that can be validated against comparisonBitmap.
SkScalar recordScale = SkScalarInvert(replayScale);
SkPicture* pict = gmmain.generate_new_picture(gm, kTileGrid_BbhType, recordScale);
SkPicture* pict = gmmain.generate_new_picture(gm, kTileGrid_BbhType,
SkPicture::kUsePathBoundsForClip_RecordingFlag, recordScale);
SkAutoUnref aur(pict);
SkBitmap bitmap;
gmmain.generate_image_from_picture(gm, compareConfig, pict,

View File

@ -190,8 +190,9 @@ void PictureRenderer::resetState() {
}
uint32_t PictureRenderer::recordFlags() {
return kNone_BBoxHierarchyType == fBBoxHierarchyType ? 0 :
SkPicture::kOptimizeForClippedPlayback_RecordingFlag;
return kNone_BBoxHierarchyType == (fBBoxHierarchyType ? 0 :
SkPicture::kOptimizeForClippedPlayback_RecordingFlag) |
SkPicture::kUsePathBoundsForClip_RecordingFlag;
}
/**