diff options
author | caryclark@google.com <caryclark@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2012-11-07 16:42:17 +0000 |
---|---|---|
committer | caryclark@google.com <caryclark@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2012-11-07 16:42:17 +0000 |
commit | e3e940cf81dc46d872002ded98c1bd39c2daf1b0 (patch) | |
tree | 838b67169c7876d61a24c75de0ecd827d9a70384 | |
parent | 7b7cdd147f5528865238e5ed98c79e6d319fde9b (diff) |
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
-rw-r--r-- | tools/PictureRenderer.cpp | 13 | ||||
-rw-r--r-- | tools/PictureRenderer.h | 19 | ||||
-rw-r--r-- | tools/bench_pictures_main.cpp | 11 |
3 files changed, 29 insertions, 14 deletions
diff --git a/tools/PictureRenderer.cpp b/tools/PictureRenderer.cpp index 59ba680842..84b67d84f9 100644 --- a/tools/PictureRenderer.cpp +++ b/tools/PictureRenderer.cpp @@ -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; } diff --git a/tools/PictureRenderer.h b/tools/PictureRenderer.h index 5b5f84bc06..8d9a6bd978 100644 --- a/tools/PictureRenderer.h +++ b/tools/PictureRenderer.h @@ -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 diff --git a/tools/bench_pictures_main.cpp b/tools/bench_pictures_main.cpp index 569a0a5006..acbe747c8b 100644 --- a/tools/bench_pictures_main.cpp +++ b/tools/bench_pictures_main.cpp @@ -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; |