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

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: 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
« no previous file with comments | « gm/pictureimagefilter.cpp ('k') | src/effects/SkPictureImageFilter.cpp » ('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 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_PictureMode));
31 } 31 }
32 32
33 /** 33 /**
34 * Refs the passed-in picture. The picture is rasterized at a resolution th at matches the 34 * 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 35 * 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 36 * destination canvas, bilinear filtering will be used. If pixelated is tru e, then
37 * nearest neighbor filtering is used instead. cropRect can be used 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,
42 uint32_t uniqueID = 0) { 43 uint32_t uniqueID = 0,
44 bool pixelated = false) {
Stephen White 2014/12/09 16:22:10 I think this should take a SkPaint::FilterLevel, r
43 return SkNEW_ARGS(SkPictureImageFilter, (picture, cropRect, uniqueID, 45 return SkNEW_ARGS(SkPictureImageFilter, (picture, cropRect, uniqueID,
44 kLocalSpace_PictureResolution)) ; 46 pixelated ? kLocalSpacePixelated_PictureMode : kLocalSpace_PictureMo de));
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 PictureMode {
51 kDeviceSpace_PictureResolution, 53 kDeviceSpace_PictureMode,
52 kLocalSpace_PictureResolution 54 kLocalSpace_PictureMode,
55 kLocalSpacePixelated_PictureMode
53 }; 56 };
54 57
55 explicit SkPictureImageFilter(const SkPicture* picture, uint32_t uniqueID); 58 explicit SkPictureImageFilter(const SkPicture* picture, uint32_t uniqueID);
56 SkPictureImageFilter(const SkPicture* picture, const SkRect& cropRect, uint3 2_t uniqueID, 59 SkPictureImageFilter(const SkPicture* picture, const SkRect& cropRect, uint3 2_t uniqueID,
57 PictureResolution); 60 PictureMode);
58 virtual ~SkPictureImageFilter(); 61 virtual ~SkPictureImageFilter();
59 /* Constructs an SkPictureImageFilter object from an SkReadBuffer. 62 /* Constructs an SkPictureImageFilter object from an SkReadBuffer.
60 * Note: If the SkPictureImageFilter object construction requires bitmap 63 * Note: If the SkPictureImageFilter object construction requires bitmap
61 * decoding, the decoder must be set on the SkReadBuffer parameter by calli ng 64 * decoding, the decoder must be set on the SkReadBuffer parameter by calli ng
62 * SkReadBuffer::setBitmapDecoder() before calling this constructor. 65 * SkReadBuffer::setBitmapDecoder() before calling this constructor.
63 * @param SkReadBuffer Serialized picture data. 66 * @param SkReadBuffer Serialized picture data.
64 */ 67 */
65 virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE; 68 virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE;
66 virtual bool onFilterImage(Proxy*, const SkBitmap& src, const Context&, 69 virtual bool onFilterImage(Proxy*, const SkBitmap& src, const Context&,
67 SkBitmap* result, SkIPoint* offset) const SK_OVER RIDE; 70 SkBitmap* result, SkIPoint* offset) const SK_OVER RIDE;
68 71
69 private: 72 private:
70 73
71 74
72 void drawPictureAtDeviceResolution(Proxy*, SkBaseDevice*, const SkIRect& dev iceBounds, 75 void drawPictureAtDeviceResolution(Proxy*, SkBaseDevice*, const SkIRect& dev iceBounds,
73 const Context&) const; 76 const Context&) const;
74 void drawPictureAtLocalResolution(Proxy*, SkBaseDevice*, const SkIRect& devi ceBounds, 77 void drawPictureAtLocalResolution(Proxy*, SkBaseDevice*, const SkIRect& devi ceBounds,
75 const Context&) const; 78 const Context&) const;
76 79
77 const SkPicture* fPicture; 80 const SkPicture* fPicture;
78 SkRect fCropRect; 81 SkRect fCropRect;
79 PictureResolution fPictureResolution; 82 PictureMode fPictureMode;
80 typedef SkImageFilter INHERITED; 83 typedef SkImageFilter INHERITED;
81 }; 84 };
82 85
83 #endif 86 #endif
OLDNEW
« no previous file with comments | « gm/pictureimagefilter.cpp ('k') | src/effects/SkPictureImageFilter.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698