Simplify calculations in AADistanceFieldPathBatch::writePathVertices.
authorbenjaminwagner <benjaminwagner@google.com>
Mon, 22 Feb 2016 19:10:33 +0000 (11:10 -0800)
committerCommit bot <commit-bot@chromium.org>
Mon, 22 Feb 2016 19:10:33 +0000 (11:10 -0800)
No API changes.

BUG=skia:4632
GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1715063002
TBR=reed

Review URL: https://codereview.chromium.org/1715063002

include/gpu/GrTexture.h
src/gpu/GrTexture.cpp
src/gpu/GrTexturePriv.h
src/gpu/batches/GrAADistanceFieldPathRenderer.cpp

index ddba940..c590d87 100644 (file)
@@ -60,10 +60,6 @@ private:
     };
 
     MipMapsStatus   fMipMapsStatus;
-    // These two shift a fixed-point value into normalized coordinates 
-    // for this texture if the texture is power of two sized.
-    int             fShiftFixedX;
-    int             fShiftFixedY;
 
     friend class GrTexturePriv;
 
index fe5b2c3..76916ae 100644 (file)
@@ -91,9 +91,6 @@ GrTexture::GrTexture(GrGpu* gpu, LifeCycle lifeCycle, const GrSurfaceDesc& desc)
         GrTexturePriv::ComputeScratchKey(desc, &key);
         this->setScratchKey(key);
     }
-    // only make sense if alloc size is pow2
-    fShiftFixedX = 31 - SkCLZ(fDesc.fWidth);
-    fShiftFixedY = 31 - SkCLZ(fDesc.fHeight);
 }
 
 void GrTexturePriv::ComputeScratchKey(const GrSurfaceDesc& desc, GrScratchKey* key) {
index da0558e..165594c 100644 (file)
@@ -41,17 +41,6 @@ public:
 
     static void ComputeScratchKey(const GrSurfaceDesc&, GrScratchKey*);
 
-    // TODO: Move this logic and the shift values out of here and to the callers.
-    SkFixed normalizeFixedX(SkFixed x) const {
-        SkASSERT(SkIsPow2(fTexture->fDesc.fWidth));
-        return x >> fTexture->fShiftFixedX;
-    }
-
-    SkFixed normalizeFixedY(SkFixed y) const {
-        SkASSERT(SkIsPow2(fTexture->fDesc.fHeight));
-        return y >> fTexture->fShiftFixedY;
-    }
-
 private:
     GrTexturePriv(GrTexture* texture) : fTexture(texture) { }
     GrTexturePriv(const GrTexturePriv& that) : fTexture(that.fTexture) { }
index d48649c..8525eb2 100644 (file)
@@ -461,11 +461,6 @@ private:
         width *= invScale;
         height *= invScale;
 
-        SkFixed tx = SkIntToFixed(pathData->fAtlasLocation.fX);
-        SkFixed ty = SkIntToFixed(pathData->fAtlasLocation.fY);
-        SkFixed tw = SkScalarToFixed(pathData->fBounds.width());
-        SkFixed th = SkScalarToFixed(pathData->fBounds.height());
-
         SkPoint* positions = reinterpret_cast<SkPoint*>(offset);
 
         // vertex positions
@@ -479,12 +474,15 @@ private:
             *colorPtr = color;
         }
 
+        const SkScalar tx = SkIntToScalar(pathData->fAtlasLocation.fX);
+        const SkScalar ty = SkIntToScalar(pathData->fAtlasLocation.fY);
+
         // vertex texture coords
         SkPoint* textureCoords = (SkPoint*)(offset + sizeof(SkPoint) + sizeof(GrColor));
-        textureCoords->setRectFan(SkFixedToFloat(texture->texturePriv().normalizeFixedX(tx)),
-                                  SkFixedToFloat(texture->texturePriv().normalizeFixedY(ty)),
-                                  SkFixedToFloat(texture->texturePriv().normalizeFixedX(tx + tw)),
-                                  SkFixedToFloat(texture->texturePriv().normalizeFixedY(ty + th)),
+        textureCoords->setRectFan(tx / texture->width(),
+                                  ty / texture->height(),
+                                  (tx + pathData->fBounds.width()) / texture->width(),
+                                  (ty + pathData->fBounds.height())  / texture->height(),
                                   vertexStride);
     }