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 "effects/Gr1DKernelEffect.h" | 18 #include "effects/Gr1DKernelEffect.h" |
19 #include "SkImageFilterUtils.h" | 19 #include "SkImageFilterUtils.h" |
20 #endif | 20 #endif |
21 | 21 |
22 SkMorphologyImageFilter::SkMorphologyImageFilter(SkFlattenableReadBuffer& buffer
) | 22 SkMorphologyImageFilter::SkMorphologyImageFilter(SkFlattenableReadBuffer& buffer
) |
23 : INHERITED(buffer) { | 23 : INHERITED(buffer) { |
24 fRadius.fWidth = buffer.readInt(); | 24 fRadius.fWidth = buffer.readInt(); |
25 fRadius.fHeight = buffer.readInt(); | 25 fRadius.fHeight = buffer.readInt(); |
| 26 buffer.validate((fRadius.fWidth >= 0) && |
| 27 (fRadius.fHeight >= 0)); |
26 } | 28 } |
27 | 29 |
28 SkMorphologyImageFilter::SkMorphologyImageFilter(int radiusX, int radiusY, SkIma
geFilter* input, const CropRect* cropRect) | 30 SkMorphologyImageFilter::SkMorphologyImageFilter(int radiusX, int radiusY, SkIma
geFilter* input, const CropRect* cropRect) |
29 : INHERITED(input, cropRect), fRadius(SkISize::Make(radiusX, radiusY)) { | 31 : INHERITED(input, cropRect), fRadius(SkISize::Make(radiusX, radiusY)) { |
30 } | 32 } |
31 | 33 |
32 | 34 |
33 void SkMorphologyImageFilter::flatten(SkFlattenableWriteBuffer& buffer) const { | 35 void SkMorphologyImageFilter::flatten(SkFlattenableWriteBuffer& buffer) const { |
34 this->INHERITED::flatten(buffer); | 36 this->INHERITED::flatten(buffer); |
35 buffer.writeInt(fRadius.fWidth); | 37 buffer.writeInt(fRadius.fWidth); |
(...skipping 545 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
581 | 583 |
582 if (!apply_morphology(input, bounds, GrMorphologyEffect::kErode_MorphologyTy
pe, radius(), result)) { | 584 if (!apply_morphology(input, bounds, GrMorphologyEffect::kErode_MorphologyTy
pe, radius(), result)) { |
583 return false; | 585 return false; |
584 } | 586 } |
585 offset->fX += bounds.left(); | 587 offset->fX += bounds.left(); |
586 offset->fY += bounds.top(); | 588 offset->fY += bounds.top(); |
587 return true; | 589 return true; |
588 } | 590 } |
589 | 591 |
590 #endif | 592 #endif |
OLD | NEW |