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" |
(...skipping 351 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
362 switch (fType) { | 362 switch (fType) { |
363 case GrMorphologyEffect::kErode_MorphologyType: | 363 case GrMorphologyEffect::kErode_MorphologyType: |
364 builder->fsCodeAppendf("\t\t%s = vec4(1, 1, 1, 1);\n", outputColor); | 364 builder->fsCodeAppendf("\t\t%s = vec4(1, 1, 1, 1);\n", outputColor); |
365 func = "min"; | 365 func = "min"; |
366 break; | 366 break; |
367 case GrMorphologyEffect::kDilate_MorphologyType: | 367 case GrMorphologyEffect::kDilate_MorphologyType: |
368 builder->fsCodeAppendf("\t\t%s = vec4(0, 0, 0, 0);\n", outputColor); | 368 builder->fsCodeAppendf("\t\t%s = vec4(0, 0, 0, 0);\n", outputColor); |
369 func = "max"; | 369 func = "max"; |
370 break; | 370 break; |
371 default: | 371 default: |
372 GrCrash("Unexpected type"); | 372 SkFAIL("Unexpected type"); |
373 func = ""; // suppress warning | 373 func = ""; // suppress warning |
374 break; | 374 break; |
375 } | 375 } |
376 const char* imgInc = builder->getUniformCStr(fImageIncrementUni); | 376 const char* imgInc = builder->getUniformCStr(fImageIncrementUni); |
377 | 377 |
378 builder->fsCodeAppendf("\t\tvec2 coord = %s - %d.0 * %s;\n", coords2D.c_str(
), fRadius, imgInc); | 378 builder->fsCodeAppendf("\t\tvec2 coord = %s - %d.0 * %s;\n", coords2D.c_str(
), fRadius, imgInc); |
379 builder->fsCodeAppendf("\t\tfor (int i = 0; i < %d; i++) {\n", this->width()
); | 379 builder->fsCodeAppendf("\t\tfor (int i = 0; i < %d; i++) {\n", this->width()
); |
380 builder->fsCodeAppendf("\t\t\t%s = %s(%s, ", outputColor, func, outputColor)
; | 380 builder->fsCodeAppendf("\t\t\t%s = %s(%s, ", outputColor, func, outputColor)
; |
381 builder->fsAppendTextureLookup(samplers[0], "coord"); | 381 builder->fsAppendTextureLookup(samplers[0], "coord"); |
382 builder->fsCodeAppend(");\n"); | 382 builder->fsCodeAppend(");\n"); |
(...skipping 20 matching lines...) Expand all Loading... |
403 SkASSERT(kern.radius() == fRadius); | 403 SkASSERT(kern.radius() == fRadius); |
404 float imageIncrement[2] = { 0 }; | 404 float imageIncrement[2] = { 0 }; |
405 switch (kern.direction()) { | 405 switch (kern.direction()) { |
406 case Gr1DKernelEffect::kX_Direction: | 406 case Gr1DKernelEffect::kX_Direction: |
407 imageIncrement[0] = 1.0f / texture.width(); | 407 imageIncrement[0] = 1.0f / texture.width(); |
408 break; | 408 break; |
409 case Gr1DKernelEffect::kY_Direction: | 409 case Gr1DKernelEffect::kY_Direction: |
410 imageIncrement[1] = 1.0f / texture.height(); | 410 imageIncrement[1] = 1.0f / texture.height(); |
411 break; | 411 break; |
412 default: | 412 default: |
413 GrCrash("Unknown filter direction."); | 413 SkFAIL("Unknown filter direction."); |
414 } | 414 } |
415 uman.set2fv(fImageIncrementUni, 1, imageIncrement); | 415 uman.set2fv(fImageIncrementUni, 1, imageIncrement); |
416 } | 416 } |
417 | 417 |
418 /////////////////////////////////////////////////////////////////////////////// | 418 /////////////////////////////////////////////////////////////////////////////// |
419 | 419 |
420 GrMorphologyEffect::GrMorphologyEffect(GrTexture* texture, | 420 GrMorphologyEffect::GrMorphologyEffect(GrTexture* texture, |
421 Direction direction, | 421 Direction direction, |
422 int radius, | 422 int radius, |
423 MorphologyType type) | 423 MorphologyType type) |
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
581 SkBitmap* result, SkIPoint* offset) con
st { | 581 SkBitmap* result, SkIPoint* offset) con
st { |
582 return this->filterImageGPUGeneric(true, proxy, src, ctx, result, offset); | 582 return this->filterImageGPUGeneric(true, proxy, src, ctx, result, offset); |
583 } | 583 } |
584 | 584 |
585 bool SkErodeImageFilter::filterImageGPU(Proxy* proxy, const SkBitmap& src, const
Context& ctx, | 585 bool SkErodeImageFilter::filterImageGPU(Proxy* proxy, const SkBitmap& src, const
Context& ctx, |
586 SkBitmap* result, SkIPoint* offset) cons
t { | 586 SkBitmap* result, SkIPoint* offset) cons
t { |
587 return this->filterImageGPUGeneric(false, proxy, src, ctx, result, offset); | 587 return this->filterImageGPUGeneric(false, proxy, src, ctx, result, offset); |
588 } | 588 } |
589 | 589 |
590 #endif | 590 #endif |
OLD | NEW |