| 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 "SkMorphologyImageFilter.h" | 8 #include "SkMorphologyImageFilter.h" |
| 9 #include "SkBitmap.h" | 9 #include "SkBitmap.h" |
| 10 #include "SkColorPriv.h" | 10 #include "SkColorPriv.h" |
| (...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 159 SkIRect bounds; | 159 SkIRect bounds; |
| 160 if (!this->applyCropRect(ctx, proxy, src, &srcOffset, &bounds, &src)) { | 160 if (!this->applyCropRect(ctx, proxy, src, &srcOffset, &bounds, &src)) { |
| 161 return false; | 161 return false; |
| 162 } | 162 } |
| 163 | 163 |
| 164 SkAutoLockPixels alp(src); | 164 SkAutoLockPixels alp(src); |
| 165 if (!src.getPixels()) { | 165 if (!src.getPixels()) { |
| 166 return false; | 166 return false; |
| 167 } | 167 } |
| 168 | 168 |
| 169 if (!dst->allocPixels(src.info().makeWH(bounds.width(), bounds.height()))) { | 169 if (!dst->tryAllocPixels(src.info().makeWH(bounds.width(), bounds.height()))
) { |
| 170 return false; | 170 return false; |
| 171 } | 171 } |
| 172 | 172 |
| 173 SkVector radius = SkVector::Make(SkIntToScalar(this->radius().width()), | 173 SkVector radius = SkVector::Make(SkIntToScalar(this->radius().width()), |
| 174 SkIntToScalar(this->radius().height())); | 174 SkIntToScalar(this->radius().height())); |
| 175 ctx.ctm().mapVectors(&radius, 1); | 175 ctx.ctm().mapVectors(&radius, 1); |
| 176 int width = SkScalarFloorToInt(radius.fX); | 176 int width = SkScalarFloorToInt(radius.fX); |
| 177 int height = SkScalarFloorToInt(radius.fY); | 177 int height = SkScalarFloorToInt(radius.fY); |
| 178 | 178 |
| 179 if (width < 0 || height < 0) { | 179 if (width < 0 || height < 0) { |
| 180 return false; | 180 return false; |
| 181 } | 181 } |
| 182 | 182 |
| 183 SkIRect srcBounds = bounds; | 183 SkIRect srcBounds = bounds; |
| 184 srcBounds.offset(-srcOffset); | 184 srcBounds.offset(-srcOffset); |
| 185 | 185 |
| 186 if (width == 0 && height == 0) { | 186 if (width == 0 && height == 0) { |
| 187 src.extractSubset(dst, srcBounds); | 187 src.extractSubset(dst, srcBounds); |
| 188 offset->fX = bounds.left(); | 188 offset->fX = bounds.left(); |
| 189 offset->fY = bounds.top(); | 189 offset->fY = bounds.top(); |
| 190 return true; | 190 return true; |
| 191 } | 191 } |
| 192 | 192 |
| 193 SkBitmap temp; | 193 SkBitmap temp; |
| 194 if (!temp.allocPixels(dst->info())) { | 194 if (!temp.tryAllocPixels(dst->info())) { |
| 195 return false; | 195 return false; |
| 196 } | 196 } |
| 197 | 197 |
| 198 if (width > 0 && height > 0) { | 198 if (width > 0 && height > 0) { |
| 199 callProcX(procX, src, &temp, width, srcBounds); | 199 callProcX(procX, src, &temp, width, srcBounds); |
| 200 SkIRect tmpBounds = SkIRect::MakeWH(srcBounds.width(), srcBounds.height(
)); | 200 SkIRect tmpBounds = SkIRect::MakeWH(srcBounds.width(), srcBounds.height(
)); |
| 201 callProcY(procY, temp, dst, height, tmpBounds); | 201 callProcY(procY, temp, dst, height, tmpBounds); |
| 202 } else if (width > 0) { | 202 } else if (width > 0) { |
| 203 callProcX(procX, src, dst, width, srcBounds); | 203 callProcX(procX, src, dst, width, srcBounds); |
| 204 } else if (height > 0) { | 204 } else if (height > 0) { |
| (...skipping 396 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 601 SkBitmap* result, SkIPoint* offset) con
st { | 601 SkBitmap* result, SkIPoint* offset) con
st { |
| 602 return this->filterImageGPUGeneric(true, proxy, src, ctx, result, offset); | 602 return this->filterImageGPUGeneric(true, proxy, src, ctx, result, offset); |
| 603 } | 603 } |
| 604 | 604 |
| 605 bool SkErodeImageFilter::filterImageGPU(Proxy* proxy, const SkBitmap& src, const
Context& ctx, | 605 bool SkErodeImageFilter::filterImageGPU(Proxy* proxy, const SkBitmap& src, const
Context& ctx, |
| 606 SkBitmap* result, SkIPoint* offset) cons
t { | 606 SkBitmap* result, SkIPoint* offset) cons
t { |
| 607 return this->filterImageGPUGeneric(false, proxy, src, ctx, result, offset); | 607 return this->filterImageGPUGeneric(false, proxy, src, ctx, result, offset); |
| 608 } | 608 } |
| 609 | 609 |
| 610 #endif | 610 #endif |
| OLD | NEW |