| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2008 The Android Open Source Project | 2 * Copyright 2008 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 #include "SkBitmapDevice.h" | 8 #include "SkBitmapDevice.h" |
| 9 #include "SkCanvas.h" | 9 #include "SkCanvas.h" |
| 10 #include "SkCanvasPriv.h" | 10 #include "SkCanvasPriv.h" |
| (...skipping 394 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 405 // there is no existing paint colorfilter, so we can just return the ima
gefilter's | 405 // there is no existing paint colorfilter, so we can just return the ima
gefilter's |
| 406 return imgCF; | 406 return imgCF; |
| 407 } | 407 } |
| 408 | 408 |
| 409 // The paint has both a colorfilter(paintCF) and an imagefilter-which-is-a-c
olorfilter(imgCF) | 409 // The paint has both a colorfilter(paintCF) and an imagefilter-which-is-a-c
olorfilter(imgCF) |
| 410 // and we need to combine them into a single colorfilter. | 410 // and we need to combine them into a single colorfilter. |
| 411 SkAutoTUnref<SkColorFilter> autoImgCF(imgCF); | 411 SkAutoTUnref<SkColorFilter> autoImgCF(imgCF); |
| 412 return SkColorFilter::CreateComposeFilter(imgCF, paintCF); | 412 return SkColorFilter::CreateComposeFilter(imgCF, paintCF); |
| 413 } | 413 } |
| 414 | 414 |
| 415 #ifndef SK_SAVE_LAYER_BOUNDS_ARE_FILTERED |
| 415 /** | 416 /** |
| 416 * There are many bounds in skia. A circle's bounds is just its center extended
by its radius. | 417 * There are many bounds in skia. A circle's bounds is just its center extended
by its radius. |
| 417 * However, if we stroke a circle, then the "bounds" of that is larger, since it
will now draw | 418 * However, if we stroke a circle, then the "bounds" of that is larger, since it
will now draw |
| 418 * outside of its raw-bounds by 1/2 the stroke width. SkPaint has lots of optio
nal | 419 * outside of its raw-bounds by 1/2 the stroke width. SkPaint has lots of optio
nal |
| 419 * effects/attributes that can modify the effective bounds of a given primitive
-- maskfilters, | 420 * effects/attributes that can modify the effective bounds of a given primitive
-- maskfilters, |
| 420 * patheffects, stroking, etc. This function takes a raw bounds and a paint, an
d returns the | 421 * patheffects, stroking, etc. This function takes a raw bounds and a paint, an
d returns the |
| 421 * conservative "effective" bounds based on the settings in the paint... with on
e exception. This | 422 * conservative "effective" bounds based on the settings in the paint... with on
e exception. This |
| 422 * function does *not* look at the imagefilter, which can also modify the effect
ive bounds. It is | 423 * function does *not* look at the imagefilter, which can also modify the effect
ive bounds. It is |
| 423 * deliberately ignored. | 424 * deliberately ignored. |
| 424 */ | 425 */ |
| 425 static const SkRect& apply_paint_to_bounds_sans_imagefilter(const SkPaint& paint
, | 426 static const SkRect& apply_paint_to_bounds_sans_imagefilter(const SkPaint& paint
, |
| 426 const SkRect& rawBou
nds, | 427 const SkRect& rawBou
nds, |
| 427 SkRect* storage) { | 428 SkRect* storage) { |
| 428 SkPaint tmpUnfiltered(paint); | 429 SkPaint tmpUnfiltered(paint); |
| 429 tmpUnfiltered.setImageFilter(nullptr); | 430 tmpUnfiltered.setImageFilter(nullptr); |
| 430 if (tmpUnfiltered.canComputeFastBounds()) { | 431 if (tmpUnfiltered.canComputeFastBounds()) { |
| 431 return tmpUnfiltered.computeFastBounds(rawBounds, storage); | 432 return tmpUnfiltered.computeFastBounds(rawBounds, storage); |
| 432 } else { | 433 } else { |
| 433 return rawBounds; | 434 return rawBounds; |
| 434 } | 435 } |
| 435 } | 436 } |
| 437 #endif |
| 436 | 438 |
| 437 class AutoDrawLooper { | 439 class AutoDrawLooper { |
| 438 public: | 440 public: |
| 439 // "rawBounds" is the original bounds of the primitive about to be drawn, un
modified by the | 441 // "rawBounds" is the original bounds of the primitive about to be drawn, un
modified by the |
| 440 // paint. It's used to determine the size of the offscreen layer for filters
. | 442 // paint. It's used to determine the size of the offscreen layer for filters
. |
| 441 // If null, the clip will be used instead. | 443 // If null, the clip will be used instead. |
| 442 AutoDrawLooper(SkCanvas* canvas, const SkSurfaceProps& props, const SkPaint&
paint, | 444 AutoDrawLooper(SkCanvas* canvas, const SkSurfaceProps& props, const SkPaint&
paint, |
| 443 bool skipLayerForImageFilter = false, | 445 bool skipLayerForImageFilter = false, |
| 444 const SkRect* rawBounds = nullptr) : fOrigPaint(paint) { | 446 const SkRect* rawBounds = nullptr) : fOrigPaint(paint) { |
| 445 fCanvas = canvas; | 447 fCanvas = canvas; |
| (...skipping 2581 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3027 } | 3029 } |
| 3028 | 3030 |
| 3029 if (matrix) { | 3031 if (matrix) { |
| 3030 canvas->concat(*matrix); | 3032 canvas->concat(*matrix); |
| 3031 } | 3033 } |
| 3032 } | 3034 } |
| 3033 | 3035 |
| 3034 SkAutoCanvasMatrixPaint::~SkAutoCanvasMatrixPaint() { | 3036 SkAutoCanvasMatrixPaint::~SkAutoCanvasMatrixPaint() { |
| 3035 fCanvas->restoreToCount(fSaveCount); | 3037 fCanvas->restoreToCount(fSaveCount); |
| 3036 } | 3038 } |
| OLD | NEW |