summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlex Sakhartchouk <alexst@google.com>2010-08-05 11:24:14 -0700
committerAlex Sakhartchouk <alexst@google.com>2010-08-05 11:24:14 -0700
commit55e81983562ca507883f32f817e9d24e1c49b909 (patch)
tree47cc8923a42cde3305c6304c4d06cc3c23d20bc4
parent518f033b68649c151cc8725ea8c557eae01cc567 (diff)
downloadframeworks_base-55e81983562ca507883f32f817e9d24e1c49b909.zip
frameworks_base-55e81983562ca507883f32f817e9d24e1c49b909.tar.gz
frameworks_base-55e81983562ca507883f32f817e9d24e1c49b909.tar.bz2
Fixing fonts to use constant color instead of variable.
Change-Id: Ia590dfed482f82b7bc748c25b7b1592efea5b68c
-rw-r--r--libs/rs/java/ModelViewer/src/com/android/modelviewer/modelviewer.rs2
-rw-r--r--libs/rs/rsContext.cpp32
-rw-r--r--libs/rs/rsFont.cpp14
-rw-r--r--libs/rs/rsFont.h1
4 files changed, 21 insertions, 28 deletions
diff --git a/libs/rs/java/ModelViewer/src/com/android/modelviewer/modelviewer.rs b/libs/rs/java/ModelViewer/src/com/android/modelviewer/modelviewer.rs
index 41594eb..adb609c 100644
--- a/libs/rs/java/ModelViewer/src/com/android/modelviewer/modelviewer.rs
+++ b/libs/rs/java/ModelViewer/src/com/android/modelviewer/modelviewer.rs
@@ -62,7 +62,7 @@ int root(int launchID) {
rsgDrawMesh(gTestMesh);
- color(0.3f, 0.3f, 0.3f, 1.0f);
+ rsgFontColor(0.3f, 0.3f, 0.3f, 1.0f);
rsgDrawText("Renderscript model test", 30, 695);
rsgBindFont(gItalic);
diff --git a/libs/rs/rsContext.cpp b/libs/rs/rsContext.cpp
index 681f83e..dfdeb98 100644
--- a/libs/rs/rsContext.cpp
+++ b/libs/rs/rsContext.cpp
@@ -263,38 +263,18 @@ void Context::displayDebugStats()
{
char buffer[128];
sprintf(buffer, "Frame %i ms, Script %i ms", mTimeMSLastFrame, mTimeMSLastScript);
- /*float oldR = mStateVertex.color[0];
- float oldG = mStateVertex.color[1];
- float oldB = mStateVertex.color[2];
- float oldA = mStateVertex.color[3];*/
+ float oldR, oldG, oldB, oldA;
+ mStateFont.getFontColor(&oldR, &oldG, &oldB, &oldA);
float shadowCol = 0.2f;
- /*mStateVertex.color[0] = shadowCol;
- mStateVertex.color[1] = shadowCol;
- mStateVertex.color[2] = shadowCol;
- mStateVertex.color[3] = 1.0f;
- if (!checkVersion2_0()) {
- glColor4f(shadowCol, shadowCol, shadowCol, 1.0f);
- }*/
+ mStateFont.setFontColor(shadowCol, shadowCol, shadowCol, 1.0f);
mStateFont.renderText(buffer, 5, getHeight() - 5);
- /*float textCol = 0.9f;
- mStateVertex.color[0] = textCol;
- mStateVertex.color[1] = textCol;
- mStateVertex.color[2] = textCol;
- mStateVertex.color[3] = 1.0f;
- if (!checkVersion2_0()) {
- glColor4f(textCol, textCol, textCol, 1.0f);
- }*/
+ float textCol = 0.9f;
+ mStateFont.setFontColor(textCol, textCol, textCol, 1.0f);
mStateFont.renderText(buffer, 4, getHeight() - 6);
- /*mStateVertex.color[0] = oldR;
- mStateVertex.color[1] = oldG;
- mStateVertex.color[2] = oldB;
- mStateVertex.color[3] = oldA;
- if (!checkVersion2_0()) {
- glColor4f(oldR, oldG, oldB, oldA);
- }*/
+ mStateFont.setFontColor(oldR, oldG, oldB, oldA);
}
void * Context::threadProc(void *vrsc)
diff --git a/libs/rs/rsFont.cpp b/libs/rs/rsFont.cpp
index a741adc..833bee0 100644
--- a/libs/rs/rsFont.cpp
+++ b/libs/rs/rsFont.cpp
@@ -259,7 +259,7 @@ FontState::FontState()
mCurrentQuadIndex = 0;
mRSC = NULL;
mLibrary = NULL;
- setFontColor(0.0f, 0.0f, 0.0f, 1.0f);
+ setFontColor(0.1f, 0.1f, 0.1f, 1.0f);
}
FontState::~FontState()
@@ -521,6 +521,11 @@ void FontState::issueDrawCommand() {
ObjectBaseRef<const ProgramStore> tmpPS(mRSC->getFragmentStore());
mRSC->setFragmentStore(mFontProgramStore.get());
+ if(mFontColorDirty) {
+ mFontShaderF->setConstantColor(mFontColor[0], mFontColor[1], mFontColor[2], mFontColor[3]);
+ mFontColorDirty = false;
+ }
+
if (!mRSC->setupCheck()) {
mRSC->setVertex((ProgramVertex *)tmpV.get());
mRSC->setRaster((ProgramRaster *)tmpR.get());
@@ -669,6 +674,13 @@ void FontState::setFontColor(float r, float g, float b, float a) {
mFontColorDirty = true;
}
+void FontState::getFontColor(float *r, float *g, float *b, float *a) const {
+ *r = mFontColor[0];
+ *g = mFontColor[1];
+ *b = mFontColor[2];
+ *a = mFontColor[3];
+}
+
void FontState::deinit(Context *rsc)
{
mInitialized = false;
diff --git a/libs/rs/rsFont.h b/libs/rs/rsFont.h
index 2d9a34a..ab229be 100644
--- a/libs/rs/rsFont.h
+++ b/libs/rs/rsFont.h
@@ -117,6 +117,7 @@ public:
void renderText(Allocation *alloc, uint32_t start, int len, int x, int y);
void setFontColor(float r, float g, float b, float a);
+ void getFontColor(float *r, float *g, float *b, float *a) const;
protected: