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 ? SK_ScalarHalf : 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 | |
85 bool operator== (const GrTextureDomain& that) const { | 72 bool operator== (const GrTextureDomain& that) const { |
86 return fMode == that.fMode && (kIgnore_Mode == fMode || fDomain == that.
fDomain); | 73 return fMode == that.fMode && (kIgnore_Mode == fMode || fDomain == that.
fDomain); |
87 } | 74 } |
88 | 75 |
89 /** | 76 /** |
90 * A GrGLProcessor subclass that corresponds to a GrProcessor subclass that
uses GrTextureDomain | 77 * A GrGLProcessor subclass that corresponds to a GrProcessor subclass that
uses GrTextureDomain |
91 * should include this helper. It generates the texture domain GLSL, produce
s the part of the | 78 * should include this helper. It generates the texture domain GLSL, produce
s the part of the |
92 * effect key that reflects the texture domain code, and performs the unifor
m uploads necessary | 79 * effect key that reflects the texture domain code, and performs the unifor
m uploads necessary |
93 * for texture domains. | 80 * for texture domains. |
94 */ | 81 */ |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
188 bool onIsEqual(const GrFragmentProcessor&) const override; | 175 bool onIsEqual(const GrFragmentProcessor&) const override; |
189 | 176 |
190 void onComputeInvariantOutput(GrInvariantOutput* inout) const override; | 177 void onComputeInvariantOutput(GrInvariantOutput* inout) const override; |
191 | 178 |
192 GR_DECLARE_FRAGMENT_PROCESSOR_TEST; | 179 GR_DECLARE_FRAGMENT_PROCESSOR_TEST; |
193 | 180 |
194 typedef GrSingleTextureEffect INHERITED; | 181 typedef GrSingleTextureEffect INHERITED; |
195 }; | 182 }; |
196 | 183 |
197 #endif | 184 #endif |
OLD | NEW |