Revert "Reland "Reland "Add new method for storing DrawOpAtlas texture index."""
This reverts commit 3b9c544bf86f930a29231ad997cb6cfad9055f66.
Reason for revert: Probably causing text issues in Chrome
Original change's description:
> Reland "Reland "Add new method for storing DrawOpAtlas texture index.""
>
> This is a reland of dea2f34f09c3d0326b36099b406fa546f2b8fd96
>
> Original change's description:
> > Reland "Add new method for storing DrawOpAtlas texture index."
> >
> > This is a reland of c8b2e615400fe43b74dbbd2d7167bb97bd032f87
> >
> > Original change's description:
> > > Add new method for storing DrawOpAtlas texture index.
> > >
> > > Storing the texture index in the lower bit of each texture coordinate
> > > seems to have issues on certain iOS devices. Rather than do that, we
> > > use the sign of the texture coordinate to act as our storage bit.
> > > To manage encoding 0 we map [0, N] to [-1, -N-1] to represent a bit.
> > >
> > > Change-Id: Ic588ee92cf858915a1833cf482d4b23bd11c1000
> > > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/263561
> > > Commit-Queue: Jim Van Verth <jvanverth@google.com>
> > > Reviewed-by: Brian Osman <brianosman@google.com>
> >
> > Change-Id: I901502c3d83ff9727c51ad4447b0cee733257649
> > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/264566
> > Reviewed-by: Jim Van Verth <jvanverth@google.com>
> > Commit-Queue: Jim Van Verth <jvanverth@google.com>
>
> Change-Id: I000bb74ca57e321084ca2d1d9dc2f0274880c0da
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/264689
> Reviewed-by: Jim Van Verth <jvanverth@google.com>
> Commit-Queue: Jim Van Verth <jvanverth@google.com>
TBR=jvanverth@google.com,brianosman@google.com
Bug: 1045016
# Not skipping CQ checks because original CL landed > 1 day ago.
Change-Id: Ie376c7b3cb359f5378e4dd983a103da81ec92e5d
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/266557
Reviewed-by: Jim Van Verth <jvanverth@google.com>
Commit-Queue: Jim Van Verth <jvanverth@google.com>
diff --git a/src/gpu/ops/GrAtlasTextOp.cpp b/src/gpu/ops/GrAtlasTextOp.cpp
index 24495d2..f790870 100644
--- a/src/gpu/ops/GrAtlasTextOp.cpp
+++ b/src/gpu/ops/GrAtlasTextOp.cpp
@@ -192,22 +192,17 @@
// In the LCD case the color will be garbage, but we'll overwrite it with the texcoords
// and it avoids a lot of conditionals.
auto color = *reinterpret_cast<const SkColor*>(blobVertices + sizeof(SkPoint));
- size_t coordOffset = vertexStride - 2*sizeof(int16_t);
- auto* blobCoordsLT = reinterpret_cast<const int16_t*>(blobVertices + coordOffset);
- auto* blobCoordsRB = reinterpret_cast<const int16_t*>(blobVertices + 3 * vertexStride +
+ size_t coordOffset = vertexStride - 2*sizeof(uint16_t);
+ auto* blobCoordsLT = reinterpret_cast<const uint16_t*>(blobVertices + coordOffset);
+ auto* blobCoordsRB = reinterpret_cast<const uint16_t*>(blobVertices + 3 * vertexStride +
coordOffset);
// Pull out the texel coordinates and texture index bits
- int16_t coordsRectL = blobCoordsLT[0];
- int16_t coordsRectT = blobCoordsLT[1];
- int16_t coordsRectR = blobCoordsRB[0];
- int16_t coordsRectB = blobCoordsRB[1];
- int index0, index1;
-
- std::tie(coordsRectL, coordsRectT, index0) =
- GrDrawOpAtlas::UnpackIndexFromTexCoords(coordsRectL, coordsRectT);
- std::tie(coordsRectR, coordsRectB, index1) =
- GrDrawOpAtlas::UnpackIndexFromTexCoords(coordsRectR, coordsRectB);
- SkASSERT(index0 == index1);
+ uint16_t coordsRectL = blobCoordsLT[0] >> 1;
+ uint16_t coordsRectT = blobCoordsLT[1] >> 1;
+ uint16_t coordsRectR = blobCoordsRB[0] >> 1;
+ uint16_t coordsRectB = blobCoordsRB[1] >> 1;
+ uint16_t pageIndexX = blobCoordsLT[0] & 0x1;
+ uint16_t pageIndexY = blobCoordsLT[1] & 0x1;
int positionRectWidth = positionRect.width();
int positionRectHeight = positionRect.height();
@@ -233,10 +228,10 @@
positionRect.fBottom -= delta;
// Repack texel coordinates and index
- std::tie(coordsRectL, coordsRectT) =
- GrDrawOpAtlas::PackIndexInTexCoords(coordsRectL, coordsRectT, index0);
- std::tie(coordsRectR, coordsRectB) =
- GrDrawOpAtlas::PackIndexInTexCoords(coordsRectR, coordsRectB, index1);
+ coordsRectL = coordsRectL << 1 | pageIndexX;
+ coordsRectT = coordsRectT << 1 | pageIndexY;
+ coordsRectR = coordsRectR << 1 | pageIndexX;
+ coordsRectB = coordsRectB << 1 | pageIndexY;
// Set new positions and coords
SkPoint* currPosition = reinterpret_cast<SkPoint*>(currVertex);
diff --git a/src/gpu/ops/GrSmallPathRenderer.cpp b/src/gpu/ops/GrSmallPathRenderer.cpp
index 500c74e..92f2120 100644
--- a/src/gpu/ops/GrSmallPathRenderer.cpp
+++ b/src/gpu/ops/GrSmallPathRenderer.cpp
@@ -624,20 +624,17 @@
shapeData->fBounds.fRight /= scale;
shapeData->fBounds.fBottom /= scale;
- // Pack the page index into the u and v texture coords
+ // We pack the 2bit page index in the low bit of the u and v texture coords
uint16_t pageIndex = GrDrawOpAtlas::GetPageIndexFromID(id);
SkASSERT(pageIndex < 4);
- int16_t left, top, right, bottom;
- std::tie(left, top, right, bottom) =
- std::make_tuple(atlasLocation.fX + SK_DistanceFieldPad,
- atlasLocation.fY + SK_DistanceFieldPad,
- atlasLocation.fX + SK_DistanceFieldPad + devPathBounds.width(),
- atlasLocation.fY + SK_DistanceFieldPad + devPathBounds.height());
- std::tie(left, top) =
- GrDrawOpAtlas::PackIndexInTexCoords(left, top, pageIndex);
- std::tie(right, bottom) =
- GrDrawOpAtlas::PackIndexInTexCoords(right, bottom, pageIndex);
- shapeData->fTextureCoords.set(left, top, right, bottom);
+ uint16_t uBit = (pageIndex >> 1) & 0x1;
+ uint16_t vBit = pageIndex & 0x1;
+ shapeData->fTextureCoords.set((atlasLocation.fX+SK_DistanceFieldPad) << 1 | uBit,
+ (atlasLocation.fY+SK_DistanceFieldPad) << 1 | vBit,
+ (atlasLocation.fX+SK_DistanceFieldPad+
+ devPathBounds.width()) << 1 | uBit,
+ (atlasLocation.fY+SK_DistanceFieldPad+
+ devPathBounds.height()) << 1 | vBit);
fShapeCache->add(shapeData);
fShapeList->addToTail(shapeData);
@@ -725,18 +722,14 @@
shapeData->fBounds = SkRect::Make(devPathBounds);
shapeData->fBounds.offset(-translateX, -translateY);
- // Pack the page index into the u and v texture coords
+ // We pack the 2bit page index in the low bit of the u and v texture coords
uint16_t pageIndex = GrDrawOpAtlas::GetPageIndexFromID(id);
SkASSERT(pageIndex < 4);
- int16_t left, top, right, bottom;
- std::tie(left, top, right, bottom) = std::make_tuple(atlasLocation.fX, atlasLocation.fY,
- atlasLocation.fX+width,
- atlasLocation.fY+height);
- std::tie(left, top) =
- GrDrawOpAtlas::PackIndexInTexCoords(left, top, pageIndex);
- std::tie(right, bottom) =
- GrDrawOpAtlas::PackIndexInTexCoords(right, bottom, pageIndex);
- shapeData->fTextureCoords.set(left, top, right, bottom);
+ uint16_t uBit = (pageIndex >> 1) & 0x1;
+ uint16_t vBit = pageIndex & 0x1;
+ shapeData->fTextureCoords.set(atlasLocation.fX << 1 | uBit, atlasLocation.fY << 1 | vBit,
+ (atlasLocation.fX+width) << 1 | uBit,
+ (atlasLocation.fY+height) << 1 | vBit);
fShapeCache->add(shapeData);
fShapeList->addToTail(shapeData);