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) { virtual void filter(SkPaint* paint, Type t) {
paint->setFlags(paint->getFlags() & ~fFlags[t] & SkPaint::kAllFlags); 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* maskFilter = paint->getMaskFilter();
SkMaskFilter::BlurInfo blurInfo; SkMaskFilter::BlurInfo blurInfo;
if (maskFilter && maskFilter->asABlur(&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]) { if (PictureRenderer::kHinting_DrawFilterFlag & fFlags[t]) {
@ -80,6 +86,9 @@ private:
static SkCanvas* setUpFilter(SkCanvas* canvas, PictureRenderer::DrawFilterFlags* drawFilters) { static SkCanvas* setUpFilter(SkCanvas* canvas, PictureRenderer::DrawFilterFlags* drawFilters) {
if (drawFilters && !canvas->getDrawFilter()) { if (drawFilters && !canvas->getDrawFilter()) {
canvas->setDrawFilter(SkNEW_ARGS(FlagsDrawFilter, (drawFilters)))->unref(); canvas->setDrawFilter(SkNEW_ARGS(FlagsDrawFilter, (drawFilters)))->unref();
if (drawFilters[0] & PictureRenderer::kAAClip_DrawFilterFlag) {
canvas->setAllowSoftClip(false);
}
} }
return canvas; return canvas;
} }

View File

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

View File

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