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

Side by Side Diff: include/core/SkImageFilter.h

Issue 19775006: Implement crop rect for SkImageFilter (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Fix comments Created 7 years, 4 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 | Annotate | Revision Log
« no previous file with comments | « gyp/tests.gyp ('k') | include/core/SkRect.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 2011 Google Inc. 2 * Copyright 2011 Google Inc.
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 SkImageFilter_DEFINED 8 #ifndef SkImageFilter_DEFINED
9 #define SkImageFilter_DEFINED 9 #define SkImageFilter_DEFINED
10 10
11 #include "SkFlattenable.h" 11 #include "SkFlattenable.h"
12 #include "SkRect.h"
12 13
13 class SkBitmap; 14 class SkBitmap;
14 class SkColorFilter; 15 class SkColorFilter;
15 class SkDevice; 16 class SkDevice;
16 class SkMatrix; 17 class SkMatrix;
17 struct SkIPoint; 18 struct SkIPoint;
18 struct SkIRect;
19 class SkShader; 19 class SkShader;
20 class GrEffectRef; 20 class GrEffectRef;
21 class GrTexture; 21 class GrTexture;
22 22
23 /** 23 /**
24 * Experimental. 24 * Experimental.
25 * 25 *
26 * Base class for image filters. If one is installed in the paint, then 26 * Base class for image filters. If one is installed in the paint, then
27 * all drawing occurs as usual, but it is as if the drawing happened into an 27 * all drawing occurs as usual, but it is as if the drawing happened into an
28 * offscreen (before the xfermode is applied). This offscreen bitmap will 28 * offscreen (before the xfermode is applied). This offscreen bitmap will
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
132 132
133 /** 133 /**
134 * Returns the input filter at a given index, or NULL if no input is 134 * Returns the input filter at a given index, or NULL if no input is
135 * connected. The indices used are filter-specific. 135 * connected. The indices used are filter-specific.
136 */ 136 */
137 SkImageFilter* getInput(int i) const { 137 SkImageFilter* getInput(int i) const {
138 SkASSERT(i < fInputCount); 138 SkASSERT(i < fInputCount);
139 return fInputs[i]; 139 return fInputs[i];
140 } 140 }
141 141
142 /**
143 * Returns the crop rectangle of this filter. This is set at construction
144 * time, and determines which pixels from the input image will
145 * be processed. The size of this rectangle should be used as the size
146 * of the destination image. The origin of this rect should be used to
147 * offset access to the input images, and should also be added to the
148 * "offset" parameter in onFilterImage and filterImageGPU(). (The latter
149 * ensures that the resulting buffer is drawn in the correct location.)
150 */
151 const SkIRect& cropRect() const { return fCropRect; }
152
142 protected: 153 protected:
143 SkImageFilter(int inputCount, SkImageFilter** inputs); 154 SkImageFilter(int inputCount, SkImageFilter** inputs, const SkIRect* cropRec t = NULL);
144 155
145 // Convenience constructor for 1-input filters. 156 // Convenience constructor for 1-input filters.
146 explicit SkImageFilter(SkImageFilter* input); 157 explicit SkImageFilter(SkImageFilter* input, const SkIRect* cropRect = NULL) ;
147 158
148 // Convenience constructor for 2-input filters. 159 // Convenience constructor for 2-input filters.
149 SkImageFilter(SkImageFilter* input1, SkImageFilter* input2); 160 SkImageFilter(SkImageFilter* input1, SkImageFilter* input2, const SkIRect* c ropRect = NULL);
150 161
151 virtual ~SkImageFilter(); 162 virtual ~SkImageFilter();
152 163
153 explicit SkImageFilter(SkFlattenableReadBuffer& rb); 164 explicit SkImageFilter(SkFlattenableReadBuffer& rb);
154 165
155 virtual void flatten(SkFlattenableWriteBuffer& wb) const SK_OVERRIDE; 166 virtual void flatten(SkFlattenableWriteBuffer& wb) const SK_OVERRIDE;
156 167
157 // Default impl returns false 168 // Default impl returns false
158 virtual bool onFilterImage(Proxy*, const SkBitmap& src, const SkMatrix&, 169 virtual bool onFilterImage(Proxy*, const SkBitmap& src, const SkMatrix&,
159 SkBitmap* result, SkIPoint* offset); 170 SkBitmap* result, SkIPoint* offset);
160 // Default impl copies src into dst and returns true 171 // Default impl copies src into dst and returns true
161 virtual bool onFilterBounds(const SkIRect&, const SkMatrix&, SkIRect*); 172 virtual bool onFilterBounds(const SkIRect&, const SkMatrix&, SkIRect*);
162 173
174 // Sets rect to the intersection of rect and the crop rect. If there
175 // is no overlap, returns false and leaves rect unchanged.
176 bool applyCropRect(SkIRect* rect) const;
177
163 private: 178 private:
164 typedef SkFlattenable INHERITED; 179 typedef SkFlattenable INHERITED;
165 int fInputCount; 180 int fInputCount;
166 SkImageFilter** fInputs; 181 SkImageFilter** fInputs;
182 SkIRect fCropRect;
167 }; 183 };
168 184
169 #endif 185 #endif
OLDNEW
« no previous file with comments | « gyp/tests.gyp ('k') | include/core/SkRect.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698