diff options
author | Chris Craik <ccraik@google.com> | 2015-02-27 17:04:20 -0800 |
---|---|---|
committer | Chris Craik <ccraik@google.com> | 2015-02-27 17:09:02 -0800 |
commit | 083e733e8223a7d416d6c139f318e61864b28ad6 (patch) | |
tree | 8f5c0e4faf6cf4e6649319b96706286b68e5763d /libs | |
parent | 6b109c74982033d4a220cd10a0eab8b024b351c9 (diff) | |
download | frameworks_base-083e733e8223a7d416d6c139f318e61864b28ad6.zip frameworks_base-083e733e8223a7d416d6c139f318e61864b28ad6.tar.gz frameworks_base-083e733e8223a7d416d6c139f318e61864b28ad6.tar.bz2 |
Cleanup of FontRenderer
Remove invalid and over complicated buffer unbinding
optimization, and simplify constructor.
Change-Id: I3dd90528de4f377e972bbd7967e7e232875387e4
Diffstat (limited to 'libs')
-rw-r--r-- | libs/hwui/FontRenderer.cpp | 49 | ||||
-rw-r--r-- | libs/hwui/OpenGLRenderer.cpp | 23 | ||||
-rwxr-xr-x | libs/hwui/OpenGLRenderer.h | 2 |
3 files changed, 31 insertions, 43 deletions
diff --git a/libs/hwui/FontRenderer.cpp b/libs/hwui/FontRenderer.cpp index 55b2d19..d1d2fcc 100644 --- a/libs/hwui/FontRenderer.cpp +++ b/libs/hwui/FontRenderer.cpp @@ -24,6 +24,7 @@ #include "Rect.h" #include "renderstate/RenderState.h" #include "utils/Blur.h" +#include "utils/MathUtils.h" #include "utils/Timing.h" #include <SkGlyph.h> @@ -47,7 +48,6 @@ namespace uirenderer { // TextSetupFunctor /////////////////////////////////////////////////////////////////////////////// status_t TextSetupFunctor::setup(GLenum glyphFormat) { - renderer->setupDraw(); renderer->setupDrawTextGamma(paint); renderer->setupDrawDirtyRegionsDisabled(); @@ -94,20 +94,23 @@ status_t TextSetupFunctor::setup(GLenum glyphFormat) { static bool sLogFontRendererCreate = true; -FontRenderer::FontRenderer() : - mActiveFonts(LruCache<Font::FontDescription, Font*>::kUnlimitedCapacity) { +FontRenderer::FontRenderer() + : mGammaTable(nullptr) + , mCurrentFont(nullptr) + , mActiveFonts(LruCache<Font::FontDescription, Font*>::kUnlimitedCapacity) + , mCurrentCacheTexture(nullptr) + , mUploadTexture(false) + , mFunctor(nullptr) + , mClip(nullptr) + , mBounds(nullptr) + , mDrawn(false) + , mInitialized(false) + , mLinearFiltering(false) { if (sLogFontRendererCreate) { INIT_LOGD("Creating FontRenderer"); } - mGammaTable = nullptr; - mInitialized = false; - - mCurrentCacheTexture = nullptr; - - mLinearFiltering = false; - mSmallCacheWidth = DEFAULT_TEXT_SMALL_CACHE_WIDTH; mSmallCacheHeight = DEFAULT_TEXT_SMALL_CACHE_HEIGHT; mLargeCacheWidth = DEFAULT_TEXT_LARGE_CACHE_WIDTH; @@ -131,10 +134,11 @@ FontRenderer::FontRenderer() : } uint32_t maxTextureSize = (uint32_t) Caches::getInstance().maxTextureSize; - mSmallCacheWidth = mSmallCacheWidth > maxTextureSize ? maxTextureSize : mSmallCacheWidth; - mSmallCacheHeight = mSmallCacheHeight > maxTextureSize ? maxTextureSize : mSmallCacheHeight; - mLargeCacheWidth = mLargeCacheWidth > maxTextureSize ? maxTextureSize : mLargeCacheWidth; - mLargeCacheHeight = mLargeCacheHeight > maxTextureSize ? maxTextureSize : mLargeCacheHeight; + + mSmallCacheWidth = MathUtils::min(mSmallCacheWidth, maxTextureSize); + mSmallCacheHeight = MathUtils::min(mSmallCacheHeight, maxTextureSize); + mLargeCacheWidth = MathUtils::min(mLargeCacheWidth, maxTextureSize); + mLargeCacheHeight = MathUtils::min(mLargeCacheHeight, maxTextureSize); if (sLogFontRendererCreate) { INIT_LOGD(" Text cache sizes, in pixels: %i x %i, %i x %i, %i x %i, %i x %i", @@ -493,22 +497,19 @@ void FontRenderer::issueDrawCommand(Vector<CacheTexture*>& cacheTextures) { CacheTexture* texture = cacheTextures[i]; if (texture->canDraw()) { if (first) { - if (mFunctor) { - mFunctor->setup(texture->getFormat()); - } + mFunctor->setup(texture->getFormat()); checkTextureUpdate(); renderState.meshState().bindQuadIndicesBuffer(); - if (!mDrawn) { - // If returns true, a VBO was bound and we must - // rebind our vertex attrib pointers even if - // they have the same values as the current pointers - forceRebind = renderState.meshState().unbindMeshBuffer(); - } + // If returns true, a VBO was bound and we must + // rebind our vertex attrib pointers even if + // they have the same values as the current pointers + forceRebind = renderState.meshState().unbindMeshBuffer(); caches.textureState().activateTexture(0); first = false; + mDrawn = true; } caches.textureState().bindTexture(texture->getTextureId()); @@ -531,8 +532,6 @@ void FontRenderer::issueDrawCommand(Vector<CacheTexture*>& cacheTextures) { void FontRenderer::issueDrawCommand() { issueDrawCommand(mACacheTextures); issueDrawCommand(mRGBACacheTextures); - - mDrawn = true; } void FontRenderer::appendMeshQuadNoClip(float x1, float y1, float u1, float v1, diff --git a/libs/hwui/OpenGLRenderer.cpp b/libs/hwui/OpenGLRenderer.cpp index cef3326..dd5c49f 100644 --- a/libs/hwui/OpenGLRenderer.cpp +++ b/libs/hwui/OpenGLRenderer.cpp @@ -1169,7 +1169,7 @@ void OpenGLRenderer::drawRegionRects(const SkRegion& region, const SkPaint& pain } void OpenGLRenderer::dirtyLayer(const float left, const float top, - const float right, const float bottom, const mat4 transform) { + const float right, const float bottom, const Matrix4& transform) { if (hasLayer()) { Rect bounds(left, top, right, bottom); transform.mapRect(bounds); @@ -2805,16 +2805,11 @@ void OpenGLRenderer::drawPosText(const char* text, int bytesCount, int count, TextSetupFunctor functor(this, x, y, pureTranslate, alpha, mode, paint); if (fontRenderer.renderPosText(paint, &clip, text, 0, bytesCount, count, x, y, - positions, hasActiveLayer ? &bounds : nullptr, &functor)) { - if (hasActiveLayer) { - if (!pureTranslate) { - currentTransform()->mapRect(bounds); - } - dirtyLayerUnchecked(bounds, getRegion()); - } + positions, hasLayer() ? &bounds : nullptr, &functor)) { + dirtyLayer(bounds.left, bounds.top, bounds.right, bounds.bottom, *currentTransform()); + mDirty = true; } - mDirty = true; } bool OpenGLRenderer::findBestFontTransform(const mat4& transform, SkMatrix* outMatrix) const { @@ -3011,13 +3006,9 @@ void OpenGLRenderer::drawTextOnPath(const char* text, int bytesCount, int count, if (fontRenderer.renderTextOnPath(paint, clip, text, 0, bytesCount, count, path, hOffset, vOffset, hasActiveLayer ? &bounds : nullptr, &functor)) { - if (hasActiveLayer) { - currentTransform()->mapRect(bounds); - dirtyLayerUnchecked(bounds, getRegion()); - } + dirtyLayer(bounds.left, bounds.top, bounds.right, bounds.bottom, *currentTransform()); + mDirty = true; } - - mDirty = true; } void OpenGLRenderer::drawPath(const SkPath* path, const SkPaint* paint) { @@ -3109,11 +3100,9 @@ void OpenGLRenderer::drawLayer(Layer* layer, float x, float y) { x + layer->layer.getWidth(), y + layer->layer.getHeight()); } - TextureVertex* mesh = &layer->mesh[0]; GLsizei elementsCount = layer->meshElementCount; - while (elementsCount > 0) { GLsizei drawCount = MathUtils::min(elementsCount, (GLsizei) kMaxNumberOfQuads * 6); diff --git a/libs/hwui/OpenGLRenderer.h b/libs/hwui/OpenGLRenderer.h index 63a63b8..e1bef65 100755 --- a/libs/hwui/OpenGLRenderer.h +++ b/libs/hwui/OpenGLRenderer.h @@ -677,7 +677,7 @@ private: * are transformed with the supplied matrix. */ void dirtyLayer(const float left, const float top, - const float right, const float bottom, const mat4 transform); + const float right, const float bottom, const Matrix4& transform); /** * Mark the layer as dirty at the specified coordinates. |