blob: fbd04f097a97624f017b8d8762e4cd099228edbd [file] [log] [blame]
senorblanco@chromium.org53333002013-12-12 23:28:52 +00001/*
2 * Copyright 2013 The Android Open Source Project
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 SkPictureImageFilter_DEFINED
9#define SkPictureImageFilter_DEFINED
10
11#include "SkImageFilter.h"
12#include "SkPicture.h"
13
14class SK_API SkPictureImageFilter : public SkImageFilter {
15public:
16 /**
17 * Refs the passed-in picture.
18 */
senorblanco5e5f9482014-08-26 12:27:12 -070019 static SkPictureImageFilter* Create(const SkPicture* picture, int32_t uniqueID = 0) {
20 return SkNEW_ARGS(SkPictureImageFilter, (picture, uniqueID));
commit-bot@chromium.orgcac5fd52014-03-10 10:51:58 +000021 }
senorblanco@chromium.org53333002013-12-12 23:28:52 +000022
23 /**
commit-bot@chromium.orgcac5fd52014-03-10 10:51:58 +000024 * Refs the passed-in picture. cropRect can be used to crop or expand the destination rect when
senorblanco@chromium.org53333002013-12-12 23:28:52 +000025 * the picture is drawn. (No scaling is implied by the dest rect; only the CTM is applied.)
26 */
senorblanco5e5f9482014-08-26 12:27:12 -070027 static SkPictureImageFilter* Create(const SkPicture* picture, const SkRect& cropRect, uint32_t uniqueID = 0) {
28 return SkNEW_ARGS(SkPictureImageFilter, (picture, cropRect, uniqueID));
commit-bot@chromium.orgcac5fd52014-03-10 10:51:58 +000029 }
senorblanco@chromium.org53333002013-12-12 23:28:52 +000030
31 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkPictureImageFilter)
32
33protected:
senorblanco5e5f9482014-08-26 12:27:12 -070034 explicit SkPictureImageFilter(const SkPicture* picture, uint32_t uniqueID);
35 SkPictureImageFilter(const SkPicture* picture, const SkRect& cropRect, uint32_t uniqueID);
senorblanco@chromium.org53333002013-12-12 23:28:52 +000036 virtual ~SkPictureImageFilter();
commit-bot@chromium.org5e0995e2014-02-07 12:20:04 +000037 /* Constructs an SkPictureImageFilter object from an SkReadBuffer.
38 * Note: If the SkPictureImageFilter object construction requires bitmap
39 * decoding, the decoder must be set on the SkReadBuffer parameter by calling
40 * SkReadBuffer::setBitmapDecoder() before calling this constructor.
41 * @param SkReadBuffer Serialized picture data.
42 */
reed9fa60da2014-08-21 07:59:51 -070043#ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING
commit-bot@chromium.org5e0995e2014-02-07 12:20:04 +000044 explicit SkPictureImageFilter(SkReadBuffer&);
reed9fa60da2014-08-21 07:59:51 -070045#endif
commit-bot@chromium.org8b0e8ac2014-01-30 18:58:24 +000046 virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE;
senorblanco@chromium.org4cb543d2014-03-14 15:44:01 +000047 virtual bool onFilterImage(Proxy*, const SkBitmap& src, const Context&,
commit-bot@chromium.orgae761f72014-02-05 22:32:02 +000048 SkBitmap* result, SkIPoint* offset) const SK_OVERRIDE;
senorblanco@chromium.org910702b2014-05-30 20:36:15 +000049 virtual bool onFilterBounds(const SkIRect& src, const SkMatrix&,
50 SkIRect* dst) const SK_OVERRIDE;
senorblanco@chromium.org53333002013-12-12 23:28:52 +000051
52private:
robertphillipse8464992014-07-14 07:53:26 -070053 const SkPicture* fPicture;
54 SkRect fCropRect;
senorblanco@chromium.org53333002013-12-12 23:28:52 +000055 typedef SkImageFilter INHERITED;
56};
57
58#endif