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 #ifndef GrTextureDomainEffect_DEFINED | 8 #ifndef GrTextureDomainEffect_DEFINED |
9 #define GrTextureDomainEffect_DEFINED | 9 #define GrTextureDomainEffect_DEFINED |
10 | 10 |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
62 SkScalar hInv = SK_Scalar1 / texture->height(); | 62 SkScalar hInv = SK_Scalar1 / texture->height(); |
63 SkRect result = { | 63 SkRect result = { |
64 texelRect.fLeft * wInv, | 64 texelRect.fLeft * wInv, |
65 texelRect.fTop * hInv, | 65 texelRect.fTop * hInv, |
66 texelRect.fRight * wInv, | 66 texelRect.fRight * wInv, |
67 texelRect.fBottom * hInv | 67 texelRect.fBottom * hInv |
68 }; | 68 }; |
69 return result; | 69 return result; |
70 } | 70 } |
71 | 71 |
| 72 static const SkRect MakeTexelDomainForMode(const GrTexture* texture, const S
kIRect& texelRect, Mode mode) { |
| 73 // For Clamp mode, inset by half a texel. |
| 74 SkScalar wInv = SK_Scalar1 / texture->width(); |
| 75 SkScalar hInv = SK_Scalar1 / texture->height(); |
| 76 SkScalar inset = (mode == kClamp_Mode && !texelRect.isEmpty()) ? SK_Scal
arHalf : 0; |
| 77 return SkRect::MakeLTRB( |
| 78 (texelRect.fLeft + inset) * wInv, |
| 79 (texelRect.fTop + inset) * hInv, |
| 80 (texelRect.fRight - inset) * wInv, |
| 81 (texelRect.fBottom - inset) * hInv |
| 82 ); |
| 83 } |
| 84 |
72 bool operator== (const GrTextureDomain& that) const { | 85 bool operator== (const GrTextureDomain& that) const { |
73 return fMode == that.fMode && (kIgnore_Mode == fMode || fDomain == that.
fDomain); | 86 return fMode == that.fMode && (kIgnore_Mode == fMode || fDomain == that.
fDomain); |
74 } | 87 } |
75 | 88 |
76 /** | 89 /** |
77 * A GrGLProcessor subclass that corresponds to a GrProcessor subclass that
uses GrTextureDomain | 90 * A GrGLProcessor subclass that corresponds to a GrProcessor subclass that
uses GrTextureDomain |
78 * should include this helper. It generates the texture domain GLSL, produce
s the part of the | 91 * should include this helper. It generates the texture domain GLSL, produce
s the part of the |
79 * effect key that reflects the texture domain code, and performs the unifor
m uploads necessary | 92 * effect key that reflects the texture domain code, and performs the unifor
m uploads necessary |
80 * for texture domains. | 93 * for texture domains. |
81 */ | 94 */ |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
175 bool onIsEqual(const GrFragmentProcessor&) const override; | 188 bool onIsEqual(const GrFragmentProcessor&) const override; |
176 | 189 |
177 void onComputeInvariantOutput(GrInvariantOutput* inout) const override; | 190 void onComputeInvariantOutput(GrInvariantOutput* inout) const override; |
178 | 191 |
179 GR_DECLARE_FRAGMENT_PROCESSOR_TEST; | 192 GR_DECLARE_FRAGMENT_PROCESSOR_TEST; |
180 | 193 |
181 typedef GrSingleTextureEffect INHERITED; | 194 typedef GrSingleTextureEffect INHERITED; |
182 }; | 195 }; |
183 | 196 |
184 #endif | 197 #endif |
OLD | NEW |