diff options
author | commit-bot@chromium.org <commit-bot@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2013-09-26 16:09:28 +0000 |
---|---|---|
committer | commit-bot@chromium.org <commit-bot@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2013-09-26 16:09:28 +0000 |
commit | 1a4fb70c8a04db2d92ec821555f91218a989031d (patch) | |
tree | 14ac67f5ef3d1784f0c03d941d7d5b505e344920 /gm/xfermodeimagefilter.cpp | |
parent | 952944144758dd3f9a8a010ec1d99cb4bd035ae4 (diff) |
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
Diffstat (limited to 'gm/xfermodeimagefilter.cpp')
-rw-r--r-- | gm/xfermodeimagefilter.cpp | 35 |
1 files changed, 35 insertions, 0 deletions
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; |