diff options
| author | 2013-06-25 14:25:17 -0700 | |
|---|---|---|
| committer | 2013-07-31 15:50:47 -0700 | |
| commit | 1e546815bbb736c50679a8aefc25f48561026fc5 (patch) | |
| tree | 11a3b7106638c123d052d50ce3e2a1757e004cb4 /libs/hwui/OpenGLRenderer.cpp | |
| parent | 3a6f25512c0a682b10961a5a7428e3393ffb0b75 (diff) | |
Support RGBA fonts and bitmap fonts (and RGBA bitmap fonts)
Quite a few things going on in this commit:
- Enable bitmap strikes by default in Paint objects.
The SkPaint parameter that enables bitmap strikes was not previously
included in DEFAULT_PAINT_FLAGS. This effectively disabled bitmap
fonts. Oops! It's for the best, though, as additional work was needed
in Skia to make bitmap fonts work anyway.
- Complain if TEXTURE_BORDER_SIZE is not 1.
Our glyph cache code does not currently handle any value other than 1
here, including zero. I've added a little C preprocessor check to
prevent future engineers (including especially future-me) from
thinking that they can change this value without updating the related
code.
- Add GL_RGBA support to hwui's FontRenderer and friends
This also happened to involve some refactoring for convenience and
cleanliness.
Bug: 9577689
Change-Id: I0abd1e5a0d6623106247fb6421787e2c2f2ea19c
Diffstat (limited to 'libs/hwui/OpenGLRenderer.cpp')
| -rw-r--r-- | libs/hwui/OpenGLRenderer.cpp | 69 |
1 files changed, 4 insertions, 65 deletions
diff --git a/libs/hwui/OpenGLRenderer.cpp b/libs/hwui/OpenGLRenderer.cpp index bc00ce897756..be0cd2afb105 100644 --- a/libs/hwui/OpenGLRenderer.cpp +++ b/libs/hwui/OpenGLRenderer.cpp @@ -2825,48 +2825,6 @@ bool OpenGLRenderer::canSkipText(const SkPaint* paint) const { return alpha == 0.0f && getXfermode(paint->getXfermode()) == SkXfermode::kSrcOver_Mode; } -class TextSetupFunctor: public Functor { -public: - TextSetupFunctor(OpenGLRenderer& renderer, float x, float y, bool pureTranslate, - int alpha, SkXfermode::Mode mode, SkPaint* paint): Functor(), - renderer(renderer), x(x), y(y), pureTranslate(pureTranslate), - alpha(alpha), mode(mode), paint(paint) { - } - ~TextSetupFunctor() { } - - status_t operator ()(int what, void* data) { - renderer.setupDraw(); - renderer.setupDrawTextGamma(paint); - renderer.setupDrawDirtyRegionsDisabled(); - renderer.setupDrawWithTexture(true); - renderer.setupDrawAlpha8Color(paint->getColor(), alpha); - renderer.setupDrawColorFilter(); - renderer.setupDrawShader(); - renderer.setupDrawBlending(true, mode); - renderer.setupDrawProgram(); - renderer.setupDrawModelView(x, y, x, y, pureTranslate, true); - // Calling setupDrawTexture with the name 0 will enable the - // uv attributes and increase the texture unit count - // texture binding will be performed by the font renderer as - // needed - renderer.setupDrawTexture(0); - renderer.setupDrawPureColorUniforms(); - renderer.setupDrawColorFilterUniforms(); - renderer.setupDrawShaderUniforms(pureTranslate); - renderer.setupDrawTextGammaUniforms(); - - return NO_ERROR; - } - - OpenGLRenderer& renderer; - float x; - float y; - bool pureTranslate; - int alpha; - SkXfermode::Mode mode; - SkPaint* paint; -}; - status_t OpenGLRenderer::drawPosText(const char* text, int bytesCount, int count, const float* positions, SkPaint* paint) { if (text == NULL || count == 0 || mSnapshot->isIgnored() || canSkipText(paint)) { @@ -2912,7 +2870,7 @@ status_t OpenGLRenderer::drawPosText(const char* text, int bytesCount, int count const bool hasActiveLayer = hasLayer(); - TextSetupFunctor functor(*this, x, y, pureTranslate, alpha, mode, paint); + TextSetupFunctor functor(this, x, y, pureTranslate, alpha, mode, paint); if (fontRenderer.renderPosText(paint, clip, text, 0, bytesCount, count, x, y, positions, hasActiveLayer ? &bounds : NULL, &functor)) { if (hasActiveLayer) { @@ -3003,7 +2961,7 @@ status_t OpenGLRenderer::drawText(const char* text, int bytesCount, int count, f Rect layerBounds(FLT_MAX / 2.0f, FLT_MAX / 2.0f, FLT_MIN / 2.0f, FLT_MIN / 2.0f); bool status; - TextSetupFunctor functor(*this, x, y, pureTranslate, alpha, mode, paint); + TextSetupFunctor functor(this, x, y, pureTranslate, alpha, mode, paint); // don't call issuedrawcommand, do it at end of batch bool forceFinish = (drawOpMode != kDrawOpMode_Defer); @@ -3045,26 +3003,7 @@ status_t OpenGLRenderer::drawTextOnPath(const char* text, int bytesCount, int co int alpha; SkXfermode::Mode mode; getAlphaAndMode(paint, &alpha, &mode); - - setupDraw(); - setupDrawTextGamma(paint); - setupDrawDirtyRegionsDisabled(); - setupDrawWithTexture(true); - setupDrawAlpha8Color(paint->getColor(), alpha); - setupDrawColorFilter(); - setupDrawShader(); - setupDrawBlending(true, mode); - setupDrawProgram(); - setupDrawModelView(0.0f, 0.0f, 0.0f, 0.0f, false, true); - // Calling setupDrawTexture with the name 0 will enable the - // uv attributes and increase the texture unit count - // texture binding will be performed by the font renderer as - // needed - setupDrawTexture(0); - setupDrawPureColorUniforms(); - setupDrawColorFilterUniforms(); - setupDrawShaderUniforms(false); - setupDrawTextGammaUniforms(); + TextSetupFunctor functor(this, 0.0f, 0.0f, false, alpha, mode, paint); const Rect* clip = &mSnapshot->getLocalClip(); Rect bounds(FLT_MAX / 2.0f, FLT_MAX / 2.0f, FLT_MIN / 2.0f, FLT_MIN / 2.0f); @@ -3072,7 +3011,7 @@ status_t OpenGLRenderer::drawTextOnPath(const char* text, int bytesCount, int co const bool hasActiveLayer = hasLayer(); if (fontRenderer.renderTextOnPath(paint, clip, text, 0, bytesCount, count, path, - hOffset, vOffset, hasActiveLayer ? &bounds : NULL)) { + hOffset, vOffset, hasActiveLayer ? &bounds : NULL, &functor)) { if (hasActiveLayer) { currentTransform().mapRect(bounds); dirtyLayerUnchecked(bounds, getRegion()); |