Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(7)

Unified Diff: gm/imagefiltersgraph.cpp

Issue 1884733002: Remove SimpleOffsetFilter (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: gm/imagefiltersgraph.cpp
diff --git a/gm/imagefiltersgraph.cpp b/gm/imagefiltersgraph.cpp
index 8c80ca3379d5a0ef5fbe833fbb21739d65f43df3..d9ab4d025ed3ba2db30f793248c5f2acd8663f7a 100644
--- a/gm/imagefiltersgraph.cpp
+++ b/gm/imagefiltersgraph.cpp
@@ -15,6 +15,7 @@
#include "SkImage.h"
#include "SkImageSource.h"
#include "SkMatrixConvolutionImageFilter.h"
+#include "SkOffsetImageFilter.h"
#include "SkReadBuffer.h"
#include "SkSpecialImage.h"
#include "SkSpecialSurface.h"
@@ -24,94 +25,6 @@
#include "SkTestImageFilters.h"
#include "SkXfermodeImageFilter.h"
-// More closely models how Blink's OffsetFilter works as of 10/23/13. SkOffsetImageFilter doesn't
-// perform a draw and this one does.
-class SimpleOffsetFilter : public SkImageFilter {
-public:
- class Registrar {
- public:
- Registrar() {
- SkFlattenable::Register("SimpleOffsetFilter",
- SimpleOffsetFilter::CreateProc,
- SimpleOffsetFilter::GetFlattenableType());
- }
- };
- static sk_sp<SkImageFilter> Make(SkScalar dx, SkScalar dy, sk_sp<SkImageFilter> input) {
- return sk_sp<SkImageFilter>(new SimpleOffsetFilter(dx, dy, std::move(input)));
- }
-
- SK_TO_STRING_OVERRIDE()
- SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SimpleOffsetFilter);
-
-protected:
- sk_sp<SkSpecialImage> onFilterImage(SkSpecialImage* source, const Context& ctx,
- SkIPoint* offset) const override {
- SkIPoint inputOffset = SkIPoint::Make(0, 0);
- sk_sp<SkSpecialImage> input(this->filterInput(0, source, ctx, &inputOffset));
- if (!input) {
- return nullptr;
- }
-
- SkIRect bounds;
- input = this->applyCropRect(ctx, input.get(), &inputOffset, &bounds);
- if (!input) {
- return nullptr;
- }
-
- SkImageInfo info = SkImageInfo::MakeN32Premul(bounds.width(), bounds.height());
-
- sk_sp<SkSpecialSurface> surf(source->makeSurface(info));
- if (!surf) {
- return nullptr;
- }
-
- SkCanvas* canvas = surf->getCanvas();
- SkASSERT(canvas);
-
- SkPaint paint;
- paint.setXfermodeMode(SkXfermode::kSrc_Mode);
-
- input->draw(canvas, fDX - bounds.left(), fDY - bounds.top(), &paint);
-
- offset->fX += bounds.left();
- offset->fY += bounds.top();
- return surf->makeImageSnapshot();
- }
-
- void flatten(SkWriteBuffer& buffer) const override {
- this->INHERITED::flatten(buffer);
- buffer.writeScalar(fDX);
- buffer.writeScalar(fDY);
- }
-
-private:
- SimpleOffsetFilter(SkScalar dx, SkScalar dy, sk_sp<SkImageFilter> input)
- : SkImageFilter(&input, 1, nullptr)
- , fDX(dx)
- , fDY(dy) {
- }
-
- SkScalar fDX, fDY;
-
- typedef SkImageFilter INHERITED;
-};
-
-static SimpleOffsetFilter::Registrar gReg;
-
-sk_sp<SkFlattenable> SimpleOffsetFilter::CreateProc(SkReadBuffer& buffer) {
- SK_IMAGEFILTER_UNFLATTEN_COMMON(common, 1);
- SkScalar dx = buffer.readScalar();
- SkScalar dy = buffer.readScalar();
- return Make(dx, dy, common.getInput(0));
-}
-
-#ifndef SK_IGNORE_TO_STRING
-void SimpleOffsetFilter::toString(SkString* str) const {
- str->appendf("SimpleOffsetFilter: (");
- str->append(")");
-}
-#endif
-
class ImageFiltersGraphGM : public skiagm::GM {
public:
ImageFiltersGraphGM() {}
@@ -173,7 +86,8 @@ protected:
sk_sp<SkColorFilter> matrixCF(SkColorFilter::MakeMatrixFilterRowMajor255(matrix));
sk_sp<SkImageFilter> matrixFilter(SkColorFilterImageFilter::Make(std::move(matrixCF),
nullptr));
- sk_sp<SkImageFilter> offsetFilter(SimpleOffsetFilter::Make(10.0f, 10.f, matrixFilter));
+ sk_sp<SkImageFilter> offsetFilter(SkOffsetImageFilter::Make(10.0f, 10.f,
+ matrixFilter));
SkPaint paint;
paint.setImageFilter(
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698