| 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 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 156 SkIRect bounds; | 156 SkIRect bounds; |
| 157 if (!this->applyCropRect(ctx, proxy, src, &srcOffset, &bounds, &src)) { | 157 if (!this->applyCropRect(ctx, proxy, src, &srcOffset, &bounds, &src)) { |
| 158 return false; | 158 return false; |
| 159 } | 159 } |
| 160 | 160 |
| 161 SkAutoLockPixels alp(src); | 161 SkAutoLockPixels alp(src); |
| 162 if (!src.getPixels()) { | 162 if (!src.getPixels()) { |
| 163 return false; | 163 return false; |
| 164 } | 164 } |
| 165 | 165 |
| 166 dst->setConfig(src.config(), bounds.width(), bounds.height()); | 166 if (!dst->allocPixels(src.info().makeWH(bounds.width(), bounds.height()))) { |
| 167 dst->allocPixels(); | |
| 168 if (!dst->getPixels()) { | |
| 169 return false; | 167 return false; |
| 170 } | 168 } |
| 171 | 169 |
| 172 SkVector radius = SkVector::Make(SkIntToScalar(this->radius().width()), | 170 SkVector radius = SkVector::Make(SkIntToScalar(this->radius().width()), |
| 173 SkIntToScalar(this->radius().height())); | 171 SkIntToScalar(this->radius().height())); |
| 174 ctx.ctm().mapVectors(&radius, 1); | 172 ctx.ctm().mapVectors(&radius, 1); |
| 175 int width = SkScalarFloorToInt(radius.fX); | 173 int width = SkScalarFloorToInt(radius.fX); |
| 176 int height = SkScalarFloorToInt(radius.fY); | 174 int height = SkScalarFloorToInt(radius.fY); |
| 177 | 175 |
| 178 if (width < 0 || height < 0) { | 176 if (width < 0 || height < 0) { |
| 179 return false; | 177 return false; |
| 180 } | 178 } |
| 181 | 179 |
| 182 SkIRect srcBounds = bounds; | 180 SkIRect srcBounds = bounds; |
| 183 srcBounds.offset(-srcOffset); | 181 srcBounds.offset(-srcOffset); |
| 184 | 182 |
| 185 if (width == 0 && height == 0) { | 183 if (width == 0 && height == 0) { |
| 186 src.extractSubset(dst, srcBounds); | 184 src.extractSubset(dst, srcBounds); |
| 187 offset->fX = bounds.left(); | 185 offset->fX = bounds.left(); |
| 188 offset->fY = bounds.top(); | 186 offset->fY = bounds.top(); |
| 189 return true; | 187 return true; |
| 190 } | 188 } |
| 191 | 189 |
| 192 SkBitmap temp; | 190 SkBitmap temp; |
| 193 temp.setConfig(dst->config(), dst->width(), dst->height()); | 191 if (!temp.allocPixels(dst->info())) { |
| 194 if (!temp.allocPixels()) { | |
| 195 return false; | 192 return false; |
| 196 } | 193 } |
| 197 | 194 |
| 198 if (width > 0 && height > 0) { | 195 if (width > 0 && height > 0) { |
| 199 callProcX(procX, src, &temp, width, srcBounds); | 196 callProcX(procX, src, &temp, width, srcBounds); |
| 200 SkIRect tmpBounds = SkIRect::MakeWH(srcBounds.width(), srcBounds.height(
)); | 197 SkIRect tmpBounds = SkIRect::MakeWH(srcBounds.width(), srcBounds.height(
)); |
| 201 callProcY(procY, temp, dst, height, tmpBounds); | 198 callProcY(procY, temp, dst, height, tmpBounds); |
| 202 } else if (width > 0) { | 199 } else if (width > 0) { |
| 203 callProcX(procX, src, dst, width, srcBounds); | 200 callProcX(procX, src, dst, width, srcBounds); |
| 204 } else if (height > 0) { | 201 } else if (height > 0) { |
| (...skipping 376 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 581 SkBitmap* result, SkIPoint* offset) con
st { | 578 SkBitmap* result, SkIPoint* offset) con
st { |
| 582 return this->filterImageGPUGeneric(true, proxy, src, ctx, result, offset); | 579 return this->filterImageGPUGeneric(true, proxy, src, ctx, result, offset); |
| 583 } | 580 } |
| 584 | 581 |
| 585 bool SkErodeImageFilter::filterImageGPU(Proxy* proxy, const SkBitmap& src, const
Context& ctx, | 582 bool SkErodeImageFilter::filterImageGPU(Proxy* proxy, const SkBitmap& src, const
Context& ctx, |
| 586 SkBitmap* result, SkIPoint* offset) cons
t { | 583 SkBitmap* result, SkIPoint* offset) cons
t { |
| 587 return this->filterImageGPUGeneric(false, proxy, src, ctx, result, offset); | 584 return this->filterImageGPUGeneric(false, proxy, src, ctx, result, offset); |
| 588 } | 585 } |
| 589 | 586 |
| 590 #endif | 587 #endif |
| OLD | NEW |