| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2012 Google Inc. | 2 * Copyright 2012 Google Inc. |
| 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 "GrConvolutionEffect.h" | 8 #include "GrConvolutionEffect.h" |
| 9 #include "gl/GrGLEffect.h" | 9 #include "gl/GrGLEffect.h" |
| 10 #include "gl/GrGLSL.h" | 10 #include "gl/GrGLSL.h" |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 113 switch (conv.direction()) { | 113 switch (conv.direction()) { |
| 114 case Gr1DKernelEffect::kX_Direction: | 114 case Gr1DKernelEffect::kX_Direction: |
| 115 imageIncrement[0] = 1.0f / texture.width(); | 115 imageIncrement[0] = 1.0f / texture.width(); |
| 116 break; | 116 break; |
| 117 case Gr1DKernelEffect::kY_Direction: | 117 case Gr1DKernelEffect::kY_Direction: |
| 118 imageIncrement[1] = ySign / texture.height(); | 118 imageIncrement[1] = ySign / texture.height(); |
| 119 break; | 119 break; |
| 120 default: | 120 default: |
| 121 GrCrash("Unknown filter direction."); | 121 GrCrash("Unknown filter direction."); |
| 122 } | 122 } |
| 123 uman.set2fv(fImageIncrementUni, 0, 1, imageIncrement); | 123 uman.set2fv(fImageIncrementUni, 1, imageIncrement); |
| 124 if (conv.useBounds()) { | 124 if (conv.useBounds()) { |
| 125 const float* bounds = conv.bounds(); | 125 const float* bounds = conv.bounds(); |
| 126 if (Gr1DKernelEffect::kY_Direction == conv.direction() && | 126 if (Gr1DKernelEffect::kY_Direction == conv.direction() && |
| 127 texture.origin() != kTopLeft_GrSurfaceOrigin) { | 127 texture.origin() != kTopLeft_GrSurfaceOrigin) { |
| 128 uman.set2f(fBoundsUni, 1.0f - bounds[1], 1.0f - bounds[0]); | 128 uman.set2f(fBoundsUni, 1.0f - bounds[1], 1.0f - bounds[0]); |
| 129 } else { | 129 } else { |
| 130 uman.set2f(fBoundsUni, bounds[0], bounds[1]); | 130 uman.set2f(fBoundsUni, bounds[0], bounds[1]); |
| 131 } | 131 } |
| 132 } | 132 } |
| 133 uman.set1fv(fKernelUni, 0, this->width(), conv.kernel()); | 133 uman.set1fv(fKernelUni, this->width(), conv.kernel()); |
| 134 } | 134 } |
| 135 | 135 |
| 136 GrGLEffect::EffectKey GrGLConvolutionEffect::GenKey(const GrDrawEffect& drawEffe
ct, | 136 GrGLEffect::EffectKey GrGLConvolutionEffect::GenKey(const GrDrawEffect& drawEffe
ct, |
| 137 const GrGLCaps&) { | 137 const GrGLCaps&) { |
| 138 const GrConvolutionEffect& conv = drawEffect.castEffect<GrConvolutionEffect>
(); | 138 const GrConvolutionEffect& conv = drawEffect.castEffect<GrConvolutionEffect>
(); |
| 139 EffectKey key = conv.radius(); | 139 EffectKey key = conv.radius(); |
| 140 key <<= 2; | 140 key <<= 2; |
| 141 if (conv.useBounds()) { | 141 if (conv.useBounds()) { |
| 142 key |= 0x2; | 142 key |= 0x2; |
| 143 key |= GrConvolutionEffect::kY_Direction == conv.direction() ? 0x1 : 0x0
; | 143 key |= GrConvolutionEffect::kY_Direction == conv.direction() ? 0x1 : 0x0
; |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 229 } | 229 } |
| 230 | 230 |
| 231 bool useBounds = random->nextBool(); | 231 bool useBounds = random->nextBool(); |
| 232 return GrConvolutionEffect::Create(textures[texIdx], | 232 return GrConvolutionEffect::Create(textures[texIdx], |
| 233 dir, | 233 dir, |
| 234 radius, | 234 radius, |
| 235 kernel, | 235 kernel, |
| 236 useBounds, | 236 useBounds, |
| 237 bounds); | 237 bounds); |
| 238 } | 238 } |
| OLD | NEW |