Index: src/gpu/effects/GrTextureDomain.h |
diff --git a/src/gpu/effects/GrTextureDomain.h b/src/gpu/effects/GrTextureDomain.h |
index 7efd9f2dee1850d1d054582be3e577b9df5ff829..6a462f96a8c77bdbce1396783679fb92122d3a17 100644 |
--- a/src/gpu/effects/GrTextureDomain.h |
+++ b/src/gpu/effects/GrTextureDomain.h |
@@ -69,6 +69,19 @@ public: |
return result; |
} |
+ static const SkRect MakeTexelDomainForMode(const GrTexture* texture, const SkIRect& texelRect, Mode mode) { |
+ // For Clamp mode, inset by half a texel. |
+ SkScalar wInv = SK_Scalar1 / texture->width(); |
+ SkScalar hInv = SK_Scalar1 / texture->height(); |
+ SkScalar inset = (mode == kClamp_Mode && !texelRect.isEmpty()) ? SK_ScalarHalf : 0; |
+ return SkRect::MakeLTRB( |
+ (texelRect.fLeft + inset) * wInv, |
+ (texelRect.fTop + inset) * hInv, |
+ (texelRect.fRight - inset) * wInv, |
+ (texelRect.fBottom - inset) * hInv |
+ ); |
+ } |
+ |
bool operator== (const GrTextureDomain& that) const { |
return fMode == that.fMode && (kIgnore_Mode == fMode || fDomain == that.fDomain); |
} |