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
2013-09-26 16:09:28 +00:00
|
|
|
/*
|
|
|
|
* Copyright 2013 Google Inc.
|
|
|
|
*
|
|
|
|
* Use of this source code is governed by a BSD-style license that can be
|
|
|
|
* found in the LICENSE file.
|
|
|
|
*/
|
|
|
|
|
2019-04-23 17:05:21 +00:00
|
|
|
#include "gm/gm.h"
|
2019-05-01 21:28:53 +00:00
|
|
|
#include "include/core/SkBitmap.h"
|
|
|
|
#include "include/core/SkCanvas.h"
|
|
|
|
#include "include/core/SkColor.h"
|
2019-04-23 17:05:21 +00:00
|
|
|
#include "include/core/SkImage.h"
|
2019-05-01 21:28:53 +00:00
|
|
|
#include "include/core/SkImageFilter.h"
|
|
|
|
#include "include/core/SkMatrix.h"
|
|
|
|
#include "include/core/SkPaint.h"
|
|
|
|
#include "include/core/SkRect.h"
|
|
|
|
#include "include/core/SkRefCnt.h"
|
|
|
|
#include "include/core/SkScalar.h"
|
|
|
|
#include "include/core/SkSize.h"
|
|
|
|
#include "include/core/SkString.h"
|
2019-08-02 19:21:23 +00:00
|
|
|
#include "include/effects/SkImageFilters.h"
|
2019-08-02 13:57:04 +00:00
|
|
|
#include "src/core/SkImageFilter_Base.h"
|
2019-04-23 17:05:21 +00:00
|
|
|
#include "tools/ToolUtils.h"
|
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
2013-09-26 16:09:28 +00:00
|
|
|
|
2019-05-01 21:28:53 +00:00
|
|
|
#include <utility>
|
|
|
|
|
2014-03-04 19:05:25 +00:00
|
|
|
#define WIDTH 600
|
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
2013-09-26 16:09:28 +00:00
|
|
|
#define HEIGHT 100
|
|
|
|
#define MARGIN 12
|
|
|
|
|
2015-06-22 16:10:14 +00:00
|
|
|
class OffsetImageFilterGM : public skiagm::GM {
|
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
2013-09-26 16:09:28 +00:00
|
|
|
public:
|
2015-06-22 16:10:14 +00:00
|
|
|
OffsetImageFilterGM() {
|
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
2013-09-26 16:09:28 +00:00
|
|
|
this->setBGColor(0xFF000000);
|
|
|
|
}
|
|
|
|
|
|
|
|
protected:
|
2015-06-22 16:10:14 +00:00
|
|
|
SkString onShortName() override {
|
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
2013-09-26 16:09:28 +00:00
|
|
|
return SkString("offsetimagefilter");
|
|
|
|
}
|
|
|
|
|
2015-06-22 16:10:14 +00:00
|
|
|
SkISize onISize() override {
|
2014-06-10 06:59:03 +00:00
|
|
|
return SkISize::Make(WIDTH, HEIGHT);
|
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
2013-09-26 16:09:28 +00:00
|
|
|
}
|
|
|
|
|
2015-06-22 16:10:14 +00:00
|
|
|
void onOnceBeforeDraw() override {
|
2016-03-17 17:51:11 +00:00
|
|
|
fBitmap = SkImage::MakeFromBitmap(
|
2019-03-20 16:12:10 +00:00
|
|
|
ToolUtils::create_string_bitmap(80, 80, 0xD000D000, 15, 65, 96, "e"));
|
2016-03-29 16:03:52 +00:00
|
|
|
|
2016-03-17 17:51:11 +00:00
|
|
|
fCheckerboard = SkImage::MakeFromBitmap(
|
2019-03-20 16:12:10 +00:00
|
|
|
ToolUtils::create_checkerboard_bitmap(80, 80, 0xFFA0A0A0, 0xFF404040, 8));
|
2015-06-22 16:10:14 +00:00
|
|
|
}
|
2015-01-26 19:24:32 +00:00
|
|
|
|
2015-06-22 16:10:14 +00:00
|
|
|
void onDraw(SkCanvas* canvas) override {
|
2015-04-09 18:13:24 +00:00
|
|
|
canvas->clear(SK_ColorBLACK);
|
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
2013-09-26 16:09:28 +00:00
|
|
|
SkPaint paint;
|
|
|
|
|
2014-01-27 13:42:58 +00:00
|
|
|
for (int i = 0; i < 4; i++) {
|
2016-04-01 16:28:51 +00:00
|
|
|
sk_sp<SkImage> image = (i & 0x01) ? fCheckerboard : fBitmap;
|
Make SkImageFilter crop rects relative to the primitive origin, instead of relative to their parent's crop rect. This is required by SVG semantics, and is more sane anyway.
To do this, this patch changes the "offset/loc" parameter in filterImage() / onFilterImage() from an inout-param to an out-param only, so that the calling filter can know how much the input filter wants its result offset (and doesn't include the original primitive position). This offset can then be applied to the current filter's crop rect. (I've renamed the parameter "offset" in all cases to make this clear.) This makes the call sites in SkCanvas/SkGpuDevice responsible for applying the resulting offset to the primitive's position, which is actually a fairly small change.
This change also fixes SkTileImageFilter and SkOffsetImageFilter to correctly handle an input offset, which they weren't before. This required modifying the GM's, since they assumed the broken behaviour.
NOTE: this will require rebaselining the imagefiltersgraph test, since it has a new test case.
NOTE: this will "break" the Blink layout tests css3/filters/effect-reference-subregion-chained-hw.html and css3/filters/effect-reference-subregion-hw.html, but it actually makes them give correct results. It should be suppressed on the skia roll, and I'll rebaseline it.
R=reed@google.com
Review URL: https://codereview.chromium.org/112803004
git-svn-id: http://skia.googlecode.com/svn/trunk@12895 2bbb7eff-a529-9590-31e7-b0007b416f81
2014-01-03 21:48:22 +00:00
|
|
|
SkIRect cropRect = SkIRect::MakeXYWH(i * 12,
|
|
|
|
i * 8,
|
2015-09-15 18:26:13 +00:00
|
|
|
image->width() - i * 8,
|
|
|
|
image->height() - i * 12);
|
2019-08-02 19:21:23 +00:00
|
|
|
sk_sp<SkImageFilter> tileInput(SkImageFilters::Image(image));
|
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
2013-09-26 16:09:28 +00:00
|
|
|
SkScalar dx = SkIntToScalar(i*5);
|
|
|
|
SkScalar dy = SkIntToScalar(i*10);
|
2019-08-02 19:21:23 +00:00
|
|
|
paint.setImageFilter(SkImageFilters::Offset(dx, dy, std::move(tileInput), &cropRect));
|
2016-04-01 16:28:51 +00:00
|
|
|
DrawClippedImage(canvas, image.get(), paint, 1, cropRect);
|
2015-09-15 18:26:13 +00:00
|
|
|
canvas->translate(SkIntToScalar(image->width() + MARGIN), 0);
|
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
2013-09-26 16:09:28 +00:00
|
|
|
}
|
2014-03-04 19:05:25 +00:00
|
|
|
|
|
|
|
SkIRect cropRect = SkIRect::MakeXYWH(0, 0, 100, 100);
|
2019-08-02 19:21:23 +00:00
|
|
|
paint.setImageFilter(SkImageFilters::Offset(-5, -10, nullptr, &cropRect));
|
2016-03-17 17:51:11 +00:00
|
|
|
DrawClippedImage(canvas, fBitmap.get(), paint, 2, cropRect);
|
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
2013-09-26 16:09:28 +00:00
|
|
|
}
|
|
|
|
private:
|
2015-09-15 18:26:13 +00:00
|
|
|
static void DrawClippedImage(SkCanvas* canvas, const SkImage* image, const SkPaint& paint,
|
|
|
|
SkScalar scale, const SkIRect& cropRect) {
|
|
|
|
SkRect clipRect = SkRect::MakeIWH(image->width(), image->height());
|
|
|
|
|
|
|
|
canvas->save();
|
|
|
|
canvas->clipRect(clipRect);
|
|
|
|
canvas->scale(scale, scale);
|
|
|
|
canvas->drawImage(image, 0, 0, &paint);
|
|
|
|
canvas->restore();
|
|
|
|
|
|
|
|
// Draw a boundary rect around the intersection of the clip rect and crop rect.
|
|
|
|
SkRect cropRectFloat;
|
2020-05-21 16:11:27 +00:00
|
|
|
SkMatrix::Scale(scale, scale).mapRect(&cropRectFloat, SkRect::Make(cropRect));
|
2015-09-15 18:26:13 +00:00
|
|
|
if (clipRect.intersect(cropRectFloat)) {
|
|
|
|
SkPaint strokePaint;
|
|
|
|
strokePaint.setStyle(SkPaint::kStroke_Style);
|
|
|
|
strokePaint.setStrokeWidth(2);
|
|
|
|
strokePaint.setColor(SK_ColorRED);
|
|
|
|
canvas->drawRect(clipRect, strokePaint);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-03-17 17:51:11 +00:00
|
|
|
sk_sp<SkImage> fBitmap, fCheckerboard;
|
2015-09-03 20:32:33 +00:00
|
|
|
|
2020-09-03 02:42:33 +00:00
|
|
|
using INHERITED = skiagm::GM;
|
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
2013-09-26 16:09:28 +00:00
|
|
|
};
|
2015-06-22 16:10:14 +00:00
|
|
|
DEF_GM( return new OffsetImageFilterGM; )
|
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
2013-09-26 16:09:28 +00:00
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2015-06-23 13:01:10 +00:00
|
|
|
class SimpleOffsetImageFilterGM : public skiagm::GM {
|
|
|
|
public:
|
|
|
|
SimpleOffsetImageFilterGM() {}
|
2016-03-29 16:03:52 +00:00
|
|
|
|
2015-06-23 13:01:10 +00:00
|
|
|
protected:
|
|
|
|
SkString onShortName() override {
|
|
|
|
return SkString("simple-offsetimagefilter");
|
|
|
|
}
|
2016-03-29 16:03:52 +00:00
|
|
|
|
2015-06-23 21:34:58 +00:00
|
|
|
SkISize onISize() override { return SkISize::Make(640, 200); }
|
2016-03-29 16:03:52 +00:00
|
|
|
|
2016-03-31 16:05:49 +00:00
|
|
|
void doDraw(SkCanvas* canvas, const SkRect& r, sk_sp<SkImageFilter> imgf,
|
2015-08-27 14:41:13 +00:00
|
|
|
const SkRect* clipR = nullptr) {
|
2015-06-23 13:01:10 +00:00
|
|
|
SkPaint p;
|
|
|
|
|
|
|
|
if (clipR) {
|
|
|
|
p.setColor(0xFF00FF00);
|
|
|
|
p.setStyle(SkPaint::kStroke_Style);
|
|
|
|
canvas->drawRect(clipR->makeInset(SK_ScalarHalf, SK_ScalarHalf), p);
|
|
|
|
p.setStyle(SkPaint::kFill_Style);
|
|
|
|
}
|
|
|
|
|
2019-08-02 13:57:04 +00:00
|
|
|
// Visualize the crop rect for debugging
|
|
|
|
if (imgf && as_IFB(imgf)->cropRectIsSet()) {
|
|
|
|
SkImageFilter::CropRect cr = as_IFB(imgf)->getCropRect();
|
2015-06-23 15:29:20 +00:00
|
|
|
|
|
|
|
p.setColor(0x66FF00FF);
|
|
|
|
p.setStyle(SkPaint::kStroke_Style);
|
|
|
|
canvas->drawRect(cr.rect().makeInset(SK_ScalarHalf, SK_ScalarHalf), p);
|
|
|
|
p.setStyle(SkPaint::kFill_Style);
|
|
|
|
}
|
|
|
|
|
|
|
|
p.setColor(0x660000FF);
|
2015-06-23 13:01:10 +00:00
|
|
|
canvas->drawRect(r, p);
|
|
|
|
|
|
|
|
if (clipR) {
|
|
|
|
canvas->save();
|
|
|
|
canvas->clipRect(*clipR);
|
|
|
|
}
|
2015-06-23 16:28:52 +00:00
|
|
|
if (imgf) {
|
2016-03-31 16:05:49 +00:00
|
|
|
p.setImageFilter(std::move(imgf));
|
2015-06-23 16:28:52 +00:00
|
|
|
}
|
2015-06-23 15:29:20 +00:00
|
|
|
p.setColor(0x66FF0000);
|
2015-06-23 13:01:10 +00:00
|
|
|
canvas->drawRect(r, p);
|
2015-06-23 15:29:20 +00:00
|
|
|
|
2015-06-23 13:01:10 +00:00
|
|
|
if (clipR) {
|
|
|
|
canvas->restore();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void onDraw(SkCanvas* canvas) override {
|
2019-08-02 19:21:23 +00:00
|
|
|
SkIRect cr0 = SkIRect::MakeWH(40, 40);
|
|
|
|
SkIRect cr1 = SkIRect::MakeWH(20, 20);
|
|
|
|
SkIRect cr2 = SkIRect::MakeXYWH(40, 0, 40, 40);
|
|
|
|
const SkRect r = SkRect::Make(cr0);
|
|
|
|
const SkRect r2 = SkRect::Make(cr2);
|
2015-06-23 13:01:10 +00:00
|
|
|
|
2015-06-23 21:34:58 +00:00
|
|
|
canvas->translate(40, 40);
|
2016-03-29 16:03:52 +00:00
|
|
|
|
2015-06-23 21:34:58 +00:00
|
|
|
canvas->save();
|
2015-08-27 14:41:13 +00:00
|
|
|
this->doDraw(canvas, r, nullptr);
|
2016-03-29 16:03:52 +00:00
|
|
|
|
2015-06-23 21:34:58 +00:00
|
|
|
canvas->translate(100, 0);
|
2019-08-02 19:21:23 +00:00
|
|
|
this->doDraw(canvas, r, SkImageFilters::Offset(20, 20, nullptr));
|
2016-03-29 16:03:52 +00:00
|
|
|
|
2015-06-23 21:34:58 +00:00
|
|
|
canvas->translate(100, 0);
|
2019-08-02 19:21:23 +00:00
|
|
|
this->doDraw(canvas, r, SkImageFilters::Offset(20, 20, nullptr, &cr0));
|
2016-03-29 16:03:52 +00:00
|
|
|
|
2015-06-23 21:34:58 +00:00
|
|
|
canvas->translate(100, 0);
|
2019-08-02 19:21:23 +00:00
|
|
|
this->doDraw(canvas, r, SkImageFilters::Offset(20, 20, nullptr), &r);
|
2016-03-29 16:03:52 +00:00
|
|
|
|
2015-06-23 21:34:58 +00:00
|
|
|
canvas->translate(100, 0);
|
2019-08-02 19:21:23 +00:00
|
|
|
this->doDraw(canvas, r, SkImageFilters::Offset(20, 20, nullptr, &cr1));
|
2016-03-29 16:03:52 +00:00
|
|
|
|
2015-06-23 21:34:58 +00:00
|
|
|
SkRect clipR = SkRect::MakeXYWH(40, 40, 40, 40);
|
|
|
|
canvas->translate(100, 0);
|
2019-08-02 19:21:23 +00:00
|
|
|
this->doDraw(canvas, r, SkImageFilters::Offset(20, 20, nullptr, nullptr), &clipR);
|
2015-06-23 21:34:58 +00:00
|
|
|
canvas->restore();
|
|
|
|
|
|
|
|
// 2nd row
|
|
|
|
canvas->translate(0, 80);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* combos of clip and crop rects that align with src and dst
|
|
|
|
*/
|
|
|
|
|
|
|
|
// crop==clip==src
|
2019-08-02 19:21:23 +00:00
|
|
|
this->doDraw(canvas, r, SkImageFilters::Offset(40, 0, nullptr, &cr0), &r);
|
2015-06-23 21:34:58 +00:00
|
|
|
|
|
|
|
// crop==src, clip==dst
|
|
|
|
canvas->translate(100, 0);
|
2019-08-02 19:21:23 +00:00
|
|
|
this->doDraw(canvas, r, SkImageFilters::Offset(40, 0, nullptr, &cr0), &r2);
|
2015-06-23 21:34:58 +00:00
|
|
|
|
|
|
|
// crop==dst, clip==src
|
|
|
|
canvas->translate(100, 0);
|
2019-08-02 19:21:23 +00:00
|
|
|
this->doDraw(canvas, r, SkImageFilters::Offset(40, 0, nullptr, &cr2), &r);
|
2015-06-23 21:34:58 +00:00
|
|
|
|
|
|
|
// crop==clip==dst
|
|
|
|
canvas->translate(100, 0);
|
2019-08-02 19:21:23 +00:00
|
|
|
this->doDraw(canvas, r, SkImageFilters::Offset(40, 0, nullptr, &cr2), &r2);
|
2015-06-23 13:01:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
2020-09-03 02:42:33 +00:00
|
|
|
using INHERITED = skiagm::GM;
|
2015-06-23 13:01:10 +00:00
|
|
|
};
|
|
|
|
DEF_GM( return new SimpleOffsetImageFilterGM; )
|