blob: 440337a64236e9f775bf2e78b2b71ac4af38073a [file] [log] [blame]
commit-bot@chromium.org1a4fb702013-09-26 16:09:28 +00001/*
2 * Copyright 2013 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
8#ifndef SkTileImageFilter_DEFINED
9#define SkTileImageFilter_DEFINED
10
11#include "SkImageFilter.h"
12
sugoi@google.com55f56822013-10-02 18:27:43 +000013class SK_API SkTileImageFilter : public SkImageFilter {
commit-bot@chromium.org1a4fb702013-09-26 16:09:28 +000014 typedef SkImageFilter INHERITED;
15
16public:
commit-bot@chromium.orgcac5fd52014-03-10 10:51:58 +000017 /** Create a tile image filter
commit-bot@chromium.org1a4fb702013-09-26 16:09:28 +000018 @param srcRect Defines the pixels to tile
19 @param dstRect Defines the pixels where tiles are drawn
20 @param input Input from which the subregion defined by srcRect will be tiled
21 */
commit-bot@chromium.orgcac5fd52014-03-10 10:51:58 +000022 static SkTileImageFilter* Create(const SkRect& srcRect, const SkRect& dstRect,
senorblanco5e5f9482014-08-26 12:27:12 -070023 SkImageFilter* input, uint32_t uniqueID = 0);
commit-bot@chromium.org1a4fb702013-09-26 16:09:28 +000024
senorblanco@chromium.org4cb543d2014-03-14 15:44:01 +000025 virtual bool onFilterImage(Proxy* proxy, const SkBitmap& src, const Context& ctx,
commit-bot@chromium.orgae761f72014-02-05 22:32:02 +000026 SkBitmap* dst, SkIPoint* offset) const SK_OVERRIDE;
senorblanco@chromium.org0a5c2332014-04-29 15:20:39 +000027 virtual bool onFilterBounds(const SkIRect& src, const SkMatrix&,
28 SkIRect* dst) const SK_OVERRIDE;
commit-bot@chromium.org1a4fb702013-09-26 16:09:28 +000029
30 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkTileImageFilter)
31
32protected:
senorblanco5e5f9482014-08-26 12:27:12 -070033 SkTileImageFilter(const SkRect& srcRect, const SkRect& dstRect, SkImageFilter* input, uint32_t uniqueID)
34 : INHERITED(1, &input, NULL, uniqueID), fSrcRect(srcRect), fDstRect(dstRect) {}
reed9fa60da2014-08-21 07:59:51 -070035#ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING
commit-bot@chromium.org8b0e8ac2014-01-30 18:58:24 +000036 explicit SkTileImageFilter(SkReadBuffer& buffer);
reed9fa60da2014-08-21 07:59:51 -070037#endif
commit-bot@chromium.org1a4fb702013-09-26 16:09:28 +000038
commit-bot@chromium.org8b0e8ac2014-01-30 18:58:24 +000039 virtual void flatten(SkWriteBuffer& buffer) const SK_OVERRIDE;
commit-bot@chromium.org1a4fb702013-09-26 16:09:28 +000040
commit-bot@chromium.org1a4fb702013-09-26 16:09:28 +000041private:
42 SkRect fSrcRect;
43 SkRect fDstRect;
44};
45
46#endif