From 1a4fb70c8a04db2d92ec821555f91218a989031d Mon Sep 17 00:00:00 2001 From: "commit-bot@chromium.org" Date: Thu, 26 Sep 2013 16:09:28 +0000 Subject: Moving 4 SkImageFilter derived classes from blink to skia There were 4 classes in blink that derived from SkImageFilter : - TileImageFilter -> SkTileImageFilter - OffsetImageFilter -> SkOffsetImageFilter (already existed) - FloodImageFilter -> SkFloodImageFilter - CompositeImageFilter -> SkCompositeImageFilter All functions were copied as is, without modification (except for warnings fixes), except for the offset filter, which was merged into the existing SkOffsetImageFilter class, as a special case when a crop rect is provided. Since the names won't clash with the names in blink, it should be easy to integrate them in blink later and fix issues, if needed. BUG= R=senorblanco@google.com, senorblanco@chromium.org, bsalomon@google.com, reed@google.com, mtklein@google.com Author: sugoi@chromium.org Review URL: https://chromiumcodereview.appspot.com/24157005 git-svn-id: http://skia.googlecode.com/svn/trunk@11475 2bbb7eff-a529-9590-31e7-b0007b416f81 --- gm/xfermodeimagefilter.cpp | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) (limited to 'gm/xfermodeimagefilter.cpp') diff --git a/gm/xfermodeimagefilter.cpp b/gm/xfermodeimagefilter.cpp index 94d60e45eb..ef2958a0c3 100644 --- a/gm/xfermodeimagefilter.cpp +++ b/gm/xfermodeimagefilter.cpp @@ -189,6 +189,41 @@ protected: SkIntToScalar(fBitmap.height() + 4))); canvas->drawPaint(paint); canvas->restore(); + x += fBitmap.width() + MARGIN; + if (x + fBitmap.width() > WIDTH) { + x = 0; + y += fBitmap.height() + MARGIN; + } + // Test cropping + static const size_t nbSamples = 3; + SkXfermode::Mode sampledModes[nbSamples] = {SkXfermode::kOverlay_Mode, + SkXfermode::kSrcOver_Mode, + SkXfermode::kPlus_Mode}; + int offsets[nbSamples][4] = {{ 10, 10, -16, -16}, + { 10, 10, 10, 10}, + {-10, -10, -6, -6}}; + for (size_t i = 0; i < nbSamples; ++i) { + SkIRect cropRect = SkIRect::MakeXYWH(x + offsets[i][0], + y + offsets[i][1], + fBitmap.width() + offsets[i][2], + fBitmap.height() + offsets[i][3]); + mode.reset(SkXfermode::Create(sampledModes[i])); + filter.reset(SkNEW_ARGS(SkXfermodeImageFilter, + (mode, offsetBackground, offsetForeground, &cropRect))); + paint.setImageFilter(filter); + canvas->save(); + canvas->clipRect(SkRect::MakeXYWH(SkIntToScalar(x), + SkIntToScalar(y), + SkIntToScalar(fBitmap.width() + 4), + SkIntToScalar(fBitmap.height() + 4))); + canvas->drawPaint(paint); + canvas->restore(); + x += fBitmap.width() + MARGIN; + if (x + fBitmap.width() > WIDTH) { + x = 0; + y += fBitmap.height() + MARGIN; + } + } } private: typedef GM INHERITED; -- cgit v1.2.3