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 "SkDevice.h" | 11 #include "SkDevice.h" |
12 #include "SkOpts.h" | 12 #include "SkOpts.h" |
13 #include "SkReadBuffer.h" | 13 #include "SkReadBuffer.h" |
14 #include "SkRect.h" | 14 #include "SkRect.h" |
15 #include "SkWriteBuffer.h" | 15 #include "SkWriteBuffer.h" |
16 #if SK_SUPPORT_GPU | 16 #if SK_SUPPORT_GPU |
17 #include "GrContext.h" | 17 #include "GrContext.h" |
18 #include "GrDrawContext.h" | 18 #include "GrDrawContext.h" |
19 #include "GrInvariantOutput.h" | 19 #include "GrInvariantOutput.h" |
20 #include "GrTexture.h" | 20 #include "GrTexture.h" |
21 #include "effects/Gr1DKernelEffect.h" | 21 #include "effects/Gr1DKernelEffect.h" |
22 #include "gl/GrGLFragmentProcessor.h" | 22 #include "gl/GrGLFragmentProcessor.h" |
23 #include "gl/builders/GrGLProgramBuilder.h" | 23 #include "glsl/GrGLSLFragmentShaderBuilder.h" |
| 24 #include "glsl/GrGLSLProgramBuilder.h" |
24 #include "glsl/GrGLSLProgramDataManager.h" | 25 #include "glsl/GrGLSLProgramDataManager.h" |
25 #endif | 26 #endif |
26 | 27 |
27 SkMorphologyImageFilter::SkMorphologyImageFilter(int radiusX, | 28 SkMorphologyImageFilter::SkMorphologyImageFilter(int radiusX, |
28 int radiusY, | 29 int radiusY, |
29 SkImageFilter* input, | 30 SkImageFilter* input, |
30 const CropRect* cropRect) | 31 const CropRect* cropRect) |
31 : INHERITED(1, &input, cropRect), fRadius(SkISize::Make(radiusX, radiusY)) { | 32 : INHERITED(1, &input, cropRect), fRadius(SkISize::Make(radiusX, radiusY)) { |
32 } | 33 } |
33 | 34 |
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
280 | 281 |
281 GrGLMorphologyEffect::GrGLMorphologyEffect(const GrProcessor& proc) { | 282 GrGLMorphologyEffect::GrGLMorphologyEffect(const GrProcessor& proc) { |
282 const GrMorphologyEffect& m = proc.cast<GrMorphologyEffect>(); | 283 const GrMorphologyEffect& m = proc.cast<GrMorphologyEffect>(); |
283 fRadius = m.radius(); | 284 fRadius = m.radius(); |
284 fDirection = m.direction(); | 285 fDirection = m.direction(); |
285 fUseRange = m.useRange(); | 286 fUseRange = m.useRange(); |
286 fType = m.type(); | 287 fType = m.type(); |
287 } | 288 } |
288 | 289 |
289 void GrGLMorphologyEffect::emitCode(EmitArgs& args) { | 290 void GrGLMorphologyEffect::emitCode(EmitArgs& args) { |
290 fPixelSizeUni = args.fBuilder->addUniform(GrGLProgramBuilder::kFragment_Visi
bility, | 291 fPixelSizeUni = args.fBuilder->addUniform(GrGLSLProgramBuilder::kFragment_Vi
sibility, |
291 kFloat_GrSLType, kDefault_GrSLPrecis
ion, | 292 kFloat_GrSLType, kDefault_GrSLPrecis
ion, |
292 "PixelSize"); | 293 "PixelSize"); |
293 const char* pixelSizeInc = args.fBuilder->getUniformCStr(fPixelSizeUni); | 294 const char* pixelSizeInc = args.fBuilder->getUniformCStr(fPixelSizeUni); |
294 fRangeUni = args.fBuilder->addUniform(GrGLProgramBuilder::kFragment_Visibili
ty, | 295 fRangeUni = args.fBuilder->addUniform(GrGLSLProgramBuilder::kFragment_Visibi
lity, |
295 kVec2f_GrSLType, kDefault_GrSLPrecis
ion, | 296 kVec2f_GrSLType, kDefault_GrSLPrecis
ion, |
296 "Range"); | 297 "Range"); |
297 const char* range = args.fBuilder->getUniformCStr(fRangeUni); | 298 const char* range = args.fBuilder->getUniformCStr(fRangeUni); |
298 | 299 |
299 GrGLFragmentBuilder* fsBuilder = args.fBuilder->getFragmentShaderBuilder(); | 300 GrGLSLFragmentBuilder* fsBuilder = args.fBuilder->getFragmentShaderBuilder()
; |
300 SkString coords2D = fsBuilder->ensureFSCoords2D(args.fCoords, 0); | 301 SkString coords2D = fsBuilder->ensureFSCoords2D(args.fCoords, 0); |
301 const char* func; | 302 const char* func; |
302 switch (fType) { | 303 switch (fType) { |
303 case GrMorphologyEffect::kErode_MorphologyType: | 304 case GrMorphologyEffect::kErode_MorphologyType: |
304 fsBuilder->codeAppendf("\t\t%s = vec4(1, 1, 1, 1);\n", args.fOutputC
olor); | 305 fsBuilder->codeAppendf("\t\t%s = vec4(1, 1, 1, 1);\n", args.fOutputC
olor); |
305 func = "min"; | 306 func = "min"; |
306 break; | 307 break; |
307 case GrMorphologyEffect::kDilate_MorphologyType: | 308 case GrMorphologyEffect::kDilate_MorphologyType: |
308 fsBuilder->codeAppendf("\t\t%s = vec4(0, 0, 0, 0);\n", args.fOutputC
olor); | 309 fsBuilder->codeAppendf("\t\t%s = vec4(0, 0, 0, 0);\n", args.fOutputC
olor); |
309 func = "max"; | 310 func = "max"; |
(...skipping 359 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
669 SkBitmap* result, SkIPoint* offset) con
st { | 670 SkBitmap* result, SkIPoint* offset) con
st { |
670 return this->filterImageGPUGeneric(true, proxy, src, ctx, result, offset); | 671 return this->filterImageGPUGeneric(true, proxy, src, ctx, result, offset); |
671 } | 672 } |
672 | 673 |
673 bool SkErodeImageFilter::filterImageGPU(Proxy* proxy, const SkBitmap& src, const
Context& ctx, | 674 bool SkErodeImageFilter::filterImageGPU(Proxy* proxy, const SkBitmap& src, const
Context& ctx, |
674 SkBitmap* result, SkIPoint* offset) cons
t { | 675 SkBitmap* result, SkIPoint* offset) cons
t { |
675 return this->filterImageGPUGeneric(false, proxy, src, ctx, result, offset); | 676 return this->filterImageGPUGeneric(false, proxy, src, ctx, result, offset); |
676 } | 677 } |
677 | 678 |
678 #endif | 679 #endif |
OLD | NEW |