Add low blur and AAClip options to picture bench.

Copy the settings instead of pointing to the
original set on the stack.
Review URL: https://codereview.appspot.com/6818103

git-svn-id: http://skia.googlecode.com/svn/trunk@6330 2bbb7eff-a529-9590-31e7-b0007b416f81
This commit is contained in:
caryclark@google.com 2012-11-07 16:42:17 +00:00
parent 7b7cdd147f
commit e3e940cf81
3 changed files with 29 additions and 14 deletions

View File

@ -59,11 +59,17 @@ public:
virtual void filter(SkPaint* paint, Type t) {
paint->setFlags(paint->getFlags() & ~fFlags[t] & SkPaint::kAllFlags);
if (PictureRenderer::kBlur_DrawFilterFlag & fFlags[t]) {
if ((PictureRenderer::kBlur_DrawFilterFlag | PictureRenderer::kLowBlur_DrawFilterFlag)
& fFlags[t]) {
SkMaskFilter* maskFilter = paint->getMaskFilter();
SkMaskFilter::BlurInfo blurInfo;
if (maskFilter && maskFilter->asABlur(&blurInfo)) {
paint->setMaskFilter(NULL);
if (PictureRenderer::kBlur_DrawFilterFlag & fFlags[t]) {
paint->setMaskFilter(NULL);
} else {
blurInfo.fHighQuality = false;
maskFilter->setAsABlur(blurInfo);
}
}
}
if (PictureRenderer::kHinting_DrawFilterFlag & fFlags[t]) {
@ -80,6 +86,9 @@ private:
static SkCanvas* setUpFilter(SkCanvas* canvas, PictureRenderer::DrawFilterFlags* drawFilters) {
if (drawFilters && !canvas->getDrawFilter()) {
canvas->setDrawFilter(SkNEW_ARGS(FlagsDrawFilter, (drawFilters)))->unref();
if (drawFilters[0] & PictureRenderer::kAAClip_DrawFilterFlag) {
canvas->setAllowSoftClip(false);
}
}
return canvas;
}

View File

@ -51,9 +51,11 @@ public:
// this uses SkPaint::Flags as a base and adds additional flags
enum DrawFilterFlags {
kNone_DrawFilterFlag = 0,
kBlur_DrawFilterFlag = 0x4000,
kHinting_DrawFilterFlag = 0x8000, // toggles between no hinting and normal hinting
kSlightHinting_DrawFilterFlag = 0x10000, // toggles between slight and normal hinting
kBlur_DrawFilterFlag = 0x4000, // toggles between blur and no blur
kLowBlur_DrawFilterFlag = 0x8000, // toggles between low and high quality blur
kHinting_DrawFilterFlag = 0x10000, // toggles between no hinting and normal hinting
kSlightHinting_DrawFilterFlag = 0x20000, // toggles between slight and normal hinting
kAAClip_DrawFilterFlag = 0x40000, // toggles between soft and hard clip
};
SK_COMPILE_ASSERT(!(kBlur_DrawFilterFlag & SkPaint::kAllFlags), blur_flag_must_be_greater);
@ -96,8 +98,8 @@ public:
fDeviceType = deviceType;
}
void setDrawFilters(DrawFilterFlags* filters, const SkString& configName) {
fDrawFilters = filters;
void setDrawFilters(DrawFilterFlags const * const filters, const SkString& configName) {
memcpy(fDrawFilters, filters, sizeof(fDrawFilters));
fDrawFiltersConfig = configName;
}
@ -159,13 +161,14 @@ public:
: fPicture(NULL)
, fDeviceType(kBitmap_DeviceType)
, fBBoxHierarchyType(kNone_BBoxHierarchyType)
, fDrawFilters(NULL)
, fGridWidth(0)
, fGridHeight(0)
#if SK_SUPPORT_GPU
, fGrContext(fGrContextFactory.get(GrContextFactory::kNative_GLContextType))
#endif
{}
{
sk_bzero(fDrawFilters, sizeof(fDrawFilters));
}
protected:
void buildBBoxHierarchy();
@ -178,7 +181,7 @@ protected:
SkPicture* fPicture;
SkDeviceTypes fDeviceType;
BBoxHierarchyType fBBoxHierarchyType;
DrawFilterFlags* fDrawFilters;
DrawFilterFlags fDrawFilters[SkDrawFilter::kTypeCount];
SkString fDrawFiltersConfig;
int fGridWidth, fGridHeight; // used when fBBoxHierarchyType is TileGrid

View File

@ -49,8 +49,10 @@ static char const * const gFilterFlags[] = {
"verticalText",
"genA8FromLCD",
"blur",
"lowBlur",
"hinting",
"slightHinting",
"AAClip",
};
static const size_t kFilterFlagsCount = sizeof(gFilterFlags) / sizeof(gFilterFlags[0]);
@ -194,10 +196,11 @@ static void usage(const char* argv0) {
"Set the number of times to repeat each test."
" Default is %i.\n", DEFAULT_REPEATS);
SkDebugf(
" --filter type:flag : ");
SkDebugf(
"Enable canvas filtering to disable a paint flag,\n"
" disable blur, or use less hinting.\n");
" --filter type:flag : Enable canvas filtering to disable a paint flag,\n"
" use no blur or low quality blur, or use no hinting or\n"
" slight hinting. For all flags except AAClip, specify the\n"
" type of primitive to effect, or choose all. for AAClip\n"
" alone, the filter affects all clips independent of type.\n");
}
SkBenchLogger gLogger;