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

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

Issue 1497083005: Revert of Matrix convolution bounds fix; affectsTransparentBlack fixes. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 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/matrixconvolution.cpp ('k') | include/effects/SkColorFilterImageFilter.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
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after
192 // DEPRECATED : use isColorFilterNode() instead 192 // DEPRECATED : use isColorFilterNode() instead
193 bool asColorFilter(SkColorFilter** filterPtr) const { 193 bool asColorFilter(SkColorFilter** filterPtr) const {
194 return this->isColorFilterNode(filterPtr); 194 return this->isColorFilterNode(filterPtr);
195 } 195 }
196 196
197 /** 197 /**
198 * Returns true (and optionally returns a ref'd filter) if this imagefilter can be completely 198 * Returns true (and optionally returns a ref'd filter) if this imagefilter can be completely
199 * replaced by the returned colorfilter. i.e. the two effects will affect d rawing in the 199 * replaced by the returned colorfilter. i.e. the two effects will affect d rawing in the
200 * same way. 200 * same way.
201 */ 201 */
202 bool asAColorFilter(SkColorFilter** filterPtr) const; 202 bool asAColorFilter(SkColorFilter** filterPtr) const {
203 return this->countInputs() > 0 &&
204 NULL == this->getInput(0) &&
205 !this->affectsTransparentBlack() &&
206 this->isColorFilterNode(filterPtr);
207 }
203 208
204 /** 209 /**
205 * Returns the number of inputs this filter will accept (some inputs can 210 * Returns the number of inputs this filter will accept (some inputs can
206 * be NULL). 211 * be NULL).
207 */ 212 */
208 int countInputs() const { return fInputCount; } 213 int countInputs() const { return fInputCount; }
209 214
210 /** 215 /**
211 * Returns the input filter at a given index, or NULL if no input is 216 * Returns the input filter at a given index, or NULL if no input is
212 * connected. The indices used are filter-specific. 217 * connected. The indices used are filter-specific.
(...skipping 15 matching lines...) Expand all
228 * drawn in the correct location.) 233 * drawn in the correct location.)
229 */ 234 */
230 bool cropRectIsSet() const { return fCropRect.flags() != 0x0; } 235 bool cropRectIsSet() const { return fCropRect.flags() != 0x0; }
231 236
232 CropRect getCropRect() const { return fCropRect; } 237 CropRect getCropRect() const { return fCropRect; }
233 238
234 // Default impl returns union of all input bounds. 239 // Default impl returns union of all input bounds.
235 virtual void computeFastBounds(const SkRect&, SkRect*) const; 240 virtual void computeFastBounds(const SkRect&, SkRect*) const;
236 241
237 // Can this filter DAG compute the resulting bounds of an object-space recta ngle? 242 // Can this filter DAG compute the resulting bounds of an object-space recta ngle?
238 virtual bool canComputeFastBounds() const; 243 bool canComputeFastBounds() const;
239 244
240 /** 245 /**
241 * If this filter can be represented by another filter + a localMatrix, ret urn that filter, 246 * If this filter can be represented by another filter + a localMatrix, ret urn that filter,
242 * else return null. 247 * else return null.
243 */ 248 */
244 SkImageFilter* newWithLocalMatrix(const SkMatrix& matrix) const; 249 SkImageFilter* newWithLocalMatrix(const SkMatrix& matrix) const;
245 250
246 /** 251 /**
247 * Create an SkMatrixImageFilter, which transforms its input by the given ma trix. 252 * Create an SkMatrixImageFilter, which transforms its input by the given ma trix.
248 */ 253 */
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
398 * 403 *
399 * The effect can assume its vertexCoords space maps 1-to-1 with texels 404 * The effect can assume its vertexCoords space maps 1-to-1 with texels
400 * in the texture. "matrix" is a transformation to apply to filter 405 * in the texture. "matrix" is a transformation to apply to filter
401 * parameters before they are used in the effect. Note that this function 406 * parameters before they are used in the effect. Note that this function
402 * will be called with (NULL, NULL, SkMatrix::I()) to query for support, 407 * will be called with (NULL, NULL, SkMatrix::I()) to query for support,
403 * so returning "true" indicates support for all possible matrices. 408 * so returning "true" indicates support for all possible matrices.
404 */ 409 */
405 virtual bool asFragmentProcessor(GrFragmentProcessor**, GrTexture*, const Sk Matrix&, 410 virtual bool asFragmentProcessor(GrFragmentProcessor**, GrTexture*, const Sk Matrix&,
406 const SkIRect& bounds) const; 411 const SkIRect& bounds) const;
407 412
413 /**
414 * Returns true if this filter can cause transparent black pixels to become
415 * visible (ie., alpha > 0). The default implementation returns false. This
416 * function is non-recursive, i.e., only queries this filter and not its
417 * inputs.
418 */
419 virtual bool affectsTransparentBlack() const;
420
408 private: 421 private:
409 friend class SkGraphics; 422 friend class SkGraphics;
410 static void PurgeCache(); 423 static void PurgeCache();
411 424
412 bool usesSrcInput() const { return fUsesSrcInput; } 425 bool usesSrcInput() const { return fUsesSrcInput; }
413 426
414 typedef SkFlattenable INHERITED; 427 typedef SkFlattenable INHERITED;
415 int fInputCount; 428 int fInputCount;
416 SkImageFilter** fInputs; 429 SkImageFilter** fInputs;
417 bool fUsesSrcInput; 430 bool fUsesSrcInput;
418 CropRect fCropRect; 431 CropRect fCropRect;
419 uint32_t fUniqueID; // Globally unique 432 uint32_t fUniqueID; // Globally unique
420 }; 433 };
421 434
422 /** 435 /**
423 * Helper to unflatten the common data, and return NULL if we fail. 436 * Helper to unflatten the common data, and return NULL if we fail.
424 */ 437 */
425 #define SK_IMAGEFILTER_UNFLATTEN_COMMON(localVar, expectedCount) \ 438 #define SK_IMAGEFILTER_UNFLATTEN_COMMON(localVar, expectedCount) \
426 Common localVar; \ 439 Common localVar; \
427 do { \ 440 do { \
428 if (!localVar.unflatten(buffer, expectedCount)) { \ 441 if (!localVar.unflatten(buffer, expectedCount)) { \
429 return NULL; \ 442 return NULL; \
430 } \ 443 } \
431 } while (0) 444 } while (0)
432 445
433 #endif 446 #endif
OLDNEW
« no previous file with comments | « gm/matrixconvolution.cpp ('k') | include/effects/SkColorFilterImageFilter.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698