summaryrefslogtreecommitdiffstats
path: root/libs/hwui
diff options
context:
space:
mode:
authorAlex Sakhartchouk <alexst@google.com>2011-02-17 16:45:37 -0800
committerAlex Sakhartchouk <alexst@google.com>2011-02-17 16:45:37 -0800
commit894df17eee708688c8a6e67941add2017239c790 (patch)
tree6bdce5bbcd62d824227c9e9f30e78db40bba5988 /libs/hwui
parent2e10374dceea41ebab13e5d2834f6767f2c23b3d (diff)
downloadframeworks_base-894df17eee708688c8a6e67941add2017239c790.zip
frameworks_base-894df17eee708688c8a6e67941add2017239c790.tar.gz
frameworks_base-894df17eee708688c8a6e67941add2017239c790.tar.bz2
Fixing font renderer attribute slot locations.
Change-Id: I6377bb641df7d8372d873c00790189f9a190afd6
Diffstat (limited to 'libs/hwui')
-rw-r--r--libs/hwui/FontRenderer.cpp16
-rw-r--r--libs/hwui/FontRenderer.h8
-rw-r--r--libs/hwui/OpenGLRenderer.cpp6
3 files changed, 22 insertions, 8 deletions
diff --git a/libs/hwui/FontRenderer.cpp b/libs/hwui/FontRenderer.cpp
index 0042f49..8bae684 100644
--- a/libs/hwui/FontRenderer.cpp
+++ b/libs/hwui/FontRenderer.cpp
@@ -316,6 +316,8 @@ FontRenderer::FontRenderer() {
mTextTexture = NULL;
mIndexBufferID = 0;
+ mPositionAttrSlot = -1;
+ mTexcoordAttrSlot = -1;
mCacheWidth = DEFAULT_TEXT_CACHE_WIDTH;
mCacheHeight = DEFAULT_TEXT_CACHE_HEIGHT;
@@ -565,13 +567,8 @@ void FontRenderer::issueDrawCommand() {
float* vtx = mTextMeshPtr;
float* tex = vtx + 3;
- // position is slot 0
- uint32_t slot = 0;
- glVertexAttribPointer(slot, 3, GL_FLOAT, false, 20, vtx);
-
- // texture0 is slot 1
- slot = 1;
- glVertexAttribPointer(slot, 2, GL_FLOAT, false, 20, tex);
+ glVertexAttribPointer(mPositionAttrSlot, 3, GL_FLOAT, false, 20, vtx);
+ glVertexAttribPointer(mTexcoordAttrSlot, 2, GL_FLOAT, false, 20, tex);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, mIndexBufferID);
glDrawElements(GL_TRIANGLES, mCurrentQuadIndex * 6, GL_UNSIGNED_SHORT, NULL);
@@ -718,6 +715,11 @@ bool FontRenderer::renderText(SkPaint* paint, const Rect* clip, const char *text
return false;
}
+ if (mPositionAttrSlot < 0 || mTexcoordAttrSlot < 0) {
+ LOGE("Font renderer unable to draw, attribute slots undefined");
+ return false;
+ }
+
mDrawn = false;
mBounds = bounds;
mClip = clip;
diff --git a/libs/hwui/FontRenderer.h b/libs/hwui/FontRenderer.h
index 1005812..46f332e 100644
--- a/libs/hwui/FontRenderer.h
+++ b/libs/hwui/FontRenderer.h
@@ -138,6 +138,11 @@ public:
mGammaTable = gammaTable;
}
+ void setAttributeBindingSlots(int positionSlot, int texCoordSlot) {
+ mPositionAttrSlot = positionSlot;
+ mTexcoordAttrSlot = texCoordSlot;
+ }
+
void setFont(SkPaint* paint, uint32_t fontId, float fontSize);
bool renderText(SkPaint* paint, const Rect* clip, const char *text, uint32_t startIndex,
uint32_t len, int numGlyphs, int x, int y, Rect* bounds);
@@ -263,6 +268,9 @@ protected:
uint32_t mIndexBufferID;
+ int32_t mPositionAttrSlot;
+ int32_t mTexcoordAttrSlot;
+
const Rect* mClip;
Rect* mBounds;
bool mDrawn;
diff --git a/libs/hwui/OpenGLRenderer.cpp b/libs/hwui/OpenGLRenderer.cpp
index 68b54fe..4a08f53 100644
--- a/libs/hwui/OpenGLRenderer.cpp
+++ b/libs/hwui/OpenGLRenderer.cpp
@@ -1585,8 +1585,12 @@ void OpenGLRenderer::drawText(const char* text, int bytesCount, int count,
#else
bool hasActiveLayer = false;
#endif
-
mCaches.unbindMeshBuffer();
+
+ // Tell font renderer the locations of position and texture coord
+ // attributes so it can bind its data properly
+ int positionSlot = mCaches.currentProgram->position;
+ fontRenderer.setAttributeBindingSlots(positionSlot, mTexCoordsSlot);
if (fontRenderer.renderText(paint, clip, text, 0, bytesCount, count, x, y,
hasActiveLayer ? &bounds : NULL)) {
#if RENDER_LAYERS_AS_REGIONS