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

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

Issue 787073003: Adding an option for pixelated rendering in SkPictureImageFilter (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: filter level Created 6 years 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
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 SkPictureImageFilter* Create(const SkPicture* picture, int32_t unique ID = 0) { 19 static SkPictureImageFilter* Create(const SkPicture* picture, int32_t unique ID = 0) {
20 return SkNEW_ARGS(SkPictureImageFilter, (picture, uniqueID)); 20 return SkNEW_ARGS(SkPictureImageFilter, (picture, uniqueID));
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 SkPictureImageFilter* Create(const SkPicture* picture, const SkRect& cropRect, 27 static SkPictureImageFilter* Create(const SkPicture* picture, const SkRect& cropRect,
28 uint32_t uniqueID = 0) { 28 uint32_t uniqueID = 0) {
29 return SkNEW_ARGS(SkPictureImageFilter, (picture, cropRect, uniqueID, 29 return SkNEW_ARGS(SkPictureImageFilter, (picture, cropRect, uniqueID,
30 kDeviceSpace_PictureResolution) ); 30 kDeviceSpace_PictureResolution,
31 SkPaint::kLow_FilterLevel));
31 } 32 }
32 33
33 /** 34 /**
34 * Refs the passed-in picture. The picture is rasterized at a resolution th at matches the 35 * Refs the passed-in picture. The picture is rasterized at a resolution th at matches the
35 * local coordinate space. If the picture needs to be resampled for drawing it into the 36 * local coordinate space. If the picture needs to be resampled for drawing it into the
36 * destination canvas, bilinear filtering will be used. cropRect can be use d to crop or 37 * destination canvas, bilinear filtering will be used. cropRect can be use d to crop or
37 * expand the destination rect when the picture is drawn. (No scaling is im plied by the 38 * expand the destination rect when the picture is drawn. (No scaling is im plied by the
38 * dest rect; only the CTM is applied.) 39 * dest rect; only the CTM is applied.)
39 */ 40 */
40 static SkPictureImageFilter* CreateForLocalSpace(const SkPicture* picture, 41 static SkPictureImageFilter* CreateForLocalSpace(const SkPicture* picture,
41 const SkRect& cropRect, 42 const SkRect& cropRect,
43 SkPaint::FilterLevel filter Level,
42 uint32_t uniqueID = 0) { 44 uint32_t uniqueID = 0) {
43 return SkNEW_ARGS(SkPictureImageFilter, (picture, cropRect, uniqueID, 45 return SkNEW_ARGS(SkPictureImageFilter, (picture, cropRect, uniqueID,
44 kLocalSpace_PictureResolution)) ; 46 kLocalSpace_PictureResolution, filterLevel));
45 } 47 }
46 48
47 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkPictureImageFilter) 49 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkPictureImageFilter)
48 50
49 protected: 51 protected:
50 enum PictureResolution { 52 enum PictureResolution {
51 kDeviceSpace_PictureResolution, 53 kDeviceSpace_PictureResolution,
52 kLocalSpace_PictureResolution 54 kLocalSpace_PictureResolution
53 }; 55 };
54 56
55 explicit SkPictureImageFilter(const SkPicture* picture, uint32_t uniqueID); 57 explicit SkPictureImageFilter(const SkPicture* picture, uint32_t uniqueID);
56 SkPictureImageFilter(const SkPicture* picture, const SkRect& cropRect, uint3 2_t uniqueID, 58 SkPictureImageFilter(const SkPicture* picture, const SkRect& cropRect, uint3 2_t uniqueID,
57 PictureResolution); 59 PictureResolution, SkPaint::FilterLevel);
58 virtual ~SkPictureImageFilter(); 60 virtual ~SkPictureImageFilter();
59 /* Constructs an SkPictureImageFilter object from an SkReadBuffer. 61 /* Constructs an SkPictureImageFilter object from an SkReadBuffer.
60 * Note: If the SkPictureImageFilter object construction requires bitmap 62 * Note: If the SkPictureImageFilter object construction requires bitmap
61 * decoding, the decoder must be set on the SkReadBuffer parameter by calli ng 63 * decoding, the decoder must be set on the SkReadBuffer parameter by calli ng
62 * SkReadBuffer::setBitmapDecoder() before calling this constructor. 64 * SkReadBuffer::setBitmapDecoder() before calling this constructor.
63 * @param SkReadBuffer Serialized picture data. 65 * @param SkReadBuffer Serialized picture data.
64 */ 66 */
65 virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE; 67 virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE;
66 virtual bool onFilterImage(Proxy*, const SkBitmap& src, const Context&, 68 virtual bool onFilterImage(Proxy*, const SkBitmap& src, const Context&,
67 SkBitmap* result, SkIPoint* offset) const SK_OVER RIDE; 69 SkBitmap* result, SkIPoint* offset) const SK_OVER RIDE;
68 70
69 private: 71 private:
70 72
71 73
72 void drawPictureAtDeviceResolution(Proxy*, SkBaseDevice*, const SkIRect& dev iceBounds, 74 void drawPictureAtDeviceResolution(Proxy*, SkBaseDevice*, const SkIRect& dev iceBounds,
73 const Context&) const; 75 const Context&) const;
74 void drawPictureAtLocalResolution(Proxy*, SkBaseDevice*, const SkIRect& devi ceBounds, 76 void drawPictureAtLocalResolution(Proxy*, SkBaseDevice*, const SkIRect& devi ceBounds,
75 const Context&) const; 77 const Context&) const;
76 78
77 const SkPicture* fPicture; 79 const SkPicture* fPicture;
78 SkRect fCropRect; 80 SkRect fCropRect;
79 PictureResolution fPictureResolution; 81 PictureResolution fPictureResolution;
82 SkPaint::FilterLevel fFilterLevel;
80 typedef SkImageFilter INHERITED; 83 typedef SkImageFilter INHERITED;
81 }; 84 };
82 85
83 #endif 86 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698