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

Side by Side Diff: include/effects/SkPictureImageFilter.h

Issue 1389063002: Revert of factories should return baseclass, allowing the impl to specialize (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 2 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 unified diff | Download patch
« no previous file with comments | « include/effects/SkOffsetImageFilter.h ('k') | include/effects/SkPixelXorXfermode.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2013 The Android Open Source Project 2 * Copyright 2013 The Android Open Source Project
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #ifndef SkPictureImageFilter_DEFINED 8 #ifndef SkPictureImageFilter_DEFINED
9 #define SkPictureImageFilter_DEFINED 9 #define SkPictureImageFilter_DEFINED
10 10
11 #include "SkImageFilter.h" 11 #include "SkImageFilter.h"
12 #include "SkPicture.h" 12 #include "SkPicture.h"
13 13
14 class SK_API SkPictureImageFilter : public SkImageFilter { 14 class SK_API SkPictureImageFilter : public SkImageFilter {
15 public: 15 public:
16 /** 16 /**
17 * Refs the passed-in picture. 17 * Refs the passed-in picture.
18 */ 18 */
19 static SkImageFilter* Create(const SkPicture* picture) { 19 static SkPictureImageFilter* Create(const SkPicture* picture) {
20 return new SkPictureImageFilter(picture); 20 return new SkPictureImageFilter(picture);
21 } 21 }
22 22
23 /** 23 /**
24 * Refs the passed-in picture. cropRect can be used to crop or expand the d estination rect when 24 * Refs the passed-in picture. cropRect can be used to crop or expand the d estination rect when
25 * the picture is drawn. (No scaling is implied by the dest rect; only the CTM is applied.) 25 * the picture is drawn. (No scaling is implied by the dest rect; only the CTM is applied.)
26 */ 26 */
27 static SkImageFilter* Create(const SkPicture* picture, const SkRect& cropRec t) { 27 static SkPictureImageFilter* Create(const SkPicture* picture, const SkRect& cropRect) {
28 return new SkPictureImageFilter(picture, cropRect, kDeviceSpace_PictureR esolution, 28 return new SkPictureImageFilter(picture, cropRect, kDeviceSpace_PictureR esolution,
29 kLow_SkFilterQuality); 29 kLow_SkFilterQuality);
30 } 30 }
31 31
32 /** 32 /**
33 * Refs the passed-in picture. The picture is rasterized at a resolution th at matches the 33 * Refs the passed-in picture. The picture is rasterized at a resolution th at matches the
34 * local coordinate space. If the picture needs to be resampled for drawing it into the 34 * local coordinate space. If the picture needs to be resampled for drawing it into the
35 * destination canvas, bilinear filtering will be used. cropRect can be use d to crop or 35 * destination canvas, bilinear filtering will be used. cropRect can be use d to crop or
36 * expand the destination rect when the picture is drawn. (No scaling is im plied by the 36 * expand the destination rect when the picture is drawn. (No scaling is im plied by the
37 * dest rect; only the CTM is applied.) 37 * dest rect; only the CTM is applied.)
38 */ 38 */
39 static SkImageFilter* CreateForLocalSpace(const SkPicture* picture, 39 static SkPictureImageFilter* CreateForLocalSpace(const SkPicture* picture,
40 const SkRect& cropRect, 40 const SkRect& cropRect,
41 SkFilterQuality filterQuali ty) { 41 SkFilterQuality filterQuali ty) {
42 return new SkPictureImageFilter(picture, cropRect, kLocalSpace_PictureRe solution, 42 return new SkPictureImageFilter(picture, cropRect, kLocalSpace_PictureRe solution,
43 filterQuality); 43 filterQuality);
44 } 44 }
45
46 SK_TO_STRING_OVERRIDE() 45 SK_TO_STRING_OVERRIDE()
47 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkPictureImageFilter) 46 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkPictureImageFilter)
48 47
49 protected: 48 protected:
50 enum PictureResolution { 49 enum PictureResolution {
51 kDeviceSpace_PictureResolution, 50 kDeviceSpace_PictureResolution,
52 kLocalSpace_PictureResolution 51 kLocalSpace_PictureResolution
53 }; 52 };
54 53
54 explicit SkPictureImageFilter(const SkPicture* picture);
55 SkPictureImageFilter(const SkPicture* picture, const SkRect& cropRect,
56 PictureResolution, SkFilterQuality);
55 virtual ~SkPictureImageFilter(); 57 virtual ~SkPictureImageFilter();
56
57 /* Constructs an SkPictureImageFilter object from an SkReadBuffer. 58 /* Constructs an SkPictureImageFilter object from an SkReadBuffer.
58 * Note: If the SkPictureImageFilter object construction requires bitmap 59 * Note: If the SkPictureImageFilter object construction requires bitmap
59 * decoding, the decoder must be set on the SkReadBuffer parameter by calli ng 60 * decoding, the decoder must be set on the SkReadBuffer parameter by calli ng
60 * SkReadBuffer::setBitmapDecoder() before calling this constructor. 61 * SkReadBuffer::setBitmapDecoder() before calling this constructor.
61 * @param SkReadBuffer Serialized picture data. 62 * @param SkReadBuffer Serialized picture data.
62 */ 63 */
63 void flatten(SkWriteBuffer&) const override; 64 void flatten(SkWriteBuffer&) const override;
64 bool onFilterImage(Proxy*, const SkBitmap& src, const Context&, SkBitmap* re sult, 65 virtual bool onFilterImage(Proxy*, const SkBitmap& src, const Context&,
65 SkIPoint* offset) const override; 66 SkBitmap* result, SkIPoint* offset) const overrid e;
66 67
67 private: 68 private:
68 explicit SkPictureImageFilter(const SkPicture* picture); 69
69 SkPictureImageFilter(const SkPicture* picture, const SkRect& cropRect,
70 PictureResolution, SkFilterQuality);
71 70
72 void drawPictureAtDeviceResolution(SkBaseDevice*, const SkIRect& deviceBound s, 71 void drawPictureAtDeviceResolution(SkBaseDevice*, const SkIRect& deviceBound s,
73 const Context&) const; 72 const Context&) const;
74 void drawPictureAtLocalResolution(Proxy*, SkBaseDevice*, const SkIRect& devi ceBounds, 73 void drawPictureAtLocalResolution(Proxy*, SkBaseDevice*, const SkIRect& devi ceBounds,
75 const Context&) const; 74 const Context&) const;
76 75
77 const SkPicture* fPicture; 76 const SkPicture* fPicture;
78 SkRect fCropRect; 77 SkRect fCropRect;
79 PictureResolution fPictureResolution; 78 PictureResolution fPictureResolution;
80 SkFilterQuality fFilterQuality; 79 SkFilterQuality fFilterQuality;
81
82 typedef SkImageFilter INHERITED; 80 typedef SkImageFilter INHERITED;
83 }; 81 };
84 82
85 #endif 83 #endif
OLDNEW
« no previous file with comments | « include/effects/SkOffsetImageFilter.h ('k') | include/effects/SkPixelXorXfermode.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698