• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
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 "SkFlattenable.h"
12 #include "SkImageFilter.h"
13 #include "SkPicture.h"
14 
15 class SK_API SkPictureImageFilter : public SkImageFilter {
16 public:
17     /**
18      *  Refs the passed-in picture.
19      */
20     static sk_sp<SkImageFilter> Make(sk_sp<SkPicture> picture);
21 
22     /**
23      *  Refs the passed-in picture. cropRect can be used to crop or expand the destination rect when
24      *  the picture is drawn. (No scaling is implied by the dest rect; only the CTM is applied.)
25      */
26     static sk_sp<SkImageFilter> Make(sk_sp<SkPicture> picture, const SkRect& cropRect);
27 
28 
29 protected:
30     /*  Constructs an SkPictureImageFilter object from an SkReadBuffer.
31      *  Note: If the SkPictureImageFilter object construction requires bitmap
32      *  decoding, the decoder must be set on the SkReadBuffer parameter by calling
33      *  SkReadBuffer::setBitmapDecoder() before calling this constructor.
34      *  @param SkReadBuffer Serialized picture data.
35      */
36     void flatten(SkWriteBuffer&) const override;
37     sk_sp<SkSpecialImage> onFilterImage(SkSpecialImage* source, const Context&,
38                                         SkIPoint* offset) const override;
39     sk_sp<SkImageFilter> onMakeColorSpace(SkColorSpaceXformer*) const override;
40 
41 private:
42     SK_FLATTENABLE_HOOKS(SkPictureImageFilter)
43 
44     explicit SkPictureImageFilter(sk_sp<SkPicture> picture);
45     SkPictureImageFilter(sk_sp<SkPicture> picture, const SkRect& cropRect, sk_sp<SkColorSpace>);
46 
47     sk_sp<SkPicture>    fPicture;
48     SkRect              fCropRect;
49 
50     // Should never be set by a public constructor.  This is only used when onMakeColorSpace()
51     // forces a deferred color space xform.
52     sk_sp<SkColorSpace>   fColorSpace;
53 
54     typedef SkImageFilter INHERITED;
55 };
56 
57 #endif
58