diff options
author | benjaminwagner <benjaminwagner@google.com> | 2016-02-22 11:10:33 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-02-22 11:10:33 -0800 |
commit | 01e583807618038a578a3b07cfad3101d24115c7 (patch) | |
tree | 6f9e7fb3787bdfc7df448607eab10c56699e8989 /src | |
parent | f47b9a3b88a037a481eb70f01a4cf9f5be34dc28 (diff) |
Simplify calculations in AADistanceFieldPathBatch::writePathVertices.
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
Diffstat (limited to 'src')
-rw-r--r-- | src/gpu/GrTexture.cpp | 3 | ||||
-rw-r--r-- | src/gpu/GrTexturePriv.h | 11 | ||||
-rw-r--r-- | src/gpu/batches/GrAADistanceFieldPathRenderer.cpp | 16 |
3 files changed, 7 insertions, 23 deletions
diff --git a/src/gpu/GrTexture.cpp b/src/gpu/GrTexture.cpp index fe5b2c3c37..76916aee9a 100644 --- a/src/gpu/GrTexture.cpp +++ b/src/gpu/GrTexture.cpp @@ -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) { diff --git a/src/gpu/GrTexturePriv.h b/src/gpu/GrTexturePriv.h index da0558e574..165594c37a 100644 --- a/src/gpu/GrTexturePriv.h +++ b/src/gpu/GrTexturePriv.h @@ -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) { } diff --git a/src/gpu/batches/GrAADistanceFieldPathRenderer.cpp b/src/gpu/batches/GrAADistanceFieldPathRenderer.cpp index d48649cd27..8525eb2fde 100644 --- a/src/gpu/batches/GrAADistanceFieldPathRenderer.cpp +++ b/src/gpu/batches/GrAADistanceFieldPathRenderer.cpp @@ -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); } |