Revert "Add new method for storing DrawOpAtlas texture index."
This reverts commit c8b2e615400fe43b74dbbd2d7167bb97bd032f87.
Reason for revert: Seeing multitexture failures on Gold
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>
TBR=jvanverth@google.com,brianosman@google.com
Change-Id: I9ba28eb800e608fb5ee1ce877b5ab8b5b99db261
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/264421
Reviewed-by: Jim Van Verth <jvanverth@google.com>
Commit-Queue: Jim Van Verth <jvanverth@google.com>
diff --git a/src/gpu/text/GrTextBlob.cpp b/src/gpu/text/GrTextBlob.cpp
index 45ba8df..894a227 100644
--- a/src/gpu/text/GrTextBlob.cpp
+++ b/src/gpu/text/GrTextBlob.cpp
@@ -228,14 +228,14 @@
const size_t vertexStride = this->vertexStride();
const size_t texCoordOffset = this->texCoordOffset();
char* vertex = this->quadStart(begin);
- int16_t* textureCoords = reinterpret_cast<int16_t*>(vertex + texCoordOffset);
+ uint16_t* textureCoords = reinterpret_cast<uint16_t*>(vertex + texCoordOffset);
for (int i = begin; i < end; i++) {
GrGlyph* glyph = this->fGlyphs[i];
SkASSERT(glyph != nullptr);
int width = glyph->fBounds.width();
int height = glyph->fBounds.height();
- int16_t u0, v0, u1, v1;
+ uint16_t u0, v0, u1, v1;
if (this->drawAsDistanceFields()) {
u0 = glyph->fAtlasLocation.fX + SK_DistanceFieldInset;
v0 = glyph->fAtlasLocation.fY + SK_DistanceFieldInset;
@@ -248,23 +248,32 @@
v1 = v0 + height;
}
- // We pack the 2bit page index as the sign bit of the u and v texture coords
+ // We pack the 2bit page index in the low bit of the u and v texture coords
uint32_t pageIndex = glyph->pageIndex();
- std::tie(u0, v0) = GrDrawOpAtlas::PackIndexInTexCoords(u0, v0, pageIndex);
- std::tie(u1, v1) = GrDrawOpAtlas::PackIndexInTexCoords(u1, v1, pageIndex);
+ SkASSERT(pageIndex < 4);
+ uint16_t uBit = (pageIndex >> 1u) & 0x1u;
+ uint16_t vBit = pageIndex & 0x1u;
+ u0 <<= 1u;
+ u0 |= uBit;
+ v0 <<= 1u;
+ v0 |= vBit;
+ u1 <<= 1u;
+ u1 |= uBit;
+ v1 <<= 1u;
+ v1 |= vBit;
textureCoords[0] = u0;
textureCoords[1] = v0;
- textureCoords = SkTAddOffset<int16_t>(textureCoords, vertexStride);
+ textureCoords = SkTAddOffset<uint16_t>(textureCoords, vertexStride);
textureCoords[0] = u0;
textureCoords[1] = v1;
- textureCoords = SkTAddOffset<int16_t>(textureCoords, vertexStride);
+ textureCoords = SkTAddOffset<uint16_t>(textureCoords, vertexStride);
textureCoords[0] = u1;
textureCoords[1] = v0;
- textureCoords = SkTAddOffset<int16_t>(textureCoords, vertexStride);
+ textureCoords = SkTAddOffset<uint16_t>(textureCoords, vertexStride);
textureCoords[0] = u1;
textureCoords[1] = v1;
- textureCoords = SkTAddOffset<int16_t>(textureCoords, vertexStride);
+ textureCoords = SkTAddOffset<uint16_t>(textureCoords, vertexStride);
}
}