OLD | NEW |
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2006 The Android Open Source Project | 3 * Copyright 2006 The Android Open Source Project |
4 * | 4 * |
5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
7 */ | 7 */ |
8 | 8 |
9 #include "SkBlurMaskFilter.h" | 9 #include "SkBlurMaskFilter.h" |
10 #include "SkBlurMask.h" | 10 #include "SkBlurMask.h" |
(...skipping 612 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
623 GrGLRectBlurEffect::GrGLRectBlurEffect(const GrBackendEffectFactory& factory, co
nst GrDrawEffect&) | 623 GrGLRectBlurEffect::GrGLRectBlurEffect(const GrBackendEffectFactory& factory, co
nst GrDrawEffect&) |
624 : INHERITED(factory) { | 624 : INHERITED(factory) { |
625 } | 625 } |
626 | 626 |
627 void OutputRectBlurProfileLookup(GrGLShaderBuilder* builder, | 627 void OutputRectBlurProfileLookup(GrGLShaderBuilder* builder, |
628 const GrGLShaderBuilder::TextureSampler& sample
r, | 628 const GrGLShaderBuilder::TextureSampler& sample
r, |
629 const char *output, | 629 const char *output, |
630 const char *profileSize, const char *loc, | 630 const char *profileSize, const char *loc, |
631 const char *blurred_width, | 631 const char *blurred_width, |
632 const char *sharp_width) { | 632 const char *sharp_width) { |
633 builder->fsCodeAppendf("\t\tfloat coord = (0.5 * (abs(2*%s - %s) - %s))/%s;\
n", | 633 builder->fsCodeAppendf("\t\tfloat coord = (0.5 * (abs(2.0*%s - %s) - %s))/%s
;\n", |
634 loc, blurred_width, sharp_width, profileSize); | 634 loc, blurred_width, sharp_width, profileSize); |
635 builder->fsCodeAppendf("\t\t%s = ", output); | 635 builder->fsCodeAppendf("\t\t%s = ", output); |
636 builder->fsAppendTextureLookup(sampler, "vec2(coord,0.5)"); | 636 builder->fsAppendTextureLookup(sampler, "vec2(coord,0.5)"); |
637 builder->fsCodeAppend(".a;\n"); | 637 builder->fsCodeAppend(".a;\n"); |
638 } | 638 } |
639 | 639 |
640 void GrGLRectBlurEffect::emitCode(GrGLShaderBuilder* builder, | 640 void GrGLRectBlurEffect::emitCode(GrGLShaderBuilder* builder, |
641 const GrDrawEffect&, | 641 const GrDrawEffect&, |
642 EffectKey key, | 642 EffectKey key, |
643 const char* outputColor, | 643 const char* outputColor, |
(...skipping 19 matching lines...) Expand all Loading... |
663 builder->fsCodeAppendf("\tvec4 src=%s;\n", inputColor); | 663 builder->fsCodeAppendf("\tvec4 src=%s;\n", inputColor); |
664 } else { | 664 } else { |
665 builder->fsCodeAppendf("\tvec4 src=vec4(1)\n;"); | 665 builder->fsCodeAppendf("\tvec4 src=vec4(1)\n;"); |
666 } | 666 } |
667 | 667 |
668 builder->fsCodeAppendf("\tvec2 translatedPos = %s.xy - %s.xy;\n", fragmentPo
s, rectName ); | 668 builder->fsCodeAppendf("\tvec2 translatedPos = %s.xy - %s.xy;\n", fragmentPo
s, rectName ); |
669 builder->fsCodeAppendf("\tfloat width = %s.z - %s.x;\n", rectName, rectName)
; | 669 builder->fsCodeAppendf("\tfloat width = %s.z - %s.x;\n", rectName, rectName)
; |
670 builder->fsCodeAppendf("\tfloat height = %s.w - %s.y;\n", rectName, rectName
); | 670 builder->fsCodeAppendf("\tfloat height = %s.w - %s.y;\n", rectName, rectName
); |
671 | 671 |
672 builder->fsCodeAppendf("\tvec2 smallDims = vec2(width - %s, height-%s);\n",
profileSizeName, profileSizeName); | 672 builder->fsCodeAppendf("\tvec2 smallDims = vec2(width - %s, height-%s);\n",
profileSizeName, profileSizeName); |
673 builder->fsCodeAppendf("\tfloat center = 2.0 * floor(%s/2 + .25) - 1;\n", pr
ofileSizeName); | 673 builder->fsCodeAppendf("\tfloat center = 2.0 * floor(%s/2.0 + .25) - 1.0;\n"
, profileSizeName); |
674 builder->fsCodeAppendf("\tvec2 wh = smallDims - vec2(center,center);\n"); | 674 builder->fsCodeAppendf("\tvec2 wh = smallDims - vec2(center,center);\n"); |
675 | 675 |
676 builder->fsCodeAppendf("\tfloat horiz_lookup;\n"); | 676 builder->fsCodeAppendf("\tfloat horiz_lookup;\n"); |
677 builder->fsCodeAppendf("\tif (%s <= smallDims.x) {\n", profileSizeName); | 677 builder->fsCodeAppendf("\tif (%s <= smallDims.x) {\n", profileSizeName); |
678 OutputRectBlurProfileLookup(builder, samplers[0], "horiz_lookup", profileSiz
eName, "translatedPos.x", "width", "wh.x"); | 678 OutputRectBlurProfileLookup(builder, samplers[0], "horiz_lookup", profileSiz
eName, "translatedPos.x", "width", "wh.x"); |
679 builder->fsCodeAppendf("\t}\n"); | 679 builder->fsCodeAppendf("\t}\n"); |
680 | 680 |
681 builder->fsCodeAppendf("\tfloat vert_lookup;\n"); | 681 builder->fsCodeAppendf("\tfloat vert_lookup;\n"); |
682 builder->fsCodeAppendf("\tif (%s <= smallDims.y) {\n", profileSizeName); | 682 builder->fsCodeAppendf("\tif (%s <= smallDims.y) {\n", profileSizeName); |
683 OutputRectBlurProfileLookup(builder, samplers[0], "vert_lookup", profileSize
Name, "translatedPos.y", "height", "wh.y"); | 683 OutputRectBlurProfileLookup(builder, samplers[0], "vert_lookup", profileSize
Name, "translatedPos.y", "height", "wh.y"); |
684 builder->fsCodeAppendf("\t}\n"); | 684 builder->fsCodeAppendf("\t}\n"); |
685 | 685 |
686 builder->fsCodeAppendf("\tfloat final = 1.0 - horiz_lookup * vert_lookup;\n"
); | 686 builder->fsCodeAppendf("\tfloat final = 1.0 - horiz_lookup * vert_lookup;\n"
); |
687 | 687 |
688 builder->fsCodeAppendf("\t%s = vec4(final, final, final, 1);\n", outputColor
); | 688 builder->fsCodeAppendf("\t%s = vec4(final, final, final, 1.0);\n", outputCol
or ); |
689 } | 689 } |
690 | 690 |
691 void GrGLRectBlurEffect::setData(const GrGLUniformManager& uman, | 691 void GrGLRectBlurEffect::setData(const GrGLUniformManager& uman, |
692 const GrDrawEffect& drawEffect) { | 692 const GrDrawEffect& drawEffect) { |
693 const GrRectBlurEffect& rbe = drawEffect.castEffect<GrRectBlurEffect>(); | 693 const GrRectBlurEffect& rbe = drawEffect.castEffect<GrRectBlurEffect>(); |
694 SkRect rect = rbe.getRect(); | 694 SkRect rect = rbe.getRect(); |
695 | 695 |
696 uman.set4f(fProxyRectUniform, rect.fLeft, rect.fTop, rect.fRight, rect.fBott
om); | 696 uman.set4f(fProxyRectUniform, rect.fLeft, rect.fTop, rect.fRight, rect.fBott
om); |
697 uman.set1f(fProfileSizeUniform, SkScalarCeilToScalar(6*rbe.getSigma())); | 697 uman.set1f(fProfileSizeUniform, SkScalarCeilToScalar(6*rbe.getSigma())); |
698 } | 698 } |
(...skipping 513 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1212 } else { | 1212 } else { |
1213 str->append("None"); | 1213 str->append("None"); |
1214 } | 1214 } |
1215 str->append("))"); | 1215 str->append("))"); |
1216 } | 1216 } |
1217 #endif | 1217 #endif |
1218 | 1218 |
1219 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(SkBlurMaskFilter) | 1219 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(SkBlurMaskFilter) |
1220 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkBlurMaskFilterImpl) | 1220 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkBlurMaskFilterImpl) |
1221 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END | 1221 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END |
OLD | NEW |