summaryrefslogtreecommitdiffstats
path: root/libs/hwui/FontRenderer.cpp
diff options
context:
space:
mode:
authorRomain Guy <romainguy@google.com>2010-10-27 18:57:51 -0700
committerRomain Guy <romainguy@google.com>2010-11-02 16:17:23 -0700
commit5b3b35296e8b2c8d3f07d32bb645d5414db41a1d (patch)
treebad2ebdbfeb8a3a0be1591d5a357a8280df7d1d2 /libs/hwui/FontRenderer.cpp
parent2444ddb3d9b59ec45ba50858fcbff639e59b93b1 (diff)
downloadframeworks_base-5b3b35296e8b2c8d3f07d32bb645d5414db41a1d.zip
frameworks_base-5b3b35296e8b2c8d3f07d32bb645d5414db41a1d.tar.gz
frameworks_base-5b3b35296e8b2c8d3f07d32bb645d5414db41a1d.tar.bz2
Optimize FBO drawing with regions.
This optimization is currently disabled until Launcher is modified to take advantage of it. The optimization can be enabled by turning on RENDER_LAYERS_AS_REGIONS in the OpenGLRenderer.h file. Change-Id: I2fdf59d0f4dc690a3d7f712173ab8db3848b27b1
Diffstat (limited to 'libs/hwui/FontRenderer.cpp')
-rw-r--r--libs/hwui/FontRenderer.cpp20
1 files changed, 17 insertions, 3 deletions
diff --git a/libs/hwui/FontRenderer.cpp b/libs/hwui/FontRenderer.cpp
index e1a236c..5224689 100644
--- a/libs/hwui/FontRenderer.cpp
+++ b/libs/hwui/FontRenderer.cpp
@@ -556,6 +556,8 @@ void FontRenderer::issueDrawCommand() {
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, mIndexBufferID);
glDrawElements(GL_TRIANGLES, mCurrentQuadIndex * 6, GL_UNSIGNED_SHORT, NULL);
+
+ mDrawn = true;
}
void FontRenderer::appendMeshQuad(float x1, float y1, float z1, float u1, float v1, float x2,
@@ -595,6 +597,13 @@ void FontRenderer::appendMeshQuad(float x1, float y1, float z1, float u1, float
mCurrentQuadIndex++;
+ if (mBounds) {
+ mBounds->left = fmin(mBounds->left, x1);
+ mBounds->top = fmin(mBounds->top, y3);
+ mBounds->right = fmax(mBounds->right, x3);
+ mBounds->bottom = fmax(mBounds->bottom, y1);
+ }
+
if (mCurrentQuadIndex == mMaxNumberOfQuads) {
issueDrawCommand();
mCurrentQuadIndex = 0;
@@ -674,22 +683,27 @@ FontRenderer::DropShadow FontRenderer::renderDropShadow(SkPaint* paint, const ch
return image;
}
-void FontRenderer::renderText(SkPaint* paint, const Rect* clip, const char *text,
- uint32_t startIndex, uint32_t len, int numGlyphs, int x, int y) {
+bool FontRenderer::renderText(SkPaint* paint, const Rect* clip, const char *text,
+ uint32_t startIndex, uint32_t len, int numGlyphs, int x, int y, Rect* bounds) {
checkInit();
if (!mCurrentFont) {
LOGE("No font set");
- return;
+ return false;
}
+ mDrawn = false;
+ mBounds = bounds;
mClip = clip;
mCurrentFont->renderUTF(paint, text, startIndex, len, numGlyphs, x, y);
+ mBounds = NULL;
if (mCurrentQuadIndex != 0) {
issueDrawCommand();
mCurrentQuadIndex = 0;
}
+
+ return mDrawn;
}
void FontRenderer::computeGaussianWeights(float* weights, int32_t radius) {