| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2012 The Android Open Source Project | 2 * Copyright 2012 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 "SkImageFilter.h" | 8 #include "SkImageFilter.h" |
| 9 | 9 |
| 10 #include "SkBitmap.h" | 10 #include "SkBitmap.h" |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 43 if (fFlags & CropRect::kHasLeft_CropEdge) { | 43 if (fFlags & CropRect::kHasLeft_CropEdge) { |
| 44 str->appendf("%.2f, ", fRect.fLeft); | 44 str->appendf("%.2f, ", fRect.fLeft); |
| 45 } else { | 45 } else { |
| 46 str->appendf("X, "); | 46 str->appendf("X, "); |
| 47 } | 47 } |
| 48 if (fFlags & CropRect::kHasTop_CropEdge) { | 48 if (fFlags & CropRect::kHasTop_CropEdge) { |
| 49 str->appendf("%.2f, ", fRect.fTop); | 49 str->appendf("%.2f, ", fRect.fTop); |
| 50 } else { | 50 } else { |
| 51 str->appendf("X, "); | 51 str->appendf("X, "); |
| 52 } | 52 } |
| 53 if (fFlags & CropRect::kHasRight_CropEdge) { | 53 if (fFlags & CropRect::kHasWidth_CropEdge) { |
| 54 str->appendf("%.2f, ", fRect.fRight); | 54 str->appendf("%.2f, ", fRect.width()); |
| 55 } else { | 55 } else { |
| 56 str->appendf("X, "); | 56 str->appendf("X, "); |
| 57 } | 57 } |
| 58 if (fFlags & CropRect::kHasBottom_CropEdge) { | 58 if (fFlags & CropRect::kHasHeight_CropEdge) { |
| 59 str->appendf("%.2f", fRect.fBottom); | 59 str->appendf("%.2f", fRect.height()); |
| 60 } else { | 60 } else { |
| 61 str->appendf("X"); | 61 str->appendf("X"); |
| 62 } | 62 } |
| 63 str->appendf(") "); | 63 str->appendf(") "); |
| 64 } | 64 } |
| 65 #endif | 65 #endif |
| 66 | 66 |
| 67 bool SkImageFilter::CropRect::applyTo(const SkIRect& imageBounds, const Context&
ctx, | 67 bool SkImageFilter::CropRect::applyTo(const SkIRect& imageBounds, const Context&
ctx, |
| 68 SkIRect* cropped) const { | 68 SkIRect* cropped) const { |
| 69 *cropped = imageBounds; | 69 *cropped = imageBounds; |
| 70 if (fFlags) { | 70 if (fFlags) { |
| 71 SkRect devCropR; | 71 SkRect devCropR; |
| 72 ctx.ctm().mapRect(&devCropR, fRect); | 72 ctx.ctm().mapRect(&devCropR, fRect); |
| 73 const SkIRect devICropR = devCropR.roundOut(); | 73 const SkIRect devICropR = devCropR.roundOut(); |
| 74 | 74 |
| 75 // Compute the left/top first, in case we have to read them to compute r
ight/bottom | 75 // Compute the left/top first, in case we have to read them to compute r
ight/bottom |
| 76 if (fFlags & kHasLeft_CropEdge) { | 76 if (fFlags & kHasLeft_CropEdge) { |
| 77 cropped->fLeft = devICropR.fLeft; | 77 cropped->fLeft = devICropR.fLeft; |
| 78 } | 78 } |
| 79 if (fFlags & kHasTop_CropEdge) { | 79 if (fFlags & kHasTop_CropEdge) { |
| 80 cropped->fTop = devICropR.fTop; | 80 cropped->fTop = devICropR.fTop; |
| 81 } | 81 } |
| 82 if (fFlags & kHasRight_CropEdge) { | 82 if (fFlags & kHasWidth_CropEdge) { |
| 83 cropped->fRight = cropped->fLeft + devICropR.width(); | 83 cropped->fRight = cropped->fLeft + devICropR.width(); |
| 84 } | 84 } |
| 85 if (fFlags & kHasBottom_CropEdge) { | 85 if (fFlags & kHasHeight_CropEdge) { |
| 86 cropped->fBottom = cropped->fTop + devICropR.height(); | 86 cropped->fBottom = cropped->fTop + devICropR.height(); |
| 87 } | 87 } |
| 88 } | 88 } |
| 89 return cropped->intersect(ctx.clipBounds()); | 89 return cropped->intersect(ctx.clipBounds()); |
| 90 } | 90 } |
| 91 | 91 |
| 92 ////////////////////////////////////////////////////////////////////////////////
/////////////////// | 92 ////////////////////////////////////////////////////////////////////////////////
/////////////////// |
| 93 | 93 |
| 94 static int32_t next_image_filter_unique_id() { | 94 static int32_t next_image_filter_unique_id() { |
| 95 static int32_t gImageFilterUniqueID; | 95 static int32_t gImageFilterUniqueID; |
| (...skipping 483 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 579 } | 579 } |
| 580 return dev; | 580 return dev; |
| 581 } | 581 } |
| 582 | 582 |
| 583 bool SkImageFilter::Proxy::filterImage(const SkImageFilter* filter, const SkBitm
ap& src, | 583 bool SkImageFilter::Proxy::filterImage(const SkImageFilter* filter, const SkBitm
ap& src, |
| 584 const SkImageFilter::Context& ctx, | 584 const SkImageFilter::Context& ctx, |
| 585 SkBitmap* result, SkIPoint* offset) { | 585 SkBitmap* result, SkIPoint* offset) { |
| 586 return fDevice->filterImage(filter, src, ctx, result, offset); | 586 return fDevice->filterImage(filter, src, ctx, result, offset); |
| 587 } | 587 } |
| 588 | 588 |
| OLD | NEW |