diff options
Diffstat (limited to 'libs')
-rw-r--r-- | libs/hwui/FontRenderer.cpp | 49 | ||||
-rw-r--r-- | libs/hwui/Layer.cpp | 17 | ||||
-rw-r--r-- | libs/hwui/Layer.h | 38 | ||||
-rw-r--r-- | libs/hwui/LayerCache.cpp | 3 | ||||
-rw-r--r-- | libs/hwui/LayerRenderer.cpp | 3 | ||||
-rw-r--r-- | libs/hwui/OpenGLRenderer.cpp | 23 | ||||
-rwxr-xr-x | libs/hwui/OpenGLRenderer.h | 2 | ||||
-rw-r--r-- | libs/hwui/Patch.cpp | 7 | ||||
-rw-r--r-- | libs/hwui/Patch.h | 15 |
9 files changed, 59 insertions, 98 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/Layer.cpp b/libs/hwui/Layer.cpp index 7a026ef..458f35b 100644 --- a/libs/hwui/Layer.cpp +++ b/libs/hwui/Layer.cpp @@ -37,7 +37,7 @@ namespace android { namespace uirenderer { -Layer::Layer(Type layerType, RenderState& renderState, const uint32_t layerWidth, const uint32_t layerHeight) +Layer::Layer(Type layerType, RenderState& renderState, uint32_t layerWidth, uint32_t layerHeight) : state(kState_Uncached) , caches(Caches::getInstance()) , renderState(renderState) @@ -46,24 +46,9 @@ Layer::Layer(Type layerType, RenderState& renderState, const uint32_t layerWidth // TODO: This is a violation of Android's typical ref counting, but it // preserves the old inc/dec ref locations. This should be changed... incStrong(nullptr); - mesh = nullptr; - meshElementCount = 0; - cacheable = true; - dirty = false; renderTarget = GL_TEXTURE_2D; texture.width = layerWidth; texture.height = layerHeight; - colorFilter = nullptr; - deferredUpdateScheduled = false; - renderNode = nullptr; - fbo = 0; - stencil = nullptr; - debugDrawUpdate = false; - hasDrawnSinceUpdate = false; - forceFilter = false; - convexMask = nullptr; - rendererLightPosDirty = true; - wasBuildLayered = false; renderState.registerLayer(this); } diff --git a/libs/hwui/Layer.h b/libs/hwui/Layer.h index 3c1f1d1..b670870 100644 --- a/libs/hwui/Layer.h +++ b/libs/hwui/Layer.h @@ -72,7 +72,7 @@ public: }; State state; // public for logging/debugging purposes - Layer(Type type, RenderState& renderState, const uint32_t layerWidth, const uint32_t layerHeight); + Layer(Type type, RenderState& renderState, uint32_t layerWidth, uint32_t layerHeight); ~Layer(); static uint32_t computeIdealWidth(uint32_t layerWidth); @@ -324,19 +324,19 @@ public: /** * If the layer can be rendered as a mesh, this is non-null. */ - TextureVertex* mesh; - GLsizei meshElementCount; + TextureVertex* mesh = nullptr; + GLsizei meshElementCount = 0; /** * Used for deferred updates. */ - bool deferredUpdateScheduled; + bool deferredUpdateScheduled = false; std::unique_ptr<OpenGLRenderer> renderer; sp<RenderNode> renderNode; Rect dirtyRect; - bool debugDrawUpdate; - bool hasDrawnSinceUpdate; - bool wasBuildLayered; + bool debugDrawUpdate = false; + bool hasDrawnSinceUpdate = false; + bool wasBuildLayered = false; private: void requireRenderer(); @@ -350,17 +350,17 @@ private: * Name of the FBO used to render the layer. If the name is 0 * this layer is not backed by an FBO, but a simple texture. */ - GLuint fbo; + GLuint fbo = 0; /** * The render buffer used as the stencil buffer. */ - RenderBuffer* stencil; + RenderBuffer* stencil = nullptr; /** * Indicates whether this layer has been used already. */ - bool empty; + bool empty = true; /** * The texture backing this layer. @@ -370,7 +370,7 @@ private: /** * If set to true (by default), the layer can be reused. */ - bool cacheable; + bool cacheable = true; /** * Denotes whether the layer is a DisplayList, or Texture layer. @@ -381,32 +381,32 @@ private: * When set to true, this layer is dirty and should be cleared * before any rendering occurs. */ - bool dirty; + bool dirty = false; /** * Indicates the render target. */ - GLenum renderTarget; + GLenum renderTarget = GL_TEXTURE_2D; /** * Color filter used to draw this layer. Optional. */ - SkColorFilter* colorFilter; + SkColorFilter* colorFilter = nullptr; /** * Indicates raster data backing the layer is scaled, requiring filtration. */ - bool forceFilter; + bool forceFilter = false; /** * Opacity of the layer. */ - int alpha; + int alpha = 255; /** * Blending mode of the layer. */ - SkXfermode::Mode mode; + SkXfermode::Mode mode = SkXfermode::kSrcOver_Mode; /** * Optional texture coordinates transform. @@ -422,7 +422,7 @@ private: * Cached transform of layer in window, updated only on creation / resize */ mat4 cachedInvTransformInWindow; - bool rendererLightPosDirty; + bool rendererLightPosDirty = true; /** * Used to defer display lists when the layer is updated with a @@ -435,7 +435,7 @@ private: * * Data not owned/managed by layer object. */ - const SkPath* convexMask; + const SkPath* convexMask = nullptr; }; // struct Layer diff --git a/libs/hwui/LayerCache.cpp b/libs/hwui/LayerCache.cpp index 60d4f4f..bcbd412 100644 --- a/libs/hwui/LayerCache.cpp +++ b/libs/hwui/LayerCache.cpp @@ -116,9 +116,6 @@ Layer* LayerCache::get(RenderState& renderState, const uint32_t width, const uin layer = new Layer(Layer::kType_DisplayList, renderState, entry.mWidth, entry.mHeight); layer->setBlend(true); - layer->setEmpty(true); - layer->setFbo(0); - layer->generateTexture(); layer->bindTexture(); layer->setFilter(GL_NEAREST); diff --git a/libs/hwui/LayerRenderer.cpp b/libs/hwui/LayerRenderer.cpp index 1326206..223bdf0 100644 --- a/libs/hwui/LayerRenderer.cpp +++ b/libs/hwui/LayerRenderer.cpp @@ -275,9 +275,6 @@ Layer* LayerRenderer::createTextureLayer(RenderState& renderState) { Layer* layer = new Layer(Layer::kType_Texture, renderState, 0, 0); layer->setCacheable(false); - layer->setEmpty(true); - layer->setFbo(0); - layer->setAlpha(255, SkXfermode::kSrcOver_Mode); layer->layer.set(0.0f, 0.0f, 0.0f, 0.0f); layer->texCoords.set(0.0f, 1.0f, 1.0f, 0.0f); layer->region.clear(); 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. diff --git a/libs/hwui/Patch.cpp b/libs/hwui/Patch.cpp index 8a4d65b..ce51e04 100644 --- a/libs/hwui/Patch.cpp +++ b/libs/hwui/Patch.cpp @@ -29,13 +29,6 @@ namespace android { namespace uirenderer { /////////////////////////////////////////////////////////////////////////////// -// Constructors/destructor -/////////////////////////////////////////////////////////////////////////////// - -Patch::Patch(): vertices(), verticesCount(0), indexCount(0), hasEmptyQuads(false) { -} - -/////////////////////////////////////////////////////////////////////////////// // Vertices management /////////////////////////////////////////////////////////////////////////////// diff --git a/libs/hwui/Patch.h b/libs/hwui/Patch.h index ea8c8c2..9afb41d 100644 --- a/libs/hwui/Patch.h +++ b/libs/hwui/Patch.h @@ -39,7 +39,7 @@ struct TextureVertex; class Patch { public: - Patch(); + Patch() {} /** * Returns the size of this patch's mesh in bytes. @@ -47,13 +47,14 @@ public: uint32_t getSize() const; std::unique_ptr<TextureVertex[]> vertices; - uint32_t verticesCount; - uint32_t indexCount; - bool hasEmptyQuads; + uint32_t verticesCount = 0; + uint32_t indexCount = 0; + bool hasEmptyQuads = false; Vector<Rect> quads; - GLintptr offset; - GLintptr textureOffset; + Rect bounds; + GLintptr offset = 0; + GLintptr textureOffset = 0; TextureVertex* createMesh(const float bitmapWidth, const float bitmapHeight, float width, float height, const Res_png_9patch* patch); @@ -67,7 +68,7 @@ private: void generateQuad(TextureVertex*& vertex, float x1, float y1, float x2, float y2, float u1, float v1, float u2, float v2, uint32_t& quadCount); - const uint32_t* mColors; + const uint32_t* mColors = nullptr; UvMapper mUvMapper; }; // struct Patch |