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" |
11 #include "SkFlattenableBuffers.h" | 11 #include "SkFlattenableBuffers.h" |
12 #include "SkRect.h" | 12 #include "SkRect.h" |
13 #if SK_SUPPORT_GPU | 13 #if SK_SUPPORT_GPU |
14 #include "GrContext.h" | 14 #include "GrContext.h" |
15 #include "GrTexture.h" | 15 #include "GrTexture.h" |
16 #include "GrTBackendEffectFactory.h" | 16 #include "GrTBackendEffectFactory.h" |
17 #include "gl/GrGLEffect.h" | 17 #include "gl/GrGLEffect.h" |
18 #include "gl/GrGLEffectMatrix.h" | 18 #include "gl/GrGLEffectMatrix.h" |
19 #include "effects/Gr1DKernelEffect.h" | 19 #include "effects/Gr1DKernelEffect.h" |
20 #include "SkImageFilterUtils.h" | 20 #include "SkImageFilterUtils.h" |
21 #endif | 21 #endif |
22 | 22 |
23 SkMorphologyImageFilter::SkMorphologyImageFilter(SkFlattenableReadBuffer& buffer
) | 23 SkMorphologyImageFilter::SkMorphologyImageFilter(SkFlattenableReadBuffer& buffer
) |
24 : INHERITED(buffer) { | 24 : INHERITED(buffer) { |
25 fRadius.fWidth = buffer.readInt(); | 25 fRadius.fWidth = buffer.readInt(); |
26 fRadius.fHeight = buffer.readInt(); | 26 fRadius.fHeight = buffer.readInt(); |
| 27 buffer.validateData(SkScalarIsFinite(fRadius.fWidth) && |
| 28 SkScalarIsFinite(fRadius.fHeight) && |
| 29 (fRadius.fWidth >= 0) && |
| 30 (fRadius.fHeight >= 0)); |
27 } | 31 } |
28 | 32 |
29 SkMorphologyImageFilter::SkMorphologyImageFilter(int radiusX, int radiusY, SkIma
geFilter* input) | 33 SkMorphologyImageFilter::SkMorphologyImageFilter(int radiusX, int radiusY, SkIma
geFilter* input) |
30 : INHERITED(input), fRadius(SkISize::Make(radiusX, radiusY)) { | 34 : INHERITED(input), fRadius(SkISize::Make(radiusX, radiusY)) { |
31 } | 35 } |
32 | 36 |
33 | 37 |
34 void SkMorphologyImageFilter::flatten(SkFlattenableWriteBuffer& buffer) const { | 38 void SkMorphologyImageFilter::flatten(SkFlattenableWriteBuffer& buffer) const { |
35 this->INHERITED::flatten(buffer); | 39 this->INHERITED::flatten(buffer); |
36 buffer.writeInt(fRadius.fWidth); | 40 buffer.writeInt(fRadius.fWidth); |
(...skipping 486 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
523 } | 527 } |
524 GrTexture* input = inputBM.getTexture(); | 528 GrTexture* input = inputBM.getTexture(); |
525 SkIRect bounds; | 529 SkIRect bounds; |
526 src.getBounds(&bounds); | 530 src.getBounds(&bounds); |
527 SkAutoTUnref<GrTexture> resultTex(apply_morphology(input, bounds, | 531 SkAutoTUnref<GrTexture> resultTex(apply_morphology(input, bounds, |
528 GrMorphologyEffect::kErode_MorphologyType, radius())); | 532 GrMorphologyEffect::kErode_MorphologyType, radius())); |
529 return SkImageFilterUtils::WrapTexture(resultTex, src.width(), src.height(),
result); | 533 return SkImageFilterUtils::WrapTexture(resultTex, src.width(), src.height(),
result); |
530 } | 534 } |
531 | 535 |
532 #endif | 536 #endif |
OLD | NEW |