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 "glsl/GrGLSLFragmentProcessor.h" | 22 #include "glsl/GrGLSLFragmentProcessor.h" |
23 #include "glsl/GrGLSLFragmentShaderBuilder.h" | 23 #include "glsl/GrGLSLFragmentShaderBuilder.h" |
24 #include "glsl/GrGLSLProgramBuilder.h" | |
25 #include "glsl/GrGLSLProgramDataManager.h" | 24 #include "glsl/GrGLSLProgramDataManager.h" |
| 25 #include "glsl/GrGLSLUniformHandler.h" |
26 #endif | 26 #endif |
27 | 27 |
28 SkMorphologyImageFilter::SkMorphologyImageFilter(int radiusX, | 28 SkMorphologyImageFilter::SkMorphologyImageFilter(int radiusX, |
29 int radiusY, | 29 int radiusY, |
30 SkImageFilter* input, | 30 SkImageFilter* input, |
31 const CropRect* cropRect) | 31 const CropRect* cropRect) |
32 : INHERITED(1, &input, cropRect), fRadius(SkISize::Make(radiusX, radiusY)) { | 32 : INHERITED(1, &input, cropRect), fRadius(SkISize::Make(radiusX, radiusY)) { |
33 } | 33 } |
34 | 34 |
35 void SkMorphologyImageFilter::flatten(SkWriteBuffer& buffer) const { | 35 void SkMorphologyImageFilter::flatten(SkWriteBuffer& buffer) const { |
(...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
281 | 281 |
282 GrGLMorphologyEffect::GrGLMorphologyEffect(const GrProcessor& proc) { | 282 GrGLMorphologyEffect::GrGLMorphologyEffect(const GrProcessor& proc) { |
283 const GrMorphologyEffect& m = proc.cast<GrMorphologyEffect>(); | 283 const GrMorphologyEffect& m = proc.cast<GrMorphologyEffect>(); |
284 fRadius = m.radius(); | 284 fRadius = m.radius(); |
285 fDirection = m.direction(); | 285 fDirection = m.direction(); |
286 fUseRange = m.useRange(); | 286 fUseRange = m.useRange(); |
287 fType = m.type(); | 287 fType = m.type(); |
288 } | 288 } |
289 | 289 |
290 void GrGLMorphologyEffect::emitCode(EmitArgs& args) { | 290 void GrGLMorphologyEffect::emitCode(EmitArgs& args) { |
291 fPixelSizeUni = args.fBuilder->addUniform(GrGLSLProgramBuilder::kFragment_Vi
sibility, | 291 GrGLSLUniformHandler* uniformHandler = args.fUniformHandler; |
292 kFloat_GrSLType, kDefault_GrSLPrecis
ion, | 292 fPixelSizeUni = uniformHandler->addUniform(GrGLSLUniformHandler::kFragment_V
isibility, |
293 "PixelSize"); | 293 kFloat_GrSLType, kDefault_GrSLPre
cision, |
294 const char* pixelSizeInc = args.fBuilder->getUniformCStr(fPixelSizeUni); | 294 "PixelSize"); |
295 fRangeUni = args.fBuilder->addUniform(GrGLSLProgramBuilder::kFragment_Visibi
lity, | 295 const char* pixelSizeInc = uniformHandler->getUniformCStr(fPixelSizeUni); |
296 kVec2f_GrSLType, kDefault_GrSLPrecis
ion, | 296 fRangeUni = uniformHandler->addUniform(GrGLSLUniformHandler::kFragment_Visib
ility, |
297 "Range"); | 297 kVec2f_GrSLType, kDefault_GrSLPrecisi
on, |
298 const char* range = args.fBuilder->getUniformCStr(fRangeUni); | 298 "Range"); |
| 299 const char* range = uniformHandler->getUniformCStr(fRangeUni); |
299 | 300 |
300 GrGLSLFragmentBuilder* fragBuilder = args.fFragBuilder; | 301 GrGLSLFragmentBuilder* fragBuilder = args.fFragBuilder; |
301 SkString coords2D = fragBuilder->ensureFSCoords2D(args.fCoords, 0); | 302 SkString coords2D = fragBuilder->ensureFSCoords2D(args.fCoords, 0); |
302 const char* func; | 303 const char* func; |
303 switch (fType) { | 304 switch (fType) { |
304 case GrMorphologyEffect::kErode_MorphologyType: | 305 case GrMorphologyEffect::kErode_MorphologyType: |
305 fragBuilder->codeAppendf("\t\t%s = vec4(1, 1, 1, 1);\n", args.fOutpu
tColor); | 306 fragBuilder->codeAppendf("\t\t%s = vec4(1, 1, 1, 1);\n", args.fOutpu
tColor); |
306 func = "min"; | 307 func = "min"; |
307 break; | 308 break; |
308 case GrMorphologyEffect::kDilate_MorphologyType: | 309 case GrMorphologyEffect::kDilate_MorphologyType: |
(...skipping 364 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
673 SkBitmap* result, SkIPoint* offset) con
st { | 674 SkBitmap* result, SkIPoint* offset) con
st { |
674 return this->filterImageGPUGeneric(true, proxy, src, ctx, result, offset); | 675 return this->filterImageGPUGeneric(true, proxy, src, ctx, result, offset); |
675 } | 676 } |
676 | 677 |
677 bool SkErodeImageFilter::filterImageGPU(Proxy* proxy, const SkBitmap& src, const
Context& ctx, | 678 bool SkErodeImageFilter::filterImageGPU(Proxy* proxy, const SkBitmap& src, const
Context& ctx, |
678 SkBitmap* result, SkIPoint* offset) cons
t { | 679 SkBitmap* result, SkIPoint* offset) cons
t { |
679 return this->filterImageGPUGeneric(false, proxy, src, ctx, result, offset); | 680 return this->filterImageGPUGeneric(false, proxy, src, ctx, result, offset); |
680 } | 681 } |
681 | 682 |
682 #endif | 683 #endif |
OLD | NEW |