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 "SkReadBuffer.h" | 11 #include "SkReadBuffer.h" |
12 #include "SkWriteBuffer.h" | 12 #include "SkWriteBuffer.h" |
13 #include "SkRect.h" | 13 #include "SkRect.h" |
14 #include "SkMorphology_opts.h" | 14 #include "SkMorphology_opts.h" |
15 #if SK_SUPPORT_GPU | 15 #if SK_SUPPORT_GPU |
16 #include "GrContext.h" | 16 #include "GrContext.h" |
17 #include "GrTexture.h" | 17 #include "GrTexture.h" |
18 #include "GrTBackendEffectFactory.h" | 18 #include "GrTBackendEffectFactory.h" |
19 #include "gl/GrGLEffect.h" | 19 #include "gl/GrGLEffect.h" |
20 #include "gl/GrGLShaderBuilder.h" | 20 #include "gl/GrGLShaderBuilder.h" |
21 #include "effects/Gr1DKernelEffect.h" | 21 #include "effects/Gr1DKernelEffect.h" |
22 #endif | 22 #endif |
23 | 23 |
| 24 #ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING |
24 SkMorphologyImageFilter::SkMorphologyImageFilter(SkReadBuffer& buffer) | 25 SkMorphologyImageFilter::SkMorphologyImageFilter(SkReadBuffer& buffer) |
25 : INHERITED(1, buffer) { | 26 : INHERITED(1, buffer) { |
26 fRadius.fWidth = buffer.readInt(); | 27 fRadius.fWidth = buffer.readInt(); |
27 fRadius.fHeight = buffer.readInt(); | 28 fRadius.fHeight = buffer.readInt(); |
28 buffer.validate((fRadius.fWidth >= 0) && | 29 buffer.validate((fRadius.fWidth >= 0) && |
29 (fRadius.fHeight >= 0)); | 30 (fRadius.fHeight >= 0)); |
30 } | 31 } |
| 32 #endif |
31 | 33 |
32 SkMorphologyImageFilter::SkMorphologyImageFilter(int radiusX, | 34 SkMorphologyImageFilter::SkMorphologyImageFilter(int radiusX, |
33 int radiusY, | 35 int radiusY, |
34 SkImageFilter* input, | 36 SkImageFilter* input, |
35 const CropRect* cropRect) | 37 const CropRect* cropRect) |
36 : INHERITED(1, &input, cropRect), fRadius(SkISize::Make(radiusX, radiusY)) { | 38 : INHERITED(1, &input, cropRect), fRadius(SkISize::Make(radiusX, radiusY)) { |
37 } | 39 } |
38 | 40 |
39 | |
40 void SkMorphologyImageFilter::flatten(SkWriteBuffer& buffer) const { | 41 void SkMorphologyImageFilter::flatten(SkWriteBuffer& buffer) const { |
41 this->INHERITED::flatten(buffer); | 42 this->INHERITED::flatten(buffer); |
42 buffer.writeInt(fRadius.fWidth); | 43 buffer.writeInt(fRadius.fWidth); |
43 buffer.writeInt(fRadius.fHeight); | 44 buffer.writeInt(fRadius.fHeight); |
44 } | 45 } |
45 | 46 |
46 enum MorphDirection { | 47 enum MorphDirection { |
47 kX, kY | 48 kX, kY |
48 }; | 49 }; |
49 | 50 |
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
251 return false; | 252 return false; |
252 } | 253 } |
253 SkVector radius = SkVector::Make(SkIntToScalar(this->radius().width()), | 254 SkVector radius = SkVector::Make(SkIntToScalar(this->radius().width()), |
254 SkIntToScalar(this->radius().height())); | 255 SkIntToScalar(this->radius().height())); |
255 ctm.mapVectors(&radius, 1); | 256 ctm.mapVectors(&radius, 1); |
256 bounds.outset(SkScalarCeilToInt(radius.x()), SkScalarCeilToInt(radius.y())); | 257 bounds.outset(SkScalarCeilToInt(radius.x()), SkScalarCeilToInt(radius.y())); |
257 *dst = bounds; | 258 *dst = bounds; |
258 return true; | 259 return true; |
259 } | 260 } |
260 | 261 |
| 262 SkFlattenable* SkErodeImageFilter::CreateProc(SkReadBuffer& buffer) { |
| 263 SK_IMAGEFILTER_UNFLATTEN_COMMON(1); |
| 264 const int width = buffer.readInt(); |
| 265 const int height = buffer.readInt(); |
| 266 return Create(width, height, common.inputAt(0), &common.cropRect()); |
| 267 } |
| 268 |
| 269 SkFlattenable* SkDilateImageFilter::CreateProc(SkReadBuffer& buffer) { |
| 270 SK_IMAGEFILTER_UNFLATTEN_COMMON(1); |
| 271 const int width = buffer.readInt(); |
| 272 const int height = buffer.readInt(); |
| 273 return Create(width, height, common.inputAt(0), &common.cropRect()); |
| 274 } |
| 275 |
261 #if SK_SUPPORT_GPU | 276 #if SK_SUPPORT_GPU |
262 | 277 |
263 /////////////////////////////////////////////////////////////////////////////// | 278 /////////////////////////////////////////////////////////////////////////////// |
264 | 279 |
265 class GrGLMorphologyEffect; | 280 class GrGLMorphologyEffect; |
266 | 281 |
267 /** | 282 /** |
268 * Morphology effects. Depending upon the type of morphology, either the | 283 * Morphology effects. Depending upon the type of morphology, either the |
269 * component-wise min (Erode_Type) or max (Dilate_Type) of all pixels in the | 284 * component-wise min (Erode_Type) or max (Dilate_Type) of all pixels in the |
270 * kernel is selected as the new color. The new color is modulated by the input | 285 * kernel is selected as the new color. The new color is modulated by the input |
(...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
584 SkBitmap* result, SkIPoint* offset) con
st { | 599 SkBitmap* result, SkIPoint* offset) con
st { |
585 return this->filterImageGPUGeneric(true, proxy, src, ctx, result, offset); | 600 return this->filterImageGPUGeneric(true, proxy, src, ctx, result, offset); |
586 } | 601 } |
587 | 602 |
588 bool SkErodeImageFilter::filterImageGPU(Proxy* proxy, const SkBitmap& src, const
Context& ctx, | 603 bool SkErodeImageFilter::filterImageGPU(Proxy* proxy, const SkBitmap& src, const
Context& ctx, |
589 SkBitmap* result, SkIPoint* offset) cons
t { | 604 SkBitmap* result, SkIPoint* offset) cons
t { |
590 return this->filterImageGPUGeneric(false, proxy, src, ctx, result, offset); | 605 return this->filterImageGPUGeneric(false, proxy, src, ctx, result, offset); |
591 } | 606 } |
592 | 607 |
593 #endif | 608 #endif |
OLD | NEW |