From 6c1ee2d4e727357451c8a6fcf4a08e75890b5d6d Mon Sep 17 00:00:00 2001 From: "commit-bot@chromium.org" Date: Mon, 7 Oct 2013 18:00:17 +0000 Subject: Luminance-to-alpha color filter (SkLumaColorFilter). Adding a color filter luma implementation. The plan is to convert existing clients and then deprecate SkLumaXfermode. R=bsalomon@google.com, reed@google.com, robertphillips@google.com Author: fmalita@chromium.org Review URL: https://codereview.chromium.org/25453004 git-svn-id: http://skia.googlecode.com/svn/trunk@11636 2bbb7eff-a529-9590-31e7-b0007b416f81 --- bench/ColorFilterBench.cpp | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) (limited to 'bench/ColorFilterBench.cpp') diff --git a/bench/ColorFilterBench.cpp b/bench/ColorFilterBench.cpp index e30b005964..6d98a0eabc 100644 --- a/bench/ColorFilterBench.cpp +++ b/bench/ColorFilterBench.cpp @@ -8,6 +8,7 @@ #include "SkCanvas.h" #include "SkColorFilterImageFilter.h" #include "SkColorMatrixFilter.h" +#include "SkLumaColorFilter.h" #include "SkTableColorFilter.h" #define FILTER_WIDTH_SMALL SkIntToScalar(32) @@ -314,6 +315,33 @@ private: typedef ColorFilterBaseBench INHERITED; }; +class LumaColorFilterBench : public ColorFilterBaseBench { + +public: + LumaColorFilterBench(bool small) : INHERITED(small) { + } + +protected: + virtual const char* onGetName() SK_OVERRIDE { + return isSmall() ? "luma_colorfilter_small" : "luma_colorfilter_large"; + } + + virtual void onDraw(SkCanvas* canvas) SK_OVERRIDE { + SkRect r = getFilterRect(); + SkPaint paint; + paint.setColor(SK_ColorRED); + + for (int i = 0; i < this->getLoops(); i++) { + SkAutoTUnref luma_filter(SkLumaColorFilter::Create()); + paint.setColorFilter(luma_filter); + canvas->drawRect(r, paint); + } + } + +private: + typedef ColorFilterBaseBench INHERITED; +}; + /////////////////////////////////////////////////////////////////////////////// DEF_BENCH( return new ColorFilterDimBrightBench(true); ) @@ -325,6 +353,7 @@ DEF_BENCH( return new ColorFilterBrightBench(true); ) DEF_BENCH( return new ColorFilterBlueBench(true); ) DEF_BENCH( return new ColorFilterGrayBench(true); ) DEF_BENCH( return new TableColorFilterBench(true); ) +DEF_BENCH( return new LumaColorFilterBench(true); ) DEF_BENCH( return new ColorFilterDimBrightBench(false); ) DEF_BENCH( return new ColorFilterBrightGrayBench(false); ) @@ -335,3 +364,4 @@ DEF_BENCH( return new ColorFilterBrightBench(false); ) DEF_BENCH( return new ColorFilterBlueBench(false); ) DEF_BENCH( return new ColorFilterGrayBench(false); ) DEF_BENCH( return new TableColorFilterBench(false); ) +DEF_BENCH( return new LumaColorFilterBench(false); ) -- cgit v1.2.3