OLD | NEW |
---|---|
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 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
157 kReverse_MapDirection | 157 kReverse_MapDirection |
158 }; | 158 }; |
159 /** | 159 /** |
160 * Map a device-space rect recursively forward or backward through the | 160 * Map a device-space rect recursively forward or backward through the |
161 * filter DAG. kForward_MapDirection is used to determine which pixels of | 161 * filter DAG. kForward_MapDirection is used to determine which pixels of |
162 * the destination canvas a source image rect would touch after filtering. | 162 * the destination canvas a source image rect would touch after filtering. |
163 * kReverse_MapDirection is used to determine which rect of the source | 163 * kReverse_MapDirection is used to determine which rect of the source |
164 * image would be required to fill the given rect (typically, clip bounds). | 164 * image would be required to fill the given rect (typically, clip bounds). |
165 * Used for clipping and temp-buffer allocations, so the result need not | 165 * Used for clipping and temp-buffer allocations, so the result need not |
166 * be exact, but should never be smaller than the real answer. The default | 166 * be exact, but should never be smaller than the real answer. The default |
167 * implementation recursively unions all input bounds, or returns false if | 167 * implementation recursively unions all input bounds, or returns the |
168 * no inputs. | 168 * source rect if no inputs. |
169 */ | 169 */ |
170 SkIRect filterBounds(const SkIRect& src, const SkMatrix& ctm, | |
171 MapDirection = kReverse_MapDirection) const; | |
172 | |
173 #ifdef SK_SUPPORT_LEGACY_FILTERBOUNDS_RETURN | |
174 /* DEPRECATED */ | |
170 bool filterBounds(const SkIRect& src, const SkMatrix& ctm, SkIRect* dst, | 175 bool filterBounds(const SkIRect& src, const SkMatrix& ctm, SkIRect* dst, |
171 MapDirection = kReverse_MapDirection) const; | 176 MapDirection = kReverse_MapDirection) const; |
177 #endif | |
172 | 178 |
173 /** | 179 /** |
174 * Returns true if the filter can be processed on the GPU. This is most | 180 * Returns true if the filter can be processed on the GPU. This is most |
175 * often used for multi-pass effects, where intermediate results must be | 181 * often used for multi-pass effects, where intermediate results must be |
176 * rendered to textures. For single-pass effects, use asFragmentProcessor( ). | 182 * rendered to textures. For single-pass effects, use asFragmentProcessor( ). |
177 * The default implementation returns asFragmentProcessor(NULL, NULL, SkMat rix::I(), | 183 * The default implementation returns asFragmentProcessor(NULL, NULL, SkMat rix::I(), |
178 * SkIRect()). | 184 * SkIRect()). |
179 */ | 185 */ |
180 virtual bool canFilterImageGPU() const; | 186 virtual bool canFilterImageGPU() const; |
181 | 187 |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
239 * should be used to offset access to the input images, and should also | 245 * should be used to offset access to the input images, and should also |
240 * be added to the "offset" parameter in onFilterImage and | 246 * be added to the "offset" parameter in onFilterImage and |
241 * filterImageGPU(). (The latter ensures that the resulting buffer is | 247 * filterImageGPU(). (The latter ensures that the resulting buffer is |
242 * drawn in the correct location.) | 248 * drawn in the correct location.) |
243 */ | 249 */ |
244 bool cropRectIsSet() const { return fCropRect.flags() != 0x0; } | 250 bool cropRectIsSet() const { return fCropRect.flags() != 0x0; } |
245 | 251 |
246 CropRect getCropRect() const { return fCropRect; } | 252 CropRect getCropRect() const { return fCropRect; } |
247 | 253 |
248 // Default impl returns union of all input bounds. | 254 // Default impl returns union of all input bounds. |
249 virtual void computeFastBounds(const SkRect&, SkRect*) const; | 255 virtual SkRect computeFastBounds(const SkRect&) const; |
reed1
2016/03/21 20:44:32
hope nobody in chrome/blink called this
Stephen White
2016/03/21 20:47:03
Nope. I git grepped, and built Chrome to be sure.
| |
250 | 256 |
251 // Can this filter DAG compute the resulting bounds of an object-space recta ngle? | 257 // Can this filter DAG compute the resulting bounds of an object-space recta ngle? |
252 virtual bool canComputeFastBounds() const; | 258 virtual bool canComputeFastBounds() const; |
253 | 259 |
254 /** | 260 /** |
255 * If this filter can be represented by another filter + a localMatrix, ret urn that filter, | 261 * If this filter can be represented by another filter + a localMatrix, ret urn that filter, |
256 * else return null. | 262 * else return null. |
257 */ | 263 */ |
258 SkImageFilter* newWithLocalMatrix(const SkMatrix& matrix) const; | 264 SkImageFilter* newWithLocalMatrix(const SkMatrix& matrix) const; |
259 | 265 |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
351 * case both the result and offset parameters will be ignored by the | 357 * case both the result and offset parameters will be ignored by the |
352 * caller. | 358 * caller. |
353 */ | 359 */ |
354 virtual bool onFilterImageDeprecated(Proxy*, const SkBitmap& src, const Cont ext&, | 360 virtual bool onFilterImageDeprecated(Proxy*, const SkBitmap& src, const Cont ext&, |
355 SkBitmap* result, SkIPoint* offset) con st; | 361 SkBitmap* result, SkIPoint* offset) con st; |
356 | 362 |
357 virtual SkSpecialImage* onFilterImage(SkSpecialImage* src, const Context&, | 363 virtual SkSpecialImage* onFilterImage(SkSpecialImage* src, const Context&, |
358 SkIPoint* offset) const; | 364 SkIPoint* offset) const; |
359 | 365 |
360 /** | 366 /** |
361 * This function recurses into its inputs with the given clip rect (first | 367 * This function recurses into its inputs with the given rect (first |
362 * argument), calls filterBounds() with the given map direction on each, | 368 * argument), calls filterBounds() with the given map direction on each, |
363 * and unions the result (third argument). If the rect cannot be mapped, | 369 * and returns the union of those results. If a derived class has special |
364 * false is returned and the destination rect is left unchanged. | 370 * recursion requirements (e.g., it has an input which does not participate |
365 * If a derived class has special recursion requirements (e.g., it has an | 371 * in bounds computation), it can be overridden here. |
366 * input which does not participate in bounds computation), it can be | |
367 * overridden here. | |
368 * | 372 * |
369 * Note that this function is *not* responsible for mapping the rect for | 373 * Note that this function is *not* responsible for mapping the rect for |
370 * this node's filter bounds requirements (i.e., calling | 374 * this node's filter bounds requirements (i.e., calling |
371 * onFilterNodeBounds()); that is handled by filterBounds(). | 375 * onFilterNodeBounds()); that is handled by filterBounds(). |
372 */ | 376 */ |
373 virtual bool onFilterBounds(const SkIRect&, const SkMatrix&, SkIRect*, MapDi rection) const; | 377 virtual SkIRect onFilterBounds(const SkIRect&, const SkMatrix&, MapDirection ) const; |
374 | 378 |
375 /** | 379 /** |
376 * Performs a forwards or reverse mapping of the given rect to accommodate | 380 * Performs a forwards or reverse mapping of the given rect to accommodate |
377 * this filter's margin requirements. kForward_MapDirection is used to | 381 * this filter's margin requirements. kForward_MapDirection is used to |
378 * determine the destination pixels which would be touched by filtering | 382 * determine the destination pixels which would be touched by filtering |
379 * the given given source rect (e.g., given source bitmap bounds, | 383 * the given given source rect (e.g., given source bitmap bounds, |
380 * determine the optimal bounds of the filtered offscreen bitmap). | 384 * determine the optimal bounds of the filtered offscreen bitmap). |
381 * kReverse_MapDirection is used to determine which pixels of the | 385 * kReverse_MapDirection is used to determine which pixels of the |
382 * input(s) would be required to fill the given destination rect | 386 * input(s) would be required to fill the given destination rect |
383 * (e.g., clip bounds). NOTE: these operations may not be the | 387 * (e.g., clip bounds). NOTE: these operations may not be the |
384 * inverse of the other. For example, blurring expands the given rect | 388 * inverse of the other. For example, blurring expands the given rect |
385 * in both forward and reverse directions. Unlike | 389 * in both forward and reverse directions. Unlike |
386 * onFilterBounds(), this function is non-recursive. | 390 * onFilterBounds(), this function is non-recursive. |
387 */ | 391 */ |
388 virtual void onFilterNodeBounds(const SkIRect&, const SkMatrix&, SkIRect*, M apDirection) const; | 392 virtual SkIRect onFilterNodeBounds(const SkIRect&, const SkMatrix&, MapDirec tion) const; |
389 | 393 |
390 // Helper function which invokes filter processing on the input at the | 394 // Helper function which invokes filter processing on the input at the |
391 // specified "index". If the input is null, it leaves "result" and | 395 // specified "index". If the input is null, it leaves "result" and |
392 // "offset" untouched, and returns true. If the input is non-null, it | 396 // "offset" untouched, and returns true. If the input is non-null, it |
393 // calls filterImage() on that input, and returns true on success. | 397 // calls filterImage() on that input, and returns true on success. |
394 // i.e., return !getInput(index) || getInput(index)->filterImage(...); | 398 // i.e., return !getInput(index) || getInput(index)->filterImage(...); |
395 bool filterInputDeprecated(int index, Proxy*, const SkBitmap& src, const Con text&, | 399 bool filterInputDeprecated(int index, Proxy*, const SkBitmap& src, const Con text&, |
396 SkBitmap* result, SkIPoint* offset) const; | 400 SkBitmap* result, SkIPoint* offset) const; |
397 | 401 |
398 /** | 402 /** |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
479 */ | 483 */ |
480 #define SK_IMAGEFILTER_UNFLATTEN_COMMON(localVar, expectedCount) \ | 484 #define SK_IMAGEFILTER_UNFLATTEN_COMMON(localVar, expectedCount) \ |
481 Common localVar; \ | 485 Common localVar; \ |
482 do { \ | 486 do { \ |
483 if (!localVar.unflatten(buffer, expectedCount)) { \ | 487 if (!localVar.unflatten(buffer, expectedCount)) { \ |
484 return NULL; \ | 488 return NULL; \ |
485 } \ | 489 } \ |
486 } while (0) | 490 } while (0) |
487 | 491 |
488 #endif | 492 #endif |
OLD | NEW |